From nobody Mon Feb 2 07:30:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1768924590; cv=none; d=zohomail.com; s=zohoarc; b=kUpgjKngzxhUjZapQmiTDNM64fBDbWkXkfQHzP/3f7S1ChqQ9mIxLbS/8boSJxE3d33UP8Ikxer5nzcl12SzkV1vwsAIIs0fpGJ2LlfHoohsj004s78gW3QxWd+vPOa7YEk3ZWxmRBDJppTr/f5A4cgmHVYyqiS1d/OOcwueLvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768924590; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=JzM93W2nBqXJefumj6+rXF1ERSkZdcZl6TBLTTlfyJI=; b=Q5I43pp9+9SXg/Y3LzetTKLovFQY/AZ8HQwH/a1kvEmXwWvfjn96/Y2PQtboIqoy6kM8awFmje3VW46yFYr53D2v1I7G59lYp6HpvR1dD5JE+SBmLSizh8nPZczln33s8zMiGbiyMXLj/FqSqrDHEWwivXBgOlP1UIuRb0OHwi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1768924589904976.4526002546305; Tue, 20 Jan 2026 07:56:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 55DD43F33C; Tue, 20 Jan 2026 10:56:29 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 66D9E43EAE; Tue, 20 Jan 2026 10:54:30 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id B876341A25; Tue, 20 Jan 2026 10:54:25 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E2137417E1 for ; Tue, 20 Jan 2026 10:54:24 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-PSK9dg7kOCOCohaPWKAqTw-1; Tue, 20 Jan 2026 10:54:23 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3DC321956096 for ; Tue, 20 Jan 2026 15:54:22 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 99C1C1800993 for ; Tue, 20 Jan 2026 15:54:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768924464; h=from:from: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; bh=JzM93W2nBqXJefumj6+rXF1ERSkZdcZl6TBLTTlfyJI=; b=Q4ZUgpojWAEKsbTiDtlYFL/+DgErMEmyxgMn9+ZpJlx2WZylw2wQs7WYePa8a1KcMNo4Mw vsLvmoiw+ZMLcy6tJ2N3amTUBPWVC/duGNjUcXfbVnbE4en3OOR+rliJTZqDtWFVpyW38g LDOEyeN7bKE9ViwQ38nsnpIQ75KtyFo= X-MC-Unique: PSK9dg7kOCOCohaPWKAqTw-1 X-Mimecast-MFC-AGG-ID: PSK9dg7kOCOCohaPWKAqTw_1768924462 To: devel@lists.libvirt.org Subject: [PATCH 2/2] src: Use device alias when ifname is unset in virDomainInterfaceAddresses() Date: Tue, 20 Jan 2026 16:54:16 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 47NH1cNFyJAZdMD6yon6wse0b140sGtlNfn_itc_XCg_1768924462 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OY7PTCUY6CHBHLUKK5JSK6XTHVPJ7ZVW X-Message-ID-Hash: OY7PTCUY6CHBHLUKK5JSK6XTHVPJ7ZVW X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1768924592625154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The virDomainInterfaceAddresses() API returns an array of _virDomainInterface structs which then describe IP addresses associated with given domain. The struct contains 'name' member which is documented deliberately vaguely: "interface name". This is because depending on the source of truth used (controlled by 'source' argument) the name can be wildly different from the one in domain XML. Now, in case of source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP, the host's ARP table is parsed and matching interfaces are found by comparing MAC addresses. If it's a match then the 'name' is set to net->ifname (corresponds to /interface/target/@dev). But that is not always set and sometimes may be NULL (e.g. for hostdevs, usernet). We can't change the API (like we did for hwaddr in v1.2.14-rc1~105) because this is already released. So the next best thing to do is to put the interface alias in there. To be on a safe side, do the same change to the VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE case. Resolves: https://issues.redhat.com/browse/RHEL-141496 Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 16 ++++++++++++++-- src/libvirt-domain.c | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d00a43e969..8b26de674e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15598,6 +15598,12 @@ virDomainNetDHCPInterfaces(virDomainDef *def, goto error; =20 if (n_leases) { + const char *ifname =3D def->nets[i]->ifname; + + if (!ifname) { + ifname =3D def->nets[i]->info.alias; + } + ifaces_ret =3D g_renew(virDomainInterfacePtr, ifaces_ret, ifac= es_count + 1); ifaces_ret[ifaces_count] =3D g_new0(virDomainInterface, 1); iface =3D ifaces_ret[ifaces_count]; @@ -15606,7 +15612,7 @@ virDomainNetDHCPInterfaces(virDomainDef *def, /* Assuming each lease corresponds to a separate IP */ iface->naddrs =3D n_leases; iface->addrs =3D g_new0(virDomainIPAddress, iface->naddrs); - iface->name =3D g_strdup(def->nets[i]->ifname); + iface->name =3D g_strdup(ifname); iface->hwaddr =3D g_strdup(macaddr); } =20 @@ -15660,9 +15666,15 @@ virDomainNetARPInterfaces(virDomainDef *def, virArpTableEntry entry =3D table->t[j]; =20 if (STREQ(entry.mac, macaddr)) { + const char *ifname =3D def->nets[i]->ifname; + + if (!ifname) { + ifname =3D def->nets[i]->info.alias; + } + iface =3D g_new0(virDomainInterface, 1); =20 - iface->name =3D g_strdup(def->nets[i]->ifname); + iface->name =3D g_strdup(ifname); =20 iface->hwaddr =3D g_strdup(macaddr); =20 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index a278c4679d..a1f6efde20 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12880,6 +12880,8 @@ virDomainFSInfoFree(virDomainFSInfoPtr info) * Note that for some @source values some pieces of returned @ifaces * might be unset (e.g. VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP does not * set IP address prefix as ARP table does not have any notion of that). + * Moreover, it may happen that the interface doesn't have a name. In + * that case, @ifaces->name is set to the interface's device alias. * * @ifaces->name is never NULL, and @ifaces->hwaddr may be NULL. * --=20 2.52.0