From nobody Sun Feb 8 14:12:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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=1576853916; cv=none; d=zohomail.com; s=zohoarc; b=SRxsXMlYp56EXS9mHH/zhoQ9Qb4CfDZyDtAbnfMSAb5aohqhqeMtsltWv1ewQcZZH1lQljXL/5+OkQWHObTJONAj88Imtu38yWHp40Whf+tq18J7vJHQxVKQ2Mp1OqUTeazSHEwtMU/SDPrfPhwklg3KsTUGBtEQj6A2GifbMyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853916; 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=RWf2nNFK6wj1+oGNDT2rt2Z02zzPd75sUDvglyqS9WM=; b=N+Csm7BufrMiSUwguTHlrBhoklyBbzJ1PRnr1qn6i9DdJRwL+1s0GX7gUXzDQX9pTg149T4/riTfsvwOhNXYR75BriOIUhj0R7eWxvP5i93IWqb8Tdn370o11QLohcxyXk+p4qlJlc4EV2bngQkYSZpxIJs45rsZJ+XaxDmL020= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1576853916388339.37345885069647; Fri, 20 Dec 2019 06:58:36 -0800 (PST) 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-178-lArlDcDtOjm5G1unBcrBxQ-1; Fri, 20 Dec 2019 09:58:33 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4A00800C79; Fri, 20 Dec 2019 14:58:27 +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 1141E605A7; Fri, 20 Dec 2019 14:58:27 +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 BE5DC18089CD; Fri, 20 Dec 2019 14:58:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKEwNT1032517 for ; Fri, 20 Dec 2019 09:58:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id E3F5D6FDCE; Fri, 20 Dec 2019 14:58:23 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CBF16E41E for ; Fri, 20 Dec 2019 14:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853914; 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=RWf2nNFK6wj1+oGNDT2rt2Z02zzPd75sUDvglyqS9WM=; b=Kfc6NHKKKuaTYxDeX/I8Z48gkIGfggyZ6Cq/WnnlHDCzs742vMUuiuvJmx3ImmiWuDexwk bei/E1S25dG1eAnp0HXwUdQKRM5IohioJR1HZkIvsePxN/4iMrgL8WCWIPpxoSk0WNfdi3 tifKAC3anHuZyM7P+YvCSSSL5Jb0uRU= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:06 +0100 Message-Id: <20191220145813.756206-5-ptoscano@redhat.com> In-Reply-To: <20191220145813.756206-1-ptoscano@redhat.com> References: <20191220145813.756206-1-ptoscano@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 04/11] esx: split scsilunToStorageVol helper 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.79 on 10.5.11.11 X-MC-Unique: lArlDcDtOjm5G1unBcrBxQ-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" Move the creation of a virStorageVolPtr object from the esxVI_ScsiLun object of a SCSI lun out of esxStorageVolLookupByName and esxStorageVolLookupByPath in an own helper. This way it can be used also in other functions. Signed-off-by: Pino Toscano Reviewed-by: Cole Robinson --- src/esx/esx_storage_backend_iscsi.c | 60 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index b6e0841dda..50de7d88ac 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -440,6 +440,35 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char= **const names, =20 =20 =20 +static virStorageVolPtr +scsiLunToStorageVol(virConnectPtr conn, esxVI_ScsiLun *scsiLun, + const char *pool) +{ + /* VIR_CRYPTO_HASH_SIZE_MD5 =3D VIR_UUID_BUFLEN =3D 16 */ + unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; + char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; + + /* + * ScsiLun provides a UUID field that is unique across + * multiple servers. But this field length is ~55 characters + * compute MD5 hash to transform it to an acceptable + * libvirt format + */ + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0) + return NULL; + virUUIDFormat(md5, uuid_string); + + /* + * ScsiLun provides displayName and canonicalName but both are + * optional and its observed that they can be NULL, using + * deviceName to create volume. + */ + return virGetStorageVol(conn, pool, scsiLun->deviceName, uuid_string, + &esxStorageBackendISCSI, NULL); +} + + + static virStorageVolPtr esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) @@ -448,9 +477,6 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, esxPrivate *priv =3D pool->conn->privateData; esxVI_ScsiLun *scsiLunList =3D NULL; esxVI_ScsiLun *scsiLun; - /* VIR_CRYPTO_HASH_SIZE_MD5 =3D VIR_UUID_BUFLEN =3D 16 */ - unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; - char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; =20 if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; @@ -458,23 +484,7 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, for (scsiLun =3D scsiLunList; scsiLun; scsiLun =3D scsiLun->_next) { if (STREQ(scsiLun->deviceName, name)) { - /* - * ScsiLun provides a UUID field that is unique across - * multiple servers. But this field length is ~55 characters - * compute MD5 hash to transform it to an acceptable - * libvirt format - */ - if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) = < 0) - goto cleanup; - virUUIDFormat(md5, uuid_string); - - /* - * ScsiLun provides displayName and canonicalName but both are - * optional and its observed that they can be NULL, using - * deviceName to create volume. - */ - volume =3D virGetStorageVol(pool->conn, pool->name, name, uuid= _string, - &esxStorageBackendISCSI, NULL); + volume =3D scsiLunToStorageVol(pool->conn, scsiLun, pool->name= ); break; } } @@ -496,9 +506,6 @@ esxStorageVolLookupByPath(virConnectPtr conn, const cha= r *path) esxVI_ScsiLun *scsiLun; esxVI_HostScsiDisk *hostScsiDisk =3D NULL; char *poolName =3D NULL; - /* VIR_CRYPTO_HASH_SIZE_MD5 =3D VIR_UUID_BUFLEN =3D 16 */ - unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; - char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; =20 if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; @@ -516,12 +523,7 @@ esxStorageVolLookupByPath(virConnectPtr conn, const ch= ar *path) goto cleanup; } =20 - if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) = < 0) - goto cleanup; - virUUIDFormat(md5, uuid_string); - - volume =3D virGetStorageVol(conn, poolName, path, uuid_string, - &esxStorageBackendISCSI, NULL); + volume =3D scsiLunToStorageVol(conn, scsiLun, poolName); break; } } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list