From: Peter Krempa Date: Thu, 26 Sep 2019 11:19:40 +0000 (+0200) Subject: qemu: checkpoint: Refactor cleanup in qemuCheckpointCreateXML X-Git-Tag: v5.8.0-rc1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34cb003d09e2f3959d58fb859ea74b8142f2b30b;p=thirdparty%2Flibvirt.git qemu: checkpoint: Refactor cleanup in qemuCheckpointCreateXML Use VIR_AUTO* helpers and get rid of the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 4f14dcef08..76abd4154a 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -364,9 +364,9 @@ qemuCheckpointCreateXML(virDomainPtr domain, bool redefine = flags & VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE; unsigned int parse_flags = 0; virDomainMomentObjPtr other = NULL; - virQEMUDriverConfigPtr cfg = NULL; - virCapsPtr caps = NULL; - virJSONValuePtr actions = NULL; + VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL; + VIR_AUTOUNREF(virCapsPtr) caps = NULL; + VIR_AUTOPTR(virJSONValue) actions = NULL; int ret; VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL; @@ -381,32 +381,32 @@ qemuCheckpointCreateXML(virDomainPtr domain, if (virDomainSnapshotObjListNum(vm->snapshots, NULL, 0) > 0) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot create checkpoint while snapshot exists")); - goto cleanup; + return NULL; } if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BITMAP_MERGE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("qemu binary lacks persistent bitmaps support")); - goto cleanup; + return NULL; } if (!(caps = virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; + return NULL; if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot create checkpoint for inactive domain")); - goto cleanup; + return NULL; } if (!(def = virDomainCheckpointDefParseString(xmlDesc, caps, driver->xmlopt, priv->qemuCaps, parse_flags))) - goto cleanup; + return NULL; /* Unlike snapshots, the RNG schema already ensured a sane filename. */ /* We are going to modify the domain below. */ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; + return NULL; if (redefine) { if (virDomainCheckpointRedefinePrep(vm, &def, &chk, @@ -485,10 +485,6 @@ qemuCheckpointCreateXML(virDomainPtr domain, qemuDomainObjEndJob(driver, vm); - cleanup: - virJSONValueFree(actions); - virObjectUnref(caps); - virObjectUnref(cfg); return checkpoint; }