mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
snapshot: fix logic bug in qemu undefine
Commit 19f8c98
introduced VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA,
with the intent that omitting the flag makes undefine fail, and
including the flag deletes metadata. But it used the wrong logic.
Also, hoist the transient domain sooner, so that we don't
accidentally remove metadata of a transient domain.
* src/qemu/qemu_driver.c (qemuDomainUndefineFlags): Check correct
flag value.
This commit is contained in:
parent
a55f18929b
commit
e6966fa79a
@ -5095,7 +5095,7 @@ cleanup:
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainUndefineFlags(virDomainPtr dom,
|
qemuDomainUndefineFlags(virDomainPtr dom,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
@ -5118,11 +5118,17 @@ qemuDomainUndefineFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!vm->persistent) {
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("cannot undefine transient domain"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm) &&
|
if (!virDomainObjIsActive(vm) &&
|
||||||
(nsnapshots = virDomainSnapshotObjListNum(&vm->snapshots, 0))) {
|
(nsnapshots = virDomainSnapshotObjListNum(&vm->snapshots, 0))) {
|
||||||
struct snap_remove rem;
|
struct snap_remove rem;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA) {
|
if (!(flags & VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA)) {
|
||||||
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("cannot delete inactive domain with %d "
|
_("cannot delete inactive domain with %d "
|
||||||
"snapshots"),
|
"snapshots"),
|
||||||
@ -5139,12 +5145,6 @@ qemuDomainUndefineFlags(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vm->persistent) {
|
|
||||||
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("cannot undefine transient domain"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = qemuDomainManagedSavePath(driver, vm);
|
name = qemuDomainManagedSavePath(driver, vm);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user