Re: [PATCH 1/2] snapshot: let virsh edit disk snapshots

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

 



On Thu, Oct 06, 2011 at 05:18:33PM -0600, Eric Blake wrote:
> It was impossible for 'virsh snapshot-current dom name' to set name
> as the current snapshot, if name is a disk-only snapshot.
> 
> Using strstr rather than full-blown xml parsing is safe, since the
> xml is assumed to be well-formed coming from libvirtd rather than
> arbitrary text coming from the user.
> 
> * tools/virsh.c (cmdSnapshotCurrent, cmdSnapshotEdit): Pass
> disk_only flag when redefining a disk snapshot.
> ---
>  tools/virsh.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 48f2b8a..70a4078 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -12869,6 +12869,9 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
>      virDomainSnapshotFree(snapshot);
>      snapshot = NULL;
> 
> +    if (strstr(doc, "<state>disk-snapshot</state>"))
> +        define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
> +

 ahum, but okay ... maybe a small comment in the code

>      /* Create and open the temporary file.  */
>      tmp = editWriteToTempFile(ctl, doc);
>      if (!tmp)
> @@ -12978,6 +12981,8 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
>          xml = virDomainSnapshotGetXMLDesc(snapshot, VIR_DOMAIN_XML_SECURE);
>          if (!xml)
>              goto cleanup;
> +        if (strstr(xml, "<state>disk-snapshot</state>"))
> +            flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;

  same,

>          snapshot2 = virDomainSnapshotCreateXML(dom, xml, flags);
>          if (snapshot2 == NULL)
>              goto cleanup;

  ACK,

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]