From nobody Sun Feb 8 12:20:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578573983; cv=none; d=zohomail.com; s=zohoarc; b=PSysXHeosWDWb8I0//o0P5cBHxGEh9vvWyzp1Lksv7uuRPErwXd2qYjZWT+D7DaCvY2xHLcYAIWF+eoFUgORdpXV4wBGS+reeIFFLwvT1VyuybJmGMPz7pcJvjP/iAzesKtLngJndyRd3xGnBSFGcE4lSNJ/feWe4MRwchPK6tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578573983; h=Content-Type:Content-Transfer-Encoding:Cc: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=laF13MMafw1ahsDNPLl5DKc9FlhQP7b/UZBHBpCeFGY=; b=L3+8+b9uPdk5s7dnFNBoPipRKoL+jYwJuQO4+irXJsWwJvqa3M97mb7AaJTG6BVL9G7xQv2hWkoV9rZ/pqK5QWQTbk0b9bmR6orqfqAUh7sKhflmMOQ3vX8PGPtuTdB6Vo2JSRAv99uP/P8AOQPjKsJZegy68HD7Vu0Ycaq3f+Q= 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 1578573983424448.2811223551106; Thu, 9 Jan 2020 04:46:23 -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-66-zpwlI-XdNSSAtaPW_5QShw-1; Thu, 09 Jan 2020 07:46:19 -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 5D1F81005513; Thu, 9 Jan 2020 12:46:13 +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 9EE6C7FB5C; Thu, 9 Jan 2020 12:46:12 +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 DD815503BE; Thu, 9 Jan 2020 12:46:11 +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 009Ck9us030823 for ; Thu, 9 Jan 2020 07:46:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4357786C5C; Thu, 9 Jan 2020 12:46:09 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99DCD86CBA; Thu, 9 Jan 2020 12:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578573980; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=laF13MMafw1ahsDNPLl5DKc9FlhQP7b/UZBHBpCeFGY=; b=DRRN3ah8oFCL5CoAITnhUGOc41isk1LcX2HKYUIlQurGk5Qznjwwlog4nuENxM5PBxn4M+ fzT+/iSCAD7+tNRwme1qXtkCxF0WUbJrCATSsDgqa+UNPIBljg4UgnnQ/p8TdSZGJZ6q57 VqhZJZSUILDhyYdI/wWMmko+NCkDGVg= From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 9 Jan 2020 13:45:57 +0100 Message-Id: <41c0cfde24da010b1b563affc3442c830a31909d.1578573671.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: jcfaracco@gmail.com Subject: [libvirt] [PATCH v4 2/5] Introduce source flags to virDomainGetHostname() 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: zpwlI-XdNSSAtaPW_5QShw-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" From: Julio Faracco There is a lots of possibilities to retrieve hostname information from domain. Libvirt could use lease information from dnsmasq to get current hostname too. QEMU supports QEMU-agent but it can use lease source. Signed-off-by: Michal Privoznik Signed-off-by: Julio Faracco Reviewed-by: Erik Skultety --- include/libvirt/libvirt-domain.h | 6 ++++++ include/libvirt/virterror.h | 1 + src/libvirt-domain.c | 9 +++++---- src/remote/remote_daemon.c | 1 + src/util/virerror.c | 3 +++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index c1b9a9d1d0..44f6b62913 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1567,6 +1567,12 @@ int virDomainSetMemoryStatsPerio= d (virDomainPtr domain, int virDomainGetMaxVcpus (virDomainPtr domain); int virDomainGetSecurityLabel (virDomainPtr domain, virSecurityLabelPtr sec= label); + +typedef enum { + VIR_DOMAIN_GET_HOSTNAME_LEASE =3D (1 << 0), /* Parse DHCP lease file */ + VIR_DOMAIN_GET_HOSTNAME_AGENT =3D (1 << 1), /* Query qemu guest agent = */ +} virDomainGetHostnameFlags; + char * virDomainGetHostname (virDomainPtr domain, unsigned int flags); int virDomainGetSecurityLabelList (virDomainPtr domain, diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 54f4f8190d..b7aa2a0ec3 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -332,6 +332,7 @@ typedef enum { VIR_ERR_INVALID_NETWORK_PORT =3D 105, /* invalid network port object */ VIR_ERR_NETWORK_PORT_EXIST =3D 106, /* the network port already exis= t */ VIR_ERR_NO_NETWORK_PORT =3D 107, /* network port not found */ + VIR_ERR_NO_HOSTNAME =3D 108, /* no domain's hostname found */ =20 # ifdef VIR_ENUM_SENTINELS VIR_ERR_NUMBER_LAST diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index eb66999f07..d0304e174f 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11025,12 +11025,13 @@ virDomainGetDiskErrors(virDomainPtr dom, /** * virDomainGetHostname: * @domain: a domain object - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of virDomainGetHostnameFlags * - * Get the hostname for that domain. + * Get the hostname for that domain. If no hostname is found, + * then an error is raised with VIR_ERR_NO_HOSTNAME code. * - * Dependent on hypervisor used, this may require a guest agent to be - * available. + * Dependent on hypervisor and @flags used, this may require a + * guest agent to be available. * * Returns the hostname which must be freed by the caller, or * NULL if there was an error. diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index cd55b2c39e..1c224f8050 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -296,6 +296,7 @@ static int daemonErrorLogFilter(virErrorPtr err, int pr= iority) case VIR_ERR_NO_DOMAIN_METADATA: case VIR_ERR_NO_SERVER: case VIR_ERR_NO_CLIENT: + case VIR_ERR_NO_HOSTNAME: return VIR_LOG_DEBUG; } =20 diff --git a/src/util/virerror.c b/src/util/virerror.c index aac6ee3597..0f3ee1faaa 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1233,6 +1233,9 @@ static const virErrorMsgTuple virErrorMsgStrings[] = =3D { [VIR_ERR_NO_NETWORK_PORT] =3D { N_("network port not found"), N_("network port not found: %s") }, + [VIR_ERR_NO_HOSTNAME] =3D { + N_("no hostname found"), + N_("no hostname found: %s") }, }; =20 G_STATIC_ASSERT(G_N_ELEMENTS(virErrorMsgStrings) =3D=3D VIR_ERR_NUMBER_LAS= T); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list