[libvirt] [PATCH] vmx: add support for hostonly interfaces

Javier Uruen Val posted 1 patch 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180711152645.31468-1-javi.uruen@gmail.com
Test syntax-check passed
src/vmx/vmx.c                                 |  19 ++-
.../vmx2xml-fusion-in-the-wild-2.vmx          | 115 ++++++++++++++++++
.../vmx2xml-fusion-in-the-wild-2.xml          |  34 ++++++
tests/vmx2xmltest.c                           |   1 +
.../xml2vmx-fusion-in-the-wild-2.vmx          |  36 ++++++
.../xml2vmx-fusion-in-the-wild-2.xml          |  31 +++++
tests/xml2vmxtest.c                           |   1 +
7 files changed, 231 insertions(+), 6 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.xml
create mode 100755 tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.xml

[libvirt] [PATCH] vmx: add support for hostonly interfaces

Posted by Javier Uruen Val 1 week ago
Vmware fusion allows you to configure a network interface
as "hostonly". This uses a private network that is not
normally accessible from the physical networks on the
Mac/PC.

We map "hostonly" in the vmx configuration to "network"
in the domain configuration. Some comments in vmx.c
seem to point towards using this mapping and not other
such as "internal" or something else.

Added tests and configuration files from actual vmx
machines configured with "hostonly".

Signed-off-by: Javier Uruen Val <javi.uruen@gmail.com>
---
 src/vmx/vmx.c                                 |  19 ++-
 .../vmx2xml-fusion-in-the-wild-2.vmx          | 115 ++++++++++++++++++
 .../vmx2xml-fusion-in-the-wild-2.xml          |  34 ++++++
 tests/vmx2xmltest.c                           |   1 +
 .../xml2vmx-fusion-in-the-wild-2.vmx          |  36 ++++++
 .../xml2vmx-fusion-in-the-wild-2.xml          |  31 +++++
 tests/xml2vmxtest.c                           |   1 +
 7 files changed, 231 insertions(+), 6 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.xml
 create mode 100755 tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.xml

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index fe24b060d7..c812a8fb33 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2650,6 +2650,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
     /* vmx:networkName -> def:data.bridge.brname */
     if (connectionType == NULL ||
         STRCASEEQ(connectionType, "bridged") ||
+        STRCASEEQ(connectionType, "hostonly") ||
         STRCASEEQ(connectionType, "custom")) {
         if (virVMXGetConfigString(conf, networkName_name, &networkName,
                                   true) < 0)
@@ -2674,11 +2675,12 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
         virtualDev = NULL;
         networkName = NULL;
     } else if (STRCASEEQ(connectionType, "hostonly")) {
-        /* FIXME */
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("No yet handled value '%s' for VMX entry '%s'"),
-                       connectionType, connectionType_name);
-        goto cleanup;
+        (*def)->type = VIR_DOMAIN_NET_TYPE_NETWORK;
+        (*def)->model = virtualDev;
+        (*def)->data.network.name = networkName;
+
+        virtualDev = NULL;
+        networkName = NULL;
     } else if (STRCASEEQ(connectionType, "nat")) {
         (*def)->type = VIR_DOMAIN_NET_TYPE_USER;
         (*def)->model = virtualDev;
@@ -3783,6 +3785,12 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
       case VIR_DOMAIN_NET_TYPE_USER:
         virBufferAsprintf(buffer, "ethernet%d.connectionType = \"nat\"\n",
                           controller);
+
+        break;
+
+      case VIR_DOMAIN_NET_TYPE_NETWORK:
+        virBufferAsprintf(buffer, "ethernet%d.connectionType = \"hostonly\"\n",
+                              controller);
         break;
 
       case VIR_DOMAIN_NET_TYPE_ETHERNET:
@@ -3790,7 +3798,6 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
       case VIR_DOMAIN_NET_TYPE_SERVER:
       case VIR_DOMAIN_NET_TYPE_CLIENT:
       case VIR_DOMAIN_NET_TYPE_MCAST:
-      case VIR_DOMAIN_NET_TYPE_NETWORK:
       case VIR_DOMAIN_NET_TYPE_INTERNAL:
       case VIR_DOMAIN_NET_TYPE_DIRECT:
       case VIR_DOMAIN_NET_TYPE_HOSTDEV:
diff --git a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.vmx b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.vmx
new file mode 100644
index 0000000000..c871cca540
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.vmx
@@ -0,0 +1,115 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "12"
+vcpu.hotadd = "TRUE"
+scsi0.present = "TRUE"
+scsi0.virtualDev = "lsilogic"
+sata0.present = "TRUE"
+memsize = "4996"
+mem.hotadd = "TRUE"
+scsi0:0.present = "TRUE"
+scsi0:0.fileName = "Virtual Disk.vmdk"
+sata0:1.present = "TRUE"
+sata0:1.autodetect = "TRUE"
+sata0:1.deviceType = "cdrom-image"
+sata0:1.startConnected = "FALSE"
+ethernet0.present = "TRUE"
+ethernet0.connectionType = "hostonly"
+ethernet0.virtualDev = "e1000"
+ethernet0.wakeOnPcktRcv = "FALSE"
+ethernet0.addressType = "generated"
+ethernet0.linkStatePropagation.enable = "FALSE"
+usb.present = "TRUE"
+ehci.present = "TRUE"
+ehci.pciSlotNumber = "35"
+sound.present = "TRUE"
+sound.fileName = "-1"
+sound.autodetect = "TRUE"
+mks.enable3d = "TRUE"
+svga.graphicsMemoryKB = "786432"
+pciBridge0.present = "TRUE"
+pciBridge4.present = "TRUE"
+pciBridge4.virtualDev = "pcieRootPort"
+pciBridge4.functions = "8"
+pciBridge5.present = "TRUE"
+pciBridge5.virtualDev = "pcieRootPort"
+pciBridge5.functions = "8"
+pciBridge6.present = "TRUE"
+pciBridge6.virtualDev = "pcieRootPort"
+pciBridge6.functions = "8"
+pciBridge7.present = "TRUE"
+pciBridge7.virtualDev = "pcieRootPort"
+pciBridge7.functions = "8"
+vmci0.present = "TRUE"
+hpet0.present = "TRUE"
+usb.vbluetooth.startConnected = "TRUE"
+tools.syncTime = "TRUE"
+displayName = "Ubuntu16.04"
+guestOS = "ubuntu-64"
+nvram = "Ubuntu16.04.nvram"
+virtualHW.productCompatibility = "hosted"
+tools.upgrade.policy = "upgradeAtPowerCycle"
+powerType.powerOff = "soft"
+powerType.powerOn = "soft"
+powerType.suspend = "soft"
+powerType.reset = "soft"
+extendedConfigFile = "Ubuntu16.04.vmxf"
+uuid.bios = "56 4d 97 36 09 cb ba 6f-20 57 e7 01 50 72 7f 3f"
+uuid.location = "56 4d 97 36 09 cb ba 6f-20 57 e7 01 50 72 7f 3f"
+migrate.hostlog = "./Ubuntu16.04-7a77148b.hlog"
+scsi0:0.redo = ""
+pciBridge0.pciSlotNumber = "17"
+pciBridge4.pciSlotNumber = "21"
+pciBridge5.pciSlotNumber = "22"
+pciBridge6.pciSlotNumber = "23"
+pciBridge7.pciSlotNumber = "24"
+scsi0.pciSlotNumber = "16"
+usb.pciSlotNumber = "32"
+ethernet0.pciSlotNumber = "33"
+sound.pciSlotNumber = "34"
+vmci0.pciSlotNumber = "36"
+sata0.pciSlotNumber = "37"
+ethernet0.generatedAddress = "00:0C:29:72:7F:3F"
+ethernet0.generatedAddressOffset = "0"
+vmci0.id = "1349680959"
+monitor.phys_bits_used = "42"
+vmotion.checkpointFBSize = "4194304"
+vmotion.checkpointSVGAPrimarySize = "67108864"
+cleanShutdown = "FALSE"
+softPowerOff = "FALSE"
+usb:1.speed = "2"
+usb:1.present = "TRUE"
+usb:1.deviceType = "hub"
+usb:1.port = "1"
+usb:1.parent = "-1"
+checkpoint.vmState = ""
+sata0:1.fileName = "/Users/johndoe/Downloads/ubuntu-16.04.3-desktop-amd64.iso"
+gui.lastPoweredViewMode = "windowed"
+svga.guestBackedPrimaryAware = "TRUE"
+gui.viewModeAtPowerOn = "windowed"
+tools.remindInstall = "FALSE"
+toolsInstallManager.updateCounter = "2"
+toolsInstallManager.lastInstallError = "0"
+keyboardAndMouseProfile = "52506018-92dd-7b40-6bc7-085ea95583f4"
+isolation.tools.hgfs.disable = "false"
+hgfs.mapRootShare = "true"
+hgfs.linkRootShare = "true"
+sharedFolder0.present = "true"
+sharedFolder0.enabled = "TRUE"
+sharedFolder0.readAccess = "true"
+sharedFolder0.writeAccess = "true"
+sharedFolder0.hostPath = "/Users/johndoe/dev/vmware-shared"
+sharedFolder0.guestName = "vmware-shared"
+sharedFolder0.expiration = "never"
+sharedFolder.maxNum = "1"
+gui.exitOnCLIHLT = "TRUE"
+serial0.present = "FALSE"
+floppy0.present = "FALSE"
+usb:0.present = "TRUE"
+usb:0.deviceType = "hid"
+usb:0.port = "0"
+usb:0.parent = "-1"
+ehci:0.present = "TRUE"
+ehci:0.deviceType = "video"
+ehci:0.port = "0"
+ehci:0.parent = "-1"
diff --git a/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.xml b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.xml
new file mode 100644
index 0000000000..2e0bf504f0
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-2.xml
@@ -0,0 +1,34 @@
+<domain type='vmware'>
+  <name>Ubuntu16.04</name>
+  <uuid>564d9736-09cb-ba6f-2057-e70150727f3f</uuid>
+  <memory unit='KiB'>5115904</memory>
+  <currentMemory unit='KiB'>5115904</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <source file='[datastore] directory/Virtual Disk.vmdk'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0' model='lsilogic'/>
+    <filesystem type='mount' accessmode='passthrough'>
+      <source dir='/Users/johndoe/dev/vmware-shared'/>
+      <target dir='vmware-shared'/>
+    </filesystem>
+    <interface type='network'>
+      <mac address='00:0c:29:72:7f:3f'/>
+      <source network=''/>
+      <model type='e1000'/>
+    </interface>
+    <video>
+      <model type='vmvga' vram='4096' primary='yes'/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 7289dc91e3..0db4702519 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -280,6 +280,7 @@ mymain(void)
     DO_TEST("ws-in-the-wild-2", "ws-in-the-wild-2");
 
     DO_TEST("fusion-in-the-wild-1", "fusion-in-the-wild-1");
+    DO_TEST("fusion-in-the-wild-2", "fusion-in-the-wild-2");
 
     DO_TEST("annotation", "annotation");
 
diff --git a/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.vmx b/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.vmx
new file mode 100755
index 0000000000..a5dbf5244c
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.vmx
@@ -0,0 +1,36 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "9"
+guestOS = "other-64"
+uuid.bios = "56 4d 08 c1 40 dd 13 95-85 01 b3 af 47 74 24 7d"
+displayName = "Windows 10 x64"
+memsize = "6728"
+numvcpus = "1"
+scsi0.present = "true"
+scsi0.virtualDev = "lsisas1068"
+scsi0:0.present = "true"
+scsi0:0.deviceType = "scsi-hardDisk"
+scsi0:0.fileName = "/data/vmware/disk.vmdk"
+floppy0.present = "false"
+floppy1.present = "false"
+ethernet0.present = "true"
+ethernet0.virtualDev = "e1000"
+ethernet0.connectionType = "hostonly"
+ethernet0.addressType = "static"
+ethernet0.address = "00:90:b9:dc:ea:81"
+ethernet0.checkMACAddress = "false"
+svga.vramSize = "4194304"
+pciBridge0.present = "true"
+pciBridge4.present = "true"
+pciBridge4.virtualDev = "pcieRootPort"
+pciBridge4.functions = "8"
+pciBridge5.present = "true"
+pciBridge5.virtualDev = "pcieRootPort"
+pciBridge5.functions = "8"
+pciBridge6.present = "true"
+pciBridge6.virtualDev = "pcieRootPort"
+pciBridge6.functions = "8"
+pciBridge7.present = "true"
+pciBridge7.virtualDev = "pcieRootPort"
+pciBridge7.functions = "8"
+vmci0.present = "true"
diff --git a/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.xml b/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.xml
new file mode 100644
index 0000000000..be988e1bd9
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-2.xml
@@ -0,0 +1,31 @@
+<domain type='vmware'>
+  <name>Windows 10 x64</name>
+  <uuid>564d08c1-40dd-1395-8501-b3af4774247d</uuid>
+  <memory unit='KiB'>6889472</memory>
+  <currentMemory unit='KiB'>6889472</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64'>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>
+    <disk type='file' device='disk'>
+      <source file='/data/vmware/disk.vmdk'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0' model='lsisas1068'/>
+    <interface type='network'>
+      <mac address='00:90:b9:dc:ea:81'/>
+      <source network=''/>
+      <model type='e1000'/>
+    </interface>
+    <video>
+      <model type='vmvga' vram='4096' primary='yes'/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index f6bcd7b012..e9bde580eb 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -290,6 +290,7 @@ mymain(void)
     DO_TEST("ws-in-the-wild-2", "ws-in-the-wild-2", 8);
 
     DO_TEST("fusion-in-the-wild-1", "fusion-in-the-wild-1", 9);
+    DO_TEST("fusion-in-the-wild-2", "fusion-in-the-wild-2", 9);
 
     DO_TEST("annotation", "annotation", 4);
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list