mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh-snapshot: Refactor cmdSnapshotDumpXML
This patch simplifies error paths and switches to use vshCommandOptStringReq for argument retrieval in cmdSnapshotDumpXML
This commit is contained in:
parent
e9dc07393a
commit
351f7a2f2c
@ -1775,31 +1775,26 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptBool(cmd, "security-info"))
|
if (vshCommandOptBool(cmd, "security-info"))
|
||||||
flags |= VIR_DOMAIN_XML_SECURE;
|
flags |= VIR_DOMAIN_XML_SECURE;
|
||||||
|
|
||||||
dom = vshCommandOptDomain(ctl, cmd, NULL);
|
if (vshCommandOptStringReq(ctl, cmd, "snapshotname", &name) < 0)
|
||||||
if (dom == NULL)
|
return false;
|
||||||
|
|
||||||
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(snapshot = virDomainSnapshotLookupByName(dom, name, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (vshCommandOptString(cmd, "snapshotname", &name) <= 0)
|
if (!(xml = virDomainSnapshotGetXMLDesc(snapshot, flags)))
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
snapshot = virDomainSnapshotLookupByName(dom, name, 0);
|
|
||||||
if (snapshot == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
xml = virDomainSnapshotGetXMLDesc(snapshot, flags);
|
|
||||||
if (!xml)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
vshPrint(ctl, "%s", xml);
|
vshPrint(ctl, "%s", xml);
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
if (snapshot)
|
if (snapshot)
|
||||||
virDomainSnapshotFree(snapshot);
|
virDomainSnapshotFree(snapshot);
|
||||||
if (dom)
|
virDomainFree(dom);
|
||||||
virDomainFree(dom);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user