mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 12:22:20 +00:00
Don't force dconn to be NULL in virDomainMigrate
The code for tunnelled migration wierdly required the app to pass a NULL 'dconn' parameter, only to have to use virConnectOpen itself shortly thereafter to get a 'dconn' object. Remove this bogus check & require the app to always pas 'dconn' as before * src/libvirt.c: Require 'dconn' for virDomainMigrate calls again and remove call to virConnectOpen
This commit is contained in:
parent
f6c66d01fb
commit
543e013a15
@ -3058,35 +3058,12 @@ virDomainMigrateVersion2 (virDomainPtr domain,
|
|||||||
*/
|
*/
|
||||||
static virDomainPtr
|
static virDomainPtr
|
||||||
virDomainMigrateTunnelled(virDomainPtr domain,
|
virDomainMigrateTunnelled(virDomainPtr domain,
|
||||||
|
virConnectPtr dconn,
|
||||||
unsigned long flags,
|
unsigned long flags,
|
||||||
const char *dname,
|
const char *dname,
|
||||||
const char *uri,
|
const char *uri,
|
||||||
unsigned long bandwidth)
|
unsigned long bandwidth)
|
||||||
{
|
{
|
||||||
virConnectPtr dconn;
|
|
||||||
virDomainPtr ddomain = NULL;
|
|
||||||
|
|
||||||
if (uri == NULL) {
|
|
||||||
/* if you are doing a secure migration, you *must* also pass a uri */
|
|
||||||
virLibConnError(domain->conn, VIR_ERR_INVALID_ARG,
|
|
||||||
_("requested TUNNELLED migration, but no URI passed"));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (domain->conn->flags & VIR_CONNECT_RO) {
|
|
||||||
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: do we even need this check? In theory, V1 of the protocol
|
|
||||||
* should be able to do tunnelled migration as well
|
|
||||||
*/
|
|
||||||
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
|
|
||||||
VIR_DRV_FEATURE_MIGRATION_V2)) {
|
|
||||||
virLibConnError(domain->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Perform the migration. The driver isn't supposed to return
|
/* Perform the migration. The driver isn't supposed to return
|
||||||
* until the migration is complete.
|
* until the migration is complete.
|
||||||
*/
|
*/
|
||||||
@ -3094,18 +3071,7 @@ virDomainMigrateTunnelled(virDomainPtr domain,
|
|||||||
(domain, NULL, 0, uri, flags, dname, bandwidth) == -1)
|
(domain, NULL, 0, uri, flags, dname, bandwidth) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dconn = virConnectOpen(uri);
|
return virDomainLookupByName(dconn, dname ? dname : domain->name);
|
||||||
if (dconn == NULL)
|
|
||||||
/* FIXME: this is pretty crappy; as far as we know, the migration has
|
|
||||||
* now succeeded, but we can't connect back to the other side
|
|
||||||
*/
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ddomain = virDomainLookupByName(dconn, dname ? dname : domain->name);
|
|
||||||
|
|
||||||
virConnectClose(dconn);
|
|
||||||
|
|
||||||
return ddomain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3182,32 +3148,29 @@ virDomainMigrate (virDomainPtr domain,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_MIGRATE_TUNNELLED) {
|
/* Now checkout the destination */
|
||||||
/* tunnelled migration is more or less a completely different migration
|
if (!VIR_IS_CONNECT(dconn)) {
|
||||||
* protocol. dconn has to be NULL, uri has to be set, and the flow
|
virLibConnError(domain->conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
* of logic is completely different. Hence, here we split off from
|
goto error;
|
||||||
* the main migration flow and use a separate function.
|
|
||||||
*/
|
|
||||||
if (dconn != NULL) {
|
|
||||||
virLibConnError(domain->conn, VIR_ERR_INVALID_ARG,
|
|
||||||
_("requested TUNNELLED migration, but non-NULL dconn"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
ddomain = virDomainMigrateTunnelled(domain, flags, dname, uri, bandwidth);
|
|
||||||
}
|
}
|
||||||
else {
|
if (dconn->flags & VIR_CONNECT_RO) {
|
||||||
/* Now checkout the destination */
|
/* NB, deliberately report error against source object, not dest */
|
||||||
if (!VIR_IS_CONNECT(dconn)) {
|
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
||||||
virLibConnError(domain->conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
goto error;
|
||||||
goto error;
|
}
|
||||||
}
|
|
||||||
if (dconn->flags & VIR_CONNECT_RO) {
|
if (flags & VIR_MIGRATE_TUNNELLED) {
|
||||||
/* NB, deliberately report error against source object, not dest */
|
char *dstURI = NULL;
|
||||||
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
if (uri == NULL) {
|
||||||
goto error;
|
dstURI = virConnectGetURI(dconn);
|
||||||
|
if (!uri)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ddomain = virDomainMigrateTunnelled(domain, dconn, flags, dname, uri ? uri : dstURI, bandwidth);
|
||||||
|
|
||||||
|
VIR_FREE(dstURI);
|
||||||
|
} else {
|
||||||
/* Check that migration is supported by both drivers. */
|
/* Check that migration is supported by both drivers. */
|
||||||
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
|
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
|
||||||
VIR_DRV_FEATURE_MIGRATION_V1) &&
|
VIR_DRV_FEATURE_MIGRATION_V1) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user