]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuProcessStartWithMemoryState: make it possible to use without data
authorPavel Hrdina <phrdina@redhat.com>
Wed, 27 Sep 2023 09:41:46 +0000 (11:41 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 9 Oct 2023 11:56:50 +0000 (13:56 +0200)
When used with internal snapshots there is no memory state file so we
have no data to load and decompression is not needed.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_process.c

index 6da07f031697bfd360cd277611ad7ccbddf0af90..ae0bb7bf8040a258d2c8cb327be27dbd33c1547a 100644 (file)
@@ -8100,7 +8100,7 @@ qemuProcessStart(virConnectPtr conn,
  * @fd: FD pointer of memory state file
  * @path: path to memory state file
  * @snapshot: internal snapshot to load when starting QEMU process or NULL
- * @data: data from memory state file
+ * @data: data from memory state file or NULL
  * @asyncJob: type of asynchronous job
  * @start_flags: flags to start QEMU process with
  * @reason: audit log reason
@@ -8109,10 +8109,11 @@ qemuProcessStart(virConnectPtr conn,
  * Start VM with existing memory state. Make sure that the stored memory state
  * is correctly decompressed so it can be loaded by QEMU process.
  *
- * When reverting to internal snapshot caller needs to pass @snapshot as well
- * to correctly start QEMU process.
+ * When reverting to internal snapshot caller needs to pass @snapshot
+ * to correctly start QEMU process, @fd, @path, @data needs to be NULL.
  *
- * When restoring VM from saved image @snapshot needs to be NULL.
+ * When restoring VM from saved image caller needs to pass @fd, @path and
+ * @data to correctly start QEMU process, @snapshot needs to be NULL.
  *
  * For audit purposes the expected @reason is one of `restored` or `from-snapshot`.
  *
@@ -8138,9 +8139,16 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
     g_autofree char *errbuf = NULL;
     int rc = 0;
 
-    if (virSaveCookieParseString(data->cookie, (virObject **)&cookie,
-                                 virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
-        return -1;
+    if (data) {
+        if (virSaveCookieParseString(data->cookie, (virObject **)&cookie,
+                                     virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
+            return -1;
+
+        if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd,
+                                            &errbuf, &cmd) < 0) {
+            return -1;
+        }
+    }
 
     if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf, &cmd) < 0)
         return -1;
@@ -8161,7 +8169,10 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
                          start_flags) == 0)
         *started = true;
 
-    rc = qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf, *started, path);
+    if (data) {
+        rc = qemuSaveImageDecompressionStop(cmd, fd, &intermediatefd, errbuf,
+                                            *started, path);
+    }
 
     virDomainAuditStart(vm, reason, *started);
     if (!*started || rc < 0)