From: Ján Tomko Date: Thu, 5 Feb 2015 12:38:40 +0000 (+0100) Subject: Only parse custom vhost path for virtio interfaces X-Git-Tag: v1.2.13-rc1~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84f741812f970f9ee9b857673c03433f7c2866a6;p=thirdparty%2Flibvirt.git Only parse custom vhost path for virtio interfaces 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 --- diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c5ad6f4b80..18e472220e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4142,7 +4142,9 @@ qemu-kvm -net nic,model=? /dev/null

For tuning the backend of the network, the backend element - can be used. Supported attributes are tap and vhost, + can be used. The vhost attribute can override the default vhost + device path (/dev/vhost-net) for devices with virtio model. + Supported attributes are tap and vhost, allowing to override the default devices for creating tap and vhost devices.

Overriding the target element
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4251b133a9..f0b715d113 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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 index 0000000000..2cf312f0ca --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml @@ -0,0 +1,39 @@ + + test + bba65c0e-c049-934f-b6aa-4e2c0582acdf + 1048576 + 1048576 + 1 + + hvm + + + + + + destroy + restart + restart + + /usr/bin/qemu + + +
+ + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml new file mode 100644 index 0000000000..266cbf0a72 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -0,0 +1,38 @@ + + test + bba65c0e-c049-934f-b6aa-4e2c0582acdf + 1048576 + 1048576 + 1 + + hvm + + + + + + destroy + restart + restart + + /usr/bin/qemu + + +
+ + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a0a1cab206..d3dfd9e750 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -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");