Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libxl/libxl_conf.c | 22 +++++++++++-----------
src/libxl/libxl_domain.c | 15 +++++++--------
src/libxl/libxl_driver.c | 12 ++++++------
src/libxl/libxl_logger.c | 8 ++++----
src/libxl/libxl_migration.c | 6 +++---
src/libxl/xen_common.c | 10 +++++-----
src/libxl/xen_xl.c | 12 ++++++------
src/libxl/xen_xm.c | 4 ++--
8 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index a984c9c8aa..1ff2a6af07 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -212,7 +212,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
case VIR_DOMAIN_CHR_TYPE_FILE:
case VIR_DOMAIN_CHR_TYPE_PIPE:
- virAsprintf(buf, "%s:%s", type, srcdef->data.file.path);
+ *buf = g_strdup_printf("%s:%s", type, srcdef->data.file.path);
break;
case VIR_DOMAIN_CHR_TYPE_DEV:
@@ -231,8 +231,8 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
if (bindService == NULL)
bindService = "0";
- virAsprintf(buf, "udp:%s:%s@%s:%s", connectHost,
- srcdef->data.udp.connectService, bindHost, bindService);
+ *buf = g_strdup_printf("udp:%s:%s@%s:%s", connectHost,
+ srcdef->data.udp.connectService, bindHost,
bindService);
break;
}
@@ -244,15 +244,15 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
else
prefix = "tcp";
- virAsprintf(buf, "%s:%s:%s%s", prefix, srcdef->data.tcp.host,
- srcdef->data.tcp.service,
- srcdef->data.tcp.listen ? ",server,nowait" :
"");
+ *buf = g_strdup_printf("%s:%s:%s%s", prefix, srcdef->data.tcp.host,
+ srcdef->data.tcp.service,
+ srcdef->data.tcp.listen ? ",server,nowait" :
"");
break;
}
case VIR_DOMAIN_CHR_TYPE_UNIX:
- virAsprintf(buf, "unix:%s%s", srcdef->data.nix.path,
- srcdef->data.nix.listen ? ",server,nowait" :
"");
+ *buf = g_strdup_printf("unix:%s%s", srcdef->data.nix.path,
+ srcdef->data.nix.listen ? ",server,nowait" :
"");
break;
default:
@@ -1927,9 +1927,9 @@ libxlPrepareChannel(virDomainChrDefPtr channel,
if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN &&
channel->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
!channel->source->data.nix.path) {
- virAsprintf(&channel->source->data.nix.path, "%s/%s-%s",
channelDir,
- domainName,
- channel->target.name ? channel->target.name :
"unknown.sock");
+ channel->source->data.nix.path = g_strdup_printf("%s/%s-%s",
channelDir,
+ domainName,
+ channel->target.name ?
channel->target.name : "unknown.sock");
channel->source->data.nix.listen = true;
}
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index ebb739ae54..42fca19c5b 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -714,7 +714,7 @@ libxlDomainManagedSavePath(libxlDriverPrivatePtr driver,
virDomainObjPtr vm)
char *ret;
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
- virAsprintf(&ret, "%s/%s.save", cfg->saveDir, vm->def->name);
+ ret = g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->name);
return ret;
}
@@ -905,7 +905,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
}
}
- virAsprintf(&file, "%s/%s.xml", cfg->stateDir,
vm->def->name);
+ file = g_strdup_printf("%s/%s.xml", cfg->stateDir,
vm->def->name);
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name);
@@ -944,8 +944,8 @@ libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
localtime_r(&curtime, &time_info);
strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
- virAsprintf(&dumpfile, "%s/%s-%s", cfg->autoDumpDir,
vm->def->name,
- timestr);
+ dumpfile = g_strdup_printf("%s/%s-%s", cfg->autoDumpDir,
vm->def->name,
+ timestr);
/* Unlock virDomainObj while dumping core */
virObjectUnlock(vm);
@@ -1121,7 +1121,7 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void
*for_callback)
for (i = 0; i < vm->def->nserials; i++) {
chr = vm->def->serials[i];
- virAsprintf(&chr->info.alias, "serial%zd", i);
+ chr->info.alias = g_strdup_printf("serial%zd", i);
if (chr->source->type == VIR_DOMAIN_CHR_TYPE_PTY) {
if (chr->source->data.file.path)
continue;
@@ -1161,9 +1161,8 @@ libxlDomainCreateIfaceNames(virDomainDefPtr def, libxl_domain_config
*d_config)
if (net->ifname)
continue;
- virAsprintf(&net->ifname,
- LIBXL_GENERATED_PREFIX_XEN "%d.%d%s",
- def->id, x_nic->devid, suffix);
+ net->ifname = g_strdup_printf(LIBXL_GENERATED_PREFIX_XEN "%d.%d%s",
+ def->id, x_nic->devid, suffix);
}
}
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 69a949ee26..b1ea55b560 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -693,7 +693,7 @@ libxlStateInitialize(bool privileged,
if (!(cfg = libxlDriverConfigNew()))
goto error;
- virAsprintf(&driverConf, "%s/libxl.conf", cfg->configBaseDir);
+ driverConf = g_strdup_printf("%s/libxl.conf", cfg->configBaseDir);
if (libxlDriverConfigLoadFile(cfg, driverConf) < 0)
goto error;
@@ -5390,13 +5390,13 @@ libxlDiskSectorSize(int domid, int devno)
}
path = val = NULL;
- virAsprintf(&path, "/local/domain/%d/device/vbd/%d/backend", domid,
devno);
+ path = g_strdup_printf("/local/domain/%d/device/vbd/%d/backend", domid,
devno);
if ((val = xs_read(handle, XBT_NULL, path, &len)) == NULL)
goto cleanup;
VIR_FREE(path);
- virAsprintf(&path, "%s/physical-sector-size", val);
+ path = g_strdup_printf("%s/physical-sector-size", val);
VIR_FREE(val);
if ((val = xs_read(handle, XBT_NULL, path, &len)) == NULL)
@@ -5434,8 +5434,8 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm,
stats->backend = g_strdup("vbd");
- virAsprintf(&path,
"/sys/bus/xen-backend/devices/vbd-%d-%d/statistics",
- vm->def->id, devno);
+ path =
g_strdup_printf("/sys/bus/xen-backend/devices/vbd-%d-%d/statistics",
+ vm->def->id, devno);
if (!virFileExists(path)) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -5444,7 +5444,7 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm,
}
# define LIBXL_SET_VBDSTAT(FIELD, VAR, MUL) \
- virAsprintf(&name, "%s/"FIELD, path); \
+ name = g_strdup_printf("%s/"FIELD, path); \
if ((virFileReadAll(name, 256, &val) < 0) || \
(sscanf(val, "%llu", &status) != 1)) { \
virReportError(VIR_ERR_OPERATION_FAILED, \
diff --git a/src/libxl/libxl_logger.c b/src/libxl/libxl_logger.c
index 4bdca54fcc..ffbc722f2c 100644
--- a/src/libxl/libxl_logger.c
+++ b/src/libxl/libxl_logger.c
@@ -158,7 +158,7 @@ libxlLoggerNew(const char *logDir, virLogPriority minLevel)
if ((logger.files = virHashCreate(3, libxlLoggerFileFree)) == NULL)
return NULL;
- virAsprintf(&path, "%s/libxl-driver.log", logDir);
+ path = g_strdup_printf("%s/libxl-driver.log", logDir);
if ((logger.defaultLogFile = fopen(path, "a")) == NULL)
goto error;
@@ -195,8 +195,8 @@ libxlLoggerOpenFile(libxlLoggerPtr logger,
char *domidstr = NULL;
char ebuf[1024];
- virAsprintf(&path, "%s/%s.log", logger->logDir, name);
- virAsprintf(&domidstr, "%d", id);
+ path = g_strdup_printf("%s/%s.log", logger->logDir, name);
+ domidstr = g_strdup_printf("%d", id);
if (!(logFile = fopen(path, "a"))) {
VIR_WARN("Failed to open log file %s: %s",
@@ -220,7 +220,7 @@ void
libxlLoggerCloseFile(libxlLoggerPtr logger, int id)
{
char *domidstr = NULL;
- virAsprintf(&domidstr, "%d", id);
+ domidstr = g_strdup_printf("%d", id);
ignore_value(virHashRemoveEntry(logger->files, domidstr));
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 09b709e51b..6bee653e3f 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -709,12 +709,12 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn,
goto endjob;
priv->migrationPort = port;
- virAsprintf(uri_out, "tcp://%s:%d", hostname, port);
+ *uri_out = g_strdup_printf("tcp://%s:%d", hostname, port);
} else {
if (!(STRPREFIX(uri_in, "tcp://"))) {
/* not full URI, add prefix tcp:// */
char *tmp;
- virAsprintf(&tmp, "tcp://%s", uri_in);
+ tmp = g_strdup_printf("tcp://%s", uri_in);
uri = virURIParse(tmp);
VIR_FREE(tmp);
} else {
@@ -745,7 +745,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn,
port = uri->port;
}
- virAsprintf(uri_out, "tcp://%s:%d", hostname, port);
+ *uri_out = g_strdup_printf("tcp://%s:%d", hostname, port);
}
snprintf(portstr, sizeof(portstr), "%d", port);
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 826e6699bf..b6865098ed 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -1838,11 +1838,11 @@ xenFormatPCI(virConfPtr conf, virDomainDefPtr def)
virConfValuePtr val, tmp;
char *buf;
- virAsprintf(&buf, "%04x:%02x:%02x.%x",
- def->hostdevs[i]->source.subsys.u.pci.addr.domain,
- def->hostdevs[i]->source.subsys.u.pci.addr.bus,
- def->hostdevs[i]->source.subsys.u.pci.addr.slot,
- def->hostdevs[i]->source.subsys.u.pci.addr.function);
+ buf = g_strdup_printf("%04x:%02x:%02x.%x",
+
def->hostdevs[i]->source.subsys.u.pci.addr.domain,
+ def->hostdevs[i]->source.subsys.u.pci.addr.bus,
+ def->hostdevs[i]->source.subsys.u.pci.addr.slot,
+
def->hostdevs[i]->source.subsys.u.pci.addr.function);
if (VIR_ALLOC(val) < 0) {
VIR_FREE(buf);
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index a7c51e3c98..67fb5366b2 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -83,9 +83,9 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
VIR_WARN("ignoring root= and extra= in favour of cmdline=");
} else {
if (root && extra) {
- virAsprintf(&cmdline, "root=%s %s", root, extra);
+ cmdline = g_strdup_printf("root=%s %s", root, extra);
} else if (root) {
- virAsprintf(&cmdline, "root=%s", root);
+ cmdline = g_strdup_printf("root=%s", root);
} else if (extra) {
cmdline = g_strdup(extra);
}
@@ -1394,7 +1394,7 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def)
policy = "0";
break;
}
- virAsprintf(&cpuid_pairs[j++], "%s=%s", feature_name, policy);
+ cpuid_pairs[j++] = g_strdup_printf("%s=%s", feature_name, policy);
}
cpuid_pairs[j] = NULL;
@@ -2068,9 +2068,9 @@ xenFormatXLUSB(virConfPtr conf,
virConfValuePtr val, tmp;
char *buf;
- virAsprintf(&buf, "hostbus=%x,hostaddr=%x",
- def->hostdevs[i]->source.subsys.u.usb.bus,
- def->hostdevs[i]->source.subsys.u.usb.device);
+ buf = g_strdup_printf("hostbus=%x,hostaddr=%x",
+ def->hostdevs[i]->source.subsys.u.usb.bus,
+ def->hostdevs[i]->source.subsys.u.usb.device);
if (VIR_ALLOC(val) < 0) {
VIR_FREE(buf);
diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c
index d962b13cbb..6f85b2793b 100644
--- a/src/libxl/xen_xm.c
+++ b/src/libxl/xen_xm.c
@@ -90,9 +90,9 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
return -1;
if (root && extra) {
- virAsprintf(&def->os.cmdline, "root=%s %s", root, extra);
+ def->os.cmdline = g_strdup_printf("root=%s %s", root, extra);
} else if (root) {
- virAsprintf(&def->os.cmdline, "root=%s", root);
+ def->os.cmdline = g_strdup_printf("root=%s", root);
} else if (extra) {
def->os.cmdline = g_strdup(extra);
}
--
2.21.0