From nobody Sun Feb 8 14:12:33 2026
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
---
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