From nobody Mon Feb 9 09:01:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1571752865; cv=none; d=zoho.com; s=zohoarc; b=P7YR/8pWotF+vooime8R+mrjQIshHIfiOOvoCyX2MhR6aTxALdvXYe2yQlyXnuyXsb3drqWe6ID2tm+qncArF4xDZzn9vbNVgJNFkMrgxiceK4v5HLb5kZpHnSP0UUudwMr/AlL/VR0R1OYkee2BphoEbxlzl2iqHqQyX/6GGfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571752865; 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=D1UdoHwoiv77/BKrUiOyw6Vad4NojG3gGgl1z/6CeOY=; b=cYz2DeIwq0bEu97ogrNeILSe5S9BRWzJUBq4lCnloH5YuR/QkzP/JTpsOvu5bREntt/1vQzJHIjfjuQi7U/vFv7+dmbxp82VnX8g+qn3mG7LWW0d8s3UhWQoAuOAaWhj25jLltsu/ttxbLOy5MZz0gDkiTVfxZE++psx/9bl8O8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571752865093115.98067346615346; Tue, 22 Oct 2019 07:01:05 -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-243-ozJr_o2UN9Oc6EpY3JZNGQ-1; Tue, 22 Oct 2019 10:00:50 -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 571501005526; Tue, 22 Oct 2019 14:00:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6099EA226; Tue, 22 Oct 2019 14:00:44 +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 254B93FB46; Tue, 22 Oct 2019 14:00:43 +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 x9ME0dHg002580 for ; Tue, 22 Oct 2019 10:00:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C7A46046B; Tue, 22 Oct 2019 14:00:39 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED29605C6 for ; Tue, 22 Oct 2019 14:00:38 +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=D1UdoHwoiv77/BKrUiOyw6Vad4NojG3gGgl1z/6CeOY=; b=F5zyS9gZL3scVb5DZNuTiguYOI2AtuED8IRIJ6DEh1GsAxFzBubGsy103Z/y3XtJfMJok+ 1QdJRJcTQ+tQ5gvXR+Pg43PmdshRRoPZC1IrEPQApj8XSkS4xCRquexFX3MoFpK2HP4GQ5 oseYqa7T4nVaeHpJP1yvjwkn3Lygkgs= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 15:57:45 +0200 Message-Id: <8168115fa862311c1ecd65f7a5881c97127e3d1e.1571752582.git.mprivozn@redhat.com> 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 41/75] esx: 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: ozJr_o2UN9Oc6EpY3JZNGQ-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/esx/esx_driver.c | 40 +++++++++++++------------- src/esx/esx_storage_backend_vmfs.c | 46 +++++++++++++++--------------- src/esx/esx_stream.c | 8 +++--- src/esx/esx_vi.c | 23 +++++++-------- 4 files changed, 58 insertions(+), 59 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 117ac674d4..8117c454e4 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -143,8 +143,8 @@ esxParseVMXFileName(const char *fileName, void *opaque) =20 if (!strchr(fileName, '/') && !strchr(fileName, '\\')) { /* Plain file name, use same directory as for the .vmx file */ - virAsprintf(&result, "%s/%s", data->datastorePathWithoutFileName, - fileName); + result =3D g_strdup_printf("%s/%s", data->datastorePathWithoutFile= Name, + fileName); } else { if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name") < 0 || @@ -188,7 +188,7 @@ esxParseVMXFileName(const char *fileName, void *opaque) ++tmp; } =20 - virAsprintf(&result, "[%s] %s", datastoreName, strippedFileNam= e); + result =3D g_strdup_printf("[%s] %s", datastoreName, strippedF= ileName); =20 break; } @@ -222,8 +222,8 @@ esxParseVMXFileName(const char *fileName, void *opaque) goto cleanup; } =20 - virAsprintf(&result, "[%s] %s", datastoreName, - directoryAndFileName); + result =3D g_strdup_printf("[%s] %s", datastoreName, + directoryAndFileName); } =20 /* If it's an absolute path outside of a datastore just use it as = is */ @@ -635,8 +635,8 @@ esxConnectToHost(esxPrivate *priv, conn->uri->server))) goto cleanup; =20 - virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport, - conn->uri->server, conn->uri->port); + url =3D g_strdup_printf("%s://%s:%d/sdk", priv->parsedUri->transport, + conn->uri->server, conn->uri->port); =20 if (esxVI_Context_Alloc(&priv->host) < 0 || esxVI_Context_Connect(priv->host, url, ipAddress, username, passwo= rd, @@ -723,8 +723,8 @@ esxConnectToVCenter(esxPrivate *priv, if (!(password =3D virAuthGetPassword(conn, auth, "esx", username, hos= tname))) goto cleanup; =20 - virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport, hostna= me, - conn->uri->port); + url =3D g_strdup_printf("%s://%s:%d/sdk", priv->parsedUri->transport, = hostname, + conn->uri->port); =20 if (esxVI_Context_Alloc(&priv->vCenter) < 0 || esxVI_Context_Connect(priv->vCenter, url, ipAddress, username, @@ -1158,7 +1158,7 @@ esxConnectGetHostname(virConnectPtr conn) if (!domainName || strlen(domainName) < 1) { complete =3D g_strdup(hostName); } else { - virAsprintf(&complete, "%s.%s", hostName, domainName); + complete =3D g_strdup_printf("%s.%s", hostName, domainName); } =20 cleanup: @@ -2638,10 +2638,10 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned i= nt flags) data.ctx =3D priv->primary; =20 if (!directoryName) { - virAsprintf(&data.datastorePathWithoutFileName, "[%s]", datastoreN= ame); + data.datastorePathWithoutFileName =3D g_strdup_printf("[%s]", data= storeName); } else { - virAsprintf(&data.datastorePathWithoutFileName, "[%s] %s", - datastoreName, directoryName); + data.datastorePathWithoutFileName =3D g_strdup_printf("[%s] %s", + datastoreName,= directoryName); } =20 ctx.opaque =3D &data; @@ -3106,11 +3106,11 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flags) =20 /* Register the domain */ if (directoryName) { - virAsprintf(&datastoreRelatedPath, "[%s] %s/%s.vmx", datastoreName, - directoryName, escapedName); + datastoreRelatedPath =3D g_strdup_printf("[%s] %s/%s.vmx", datasto= reName, + directoryName, escapedName); } else { - virAsprintf(&datastoreRelatedPath, "[%s] %s.vmx", datastoreName, - escapedName); + datastoreRelatedPath =3D g_strdup_printf("[%s] %s.vmx", datastoreN= ame, + escapedName); } =20 if (esxVI_RegisterVM_Task(priv->primary, priv->primary->datacenter->vm= Folder, @@ -3722,9 +3722,9 @@ esxDomainMigratePrepare(virConnectPtr dconn, virCheckFlags(ESX_MIGRATION_FLAGS, -1); =20 if (!uri_in) { - virAsprintf(uri_out, "vpxmigr://%s/%s/%s", priv->vCenter->ipAddres= s, - priv->vCenter->computeResource->resourcePool->value, - priv->vCenter->hostSystem->_reference->value); + *uri_out =3D g_strdup_printf("vpxmigr://%s/%s/%s", priv->vCenter->= ipAddress, + priv->vCenter->computeResource->resourc= ePool->value, + priv->vCenter->hostSystem->_reference->= value); } =20 return 0; diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 24deee7215..5f25f80072 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -606,8 +606,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char = **const names, if (length < 1) { names[count] =3D g_strdup(fileInfo->path); } else { - virAsprintf(&names[count], "%s/%s", - directoryAndFileName, fileInfo->path); + names[count] =3D g_strdup_printf("%s/%s", + directoryAndFileName, fileI= nfo->path); } =20 ++count; @@ -641,7 +641,7 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, char *datastorePath =3D NULL; char *key =3D NULL; =20 - virAsprintf(&datastorePath, "[%s] %s", pool->name, name); + datastorePath =3D g_strdup_printf("[%s] %s", pool->name, name); =20 if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, datastorePath, &key) <= 0) { @@ -773,11 +773,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const ch= ar *key) if (length < 1) { volumeName =3D g_strdup(fileInfo->path); } else { - virAsprintf(&volumeName, "%s/%s", - directoryAndFileName, fileInfo->path); + volumeName =3D g_strdup_printf("%s/%s", + directoryAndFileName, fil= eInfo->path); } =20 - virAsprintf(&datastorePath, "[%s] %s", datastoreName, volu= meName); + datastorePath =3D g_strdup_printf("[%s] %s", datastoreName= , volumeName); =20 if (!esxVI_VmDiskFileInfo_DynamicCast(fileInfo)) { /* Only a VirtualDisk has a UUID */ @@ -884,7 +884,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, goto cleanup; } =20 - virAsprintf(&unescapedDatastorePath, "[%s] %s", pool->name, def->name); + unescapedDatastorePath =3D g_strdup_printf("[%s] %s", pool->name, def-= >name); =20 if (def->target.format =3D=3D VIR_STORAGE_FILE_VMDK) { /* Parse and escape datastore path */ @@ -905,11 +905,11 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, if (!fileName) goto cleanup; =20 - virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name, - directoryName); + datastorePathWithoutFileName =3D g_strdup_printf("[%s] %s", pool->= name, + directoryName); =20 - virAsprintf(&datastorePath, "[%s] %s/%s", pool->name, directoryNam= e, - fileName); + datastorePath =3D g_strdup_printf("[%s] %s/%s", pool->name, direct= oryName, + fileName); =20 /* Create directory, if it doesn't exist yet */ if (esxVI_LookupFileInfoByDatastorePath @@ -1066,8 +1066,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; } =20 - virAsprintf(&sourceDatastorePath, "[%s] %s", sourceVolume->pool, - sourceVolume->name); + sourceDatastorePath =3D g_strdup_printf("[%s] %s", sourceVolume->pool, + sourceVolume->name); =20 /* Parse config */ def =3D virStorageVolDefParseString(&poolDef, xmldesc, 0); @@ -1098,7 +1098,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; } =20 - virAsprintf(&unescapedDatastorePath, "[%s] %s", pool->name, def->name); + unescapedDatastorePath =3D g_strdup_printf("[%s] %s", pool->name, def-= >name); =20 if (def->target.format =3D=3D VIR_STORAGE_FILE_VMDK) { /* Parse and escape datastore path */ @@ -1119,11 +1119,11 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, if (!fileName) goto cleanup; =20 - virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name, - directoryName); + datastorePathWithoutFileName =3D g_strdup_printf("[%s] %s", pool->= name, + directoryName); =20 - virAsprintf(&datastorePath, "[%s] %s/%s", pool->name, directoryNam= e, - fileName); + datastorePath =3D g_strdup_printf("[%s] %s/%s", pool->name, direct= oryName, + fileName); =20 /* Create directory, if it doesn't exist yet */ if (esxVI_LookupFileInfoByDatastorePath @@ -1218,7 +1218,7 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned= int flags) =20 virCheckFlags(0, -1); =20 - virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name); + datastorePath =3D g_strdup_printf("[%s] %s", volume->pool, volume->nam= e); =20 if (esxVI_DeleteVirtualDisk_Task(priv->primary, datastorePath, priv->primary->datacenter->_reference, @@ -1260,7 +1260,7 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned i= nt flags) =20 virCheckFlags(0, -1); =20 - virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name); + datastorePath =3D g_strdup_printf("[%s] %s", volume->pool, volume->nam= e); =20 if (esxVI_ZeroFillVirtualDisk_Task(priv->primary, datastorePath, priv->primary->datacenter->_referen= ce, @@ -1302,7 +1302,7 @@ esxStorageVolGetInfo(virStorageVolPtr volume, =20 memset(info, 0, sizeof(*info)); =20 - virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name); + datastorePath =3D g_strdup_printf("[%s] %s", volume->pool, volume->nam= e); =20 if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath, false, &fileInfo, @@ -1359,7 +1359,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, } =20 /* Lookup file info */ - virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name); + datastorePath =3D g_strdup_printf("[%s] %s", volume->pool, volume->nam= e); =20 if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath, false, &fileInfo, @@ -1420,7 +1420,7 @@ esxStorageVolGetPath(virStorageVolPtr volume) { char *path; =20 - virAsprintf(&path, "[%s] %s", volume->pool, volume->name); + path =3D g_strdup_printf("[%s] %s", volume->pool, volume->name); return path; } =20 diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c index 1a779aa095..fe3c42ae02 100644 --- a/src/esx/esx_stream.c +++ b/src/esx/esx_stream.c @@ -415,9 +415,9 @@ esxStreamOpen(virStreamPtr stream, esxPrivate *priv, co= nst char *url, streamPriv->mode =3D mode; =20 if (length > 0) { - virAsprintf(&range, "%llu-%llu", offset, offset + length - 1); + range =3D g_strdup_printf("%llu-%llu", offset, offset + length - 1= ); } else if (offset > 0) { - virAsprintf(&range, "%llu-", offset); + range =3D g_strdup_printf("%llu-", offset); } =20 if (esxVI_CURL_Alloc(&streamPriv->curl) < 0 || @@ -446,8 +446,8 @@ esxStreamOpen(virStreamPtr stream, esxPrivate *priv, co= nst char *url, curl_easy_setopt(streamPriv->curl->handle, CURLOPT_PASSWORD, priv->primary->password); #else - virAsprintf(&userpwd, "%s:%s", priv->primary->username, - priv->primary->password); + userpwd =3D g_strdup_printf("%s:%s", priv->primary->username, + priv->primary->password); =20 curl_easy_setopt(streamPriv->curl->handle, CURLOPT_USERPWD, userpwd); #endif diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 61082c5113..3ff25e2a93 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -387,9 +387,9 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, = char **content, return -1; } =20 - virAsprintf(&range, "%llu-%llu", offset, offset + *length - 1); + range =3D g_strdup_printf("%llu-%llu", offset, offset + *length - = 1); } else if (offset > 0) { - virAsprintf(&range, "%llu-", offset); + range =3D g_strdup_printf("%llu-", offset); } =20 virMutexLock(&curl->lock); @@ -1487,9 +1487,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, =20 goto cleanup; } else { - virAsprintf(&xpathExpression, - "/soapenv:Envelope/soapenv:Body/vim:%sResponse", - methodName); + xpathExpression =3D g_strdup_printf("/soapenv:Envelope/soapenv= :Body/vim:%sResponse", + methodName); =20 responseNode =3D virXPathNode(xpathExpression, xpathContext); =20 @@ -3585,12 +3584,12 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *= ctx, * The part of the datatore path didn't contain a '/', assu= me * that the part is actually the file name. */ - virAsprintf(&datastorePathWithoutFileName, "[%s]", datastoreName); + datastorePathWithoutFileName =3D g_strdup_printf("[%s]", datastore= Name); =20 fileName =3D g_strdup(directoryAndFileName); } else { - virAsprintf(&datastorePathWithoutFileName, "[%s] %s", datastoreNam= e, - directoryName); + datastorePathWithoutFileName =3D g_strdup_printf("[%s] %s", datast= oreName, + directoryName); =20 length =3D strlen(directoryName); =20 @@ -3816,7 +3815,7 @@ esxVI_LookupDatastoreContentByDatastoreName floppyImageFileQuery =3D NULL; =20 /* Search datastore for files */ - virAsprintf(&datastorePath, "[%s]", datastoreName); + datastorePath =3D g_strdup_printf("[%s]", datastoreName); =20 if (esxVI_SearchDatastoreSubFolders_Task(ctx, hostDatastoreBrowser, datastorePath, searchSpec, @@ -4534,9 +4533,9 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, } else if (!taskInfo->error->localizedMessage) { *errorMessage =3D g_strdup(taskInfo->error->fault->_actualType= ); } else { - virAsprintf(errorMessage, "%s - %s", - taskInfo->error->fault->_actualType, - taskInfo->error->localizedMessage); + *errorMessage =3D g_strdup_printf("%s - %s", + taskInfo->error->fault->_actua= lType, + taskInfo->error->localizedMess= age); } } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list