priv = vm->privateData;
- if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
+ if (!(snapDir = g_strdup_printf("%s/%s", baseDir, vm->def->name))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to allocate memory for "
"snapshot directory for domain %s"),
kill the whole process */
VIR_INFO("Loading snapshot file '%s'", entry->d_name);
- if (virAsprintf(&fullpath, "%s/%s", snapDir, entry->d_name) < 0) {
+ if (!(fullpath = g_strdup_printf("%s/%s", snapDir, entry->d_name))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to allocate memory for path"));
continue;
virObjectLock(vm);
priv = vm->privateData;
- if (virAsprintf(&chkDir, "%s/%s", baseDir, vm->def->name) < 0) {
+ if (!(chkDir = g_strdup_printf("%s/%s", baseDir, vm->def->name))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to allocate memory for "
"checkpoint directory for domain %s"),
kill the whole process */
VIR_INFO("Loading checkpoint file '%s'", entry->d_name);
- if (virAsprintf(&fullpath, "%s/%s", chkDir, entry->d_name) < 0) {
+ if (!(fullpath = g_strdup_printf("%s/%s", chkDir, entry->d_name))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to allocate memory for path"));
continue;
if (!(qemu_driver->config = cfg = virQEMUDriverConfigNew(privileged)))
goto error;
- if (virAsprintf(&driverConf, "%s/qemu.conf", cfg->configBaseDir) < 0)
+ if (!(driverConf = g_strdup_printf("%s/qemu.conf", cfg->configBaseDir)))
goto error;
if (virQEMUDriverConfigLoadFile(cfg, driverConf, privileged) < 0)
/* In general, we cannot assume pid_t fits in int; but /proc parsing
* is specific to Linux where int works fine. */
if (tid)
- ret = virAsprintf(&proc, "/proc/%d/task/%d/sched", (int)pid, (int)tid);
+ proc = g_strdup_printf("/proc/%d/task/%d/sched", (int)pid, (int)tid);
else
- ret = virAsprintf(&proc, "/proc/%d/sched", (int)pid);
- if (ret < 0)
+ proc = g_strdup_printf("/proc/%d/sched", (int)pid);
+ if (!proc)
goto cleanup;
ret = -1;
unsigned long long usertime = 0, systime = 0;
long rss = 0;
int cpu = 0;
- int ret;
/* In general, we cannot assume pid_t fits in int; but /proc parsing
* is specific to Linux where int works fine. */
if (tid)
- ret = virAsprintf(&proc, "/proc/%d/task/%d/stat", (int)pid, tid);
+ proc = g_strdup_printf("/proc/%d/task/%d/stat", (int)pid, tid);
else
- ret = virAsprintf(&proc, "/proc/%d/stat", (int)pid);
- if (ret < 0)
+ proc = g_strdup_printf("/proc/%d/stat", (int)pid);
+ if (!proc)
return -1;
pidinfo = fopen(proc, "r");
char *ret;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- if (virAsprintf(&ret, "%s/%s.save", cfg->saveDir, vm->def->name) < 0)
+ if (!(ret = g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->name)))
return NULL;
return ret;
}
}
- if (virAsprintf(&tmp, "%s/qemu.screendump.XXXXXX", cfg->cacheDir) < 0)
+ if (!(tmp = g_strdup_printf("%s/qemu.screendump.XXXXXX", cfg->cacheDir)))
goto endjob;
if ((tmp_fd = mkostemp(tmp, O_CLOEXEC)) == -1) {
localtime_r(&curtime, &time_info);
strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
- ignore_value(virAsprintf(&dumpfile, "%s/%s-%s",
- cfg->autoDumpPath,
- domname,
- timestr));
+ dumpfile = g_strdup_printf("%s/%s-%s", cfg->autoDumpPath, domname, timestr);
return dumpfile;
}
virDomainIOThreadIDDefPtr iothrid;
virJSONValuePtr props = NULL;
- if (virAsprintf(&alias, "iothread%u", iothread_id) < 0)
+ if (!(alias = g_strdup_printf("iothread%u", iothread_id)))
return -1;
if (qemuMonitorCreateObjectProps(&props, "iothread", alias, NULL) < 0)
int new_niothreads = 0;
qemuMonitorIOThreadInfoPtr *new_iothreads = NULL;
- if (virAsprintf(&alias, "iothread%u", iothread_id) < 0)
+ if (!(alias = g_strdup_printf("iothread%u", iothread_id)))
return -1;
qemuDomainObjEnterMonitor(driver, vm);
if (virDomainObjCheckActive(vm) < 0)
goto endjob;
- if (virAsprintf(&tmp, "%s/qemu.mem.XXXXXX", cfg->cacheDir) < 0)
+ if (!(tmp = g_strdup_printf("%s/qemu.mem.XXXXXX", cfg->cacheDir)))
goto endjob;
/* Create a temporary filename. */