Update the qemuDomainMigrateBegin method so that it accepts
an optional incoming XML document. This will be validated
for ABI compatibility against the current domain config,
and if this check passes, will be passed back out for use
by the qemuDomainMigratePrepare method on the target
* src/qemu/qemu_domain.c, src/qemu/qemu_domain.h,
src/qemu/qemu_migration.c: Allow custom XML to be passed
---
src/qemu/qemu_domain.c | 26 ++++++++++++++++++--------
src/qemu/qemu_domain.h | 4 ++++
src/qemu/qemu_migration.c | 27 ++++++++++++++++++---------
3 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bcacb18..ddf9e65 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -686,19 +686,14 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
}
-char *qemuDomainFormatXML(struct qemud_driver *driver,
- virDomainObjPtr vm,
- int flags)
+char *qemuDomainDefFormatXML(struct qemud_driver *driver,
+ virDomainDefPtr def,
+ int flags)
{
char *ret = NULL;
virCPUDefPtr cpu = NULL;
- virDomainDefPtr def;
virCPUDefPtr def_cpu;
- if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef)
- def = vm->newDef;
- else
- def = vm->def;
def_cpu = def->cpu;
/* Update guest CPU requirements according to host CPU */
@@ -723,6 +718,21 @@ cleanup:
return ret;
}
+char *qemuDomainFormatXML(struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ int flags)
+{
+ virDomainDefPtr def;
+
+ if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef)
+ def = vm->newDef;
+ else
+ def = vm->def;
+
+ return qemuDomainDefFormatXML(driver, def, flags);
+}
+
+
void qemuDomainObjTaint(struct qemud_driver *driver,
virDomainObjPtr obj,
enum virDomainTaintFlags taint,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 6d24f53..ac60b7e 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -111,6 +111,10 @@ void qemuDomainObjEnterRemoteWithDriver(struct qemud_driver *driver,
void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
virDomainObjPtr obj);
+char *qemuDomainDefFormatXML(struct qemud_driver *driver,
+ virDomainDefPtr vm,
+ int flags);
+
char *qemuDomainFormatXML(struct qemud_driver *driver,
virDomainObjPtr vm,
int flags);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 2f0ed28..8ebbda1 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -875,15 +875,10 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
{
char *rv = NULL;
qemuMigrationCookiePtr mig = NULL;
+ virDomainDefPtr def = NULL;
VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, cookieout=%p, cookieoutlen=%p",
driver, vm, NULLSTR(xmlin), cookieout, cookieoutlen);
- if (xmlin) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Passing XML for the target VM is not yet
supported"));
- goto cleanup;
- }
-
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
@@ -901,13 +896,27 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
0) < 0)
goto cleanup;
- rv = qemuDomainFormatXML(driver, vm,
- VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_UPDATE_CPU);
+ if (xmlin) {
+ if (!(def = virDomainDefParseString(driver->caps, xmlin,
+ VIR_DOMAIN_XML_INACTIVE)))
+ goto cleanup;
+
+ if (!virDomainDefCheckABIStability(def, vm->def))
+ goto cleanup;
+
+ rv = qemuDomainDefFormatXML(driver, def,
+ VIR_DOMAIN_XML_SECURE |
+ VIR_DOMAIN_XML_UPDATE_CPU);
+ } else {
+ rv = qemuDomainFormatXML(driver, vm,
+ VIR_DOMAIN_XML_SECURE |
+ VIR_DOMAIN_XML_UPDATE_CPU);
+ }
cleanup:
virDomainObjUnlock(vm);
qemuMigrationCookieFree(mig);
+ virDomainDefFree(def);
return rv;
}
--
1.7.4.4