Re: [PATCH 5/5] snapshot: implement getparent in qemu

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

 



On Sat, Sep 24, 2011 at 06:30:06PM -0600, Eric Blake wrote:
> First hypervisor implementation of the new API.
> Allows 'virsh snapshot-list --tree' to be more efficient.
> 
> * src/qemu/qemu_driver.c (qemuDomainSnapshotGetParent): New
> function.
> ---
>  src/qemu/qemu_driver.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 46 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 08310b4..47dde3f 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -9451,6 +9451,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)
>  {
> @@ -10432,6 +10477,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 */

  ACK, any change to get this implemented for other drivers ?

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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