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