Bug 985214

Summary: fail to transfer any data between host and guest with virtio serial through UDP option
Product: Red Hat Enterprise Linux 6 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Amit Shah <amit.shah>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.5CC: acathrow, amit.shah, bsarathy, chayang, flang, juzhang, kraxel, mdeng, michen, mkenneth, qzhang, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 987278 1121579 (view as bug list) Environment:
Last Closed: 2014-08-19 11:43:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 987278, 1121579, 1174102    

Description Sibiao Luo 2013-07-17 06:38:09 UTC
Description of problem:
boot guest with virtio serial though the UDP option, and try to transfer data between host and guest, but fail to transfer anythong. 
BTW, tried it with tcp or unix socket that have no such issue, it can transfer samll or big size data.

QEMU man help doc:
-chardev udp ,id=id [,host=host] ,port=port [,localaddr=localaddr][,localport=localport] [,ipv4][,ipv6]
Sends all traffic from the guest to a remote host over UDP.
host specifies the remote host to connect to. If not specified it defaults to "localhost".
port specifies the port on the remote host to connect to. port is required.

Version-Release number of selected component (if applicable):
host info:
2.6.32-398.el6.x86_64
qemu-kvm-0.12.1.2-2.378.el6.x86_64
guest info:
2.6.32-398.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1.boot guest with virtio serial though the UDP option.
e.g:...-device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev udp,id=channel1,host=localhost,port=12345,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev udp,id=channel2,host=localhost,port=12346,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2
2.try to transfer data between host and guest.

Actual results:
after step 2, it fail to transfer anything.
guest---->host:
# echo "sibiaoluo" > /dev/vport0p1
# nc -u -l localhost 12345       <------none output
^C
# echo "sibiaoluo" > /dev/vport0p2
# nc -u -l localhost 12346       <------none output
^C

host----->guest:
# echo "sibiaoluo" | nc -u -l localhost 12345
# cat /dev/vport0p1
                                 <------output nothing

Expected results:
It and transfer data between localhost/remotehost and guest over UDP.

Additional info:

Comment 1 Sibiao Luo 2013-07-17 06:39:44 UTC
my qemu-kvm command line:
# /usr/libexec/qemu-kvm -S -M rhel6.5.0 -cpu SandyBridge -enable-kvm -m 4096 -smp 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection -name sluo -uuid 43425b70-86e5-4664-bf2c-3b76699b8bec -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev udp,id=channel1,host=localhost,port=12345,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev udp,id=channel2,host=localhost,port=12346,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=/home/RHEL6.5-20130712.n.0-6.5-Server-x64.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,serial="QEMU-DISK1" -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-system-disk,id=system-disk,bootindex=1 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x5 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=2C:41:38:B6:40:21,bus=pci.0,addr=0x6,bootindex=2 -drive file=/home/my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,serial="QEMU-DISK2" -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-data-disk,id=data-disk,bootindex=3 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -spice port=5931,disable-ticketing -monitor stdio

Comment 2 Qunfang Zhang 2013-07-17 11:28:27 UTC
FYI:
https://bugzilla.redhat.com/show_bug.cgi?id=720635#c9

udp is not in the supported list for the chardev backend. Amit, right?

Comment 3 Sibiao Luo 2013-07-19 05:30:12 UTC
I met anther issue that fail to login to guest via virtconsole through UDP option, it have no any response when press 'Enter' keyboard, Maybe it's the same issue to this one. Please let me know it if you check that not the same issue, i will separate a new one.
We have bug 985834 for virtconsole with Unix/TCP socket problem that cann't login to guest.

Best Regards,
sluo

Comment 7 Amit Shah 2014-08-19 11:43:03 UTC
From RHEL7 clone:

https://bugzilla.redhat.com/show_bug.cgi?id=987278#c3

udp chardev works for me.

Terminal #1:
nc -4 -u -l 12345

Terminal #2: 
qemu-kvm  -chardev udp,id=test,port=12345,localport=54321,ipv4 \
     -device isa-debugcon,iobase=0x402,chardev=test

seabios log messages show up in Terminal #1 just fine.

Now and then there is a piece missing.  But note that unlike TCP the UDP protocol doesn't make any guaranties whatsoever.  In case buffers are full packets are simply dropped and lost.  So this is normal behavior.  Packets can also be reordered.

Note that both qemu+netcat are forced into ipv4 mode to make sure they speak the same protocol.

Also note that I'm explicitly setting localport to avoid a random port being picked.  This allows to keep netcat in terminal #1 running while starting qemu multiple times even though netcat will only accept packets from a single peer address.

Final note: The UDP protocol is stateless.  There is no "connected" and "disconnected" state.  Consequently the UDP chardev backend doesn't send open/close chardev events.  Which virtio-serial might depend on to work correctly.  Amit?

Bottom line:  Testing the udp chardev with anything which requires a reliable stream is bogus in the first place.  The only remotely useful use case for the udp chardev backend I can think of is to send guest output to a remote syslog server (which traditionally listens on udp port 514).