On 08/10/2011 08:32 PM, Daniel Veillard wrote:
On Wed, Aug 10, 2011 at 05:02:36PM -0600, Eric Blake wrote:
Sometimes, full XML is too much; since most snapshot commands
operate on a snapshot name, there should be an easy way to get
at the current snapshot's name.
* tools/virsh.c (cmdSnapshotCurrent): Add an option.
* tools/virsh.pod (snapshot-current): Document it.
---
+ xmldoc = xmlReadDoc((const xmlChar *) xml, "domainsnapshot.xml",
+ NULL, XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ if (!xmldoc)
+ goto cleanup;
+ ctxt = xmlXPathNewContext(xmldoc);
+ if (!ctxt) {
+ xmlFreeDoc(xmldoc);
+ }
I missed a goto cleanup here.
+
+ name = virXPathString("string(/domainsnapshot/name)", ctxt);
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xmldoc);
+ if (!name)
+ goto cleanup;
+ }
+
+ vshPrint(ctl, "%s", name ? name : xml);
as well as a VIR_FREE(name) here to avoid a leak.
ACK, this is really more convenient in most cases,
Pushed with those fixes, and also mentioning a common use case in the
commit message:
virsh snapshot-revert dom `virsh snapshot-current dom --name`
for reverting back to the most recently made snapshot.
--
Eric Blake eblake@xxxxxxxxxx +1-801-349-2682
Libvirt virtualization library http://libvirt.org
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list