[libvirt] [PATCH v2 0/2] Removing backend support when net interface is user/direct/hostdev.

The <backend> xml tag is not supported for some interface types and the virsh command 'attach-device' permits to add <backend> settings to all of them. These commits avoid <backend> for user, direct and hostdev interface types. One commit changes some test cases to avoid wrong <backend> usage. Julio Faracco (2): tests: changing network interface types when backend tag is defined. qemu: network user/direct/hostdev do not support backend. src/qemu/qemu_domain.c | 15 +++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml | 3 ++- .../qemuxml2xmlout-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml | 3 ++- 5 files changed, 27 insertions(+), 6 deletions(-) -- 2.7.4

Some test cases have the backend tag inside wrong interfaces. The backend xml tag does not support <interface type='user|direct|hostdev'>. So this commit changes some network types inside the interfaces that have backend defined. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml | 3 ++- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml b/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml index a1532cb..4e1d67e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml @@ -22,14 +22,16 @@ </controller> <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> - <interface type='user'> + <interface type='network'> <mac address='52:54:00:e5:48:58'/> + <source network='default'/> <model type='e1000'/> <driver name='vhost' queues='5'/> <backend tap='/dev/null' vhost='/dev/zero'/> </interface> - <interface type='user'> + <interface type='network'> <mac address='52:54:00:e5:48:59'/> + <source network='default'/> <model type='virtio'/> <driver name='vhost' queues='1'/> <backend tap='/dev/null' vhost='/dev/zero'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml b/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml index c2303b7..6d7ffb0 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml @@ -35,8 +35,9 @@ </controller> <controller type='ide' index='0'/> <controller type='pci' index='0' model='pci-root'/> - <interface type='user'> + <interface type='network'> <mac address='52:54:00:e5:48:58'/> + <source network='default'/> <model type='virtio'/> <driver name='vhost' queues='5'/> <backend tap='/dev/null' vhost='/dev/zero'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml index 3a95b60..a6be754 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml @@ -26,14 +26,16 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='pci' index='0' model='pci-root'/> - <interface type='user'> + <interface type='network'> <mac address='52:54:00:e5:48:58'/> + <source network='default'/> <model type='e1000'/> <backend tap='/dev/null'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> - <interface type='user'> + <interface type='network'> <mac address='52:54:00:e5:48:59'/> + <source network='default'/> <model type='virtio'/> <driver name='vhost'/> <backend tap='/dev/null' vhost='/dev/zero'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml index 759b844..7787bef 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml @@ -39,8 +39,9 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='pci' index='0' model='pci-root'/> - <interface type='user'> + <interface type='network'> <mac address='52:54:00:e5:48:58'/> + <source network='default'/> <model type='virtio'/> <driver name='vhost' queues='5'/> <backend tap='/dev/null' vhost='/dev/zero'/> -- 2.7.4

On Fri, Nov 17, 2017 at 07:27:40PM -0200, Julio Faracco wrote:
Some test cases have the backend tag inside wrong interfaces. The backend xml tag does not support <interface type='user|direct|hostdev'>. So this commit changes some network types inside the interfaces that have backend defined.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml | 3 ++- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-)
ACK and pushed. Jan

Hi Jan and guys, I was facing a weird issue when I was rewriting this. If I start with the <source/> tag, the test fails. I need to start with <mac address/> tag to work properly. Test fails: ... <interface type='network'> <source network='default'/> <mac address='52:54:00:e5:48:58'/> ... Test returns ok: ... <interface type='network'> <mac address='52:54:00:e5:48:58'/> <source network='default'/> ... In my point of view, both structure means the same thing. It is happening because virDomainNetDefFormat() generates <mac address/> right after <interface/> tag. Em 23 de nov de 2017 2:48 PM, "Ján Tomko" <jtomko@redhat.com> escreveu:
On Fri, Nov 17, 2017 at 07:27:40PM -0200, Julio Faracco wrote:
Some test cases have the backend tag inside wrong interfaces. The backend xml tag does not support <interface type='user|direct|hostdev'>. So this commit changes some network types inside the interfaces that have backend defined.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2argvdata/qemuxml2argv-tap-vhost.xml | 3 ++- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost-incorrect.xml | 6 ++++-- tests/qemuxml2xmloutdata/qemuxml2xmlout-tap-vhost.xml | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-)
ACK and pushed.
Jan

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@gmail.com> --- src/qemu/qemu_domain.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cc7596b..0215b2a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3608,6 +3608,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, goto cleanup; } + if (net->backend.tap) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Custom tap device path is not supported for: %s"), + virDomainNetTypeToString(net->type)); + goto cleanup; + } + for (i = 0; i < net->guestIP.nips; i++) { const virNetDevIPAddr *ip = net->guestIP.ips[i]; @@ -3649,6 +3656,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, } } } + } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT || + net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (net->backend.tap) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Custom tap device path is not supported for: %s"), + virDomainNetTypeToString(net->type)); + goto cleanup; + } } else if (net->guestIP.nroutes || net->guestIP.nips) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid attempt to set network interface " -- 2.7.4

On Fri, Nov 17, 2017 at 07:27:41PM -0200, Julio Faracco wrote:
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@gmail.com> --- src/qemu/qemu_domain.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cc7596b..0215b2a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3649,6 +3656,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, } } } + } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT || + net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (net->backend.tap) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Custom tap device path is not supported for: %s"), + virDomainNetTypeToString(net->type)); + goto cleanup; + }
Adding this 'else if' clause means that the following check is no longer executed for TYPE_DIRECT and TYPE_HOSTDEV:
} else if (net->guestIP.nroutes || net->guestIP.nips) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid attempt to set network interface "
Jan

Opssss... Python feelings! 2017-11-23 14:50 GMT-02:00 Ján Tomko <jtomko@redhat.com>:
On Fri, Nov 17, 2017 at 07:27:41PM -0200, Julio Faracco wrote:
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@gmail.com> --- src/qemu/qemu_domain.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index cc7596b..0215b2a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3649,6 +3656,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, } } } + } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT || + net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (net->backend.tap) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Custom tap device path is not supported for: %s"), + virDomainNetTypeToString(net->type)); + goto cleanup; + }
Adding this 'else if' clause means that the following check is no longer executed for TYPE_DIRECT and TYPE_HOSTDEV:
} else if (net->guestIP.nroutes || net->guestIP.nips) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid attempt to set network interface "
Jan
participants (2)
-
Julio Faracco
-
Ján Tomko