]> xenbits.xensource.com Git - libvirt.git/commitdiff
Only parse custom vhost path for virtio interfaces
authorJán Tomko <jtomko@redhat.com>
Thu, 5 Feb 2015 12:38:40 +0000 (13:38 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 6 Feb 2015 11:52:50 +0000 (12:52 +0100)
It is only supported for virtio adapters.
Silently drop it if it was specified for other models,
as is done for other virtio attributes.

Also mention this in the documentation.

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

docs/formatdomain.html.in
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index c5ad6f4b803df1b04b1bc3596bda5bc332b59a1e..18e472220e01f05065adeb436338f550d8f9aead 100644 (file)
@@ -4142,7 +4142,9 @@ qemu-kvm -net nic,model=? /dev/null
 
     <p>
       For tuning the backend of the network, the <code>backend</code> element
-      can be used. Supported attributes are <code>tap</code> and <code>vhost</code>,
+      can be used. The <code>vhost</code> attribute can override the default vhost
+      device path (<code>/dev/vhost-net</code>) for devices with <code>virtio</code> model.
+      Supported attributes are <code>tap</code> and <code>vhost</code>,
       allowing to override the default devices for creating tap and vhost devices.
     </p>
     <h5><a name="elementsNICSTargetOverride">Overriding the target element</a></h5>
index 4251b133a907889b6bfbd10c935ab070f1ada92d..f0b715d113d0e98b563319f3baba0279e6b12951 100644 (file)
@@ -7369,6 +7369,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     char *vhostuser_path = NULL;
     char *vhostuser_type = NULL;
     char *trustGuestRxFilters = NULL;
+    char *vhost_path = NULL;
     virNWFilterHashTablePtr filterparams = NULL;
     virDomainActualNetDefPtr actual = NULL;
     xmlNodePtr oldnode = ctxt->node;
@@ -7550,8 +7551,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
                     def->backend.tap = virFileSanitizePath(tmp);
                 VIR_FREE(tmp);
 
-                if ((tmp = virXMLPropString(cur, "vhost")))
-                    def->backend.vhost = virFileSanitizePath(tmp);
+                if (!vhost_path && (tmp = virXMLPropString(cur, "vhost")))
+                    vhost_path = virFileSanitizePath(tmp);
                 VIR_FREE(tmp);
             }
         }
@@ -7992,6 +7993,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
             }
             def->driver.virtio.guest.ufo = val;
         }
+        def->backend.vhost = vhost_path;
+        vhost_path = NULL;
     }
 
     def->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT;
@@ -8061,6 +8064,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_FREE(addrtype);
     VIR_FREE(trustGuestRxFilters);
     VIR_FREE(ips);
+    VIR_FREE(vhost_path);
     virNWFilterHashTableFree(filterparams);
 
     return def;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml b/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml
new file mode 100644 (file)
index 0000000..2cf312f
--- /dev/null
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+  <name>test</name>
+  <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-0.13'>hvm</type>
+    <boot dev='cdrom'/>
+    <boot dev='hd'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='virtio-serial' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </controller>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <interface type='user'>
+      <mac address='52:54:00:e5:48:58'/>
+      <model type='definitely-not-virtio'/>
+      <driver name='vhost' queues='5'/>
+      <backend tap='/dev/null' vhost='/dev/zero'/>
+    </interface>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml
new file mode 100644 (file)
index 0000000..266cbf0
--- /dev/null
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+  <name>test</name>
+  <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-0.13'>hvm</type>
+    <boot dev='cdrom'/>
+    <boot dev='hd'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='virtio-serial' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </controller>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <interface type='user'>
+      <mac address='52:54:00:e5:48:58'/>
+      <model type='definitely-not-virtio'/>
+      <backend tap='/dev/null'/>
+    </interface>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index a0a1cab206c7ec7aced60a8d593bafc407a76437..d3dfd9e750dcd2ff2ae5391aa13c83161dde1164 100644 (file)
@@ -417,6 +417,7 @@ mymain(void)
     DO_TEST("bios-nvram");
 
     DO_TEST("tap-vhost");
+    DO_TEST_DIFFERENT("tap-vhost-incorrect");
     DO_TEST("shmem");
     DO_TEST("smbios");