mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-30 04:21:17 +00:00
qemu: Use g_autoptr() for qemuDomainSaveCookie
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
82e127e343
commit
3203ad6cfd
@ -15997,27 +15997,23 @@ qemuDomainSaveCookiePtr
|
|||||||
qemuDomainSaveCookieNew(virDomainObjPtr vm)
|
qemuDomainSaveCookieNew(virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
qemuDomainSaveCookiePtr cookie = NULL;
|
g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
||||||
|
|
||||||
if (qemuDomainInitialize() < 0)
|
if (qemuDomainInitialize() < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if (priv->origCPU && !(cookie->cpu = virCPUDefCopy(vm->def->cpu)))
|
if (priv->origCPU && !(cookie->cpu = virCPUDefCopy(vm->def->cpu)))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
cookie->slirpHelper = qemuDomainGetSlirpHelperOk(vm);
|
cookie->slirpHelper = qemuDomainGetSlirpHelperOk(vm);
|
||||||
|
|
||||||
VIR_DEBUG("Save cookie %p, cpu=%p, slirpHelper=%d",
|
VIR_DEBUG("Save cookie %p, cpu=%p, slirpHelper=%d",
|
||||||
cookie, cookie->cpu, cookie->slirpHelper);
|
cookie, cookie->cpu, cookie->slirpHelper);
|
||||||
|
|
||||||
return cookie;
|
return g_steal_pointer(&cookie);
|
||||||
|
|
||||||
error:
|
|
||||||
virObjectUnref(cookie);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -16025,26 +16021,22 @@ static int
|
|||||||
qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED,
|
qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED,
|
||||||
virObjectPtr *obj)
|
virObjectPtr *obj)
|
||||||
{
|
{
|
||||||
qemuDomainSaveCookiePtr cookie = NULL;
|
g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
||||||
|
|
||||||
if (qemuDomainInitialize() < 0)
|
if (qemuDomainInitialize() < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST,
|
if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST,
|
||||||
&cookie->cpu) < 0)
|
&cookie->cpu) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
cookie->slirpHelper = virXPathBoolean("boolean(./slirpHelper)", ctxt) > 0;
|
cookie->slirpHelper = virXPathBoolean("boolean(./slirpHelper)", ctxt) > 0;
|
||||||
|
|
||||||
*obj = (virObjectPtr) cookie;
|
*obj = (virObjectPtr) g_steal_pointer(&cookie);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
virObjectUnref(cookie);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -610,6 +610,7 @@ struct _qemuDomainSaveCookie {
|
|||||||
bool slirpHelper;
|
bool slirpHelper;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainSaveCookie, virObjectUnref);
|
||||||
|
|
||||||
typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef;
|
typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef;
|
||||||
typedef qemuDomainXmlNsDef *qemuDomainXmlNsDefPtr;
|
typedef qemuDomainXmlNsDef *qemuDomainXmlNsDefPtr;
|
||||||
|
@ -3293,7 +3293,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
|||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virQEMUSaveDataPtr data = NULL;
|
virQEMUSaveDataPtr data = NULL;
|
||||||
qemuDomainSaveCookiePtr cookie = NULL;
|
g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
||||||
|
|
||||||
if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
|
if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3399,7 +3399,6 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
|||||||
qemuDomainRemoveInactiveJob(driver, vm);
|
qemuDomainRemoveInactiveJob(driver, vm);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(cookie);
|
|
||||||
virQEMUSaveDataFree(data);
|
virQEMUSaveDataFree(data);
|
||||||
virObjectEventStateQueue(driver->domainEventState, event);
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
return ret;
|
return ret;
|
||||||
@ -6808,7 +6807,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
|||||||
g_autofree char *errbuf = NULL;
|
g_autofree char *errbuf = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
virQEMUSaveHeaderPtr header = &data->header;
|
virQEMUSaveHeaderPtr header = &data->header;
|
||||||
qemuDomainSaveCookiePtr cookie = NULL;
|
g_autoptr(qemuDomainSaveCookie) cookie = NULL;
|
||||||
|
|
||||||
if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie,
|
if (virSaveCookieParseString(data->cookie, (virObjectPtr *)&cookie,
|
||||||
virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
|
virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
|
||||||
@ -6919,7 +6918,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(cookie);
|
|
||||||
if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0)
|
if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0)
|
||||||
VIR_WARN("failed to restore save state label on %s", path);
|
VIR_WARN("failed to restore save state label on %s", path);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user