mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
snapshot: let virsh edit disk snapshots
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.
This commit is contained in:
parent
203b361f09
commit
731f9a5e56
@ -12869,6 +12869,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virDomainSnapshotFree(snapshot);
|
virDomainSnapshotFree(snapshot);
|
||||||
snapshot = NULL;
|
snapshot = NULL;
|
||||||
|
|
||||||
|
/* strstr is safe here, since xml came from libvirt API and not user */
|
||||||
|
if (strstr(doc, "<state>disk-snapshot</state>"))
|
||||||
|
define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
|
||||||
|
|
||||||
/* Create and open the temporary file. */
|
/* Create and open the temporary file. */
|
||||||
tmp = editWriteToTempFile(ctl, doc);
|
tmp = editWriteToTempFile(ctl, doc);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
@ -12978,6 +12982,9 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
xml = virDomainSnapshotGetXMLDesc(snapshot, VIR_DOMAIN_XML_SECURE);
|
xml = virDomainSnapshotGetXMLDesc(snapshot, VIR_DOMAIN_XML_SECURE);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
/* strstr is safe here, since xml came from libvirt API and not user */
|
||||||
|
if (strstr(xml, "<state>disk-snapshot</state>"))
|
||||||
|
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
|
||||||
snapshot2 = virDomainSnapshotCreateXML(dom, xml, flags);
|
snapshot2 = virDomainSnapshotCreateXML(dom, xml, flags);
|
||||||
if (snapshot2 == NULL)
|
if (snapshot2 == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user