The tag backend is not supported for user/direct/hostdev network when you
try to define them inside the domain XML. So, other ways to include devices
cannot be permitted too. But the attach-device command is wrongly adding
unsupported features. This commit fixes this bug.
After the patch:
virsh # attach-device rhel7.4 backend.xml
error: Failed to attach device from backend.xml
error: unsupported configuration: Custom tap device path is not supported for: user
Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1480251
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/conf/domain_conf.c | 10 ++++++++++
tests/qemuxml2argvtest.c | 6 +++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0f306b7..2842533 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10518,6 +10518,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
} else if (virXMLNodeNameEqual(cur, "backend")) {
char *tmp = NULL;
+ /* user/direct/hostdev do not support backend */
+ if (def->type == VIR_DOMAIN_NET_TYPE_USER ||
+ def->type == VIR_DOMAIN_NET_TYPE_DIRECT ||
+ def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Custom tap device path is not supported for:
%s"),
+ virDomainNetTypeToString(def->type));
+ goto error;
+ }
+
if ((tmp = virXMLPropString(cur, "tap")))
def->backend.tap = virFileSanitizePath(tmp);
VIR_FREE(tmp);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 01e7d6f..fad8aba 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1219,9 +1219,9 @@ mymain(void)
QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
DO_TEST_FAILURE("net-hostdev-vfio-multidomain",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI);
- DO_TEST_FAILURE("net-hostdev-fail",
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST_PARSE_ERROR("net-hostdev-fail",
+ QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("serial-file-log",
--
2.7.4