mirror of https://gitee.com/openkylin/libvirt.git
Use g_auto for freeing virCaps
Convert all the users who unref their virCaps object unconditionally. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
efe98ca98b
commit
4eaa499c8b
|
@ -140,7 +140,7 @@ static char *
|
|||
bhyveConnectGetCapabilities(virConnectPtr conn)
|
||||
{
|
||||
struct _bhyveConn *privconn = conn->privateData;
|
||||
virCaps *caps;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
char *xml = NULL;
|
||||
|
||||
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
|
||||
|
@ -156,7 +156,6 @@ bhyveConnectGetCapabilities(virConnectPtr conn)
|
|||
goto cleanup;
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
@ -508,7 +507,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
|
|||
g_autoptr(virDomainDef) oldDef = NULL;
|
||||
virDomainObj *vm = NULL;
|
||||
virObjectEvent *event = NULL;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
@ -554,7 +553,6 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
|
|||
dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
virDomainObjEndAPI(&vm);
|
||||
virObjectEventStateQueue(privconn->domainEventState, event);
|
||||
|
||||
|
@ -1434,7 +1432,7 @@ bhyveConnectCompareCPU(virConnectPtr conn,
|
|||
{
|
||||
struct _bhyveConn *driver = conn->privateData;
|
||||
int ret = VIR_CPU_COMPARE_ERROR;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
bool failIncompatible;
|
||||
bool validateXML;
|
||||
|
||||
|
@ -1466,7 +1464,6 @@ bhyveConnectCompareCPU(virConnectPtr conn,
|
|||
}
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ static int chNodeGetInfo(virConnectPtr conn,
|
|||
static char *chConnectGetCapabilities(virConnectPtr conn)
|
||||
{
|
||||
virCHDriver *driver = conn->privateData;
|
||||
virCaps *caps;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
char *xml;
|
||||
|
||||
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
|
||||
|
@ -198,7 +198,6 @@ static char *chConnectGetCapabilities(virConnectPtr conn)
|
|||
|
||||
xml = virCapabilitiesFormatXML(caps);
|
||||
|
||||
virObjectUnref(caps);
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ static int lxcConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
|
|||
|
||||
static char *lxcConnectGetCapabilities(virConnectPtr conn) {
|
||||
virLXCDriver *driver = conn->privateData;
|
||||
virCaps *caps;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
char *xml;
|
||||
|
||||
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
|
||||
|
@ -208,7 +208,6 @@ static char *lxcConnectGetCapabilities(virConnectPtr conn) {
|
|||
|
||||
xml = virCapabilitiesFormatXML(caps);
|
||||
|
||||
virObjectUnref(caps);
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
@ -405,7 +404,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
|||
virObjectEvent *event = NULL;
|
||||
g_autoptr(virDomainDef) oldDef = NULL;
|
||||
virLXCDriverConfig *cfg = virLXCDriverGetConfig(driver);
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
@ -459,7 +458,6 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
|||
cleanup:
|
||||
virDomainObjEndAPI(&vm);
|
||||
virObjectEventStateQueue(driver->domainEventState, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return dom;
|
||||
}
|
||||
|
@ -937,7 +935,7 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn,
|
|||
char *xml = NULL;
|
||||
g_autoptr(virDomainDef) def = NULL;
|
||||
virLXCDriver *driver = conn->privateData;
|
||||
virCaps *caps = virLXCDriverGetCapabilities(driver, false);
|
||||
g_autoptr(virCaps) caps = virLXCDriverGetCapabilities(driver, false);
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
|
@ -956,7 +954,6 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn,
|
|||
xml = virDomainDefFormat(def, driver->xmlopt, 0);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
@ -1082,7 +1079,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
|||
virDomainPtr dom = NULL;
|
||||
virObjectEvent *event = NULL;
|
||||
virLXCDriverConfig *cfg = virLXCDriverGetConfig(driver);
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
|
||||
|
@ -1150,7 +1147,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
|||
cleanup:
|
||||
virDomainObjEndAPI(&vm);
|
||||
virObjectEventStateQueue(driver->domainEventState, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
virNWFilterUnlockFilterUpdates();
|
||||
return dom;
|
||||
|
@ -1229,7 +1225,7 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
|
|||
virSecurityModelPtr secmodel)
|
||||
{
|
||||
virLXCDriver *driver = conn->privateData;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
int ret = 0;
|
||||
|
||||
memset(secmodel, 0, sizeof(*secmodel));
|
||||
|
@ -1268,7 +1264,6 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
|
|||
}
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(caps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1807,7 +1802,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||
unsigned int flags)
|
||||
{
|
||||
virLXCDriver *driver = dom->conn->privateData;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
size_t i;
|
||||
virDomainObj *vm = NULL;
|
||||
virDomainDef *def = NULL;
|
||||
|
@ -1925,7 +1920,6 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||
|
||||
cleanup:
|
||||
virDomainObjEndAPI(&vm);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
@ -4456,7 +4450,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
|
|||
unsigned int flags)
|
||||
{
|
||||
virLXCDriver *driver = dom->conn->privateData;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
virDomainObj *vm = NULL;
|
||||
g_autoptr(virDomainDef) vmdef = NULL;
|
||||
virDomainDeviceDef *dev = NULL;
|
||||
|
@ -4540,7 +4534,6 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
|
|||
virDomainDeviceDefFree(dev_copy);
|
||||
virDomainDeviceDefFree(dev);
|
||||
virDomainObjEndAPI(&vm);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1207,7 +1207,7 @@ int virLXCProcessStart(virConnectPtr conn,
|
|||
int nsInheritFDs[VIR_LXC_DOMAIN_NAMESPACE_LAST];
|
||||
virCommand *cmd = NULL;
|
||||
virLXCDomainObjPrivate *priv = vm->privateData;
|
||||
virCaps *caps = NULL;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
virErrorPtr err = NULL;
|
||||
virLXCDriverConfig *cfg = virLXCDriverGetConfig(driver);
|
||||
g_autoptr(virCgroup) selfcgroup = NULL;
|
||||
|
@ -1579,7 +1579,6 @@ int virLXCProcessStart(virConnectPtr conn,
|
|||
for (i = 0; i < G_N_ELEMENTS(handshakefds); i++)
|
||||
VIR_FORCE_CLOSE(handshakefds[i]);
|
||||
virObjectUnref(cfg);
|
||||
virObjectUnref(caps);
|
||||
|
||||
virErrorRestore(&err);
|
||||
|
||||
|
|
Loading…
Reference in New Issue