|
|
9119d9 |
From 0c43436d94324c3d4e0ff26c78b549be29f05ddb Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <0c43436d94324c3d4e0ff26c78b549be29f05ddb@dist-git>
|
|
|
9119d9 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
9119d9 |
Date: Mon, 22 Sep 2014 17:52:36 +0200
|
|
|
9119d9 |
Subject: [PATCH] qemu: save image: Split out user provided XML checker
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1142693
|
|
|
9119d9 |
|
|
|
9119d9 |
Extract code used to check save image XMLs provided by users to separate
|
|
|
9119d9 |
use.
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit 92e1df2529f2c18b18c4025795e19e729f60e62e)
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 100 ++++++++++++++++++++++++++++++++-----------------
|
|
|
9119d9 |
1 file changed, 66 insertions(+), 34 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index 98b214a..73aad99 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -5318,6 +5318,68 @@ static int qemuNodeGetSecurityModel(virConnectPtr conn,
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+/**
|
|
|
9119d9 |
+ * qemuDomainSaveImageUpdateDef:
|
|
|
9119d9 |
+ * @driver: qemu driver data
|
|
|
9119d9 |
+ * @def: def of the domain from the save image
|
|
|
9119d9 |
+ * @newxml: user provided replacement XML
|
|
|
9119d9 |
+ *
|
|
|
9119d9 |
+ * Returns the new domain definition in case @newxml is ABI compatible with the
|
|
|
9119d9 |
+ * guest.
|
|
|
9119d9 |
+ */
|
|
|
9119d9 |
+static virDomainDefPtr
|
|
|
9119d9 |
+qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver,
|
|
|
9119d9 |
+ virDomainDefPtr def,
|
|
|
9119d9 |
+ const char *newxml)
|
|
|
9119d9 |
+{
|
|
|
9119d9 |
+ virDomainDefPtr ret = NULL;
|
|
|
9119d9 |
+ virDomainDefPtr newdef_migr = NULL;
|
|
|
9119d9 |
+ virDomainDefPtr newdef = NULL;
|
|
|
9119d9 |
+ virCapsPtr caps = NULL;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (!(newdef = virDomainDefParseString(newxml, caps, driver->xmlopt,
|
|
|
9119d9 |
+ QEMU_EXPECTED_VIRT_TYPES,
|
|
|
9119d9 |
+ VIR_DOMAIN_XML_INACTIVE)))
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (!(newdef_migr = qemuDomainDefCopy(driver,
|
|
|
9119d9 |
+ newdef,
|
|
|
9119d9 |
+ VIR_DOMAIN_XML_MIGRATABLE)))
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ if (!virDomainDefCheckABIStability(def, newdef_migr)) {
|
|
|
9119d9 |
+ virResetLastError();
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ /* Due to a bug in older version of external snapshot creation
|
|
|
9119d9 |
+ * code, the XML saved in the save image was not a migratable
|
|
|
9119d9 |
+ * XML. To ensure backwards compatibility with the change of the
|
|
|
9119d9 |
+ * saved XML type, we need to check the ABI compatibility against
|
|
|
9119d9 |
+ * the user provided XML if the check against the migratable XML
|
|
|
9119d9 |
+ * fails. Snapshots created prior to v1.1.3 have this issue. */
|
|
|
9119d9 |
+ if (!virDomainDefCheckABIStability(def, newdef))
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ /* use the user provided XML */
|
|
|
9119d9 |
+ ret = newdef;
|
|
|
9119d9 |
+ newdef = NULL;
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ ret = newdef_migr;
|
|
|
9119d9 |
+ newdef_migr = NULL;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ cleanup:
|
|
|
9119d9 |
+ virObjectUnref(caps);
|
|
|
9119d9 |
+ virDomainDefFree(newdef);
|
|
|
9119d9 |
+ virDomainDefFree(newdef_migr);
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+ return ret;
|
|
|
9119d9 |
+}
|
|
|
9119d9 |
+
|
|
|
9119d9 |
+
|
|
|
9119d9 |
/* Return -1 on most failures after raising error, -2 if edit was specified
|
|
|
9119d9 |
* but xmlin and state (-1 for no change, 0 for paused, 1 for running) do
|
|
|
9119d9 |
* not represent any changes (no error raised), -3 if corrupt image was
|
|
|
9119d9 |
@@ -5438,45 +5500,15 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
|
|
9119d9 |
QEMU_EXPECTED_VIRT_TYPES,
|
|
|
9119d9 |
VIR_DOMAIN_XML_INACTIVE)))
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
if (xmlin) {
|
|
|
9119d9 |
- virDomainDefPtr def2 = NULL;
|
|
|
9119d9 |
- virDomainDefPtr newdef = NULL;
|
|
|
9119d9 |
+ virDomainDefPtr tmp;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (!(def2 = virDomainDefParseString(xmlin, caps, driver->xmlopt,
|
|
|
9119d9 |
- QEMU_EXPECTED_VIRT_TYPES,
|
|
|
9119d9 |
- VIR_DOMAIN_XML_INACTIVE)))
|
|
|
9119d9 |
+ if (!(tmp = qemuDomainSaveImageUpdateDef(driver, def, xmlin)))
|
|
|
9119d9 |
goto error;
|
|
|
9119d9 |
|
|
|
9119d9 |
- newdef = qemuDomainDefCopy(driver, def2, VIR_DOMAIN_XML_MIGRATABLE);
|
|
|
9119d9 |
- if (!newdef) {
|
|
|
9119d9 |
- virDomainDefFree(def2);
|
|
|
9119d9 |
- goto error;
|
|
|
9119d9 |
- }
|
|
|
9119d9 |
-
|
|
|
9119d9 |
- if (!virDomainDefCheckABIStability(def, newdef)) {
|
|
|
9119d9 |
- virDomainDefFree(newdef);
|
|
|
9119d9 |
- virResetLastError();
|
|
|
9119d9 |
-
|
|
|
9119d9 |
- /* Due to a bug in older version of external snapshot creation
|
|
|
9119d9 |
- * code, the XML saved in the save image was not a migratable
|
|
|
9119d9 |
- * XML. To ensure backwards compatibility with the change of the
|
|
|
9119d9 |
- * saved XML type, we need to check the ABI compatibility against
|
|
|
9119d9 |
- * the user provided XML if the check against the migratable XML
|
|
|
9119d9 |
- * fails. Snapshots created prior to v1.1.3 have this issue. */
|
|
|
9119d9 |
- if (!virDomainDefCheckABIStability(def, def2)) {
|
|
|
9119d9 |
- virDomainDefFree(def2);
|
|
|
9119d9 |
- goto error;
|
|
|
9119d9 |
- }
|
|
|
9119d9 |
-
|
|
|
9119d9 |
- /* use the user provided XML */
|
|
|
9119d9 |
- newdef = def2;
|
|
|
9119d9 |
- def2 = NULL;
|
|
|
9119d9 |
- } else {
|
|
|
9119d9 |
- virDomainDefFree(def2);
|
|
|
9119d9 |
- }
|
|
|
9119d9 |
-
|
|
|
9119d9 |
virDomainDefFree(def);
|
|
|
9119d9 |
- def = newdef;
|
|
|
9119d9 |
+ def = tmp;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_FREE(xml);
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.1
|
|
|
9119d9 |
|