[libvirt] [PATCH] Reject migration with both --live and --offline when migration requested from other clients/API.

--- src/libvirt-domain.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 9491845..6a5034e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -3616,6 +3616,13 @@ virDomainMigrate(virDomainPtr domain, VIR_MIGRATE_NON_SHARED_INC, error); + if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Options --live and --offline are " + "mutually exclusive")); + goto error; + } + if (flags & VIR_MIGRATE_OFFLINE) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { @@ -3840,6 +3847,13 @@ virDomainMigrate2(virDomainPtr domain, VIR_MIGRATE_NON_SHARED_INC, error); + if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Options --live and --offline are " + "mutually exclusive")); + goto error; + } + if (flags & VIR_MIGRATE_OFFLINE) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) { @@ -4014,6 +4028,13 @@ virDomainMigrate3(virDomainPtr domain, VIR_MIGRATE_NON_SHARED_INC, error); + if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Options --live and --offline are " + "mutually exclusive")); + goto error; + } + if (flags & VIR_MIGRATE_PEER2PEER) { virReportInvalidArg(flags, "%s", _("use virDomainMigrateToURI3 for peer-to-peer " -- 1.8.3.1

The subject is too long, it should be shorter than 65 characters. On Thu, Mar 03, 2016 at 01:11:50 -0500, Nitesh Konkar wrote:
--- src/libvirt-domain.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 9491845..6a5034e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -3616,6 +3616,13 @@ virDomainMigrate(virDomainPtr domain, VIR_MIGRATE_NON_SHARED_INC, error);
+ if ((flags & VIR_MIGRATE_OFFLINE) && (flags & VIR_MIGRATE_LIVE)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("Options --live and --offline are " + "mutually exclusive")); + goto error; + } +
The APIs have no --live or --offline options, you should rewrite the message without using virsh syntax. And moving this check inside the "if (flags & VIR_MIGRATE_OFFLINE)" block below would be a bit better I think.
if (flags & VIR_MIGRATE_OFFLINE) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
... The same comment applies to all instances. Jirka
participants (2)
-
Jiri Denemark
-
Nitesh Konkar