From nobody Sat Apr 27 23:55:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516810848104360.99201456815604; Wed, 24 Jan 2018 08:20:48 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 29FEF780EA; Wed, 24 Jan 2018 16:20:47 +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 F0C645C8A5; Wed, 24 Jan 2018 16:20: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 81D7018033D8; Wed, 24 Jan 2018 16:20:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0OGCYAb027265 for ; Wed, 24 Jan 2018 11:12:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id A0A2B60462; Wed, 24 Jan 2018 16:12:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AEC36017B for ; Wed, 24 Jan 2018 16:12:32 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 4643FC049D53 for ; Wed, 24 Jan 2018 16:12:28 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowAAHdX5asGhaJNIABQ--.63591S3; Thu, 25 Jan 2018 00:12:17 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=lp5YzRIWxUsF9Eugo7 dsYo2CELcZHHmS3zjgplncQzU=; b=V3364e68qSg3rqHuWaDUam9/pWbsR4fmyB 7lbxOeeBPK7tx64cSyoo4vv6q2kPU8ma2eX2ARqqU28WrwXaRbpjwxwmkyqjWxSd F0eW9cYFGsO6Cso8ngp8Jws7Ah/hVil4gpB6V0EzAmaKqPrv4jJF+RulinD2PQBg FhDvrYcKU= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 00:09:43 +0800 Message-Id: <20180124160946.31429-2-chen_han_xiao@126.com> In-Reply-To: <20180124160946.31429-1-chen_han_xiao@126.com> References: <20180124160946.31429-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowAAHdX5asGhaJNIABQ--.63591S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxXr1UArW8Ww15Gw1xKrWUXFb_yoWrGw4UpF 4DJF90yw4rJw1fur9xZa10kF1rKw4vqr45trn7uFn0ka1kJF1xtrW7GFy7tay5t3y293sx CFsrKryj9rWkt3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jjLvtUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbiaQLXrlpD4DLD6QAAsz X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 24 Jan 2018 16:12:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 24 Jan 2018 16:12:31 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v2 1/4] util: introduce helper to parse /proc/net/arp 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 24 Jan 2018 16:20:47 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao introduce helper to parse /proc/net/arp and store it in struct virArpTable. Signed-off-by: Chen Hanxiao --- src/libvirt_private.syms | 2 ++ src/util/virmacaddr.c | 67 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virmacaddr.h | 18 +++++++++++++ 3 files changed, 87 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bc8cc1fba..26385a2e9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2133,6 +2133,8 @@ virLogVMessage; =20 =20 # util/virmacaddr.h +virArpTableFree; +virGetArpTable; virMacAddrCmp; virMacAddrCmpRaw; virMacAddrCompare; diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c index 409fdc34d..540bdbbaa 100644 --- a/src/util/virmacaddr.c +++ b/src/util/virmacaddr.c @@ -27,10 +27,15 @@ #include =20 #include "c-ctype.h" +#include "viralloc.h" +#include "virfile.h" #include "virmacaddr.h" #include "virrandom.h" +#include "virstring.h" #include "virutil.h" =20 +#define VIR_FROM_THIS VIR_FROM_NONE + static const unsigned char virMacAddrBroadcastAddrRaw[VIR_MAC_BUFLEN] =3D { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; =20 @@ -257,3 +262,65 @@ virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC= _BUFLEN]) { return memcmp(virMacAddrBroadcastAddrRaw, s, sizeof(*s)) =3D=3D 0; } + +int +virGetArpTable(virArpTablePtr *table) +{ +#define PROC_NET_ARP "/proc/net/arp" + FILE *fp =3D NULL; + char line[1024]; + int num =3D 0; + int ret =3D -1; + + if (!(fp =3D fopen(PROC_NET_ARP, "r"))) + goto cleanup; + + while (fgets(line, sizeof(line), fp)) { + char ip[32], mac[32], dev_name[32], hwtype[32], + flags[32], mask[32], nouse[32]; + + if (STRPREFIX(line, "IP address")) + continue; + + num++; + if (VIR_REALLOC_N((*table)->t, num) < 0) + goto cleanup; + (*table)->n =3D num; + /* /proc/net/arp looks like: + * 172.16.17.254 0x1 0x2 e4:68:a3:8d:ed:d3 * enp3s0 + */ + sscanf(line, "%[0-9.]%[ ]%[^ ]%[ ]%[^ ]%[ ]%[^ ]%[ ]%[^ ]%[ ]%[^ \= t\n]", + ip, nouse, + hwtype, nouse, + flags, nouse, + mac, nouse, + mask, nouse, + dev_name); + + + if (VIR_STRDUP((*table)->t[num - 1].ipaddr, ip) < 0) + goto cleanup; + if (VIR_STRDUP((*table)->t[num - 1].mac, mac) < 0) + goto cleanup; + if (VIR_STRDUP((*table)->t[num - 1].dev_name, dev_name) < 0) + goto cleanup; + } + + ret =3D 0; + + cleanup: + VIR_FORCE_FCLOSE(fp); + return ret; +} + +void +virArpTableFree(virArpTablePtr table) +{ + size_t i; + for (i =3D 0; i < table->n; i++) { + VIR_FREE(table->t[i].ipaddr); + VIR_FREE(table->t[i].mac); + VIR_FREE(table->t[i].dev_name); + } + VIR_FREE(table); +} diff --git a/src/util/virmacaddr.h b/src/util/virmacaddr.h index ef4285d63..eb18092d1 100644 --- a/src/util/virmacaddr.h +++ b/src/util/virmacaddr.h @@ -40,6 +40,22 @@ struct _virMacAddr { false otherwise. */ }; =20 +typedef struct _virArpTableEntry virArpTableEntry; +typedef virArpTableEntry *virArpTableEntryPtr; +typedef struct _virArpTable virArpTable; +typedef virArpTable *virArpTablePtr; + +struct _virArpTableEntry{ + char *ipaddr; + char *mac; + char *dev_name; +}; + +struct _virArpTable { + int n; + virArpTableEntryPtr t; +}; + int virMacAddrCompare(const char *mac1, const char *mac2); int virMacAddrCmp(const virMacAddr *mac1, const virMacAddr *mac2); int virMacAddrCmpRaw(const virMacAddr *mac1, @@ -59,5 +75,7 @@ int virMacAddrParseHex(const char* str, bool virMacAddrIsUnicast(const virMacAddr *addr); bool virMacAddrIsMulticast(const virMacAddr *addr); bool virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN]); +int virGetArpTable(virArpTablePtr *table); +void virArpTableFree(virArpTablePtr table); =20 #endif /* __VIR_MACADDR_H__ */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 23:55:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516810400337126.99646082046536; Wed, 24 Jan 2018 08:13:20 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id B8E90C057FA1; Wed, 24 Jan 2018 16:13:18 +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 4BE7560C8B; Wed, 24 Jan 2018 16:13:18 +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 784925FBD7; Wed, 24 Jan 2018 16:13:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0OGCxi2027295 for ; Wed, 24 Jan 2018 11:12:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E21617153; Wed, 24 Jan 2018 16:12:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 657175C8B7 for ; Wed, 24 Jan 2018 16:12:53 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 84C7B5312D for ; Wed, 24 Jan 2018 16:12:44 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowAAHdX5asGhaJNIABQ--.63591S4; Thu, 25 Jan 2018 00:12:17 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=f+AohSl8j9ZP9toFg/ gp3yHKEU8PcrxlKCrXfiTFCME=; b=lgzalNCGLoatrdkX/8bmevsAWQHVBseYWO 1T3ExcplrRaxmom1Z8OaslvVZZVMtOZ/I0ZDx/nSrJdRQBpBFQhKGEiPtMAyO174 ES9wf8S8axV3QfcO6jcQX0AjWsind94b55RZ8fPrLNItaBSbKpyJUSeDQYTpNkOy DI5arq4YY= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 00:09:44 +0800 Message-Id: <20180124160946.31429-3-chen_han_xiao@126.com> In-Reply-To: <20180124160946.31429-1-chen_han_xiao@126.com> References: <20180124160946.31429-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowAAHdX5asGhaJNIABQ--.63591S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxZFWDKF43GF45ZFW7Kr1xZrb_yoW5tr1fpF WUXws5trW8Gr1fG3yfGa17ZFn8G3y8KF9xWanagan2vr18Jr9rXw1xWw4jvFyjyr4fZFy7 Cr9FgayUWanFgFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jjnQUUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbiaALXrlpD4rHigAAAs7 X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 24 Jan 2018 16:12:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 24 Jan 2018 16:12:53 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v2 2/4] qemu: introduce qemuARPGetInterfaces to get IP from host's arp table 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 24 Jan 2018 16:13:19 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao introduce VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP to get ip address of VM from the output of /proc/net/arp Signed-off-by: Chen Hanxiao --- include/libvirt/libvirt-domain.h | 1 + src/qemu/qemu_driver.c | 75 ++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 76 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4048acf38..38e2d9a3e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4665,6 +4665,7 @@ typedef virMemoryParameter *virMemoryParameterPtr; typedef enum { VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE =3D 0, /* Parse DHCP lease fi= le */ VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT =3D 1, /* Query qemu guest ag= ent */ + VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP =3D 2, /* Query ARP tables */ =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a203c9297..e31a74261 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -160,6 +160,9 @@ static int qemuGetDHCPInterfaces(virDomainPtr dom, virDomainObjPtr vm, virDomainInterfacePtr **ifaces); =20 +static int qemuARPGetInterfaces(virDomainObjPtr vm, + virDomainInterfacePtr **ifaces); + static virQEMUDriverPtr qemu_driver; =20 =20 @@ -20384,6 +20387,10 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, =20 break; =20 + case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP: + ret =3D qemuARPGetInterfaces(vm, ifaces); + break; + default: virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Unknown IP address data source %d"), @@ -20494,6 +20501,74 @@ qemuGetDHCPInterfaces(virDomainPtr dom, } =20 =20 +static int +qemuARPGetInterfaces(virDomainObjPtr vm, + virDomainInterfacePtr **ifaces) +{ + size_t i, j; + size_t ifaces_count =3D 0; + int ret =3D -1; + char macaddr[VIR_MAC_STRING_BUFLEN]; + virDomainInterfacePtr *ifaces_ret =3D NULL; + virDomainInterfacePtr iface =3D NULL; + + virArpTablePtr table; + if (VIR_ALLOC(table) < 0) + goto error; + if (virGetArpTable(&table) < 0) + goto cleanup; + + for (i =3D 0; i < vm->def->nnets; i++) { + if (vm->def->nets[i]->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) + continue; + + virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr); + virArpTableEntry entry; + for (j =3D 0; j < table->n; j++) { + entry =3D table->t[j]; + if (STREQ(entry.mac, macaddr)) { + if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) + goto error; + + if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0) + goto error; + + iface =3D ifaces_ret[ifaces_count - 1]; + iface->naddrs =3D 1; + if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) + goto error; + + if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) = < 0) + goto cleanup; + + if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) + goto cleanup; + + if (VIR_STRDUP(iface->addrs->addr, entry.ipaddr) < 0) + goto cleanup; + } + } + } + + *ifaces =3D ifaces_ret; + ifaces_ret =3D NULL; + ret =3D ifaces_count; + + cleanup: + virArpTableFree(table); + return ret; + + error: + if (ifaces_ret) { + for (i =3D 0; i < ifaces_count; i++) + virDomainInterfaceFree(ifaces_ret[i]); + } + VIR_FREE(ifaces_ret); + + goto cleanup; +} + + static int qemuDomainSetUserPassword(virDomainPtr dom, const char *user, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 23:55:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516810521480117.31344743565194; Wed, 24 Jan 2018 08:15:21 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id C7CE38F898; Wed, 24 Jan 2018 16:15:19 +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 263175C544; Wed, 24 Jan 2018 16:15:18 +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 D24915FBD9; Wed, 24 Jan 2018 16:15:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0OGCUH9027248 for ; Wed, 24 Jan 2018 11:12:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9A2360E39; Wed, 24 Jan 2018 16:12:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADC2160C98 for ; Wed, 24 Jan 2018 16:12:26 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 7FAE412E4F0 for ; Wed, 24 Jan 2018 16:12:24 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowAAHdX5asGhaJNIABQ--.63591S5; Thu, 25 Jan 2018 00:12:17 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=TBpxqhAsDSbwI3pABe LRThVMnHHz/8e5QTctVNVnFs8=; b=JXyVS5w/yJAYL4wm2GTvr+d3R1L7LX9o8t nAsi9+11xzDs8oyKgX99bnumqAviAjRjZXwgt0KeTphnl9fc+ZqsgojLVLzrOgIu PsNg1xwYniA8qxxjlmnYNZLifRKErlw+sCDiAyM/W8f6sdMaD/dZF0LD2Dwt8TNS cbWJUXXpU= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 00:09:45 +0800 Message-Id: <20180124160946.31429-4-chen_han_xiao@126.com> In-Reply-To: <20180124160946.31429-1-chen_han_xiao@126.com> References: <20180124160946.31429-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowAAHdX5asGhaJNIABQ--.63591S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr48Xr45AFy5ury8Ww4xXrb_yoW8ZFW7pF s3Xay7A34kXrn8X3Z5Cw15uFykG3y29r18uan8Xw1jvr45A3WDJr17GFW09F17Ar10v3W0 vrZF9F4DZFs5AF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jI4EiUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbikgLXrlpD4DXXOgAAsI X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 24 Jan 2018 16:12:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 24 Jan 2018 16:12:25 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v2 3/4] virsh: add --source arp to domifaddr 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 24 Jan 2018 16:15:21 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao We can use: domifaddr f26-cloud --source arp to get the address. Signed-off-by: Chen Hanxiao --- tools/virsh-domain-monitor.c | 2 ++ tools/virsh.pod | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 32a42707e..68da11ed5 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2190,6 +2190,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE; } else if (STREQ(sourcestr, "agent")) { source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT; + } else if (STREQ(sourcestr, "arp")) { + source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP; } else { vshError(ctl, _("Unknown data source '%s'"), sourcestr); goto cleanup; diff --git a/tools/virsh.pod b/tools/virsh.pod index 69cc42338..1dfe2a9b0 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -759,7 +759,7 @@ B (fields appear in the followin= g order): =20 =20 =3Ditem B I [I] [I<--full>] - [I<--source lease|agent>] + [I<--source lease|agent|arp>] =20 Get a list of interfaces of a running domain along with their IP and MAC addresses, or limited output just for one interface if I is @@ -774,8 +774,9 @@ only the interface name and MAC address is displayed fo= r the first name and MAC address with "-" for the others using the same name and MAC address. =20 The I<--source> argument specifies what data source to use for the -addresses, currently one of 'lease' to read DHCP leases, or 'agent' to que= ry -the guest OS via an agent. If unspecified, 'lease' is the default. +addresses, currently 'lease' to read DHCP leases, 'agent' to query +the guest OS via an agent, or 'arp' to get IP from host's arp tables. +If unspecified, 'lease' is the default. =20 =3Ditem B I I =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 23:55:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516810389543982.2024873425717; Wed, 24 Jan 2018 08:13:09 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 7DE5265176; Wed, 24 Jan 2018 16:13:08 +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 C720617B8A; Wed, 24 Jan 2018 16:13:07 +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 709B518033DB; Wed, 24 Jan 2018 16:13:06 +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 w0OGCSZ3027232 for ; Wed, 24 Jan 2018 11:12:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id E808C17F41; Wed, 24 Jan 2018 16:12:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFD75226EB for ; Wed, 24 Jan 2018 16:12:25 +0000 (UTC) Received: from m15-113.126.com (m15-113.126.com [220.181.15.113]) by mx1.redhat.com (Postfix) with ESMTP id 448045FD79 for ; Wed, 24 Jan 2018 16:12:22 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp3 (Coremail) with SMTP id DcmowAAHdX5asGhaJNIABQ--.63591S6; Thu, 25 Jan 2018 00:12:17 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=sjqv6FENGY/+tbCOpN v538/5bUj0iWJeVdVwFyTB9CI=; b=A9kHoEu7R9sYQ7ORIuySRJX7ws2s0xJQhi yUcTzPHaLtyXlbdsPiAyccf5bzd5GgznytCY+wXGRrewltSD5ohDozlrFlGKyDn1 qUufDefmbXmNsYmvUqmuHm9QPVV2SbOkNWc9iRIWr7hwFjqkUyXni1EqLPnIYcb8 MqxFvSofY= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 00:09:46 +0800 Message-Id: <20180124160946.31429-5-chen_han_xiao@126.com> In-Reply-To: <20180124160946.31429-1-chen_han_xiao@126.com> References: <20180124160946.31429-1-chen_han_xiao@126.com> X-CM-TRANSID: DcmowAAHdX5asGhaJNIABQ--.63591S6 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUIhSdDUUUU X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbikgLXrlpD4DXXPAABsP X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 24 Jan 2018 16:12:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 24 Jan 2018 16:12:24 +0000 (UTC) for IP:'220.181.15.113' DOMAIN:'m15-113.126.com' HELO:'m15-113.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.113 m15-113.126.com 220.181.15.113 m15-113.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v2 4/4] news: qemu: use arp table of host to get the IP address of guests 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 24 Jan 2018 16:13:09 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao Signed-off-by: Chen Hanxiao --- docs/news.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index b9e04c632..105917f4d 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -47,6 +47,11 @@ interfaces, NWFilters, and so on). + + + qemu: use arp table of host to get the IP address of guests + +
--=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list