qemu_driver.c: use g_autofree when possible

String and other scalar pointers an be auto-unref, sparing us
a VIR_FREE() call.

This patch uses g_autofree whenever possible with strings and
other scalar pointer types.

Suggested-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2019-10-16 17:54:31 -03:00 committed by Michal Privoznik
parent c00d13450f
commit 0108deb944

View File

@ -1085,7 +1085,7 @@ qemuStateStop(void)
size_t i;
int state;
virDomainPtr *domains = NULL;
unsigned int *flags = NULL;
g_autofree unsigned int *flags = NULL;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(qemu_driver);
if (!(conn = virConnectOpen(cfg->uri)))
@ -1123,7 +1123,6 @@ qemuStateStop(void)
virObjectUnref(domains[i]);
VIR_FREE(domains);
}
VIR_FREE(flags);
return ret;
}
@ -1357,8 +1356,8 @@ static int
qemuGetSchedInfo(unsigned long long *cpuWait,
pid_t pid, pid_t tid)
{
char *proc = NULL;
char *data = NULL;
g_autofree char *proc = NULL;
g_autofree char *data = NULL;
char **lines = NULL;
size_t i;
int ret = -1;
@ -1422,8 +1421,6 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
ret = 0;
cleanup:
VIR_FREE(data);
VIR_FREE(proc);
virStringListFree(lines);
return ret;
}
@ -1433,7 +1430,7 @@ static int
qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
pid_t pid, int tid)
{
char *proc;
g_autofree char *proc = NULL;
FILE *pidinfo;
unsigned long long usertime = 0, systime = 0;
long rss = 0;
@ -1450,7 +1447,6 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
return -1;
pidinfo = fopen(proc, "r");
VIR_FREE(proc);
/* See 'man proc' for information about what all these fields are. We're
* only interested in a very few of them */
@ -2908,7 +2904,7 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
size_t cookie_len = 0;
int ret = -1;
size_t zerosLen = 0;
char *zeros = NULL;
g_autofree char *zeros = NULL;
xml_len = strlen(data->xml) + 1;
if (data->cookie)
@ -2965,7 +2961,6 @@ virQEMUSaveDataWrite(virQEMUSaveDataPtr data,
ret = 0;
cleanup:
VIR_FREE(zeros);
return ret;
}
@ -3300,7 +3295,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
int compressed, const char *compressedpath,
const char *xmlin, unsigned int flags)
{
char *xml = NULL;
g_autofree char *xml = NULL;
bool was_running = false;
int ret = -1;
virObjectEventPtr event = NULL;
@ -3417,7 +3412,6 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
cleanup:
virObjectUnref(cookie);
VIR_FREE(xml);
virQEMUSaveDataFree(data);
virObjectEventStateQueue(driver->domainEventState, event);
return ret;
@ -3505,7 +3499,7 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
{
virQEMUDriverPtr driver = dom->conn->privateData;
int compressed;
char *compressedpath = NULL;
g_autofree char *compressedpath = NULL;
int ret = -1;
virDomainObjPtr vm = NULL;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
@ -3534,7 +3528,6 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml,
cleanup:
virDomainObjEndAPI(&vm);
VIR_FREE(compressedpath);
return ret;
}
@ -3562,9 +3555,9 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
virQEMUDriverPtr driver = dom->conn->privateData;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
int compressed;
char *compressedpath = NULL;
g_autofree char *compressedpath = NULL;
virDomainObjPtr vm;
char *name = NULL;
g_autofree char *name = NULL;
int ret = -1;
virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
@ -3604,8 +3597,6 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
cleanup:
virDomainObjEndAPI(&vm);
VIR_FREE(name);
VIR_FREE(compressedpath);
return ret;
}
@ -3615,7 +3606,7 @@ qemuDomainManagedSaveLoad(virDomainObjPtr vm,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
char *name;
g_autofree char *name = NULL;
int ret = -1;
virObjectLock(vm);
@ -3628,7 +3619,6 @@ qemuDomainManagedSaveLoad(virDomainObjPtr vm,
ret = 0;
cleanup:
virObjectUnlock(vm);
VIR_FREE(name);
return ret;
}
@ -3660,7 +3650,7 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
int ret = -1;
char *name = NULL;
g_autofree char *name = NULL;
virCheckFlags(0, -1);
@ -3684,7 +3674,6 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
ret = 0;
cleanup:
VIR_FREE(name);
virDomainObjEndAPI(&vm);
return ret;
}
@ -3804,7 +3793,7 @@ doCoreDump(virQEMUDriverPtr driver,
unsigned int flags = VIR_FILE_WRAPPER_NON_BLOCKING;
const char *memory_dump_format = NULL;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
char *compressedpath = NULL;
g_autofree char *compressedpath = NULL;
/* We reuse "save" flag for "dump" here. Then, we can support the same
* format in "save" and "dump". This path doesn't need the compression
@ -3884,7 +3873,6 @@ doCoreDump(virQEMUDriverPtr driver,
virFileWrapperFdFree(wrapperFd);
if (ret != 0)
unlink(path);
VIR_FREE(compressedpath);
return ret;
}
@ -4010,7 +3998,7 @@ qemuDomainScreenshot(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
qemuDomainObjPrivatePtr priv;
char *tmp = NULL;
g_autofree char *tmp = NULL;
int tmp_fd = -1;
size_t i;
const char *videoAlias = NULL;
@ -4102,7 +4090,6 @@ qemuDomainScreenshot(virDomainPtr dom,
VIR_FORCE_CLOSE(tmp_fd);
if (unlink_tmp)
unlink(tmp);
VIR_FREE(tmp);
qemuDomainObjEndJob(driver, vm);
@ -4116,7 +4103,7 @@ getAutoDumpPath(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
char *dumpfile = NULL;
char *domname = virDomainDefGetShortName(vm->def);
g_autofree char *domname = virDomainDefGetShortName(vm->def);
char timestr[100];
struct tm time_info;
time_t curtime = time(NULL);
@ -4135,7 +4122,6 @@ getAutoDumpPath(virQEMUDriverPtr driver,
domname,
timestr));
VIR_FREE(domname);
return dumpfile;
}
@ -4146,11 +4132,11 @@ processWatchdogEvent(virQEMUDriverPtr driver,
{
int ret;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
char *dumpfile = getAutoDumpPath(driver, vm);
g_autofree char *dumpfile = getAutoDumpPath(driver, vm);
unsigned int flags = VIR_DUMP_MEMORY_ONLY;
if (!dumpfile)
goto cleanup;
return;
switch (action) {
case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
@ -4158,7 +4144,7 @@ processWatchdogEvent(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_DUMP,
VIR_DOMAIN_JOB_OPERATION_DUMP,
flags) < 0) {
goto cleanup;
return;
}
if (virDomainObjCheckActive(vm) < 0)
@ -4179,14 +4165,11 @@ processWatchdogEvent(virQEMUDriverPtr driver,
"%s", _("Resuming after dump failed"));
break;
default:
goto cleanup;
return;
}
endjob:
qemuDomainObjEndAsyncJob(driver, vm);
cleanup:
VIR_FREE(dumpfile);
}
static int
@ -4196,7 +4179,7 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver,
{
int ret = -1;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
char *dumpfile = getAutoDumpPath(driver, vm);
g_autofree char *dumpfile = getAutoDumpPath(driver, vm);
if (!dumpfile)
goto cleanup;
@ -4207,7 +4190,6 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Dump failed"));
cleanup:
VIR_FREE(dumpfile);
return ret;
}
@ -4217,14 +4199,11 @@ qemuProcessGuestPanicEventInfo(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuMonitorEventPanicInfoPtr info)
{
char *msg = qemuMonitorGuestPanicEventInfoFormatMsg(info);
char *timestamp = virTimeStringNow();
g_autofree char *msg = qemuMonitorGuestPanicEventInfoFormatMsg(info);
g_autofree char *timestamp = virTimeStringNow();
if (msg && timestamp)
qemuDomainLogAppendMessage(driver, vm, "%s: panic %s\n", timestamp, msg);
VIR_FREE(timestamp);
VIR_FREE(msg);
}
@ -5123,7 +5102,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
virDomainVcpuDefPtr vcpuinfo;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr cgroup_vcpu = NULL;
char *str = NULL;
g_autofree char *str = NULL;
virObjectEventPtr event = NULL;
char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = "";
virTypedParameterPtr eventParams = NULL;
@ -5187,7 +5166,6 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
cleanup:
virBitmapFree(tmpmap);
virCgroupFree(&cgroup_vcpu);
VIR_FREE(str);
virObjectEventStateQueue(driver->domainEventState, event);
return ret;
}
@ -5328,7 +5306,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
virBitmapPtr pcpumap = NULL;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
virObjectEventPtr event = NULL;
char *str = NULL;
g_autofree char *str = NULL;
virTypedParameterPtr eventParams = NULL;
int eventNparams = 0;
int eventMaxparams = 0;
@ -5417,7 +5395,6 @@ qemuDomainPinEmulator(virDomainPtr dom,
if (cgroup_emulator)
virCgroupFree(&cgroup_emulator);
virObjectEventStateQueue(driver->domainEventState, event);
VIR_FREE(str);
virBitmapFree(pcpumap);
virDomainObjEndAPI(&vm);
return ret;
@ -5799,7 +5776,7 @@ qemuDomainPinIOThread(virDomainPtr dom,
virCgroupPtr cgroup_iothread = NULL;
virObjectEventPtr event = NULL;
char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = "";
char *str = NULL;
g_autofree char *str = NULL;
virTypedParameterPtr eventParams = NULL;
int eventNparams = 0;
int eventMaxparams = 0;
@ -5911,7 +5888,6 @@ qemuDomainPinIOThread(virDomainPtr dom,
if (cgroup_iothread)
virCgroupFree(&cgroup_iothread);
virObjectEventStateQueue(driver->domainEventState, event);
VIR_FREE(str);
virBitmapFree(pcpumap);
virDomainObjEndAPI(&vm);
return ret;
@ -5923,7 +5899,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
unsigned int iothread_id)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
char *alias = NULL;
g_autofree char *alias = NULL;
size_t idx;
int ret = -1;
unsigned int orig_niothreads = vm->def->niothreadids;
@ -5999,7 +5975,6 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
}
virDomainAuditIOThread(vm, orig_niothreads, new_niothreads,
"update", ret == 0);
VIR_FREE(alias);
virJSONValueFree(props);
return ret;
@ -6044,7 +6019,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
size_t idx;
char *alias = NULL;
g_autofree char *alias = NULL;
int rc = -1;
int ret = -1;
unsigned int orig_niothreads = vm->def->niothreadids;
@ -6093,7 +6068,6 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
}
virDomainAuditIOThread(vm, orig_niothreads, new_niothreads,
"update", rc == 0);
VIR_FREE(alias);
return ret;
exit_monitor:
@ -6869,7 +6843,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
virObjectEventPtr event;
int intermediatefd = -1;
virCommandPtr cmd = NULL;
char *errbuf = NULL;
g_autofree char *errbuf = NULL;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
virQEMUSaveHeaderPtr header = &data->header;
qemuDomainSaveCookiePtr cookie = NULL;
@ -6986,7 +6960,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
cleanup:
virObjectUnref(cookie);
virCommandFree(cmd);
VIR_FREE(errbuf);
if (qemuSecurityRestoreSavedStateLabel(driver, vm, path) < 0)
VIR_WARN("failed to restore save state label on %s", path);
return ret;
@ -7002,7 +6975,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
qemuDomainObjPrivatePtr priv = NULL;
virDomainDefPtr def = NULL;
virDomainObjPtr vm = NULL;
char *xmlout = NULL;
g_autofree char *xmlout = NULL;
const char *newxml = dxml;
int fd = -1;
int ret = -1;
@ -7087,7 +7060,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
ret = -1;
virFileWrapperFdFree(wrapperFd);
virQEMUSaveDataFree(data);
VIR_FREE(xmlout);
if (vm && ret < 0)
qemuDomainRemoveInactiveJob(driver, vm);
virDomainObjEndAPI(&vm);
@ -7210,7 +7182,7 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
char *path = NULL;
g_autofree char *path = NULL;
char *ret = NULL;
virDomainDefPtr def = NULL;
int fd = -1;
@ -7247,7 +7219,6 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags)
virDomainDefFree(def);
VIR_FORCE_CLOSE(fd);
virDomainObjEndAPI(&vm);
VIR_FREE(path);
return ret;
}
@ -7258,7 +7229,7 @@ qemuDomainManagedSaveDefineXML(virDomainPtr dom, const char *dxml,
virQEMUDriverPtr driver = dom->conn->privateData;
virConnectPtr conn = dom->conn;
virDomainObjPtr vm;
char *path = NULL;
g_autofree char *path = NULL;
int ret = -1;
if (!(vm = qemuDomainObjFromDomain(dom)))
@ -7280,7 +7251,6 @@ qemuDomainManagedSaveDefineXML(virDomainPtr dom, const char *dxml,
cleanup:
virDomainObjEndAPI(&vm);
VIR_FREE(path);
return ret;
}
@ -7299,7 +7269,7 @@ qemuDomainObjRestore(virConnectPtr conn,
qemuDomainObjPrivatePtr priv = vm->privateData;
int fd = -1;
int ret = -1;
char *xmlout = NULL;
g_autofree char *xmlout = NULL;
virQEMUSaveDataPtr data = NULL;
virFileWrapperFdPtr wrapperFd = NULL;
@ -7356,7 +7326,6 @@ qemuDomainObjRestore(virConnectPtr conn,
cleanup:
virQEMUSaveDataFree(data);
VIR_FREE(xmlout);
virDomainDefFree(def);
VIR_FORCE_CLOSE(fd);
if (virFileWrapperFdClose(wrapperFd) < 0)
@ -7520,7 +7489,7 @@ qemuDomainObjStart(virConnectPtr conn,
qemuDomainAsyncJob asyncJob)
{
int ret = -1;
char *managed_save;
g_autofree char *managed_save = NULL;
bool start_paused = (flags & VIR_DOMAIN_START_PAUSED) != 0;
bool autodestroy = (flags & VIR_DOMAIN_START_AUTODESTROY) != 0;
bool bypass_cache = (flags & VIR_DOMAIN_START_BYPASS_CACHE) != 0;
@ -7594,7 +7563,6 @@ qemuDomainObjStart(virConnectPtr conn,
}
cleanup:
VIR_FREE(managed_save);
return ret;
}
@ -7742,7 +7710,7 @@ qemuDomainUndefineFlags(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
virObjectEventPtr event = NULL;
char *name = NULL;
g_autofree char *name = NULL;
int ret = -1;
int nsnapshots;
int ncheckpoints;
@ -7871,7 +7839,6 @@ qemuDomainUndefineFlags(virDomainPtr dom,
qemuDomainObjEndJob(driver, vm);
cleanup:
VIR_FREE(name);
virDomainObjEndAPI(&vm);
virObjectEventStateQueue(driver->domainEventState, event);
return ret;
@ -9209,7 +9176,8 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
char *configFile = NULL, *autostartLink = NULL;
g_autofree char *configFile = NULL;
g_autofree char *autostartLink = NULL;
int ret = -1;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
@ -9273,8 +9241,6 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
ret = 0;
cleanup:
VIR_FREE(configFile);
VIR_FREE(autostartLink);
virDomainObjEndAPI(&vm);
return ret;
}
@ -10054,7 +10020,7 @@ qemuDomainSetNumaParamsLive(virDomainObjPtr vm,
{
virCgroupPtr cgroup_temp = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
char *nodeset_str = NULL;
g_autofree char *nodeset_str = NULL;
virDomainNumatuneMemMode mode;
size_t i = 0;
int ret = -1;
@ -10104,7 +10070,6 @@ qemuDomainSetNumaParamsLive(virDomainObjPtr vm,
ret = 0;
cleanup:
VIR_FREE(nodeset_str);
virCgroupFree(&cgroup_temp);
return ret;
@ -10247,7 +10212,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
virDomainObjPtr vm = NULL;
virDomainNumatuneMemMode tmpmode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
qemuDomainObjPrivatePtr priv;
char *nodeset = NULL;
g_autofree char *nodeset = NULL;
int ret = -1;
virDomainDefPtr def = NULL;
bool live = false;
@ -10311,7 +10276,6 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
ret = 0;
cleanup:
VIR_FREE(nodeset);
virDomainObjEndAPI(&vm);
return ret;
}
@ -11178,7 +11142,7 @@ qemuDomainBlockResize(virDomainPtr dom,
virDomainObjPtr vm;
qemuDomainObjPrivatePtr priv;
int ret = -1;
char *device = NULL;
g_autofree char *device = NULL;
const char *nodename = NULL;
virDomainDiskDefPtr disk = NULL;
@ -11250,7 +11214,6 @@ qemuDomainBlockResize(virDomainPtr dom,
qemuDomainObjEndJob(driver, vm);
cleanup:
VIR_FREE(device);
virDomainObjEndAPI(&vm);
return ret;
}
@ -11959,7 +11922,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainDiskDefPtr disk = NULL;
virDomainObjPtr vm;
char *tmpbuf = NULL;
g_autofree char *tmpbuf = NULL;
ssize_t nread;
int ret = -1;
@ -12014,7 +11977,6 @@ qemuDomainBlockPeek(virDomainPtr dom,
if (disk)
virStorageFileDeinit(disk->src);
virDomainObjEndAPI(&vm);
VIR_FREE(tmpbuf);
return ret;
}
@ -12026,7 +11988,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
char *tmp = NULL;
g_autofree char *tmp = NULL;
int fd = -1, ret = -1;
qemuDomainObjPrivatePtr priv;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
@ -12098,7 +12060,6 @@ qemuDomainMemoryPeek(virDomainPtr dom,
VIR_FORCE_CLOSE(fd);
if (tmp)
unlink(tmp);
VIR_FREE(tmp);
virDomainObjEndAPI(&vm);
return ret;
}
@ -12264,7 +12225,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
int ret = -1;
int fd = -1;
struct stat sb;
char *buf = NULL;
g_autofree char *buf = NULL;
ssize_t len;
if ((rc = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb,
@ -12300,7 +12261,6 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
ret = 1;
cleanup:
VIR_FREE(buf);
qemuDomainStorageCloseStat(src, &fd);
return ret;
}
@ -12521,7 +12481,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
char *origname = NULL;
g_autofree char *origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@ -12556,7 +12516,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@ -12578,7 +12537,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
char *origname = NULL;
g_autofree char *origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@ -12623,7 +12582,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@ -12824,7 +12782,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
char *origname = NULL;
g_autofree char *origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@ -12859,7 +12817,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@ -12885,7 +12842,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
int nbdPort = 0;
int nmigrate_disks;
const char **migrate_disks = NULL;
char *origname = NULL;
g_autofree char *origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@ -12948,7 +12905,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(migrate_disks);
VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@ -12968,7 +12924,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
{
virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL;
char *origname = NULL;
g_autofree char *origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@ -12997,7 +12953,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@ -13017,7 +12972,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
virDomainDefPtr def = NULL;
const char *dom_xml = NULL;
const char *dname = NULL;
char *origname = NULL;
g_autofree char *origname = NULL;
qemuMigrationParamsPtr migParams = NULL;
int ret = -1;
@ -13056,7 +13011,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
cleanup:
qemuMigrationParamsFree(migParams);
VIR_FREE(origname);
virDomainDefFree(def);
return ret;
}
@ -13378,7 +13332,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
unsigned domain = 0, bus = 0, slot = 0, function = 0;
int ret = -1;
virNodeDeviceDefPtr def = NULL;
char *xml = NULL;
g_autofree char *xml = NULL;
bool vfio = qemuHostdevHostSupportsPassthroughVFIO();
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
@ -13428,7 +13382,6 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
cleanup:
virPCIDeviceFree(pci);
virNodeDeviceDefFree(def);
VIR_FREE(xml);
return ret;
}
@ -13446,7 +13399,7 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
unsigned domain = 0, bus = 0, slot = 0, function = 0;
int ret = -1;
virNodeDeviceDefPtr def = NULL;
char *xml = NULL;
g_autofree char *xml = NULL;
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
xml = virNodeDeviceGetXMLDesc(dev, 0);
@ -13472,7 +13425,6 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
virPCIDeviceFree(pci);
cleanup:
virNodeDeviceDefFree(def);
VIR_FREE(xml);
return ret;
}
@ -13484,7 +13436,7 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
unsigned domain = 0, bus = 0, slot = 0, function = 0;
int ret = -1;
virNodeDeviceDefPtr def = NULL;
char *xml = NULL;
g_autofree char *xml = NULL;
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
xml = virNodeDeviceGetXMLDesc(dev, 0);
@ -13510,7 +13462,6 @@ qemuNodeDeviceReset(virNodeDevicePtr dev)
virPCIDeviceFree(pci);
cleanup:
virNodeDeviceDefFree(def);
VIR_FREE(xml);
return ret;
}
@ -15349,7 +15300,6 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
char *backingStoreStr;
virDomainDiskDefPtr persistdisk;
g_autoptr(virStorageSource) terminator = NULL;
bool supportsCreate;
@ -15395,13 +15345,13 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
* block commit still works */
if (reuse) {
if (supportsBacking) {
g_autofree char *backingStoreStr = NULL;
if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
return -1;
if (backingStoreStr != NULL) {
if (virStorageIsRelative(backingStoreStr))
dd->relPath = g_steal_pointer(&backingStoreStr);
else
VIR_FREE(backingStoreStr);
}
}
} else {
@ -15848,7 +15798,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
{
virQEMUDriverPtr driver = domain->conn->privateData;
virDomainObjPtr vm = NULL;
char *xml = NULL;
g_autofree char *xml = NULL;
virDomainMomentObjPtr snap = NULL;
virDomainSnapshotPtr snapshot = NULL;
virDomainMomentObjPtr current = NULL;
@ -16129,7 +16079,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
cleanup:
virDomainObjEndAPI(&vm);
VIR_FREE(xml);
return snapshot;
}
@ -17916,7 +17865,7 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom,
virDomainDiskDefPtr disk;
int ret = -1;
virDomainObjPtr vm;
char *device = NULL;
g_autofree char *device = NULL;
unsigned long long speed = bandwidth;
virCheckFlags(VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES, -1);
@ -17961,7 +17910,6 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom,
qemuDomainObjEndJob(driver, vm);
cleanup:
VIR_FREE(device);
virDomainObjEndAPI(&vm);
return ret;
@ -19039,7 +18987,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL;
virDomainBlockIoTuneInfo info;
char *drivealias = NULL;
g_autofree char *drivealias = NULL;
const char *qdevid = NULL;
int ret = -1;
size_t i;
@ -19366,7 +19314,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
cleanup:
VIR_FREE(info.group_name);
VIR_FREE(drivealias);
virDomainObjEndAPI(&vm);
if (eventNparams)
virTypedParamsFree(eventParams, eventNparams);
@ -19387,7 +19334,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL;
virDomainBlockIoTuneInfo reply = {0};
char *drivealias = NULL;
g_autofree char *drivealias = NULL;
const char *qdevid = NULL;
int ret = -1;
int maxparams;
@ -19524,7 +19471,6 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
cleanup:
VIR_FREE(reply.group_name);
VIR_FREE(drivealias);
virDomainObjEndAPI(&vm);
return ret;
}
@ -20804,7 +20750,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
size_t i;
int ret = -1;
virVcpuInfoPtr cpuinfo = NULL;
unsigned long long *cpuwait = NULL;
g_autofree unsigned long long *cpuwait = NULL;
if (virTypedParamListAddUInt(params, virDomainDefGetVcpus(dom->def),
"vcpu.current") < 0)
@ -20869,7 +20815,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
cleanup:
VIR_FREE(cpuinfo);
VIR_FREE(cpuwait);
return ret;
}
@ -21151,7 +21096,6 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
bool blockdev)
{
char *alias = NULL;
virStorageSourcePtr n;
const char *frontendalias;
const char *backendalias;
@ -21173,6 +21117,8 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
}
for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
g_autofree char *alias = NULL;
if (blockdev) {
frontendalias = QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName;
backendalias = n->nodeformat;
@ -21210,7 +21156,6 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
params) < 0)
goto cleanup;
VIR_FREE(alias);
(*recordnr)++;
if (!visitBacking)
@ -21220,7 +21165,6 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
ret = 0;
cleanup:
VIR_FREE(alias);
return ret;
}
@ -21937,12 +21881,12 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
virObjectEventPtr event_new = NULL;
virObjectEventPtr event_old = NULL;
int ret = -1;
char *new_dom_name = NULL;
char *old_dom_name = NULL;
char *new_dom_cfg_file = NULL;
char *old_dom_cfg_file = NULL;
char *new_dom_autostart_link = NULL;
char *old_dom_autostart_link = NULL;
g_autofree char *new_dom_name = NULL;
g_autofree char *old_dom_name = NULL;
g_autofree char *new_dom_cfg_file = NULL;
g_autofree char *old_dom_cfg_file = NULL;
g_autofree char *new_dom_autostart_link = NULL;
g_autofree char *old_dom_autostart_link = NULL;
virCheckFlags(0, ret);
@ -22014,12 +21958,6 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
ret = 0;
cleanup:
VIR_FREE(old_dom_autostart_link);
VIR_FREE(new_dom_autostart_link);
VIR_FREE(old_dom_cfg_file);
VIR_FREE(new_dom_cfg_file);
VIR_FREE(old_dom_name);
VIR_FREE(new_dom_name);
virObjectEventStateQueue(driver->domainEventState, event_old);
virObjectEventStateQueue(driver->domainEventState, event_new);
return ret;
@ -22124,7 +22062,7 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
virBitmapPtr vcpus = NULL;
virBitmapPtr online = NULL;
virBitmapPtr offlinable = NULL;
char *tmp = NULL;
g_autofree char *tmp = NULL;
size_t i;
int ret = -1;
@ -22153,7 +22091,6 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
goto cleanup; \
if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0) \
goto cleanup; \
VIR_FREE(tmp)
ADD_BITMAP(vcpus);
ADD_BITMAP(online);
@ -22167,7 +22104,6 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
ret = 0;
cleanup:
VIR_FREE(tmp);
virBitmapFree(vcpus);
virBitmapFree(online);
virBitmapFree(offlinable);
@ -22395,7 +22331,7 @@ qemuDomainSetBlockThreshold(virDomainPtr dom,
qemuDomainObjPrivatePtr priv;
virDomainObjPtr vm = NULL;
virStorageSourcePtr src;
char *nodename = NULL;
g_autofree char *nodename = NULL;
int rc;
int ret = -1;
@ -22449,7 +22385,6 @@ qemuDomainSetBlockThreshold(virDomainPtr dom,
qemuDomainObjEndJob(driver, vm);
cleanup:
VIR_FREE(nodename);
virDomainObjEndAPI(&vm);
return ret;
}
@ -22628,7 +22563,7 @@ qemuDomainGetSEVMeasurement(virQEMUDriverPtr driver,
unsigned int flags)
{
int ret = -1;
char *tmp = NULL;
g_autofree char *tmp = NULL;
int maxpar = 0;
virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
@ -22653,7 +22588,6 @@ qemuDomainGetSEVMeasurement(virQEMUDriverPtr driver,
ret = 0;
endjob:
VIR_FREE(tmp);
qemuDomainObjEndJob(driver, vm);
return ret;
}