mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
qemu_driver.c: use g_autoptr() with virDomainDef pointers
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
6f0ee50be2
commit
74b2834333
@ -1737,7 +1737,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
@ -1810,7 +1810,6 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
|||||||
qemuProcessEndJob(driver, vm);
|
qemuProcessEndJob(driver, vm);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(def);
|
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
virObjectEventStateQueue(driver->domainEventState, event);
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
virObjectEventStateQueue(driver->domainEventState, event2);
|
virObjectEventStateQueue(driver->domainEventState, event2);
|
||||||
@ -5997,7 +5996,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
qemuDomainObjPrivatePtr priv = NULL;
|
qemuDomainObjPrivatePtr priv = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
g_autofree char *xmlout = NULL;
|
g_autofree char *xmlout = NULL;
|
||||||
const char *newxml = dxml;
|
const char *newxml = dxml;
|
||||||
@ -6078,7 +6077,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
|||||||
qemuProcessEndJob(driver, vm);
|
qemuProcessEndJob(driver, vm);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(def);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
if (virFileWrapperFdClose(wrapperFd) < 0)
|
if (virFileWrapperFdClose(wrapperFd) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -6104,7 +6102,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
|
|||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
virQEMUSaveDataPtr data = NULL;
|
virQEMUSaveDataPtr data = NULL;
|
||||||
|
|
||||||
@ -6123,7 +6121,6 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virQEMUSaveDataFree(data);
|
virQEMUSaveDataFree(data);
|
||||||
virDomainDefFree(def);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -6134,8 +6131,8 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
virDomainDefPtr newdef = NULL;
|
g_autoptr(virDomainDef) newdef = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
virQEMUSaveDataPtr data = NULL;
|
virQEMUSaveDataPtr data = NULL;
|
||||||
int state = -1;
|
int state = -1;
|
||||||
@ -6194,8 +6191,6 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(def);
|
|
||||||
virDomainDefFree(newdef);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
virQEMUSaveDataFree(data);
|
virQEMUSaveDataFree(data);
|
||||||
return ret;
|
return ret;
|
||||||
@ -6208,7 +6203,7 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
virQEMUSaveDataPtr data = NULL;
|
virQEMUSaveDataPtr data = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
@ -6240,7 +6235,6 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virQEMUSaveDataFree(data);
|
virQEMUSaveDataFree(data);
|
||||||
virDomainDefFree(def);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
return ret;
|
return ret;
|
||||||
@ -6289,7 +6283,7 @@ qemuDomainObjRestore(virConnectPtr conn,
|
|||||||
bool bypass_cache,
|
bool bypass_cache,
|
||||||
qemuDomainAsyncJob asyncJob)
|
qemuDomainAsyncJob asyncJob)
|
||||||
{
|
{
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -6350,7 +6344,6 @@ qemuDomainObjRestore(virConnectPtr conn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virQEMUSaveDataFree(data);
|
virQEMUSaveDataFree(data);
|
||||||
virDomainDefFree(def);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
if (virFileWrapperFdClose(wrapperFd) < 0)
|
if (virFileWrapperFdClose(wrapperFd) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -6689,8 +6682,8 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
virDomainDefPtr oldDef = NULL;
|
g_autoptr(virDomainDef) oldDef = NULL;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
@ -6754,8 +6747,16 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
|
|||||||
qemuDomainRemoveInactiveJob(driver, vm);
|
qemuDomainRemoveInactiveJob(driver, vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virDomainDefFree(oldDef);
|
|
||||||
virDomainDefFree(def);
|
event = virDomainEventLifecycleNewFromObj(vm,
|
||||||
|
VIR_DOMAIN_EVENT_DEFINED,
|
||||||
|
!oldDef ?
|
||||||
|
VIR_DOMAIN_EVENT_DEFINED_ADDED :
|
||||||
|
VIR_DOMAIN_EVENT_DEFINED_UPDATED);
|
||||||
|
|
||||||
|
VIR_INFO("Creating domain '%s'", vm->def->name);
|
||||||
|
dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
|
||||||
|
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
virObjectEventStateQueue(driver->domainEventState, event);
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
return dom;
|
return dom;
|
||||||
@ -7758,7 +7759,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDefPtr vmdef = NULL;
|
g_autoptr(virDomainDef) vmdef = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||||
virDomainDeviceDefPtr devConf = NULL;
|
virDomainDeviceDefPtr devConf = NULL;
|
||||||
virDomainDeviceDef devConfSave = { 0 };
|
virDomainDeviceDef devConfSave = { 0 };
|
||||||
@ -7848,7 +7849,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(vmdef);
|
|
||||||
virDomainDeviceDefFree(devConf);
|
virDomainDeviceDefFree(devConf);
|
||||||
virDomainDeviceDefFree(devLive);
|
virDomainDeviceDefFree(devLive);
|
||||||
|
|
||||||
@ -7906,7 +7906,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
virDomainDefPtr vmdef = NULL;
|
g_autoptr(virDomainDef) vmdef = NULL;
|
||||||
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
|
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
|
||||||
bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
|
bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -8001,7 +8001,6 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(vmdef);
|
|
||||||
if (dev != dev_copy)
|
if (dev != dev_copy)
|
||||||
virDomainDeviceDefFree(dev_copy);
|
virDomainDeviceDefFree(dev_copy);
|
||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
@ -8020,7 +8019,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
|
|||||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||||
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
|
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
|
||||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
||||||
virDomainDefPtr vmdef = NULL;
|
g_autoptr(virDomainDef) vmdef = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
@ -8095,7 +8094,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
|
|||||||
if (dev != dev_copy)
|
if (dev != dev_copy)
|
||||||
virDomainDeviceDefFree(dev_copy);
|
virDomainDeviceDefFree(dev_copy);
|
||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
virDomainDefFree(vmdef);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8110,7 +8108,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
|
|||||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
virDomainDefPtr persistentDef = NULL;
|
virDomainDefPtr persistentDef = NULL;
|
||||||
virDomainDefPtr vmdef = NULL;
|
g_autoptr(virDomainDef) vmdef = NULL;
|
||||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -8164,7 +8162,6 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(vmdef);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9284,7 +9281,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
virDomainDefPtr persistentDef = NULL;
|
virDomainDefPtr persistentDef = NULL;
|
||||||
virDomainDefPtr persistentDefCopy = NULL;
|
g_autoptr(virDomainDef) persistentDefCopy = NULL;
|
||||||
unsigned long long value_ul;
|
unsigned long long value_ul;
|
||||||
long long value_l;
|
long long value_l;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -9572,7 +9569,6 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(persistentDefCopy);
|
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
if (eventNparams)
|
if (eventNparams)
|
||||||
virTypedParamsFree(eventParams, eventNparams);
|
virTypedParamsFree(eventParams, eventNparams);
|
||||||
@ -11171,7 +11167,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
|
|||||||
const char *dom_xml)
|
const char *dom_xml)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dconn->privateData;
|
virQEMUDriverPtr driver = dconn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
g_autofree char *origname = NULL;
|
g_autofree char *origname = NULL;
|
||||||
qemuMigrationParamsPtr migParams = NULL;
|
qemuMigrationParamsPtr migParams = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -11207,7 +11203,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMigrationParamsFree(migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
virDomainDefFree(def);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11227,7 +11222,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
|
|||||||
const char *dom_xml)
|
const char *dom_xml)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dconn->privateData;
|
virQEMUDriverPtr driver = dconn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
g_autofree char *origname = NULL;
|
g_autofree char *origname = NULL;
|
||||||
qemuMigrationParamsPtr migParams = NULL;
|
qemuMigrationParamsPtr migParams = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -11273,7 +11268,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMigrationParamsFree(migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
virDomainDefFree(def);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11615,7 +11609,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
|
|||||||
const char *dom_xml)
|
const char *dom_xml)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dconn->privateData;
|
virQEMUDriverPtr driver = dconn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
g_autofree char *origname = NULL;
|
g_autofree char *origname = NULL;
|
||||||
qemuMigrationParamsPtr migParams = NULL;
|
qemuMigrationParamsPtr migParams = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -11645,7 +11639,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMigrationParamsFree(migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
virDomainDefFree(def);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11661,7 +11654,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dconn->privateData;
|
virQEMUDriverPtr driver = dconn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
const char *dom_xml = NULL;
|
const char *dom_xml = NULL;
|
||||||
const char *dname = NULL;
|
const char *dname = NULL;
|
||||||
g_autofree char *origname = NULL;
|
g_autofree char *origname = NULL;
|
||||||
@ -11703,7 +11696,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuMigrationParamsFree(migParams);
|
qemuMigrationParamsFree(migParams);
|
||||||
virDomainDefFree(def);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user