From nobody Sun Feb 8 18:14:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571752864; cv=none; d=zoho.com; s=zohoarc; b=k6QTxM5Wu0JdpcxE1Udo0Dupg7AISrotNllWlZ3jkjaMgPNhqaooHPWZuZqQn8pfwCwA+TwJFFtOIzT5/IEql2DLjP5AzMsvy3bLxkGBwX6VxICMNuRJgqHNSy1j5QGbFqh3NKpAs0gQK4ts1aPryckWJ3dIXj6KJt2orLB6k+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571752864; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PBySlvW9vq1RQfrGYRDJeTjstfxzF5f0+tP28hQDS7k=; b=citNz1Zw2adl6bifVw7WKb/XzkbPHsKKYBm7JJ/q63wg42Tv2ol2DWk/3hof5DPny3Is69dvc76yr83JVcA48Jz3WVmUQu0sFvlbo0wbDIBT7ICi/76dfmqiQU/qxuNB7DCZF3USEygokPPPbIr8sRu44zmXqycqLjZTDj7Zork= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571752864968124.33952290905142; Tue, 22 Oct 2019 07:01:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-62lBeyCRNTu1YTp4j-jKxw-1; Tue, 22 Oct 2019 10:00:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8771D107AD35; Tue, 22 Oct 2019 14:00:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A505194BB; Tue, 22 Oct 2019 14:00:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E2014180BA98; Tue, 22 Oct 2019 14:00:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9ME0gI0002641 for ; Tue, 22 Oct 2019 10:00:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A43C60467; Tue, 22 Oct 2019 14:00:42 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0C015C6D9 for ; Tue, 22 Oct 2019 14:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571752862; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PBySlvW9vq1RQfrGYRDJeTjstfxzF5f0+tP28hQDS7k=; b=MZMhuUVhT5vWk1474oO+1Io6g4ndNg7OU6WieND7TK+3WoCWW15jXXEU6lv26seseNBdNE JC0Em0iQFCgI6pdSNulRSOyQ15FfhGMvemtXZi+k1sEHnGXjCimNiQc78x8OEsqz7fjkAH WARmDWyPtfDZjyYgzNqI7kgRC9BonSA= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 15:57:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 44/75] libxl: Use g_strdup_printf() instead of virAsprintf() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 62lBeyCRNTu1YTp4j-jKxw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- 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) =20 case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: - virAsprintf(buf, "%s:%s", type, srcdef->data.file.path); + *buf =3D g_strdup_printf("%s:%s", type, srcdef->data.file.path); break; =20 case VIR_DOMAIN_CHR_TYPE_DEV: @@ -231,8 +231,8 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) if (bindService =3D=3D NULL) bindService =3D "0"; =20 - virAsprintf(buf, "udp:%s:%s@%s:%s", connectHost, - srcdef->data.udp.connectService, bindHost, bindService= ); + *buf =3D g_strdup_printf("udp:%s:%s@%s:%s", connectHost, + srcdef->data.udp.connectService, bindHost, b= indService); break; } =20 @@ -244,15 +244,15 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) else prefix =3D "tcp"; =20 - virAsprintf(buf, "%s:%s:%s%s", prefix, srcdef->data.tcp.host, - srcdef->data.tcp.service, - srcdef->data.tcp.listen ? ",server,nowait" : ""); + *buf =3D g_strdup_printf("%s:%s:%s%s", prefix, srcdef->data.tcp.ho= st, + srcdef->data.tcp.service, + srcdef->data.tcp.listen ? ",server,nowait" := ""); break; } =20 case VIR_DOMAIN_CHR_TYPE_UNIX: - virAsprintf(buf, "unix:%s%s", srcdef->data.nix.path, - srcdef->data.nix.listen ? ",server,nowait" : ""); + *buf =3D g_strdup_printf("unix:%s%s", srcdef->data.nix.path, + srcdef->data.nix.listen ? ",server,nowait" := ""); break; =20 default: @@ -1927,9 +1927,9 @@ libxlPrepareChannel(virDomainChrDefPtr channel, if (channel->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN = && channel->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX && !channel->source->data.nix.path) { - virAsprintf(&channel->source->data.nix.path, "%s/%s-%s", channelDi= r, - domainName, - channel->target.name ? channel->target.name : "unknown= .sock"); + channel->source->data.nix.path =3D g_strdup_printf("%s/%s-%s", cha= nnelDir, + domainName, + channel->target.n= ame ? channel->target.name : "unknown.sock"); =20 channel->source->data.nix.listen =3D 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 =3D libxlDriverConfigGet(driver); =20 - virAsprintf(&ret, "%s/%s.save", cfg->saveDir, vm->def->name); + ret =3D g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->name); return ret; } =20 @@ -905,7 +905,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, } } =20 - virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name); + file =3D g_strdup_printf("%s/%s.xml", cfg->stateDir, vm->def->name); =20 if (unlink(file) < 0 && errno !=3D ENOENT && errno !=3D 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); =20 - virAsprintf(&dumpfile, "%s/%s-%s", cfg->autoDumpDir, vm->def->name, - timestr); + dumpfile =3D g_strdup_printf("%s/%s-%s", cfg->autoDumpDir, vm->def->na= me, + timestr); =20 /* Unlock virDomainObj while dumping core */ virObjectUnlock(vm); @@ -1121,7 +1121,7 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev,= void *for_callback) for (i =3D 0; i < vm->def->nserials; i++) { chr =3D vm->def->serials[i]; =20 - virAsprintf(&chr->info.alias, "serial%zd", i); + chr->info.alias =3D g_strdup_printf("serial%zd", i); if (chr->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) { if (chr->source->data.file.path) continue; @@ -1161,9 +1161,8 @@ libxlDomainCreateIfaceNames(virDomainDefPtr def, libx= l_domain_config *d_config) if (net->ifname) continue; =20 - virAsprintf(&net->ifname, - LIBXL_GENERATED_PREFIX_XEN "%d.%d%s", - def->id, x_nic->devid, suffix); + net->ifname =3D g_strdup_printf(LIBXL_GENERATED_PREFIX_XEN "%d.%d%= s", + def->id, x_nic->devid, suffix); } } =20 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 =3D libxlDriverConfigNew())) goto error; =20 - virAsprintf(&driverConf, "%s/libxl.conf", cfg->configBaseDir); + driverConf =3D g_strdup_printf("%s/libxl.conf", cfg->configBaseDir); =20 if (libxlDriverConfigLoadFile(cfg, driverConf) < 0) goto error; @@ -5390,13 +5390,13 @@ libxlDiskSectorSize(int domid, int devno) } =20 path =3D val =3D NULL; - virAsprintf(&path, "/local/domain/%d/device/vbd/%d/backend", domid, de= vno); + path =3D g_strdup_printf("/local/domain/%d/device/vbd/%d/backend", dom= id, devno); =20 if ((val =3D xs_read(handle, XBT_NULL, path, &len)) =3D=3D NULL) goto cleanup; =20 VIR_FREE(path); - virAsprintf(&path, "%s/physical-sector-size", val); + path =3D g_strdup_printf("%s/physical-sector-size", val); =20 VIR_FREE(val); if ((val =3D xs_read(handle, XBT_NULL, path, &len)) =3D=3D NULL) @@ -5434,8 +5434,8 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm, =20 stats->backend =3D g_strdup("vbd"); =20 - virAsprintf(&path, "/sys/bus/xen-backend/devices/vbd-%d-%d/statistics", - vm->def->id, devno); + path =3D g_strdup_printf("/sys/bus/xen-backend/devices/vbd-%d-%d/stati= stics", + vm->def->id, devno); =20 if (!virFileExists(path)) { virReportError(VIR_ERR_OPERATION_FAILED, @@ -5444,7 +5444,7 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm, } =20 # define LIBXL_SET_VBDSTAT(FIELD, VAR, MUL) \ - virAsprintf(&name, "%s/"FIELD, path); \ + name =3D g_strdup_printf("%s/"FIELD, path); \ if ((virFileReadAll(name, 256, &val) < 0) || \ (sscanf(val, "%llu", &status) !=3D 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 minLe= vel) if ((logger.files =3D virHashCreate(3, libxlLoggerFileFree)) =3D=3D NU= LL) return NULL; =20 - virAsprintf(&path, "%s/libxl-driver.log", logDir); + path =3D g_strdup_printf("%s/libxl-driver.log", logDir); =20 if ((logger.defaultLogFile =3D fopen(path, "a")) =3D=3D NULL) goto error; @@ -195,8 +195,8 @@ libxlLoggerOpenFile(libxlLoggerPtr logger, char *domidstr =3D NULL; char ebuf[1024]; =20 - virAsprintf(&path, "%s/%s.log", logger->logDir, name); - virAsprintf(&domidstr, "%d", id); + path =3D g_strdup_printf("%s/%s.log", logger->logDir, name); + domidstr =3D g_strdup_printf("%d", id); =20 if (!(logFile =3D fopen(path, "a"))) { VIR_WARN("Failed to open log file %s: %s", @@ -220,7 +220,7 @@ void libxlLoggerCloseFile(libxlLoggerPtr logger, int id) { char *domidstr =3D NULL; - virAsprintf(&domidstr, "%d", id); + domidstr =3D g_strdup_printf("%d", id); =20 ignore_value(virHashRemoveEntry(logger->files, domidstr)); =20 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; =20 priv->migrationPort =3D port; - virAsprintf(uri_out, "tcp://%s:%d", hostname, port); + *uri_out =3D 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 =3D g_strdup_printf("tcp://%s", uri_in); uri =3D virURIParse(tmp); VIR_FREE(tmp); } else { @@ -745,7 +745,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, port =3D uri->port; } =20 - virAsprintf(uri_out, "tcp://%s:%d", hostname, port); + *uri_out =3D g_strdup_printf("tcp://%s:%d", hostname, port); } =20 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; =20 - 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.functio= n); + buf =3D g_strdup_printf("%04x:%02x:%02x.%x", + def->hostdevs[i]->source.subsys.u.pci.ad= dr.domain, + def->hostdevs[i]->source.subsys.u.pci.ad= dr.bus, + def->hostdevs[i]->source.subsys.u.pci.ad= dr.slot, + def->hostdevs[i]->source.subsys.u.pci.ad= dr.function); =20 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_cmdl= ine) VIR_WARN("ignoring root=3D and extra=3D in favour of cmdline= =3D"); } else { if (root && extra) { - virAsprintf(&cmdline, "root=3D%s %s", root, extra); + cmdline =3D g_strdup_printf("root=3D%s %s", root, extra); } else if (root) { - virAsprintf(&cmdline, "root=3D%s", root); + cmdline =3D g_strdup_printf("root=3D%s", root); } else if (extra) { cmdline =3D g_strdup(extra); } @@ -1394,7 +1394,7 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def) policy =3D "0"; break; } - virAsprintf(&cpuid_pairs[j++], "%s=3D%s", feature_name, policy); + cpuid_pairs[j++] =3D g_strdup_printf("%s=3D%s", feature_name, poli= cy); } cpuid_pairs[j] =3D NULL; =20 @@ -2068,9 +2068,9 @@ xenFormatXLUSB(virConfPtr conf, virConfValuePtr val, tmp; char *buf; =20 - virAsprintf(&buf, "hostbus=3D%x,hostaddr=3D%x", - def->hostdevs[i]->source.subsys.u.usb.bus, - def->hostdevs[i]->source.subsys.u.usb.device); + buf =3D g_strdup_printf("hostbus=3D%x,hostaddr=3D%x", + def->hostdevs[i]->source.subsys.u.usb.bu= s, + def->hostdevs[i]->source.subsys.u.usb.de= vice); =20 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; =20 if (root && extra) { - virAsprintf(&def->os.cmdline, "root=3D%s %s", root, extra); + def->os.cmdline =3D g_strdup_printf("root=3D%s %s", root, extr= a); } else if (root) { - virAsprintf(&def->os.cmdline, "root=3D%s", root); + def->os.cmdline =3D g_strdup_printf("root=3D%s", root); } else if (extra) { def->os.cmdline =3D g_strdup(extra); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list