From nobody Sun Apr 28 20:10:21 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; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594633518; cv=none; d=zohomail.com; s=zohoarc; b=S+mQqJuzGrnuJzFUJUj0rJG/1YNrzCJ+8DQDbO1Lh8GSPcc5nUX55+N1crOKAYwVfoe2bPiHZCo29cPFU29YR2v0zE64Y+mUrQ/nBgS3F7F9U9aXTbk6hdtFvvvf0NQ+R4gFeg2omLAZHtP1QQJj2FDF+wdDgn+ZYtMDKzekUNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594633518; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=/VldfppC1m1i+Dw/scxFjNfsqiP1FoH3ELtgrHfdxXs=; b=PdUwwWdfHjp2zPCfPQN+QFsgIE5wfC9+vK4uWBxNKZaIDyuCVezIVbWnOaKiCWs/ZMHR7P9lWUXH7Wnh3vfZDD9VxeVuTGsCSnJ50DAJSb5/rB99/jNYoEZBV9hTHXk/7R6JH+kJ4hwza04ZGPGnpVcTnSLm+9Yz7IzXnc4XGbw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com 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 1594633517864686.6547607527032; Mon, 13 Jul 2020 02:45:17 -0700 (PDT) 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-442-ncG-mFolMCyKi13ERqsYbw-1; Mon, 13 Jul 2020 05:45:14 -0400 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 DD68E8027F4; Mon, 13 Jul 2020 09:45:08 +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 3177E741AE; Mon, 13 Jul 2020 09:45: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 19EE172F50; Mon, 13 Jul 2020 09:45:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06D9j2G2005128 for ; Mon, 13 Jul 2020 05:45:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 95E0D217B436; Mon, 13 Jul 2020 09:45:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D7B92157F25 for ; Mon, 13 Jul 2020 09:45:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26A2A18056AB for ; Mon, 13 Jul 2020 09:45:00 +0000 (UTC) Received: from mail.diateam.net (mail.diateam.net [92.222.227.130]) by relay.mimecast.com with ESMTP id us-mta-358-HvAMnTE8Ptyu3anB1xEMUQ-1; Mon, 13 Jul 2020 05:44:57 -0400 Received: (qmail 6127 invoked from network); 13 Jul 2020 11:44:56 +0200 Received: by simscan 1.4.0 ppid: 6119, pid: 6120, t: 2.4156s scanners: regex: 1.4.0 clamav: 0.101.5/m:59/d:25804 spam: 3.4.2 Received: from lstlambert-656-1-116-247.w80-14.abo.wanadoo.fr (HELO radium.diateam.local) (bastien.orivel@diateam.net@80.14.167.247) by mail.diateam.net (envelope-from bastien.orivel@diateam.net) with SMTP; 13 Jul 2020 11:44:54 +0200 X-MC-Unique: ncG-mFolMCyKi13ERqsYbw-1 X-MC-Unique: HvAMnTE8Ptyu3anB1xEMUQ-1 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.virtualys.com X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, RCVD_IN_SORBS_DUL,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 80.14.0.0/16 From: Bastien Orivel To: libvir-list@redhat.com Subject: [PATCH] Add a check attribute on the mac address element Date: Mon, 13 Jul 2020 11:44:13 +0200 Message-Id: <20200713094413.30201-1-bastien.orivel@diateam.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Bastien Orivel 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is only used in the ESX driver where, when set to "no", it will ignore all the checks libvirt does about the origin of the MAC address (whether or not it's in a VMWare OUI) and forward the original one to the ESX server telling it not to check it either. This allows keeping a deterministic MAC address which can be useful for licensed software which might dislike changes. Signed-off-by: Bastien Orivel --- NEWS.rst | 6 ++++ docs/drvesx.html.in | 5 ++++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c | 18 +++++++++++- src/conf/domain_conf.h | 1 + src/vmx/vmx.c | 9 +++++- .../network-interface-mac-check.xml | 29 +++++++++++++++++++ tests/genericxml2xmltest.c | 2 ++ 8 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/genericxml2xmlindata/network-interface-mac-check.= xml diff --git a/NEWS.rst b/NEWS.rst index 1928220854..ac4de4360d 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -18,6 +18,12 @@ v6.6.0 (unreleased) Libvirt allows configuring ACPI Heterogeneous Memory Attribute Table to hint software running inside the guest on optimization. =20 + * esx: Add a ``check`` attribute for mac addresses. + + This attribute allows (when set to ``no``) ignoring VMWare checks of t= he + MAC addresses that would generate a new one if they were in its OUI + (00:0c:29). + * **Improvements** =20 * esx: Change the NIC limit for recent virtualHW versions diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in index ac7bc645d1..90f368e4f5 100644 --- a/docs/drvesx.html.in +++ b/docs/drvesx.html.in @@ -427,6 +427,11 @@ error: invalid argument in libvirt was built without t= he 'esx' driver
 ethernet0.checkMACAddress =3D "false"
 
+

+ Since 6.6.0, one can force libvirt to= keep the + provided MAC address when it's in the reserved VMware range by add= ing a + check=3D"no" attribute to the <mac/> element. +

=20 =20

Available hardware

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 4b4aa60c66..b926b752fe 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3179,6 +3179,9 @@ + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d14485f18d..aa1417c4d8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11904,6 +11904,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; g_autofree char *macaddr =3D NULL; + g_autofree char *macaddr_check =3D NULL; g_autofree char *type =3D NULL; g_autofree char *network =3D NULL; g_autofree char *portgroup =3D NULL; @@ -11984,6 +11985,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, } if (!macaddr && virXMLNodeNameEqual(cur, "mac")) { macaddr =3D virXMLPropString(cur, "address"); + macaddr_check =3D virXMLPropString(cur, "check"); } else if (!network && def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && virXMLNodeNameEqual(cur, "source")) { @@ -12173,6 +12175,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, def->mac_generated =3D true; } =20 + if (macaddr_check) { + int tmpCheck; + if ((tmpCheck =3D virTristateBoolTypeFromString(macaddr_check)) < = 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid mac address check value: '%s'"), + macaddr_check); + goto error; + } + def->mac_check =3D tmpCheck; + } + if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0)= { @@ -26468,8 +26481,11 @@ virDomainNetDefFormat(virBufferPtr buf, virBufferAddLit(buf, ">\n"); =20 virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "\n", + virBufferAsprintf(buf, "mac, macstr)); + if (def->mac_check !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(buf, " check=3D'%s'", virTristateBoolTypeToStrin= g(def->mac_check)); + virBufferAddLit(buf, "/>\n"); =20 if (publicActual) { /* when there is a virDomainActualNetDef, and we haven't been diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6a737591e2..f2bcd62857 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -972,6 +972,7 @@ struct _virDomainNetDef { virDomainNetType type; virMacAddr mac; bool mac_generated; /* true if mac was *just now* auto-generated by li= bvirt */ + virTristateBool mac_check; int model; /* virDomainNetModelType */ char *modelstr; union { diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index d4d66f6768..82035884a2 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3829,7 +3829,14 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int con= troller, prefix =3D (def->mac.addr[0] << 16) | (def->mac.addr[1] << 8) | def->m= ac.addr[2]; suffix =3D (def->mac.addr[3] << 16) | (def->mac.addr[4] << 8) | def->m= ac.addr[5]; =20 - if (prefix =3D=3D 0x000c29) { + if (def->mac_check =3D=3D VIR_TRISTATE_BOOL_NO) { + virBufferAsprintf(buffer, "ethernet%d.addressType =3D \"static\"\n= ", + controller); + virBufferAsprintf(buffer, "ethernet%d.address =3D \"%s\"\n", + controller, mac_string); + virBufferAsprintf(buffer, "ethernet%d.checkMACAddress =3D \"false\= "\n", + controller); + } else if (prefix =3D=3D 0x000c29) { virBufferAsprintf(buffer, "ethernet%d.addressType =3D \"generated\= "\n", controller); virBufferAsprintf(buffer, "ethernet%d.generatedAddress =3D \"%s\"\= n", diff --git a/tests/genericxml2xmlindata/network-interface-mac-check.xml b/t= ests/genericxml2xmlindata/network-interface-mac-check.xml new file mode 100644 index 0000000000..b21577d7cc --- /dev/null +++ b/tests/genericxml2xmlindata/network-interface-mac-check.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 8b9b0bafb6..102abfdec2 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -183,6 +183,8 @@ mymain(void) DO_TEST("cpu-cache-passthrough"); DO_TEST("cpu-cache-disable"); =20 + DO_TEST("network-interface-mac-check"); + DO_TEST_DIFFERENT("chardev-tcp"); DO_TEST_FULL("chardev-tcp-missing-host", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); --=20 2.20.1