|
|
a41c76 |
From c5cdebd40024c33675f93b47732869c658204056 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <c5cdebd40024c33675f93b47732869c658204056@dist-git>
|
|
|
a41c76 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
Date: Thu, 16 Jan 2020 10:03:53 +0100
|
|
|
a41c76 |
Subject: [PATCH] qemu: Use g_autoptr() for qemuDomainSaveCookie
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
a41c76 |
|
|
|
a41c76 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1718707
|
|
|
a41c76 |
|
|
|
a41c76 |
(cherry picked from commit 3203ad6cfd617fb11d4bb47e514c370b6624641b)
|
|
|
a41c76 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
Message-Id: <5e58b5853f9bd1a2b5109145afdad190071f5c44.1579165329.git.mprivozn@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/qemu/qemu_domain.c | 28 ++++++++++------------------
|
|
|
a41c76 |
src/qemu/qemu_domain.h | 1 +
|
|
|
a41c76 |
src/qemu/qemu_driver.c | 6 ++----
|
|
|
a41c76 |
3 files changed, 13 insertions(+), 22 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
a41c76 |
index 0edf316fff..91a9f0481b 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_domain.c
|
|
|
a41c76 |
+++ b/src/qemu/qemu_domain.c
|
|
|
a41c76 |
@@ -16001,27 +16001,23 @@ qemuDomainSaveCookiePtr
|
|
|
a41c76 |
qemuDomainSaveCookieNew(virDomainObjPtr vm)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
a41c76 |
- qemuDomainSaveCookiePtr cookie = NULL;
|
|
|
a41c76 |
+ g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (qemuDomainInitialize() < 0)
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (priv->origCPU && !(cookie->cpu = virCPUDefCopy(vm->def->cpu)))
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
cookie->slirpHelper = qemuDomainGetSlirpHelperOk(vm);
|
|
|
a41c76 |
|
|
|
a41c76 |
VIR_DEBUG("Save cookie %p, cpu=%p, slirpHelper=%d",
|
|
|
a41c76 |
cookie, cookie->cpu, cookie->slirpHelper);
|
|
|
a41c76 |
|
|
|
a41c76 |
- return cookie;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- error:
|
|
|
a41c76 |
- virObjectUnref(cookie);
|
|
|
a41c76 |
- return NULL;
|
|
|
a41c76 |
+ return g_steal_pointer(&cookie);
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -16029,26 +16025,22 @@ static int
|
|
|
a41c76 |
qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED,
|
|
|
a41c76 |
virObjectPtr *obj)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
- qemuDomainSaveCookiePtr cookie = NULL;
|
|
|
a41c76 |
+ g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (qemuDomainInitialize() < 0)
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST,
|
|
|
a41c76 |
&cookie->cpu) < 0)
|
|
|
a41c76 |
- goto error;
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
cookie->slirpHelper = virXPathBoolean("boolean(./slirpHelper)", ctxt) > 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
- *obj = (virObjectPtr) cookie;
|
|
|
a41c76 |
+ *obj = (virObjectPtr) g_steal_pointer(&cookie);
|
|
|
a41c76 |
return 0;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- error:
|
|
|
a41c76 |
- virObjectUnref(cookie);
|
|
|
a41c76 |
- return -1;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
a41c76 |
index c6afc484f6..60b80297fa 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_domain.h
|
|
|
a41c76 |
+++ b/src/qemu/qemu_domain.h
|
|
|
a41c76 |
@@ -610,6 +610,7 @@ struct _qemuDomainSaveCookie {
|
|
|
a41c76 |
bool slirpHelper;
|
|
|
a41c76 |
};
|
|
|
a41c76 |
|
|
|
a41c76 |
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainSaveCookie, virObjectUnref);
|
|
|
a41c76 |
|
|
|
a41c76 |
typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef;
|
|
|
a41c76 |
typedef qemuDomainXmlNsDef *qemuDomainXmlNsDefPtr;
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
a41c76 |
index e1c0550b9a..ce9b1772c1 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_driver.c
|
|
|
a41c76 |
+++ b/src/qemu/qemu_driver.c
|
|
|
a41c76 |
@@ -3293,7 +3293,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
|
|
a41c76 |
virObjectEventPtr event = NULL;
|
|
|
a41c76 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
a41c76 |
virQEMUSaveDataPtr data = NULL;
|
|
|
a41c76 |
- qemuDomainSaveCookiePtr cookie = NULL;
|
|
|
a41c76 |
+ g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
|
|
|
a41c76 |
goto cleanup;
|
|
|
a41c76 |
@@ -3399,7 +3399,6 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
|
|
a41c76 |
qemuDomainRemoveInactiveJob(driver, vm);
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
- virObjectUnref(cookie);
|
|
|
a41c76 |
virQEMUSaveDataFree(data);
|
|
|
a41c76 |
virObjectEventStateQueue(driver->domainEventState, event);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
@@ -6808,7 +6807,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
|
|
a41c76 |
g_autofree char *errbuf = NULL;
|
|
|
a41c76 |
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
|
a41c76 |
virQEMUSaveHeaderPtr header = &data->header;
|
|
|
a41c76 |
- qemuDomainSaveCookiePtr cookie = NULL;
|
|
|
a41c76 |
+ g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie,
|
|
|
a41c76 |
virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
|
|
|
a41c76 |
@@ -6919,7 +6918,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
|
|
a41c76 |
ret = 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
- virObjectUnref(cookie);
|
|
|
a41c76 |
if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0)
|
|
|
a41c76 |
VIR_WARN("failed to restore save state label on %s", path);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.25.0
|
|
|
a41c76 |
|