]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: checkpoint: Prepare internals for missing domain definition
authorPeter Krempa <pkrempa@redhat.com>
Wed, 2 Dec 2020 13:13:17 +0000 (14:13 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 4 Dec 2020 15:15:03 +0000 (16:15 +0100)
Conditionalize code which assumes that the domain definition stored in
the checkpoint is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/checkpoint_conf.c
tests/qemudomaincheckpointxml2xmltest.c

index 58e27c19b32909c493bb43a8486d320be14d5153..665beb3da40932580fe69bbe924b2eec7b829172 100644 (file)
@@ -460,10 +460,10 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf,
         virBufferAddLit(buf, "</disks>\n");
     }
 
-    if (!(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN) &&
-        virDomainDefFormatInternal(def->parent.dom, xmlopt,
-                                   buf, domainflags) < 0)
-        return -1;
+    if (def->parent.dom && !(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN)) {
+        if (virDomainDefFormatInternal(def->parent.dom, xmlopt, buf, domainflags) < 0)
+            return -1;
+    }
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</domaincheckpoint>\n");
@@ -495,23 +495,24 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm,
                                 virDomainCheckpointDefPtr def,
                                 bool *update_current)
 {
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
     virDomainMomentObjPtr parent = NULL;
 
-    virUUIDFormat(vm->def->uuid, uuidstr);
-
     if (virDomainCheckpointCheckCycles(vm->checkpoints, def, vm->def->name) < 0)
         return -1;
 
-    if (!def->parent.dom ||
-        memcmp(def->parent.dom->uuid, vm->def->uuid, VIR_UUID_BUFLEN)) {
-        virReportError(VIR_ERR_INVALID_ARG,
-                       _("definition for checkpoint %s must use uuid %s"),
-                       def->parent.name, uuidstr);
-        return -1;
+    if (def->parent.dom) {
+        if (memcmp(def->parent.dom->uuid, vm->def->uuid, VIR_UUID_BUFLEN)) {
+            char uuidstr[VIR_UUID_STRING_BUFLEN];
+            virUUIDFormat(vm->def->uuid, uuidstr);
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("definition for checkpoint %s must use uuid %s"),
+                           def->parent.name, uuidstr);
+            return -1;
+        }
+
+        if (virDomainCheckpointAlignDisks(def) < 0)
+            return -1;
     }
-    if (virDomainCheckpointAlignDisks(def) < 0)
-        return -1;
 
     if (def->parent.parent_name &&
          (parent = virDomainCheckpointFindByName(vm->checkpoints,
index a5a5b5920537b3c2ec6c24ab68716f778b207850..8b4b75d753b3a6ca6fef73a9f129905c796470e3 100644 (file)
@@ -87,11 +87,6 @@ testCompareXMLToXMLFiles(const char *inxml,
         formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE;
     }
 
-    /* Parsing XML does not populate the domain definition; work
-     * around that by not requesting domain on output */
-    if (!def->parent.dom)
-        formatflags |= VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN;
-
     if (!(actual = virDomainCheckpointDefFormat(def,
                                                 driver.xmlopt,
                                                 formatflags)))