vmx: support outputing the type attribute for MAC addresses

When support for MAC addresses having a type='static|generated'
attribute was added in:

  commit 454e5961ab
  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.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-07-20 16:46:09 +01:00
parent 6d3cb071b4
commit 80975c3c84
28 changed files with 49 additions and 40 deletions

View File

@ -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 "

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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'>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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'/>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>