[libvirt] [PATCH] qemu: format server interface without a listen address

https://bugzilla.redhat.com/show_bug.cgi?id=1130390 The listen address is not mandatory for <interface type='server'> but when it's not specified, we've been formatting it as: -netdev socket,listen=(null):5558,id=hostnet0 which failed with: Device 'socket' could not be initialized Omit the address completely and only format the port in the listen attribute. --- docs/schemas/domaincommon.rng | 10 ++++++++++ src/qemu/qemu_command.c | 3 ++- tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args | 4 +++- tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c428ddf..9d6c1ee 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2207,6 +2207,16 @@ <empty/> </element> </optional> + <optional> + <element name="model"> + <attribute name="type"> + <data type="string"> + <param name='pattern'>[a-zA-Z0-9\-_]+</param> + </data> + </attribute> + <empty/> + </element> + </optional> </interleave> </group> <group> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c041ee7..7e1f3d0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4576,7 +4576,8 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, case VIR_DOMAIN_NET_TYPE_SERVER: virBufferAsprintf(&buf, "socket%clisten=%s:%d", type_sep, - net->data.socket.address, + net->data.socket.address ? net->data.socket.address + : "", net->data.socket.port); type_sep = ','; break; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args index 26daac3..ac43630 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args @@ -7,4 +7,6 @@ pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,n -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,addr=0x3 \ -chardev socket,id=charnet1,path=/tmp/vhost1.sock \ -netdev type=vhost-user,id=hostnet1,chardev=charnet1 \ --device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,addr=0x4 +-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,addr=0x4 \ +-netdev socket,listen=:2015,id=hostnet2 \ +-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,addr=0x5 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml index e5b6242..fa09157 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml @@ -33,6 +33,11 @@ <source type='unix' path='/tmp/vhost1.sock' mode='client'/> <model type='virtio'/> </interface> + <interface type='server'> + <mac address='52:54:00:95:db:c0'/> + <source port='2015'/> + <model type='rtl8139'/> + </interface> <memballoon model='none'/> </devices> </domain> -- 2.0.4

On Tue, Jan 20, 2015 at 13:50:22 +0100, Ján Tomko wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1130390
The listen address is not mandatory for <interface type='server'> but when it's not specified, we've been formatting it as: -netdev socket,listen=(null):5558,id=hostnet0 which failed with: Device 'socket' could not be initialized
Omit the address completely and only format the port in the listen attribute.
Please mention that the schema didn't allow to specify the model to justify the schema change.
--- docs/schemas/domaincommon.rng | 10 ++++++++++ src/qemu/qemu_command.c | 3 ++- tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args | 4 +++- tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-)a
ACK, Peter
participants (2)
-
Ján Tomko
-
Peter Krempa