[libvirt PATCH 0/3] vmx: fix handling of VMX MAC address options

We first had a proposal to add a "check" attribute for MAC addresses https://www.redhat.com/archives/libvir-list/2020-July/msg00617.html For reasons I don't understand this was then replaced by a "type" attribute https://www.redhat.com/archives/libvir-list/2020-July/msg00656.html with the "type" attribute having the side-effect of changing the VMX checkMACAddress config. See the first patch for more detailed description of the flaws. The core problem with the original VMX code before either of these patches was that we have multiple distinct VMX config settings and they were all being overloaded into a single MAC address attribute in the XML. This overloading is inherantly loosing information so cannot be reliably round-trippped. The only way to solve this is to actually have explicit attributes for the config parameters from VMX and stop overloading things. IOW, we needed *both* the "check" and "type" attributes. That is what this series does. It also adds the missing VMX -> XML conversion step so we round-trip everything. There are still some pieces that are not perfect. - libvirt has type=static|generated, but VMX has type=static|generated|vpx. "vpx" is just a synonym for "generated", but using a different MAC addr range. We use the range to do the mapping, and can probablylive with that. - VMX has a a address offset field - I've not found any info on what this is needed for, but we hardcode it to 0 for XML -> VMX config, and ignore it entirely for VMX -> XML config. This means we won't roundtrip this setting. This needs fixing if anyone expects we'll see offset != 0 in the real world. Bastien Orivel (1): Add a check attribute on the mac address element Daniel P. Berrangé (2): vmx: fix logic handling mac address type vmx: support outputing the type attribute for MAC addresses docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 14 ++++ src/conf/domain_conf.h | 1 + src/vmx/vmx.c | 77 ++++++++++++++----- .../network-interface-mac-check.xml | 29 +++++++ tests/genericxml2xmltest.c | 2 + .../vmx2xml-case-insensitive-1.xml | 2 +- .../vmx2xml-case-insensitive-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 4 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml | 20 ++--- .../vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-bridged.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-custom.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml | 2 +- .../vmx2xml-ethernet-generated.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-nat.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-other.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-static.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml | 2 +- .../vmx2xml-fusion-in-the-wild-1.xml | 4 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml | 4 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 2 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.vmx | 7 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.xml | 4 +- 35 files changed, 154 insertions(+), 63 deletions(-) create mode 100644 tests/genericxml2xmlindata/network-interface-mac-check.xml -- 2.24.1

With the current formatter, the XML snippets: <interface type='bridge'> <mac address='00:0c:29:dd:ee:fe' type='static'/> <source bridge='br1'/> </interface> <interface type='bridge'> <mac address='aa:bb:cc:dd:ee:fd' type='generated'/> <source bridge='br2'/> </interface> result in ethernet1.present = "true" ethernet1.networkName = "br1" ethernet1.connectionType = "bridged" ethernet1.addressType = "static" ethernet1.address = "00:0c:29:dd:ee:fe" ethernet1.checkMACAddress = "false" ethernet2.present = "true" ethernet2.networkName = "br2" ethernet2.connectionType = "bridged" ethernet2.addressType = "static" ethernet2.address = "aa:bb:cc:dd:ee:fd" ethernet2.checkMACAddress = "false" which is flawed, as both type='static' and type='generated' in the XML turn into 'static' in the VMX config. The existence of the 'static' attribute is further overriding whether the checkMACAddress config option is set as a side effect. Both these pieces of flawed logic were introduced in commit 454e5961abf40c14f8b6d7ee216229e68fd170bf Author: Bastien Orivel <bastien.orivel@diateam.net> Date: Mon Jul 13 16:28:53 2020 +0200 Add a type attribute on the mac address element which intentionally added the 'checkMACAddress' side effect based on the 'type' attribute. With this change, we're reverting the handling of checkMACAddress to match what existed historically. The 'type' attribute now directly maps to the addressType attribute, so the above config becomes: ethernet1.present = "true" ethernet1.networkName = "br1" ethernet1.connectionType = "bridged" ethernet1.addressType = "static" ethernet1.address = "00:0c:29:dd:ee:fe" ethernet2.present = "true" ethernet2.networkName = "br2" ethernet2.connectionType = "bridged" ethernet2.addressType = "generated" ethernet2.generatedAddress = "aa:bb:cc:dd:ee:fd" ethernet2.generatedAddressOffset = "0" Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/vmx/vmx.c | 55 +++++++++++++------ .../xml2vmxdata/xml2vmx-ethernet-mac-type.vmx | 7 +-- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 97ec84446a..f0a45089cc 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3732,7 +3732,9 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, virBufferPtr buffer, int virtualHW_version) { char mac_string[VIR_MAC_STRING_BUFLEN]; - const bool staticMac = def->mac_type == VIR_DOMAIN_NET_MAC_TYPE_STATIC; + virDomainNetMacType mac_type = VIR_DOMAIN_NET_MAC_TYPE_DEFAULT; + virTristateBool mac_check = VIR_TRISTATE_BOOL_ABSENT; + bool mac_vpx = false; unsigned int prefix, suffix; /* @@ -3830,31 +3832,48 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, prefix = (def->mac.addr[0] << 16) | (def->mac.addr[1] << 8) | def->mac.addr[2]; suffix = (def->mac.addr[3] << 16) | (def->mac.addr[4] << 8) | def->mac.addr[5]; - if (prefix == 0x000c29 && !staticMac) { - virBufferAsprintf(buffer, "ethernet%d.addressType = \"generated\"\n", - controller); - virBufferAsprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n", - controller, mac_string); - virBufferAsprintf(buffer, "ethernet%d.generatedAddressOffset = \"0\"\n", - controller); - } else if (prefix == 0x005056 && suffix <= 0x3fffff && !staticMac) { - virBufferAsprintf(buffer, "ethernet%d.addressType = \"static\"\n", - controller); - virBufferAsprintf(buffer, "ethernet%d.address = \"%s\"\n", - controller, mac_string); - } else if (prefix == 0x005056 && suffix >= 0x800000 && suffix <= 0xbfffff && !staticMac) { - virBufferAsprintf(buffer, "ethernet%d.addressType = \"vpx\"\n", - controller); + /* + * Historically we've not stored all the MAC related properties + * explicitly in the XML, so we must figure out some defaults + * based on the address ranges. + */ + if (prefix == 0x000c29) { + mac_type = VIR_DOMAIN_NET_MAC_TYPE_GENERATED; + } else if (prefix == 0x005056 && suffix <= 0x3fffff) { + mac_type = VIR_DOMAIN_NET_MAC_TYPE_STATIC; + } else if (prefix == 0x005056 && suffix >= 0x800000 && suffix <= 0xbfffff) { + mac_type = VIR_DOMAIN_NET_MAC_TYPE_GENERATED; + mac_vpx = true; + } else { + mac_type = VIR_DOMAIN_NET_MAC_TYPE_STATIC; + mac_check = VIR_TRISTATE_BOOL_NO; + } + + /* If explicit MAC type is set, ignore the above defaults */ + if (def->mac_type != VIR_DOMAIN_NET_MAC_TYPE_DEFAULT) { + mac_type = def->mac_type; + if (mac_type == VIR_DOMAIN_NET_MAC_TYPE_GENERATED) + mac_check = VIR_TRISTATE_BOOL_ABSENT; + } + + if (mac_type == VIR_DOMAIN_NET_MAC_TYPE_GENERATED) { + virBufferAsprintf(buffer, "ethernet%d.addressType = \"%s\"\n", + controller, mac_vpx ? "vpx" : "generated"); virBufferAsprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n", controller, mac_string); + if (!mac_vpx) + virBufferAsprintf(buffer, "ethernet%d.generatedAddressOffset = \"0\"\n", + controller); } else { virBufferAsprintf(buffer, "ethernet%d.addressType = \"static\"\n", controller); virBufferAsprintf(buffer, "ethernet%d.address = \"%s\"\n", controller, mac_string); - virBufferAsprintf(buffer, "ethernet%d.checkMACAddress = \"false\"\n", - controller); } + if (mac_check != VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(buffer, "ethernet%d.checkMACAddress = \"%s\"\n", + controller, + mac_check == VIR_TRISTATE_BOOL_YES ? "true" : "false"); return 0; } diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx index 212b3f192c..061aed3010 100644 --- a/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx +++ b/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx @@ -20,10 +20,9 @@ ethernet1.networkName = "br1" ethernet1.connectionType = "bridged" ethernet1.addressType = "static" ethernet1.address = "00:0c:29:dd:ee:fe" -ethernet1.checkMACAddress = "false" ethernet2.present = "true" ethernet2.networkName = "br2" ethernet2.connectionType = "bridged" -ethernet2.addressType = "static" -ethernet2.address = "aa:bb:cc:dd:ee:fd" -ethernet2.checkMACAddress = "false" +ethernet2.addressType = "generated" +ethernet2.generatedAddress = "aa:bb:cc:dd:ee:fd" +ethernet2.generatedAddressOffset = "0" -- 2.24.1

When support for MAC addresses having a type='static|generated' attribute was added in: commit 454e5961abf40c14f8b6d7ee216229e68fd170bf Author: Bastien Orivel <bastien.orivel@diateam.net> Date: Mon Jul 13 16:28:53 2020 +0200 Add a type attribute on the mac address element the VMX -> XML parser was not updated. As a result while we accept the 'type' attribute on input, we never show it again on 'output', so we loose information during the roundtrip. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/vmx/vmx.c | 11 +++++++++- .../vmx2xml-case-insensitive-1.xml | 2 +- .../vmx2xml-case-insensitive-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 4 ++-- .../vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml | 20 +++++++++---------- .../vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-bridged.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-custom.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml | 2 +- .../vmx2xml-ethernet-generated.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-nat.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-other.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-static.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml | 2 +- .../vmx2xml-fusion-in-the-wild-1.xml | 4 ++-- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml | 4 ++-- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 2 +- 28 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index f0a45089cc..72f6a7d8dd 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2535,6 +2535,9 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) char generatedAddress_name[48] = ""; char *generatedAddress = NULL; + char checkMACAddress_name[48] = ""; + char *checkMACAddress = NULL; + char address_name[48] = ""; char *address = NULL; @@ -2564,6 +2567,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) VMX_BUILD_NAME(connectionType); VMX_BUILD_NAME(addressType); VMX_BUILD_NAME(generatedAddress); + VMX_BUILD_NAME(checkMACAddress); VMX_BUILD_NAME(address); VMX_BUILD_NAME(virtualDev); VMX_BUILD_NAME(features); @@ -2598,7 +2602,9 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) true) < 0 || virVMXGetConfigString(conf, generatedAddress_name, &generatedAddress, true) < 0 || - virVMXGetConfigString(conf, address_name, &address, true) < 0) { + virVMXGetConfigString(conf, address_name, &address, true) < 0 || + virVMXGetConfigString(conf, checkMACAddress_name, &checkMACAddress, + true) < 0) { goto cleanup; } @@ -2613,6 +2619,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) goto cleanup; } } + if (addressType != NULL) + (*def)->mac_type = VIR_DOMAIN_NET_MAC_TYPE_GENERATED; } else if (STRCASEEQ(addressType, "static")) { if (address != NULL) { if (virMacAddrParse(address, &(*def)->mac) < 0) { @@ -2622,6 +2630,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) goto cleanup; } } + (*def)->mac_type = VIR_DOMAIN_NET_MAC_TYPE_STATIC; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry '%s' to be 'generated' or 'static' or " diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml index fd38cfd67f..7cb6413941 100644 --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml @@ -22,7 +22,7 @@ </disk> <controller type='scsi' index='0' model='lsilogic'/> <interface type='bridge'> - <mac address='00:50:56:91:48:c7'/> + <mac address='00:50:56:91:48:c7' type='generated'/> <source bridge='VM NETWORK'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml index eb81691456..188c3f3cd5 100644 --- a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml +++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml @@ -22,7 +22,7 @@ </disk> <controller type='scsi' index='0' model='lsilogic'/> <interface type='bridge'> - <mac address='00:50:56:91:48:c7'/> + <mac address='00:50:56:91:48:c7' type='generated'/> <source bridge='vm network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml index 906cfe0648..c15275ccb9 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml @@ -22,7 +22,7 @@ </disk> <controller type='scsi' index='0' model='lsilogic'/> <interface type='bridge'> - <mac address='00:50:56:91:48:c7'/> + <mac address='00:50:56:91:48:c7' type='generated'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml index 2f85f82ad0..b079808363 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml @@ -48,7 +48,7 @@ <controller type='fdc' index='0'/> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:3c:98:3e'/> + <mac address='00:0c:29:3c:98:3e' type='generated'/> <source bridge='VM Network'/> <model type='vlance'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml index 8f219165f1..d05318c7d8 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml @@ -31,7 +31,7 @@ <controller type='fdc' index='0'/> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:f5:c3:0c'/> + <mac address='00:0c:29:f5:c3:0c' type='generated'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml index d5b3e841b7..a8a2ac6f97 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml @@ -22,11 +22,11 @@ </disk> <controller type='scsi' index='0' model='lsilogic'/> <interface type='bridge'> - <mac address='00:50:56:91:66:d4'/> + <mac address='00:50:56:91:66:d4' type='generated'/> <source bridge='VM Network'/> </interface> <interface type='bridge'> - <mac address='00:50:56:91:0c:51'/> + <mac address='00:50:56:91:0c:51' type='generated'/> <source bridge='VM Switch 2'/> </interface> <serial type='file'> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml index 296d48171c..82643e9ffe 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml @@ -32,7 +32,7 @@ <controller type='scsi' index='0' model='lsilogic'/> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:50:56:be:00:15'/> + <mac address='00:50:56:be:00:15' type='generated'/> <source bridge='VM-LAN'/> <model type='e1000'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml index 19bace7cfb..913bfedf30 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml @@ -25,7 +25,7 @@ <controller type='scsi' index='0' model='vmpvscsi'/> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:2c:3a:fc'/> + <mac address='00:0c:29:2c:3a:fc' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml index 832c1ac864..91913a2918 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml @@ -24,7 +24,7 @@ </disk> <controller type='scsi' index='0' model='vmpvscsi'/> <interface type='bridge'> - <mac address='00:50:56:9f:08:51'/> + <mac address='00:50:56:9f:08:51' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml index 2011bfb3b9..8276457bb3 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml @@ -36,52 +36,52 @@ </disk> <controller type='scsi' index='0' model='vmpvscsi'/> <interface type='bridge'> - <mac address='00:1a:4a:16:01:55'/> + <mac address='00:1a:4a:16:01:55' type='static'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:85'/> + <mac address='00:1a:4a:16:21:85' type='generated'/> <source bridge='VM Network'/> <model type='e1000'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:82'/> + <mac address='00:1a:4a:16:21:82' type='generated'/> <source bridge='VM Network'/> <model type='e1000e'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:69'/> + <mac address='00:1a:4a:16:21:69' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:80'/> + <mac address='00:1a:4a:16:21:80' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:a3'/> + <mac address='00:1a:4a:16:21:a3' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:a8'/> + <mac address='00:1a:4a:16:21:a8' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:a9'/> + <mac address='00:1a:4a:16:21:a9' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:78'/> + <mac address='00:1a:4a:16:21:78' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> <interface type='bridge'> - <mac address='00:1a:4a:16:21:81'/> + <mac address='00:1a:4a:16:21:81' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml index fa428c1986..66eca400dd 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml @@ -26,7 +26,7 @@ </disk> <controller type='scsi' index='0' model='lsisas1068'/> <interface type='bridge'> - <mac address='00:50:56:80:b3:81'/> + <mac address='00:50:56:80:b3:81' type='generated'/> <source bridge='VM Network'/> <model type='vmxnet3'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-bridged.xml b/tests/vmx2xmldata/vmx2xml-ethernet-bridged.xml index 0fe29ccd97..fac5cd7bd5 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-bridged.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-bridged.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:50:56:11:22:33'/> + <mac address='00:50:56:11:22:33' type='static'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-custom.xml b/tests/vmx2xmldata/vmx2xml-ethernet-custom.xml index e10ecd7685..ce63c24127 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-custom.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-custom.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:50:56:11:22:33'/> + <mac address='00:50:56:11:22:33' type='static'/> <source bridge='VM Network'/> <target dev='vmnet7'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml b/tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml index d497a3836f..534d35e352 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:50:56:11:22:33'/> + <mac address='00:50:56:11:22:33' type='static'/> <source bridge='VM Network'/> <model type='e1000'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml index 23b54c81c9..3fbc013f21 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:0c:29:11:22:33'/> + <mac address='00:0c:29:11:22:33' type='generated'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml b/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml index 562ddfc0ca..af721e3059 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-nat.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='user'> - <mac address='00:50:56:11:22:33'/> + <mac address='00:50:56:11:22:33' type='static'/> </interface> <video> <model type='vmvga' vram='4096' primary='yes'/> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.xml b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml index e7abad0724..b90dfe5d9b 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-other.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:12:34:56:78:90'/> + <mac address='00:12:34:56:78:90' type='static'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-static.xml b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml index 0fe29ccd97..fac5cd7bd5 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-static.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:50:56:11:22:33'/> + <mac address='00:50:56:11:22:33' type='static'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml b/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml index bbe7dfd378..54c9283989 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:50:56:11:22:33'/> + <mac address='00:50:56:11:22:33' type='static'/> <source bridge='VM Network'/> <model type='vmxnet2'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml index 5dbdb5227e..c75d52f5b2 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:50:56:87:65:43'/> + <mac address='00:50:56:87:65:43' type='generated'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml index cfc0d95960..2dd46eb2b1 100644 --- a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml @@ -25,11 +25,11 @@ <controller type='scsi' index='0' model='buslogic'/> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:3b:64:ea'/> + <mac address='00:0c:29:3b:64:ea' type='generated'/> <source bridge=''/> </interface> <interface type='bridge'> - <mac address='00:0c:29:3b:64:f4'/> + <mac address='00:0c:29:3b:64:f4' type='generated'/> <source bridge=''/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml index e507cfc2f4..62ec191c82 100644 --- a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml @@ -19,7 +19,7 @@ </disk> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:d6:2b:d3'/> + <mac address='00:0c:29:d6:2b:d3' type='generated'/> <source bridge='net1'/> <target dev='/dev/vmnet1'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml index 39e89bb204..906e4657ca 100644 --- a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml +++ b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml @@ -19,7 +19,7 @@ </disk> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:d6:cb:a4'/> + <mac address='00:0c:29:d6:cb:a4' type='generated'/> <source bridge='net1'/> <target dev='/dev/vmnet1'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml index 51101ded23..61812851e1 100644 --- a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml +++ b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml @@ -19,12 +19,12 @@ </disk> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:c4:be:5a'/> + <mac address='00:0c:29:c4:be:5a' type='generated'/> <source bridge='net1'/> <target dev='/dev/vmnet1'/> </interface> <interface type='bridge'> - <mac address='00:0c:29:c4:be:64'/> + <mac address='00:0c:29:c4:be:64' type='generated'/> <source bridge='net2'/> <target dev='/dev/vmnet2'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml index 849367a52d..a65a7d137f 100644 --- a/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml +++ b/tests/vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml @@ -19,7 +19,7 @@ </disk> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:0c:29:c5:e3:5d'/> + <mac address='00:0c:29:c5:e3:5d' type='generated'/> <source bridge='net2'/> <target dev='/dev/vmnet2'/> </interface> diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml index 9ea6bd754d..9901033bb9 100644 --- a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml @@ -25,7 +25,7 @@ <controller type='scsi' index='0' model='lsilogic'/> <controller type='ide' index='0'/> <interface type='user'> - <mac address='00:50:56:2f:d3:46'/> + <mac address='00:50:56:2f:d3:46' type='static'/> <model type='e1000'/> </interface> <video> diff --git a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml index ce8f802f88..628dfbaff0 100644 --- a/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml +++ b/tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml @@ -25,7 +25,7 @@ <controller type='scsi' index='0' model='lsilogic'/> <controller type='ide' index='0'/> <interface type='bridge'> - <mac address='00:50:56:2f:d3:46'/> + <mac address='00:50:56:2f:d3:46' type='static'/> <source bridge=''/> <model type='e1000'/> </interface> -- 2.24.1

From: Bastien Orivel <bastien.orivel@diateam.net> 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 <bastien.orivel@diateam.net> VMX conversion parts rewritten to apply on top of previously merged support for type='generated|static' Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- docs/schemas/domaincommon.rng | 5 ++++ src/conf/domain_conf.c | 14 +++++++++ src/conf/domain_conf.h | 1 + src/vmx/vmx.c | 11 +++++++ .../network-interface-mac-check.xml | 29 +++++++++++++++++++ tests/genericxml2xmltest.c | 2 ++ tests/vmx2xmldata/vmx2xml-ethernet-other.xml | 2 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.vmx | 2 ++ .../xml2vmxdata/xml2vmx-ethernet-mac-type.xml | 4 +-- 9 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 tests/genericxml2xmlindata/network-interface-mac-check.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a810f569c6..8cbbd7e6e9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3187,6 +3187,11 @@ </choice> </attribute> </optional> + <optional> + <attribute name="check"> + <ref name="virYesNo"/> + </attribute> + </optional> <empty/> </element> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7ecd2818b9..6c05244c6e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11928,6 +11928,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, int rv, val; g_autofree char *macaddr = NULL; g_autofree char *macaddr_type = NULL; + g_autofree char *macaddr_check = NULL; g_autofree char *type = NULL; g_autofree char *network = NULL; g_autofree char *portgroup = NULL; @@ -12009,6 +12010,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, if (!macaddr && virXMLNodeNameEqual(cur, "mac")) { macaddr = virXMLPropString(cur, "address"); macaddr_type = virXMLPropString(cur, "type"); + macaddr_check = virXMLPropString(cur, "check"); } else if (!network && def->type == VIR_DOMAIN_NET_TYPE_NETWORK && virXMLNodeNameEqual(cur, "source")) { @@ -12209,6 +12211,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, } def->mac_type = tmp; } + if (macaddr_check) { + int tmpCheck; + if ((tmpCheck = virTristateBoolTypeFromString(macaddr_check)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid mac address check value: '%s'"), + macaddr_check); + goto error; + } + def->mac_check = tmpCheck; + } if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT @@ -26561,6 +26573,8 @@ virDomainNetDefFormat(virBufferPtr buf, virMacAddrFormat(&def->mac, macstr)); if (def->mac_type) virBufferAsprintf(buf, " type='%s'", virDomainNetMacTypeTypeToString(def->mac_type)); + if (def->mac_check != VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(buf, " check='%s'", virTristateBoolTypeToString(def->mac_check)); virBufferAddLit(buf, "/>\n"); if (publicActual) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 241149af24..6e9da298b4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -982,6 +982,7 @@ struct _virDomainNetDef { virMacAddr mac; bool mac_generated; /* true if mac was *just now* auto-generated by libvirt */ virDomainNetMacType mac_type; + virTristateBool mac_check; int model; /* virDomainNetModelType */ char *modelstr; union { diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 72f6a7d8dd..a123a8807c 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2638,6 +2638,14 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) goto cleanup; } + if (checkMACAddress) { + if (STREQ(checkMACAddress, "true")) { + (*def)->mac_check = VIR_TRISTATE_BOOL_YES; + } else { + (*def)->mac_check = VIR_TRISTATE_BOOL_NO; + } + } + /* vmx:virtualDev, vmx:features -> def:model */ if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev, true) < 0 || virVMXGetConfigLong(conf, features_name, &features, 0, true) < 0) { @@ -3865,6 +3873,9 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, mac_check = VIR_TRISTATE_BOOL_ABSENT; } + if (def->mac_check != VIR_TRISTATE_BOOL_ABSENT) + mac_check = def->mac_check; + if (mac_type == VIR_DOMAIN_NET_MAC_TYPE_GENERATED) { virBufferAsprintf(buffer, "ethernet%d.addressType = \"%s\"\n", controller, mac_vpx ? "vpx" : "generated"); diff --git a/tests/genericxml2xmlindata/network-interface-mac-check.xml b/tests/genericxml2xmlindata/network-interface-mac-check.xml new file mode 100644 index 0000000000..a84452fbaf --- /dev/null +++ b/tests/genericxml2xmlindata/network-interface-mac-check.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <interface type='bridge'> + <mac address='aa:bb:cc:dd:ee:ff'/> + <source bridge='br0'/> + </interface> + <interface type='bridge'> + <mac address='aa:bb:cc:dd:ee:fe' type='static' check='yes'/> + <source bridge='br1'/> + </interface> + <interface type='bridge'> + <mac address='aa:bb:cc:dd:ee:fd' type='generated' check='no'/> + <source bridge='br2'/> + </interface> + </devices> +</domain> 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"); + 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); diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.xml b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml index b90dfe5d9b..ef324405d7 100644 --- a/tests/vmx2xmldata/vmx2xml-ethernet-other.xml +++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <interface type='bridge'> - <mac address='00:12:34:56:78:90' type='static'/> + <mac address='00:12:34:56:78:90' type='static' check='no'/> <source bridge='VM Network'/> </interface> <video> diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx index 061aed3010..8d7a067188 100644 --- a/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx +++ b/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.vmx @@ -20,9 +20,11 @@ ethernet1.networkName = "br1" ethernet1.connectionType = "bridged" ethernet1.addressType = "static" ethernet1.address = "00:0c:29:dd:ee:fe" +ethernet1.checkMACAddress = "true" ethernet2.present = "true" ethernet2.networkName = "br2" ethernet2.connectionType = "bridged" ethernet2.addressType = "generated" ethernet2.generatedAddress = "aa:bb:cc:dd:ee:fd" ethernet2.generatedAddressOffset = "0" +ethernet2.checkMACAddress = "false" diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.xml b/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.xml index ee85a1a56a..850fc4d80a 100644 --- a/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.xml +++ b/tests/xml2vmxdata/xml2vmx-ethernet-mac-type.xml @@ -18,11 +18,11 @@ <source bridge='br0'/> </interface> <interface type='bridge'> - <mac address='00:0c:29:dd:ee:fe' type='static'/> + <mac address='00:0c:29:dd:ee:fe' type='static' check='yes'/> <source bridge='br1'/> </interface> <interface type='bridge'> - <mac address='aa:bb:cc:dd:ee:fd' type='generated'/> + <mac address='aa:bb:cc:dd:ee:fd' type='generated' check='no'/> <source bridge='br2'/> </interface> </devices> -- 2.24.1

ping, I think we need to get this series merged before the release freeze, or revert the original broken vmx canges. On Mon, Jul 20, 2020 at 05:32:14PM +0100, Daniel P. Berrangé wrote:
We first had a proposal to add a "check" attribute for MAC addresses
https://www.redhat.com/archives/libvir-list/2020-July/msg00617.html
For reasons I don't understand this was then replaced by a "type" attribute
https://www.redhat.com/archives/libvir-list/2020-July/msg00656.html
with the "type" attribute having the side-effect of changing the VMX checkMACAddress config. See the first patch for more detailed description of the flaws.
The core problem with the original VMX code before either of these patches was that we have multiple distinct VMX config settings and they were all being overloaded into a single MAC address attribute in the XML. This overloading is inherantly loosing information so cannot be reliably round-trippped.
The only way to solve this is to actually have explicit attributes for the config parameters from VMX and stop overloading things.
IOW, we needed *both* the "check" and "type" attributes.
That is what this series does. It also adds the missing VMX -> XML conversion step so we round-trip everything.
There are still some pieces that are not perfect.
- libvirt has type=static|generated, but VMX has type=static|generated|vpx. "vpx" is just a synonym for "generated", but using a different MAC addr range. We use the range to do the mapping, and can probablylive with that.
- VMX has a a address offset field - I've not found any info on what this is needed for, but we hardcode it to 0 for XML -> VMX config, and ignore it entirely for VMX -> XML config. This means we won't roundtrip this setting. This needs fixing if anyone expects we'll see offset != 0 in the real world.
Bastien Orivel (1): Add a check attribute on the mac address element
Daniel P. Berrangé (2): vmx: fix logic handling mac address type vmx: support outputing the type attribute for MAC addresses
docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 14 ++++ src/conf/domain_conf.h | 1 + src/vmx/vmx.c | 77 ++++++++++++++----- .../network-interface-mac-check.xml | 29 +++++++ tests/genericxml2xmltest.c | 2 + .../vmx2xml-case-insensitive-1.xml | 2 +- .../vmx2xml-case-insensitive-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 4 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml | 20 ++--- .../vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-bridged.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-custom.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml | 2 +- .../vmx2xml-ethernet-generated.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-nat.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-other.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-static.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml | 2 +- .../vmx2xml-fusion-in-the-wild-1.xml | 4 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml | 4 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 2 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.vmx | 7 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.xml | 4 +- 35 files changed, 154 insertions(+), 63 deletions(-) create mode 100644 tests/genericxml2xmlindata/network-interface-mac-check.xml
-- 2.24.1
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 7/20/20 6:32 PM, Daniel P. Berrangé wrote:
We first had a proposal to add a "check" attribute for MAC addresses
https://www.redhat.com/archives/libvir-list/2020-July/msg00617.html
For reasons I don't understand this was then replaced by a "type" attribute
https://www.redhat.com/archives/libvir-list/2020-July/msg00656.html
with the "type" attribute having the side-effect of changing the VMX checkMACAddress config. See the first patch for more detailed description of the flaws.
The core problem with the original VMX code before either of these patches was that we have multiple distinct VMX config settings and they were all being overloaded into a single MAC address attribute in the XML. This overloading is inherantly loosing information so cannot be reliably round-trippped.
The only way to solve this is to actually have explicit attributes for the config parameters from VMX and stop overloading things.
IOW, we needed *both* the "check" and "type" attributes.
That is what this series does. It also adds the missing VMX -> XML conversion step so we round-trip everything.
There are still some pieces that are not perfect.
- libvirt has type=static|generated, but VMX has type=static|generated|vpx. "vpx" is just a synonym for "generated", but using a different MAC addr range. We use the range to do the mapping, and can probablylive with that.
- VMX has a a address offset field - I've not found any info on what this is needed for, but we hardcode it to 0 for XML -> VMX config, and ignore it entirely for VMX -> XML config. This means we won't roundtrip this setting. This needs fixing if anyone expects we'll see offset != 0 in the real world.
Bastien Orivel (1): Add a check attribute on the mac address element
Daniel P. Berrangé (2): vmx: fix logic handling mac address type vmx: support outputing the type attribute for MAC addresses
docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 14 ++++ src/conf/domain_conf.h | 1 + src/vmx/vmx.c | 77 ++++++++++++++----- .../network-interface-mac-check.xml | 29 +++++++ tests/genericxml2xmltest.c | 2 + .../vmx2xml-case-insensitive-1.xml | 2 +- .../vmx2xml-case-insensitive-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 4 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-7.xml | 2 +- .../vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml | 20 ++--- .../vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-bridged.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-custom.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-e1000.xml | 2 +- .../vmx2xml-ethernet-generated.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-nat.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-other.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-static.xml | 2 +- .../vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml | 2 +- tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml | 2 +- .../vmx2xml-fusion-in-the-wild-1.xml | 4 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-2.xml | 2 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-3.xml | 4 +- .../vmx2xmldata/vmx2xml-gsx-in-the-wild-4.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 2 +- .../vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 2 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.vmx | 7 +- .../xml2vmxdata/xml2vmx-ethernet-mac-type.xml | 4 +- 35 files changed, 154 insertions(+), 63 deletions(-) create mode 100644 tests/genericxml2xmlindata/network-interface-mac-check.xml
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Daniel P. Berrangé
-
Michal Privoznik