From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576853932; cv=none; d=zohomail.com; s=zohoarc; b=GYeElP5PTau5QQQtsrzAOUoGPD5P2CE8LfkX/l+um0cT64QJPGhUcDz/jnd/b21pwqN+31QmjI58lwpmakqzvJ1aCdsHukEIUBrUonuQTCsGPD8/wSH3ZkH/vALuxNqS+Fvx25AtRcof1mBm+kSEr6/pSNXvCeQqlMYRpxPONV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853932; 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=oqgcFRdquYMmUkFXVcyh297Yl9LeN3BojOXgeHl87Yc=; b=NEWxXK9oyP+Tfo1jQBKPevGSlUfmM8CGil93YzxUR/CYPgGjsOxstGa12FDQqwuuN8wI3UwcIJxxr1ZfOQX2JmOMSU5YE8UEZP4s8S08ODfmhGnLdzROMONXkIdqZqonIDInPbYuB1JT7G9Kv0YQKwEC8EOcoMr8p/guEydmoos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 157685393215138.22822598021594; Fri, 20 Dec 2019 06:58:52 -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-37-GEHV0U9KMPuv0QDxzjmNVQ-1; Fri, 20 Dec 2019 09:58:46 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 403EE1060DC6; Fri, 20 Dec 2019 14:58:41 +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 0D4E75DA76; Fri, 20 Dec 2019 14:58:41 +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 BAAA8252F0; Fri, 20 Dec 2019 14:58:40 +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 xBKEwJAa032488 for ; Fri, 20 Dec 2019 09:58:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id B0C556FEF7; Fri, 20 Dec 2019 14:58:19 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12FFB6E41E for ; Fri, 20 Dec 2019 14:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853930; 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=oqgcFRdquYMmUkFXVcyh297Yl9LeN3BojOXgeHl87Yc=; b=TpOjdPSql38L6ktIMCoA5RRN1NAmTLyrrJ3JL88Ib9xhLaDMii8P4ymlpp1LDImXTm2ysg 3gnPNfWpwJuBjaB31MfAFSzA3T+G3dItGUZOFDv0lfAKw1WKsEtygN2DndSsxHhIjicMd1 V//76Cvx3Fo/lBatBl2yZTi9QG6QBC4= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:03 +0100 Message-Id: <20191220145813.756206-2-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 01/11] esx: implement connectListAllStoragePools 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.14 X-MC-Unique: GEHV0U9KMPuv0QDxzjmNVQ-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" Implement the .connectListAllStoragePools storage API in the esx storage driver, and in all its subdrivers. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- src/esx/esx_storage_backend_iscsi.c | 70 +++++++++++++++++++++ src/esx/esx_storage_backend_vmfs.c | 96 +++++++++++++++++++++++++++++ src/esx/esx_storage_driver.c | 65 +++++++++++++++++++ 3 files changed, 231 insertions(+) diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index 72ab0d3cb0..b6e0841dda 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -779,6 +779,75 @@ esxStorageVolGetPath(virStorageVolPtr volume) =20 =20 =20 +#define MATCH(FLAG) (flags & (FLAG)) +static int +esxConnectListAllStoragePools(virConnectPtr conn, + virStoragePoolPtr **pools, + unsigned int flags) +{ + int ret =3D -1; + size_t count =3D 0; + esxPrivate *priv =3D conn->privateData; + esxVI_HostInternetScsiHba *hostInternetScsiHba =3D NULL; + esxVI_HostInternetScsiHbaStaticTarget *target; + size_t i; + + /* this driver provides only iSCSI pools */ + if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE) && + !(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI))) + return 0; + + if (esxVI_LookupHostInternetScsiHba(priv->primary, + &hostInternetScsiHba) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to obtain iSCSI adapter")); + goto cleanup; + } + + /* FIXME: code looks for software iSCSI adapter only */ + if (!hostInternetScsiHba) { + /* iSCSI adapter may not be enabled for this host */ + return 0; + } + + /* + * ESX has two kind of targets: + * 1. staticIscsiTargets + * 2. dynamicIscsiTargets + * For each dynamic target if it's reachable a static target is added. + * return iSCSI names for all static targets to avoid duplicate names. + */ + for (target =3D hostInternetScsiHba->configuredStaticTarget; + target; target =3D target->_next) { + virStoragePoolPtr pool; + + pool =3D targetToStoragePool(conn, target->iScsiName, target); + if (!pool) + goto cleanup; + + if (VIR_APPEND_ELEMENT(*pools, count, pool) < 0) + goto cleanup; + } + + ret =3D count; + + cleanup: + if (ret < 0) { + if (*pools) { + for (i =3D 0; i < count; ++i) + VIR_FREE((*pools)[i]); + VIR_FREE(*pools); + } + } + + esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba); + + return ret; +} +#undef MATCH + + + virStorageDriver esxStorageBackendISCSI =3D { .connectNumOfStoragePools =3D esxConnectNumOfStoragePools, /* 1.0.1 */ .connectListStoragePools =3D esxConnectListStoragePools, /* 1.0.1 */ @@ -799,4 +868,5 @@ virStorageDriver esxStorageBackendISCSI =3D { .storageVolDelete =3D esxStorageVolDelete, /* 1.0.1 */ .storageVolWipe =3D esxStorageVolWipe, /* 1.0.1 */ .storageVolGetPath =3D esxStorageVolGetPath, /* 1.0.1 */ + .connectListAllStoragePools =3D esxConnectListAllStoragePools, /* 6.0.= 0 */ }; diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 61b30c3c1d..41f0d4577b 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -1461,6 +1461,101 @@ esxStorageVolGetPath(virStorageVolPtr volume) =20 =20 =20 +#define MATCH(FLAG) (flags & (FLAG)) +static int +esxConnectListAllStoragePools(virConnectPtr conn, + virStoragePoolPtr **pools, + unsigned int flags) +{ + int ret =3D -1; + esxPrivate *priv =3D conn->privateData; + esxVI_String *propertyNameList =3D NULL; + esxVI_DynamicProperty *dynamicProperty =3D NULL; + esxVI_ObjectContent *datastoreList =3D NULL; + esxVI_ObjectContent *datastore =3D NULL; + size_t count =3D 0; + size_t i; + virStoragePoolPtr pool; + const bool checkPoolType =3D MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILT= ERS_POOL_TYPE); + + if (esxVI_String_AppendValueToList(&propertyNameList, + "summary.name") < 0) { + goto cleanup; + } + + if (checkPoolType && + esxVI_String_AppendValueToList(&propertyNameList, + "info") < 0) { + goto cleanup; + } + + if (esxVI_LookupDatastoreList(priv->primary, propertyNameList, + &datastoreList) < 0) { + goto cleanup; + } + + for (datastore =3D datastoreList; datastore; + datastore =3D datastore->_next) { + const char *name =3D NULL; + + for (dynamicProperty =3D datastore->propSet; dynamicProperty; + dynamicProperty =3D dynamicProperty->_next) { + if (STREQ(dynamicProperty->name, "summary.name")) { + if (esxVI_AnyType_ExpectType(dynamicProperty->val, + esxVI_Type_String) < 0) { + goto cleanup; + } + + name =3D dynamicProperty->val->string; + } + } + + if (!name) + goto cleanup; + + if (checkPoolType) { + int poolType; + + if (datastorePoolType(datastore, &poolType) < 0) + goto cleanup; + + if (!((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_DIR) && + (poolType =3D=3D VIR_STORAGE_POOL_DIR)) || + (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FS) && + (poolType =3D=3D VIR_STORAGE_POOL_FS)) || + (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NETFS) && + (poolType =3D=3D VIR_STORAGE_POOL_NETFS)))) + continue; + } + + pool =3D datastoreToStoragePoolPtr(conn, name, datastore); + if (!pool) + goto cleanup; + + if (VIR_APPEND_ELEMENT(*pools, count, pool) < 0) + goto cleanup; + } + + ret =3D count; + + cleanup: + if (ret < 0) { + if (*pools) { + for (i =3D 0; i < count; ++i) + VIR_FREE((*pools)[i]); + VIR_FREE(*pools); + } + } + + esxVI_String_Free(&propertyNameList); + esxVI_ObjectContent_Free(&datastoreList); + + return ret; +} +#undef MATCH + + + virStorageDriver esxStorageBackendVMFS =3D { .connectNumOfStoragePools =3D esxConnectNumOfStoragePools, /* 0.8.2 */ .connectListStoragePools =3D esxConnectListStoragePools, /* 0.8.2 */ @@ -1481,4 +1576,5 @@ virStorageDriver esxStorageBackendVMFS =3D { .storageVolGetInfo =3D esxStorageVolGetInfo, /* 0.8.4 */ .storageVolGetXMLDesc =3D esxStorageVolGetXMLDesc, /* 0.8.4 */ .storageVolGetPath =3D esxStorageVolGetPath, /* 0.8.4 */ + .connectListAllStoragePools =3D esxConnectListAllStoragePools, /* 6.0.= 0 */ }; diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index 8a34732b45..9e14b8b0ac 100644 --- a/src/esx/esx_storage_driver.c +++ b/src/esx/esx_storage_driver.c @@ -517,6 +517,70 @@ esxStoragePoolIsPersistent(virStoragePoolPtr pool G_GN= UC_UNUSED) =20 =20 =20 +#define MATCH(FLAG) (flags & (FLAG)) +static int +esxConnectListAllStoragePools(virConnectPtr conn, + virStoragePoolPtr **pools, + unsigned int flags) +{ + int ret =3D -1; + esxPrivate *priv =3D conn->privateData; + size_t count =3D 0; + size_t i, j; + + virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1); + + /* + * ESX storage pools are always active, persistent, and + * autostarted, so return zero elements in case we are asked + * for pools different than that. + * + * Filtering by type will be done by each backend. + */ + if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) && + !(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE))) + return 0; + if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_PERSISTENT) && + !(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT))) + return 0; + if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART) && + !(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART))) + return 0; + + if (esxVI_EnsureSession(priv->primary) < 0) + return -1; + + for (i =3D 0; i < LAST_BACKEND; ++i) { + virStoragePoolPtr *new_pools =3D 0; + int tmp =3D backends[i]->connectListAllStoragePools(conn, &new_poo= ls, flags); + + if (tmp < 0) + goto cleanup; + + for (j =3D 0; j < tmp; ++j) { + if (VIR_APPEND_ELEMENT(*pools, count, new_pools[j]) < 0) + goto cleanup; + } + VIR_FREE(new_pools); + } + + ret =3D count; + + cleanup: + if (ret < 0) { + if (*pools) { + for (i =3D 0; i < count; ++i) + VIR_FREE((*pools)[i]); + VIR_FREE(*pools); + } + } + + return ret; +} +#undef MATCH + + + virStorageDriver esxStorageDriver =3D { .connectNumOfStoragePools =3D esxConnectNumOfStoragePools, /* 0.8.2 */ .connectListStoragePools =3D esxConnectListStoragePools, /* 0.8.2 */ @@ -544,4 +608,5 @@ virStorageDriver esxStorageDriver =3D { .storageVolGetPath =3D esxStorageVolGetPath, /* 0.8.4 */ .storagePoolIsActive =3D esxStoragePoolIsActive, /* 0.8.2 */ .storagePoolIsPersistent =3D esxStoragePoolIsPersistent, /* 0.8.2 */ + .connectListAllStoragePools =3D esxConnectListAllStoragePools, /* 6.0.= 0 */ }; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1576853949; cv=none; d=zohomail.com; s=zohoarc; b=ajzr/CgP5lV8IS1NJRnMBiNeuAjtzOKzITjPi+NRVTnWN3dNJeUHL0qPjC/BnEqxLQrGH/8N45+qdUUwiRdBvKgcY9HblNjwIOo+PdXBgWBT/pITS/DkUQjs4pxJoi7DjADs6lhN0A8Pvz6ZNmJY68M4X/D9Kmvpp/epw7we+Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853949; 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=B1V7H8C1z4HnH6gC8caTCboAl/6nnohzHW/TVyjasG0=; b=MhqKI879kQe+BjIvb+IeRFLbbvavukab6aNJBc7X/NiP1VdExD7umYTG5UZhH5VuzRPoEKXvjfGKs8LxvVgrybtGQ9Rj75mclivMnBROo7D/MAcYd0HGQpPmEqhIZ/83rMO6L9vn3zqxOf4CSwX4AOEd9TkvCbTDdEQ656mT360= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576853949673100.89474962944826; Fri, 20 Dec 2019 06:59:09 -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-427-CSeiCihuP7qlfLAvIG1O7A-1; Fri, 20 Dec 2019 09:58:51 -0500 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 22A9F1005516; Fri, 20 Dec 2019 14:58:46 +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 F111D26FB3; Fri, 20 Dec 2019 14:58:45 +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 AC36118089D8; Fri, 20 Dec 2019 14:58:45 +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 xBKEwMXf032502 for ; Fri, 20 Dec 2019 09:58:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 502F46E41E; Fri, 20 Dec 2019 14:58:22 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBD747C839 for ; Fri, 20 Dec 2019 14:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853948; 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=B1V7H8C1z4HnH6gC8caTCboAl/6nnohzHW/TVyjasG0=; b=jGJ8oA0aClThf55V24OvcOOOkbiQPa+vA+Ch0QfgGqMgi5ni97xP14MiGQXlUsxfFpR/Wh pOCBmsQnVB5UtOVgxZ7DfENAND7sIB5cRG2HvxSB1RMIo+/WwT7CH3Z8+AmHIHnz7tGQGY eSJhgjFNyD06qztto1eFNNDyVwWOOgQ= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:04 +0100 Message-Id: <20191220145813.756206-3-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 02/11] esx: implement connectListAllNetworks 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: CSeiCihuP7qlfLAvIG1O7A-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" Implement the .connectListAllNetworks networks API in the esx network driver. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- src/esx/esx_network_driver.c | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index 4f359c61e2..f14d309293 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -863,6 +863,69 @@ esxNetworkIsPersistent(virNetworkPtr network G_GNUC_UN= USED) =20 =20 =20 +#define MATCH(FLAG) (flags & (FLAG)) +static int +esxConnectListAllNetworks(virConnectPtr conn, + virNetworkPtr **nets, + unsigned int flags) +{ + int ret =3D -1; + esxPrivate *priv =3D conn->privateData; + esxVI_HostVirtualSwitch *hostVirtualSwitchList =3D NULL; + esxVI_HostVirtualSwitch *hostVirtualSwitch =3D NULL; + size_t count =3D 0; + size_t i; + + virCheckFlags(VIR_CONNECT_LIST_NETWORKS_FILTERS_ALL, -1); + + /* + * ESX networks are always active, persistent, and + * autostarted, so return zero elements in case we are asked + * for networks different than that. + */ + if (MATCH(VIR_CONNECT_LIST_NETWORKS_FILTERS_ACTIVE) && + !(MATCH(VIR_CONNECT_LIST_NETWORKS_ACTIVE))) + return 0; + if (MATCH(VIR_CONNECT_LIST_NETWORKS_FILTERS_PERSISTENT) && + !(MATCH(VIR_CONNECT_LIST_NETWORKS_PERSISTENT))) + return 0; + if (MATCH(VIR_CONNECT_LIST_NETWORKS_FILTERS_AUTOSTART) && + !(MATCH(VIR_CONNECT_LIST_NETWORKS_AUTOSTART))) + return 0; + + if (esxVI_EnsureSession(priv->primary) < 0 || + esxVI_LookupHostVirtualSwitchList(priv->primary, + &hostVirtualSwitchList) < 0) { + return -1; + } + + for (hostVirtualSwitch =3D hostVirtualSwitchList; hostVirtualSwitch; + hostVirtualSwitch =3D hostVirtualSwitch->_next) { + virNetworkPtr net =3D virtualswitchToNetwork(conn, hostVirtualSwit= ch); + + if (VIR_APPEND_ELEMENT(*nets, count, net) < 0) + goto cleanup; + } + + ret =3D count; + + cleanup: + if (ret < 0) { + if (*nets) { + for (i =3D 0; i < count; ++i) + VIR_FREE((*nets)[i]); + VIR_FREE(*nets); + } + } + + esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList); + + return ret; +} +#undef MATCH + + + virNetworkDriver esxNetworkDriver =3D { .connectNumOfNetworks =3D esxConnectNumOfNetworks, /* 0.10.0 */ .connectListNetworks =3D esxConnectListNetworks, /* 0.10.0 */ @@ -877,4 +940,5 @@ virNetworkDriver esxNetworkDriver =3D { .networkSetAutostart =3D esxNetworkSetAutostart, /* 0.10.0 */ .networkIsActive =3D esxNetworkIsActive, /* 0.10.0 */ .networkIsPersistent =3D esxNetworkIsPersistent, /* 0.10.0 */ + .connectListAllNetworks =3D esxConnectListAllNetworks, /* 6.0.0 */ }; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=gUnE7/hejeLIw4Kfw5jdr6Z0v5zaaW7CF9mH9n28icHWq3O5zUJR8qQNHprV3AyOCYxlv/guZrVHNVFl7kAMSulJSHZHvdG+lxip/hp08BHfY2Mm6vzKrsEy+crPqEU82nhXWtJFj3TpiyXt0ZKe6CZ9MxVVB8rpRQXzv7x3Hbw= 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=LYnR/LhKFTqUoruTr1NkaF20Hv0WFnt0SoWLxEQJFzg=; b=OuQjokbWkMqqFB8WZaZaQnpfSZO/eXmhCcoeTMY/VKOXoHEKg4UDgE4JBetEm3rMVGHbK1HGTIlWKAbMB9pArZwUdTSmrSEnyear/4QK/Ho7vFJ3NQoAuMe4JNAfo7IkCLDgrld/tGTj3T+Ld1pln0cp3fFKdviVo4GODFhpA/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576853916406282.0337396990119; 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-357-eMh11zntOESC8c_zYFx7qA-1; Fri, 20 Dec 2019 09:58:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8EE58FD56E; Fri, 20 Dec 2019 14:58:27 +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 82B416FEEA; 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 D1D2C252E9; 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 xBKEwNLd032509 for ; Fri, 20 Dec 2019 09:58:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1F7D06FDCF; 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 9C6BC6E41E for ; Fri, 20 Dec 2019 14:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853915; 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=LYnR/LhKFTqUoruTr1NkaF20Hv0WFnt0SoWLxEQJFzg=; b=e8YNI8FmKfDWG3p1RYRU47k7TF2692yctjL4QccD6EgtLDqOa52C0gjTmtuA+Nc7YCieg9 Ehu0MUTg0d4cb7fBP4avnQ4x9fZfiJsGgAZH0ZEMrxhkv4io3KE3jmehZ6uJC94eVLYWzT Iy/GjQg43uCV6lo8VEW45PUB1dGsppI= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:05 +0100 Message-Id: <20191220145813.756206-4-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 03/11] esx: split datastorePathToStorageVol 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.13 X-MC-Unique: eMh11zntOESC8c_zYFx7qA-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 by lookup out of esxStorageVolLookupByPath in an own helper. This way it can be used also in other functions. Signed-off-by: Pino Toscano Reviewed-by: Cole Robinson Reviewed-by: Michal Privoznik --- src/esx/esx_storage_backend_vmfs.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 41f0d4577b..1d7f9afda1 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -695,32 +695,41 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, =20 =20 =20 +static virStorageVolPtr +datastorePathToStorageVol(virConnectPtr conn, const char *pool, + const char *path) +{ + esxPrivate *priv =3D conn->privateData; + g_autofree char *key =3D NULL; + + if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path, + &key) < 0) { + return NULL; + } + + return virGetStorageVol(conn, pool, path, key, + &esxStorageBackendVMFS, NULL); +} + + + static virStorageVolPtr esxStorageVolLookupByPath(virConnectPtr conn, const char *path) { virStorageVolPtr volume =3D NULL; - esxPrivate *priv =3D conn->privateData; char *datastoreName =3D NULL; char *directoryAndFileName =3D NULL; - char *key =3D NULL; =20 if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL, &directoryAndFileName) < 0) { goto cleanup; } =20 - if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path, - &key) < 0) { - goto cleanup; - } - - volume =3D virGetStorageVol(conn, datastoreName, directoryAndFileName,= key, - &esxStorageBackendVMFS, NULL); + volume =3D datastorePathToStorageVol(conn, datastoreName, directoryAnd= FileName); =20 cleanup: VIR_FREE(datastoreName); VIR_FREE(directoryAndFileName); - VIR_FREE(key); =20 return volume; } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 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 Reviewed-by: Michal Privoznik --- 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 From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576853937; cv=none; d=zohomail.com; s=zohoarc; b=BuVsq9Ix6xl3hDiG+Nj+N08ittuPssBEHSaWK7QAgM4+ioJhaH6OMzHETPwHFh1+LVuNhPR5mNladT3hkZI1LLzvlnDi4DZhV1v67/U89lA/aBnCbq7y28wjm3AnY3IIcOYbCrZWNFHR4ZexqY/zobx/z5jVF91puKUGB7WQL2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853937; 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=iIBrBK7nVfBcZ0VRlOgH3eDVjM2Cchxw0efc4+VfwDM=; b=H05zzoTQC2fFCgymRze9VfF2igsqq+RRpkD6jCaq7YGDDOb2PvTuzvvi0Cj45TeuFJIszge4f9rSuQkSb5D/6aGuRp/uucC66tqXG6S8ydx6XcJsiarEFgRN9+OgRYee7eey0D9RBNBCw44OwQFSOVnnK98/zDgv3HrlEPodiSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1576853937962579.2974828862563; Fri, 20 Dec 2019 06:58:57 -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-67-6mACUkpOP_62iNqLmUIMGA-1; Fri, 20 Dec 2019 09:58:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C603801F77; Fri, 20 Dec 2019 14:58:49 +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 599195C28F; Fri, 20 Dec 2019 14:58:49 +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 12423252F3; Fri, 20 Dec 2019 14:58:49 +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 xBKEwOfw032524 for ; Fri, 20 Dec 2019 09:58:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id B3D596E41E; Fri, 20 Dec 2019 14:58:24 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D2BC6FEEA for ; Fri, 20 Dec 2019 14:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853936; 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=iIBrBK7nVfBcZ0VRlOgH3eDVjM2Cchxw0efc4+VfwDM=; b=VKTFplSNeAv6MoRVb91NPy+aXmeOUNlo7FtUmQLzNPHz+za7NKP85sSUNT14dU5C0uq4I8 TImTH2gT7hTUxaiuCKLa/MptGAcMklk2Wrs3RfXweai7oGzSSK57JMnZPvNsa7zK4eh9LK G1g4EHCEe4Fi/np77hP8TJCtBxr2DXM= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:07 +0100 Message-Id: <20191220145813.756206-6-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 05/11] esx: implement storagePoolListAllVolumes 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.16 X-MC-Unique: 6mACUkpOP_62iNqLmUIMGA-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" Implement the .storagePoolListAllVolumes storage API in the esx storage driver, and in all its subdrivers. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- src/esx/esx_storage_backend_iscsi.c | 68 +++++++++++++++++++++++ src/esx/esx_storage_backend_vmfs.c | 83 +++++++++++++++++++++++++++++ src/esx/esx_storage_driver.c | 19 +++++++ 3 files changed, 170 insertions(+) diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index 50de7d88ac..cd83a0fbfd 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -850,6 +850,73 @@ esxConnectListAllStoragePools(virConnectPtr conn, =20 =20 =20 +static int +esxStoragePoolListAllVolumes(virStoragePoolPtr pool, + virStorageVolPtr **vols, + unsigned int flags) +{ + int ret =3D -1; + size_t count =3D 0; + esxPrivate *priv =3D pool->conn->privateData; + esxVI_HostScsiTopologyLun *hostScsiTopologyLunList =3D NULL; + esxVI_HostScsiTopologyLun *hostScsiTopologyLun; + esxVI_ScsiLun *scsiLunList =3D NULL; + esxVI_ScsiLun *scsiLun =3D NULL; + size_t i; + + virCheckFlags(0, -1); + + if (esxVI_LookupHostScsiTopologyLunListByTargetName + (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) { + goto cleanup; + } + + if (!hostScsiTopologyLunList) { + /* iSCSI adapter may not be enabled on ESX host */ + return 0; + } + + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) + goto cleanup; + + for (scsiLun =3D scsiLunList; scsiLun; + scsiLun =3D scsiLun->_next) { + for (hostScsiTopologyLun =3D hostScsiTopologyLunList; + hostScsiTopologyLun; + hostScsiTopologyLun =3D hostScsiTopologyLun->_next) { + if (STREQ(hostScsiTopologyLun->scsiLun, scsiLun->key)) { + virStorageVolPtr volume; + + volume =3D scsiLunToStorageVol(pool->conn, scsiLun, pool->= name); + if (!volume) + goto cleanup; + + if (VIR_APPEND_ELEMENT(*vols, count, volume) < 0) + goto cleanup; + } + + } + } + + ret =3D count; + + cleanup: + if (ret < 0) { + if (*vols) { + for (i =3D 0; i < count; ++i) + VIR_FREE((*vols)[i]); + VIR_FREE(*vols); + } + } + + esxVI_HostScsiTopologyLun_Free(&hostScsiTopologyLunList); + esxVI_ScsiLun_Free(&scsiLunList); + + return ret; +} + + + virStorageDriver esxStorageBackendISCSI =3D { .connectNumOfStoragePools =3D esxConnectNumOfStoragePools, /* 1.0.1 */ .connectListStoragePools =3D esxConnectListStoragePools, /* 1.0.1 */ @@ -871,4 +938,5 @@ virStorageDriver esxStorageBackendISCSI =3D { .storageVolWipe =3D esxStorageVolWipe, /* 1.0.1 */ .storageVolGetPath =3D esxStorageVolGetPath, /* 1.0.1 */ .connectListAllStoragePools =3D esxConnectListAllStoragePools, /* 6.0.= 0 */ + .storagePoolListAllVolumes =3D esxStoragePoolListAllVolumes, /* 6.0.0 = */ }; diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 1d7f9afda1..70005717cb 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -1565,6 +1565,88 @@ esxConnectListAllStoragePools(virConnectPtr conn, =20 =20 =20 +static int +esxStoragePoolListAllVolumes(virStoragePoolPtr pool, + virStorageVolPtr **vols, + unsigned int flags) +{ + int ret =3D -1; + esxPrivate *priv =3D pool->conn->privateData; + esxVI_HostDatastoreBrowserSearchResults *searchResultsList =3D NULL; + esxVI_HostDatastoreBrowserSearchResults *searchResults =3D NULL; + esxVI_FileInfo *fileInfo =3D NULL; + char *directoryAndFileName =3D NULL; + size_t length; + size_t count =3D 0; + size_t i; + + virCheckFlags(0, -1); + + if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->n= ame, + &searchResultsList) < = 0) { + goto cleanup; + } + + /* Interpret search result */ + for (searchResults =3D searchResultsList; searchResults; + searchResults =3D searchResults->_next) { + VIR_FREE(directoryAndFileName); + + if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NU= LL, + &directoryAndFileName) < 0) { + goto cleanup; + } + + /* Strip trailing separators */ + length =3D strlen(directoryAndFileName); + + while (length > 0 && directoryAndFileName[length - 1] =3D=3D '/') { + directoryAndFileName[length - 1] =3D '\0'; + --length; + } + + /* Build volume names */ + for (fileInfo =3D searchResults->file; fileInfo; + fileInfo =3D fileInfo->_next) { + g_autofree char *datastorePath =3D NULL; + virStorageVolPtr volume; + + if (length < 1) { + datastorePath =3D g_strdup(fileInfo->path); + } else { + datastorePath =3D g_strdup_printf("%s/%s", + directoryAndFileName, + fileInfo->path); + } + + volume =3D datastorePathToStorageVol(pool->conn, pool->name, d= atastorePath); + if (!volume) + goto cleanup; + + if (VIR_APPEND_ELEMENT(*vols, count, volume) < 0) + goto cleanup; + } + } + + ret =3D count; + + cleanup: + if (ret < 0) { + if (*vols) { + for (i =3D 0; i < count; ++i) + VIR_FREE((*vols)[i]); + VIR_FREE(*vols); + } + } + + esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList); + VIR_FREE(directoryAndFileName); + + return ret; +} + + + virStorageDriver esxStorageBackendVMFS =3D { .connectNumOfStoragePools =3D esxConnectNumOfStoragePools, /* 0.8.2 */ .connectListStoragePools =3D esxConnectListStoragePools, /* 0.8.2 */ @@ -1586,4 +1668,5 @@ virStorageDriver esxStorageBackendVMFS =3D { .storageVolGetXMLDesc =3D esxStorageVolGetXMLDesc, /* 0.8.4 */ .storageVolGetPath =3D esxStorageVolGetPath, /* 0.8.4 */ .connectListAllStoragePools =3D esxConnectListAllStoragePools, /* 6.0.= 0 */ + .storagePoolListAllVolumes =3D esxStoragePoolListAllVolumes, /* 6.0.0 = */ }; diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index 9e14b8b0ac..8470a31c68 100644 --- a/src/esx/esx_storage_driver.c +++ b/src/esx/esx_storage_driver.c @@ -581,6 +581,24 @@ esxConnectListAllStoragePools(virConnectPtr conn, =20 =20 =20 +static int +esxStoragePoolListAllVolumes(virStoragePoolPtr pool, + virStorageVolPtr **vols, + unsigned int flags) +{ + esxPrivate *priv =3D pool->conn->privateData; + virStorageDriverPtr backend =3D pool->privateData; + + virCheckNonNullArgReturn(pool->privateData, -1); + + if (esxVI_EnsureSession(priv->primary) < 0) + return -1; + + return backend->storagePoolListAllVolumes(pool, vols, flags); +} + + + virStorageDriver esxStorageDriver =3D { .connectNumOfStoragePools =3D esxConnectNumOfStoragePools, /* 0.8.2 */ .connectListStoragePools =3D esxConnectListStoragePools, /* 0.8.2 */ @@ -609,4 +627,5 @@ virStorageDriver esxStorageDriver =3D { .storagePoolIsActive =3D esxStoragePoolIsActive, /* 0.8.2 */ .storagePoolIsPersistent =3D esxStoragePoolIsPersistent, /* 0.8.2 */ .connectListAllStoragePools =3D esxConnectListAllStoragePools, /* 6.0.= 0 */ + .storagePoolListAllVolumes =3D esxStoragePoolListAllVolumes, /* 6.0.0 = */ }; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 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=1576854017; cv=none; d=zohomail.com; s=zohoarc; b=n01BYtrMDDwDZrb68nyykhtYyqXqyTorhZHf9lmFNJQw+ZA3aobCEs8CA5HBwe1BBXsa1vqGiCfK1Nxu9d7IdphdQatpmfenes94HxO0X96AqlZowBkkGPWeB89EVz5vDhek9mSn7OCnt4Ox7238oX3yPCV39ea8X4N1JBg/kA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576854017; 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=Z+3Hw65iFUDYC/5ivIco5nrtu6lnajNd0PV6sbNh+Eg=; b=KffkfMNNrEgyWj3qPpFbtU4HBkkECB0wpk+HidvyXUKb2TF/8n6uwBe4vLa4jZWt0DwAw2TAKKOK/5F0QI/Q43fQQMKYlFdYlM4RfAK4DkcpkJtzN4JDuXkQLt66m42nDnHGXUpWc/rb3+G1m1HqVmjsnxbvGi4cgsKzXVbO/us= 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 1576854017465414.1758509504126; Fri, 20 Dec 2019 07:00:17 -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-319-Vq5WFnqzOQSWK5QYuTC6Pg-1; Fri, 20 Dec 2019 09:59:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 435FB107ACE6; Fri, 20 Dec 2019 14:58:54 +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 1B4D15D72A; Fri, 20 Dec 2019 14:58:54 +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 C8253252F8; Fri, 20 Dec 2019 14:58:53 +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 xBKEwPKR032530 for ; Fri, 20 Dec 2019 09:58:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id ABA506FDCE; Fri, 20 Dec 2019 14:58:25 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E20A6E41E for ; Fri, 20 Dec 2019 14:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576854014; 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=Z+3Hw65iFUDYC/5ivIco5nrtu6lnajNd0PV6sbNh+Eg=; b=H6I0D/fFWrITxoD2xBE4xHKhs2ZKYYGzYBoRMLavxTGLLQ9thTTdIMqJvH3TAzIhAeHeyu 1/8hR3YMXTIxBoOlRPhrWR1vBzMAwwxQmjk/3BSAmJNAPTJkAWnUIHuRkhE1QRy3Xezijn 0w6K/BRac4omevC5DhW+AvTeVBhru1A= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:08 +0100 Message-Id: <20191220145813.756206-7-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 06/11] esx: improve some of the virErrorNumber used 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.15 X-MC-Unique: Vq5WFnqzOQSWK5QYuTC6Pg-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" A lot of virReportError() calls use VIR_ERR_INTERNAL_ERROR to represent the number of the error, even in cases where there is one fitting more. Hence, replace some of them with better virErrorNumber values. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- src/esx/esx_network_driver.c | 4 ++-- src/esx/esx_storage_backend_iscsi.c | 4 ++-- src/esx/esx_storage_backend_vmfs.c | 12 +++++----- src/esx/esx_util.c | 4 ++-- src/esx/esx_vi.c | 36 ++++++++++++++--------------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index f14d309293..2a76831606 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -355,7 +355,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) for (hostPortGroup =3D hostPortGroupList; hostPortGroup; hostPortGroup =3D hostPortGroup->_next) { if (STREQ(def->portGroups[i].name, hostPortGroup->spec->na= me)) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NETWORK_EXIST, _("HostPortGroup with name '%s' exists = already"), def->portGroups[i].name); goto cleanup; @@ -388,7 +388,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) =20 if (def->forward.ifs[i].type !=3D VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("unsupported device type in network %s " "interface pool"), def->name); diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index cd83a0fbfd..1e54cef948 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -321,7 +321,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsign= ed int flags) =20 if (!target) { /* pool not found */ - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_STORAGE_POOL, _("Could not find storage pool with name '%s'"), pool->name); goto cleanup; @@ -701,7 +701,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, } =20 if (!scsiLun) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_STORAGE_VOL, _("Could find volume with name: %s"), volume->name); goto cleanup; } diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index 70005717cb..d4b23c6d51 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -906,7 +906,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, goto cleanup; =20 if (def->type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_NO_SUPPORT, "%s", _("Creating non-file volumes is not supported")); goto cleanup; } @@ -922,7 +922,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, } =20 if (!virStringHasCaseSuffix(def->name, ".vmdk")) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Volume name '%s' has unsupported suffix, " "expecting '.vmdk'"), def->name); goto cleanup; @@ -1041,7 +1041,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, key =3D g_strdup(datastorePath); } } else { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Creation of %s volumes is not supported"), virStorageFileFormatTypeToString(def->target.format= )); goto cleanup; @@ -1120,7 +1120,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; =20 if (def->type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_NO_SUPPORT, "%s", _("Creating non-file volumes is not supported")); goto cleanup; } @@ -1136,7 +1136,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, } =20 if (!virStringHasCaseSuffix(def->name, ".vmdk")) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Volume name '%s' has unsupported suffix, " "expecting '.vmdk'"), def->name); goto cleanup; @@ -1221,7 +1221,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, key =3D g_strdup(datastorePath); } } else { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_NO_SUPPORT, _("Creation of %s volumes is not supported"), virStorageFileFormatTypeToString(def->target.format= )); goto cleanup; diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index c265528056..dc0983a47d 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -218,7 +218,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, if ((datastoreName && *datastoreName) || (directoryName && *directoryName) || (directoryAndFileName && *directoryAndFileName)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -227,7 +227,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, /* Expected format: '[] ' where is optional */ if (!(tmp =3D STRSKIP(copyOfDatastorePath, "[")) || *tmp =3D=3D ']' || !(preliminaryDatastoreName =3D strtok_r(tmp, "]", &saveptr))) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_INVALID_ARG, _("Datastore path '%s' doesn't have expected format= " "'[] '"), datastorePath); goto cleanup; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 4e67d76bfe..3c5a994848 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -435,7 +435,7 @@ esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, co= nst char *content) int responseCode =3D 0; =20 if (!content) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -552,13 +552,13 @@ esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_= CURL *curl) size_t i; =20 if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot share uninitialized CURL handle")); return -1; } =20 if (curl->shared) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot share CURL handle that is already shared"= )); return -1; } @@ -607,19 +607,19 @@ int esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl) { if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot unshare uninitialized CURL handle")); return -1; } =20 if (!curl->shared) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot unshare CURL handle that is not shared")); return -1; } =20 if (curl->shared !=3D shared) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (share) misma= tch")); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (share) mismatch= ")); return -1; } =20 @@ -727,13 +727,13 @@ int esxVI_MultiCURL_Add(esxVI_MultiCURL *multi, esxVI_CURL *curl) { if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot add uninitialized CURL handle to a multi = handle")); return -1; } =20 if (curl->multi) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot add CURL handle to a multi handle twice")= ); return -1; } @@ -773,21 +773,21 @@ int esxVI_MultiCURL_Remove(esxVI_MultiCURL *multi, esxVI_CURL *curl) { if (!curl->handle) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot remove uninitialized CURL handle from a " "multi handle")); return -1; } =20 if (!curl->multi) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot remove CURL handle from a multi handle wh= en it " "wasn't added before")); return -1; } =20 if (curl->multi !=3D multi) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (multi) misma= tch")); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (multi) mismatch= ")); return -1; } =20 @@ -994,7 +994,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, =20 if (!ctx || !url || !ipAddress || !username || !password || ctx->url || ctx->service || ctx->curl) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -1405,7 +1405,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, xmlNodePtr responseNode =3D NULL; =20 if (!request || !response || *response) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -1548,7 +1548,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, } } } else { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_HTTP_ERROR, _("HTTP response code %d for call to '%s'"), (*response)->responseCode, methodName); goto cleanup; @@ -1599,14 +1599,14 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enume= ration *enumeration, size_t i; =20 if (!anyType || !value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 *value =3D 0; /* undefined */ =20 if (anyType->type !=3D enumeration->type) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_INVALID_ARG, _("Expecting type '%s' but found '%s'"), esxVI_Type_ToString(enumeration->type), esxVI_AnyType_TypeToString(anyType)); @@ -1635,7 +1635,7 @@ esxVI_Enumeration_Serialize(const esxVI_Enumeration *= enumeration, const char *name =3D NULL; =20 if (!element || !output) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 @@ -1674,7 +1674,7 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration= *enumeration, char *name =3D NULL; =20 if (!value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument")); return -1; } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1576853931; cv=none; d=zohomail.com; s=zohoarc; b=Ce/y4W0y4Q3hp9+Q4AlbU5oMZ42OcnHZwSCAO9Kzlw4tKAy03C7VqWAuCst5xtaGJG8pnpHbE72QlpukZ84MArUe2X9Ul4YWeKTX9sasZpqHGHD5IRIq1kTU9ETIKIagpZbI9TkZAPojwbZMiW6iu3pyjXoC2vcMx/3arstC5Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853931; 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=8FxT9sc7691FpoGidUeDQ+wNG53ZeycY+wipVgD8NJQ=; b=gmnQWkjSJjpIrXgGJj2Bblp+SMFlkYo5XOnM4Q/tkKHX3+UmP0txJi8C8nadayx6ILr4SnmYmCAWmDV+eBsLmJNPHTP87y2UW/0eLHFOzkZVbhNR8dqXCS4X76DZkFQpN6mdvtitXII6/NpJhYNs68GREKRBkC+4FIIrdmGjQNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576853931099855.4568039966864; Fri, 20 Dec 2019 06:58:51 -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-107-g1i_USm2OjiwG0oOKe2KsA-1; Fri, 20 Dec 2019 09:58:48 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EE77801F77; Fri, 20 Dec 2019 14:58:41 +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 1BEAC5C57C; Fri, 20 Dec 2019 14:58:41 +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 CECA118089CE; Fri, 20 Dec 2019 14:58:40 +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 xBKEwQY0032537 for ; Fri, 20 Dec 2019 09:58:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A8336FDCE; Fri, 20 Dec 2019 14:58:26 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 042F86E41E for ; Fri, 20 Dec 2019 14:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853929; 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=8FxT9sc7691FpoGidUeDQ+wNG53ZeycY+wipVgD8NJQ=; b=Z2On5mfSA4v1vkpSWdXooixxU6vThcatfBb0BcFLbnHBSKHUYa3O34SUr6w6lq5/bEVPHi vSelyNQA3F7WLxAfj/+Tu4m15Z1lj/w3bOr8ne40944WRT486tHSZ2/S5XoryH0VhsGO0A 4xQ8LJDVuvYTFjwvfOQycG6WSHM81kU= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:09 +0100 Message-Id: <20191220145813.756206-8-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 07/11] esx: implement domainGetHostname 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.16 X-MC-Unique: g1i_USm2OjiwG0oOKe2KsA-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" Implement the .domainGetHostname hypervisor driver API to get the hostname of a running guest (needs VMware Tools). Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- docs/drvesx.html.in | 3 +++ src/esx/esx_driver.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in index ac7bc645d1..465daafc2e 100644 --- a/docs/drvesx.html.in +++ b/docs/drvesx.html.in @@ -789,6 +789,9 @@ Enter administrator password for example-vcenter.com: performed the ESX server raises an error and the driver reports it.

    +
  • + virDomainGetHostname +
  • virDomainReboot
  • diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0ede65279a..39e3faeb8f 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -5069,6 +5069,59 @@ esxDomainHasManagedSaveImage(virDomainPtr domain, un= signed int flags) } =20 =20 +static char * +esxDomainGetHostname(virDomainPtr domain, + unsigned int flags) +{ + esxPrivate *priv =3D domain->conn->privateData; + esxVI_String *propertyNameList =3D NULL; + esxVI_ObjectContent *virtualMachine =3D NULL; + esxVI_VirtualMachinePowerState powerState; + char *hostname =3D NULL; + char *new_hostname =3D NULL; + + virCheckFlags(0, NULL); + + if (esxVI_EnsureSession(priv->primary) < 0) + return NULL; + + if (esxVI_String_AppendValueListToList(&propertyNameList, + "runtime.powerState\0" + "guest.hostName") < 0 || + esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, + propertyNameList, &virtualMachine, + esxVI_Occurrence_OptionalItem) || + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0= ) { + goto cleanup; + } + + if (powerState !=3D esxVI_VirtualMachinePowerState_PoweredOn) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("Domain is not powered on")); + goto cleanup; + } + + if (esxVI_GetStringValue(virtualMachine, "guest.hostName", + &hostname, esxVI_Occurrence_OptionalItem) < 0= ) { + goto cleanup; + } + + if (!hostname) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("hostName field not available (missing VMware Too= ls?)")); + goto cleanup; + } + + new_hostname =3D g_strdup(hostname); + + cleanup: + esxVI_String_Free(&propertyNameList); + esxVI_ObjectContent_Free(&virtualMachine); + + return new_hostname; +} + + static virHypervisorDriver esxHypervisorDriver =3D { .name =3D "ESX", .connectOpen =3D esxConnectOpen, /* 0.7.0 */ @@ -5149,6 +5202,7 @@ static virHypervisorDriver esxHypervisorDriver =3D { .domainSnapshotDelete =3D esxDomainSnapshotDelete, /* 0.8.0 */ .connectIsAlive =3D esxConnectIsAlive, /* 0.9.8 */ .domainHasManagedSaveImage =3D esxDomainHasManagedSaveImage, /* 1.2.13= */ + .domainGetHostname =3D esxDomainGetHostname, /* 6.0.0 */ }; =20 =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1576853993; cv=none; d=zohomail.com; s=zohoarc; b=dRVkmxb9pnzsjicBFXsFVvpXQAua0fIpTupm93a2Rq450ntnFEcA4oF9bLTIM4hslr7dwNDa+qMzIU4OgeEmt1ifoSgrhJc84Q2pPhsRKDk9KZGZb4nZ9vWj7Rf4fN9EsEoGfNYmLKteFF653E4q7tTVJ+vI1rZ38EsANGbykiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853993; 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=DvUsGvLHu6tINuFiQJE2Ao3YhrMcjDoMcCOltD/TKOI=; b=JGBhtJiwnaN3nNriIkCpjSnnthPvSUkCqCkyQAE452h5ZeCG4i/oDOLL+l+UsQvTdlsr0ZKKP8zUpFe4ygkCY4M5JjJ8yOeomTLLep/Hb8hZnaBCzI4b/T2Bj/AyFjLSxStmzL14rZkx1wM9ab0OWi/2+AAL4PuF+yH9nnVueSM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1576853993785371.7329904271652; Fri, 20 Dec 2019 06:59:53 -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-186-T2RISlhjO5-yqQZ4c-pPYA-1; Fri, 20 Dec 2019 09:58:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 406672F2B; Fri, 20 Dec 2019 14:58:46 +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 1BD0960BF3; Fri, 20 Dec 2019 14:58:46 +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 C9A361808878; Fri, 20 Dec 2019 14:58:45 +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 xBKEwRUS032547 for ; Fri, 20 Dec 2019 09:58:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4BC446FDCE; Fri, 20 Dec 2019 14:58:27 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C805E6E41E for ; Fri, 20 Dec 2019 14:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853992; 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=DvUsGvLHu6tINuFiQJE2Ao3YhrMcjDoMcCOltD/TKOI=; b=DSXSBG5/iOhp29TH3aavLxnnCKnxj1fvEbptsVdss8B0+kqpKpoIQRnmTOtPi1GTmdzgzV l2IjgMARuCOZfx1J/HSBlFt3SyIDahdTUHMs4NHwUZUJFNseQY4urzMnk+tpL+bZm/EppS lICMHDS67E72Wjo8LqvVKxk77U7DPC4= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:10 +0100 Message-Id: <20191220145813.756206-9-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 08/11] esx: generator: fix free of elements in lists 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.12 X-MC-Unique: T2RISlhjO5-yqQZ4c-pPYA-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" When a list is freed, we iterate through all the items, invoking the free function for each; the actual free function called for each element is the function of the actual type of each element, and thus the @_next pointer in the element struct has the same type as the element itself. Currently, the free function gets the parent of the current element type, and invoke its free function to continue freeing the list. However, in case the hierarchy of the classes has more than 1 level (i.e. Class <- SubClass <- SubSubClass), the invoked free function is only the parent class' one, and not the actual base class of the hierarchy. To fix that, change the generator to get the ancestor of a class, and invoking that instead. Also, avoid to set the @_next back, as it is not needed. Fixes commits 5cff36e39ae691fbd7c40597df1732eecf294150 and f76c6dde2e33233566e886d96e76b5fe0c102d9a. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- scripts/esx_vi_generator.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/esx_vi_generator.py b/scripts/esx_vi_generator.py index 048f5dde9e..9e3151943b 100755 --- a/scripts/esx_vi_generator.py +++ b/scripts/esx_vi_generator.py @@ -751,13 +751,13 @@ class Object(GenericObject): source +=3D "{\n" =20 if self.features & Object.FEATURE__LIST: - if self.extends is not None: + ancestor =3D get_ancestor(self) + if ancestor: # avoid "dereferencing type-punned pointer will break # strict-aliasing rules" warnings - source +=3D " esxVI_%s *next =3D (esxVI_%s *)item->_nex= t;\n\n" \ - % (self.extends, self.extends) - source +=3D " esxVI_%s_Free(&next);\n" % self.extends - source +=3D " item->_next =3D (esxVI_%s *)next;\n\n" % = self.name + source +=3D " esxVI_%s *baseNext =3D (esxVI_%s *)item->= _next;\n" \ + % (ancestor, ancestor) + source +=3D " esxVI_%s_Free(&baseNext);\n\n" % ancestor else: source +=3D " esxVI_%s_Free(&item->_next);\n\n" % self.= name =20 @@ -1250,6 +1250,21 @@ def is_known_type(type): type in enums_by_name) =20 =20 +def get_ancestor(obj): + if not obj.extends: + return None + ancestor =3D None + try: + ancestor =3D ancestor_by_name[obj.extends] + except KeyError: + parent =3D objects_by_name[obj.extends] + ancestor =3D get_ancestor(parent) + if not ancestor: + ancestor =3D parent.name + ancestor_by_name[name] =3D ancestor + return ancestor + + def open_and_print(filename): if filename.startswith("./"): print(" GEN " + filename[2:]) @@ -1346,6 +1361,7 @@ managed_objects_by_name =3D {} enums_by_name =3D {} methods_by_name =3D {} block =3D None +ancestor_by_name =3D {} =20 =20 # parse input file --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 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=1576853929; cv=none; d=zohomail.com; s=zohoarc; b=Caf1ppXySB4ieUrrPRY60rrp++/QFO+SahHnFd8yb1cnqA6KEuZ+1lRq3Lb8nQMJA3NM4JeCj61GKwOJkCNWPwy9bPXzFjTwW6WJ3JdiUKDidjw+2zKslMmcltSmjyNR8Bogy091VM1HSF/OvpC9ggkHw5pYNkxTEUHPFYGvJpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853929; 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=NpPX6mHzwNFiHbBr+AoT8fLD73sOLE4bprCOKA+Yz4w=; b=AaCa7mRnpi55rHgvNFNgfh2wR97jzKCKhgTsebBzYVJkzVgS0NGlwa409qa/eXTTxp2by2egzD4VlvDZuNdxS94mbQrOxEfp4cPiNs1vkwVfLb1hMjyiTSdeC94gbdomkf0ewT5IX+l6iDKS+TtuKuwuNdhJ/H/gFYSCdfEu7l8= 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 1576853929716764.520094611374; Fri, 20 Dec 2019 06:58:49 -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-24-j6lzhooKMcCwuke7dyMgoA-1; Fri, 20 Dec 2019 09:58:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A302801F79; Fri, 20 Dec 2019 14:58:41 +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 211E560C87; Fri, 20 Dec 2019 14:58:41 +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 D30EF18089CF; Fri, 20 Dec 2019 14:58:40 +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 xBKEwSZ3032557 for ; Fri, 20 Dec 2019 09:58:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1BBD76E41E; Fri, 20 Dec 2019 14:58:28 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 990C26FEF3 for ; Fri, 20 Dec 2019 14:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853928; 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=NpPX6mHzwNFiHbBr+AoT8fLD73sOLE4bprCOKA+Yz4w=; b=R8MXGEvnCCTJKn9R0S1MG3qR+zRcY9siks0dnOXU3jhTDMjixn8Vp3ijhGeZPEIhsciNN5 vnRuZ2ZnPDIigDAIfjBGK0tmk3ZnroHdtvDVpZDeuNaBigDCPSgcx4e+3VrloDw0/wKdC3 dLOVaK7GCRYVbCto9SwgkMOCpk283Wc= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:11 +0100 Message-Id: <20191220145813.756206-10-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 09/11] esx: generator: add GuestNicInfo object 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.12 X-MC-Unique: j6lzhooKMcCwuke7dyMgoA-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" Add the definition of the GuestNicInfo object, with all the required objects for it. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- scripts/esx_vi_generator.py | 1 + src/esx/esx_vi_generator.input | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/scripts/esx_vi_generator.py b/scripts/esx_vi_generator.py index 9e3151943b..761bb2d8de 100755 --- a/scripts/esx_vi_generator.py +++ b/scripts/esx_vi_generator.py @@ -1297,6 +1297,7 @@ additional_object_features =3D { "DatastoreHostMount": (Object.FEATURE__DEEP_COPY | Object.FEATURE__LIS= T | Object.FEATURE__ANY_TYPE), "DatastoreInfo": Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CA= ST, + "GuestNicInfo": Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE, "HostConfigManager": Object.FEATURE__ANY_TYPE, "HostCpuIdInfo": Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE, "HostDatastoreBrowserSearchResults": (Object.FEATURE__LIST | diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input index 22c114e0aa..bd6ac72a18 100644 --- a/src/esx/esx_vi_generator.input +++ b/src/esx/esx_vi_generator.input @@ -277,6 +277,18 @@ object FolderFileQuery extends FileQuery end =20 =20 +object GuestNicInfo + Boolean connected = r + Int deviceConfigId = r + NetDnsConfigInfo dnsConfig = o + String ipAddress = ol + NetIpConfigInfo ipConfig = o + String macAddress = o + NetBIOSConfigInfo netBIOSConfig = o + String network = o +end + + object HostAutoStartManagerConfig AutoStartDefaults defaults = o AutoStartPowerInfo powerInfo = ol @@ -770,6 +782,48 @@ object NasDatastoreInfo extends Datastore= Info end =20 =20 +object NetBIOSConfigInfo + String mode = r +end + + +object NetDhcpConfigInfo + NetDhcpConfigInfoDhcpOptions ipv4 = o + NetDhcpConfigInfoDhcpOptions ipv6 = o +end + + +object NetDhcpConfigInfoDhcpOptions + KeyAnyValue config = ol + Boolean enable = r +end + + +object NetDnsConfigInfo + Boolean dhcp = r + String domainName = r + String hostName = r + String ipAddress = ol + String searchDomain = ol +end + + +object NetIpConfigInfo + Boolean autoConfigurationEnabled = o + NetDhcpConfigInfo dhcp = o + NetIpConfigInfoIpAddress ipAddress = ol +end + + +object NetIpConfigInfoIpAddress + String ipAddress = r + DateTime lifetime = o + String origin = o + Int prefixLength = r + String state = o +end + + object ObjectContent ManagedObjectReference obj = r DynamicProperty propSet = ol --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1576853934; cv=none; d=zohomail.com; s=zohoarc; b=DTNdtgYINOUYrxOqmIQSzPAaKb7l0KRqGTBr6cJsleoza8B511vFyuIg8w8/Tpl+cdWITK/+MYvaPNbriZroYA32TJ4m5rnwIsMMJ2bg+0QD4+Xfjc4/fQQp4Mj1/hXaoOnwd0h6jVCoXS7zRL7Nqqfw/1X46ljY2KXlPyw4BIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853934; 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=DudCZ9VFqjXDWer4AQNnWqVY9sriYXM3NL9YCKlcyJU=; b=nuEC3iB3+rb9QSG5HsutR1/sUcAzcV1UFseug4WoLiQPeassCLWNMbCmTajUZ1CBBPFSOpisPKqclEYP/j3X0p7naJvTVHTew7ba3o8wrBOTJRy8Ce1I8vqgimEGicxJamnH2Ujlbs2GIZG9sI//LE9zw5JZ0eSFfJxa1fZE1/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1576853934930829.0410232156598; Fri, 20 Dec 2019 06:58:54 -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-424-EpQYxnWyPjKttQx4Z_62rA-1; Fri, 20 Dec 2019 09:58:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34ABF8FD567; Fri, 20 Dec 2019 14:58:46 +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 11EE35DA60; Fri, 20 Dec 2019 14:58:46 +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 C0E12252EF; Fri, 20 Dec 2019 14:58:45 +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 xBKEwSYC032564 for ; Fri, 20 Dec 2019 09:58:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id E035C6FEF3; Fri, 20 Dec 2019 14:58:28 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69AB16E41E for ; Fri, 20 Dec 2019 14:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853933; 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=DudCZ9VFqjXDWer4AQNnWqVY9sriYXM3NL9YCKlcyJU=; b=BcFGUrqz6zaqjc7CnGBbEXy+j5REY40zJeIgR8UjfcXQo0Se9BV20fIfDpU4GudG7KUDki BLd94PNB/yOJSbgFcMRQYHlHYR6hCUkEJFxHk+CcT35tuWY114MRAiOUwOJDxlnC96IWmw r21c1fRGgMhItYmRm1tQYMvGwAVBZwY= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:12 +0100 Message-Id: <20191220145813.756206-11-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 10/11] esx: implement domainInterfaceAddresses 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.14 X-MC-Unique: EpQYxnWyPjKttQx4Z_62rA-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" Implement the .domainInterfaceAddresses hypervisor API, although only functional for the VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT source. Signed-off-by: Pino Toscano Reviewed-by: Michal Privoznik --- docs/drvesx.html.in | 4 ++ src/esx/esx_driver.c | 166 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in index 465daafc2e..c4a2ae78a8 100644 --- a/docs/drvesx.html.in +++ b/docs/drvesx.html.in @@ -792,6 +792,10 @@ Enter administrator password for example-vcenter.com:
  • virDomainGetHostname
  • +
  • + virDomainInterfaceAddresses (only for the + VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT source) +
  • virDomainReboot
  • diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 39e3faeb8f..73b8f32f1b 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -5122,6 +5122,171 @@ esxDomainGetHostname(virDomainPtr domain, } =20 =20 +static int +esxParseIPAddress(const char *ipAddress, int prefixLength, + virDomainIPAddress *addr) +{ + virSocketAddr tmp_addr; + virIPAddrType addr_type; + + if (virSocketAddrParseAny(&tmp_addr, ipAddress, AF_UNSPEC, false) <=3D= 0) + return 0; + + switch (VIR_SOCKET_ADDR_FAMILY(&tmp_addr)) { + case AF_INET: + addr_type =3D VIR_IP_ADDR_TYPE_IPV4; + break; + case AF_INET6: + addr_type =3D VIR_IP_ADDR_TYPE_IPV6; + break; + default: + return 0; + } + + addr->type =3D addr_type; + addr->addr =3D g_strdup(ipAddress); + addr->prefix =3D prefixLength; + + return 1; +} + + +static int +esxDomainInterfaceAddresses(virDomainPtr domain, + virDomainInterfacePtr **ifaces, + unsigned int source, + unsigned int flags) +{ + int result =3D -1; + esxPrivate *priv =3D domain->conn->privateData; + esxVI_String *propertyNameList =3D NULL; + esxVI_ObjectContent *virtualMachine =3D NULL; + esxVI_VirtualMachinePowerState powerState; + esxVI_DynamicProperty *dynamicProperty; + esxVI_GuestNicInfo *guestNicInfoList =3D NULL; + esxVI_GuestNicInfo *guestNicInfo =3D NULL; + virDomainInterfacePtr *ifaces_ret =3D NULL; + size_t ifaces_count =3D 0; + size_t i; + int ret; + + virCheckFlags(0, -1); + if (source !=3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("Unknown IP address data source %d"), + source); + return -1; + } + + if (esxVI_EnsureSession(priv->primary) < 0) + return -1; + + if (esxVI_String_AppendValueListToList(&propertyNameList, + "runtime.powerState\0" + "guest.net") < 0 || + esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, + propertyNameList, &virtualMachine, + esxVI_Occurrence_RequiredItem) || + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0= ) { + goto cleanup; + } + + if (powerState !=3D esxVI_VirtualMachinePowerState_PoweredOn) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("Domain is not powered on")); + goto cleanup; + } + + for (dynamicProperty =3D virtualMachine->propSet; dynamicProperty; + dynamicProperty =3D dynamicProperty->_next) { + if (STREQ(dynamicProperty->name, "guest.net")) { + if (esxVI_GuestNicInfo_CastListFromAnyType + (dynamicProperty->val, &guestNicInfoList) < 0) { + goto cleanup; + } + } + } + + if (!guestNicInfoList) + goto cleanup; + + for (guestNicInfo =3D guestNicInfoList; guestNicInfo; + guestNicInfo =3D guestNicInfo->_next) { + virDomainInterfacePtr iface =3D NULL; + size_t addrs_count =3D 0; + + if (guestNicInfo->connected !=3D esxVI_Boolean_True || + !guestNicInfo->network) { + continue; + } + + if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) + goto cleanup; + + if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0) + goto cleanup; + + iface =3D ifaces_ret[ifaces_count - 1]; + iface->naddrs =3D 0; + iface->name =3D g_strdup(guestNicInfo->network); + iface->hwaddr =3D g_strdup(guestNicInfo->macAddress); + + if (guestNicInfo->ipConfig) { + esxVI_NetIpConfigInfoIpAddress *ipAddress; + for (ipAddress =3D guestNicInfo->ipConfig->ipAddress; ipAddres= s; + ipAddress =3D ipAddress->_next) { + virDomainIPAddress ip_addr; + + ret =3D esxParseIPAddress(ipAddress->ipAddress, + ipAddress->prefixLength->value, &i= p_addr); + if (ret < 0) + goto cleanup; + else if (ret =3D=3D 0) + continue; + + if (VIR_APPEND_ELEMENT(iface->addrs, addrs_count, ip_addr)= < 0) + goto cleanup; + } + } else { + esxVI_String *str; + for (str =3D guestNicInfo->ipAddress; str; + str =3D str->_next) { + virDomainIPAddress ip_addr; + + /* Not even the netmask seems available... */ + ret =3D esxParseIPAddress(str->value, 0, &ip_addr); + if (ret < 0) + goto cleanup; + else if (ret =3D=3D 0) + continue; + + if (VIR_APPEND_ELEMENT(iface->addrs, addrs_count, ip_addr)= < 0) + goto cleanup; + + } + } + + iface->naddrs =3D addrs_count; + } + + *ifaces =3D ifaces_ret; + result =3D ifaces_count; + + cleanup: + if (result < 0) { + if (ifaces_ret) { + for (i =3D 0; i < ifaces_count; i++) + virDomainInterfaceFree(ifaces_ret[i]); + } + } + esxVI_String_Free(&propertyNameList); + esxVI_ObjectContent_Free(&virtualMachine); + esxVI_GuestNicInfo_Free(&guestNicInfoList); + + return result; +} + + static virHypervisorDriver esxHypervisorDriver =3D { .name =3D "ESX", .connectOpen =3D esxConnectOpen, /* 0.7.0 */ @@ -5203,6 +5368,7 @@ static virHypervisorDriver esxHypervisorDriver =3D { .connectIsAlive =3D esxConnectIsAlive, /* 0.9.8 */ .domainHasManagedSaveImage =3D esxDomainHasManagedSaveImage, /* 1.2.13= */ .domainGetHostname =3D esxDomainGetHostname, /* 6.0.0 */ + .domainInterfaceAddresses =3D esxDomainInterfaceAddresses, /* 6.0.0 */ }; =20 =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 19:42:59 2024 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=1576853949; cv=none; d=zohomail.com; s=zohoarc; b=Q3jwOdzwSfy19Hx/VxcJFYpm3+QUAwhhLO2WhLQA7KZ4prKQV+7RonlVOVb11f34zkGGFNBKSKs/iVPI1N0nmOJlxbJTpi4Jyha/mIUo79vtYztzyVOrdd5mR/QU51ZKurybL1dqeNjwW5pR6rqJ06+uDiGN/PuJ4J7AGataHHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576853949; 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=R23g3AqmO3WyWoexPTdfI1+bQ6gaTd8RRFXoWMRg+Ek=; b=L8KjAjKHB9Mb5SW9bfRQhm8u9PNC/4n4oAutkOYTajDsH73CGZGmxkR69YqWbNsRPe7vdfxq1Oj6mALpzTNdCCNymNav2T0xKFwHLSYWKNJDqIlSMrG3W6kutUGRBcK4mnEIZyE7RSUYg08XNVJoEGs6i7S3S+Syo2ukVCALa3A= 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 1576853949346828.9781636266636; Fri, 20 Dec 2019 06:59:09 -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-209-RrnaKC4TNwyKJ1qh9ISQCg-1; Fri, 20 Dec 2019 09:58:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A22DA8FD56A; Fri, 20 Dec 2019 14:58:49 +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 809D6100194E; Fri, 20 Dec 2019 14:58:49 +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 3EF0B252F6; Fri, 20 Dec 2019 14:58:49 +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 xBKEwT4Q032572 for ; Fri, 20 Dec 2019 09:58:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id B01766E41E; Fri, 20 Dec 2019 14:58:29 +0000 (UTC) Received: from lindworm.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3936F7C839 for ; Fri, 20 Dec 2019 14:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576853948; 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=R23g3AqmO3WyWoexPTdfI1+bQ6gaTd8RRFXoWMRg+Ek=; b=LCBM0nY8KN1IUUd/cUI9HwVtEqfv8WiLYIv5jcv5YdMm0uI4idoWr/FxhYaX0Ce+nqZQLh gx9OkdwQSfBMbDlp3Mz1i5iHDNn7xJmYEBDkdNh6vYW0M5sDtDeG4L/XnFe03H+q77VJDx bPCbgmR69u94sVHKf0GwT0YQgBiHR+U= From: Pino Toscano To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:58:13 +0100 Message-Id: <20191220145813.756206-12-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 11/11] docs: document implemented APIs in esx 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.22 X-MC-Unique: RrnaKC4TNwyKJ1qh9ISQCg-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: Pino Toscano Reviewed-by: Michal Privoznik --- docs/news.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 055353b9a5..6c29011d53 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -86,6 +86,20 @@ lzop should be used. + + + esx: implement various APIs + + + The virConnectListAllStoragePools(), + virConnectListAllNetworks(), + virStoragePoolListAllVolumes(), + virDomainGetHostname, + and virDomainInterfaceAddresses (only for + VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT source) + APIs were implemented in the esx driver. + +
    --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list