提交 7afa6b41 编写于 作者: E Eric Blake

snapshot: let qemu discard only snapshot metadata

Adding this was trivial compared to the previous patch for fixing
qemu snapshot deletion in the first place.

* src/qemu/qemu_driver.c (qemuDomainSnapshotDiscard): Add
parameter.
(qemuDomainSnapshotDiscardDescendant, qemuDomainSnapshotDelete):
Update callers.
上级 795fe9b2
...@@ -9171,23 +9171,26 @@ static int ...@@ -9171,23 +9171,26 @@ static int
qemuDomainSnapshotDiscard(struct qemud_driver *driver, qemuDomainSnapshotDiscard(struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainSnapshotObjPtr snap, virDomainSnapshotObjPtr snap,
bool update_current) bool update_current,
bool metadata_only)
{ {
char *snapFile = NULL; char *snapFile = NULL;
int ret = -1; int ret = -1;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
virDomainSnapshotObjPtr parentsnap = NULL; virDomainSnapshotObjPtr parentsnap = NULL;
if (!virDomainObjIsActive(vm)) { if (!metadata_only) {
/* Ignore any skipped disks */ if (!virDomainObjIsActive(vm)) {
if (qemuDomainSnapshotForEachQcow2(vm, snap, "-d", true) < 0) /* Ignore any skipped disks */
goto cleanup; if (qemuDomainSnapshotForEachQcow2(vm, snap, "-d", true) < 0)
} else { goto cleanup;
priv = vm->privateData; } else {
qemuDomainObjEnterMonitorWithDriver(driver, vm); priv = vm->privateData;
/* we continue on even in the face of error */ qemuDomainObjEnterMonitorWithDriver(driver, vm);
qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); /* we continue on even in the face of error */
qemuDomainObjExitMonitorWithDriver(driver, vm); qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
qemuDomainObjExitMonitorWithDriver(driver, vm);
}
} }
if (virAsprintf(&snapFile, "%s/%s/%s.xml", driver->snapshotDir, if (virAsprintf(&snapFile, "%s/%s/%s.xml", driver->snapshotDir,
...@@ -9232,6 +9235,7 @@ cleanup: ...@@ -9232,6 +9235,7 @@ cleanup:
struct snap_remove { struct snap_remove {
struct qemud_driver *driver; struct qemud_driver *driver;
virDomainObjPtr vm; virDomainObjPtr vm;
bool metadata_only;
int err; int err;
bool current; bool current;
}; };
...@@ -9247,7 +9251,8 @@ qemuDomainSnapshotDiscardDescendant(void *payload, ...@@ -9247,7 +9251,8 @@ qemuDomainSnapshotDiscardDescendant(void *payload,
if (snap->def->current) if (snap->def->current)
curr->current = true; curr->current = true;
err = qemuDomainSnapshotDiscard(curr->driver, curr->vm, snap, false); err = qemuDomainSnapshotDiscard(curr->driver, curr->vm, snap, false,
curr->metadata_only);
if (err && !curr->err) if (err && !curr->err)
curr->err = err; curr->err = err;
} }
...@@ -9297,8 +9302,10 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, ...@@ -9297,8 +9302,10 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
struct snap_remove rem; struct snap_remove rem;
struct snap_reparent rep; struct snap_reparent rep;
bool metadata_only = !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY);
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1); virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1);
qemuDriverLock(driver); qemuDriverLock(driver);
virUUIDFormat(snapshot->domain->uuid, uuidstr); virUUIDFormat(snapshot->domain->uuid, uuidstr);
...@@ -9323,6 +9330,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, ...@@ -9323,6 +9330,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) { if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) {
rem.driver = driver; rem.driver = driver;
rem.vm = vm; rem.vm = vm;
rem.metadata_only = metadata_only;
rem.err = 0; rem.err = 0;
rem.current = false; rem.current = false;
virDomainSnapshotForEachDescendant(&vm->snapshots, virDomainSnapshotForEachDescendant(&vm->snapshots,
...@@ -9345,7 +9353,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, ...@@ -9345,7 +9353,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
goto endjob; goto endjob;
} }
ret = qemuDomainSnapshotDiscard(driver, vm, snap, true); ret = qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
endjob: endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) if (qemuDomainObjEndJob(driver, vm) == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册