]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuProcessStartWithMemoryState: add snapshot argument
authorPavel Hrdina <phrdina@redhat.com>
Mon, 18 Sep 2023 12:28:45 +0000 (14:28 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 9 Oct 2023 11:56:49 +0000 (13:56 +0200)
When called from snapshot code we will need to pass snapshot object in
order to make internal snapshots work correctly.

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

index 2689cc73f64259df5d415969afbba74b3c803e53..6da07f031697bfd360cd277611ad7ccbddf0af90 100644 (file)
@@ -8099,6 +8099,7 @@ qemuProcessStart(virConnectPtr conn,
  * @vm: domain object
  * @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
  * @asyncJob: type of asynchronous job
  * @start_flags: flags to start QEMU process with
@@ -8108,6 +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 restoring VM from saved image @snapshot needs to be NULL.
+ *
  * For audit purposes the expected @reason is one of `restored` or `from-snapshot`.
  *
  * Returns 0 on success, -1 on error.
@@ -8118,6 +8124,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
                                 virDomainObj *vm,
                                 int *fd,
                                 const char *path,
+                                virDomainMomentObj *snapshot,
                                 virQEMUSaveData *data,
                                 virDomainAsyncJob asyncJob,
                                 unsigned int start_flags,
@@ -8149,7 +8156,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
         priv->disableSlirp = true;
 
     if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL,
-                         asyncJob, "stdio", *fd, path, NULL,
+                         asyncJob, "stdio", *fd, path, snapshot,
                          VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
                          start_flags) == 0)
         *started = true;
index c965eba3a6adfd24aefd040147519062df104a06..ef05b4689218eac5e89639881316c95734d09fca 100644 (file)
@@ -96,6 +96,7 @@ int qemuProcessStartWithMemoryState(virConnectPtr conn,
                                     virDomainObj *vm,
                                     int *fd,
                                     const char *path,
+                                    virDomainMomentObj *snapshot,
                                     virQEMUSaveData *data,
                                     virDomainAsyncJob asyncJob,
                                     unsigned int start_flags,
index 92dcf4b616e4021af030a82e6e7ac87e1c1864e9..89112e3e4488452351755538b4d05a955b9e2a7f 100644 (file)
@@ -698,7 +698,7 @@ qemuSaveImageStartVM(virConnectPtr conn,
     if (reset_nvram)
         start_flags |= VIR_QEMU_PROCESS_START_RESET_NVRAM;
 
-    if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, data,
+    if (qemuProcessStartWithMemoryState(conn, driver, vm, fd, path, NULL, data,
                                         asyncJob, start_flags, "restored",
                                         &started) < 0) {
         goto cleanup;