[libvirt PATCH v3 06/10] qemuProcessStartWithMemoryState: make it possible to use without data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c8430bf7b7..f96918073f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8165,7 +8165,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
@@ -8175,7 +8175,8 @@ qemuProcessStart(virConnectPtr conn,
  * is correctly decompressed so it can be loaded by QEMU process.
  *
  * When reverting to internal snapshot callers needs to pass @snapshot as well
- * correctly start QEMU process.
+ * correctly start QEMU process. In addition there is no memory state file so
+ * it's safe to pass NULL as @data.
  *
  * When restoring VM from saved image @snapshot needs to be NULL.
  *
@@ -8203,9 +8204,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;
@@ -8226,7 +8234,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)
-- 
2.41.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux