[PATCHv2 1/2] qemu: snapshot: Forbid taking snapshot in invalid state

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

 



Similarly to 49a3a649a85f9d3d478be355aa8694bce889586a forbid creating
snapshots in domain states impossible to reach in qemu.
---
 src/qemu/qemu_driver.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1782913..91baa7d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13393,6 +13393,26 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
         goto cleanup;
     }

+    /* allow snapshots only in certain states */
+    switch ((virDomainState) vm->state.state) {
+        /* valid states */
+    case VIR_DOMAIN_RUNNING:
+    case VIR_DOMAIN_PAUSED:
+    case VIR_DOMAIN_SHUTDOWN:
+    case VIR_DOMAIN_SHUTOFF:
+    case VIR_DOMAIN_CRASHED:
+    case VIR_DOMAIN_PMSUSPENDED:
+        break;
+
+        /* invalid states */
+    case VIR_DOMAIN_NOSTATE:
+    case VIR_DOMAIN_BLOCKED: /* invalid state, unused in qemu */
+    case VIR_DOMAIN_LAST:
+        virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"),
+                       virDomainStateTypeToString(vm->state.state));
+        goto cleanup;
+    }
+
     if (redefine) {
         if (!virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
                                            &update_current, flags) < 0)
-- 
2.0.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]