mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
snapshot: implement getparent in qemu
First hypervisor implementation of the new API. Allows 'virsh snapshot-list --tree' to be more efficient. * src/qemu/qemu_driver.c (qemuDomainSnapshotGetParent): New function.
This commit is contained in:
parent
1cf0e3db8b
commit
4ee8092dde
@ -9450,6 +9450,51 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static virDomainSnapshotPtr
|
||||
qemuDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct qemud_driver *driver = snapshot->domain->conn->privateData;
|
||||
virDomainObjPtr vm;
|
||||
virDomainSnapshotObjPtr snap = NULL;
|
||||
virDomainSnapshotPtr parent = NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
qemuDriverLock(driver);
|
||||
vm = virDomainFindByUUID(&driver->domains, snapshot->domain->uuid);
|
||||
if (!vm) {
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
||||
qemuReportError(VIR_ERR_NO_DOMAIN,
|
||||
_("no domain with matching uuid '%s'"), uuidstr);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
snap = virDomainSnapshotFindByName(&vm->snapshots, snapshot->name);
|
||||
if (!snap) {
|
||||
qemuReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
|
||||
_("no domain snapshot with matching name '%s'"),
|
||||
snapshot->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!snap->def->parent) {
|
||||
qemuReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
|
||||
_("snapshot '%s' does not have a parent"),
|
||||
snap->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
parent = virGetDomainSnapshot(snapshot->domain, snap->def->parent);
|
||||
|
||||
cleanup:
|
||||
if (vm)
|
||||
virDomainObjUnlock(vm);
|
||||
qemuDriverUnlock(driver);
|
||||
return parent;
|
||||
}
|
||||
|
||||
static virDomainSnapshotPtr qemuDomainSnapshotCurrent(virDomainPtr domain,
|
||||
unsigned int flags)
|
||||
{
|
||||
@ -10431,6 +10476,7 @@ static virDriver qemuDriver = {
|
||||
.domainSnapshotListNames = qemuDomainSnapshotListNames, /* 0.8.0 */
|
||||
.domainSnapshotLookupByName = qemuDomainSnapshotLookupByName, /* 0.8.0 */
|
||||
.domainHasCurrentSnapshot = qemuDomainHasCurrentSnapshot, /* 0.8.0 */
|
||||
.domainSnapshotGetParent = qemuDomainSnapshotGetParent, /* 0.9.7 */
|
||||
.domainSnapshotCurrent = qemuDomainSnapshotCurrent, /* 0.8.0 */
|
||||
.domainRevertToSnapshot = qemuDomainRevertToSnapshot, /* 0.8.0 */
|
||||
.domainSnapshotDelete = qemuDomainSnapshotDelete, /* 0.8.0 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user