Bug 1285697

Summary: [RFE] Add "nowait" support for vhost-user
Product: Red Hat Enterprise Linux 7 Reporter: Amnon Ilan <ailan>
Component: qemu-kvm-rhevAssignee: Victor Kaplansky <victork>
Status: CLOSED CURRENTRELEASE QA Contact: Sitong Liu <siliu>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: ailan, jean-mickael.guerin, juzhang, michen, pezhang, pginchev, siliu, thibaut.collet, victork, vincent.jardin, virt-maint, xfu
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-04 09:07:15 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: 1288337    

Description Amnon Ilan 2015-11-26 09:57:48 UTC
Description of problem:

Vhost-user should support "nowait": when a guest is starting and tries to connect 
to vhost-user, but vhost-user is not up yet for some reason (startup timing, 
vhost-user crash, live migration, etc.), the guest should be able to complete 
it's startup without waiting for vhost-user, and then complete the connections 
async when vhost-user is up.

Comment 1 Peter Ginchev 2017-01-12 11:51:31 UTC
The current RHEL 7.3 used libvirtd version 2.0.0 and QEMU version 2.6, below are proposed patches that adds 'nowait' functionality:

QEMU:
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 1b9e73a..aaa223e 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -239,6 +239,7 @@ static int net_vhost_chardev_opts(void *opaque,
     } else if (strcmp(name, "path") == 0) {
         props->is_unix = true;
     } else if (strcmp(name, "server") == 0) {
+    } else if (strcmp(name, "wait") == 0) {
     } else {
         error_setg(errp,
                    "vhost-user does not support a chardev with option %s=%s",

LIBVIRT:
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7eb6c0a..7708c90 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7668,7 +7668,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
     case VIR_DOMAIN_CHR_TYPE_UNIX:
         virBufferAsprintf(&chardev_buf, "socket,id=char%s,path=%s%s",
                           net->info.alias, net->data.vhostuser->data.nix.path,
-                          net->data.vhostuser->data.nix.listen ? ",server" : "");
+                          net->data.vhostuser->data.nix.listen ? ",server,nowait" : "");
         break;

     case VIR_DOMAIN_CHR_TYPE_NULL:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
index 3229034..f65ead8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
@@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
+-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server,nowait \
 -netdev type=vhost-user,id=hostnet0,chardev=charnet0 \
 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
 addr=0x3 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
index a9989b8..df334b1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
@@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
+-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server,nowait \
 -netdev type=vhost-user,id=hostnet0,chardev=charnet0 \
 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
 addr=0x3 \

Comment 2 Peter Ginchev 2017-01-12 11:54:25 UTC
LIBVIRT fix is relevant for all, but QEMU is specific for 2.6, 'master' branch of QEMU drops chardev parameters validation in the way it is done in 2.6, so QEMU master doesn't need a fix

Should I open a new bug for libvirt fix?

Comment 3 Victor Kaplansky 2017-01-12 15:50:54 UTC
Hi Peter,

So what do you say is, passing "nowait" as the socket param solves the bug, and the only problem from the QEMU point of view is the ned to validate "nowait" as a legal parameter. Right?

If so, it is still not clear to me why you propose to check in net/vhost-user.c
+    } else if (strcmp(name, "wait") == 0) {
for "wait" instead of "nowait"...


-- 
Victor

Comment 4 Peter Ginchev 2017-01-16 08:29:31 UTC
Hi Victor,
After our phone conversation,
I can confirm that I did test vhost-user socket connected at a much later time.
The interface is set up correctly and packets do pass.