mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 05:17:54 +03:00
virsh: checkpoint: remove pointless cleanup labels
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
9c89451dcd
commit
d0a69b2adf
@ -46,19 +46,18 @@ virshCheckpointCreate(vshControl *ctl,
|
|||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
const char *from)
|
const char *from)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
|
|
||||||
checkpoint = virDomainCheckpointCreateXML(dom, buffer, flags);
|
checkpoint = virDomainCheckpointCreateXML(dom, buffer, flags);
|
||||||
|
|
||||||
if (checkpoint == NULL)
|
if (checkpoint == NULL)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
name = virDomainCheckpointGetName(checkpoint);
|
name = virDomainCheckpointGetName(checkpoint);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
vshError(ctl, "%s", _("Could not get checkpoint name"));
|
vshError(ctl, "%s", _("Could not get checkpoint name"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from)
|
if (from)
|
||||||
@ -67,10 +66,7 @@ virshCheckpointCreate(vshControl *ctl,
|
|||||||
else
|
else
|
||||||
vshPrintExtra(ctl, _("Domain checkpoint %s created"), name);
|
vshPrintExtra(ctl, _("Domain checkpoint %s created"), name);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +110,6 @@ cmdCheckpointCreate(vshControl *ctl,
|
|||||||
const vshCmd *cmd)
|
const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = false;
|
|
||||||
const char *from = NULL;
|
const char *from = NULL;
|
||||||
g_autofree char *buffer = NULL;
|
g_autofree char *buffer = NULL;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
@ -129,23 +124,20 @@ cmdCheckpointCreate(vshControl *ctl,
|
|||||||
flags |= VIR_DOMAIN_CHECKPOINT_CREATE_QUIESCE;
|
flags |= VIR_DOMAIN_CHECKPOINT_CREATE_QUIESCE;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "xmlfile", &from) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
if (!from) {
|
if (!from) {
|
||||||
buffer = g_strdup("<domaincheckpoint/>");
|
buffer = g_strdup("<domaincheckpoint/>");
|
||||||
} else {
|
} else {
|
||||||
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
|
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
|
||||||
vshSaveLibvirtError();
|
vshSaveLibvirtError();
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virshCheckpointCreate(ctl, dom, buffer, flags, from);
|
return virshCheckpointCreate(ctl, dom, buffer, flags, from);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +226,6 @@ cmdCheckpointCreateAs(vshControl *ctl,
|
|||||||
const vshCmd *cmd)
|
const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = false;
|
|
||||||
g_autofree char *buffer = NULL;
|
g_autofree char *buffer = NULL;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
const char *desc = NULL;
|
const char *desc = NULL;
|
||||||
@ -250,7 +241,7 @@ cmdCheckpointCreateAs(vshControl *ctl,
|
|||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 ||
|
if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "description", &desc) < 0)
|
vshCommandOptStringReq(ctl, cmd, "description", &desc) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
virBufferAddLit(&buf, "<domaincheckpoint>\n");
|
virBufferAddLit(&buf, "<domaincheckpoint>\n");
|
||||||
virBufferAdjustIndent(&buf, 2);
|
virBufferAdjustIndent(&buf, 2);
|
||||||
@ -262,7 +253,7 @@ cmdCheckpointCreateAs(vshControl *ctl,
|
|||||||
virBufferAdjustIndent(&buf, 2);
|
virBufferAdjustIndent(&buf, 2);
|
||||||
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
|
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
|
||||||
if (virshParseCheckpointDiskspec(ctl, &buf, opt->data) < 0)
|
if (virshParseCheckpointDiskspec(ctl, &buf, opt->data) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
virBufferAdjustIndent(&buf, -2);
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</disks>\n");
|
virBufferAddLit(&buf, "</disks>\n");
|
||||||
@ -274,14 +265,10 @@ cmdCheckpointCreateAs(vshControl *ctl,
|
|||||||
|
|
||||||
if (vshCommandOptBool(cmd, "print-xml")) {
|
if (vshCommandOptBool(cmd, "print-xml")) {
|
||||||
vshPrint(ctl, "%s\n", buffer);
|
vshPrint(ctl, "%s\n", buffer);
|
||||||
ret = true;
|
return true;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virshCheckpointCreate(ctl, dom, buffer, flags, NULL);
|
return virshCheckpointCreate(ctl, dom, buffer, flags, NULL);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -466,7 +453,6 @@ cmdCheckpointInfo(vshControl *ctl,
|
|||||||
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
||||||
const char *name;
|
const char *name;
|
||||||
g_autofree char *parent = NULL;
|
g_autofree char *parent = NULL;
|
||||||
bool ret = false;
|
|
||||||
int count;
|
int count;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
|
||||||
@ -476,7 +462,7 @@ cmdCheckpointInfo(vshControl *ctl,
|
|||||||
|
|
||||||
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
||||||
&checkpoint, &name) < 0)
|
&checkpoint, &name) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
vshPrint(ctl, "%-15s %s\n", _("Name:"), name);
|
vshPrint(ctl, "%-15s %s\n", _("Name:"), name);
|
||||||
vshPrint(ctl, "%-15s %s\n", _("Domain:"), virDomainGetName(dom));
|
vshPrint(ctl, "%-15s %s\n", _("Domain:"), virDomainGetName(dom));
|
||||||
@ -484,7 +470,7 @@ cmdCheckpointInfo(vshControl *ctl,
|
|||||||
if (virshGetCheckpointParent(ctl, checkpoint, &parent) < 0) {
|
if (virshGetCheckpointParent(ctl, checkpoint, &parent) < 0) {
|
||||||
vshError(ctl, "%s",
|
vshError(ctl, "%s",
|
||||||
_("unexpected problem querying checkpoint state"));
|
_("unexpected problem querying checkpoint state"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent : "-");
|
vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent : "-");
|
||||||
|
|
||||||
@ -494,21 +480,18 @@ cmdCheckpointInfo(vshControl *ctl,
|
|||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
||||||
vshResetLibvirtError();
|
vshResetLibvirtError();
|
||||||
ret = true;
|
return true;
|
||||||
}
|
}
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
vshPrint(ctl, "%-15s %d\n", _("Children:"), count);
|
vshPrint(ctl, "%-15s %d\n", _("Children:"), count);
|
||||||
flags = VIR_DOMAIN_CHECKPOINT_LIST_DESCENDANTS;
|
flags = VIR_DOMAIN_CHECKPOINT_LIST_DESCENDANTS;
|
||||||
count = virDomainCheckpointListAllChildren(checkpoint, NULL, flags);
|
count = virDomainCheckpointListAllChildren(checkpoint, NULL, flags);
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
vshPrint(ctl, "%-15s %d\n", _("Descendants:"), count);
|
vshPrint(ctl, "%-15s %d\n", _("Descendants:"), count);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -876,7 +859,6 @@ cmdCheckpointDumpXML(vshControl *ctl,
|
|||||||
const vshCmd *cmd)
|
const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = false;
|
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
||||||
g_autofree char *xml = NULL;
|
g_autofree char *xml = NULL;
|
||||||
@ -894,16 +876,13 @@ cmdCheckpointDumpXML(vshControl *ctl,
|
|||||||
|
|
||||||
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
||||||
&checkpoint, &name) < 0)
|
&checkpoint, &name) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (!(xml = virDomainCheckpointGetXMLDesc(checkpoint, flags)))
|
if (!(xml = virDomainCheckpointGetXMLDesc(checkpoint, flags)))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
vshPrint(ctl, "%s", xml);
|
vshPrint(ctl, "%s", xml);
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -935,32 +914,28 @@ cmdCheckpointParent(vshControl *ctl,
|
|||||||
const vshCmd *cmd)
|
const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = false;
|
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
||||||
g_autofree char *parent = NULL;
|
g_autofree char *parent = NULL;
|
||||||
|
|
||||||
dom = virshCommandOptDomain(ctl, cmd, NULL);
|
dom = virshCommandOptDomain(ctl, cmd, NULL);
|
||||||
if (dom == NULL)
|
if (dom == NULL)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
||||||
&checkpoint, &name) < 0)
|
&checkpoint, &name) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (virshGetCheckpointParent(ctl, checkpoint, &parent) < 0)
|
if (virshGetCheckpointParent(ctl, checkpoint, &parent) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
vshError(ctl, _("checkpoint '%s' has no parent"), name);
|
vshError(ctl, _("checkpoint '%s' has no parent"), name);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrint(ctl, "%s", parent);
|
vshPrint(ctl, "%s", parent);
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1005,18 +980,17 @@ cmdCheckpointDelete(vshControl *ctl,
|
|||||||
const vshCmd *cmd)
|
const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
bool ret = false;
|
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
g_autoptr(virshDomainCheckpoint) checkpoint = NULL;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
dom = virshCommandOptDomain(ctl, cmd, NULL);
|
dom = virshCommandOptDomain(ctl, cmd, NULL);
|
||||||
if (dom == NULL)
|
if (dom == NULL)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
if (virshLookupCheckpoint(ctl, cmd, "checkpointname", dom,
|
||||||
&checkpoint, &name) < 0)
|
&checkpoint, &name) < 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (vshCommandOptBool(cmd, "children"))
|
if (vshCommandOptBool(cmd, "children"))
|
||||||
flags |= VIR_DOMAIN_CHECKPOINT_DELETE_CHILDREN;
|
flags |= VIR_DOMAIN_CHECKPOINT_DELETE_CHILDREN;
|
||||||
@ -1032,13 +1006,10 @@ cmdCheckpointDelete(vshControl *ctl,
|
|||||||
vshPrintExtra(ctl, _("Domain checkpoint %s deleted\n"), name);
|
vshPrintExtra(ctl, _("Domain checkpoint %s deleted\n"), name);
|
||||||
} else {
|
} else {
|
||||||
vshError(ctl, _("Failed to delete checkpoint %s"), name);
|
vshError(ctl, _("Failed to delete checkpoint %s"), name);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user