vmx: Add support for dummy network interface

Also map it to an ethernet without connectionType and networkName.

https://bugzilla.redhat.com/show_bug.cgi?id=1988211

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Martin Kletzander 2022-08-04 10:27:40 +02:00
parent bac6b266fb
commit 70768cda97
7 changed files with 77 additions and 3 deletions

View File

@ -2826,7 +2826,7 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def)
STRCASEEQ(connectionType, "bridged") ||
STRCASEEQ(connectionType, "custom")) {
if (virVMXGetConfigString(conf, networkName_name, &networkName,
false) < 0)
true) < 0)
goto cleanup;
}
@ -2837,7 +2837,20 @@ virVMXParseEthernet(virConf *conf, int controller, virDomainNetDef **def)
}
/* Setup virDomainNetDef */
if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
if (connectionType == NULL && networkName == NULL) {
/*
* Having neither a connectionType nor a network name can mean two
* things:
*
* 1) there is no connection of that nic
* 2) the nic is connected to VMWare Distributed Switch
*
* But we do not see any difference between these and hence we report
* the closest thing to at least make virt-v2v and others work when they
* read the domain XML.
*/
(*def)->type = VIR_DOMAIN_NET_TYPE_DUMMY;
} else if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
(*def)->data.bridge.brname = g_steal_pointer(&networkName);
} else if (STRCASEEQ(connectionType, "hostonly")) {
@ -3946,6 +3959,9 @@ virVMXFormatEthernet(virDomainNetDef *def, int controller,
controller);
break;
case VIR_DOMAIN_NET_TYPE_DUMMY:
break;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
@ -3957,7 +3973,6 @@ virVMXFormatEthernet(virDomainNetDef *def, int controller,
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
case VIR_DOMAIN_NET_TYPE_UDP:
case VIR_DOMAIN_NET_TYPE_VDPA:
case VIR_DOMAIN_NET_TYPE_DUMMY:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type '%s'"),
virDomainNetTypeToString(def->type));
return -1;

View File

@ -0,0 +1,7 @@
config.version = "8"
virtualHW.version = "4"
ethernet0.present = "true"
ethernet0.virtualDev = "e1000e"
ethernet0.addressType = "vpx"
ethernet0.generatedAddress = "00:50:56:87:65:43"
displayName = "test"

View File

@ -0,0 +1,23 @@
<domain type='vmware'>
<name>test</name>
<uuid>00000000-0000-0000-0000-000000000000</uuid>
<memory unit='KiB'>32768</memory>
<currentMemory unit='KiB'>32768</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686'>hvm</type>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<interface type='dummy'>
<mac address='00:50:56:87:65:43' type='generated'/>
<model type='e1000e'/>
</interface>
<video>
<model type='vmvga' vram='4096' primary='yes'/>
</video>
</devices>
</domain>

View File

@ -236,6 +236,7 @@ mymain(void)
DO_TEST("ethernet-static");
DO_TEST("ethernet-vpx");
DO_TEST("ethernet-other");
DO_TEST("ethernet-unmanaged-nodev");
DO_TEST("serial-file");
DO_TEST("serial-device");

View File

@ -0,0 +1,13 @@
.encoding = "UTF-8"
config.version = "8"
virtualHW.version = "4"
guestOS = "other"
uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
displayName = "ethernet-vpx"
memsize = "4"
numvcpus = "1"
floppy0.present = "false"
floppy1.present = "false"
ethernet0.present = "true"
ethernet0.addressType = "vpx"
ethernet0.generatedAddress = "00:50:56:87:65:43"

View File

@ -0,0 +1,13 @@
<domain type='vmware'>
<name>ethernet-vpx</name>
<uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
<memory unit='KiB'>4096</memory>
<os>
<type>hvm</type>
</os>
<devices>
<interface type='dummy'>
<mac address='00:50:56:87:65:43'/>
</interface>
</devices>
</domain>

View File

@ -225,6 +225,8 @@ mymain(void)
DO_TEST("ethernet-other", "ethernet-other", 4);
DO_TEST("ethernet-mac-type", "ethernet-mac-type", 4);
DO_TEST("ethernet-unmanaged-nodev", "ethernet-unmanaged-nodev", 4);
DO_TEST("serial-file", "serial-file", 4);
DO_TEST("serial-device", "serial-device", 4);
DO_TEST("serial-pipe", "serial-pipe", 4);