This patch changes all virAsprintf calls to use the GLib API
g_strdup_printf in qemu_process.c.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_process.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8843ed20da..1a168fbb76 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -110,7 +110,7 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir,
vm->def->name) < 0)
+ if (!(file = g_strdup_printf("%s/%s.xml", cfg->stateDir,
vm->def->name)))
return -1;
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
@@ -2089,7 +2089,7 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
qemuMonitorChardevInfoPtr entry;
VIR_FREE(id);
- if (virAsprintf(&id, "char%s", chr->info.alias) < 0)
+ if (!(id = g_strdup_printf("char%s", chr->info.alias)))
return -1;
entry = virHashLookup(info, id);
@@ -2177,7 +2177,7 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
if (chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
VIR_FREE(id);
- if (virAsprintf(&id, "char%s", chr->info.alias) < 0)
+ if (!(id = g_strdup_printf("char%s", chr->info.alias)))
return -1;
/* port state not reported */
@@ -3172,8 +3172,7 @@ qemuProcessPrepareMonitorChr(virDomainChrSourceDefPtr monConfig,
monConfig->type = VIR_DOMAIN_CHR_TYPE_UNIX;
monConfig->data.nix.listen = true;
- if (virAsprintf(&monConfig->data.nix.path, "%s/monitor.sock",
- domainDir) < 0)
+ if (!(monConfig->data.nix.path = g_strdup_printf("%s/monitor.sock",
domainDir)))
return -1;
return 0;
}
@@ -3376,8 +3375,8 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
} else {
newState = VIR_DOMAIN_PAUSED;
newReason = reason;
- ignore_value(virAsprintf(&msg, "was paused (%s)",
- virDomainPausedReasonTypeToString(reason)));
+ msg = g_strdup_printf("was paused (%s)",
+ virDomainPausedReasonTypeToString(reason));
}
}
@@ -4024,8 +4023,8 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
if (def->hyperv_features[i] != VIR_TRISTATE_SWITCH_ON)
continue;
- if (virAsprintf(&cpuFeature, "hv-%s",
- virDomainHypervTypeToString(i)) < 0)
+ if (!(cpuFeature = g_strdup_printf("hv-%s",
+ virDomainHypervTypeToString(i))))
return -1;
rc = virCPUDataCheckFeature(cpu, cpuFeature);
@@ -4850,8 +4849,8 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
* default instead of tcp listen. */
if (useSocket) {
memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
- if (virAsprintf(&glisten->socket, "%s/%s.sock",
- priv->libDir, type) < 0)
+ if (!(glisten->socket = g_strdup_printf("%s/%s.sock",
+ priv->libDir, type)))
return -1;
glisten->fromConfig = true;
glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
@@ -4874,8 +4873,8 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
if (!glisten->socket) {
- if (virAsprintf(&glisten->socket, "%s/%s.sock",
- priv->libDir, type) < 0)
+ if (!(glisten->socket = g_strdup_printf("%s/%s.sock",
+ priv->libDir, type)))
return -1;
glisten->autoGenerated = true;
}
@@ -5944,7 +5943,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriverPtr driver,
if (vcpu->hotpluggable == VIR_TRISTATE_BOOL_YES && vcpu->online
&&
vcpupriv->vcpus != 0) {
- if (virAsprintf(&vcpupriv->alias, "vcpu%zu", i) < 0)
+ if (!(vcpupriv->alias = g_strdup_printf("vcpu%zu", i)))
goto cleanup;
if (VIR_APPEND_ELEMENT(bootHotplug, nbootHotplug, vcpu) < 0)
@@ -8401,7 +8400,7 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
- if (virAsprintf(&template, "%s/qmp-XXXXXX", proc->libDir) < 0)
+ if (!(template = g_strdup_printf("%s/qmp-XXXXXX", proc->libDir)))
goto cleanup;
if (!(proc->uniqDir = mkdtemp(template))) {
@@ -8415,11 +8414,10 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
if (qemuProcessQEMULabelUniqPath(proc) < 0)
goto cleanup;
- if (virAsprintf(&proc->monpath, "%s/%s", proc->uniqDir,
- "qmp.monitor") < 0)
+ if (!(proc->monpath = g_strdup_printf("%s/%s", proc->uniqDir,
"qmp.monitor")))
goto cleanup;
- if (virAsprintf(&proc->monarg, "unix:%s,server,nowait",
proc->monpath) < 0)
+ if (!(proc->monarg = g_strdup_printf("unix:%s,server,nowait",
proc->monpath)))
goto cleanup;
/*
@@ -8427,7 +8425,7 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
* -daemonize we need QEMU to be allowed to create them, rather
* than libvirtd. So we're using libDir which QEMU can write to
*/
- if (virAsprintf(&proc->pidfile, "%s/%s", proc->uniqDir,
"qmp.pid") < 0)
+ if (!(proc->pidfile = g_strdup_printf("%s/%s", proc->uniqDir,
"qmp.pid")))
goto cleanup;
ret = 0;
--
2.21.0