[libvirt-users] vhost-net requested but could not be initialized

I am using a custom qemu to launch a vhost enabled VM. The qemu doesn't use the default "/dev/vhost-net" directory as character device. Due to this I am getting the error: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on: vhost-net requested but could not be initialized Is there a way to tell libvirt to avoid using the default /dev/vhost-net file? I have tried using the pass-through arguments but libvirt still processes the command and throws the error. PS: I can successfully create a vhost VM using qemu command-line, so this is a libvirt issue. -- Cheers, Asadullah Hussain

For qemu, the default vhost drive file is “/dev/vhost-net”, when you configured vhost on. Give the command “modprobe vhost-net” to add host kernel support for vhost. This is cannot controlled by libvirt I think. Wangkai From: libvirt-users-bounces@redhat.com [mailto:libvirt-users-bounces@redhat.com] On Behalf Of Asadullah Hussain Sent: Thursday, July 24, 2014 12:43 AM To: libvirt-users@redhat.com Subject: [libvirt-users] vhost-net requested but could not be initialized I am using a custom qemu to launch a vhost enabled VM. The qemu doesn't use the default "/dev/vhost-net" directory as character device. Due to this I am getting the error: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on: vhost-net requested but could not be initialized Is there a way to tell libvirt to avoid using the default /dev/vhost-net file? I have tried using the pass-through arguments but libvirt still processes the command and throws the error. PS: I can successfully create a vhost VM using qemu command-line, so this is a libvirt issue. -- Cheers, Asadullah Hussain

Thanks Wangkai but libvirt infact pre-configures network tap devices and pre-opens /dev/vhost-net file and passes these to qemu as open, ready to use file descriptors. My issue is that my qemu requires that /dev/vhost-net directory is removed and it's kernel module be unloaded. Then it creates a vhost -net device using its own configuration. On 24 July 2014 07:35, Wangkai (Kevin,C) <wangkai86@huawei.com> wrote:
For qemu, the default vhost drive file is “/dev/vhost-net”, when you configured vhost on.
Give the command “modprobe vhost-net” to add host kernel support for vhost.
This is cannot controlled by libvirt I think.
Wangkai
*From:* libvirt-users-bounces@redhat.com [mailto: libvirt-users-bounces@redhat.com] *On Behalf Of *Asadullah Hussain *Sent:* Thursday, July 24, 2014 12:43 AM *To:* libvirt-users@redhat.com *Subject:* [libvirt-users] vhost-net requested but could not be initialized
I am using a custom qemu to launch a vhost enabled VM. The qemu doesn't use the default "/dev/vhost-net" directory as character device. Due to this I am getting the error:
qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on: vhost-net requested but could not be initialized
Is there a way to tell libvirt to avoid using the default /dev/vhost-net file?
I have tried using the pass-through arguments but libvirt still processes the command and throws the error.
PS: I can successfully create a vhost VM using qemu command-line, so this is a libvirt issue.
--
Cheers,
Asadullah Hussain
-- Cheers, Asadullah Hussain

On Thu, Jul 24, 2014 at 08:42:47AM +0500, Asadullah Hussain wrote:
Thanks Wangkai but libvirt infact pre-configures network tap devices and pre-opens /dev/vhost-net file and passes these to qemu as open, ready to use file descriptors.
My issue is that my qemu requires that /dev/vhost-net directory is removed and it's kernel module be unloaded. Then it creates a vhost -net device using its own configuration.
Libvirt is only written to work against official upstream QEMU. If you have modified your QEMU to work in a different way wrt net devices then you'll have to modify your libvirt to cope or workaround the problems. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

The qemu that I am using isn't modified at all. It's the VHOST drivers that are mounted elsewhere i.e., not on default /dev/vhost-net. Here is the command that I use to launch my qemu VM: qemu-system-x86_64 -cpu host -boot order=c -hda /root/Disks/ubuntu1.qcow2 -m 1024M -smp 2 --enable-kvm -name 'client 1' -nographic -vnc :2 -net none -no-reboot -mem-path /dev/hugepages -mem-prealloc -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on -device virtio-net-pci,netdev=net1,mac=00:00:00:00:00:01,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off -netdev type=tap,id=net2,script=no,downscript=no,ifname=port4,vhost=on -device virtio-net-pci,netdev=net2,mac=00:00:00:00:00:02,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off As you can see I have created tap interfaces port3 & port4 and I just want to connect the VM to these VMs. On 24 July 2014 13:31, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jul 24, 2014 at 08:42:47AM +0500, Asadullah Hussain wrote:
Thanks Wangkai but libvirt infact pre-configures network tap devices and pre-opens /dev/vhost-net file and passes these to qemu as open, ready to use file descriptors.
My issue is that my qemu requires that /dev/vhost-net directory is removed and it's kernel module be unloaded. Then it creates a vhost -net device using its own configuration.
Libvirt is only written to work against official upstream QEMU. If you have modified your QEMU to work in a different way wrt net devices then you'll have to modify your libvirt to cope or workaround the problems.
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
-- Cheers, Asadullah Hussain

Let me clarify my question, I am using unmodified stock qemu (1.4.0) and only the location of vhost file descriptor is different from default (I don't remove the default /dev/vhost-net directory) The VHOST file descriptor is present in "/dev/vhost-0" directory instead of the default "/dev/vhost-net". When I try to give vhostfd in the XML I get a different error: 2014-07-24 10:42:22.507+0000: 3181: error : qemuMonitorOpenUnix:293 : failed to connect to monitor socket: No such process 2014-07-24 10:42:22.507+0000: 3181: error : qemuProcessWaitForMonitor:1806 : internal error process exited while connecting to monitor: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port4,vhost=on,vhostfd=/dev/vhost-0: Device 'tap' could not be initialized Whereas if I don't give the vhostfd option in the XML, it uses the default /dev/vhost-net directory and throws the following error: 2014-07-24 10:41:35.970+0000: 3183: error : qemuMonitorOpenUnix:293 : failed to connect to monitor socket: No such process 2014-07-24 10:41:35.970+0000: 3183: error : qemuProcessWaitForMonitor:1806 : internal error process exited while connecting to monitor: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port4,vhost=on: vhost-net requested but could not be initialized qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port4,vhost=on: Device 'tap' could not be initialized On 24 July 2014 13:47, Asadullah Hussain <asadxflow@gmail.com> wrote:
The qemu that I am using isn't modified at all. It's the VHOST drivers that are mounted elsewhere i.e., not on default /dev/vhost-net.
Here is the command that I use to launch my qemu VM: qemu-system-x86_64 -cpu host -boot order=c -hda /root/Disks/ubuntu1.qcow2 -m 1024M -smp 2 --enable-kvm -name 'client 1' -nographic -vnc :2 -net none -no-reboot -mem-path /dev/hugepages -mem-prealloc -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on -device virtio-net-pci,netdev=net1,mac=00:00:00:00:00:01,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off -netdev type=tap,id=net2,script=no,downscript=no,ifname=port4,vhost=on -device virtio-net-pci,netdev=net2,mac=00:00:00:00:00:02,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off As you can see I have created tap interfaces port3 & port4 and I just want to connect the VM to these VMs.
On 24 July 2014 13:31, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jul 24, 2014 at 08:42:47AM +0500, Asadullah Hussain wrote:
Thanks Wangkai but libvirt infact pre-configures network tap devices and pre-opens /dev/vhost-net file and passes these to qemu as open, ready to use file descriptors.
My issue is that my qemu requires that /dev/vhost-net directory is removed and it's kernel module be unloaded. Then it creates a vhost -net device using its own configuration.
Libvirt is only written to work against official upstream QEMU. If you have modified your QEMU to work in a different way wrt net devices then you'll have to modify your libvirt to cope or workaround the problems.
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
-- Cheers,
Asadullah Hussain
-- Cheers, Asadullah Hussain

On Thu, Jul 24, 2014 at 03:48:06PM +0500, Asadullah Hussain wrote:
Let me clarify my question, I am using unmodified stock qemu (1.4.0) and only the location of vhost file descriptor is different from default (I don't remove the default /dev/vhost-net directory)
The VHOST file descriptor is present in "/dev/vhost-0" directory instead of the default "/dev/vhost-net". When I try to give vhostfd in the XML I get a different error:
Well I suggest you make your system use the expected device name for /dev/vhost-net. Just as libvirt only targets mainline QEMU, we only target mainline kernel / standard device layout Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 24 July 2014 15:52, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jul 24, 2014 at 03:48:06PM +0500, Asadullah Hussain wrote:
Let me clarify my question, I am using unmodified stock qemu (1.4.0) and only the location of vhost file descriptor is different from default (I don't remove the default /dev/vhost-net directory)
The VHOST file descriptor is present in "/dev/vhost-0" directory instead of the default "/dev/vhost-net". When I try to give vhostfd in the XML I get a different error:
Well I suggest you make your system use the expected device name for /dev/vhost-net. Just as libvirt only targets mainline QEMU, we only target mainline kernel / standard device layout
I was able to change my device name to /dev/vhost-net but still I get the error, the error itself isn't telling much about the problem: 2014-07-24 10:41:35.970+0000: 3183: error : qemuMonitorOpenUnix:293 : failed to connect to monitor socket: No such process 2014-07-24 10:41:35.970+0000: 3183: error : qemuProcessWaitForMonitor:1806 : internal error process exited while connecting to monitor: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port4,vhost=on: vhost-net requested but could not be initialized qemu-system-x86_64: -netdev type=tap,id=net1,script=no, downscript=no,ifname=port4,vhost=on: Device 'tap' could not be initialized
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
-- Cheers, Asadullah Hussain

Currently in the VM XML, I am passing the following command line argument as a passthrough argument: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on -device virtio-net-pci,netdev=net1,mac=00:00:00:00:00:01,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off Is there another way to represent this in the XML file? maybe that may solve the problem. On 24 July 2014 15:55, Asadullah Hussain <asadxflow@gmail.com> wrote:
On 24 July 2014 15:52, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jul 24, 2014 at 03:48:06PM +0500, Asadullah Hussain wrote:
Let me clarify my question, I am using unmodified stock qemu (1.4.0) and only the location of vhost file descriptor is different from default (I don't remove the default /dev/vhost-net directory)
The VHOST file descriptor is present in "/dev/vhost-0" directory instead of the default "/dev/vhost-net". When I try to give vhostfd in the XML I get a different error:
Well I suggest you make your system use the expected device name for /dev/vhost-net. Just as libvirt only targets mainline QEMU, we only target mainline kernel / standard device layout
I was able to change my device name to /dev/vhost-net but still I get the error, the error itself isn't telling much about the problem: 2014-07-24 10:41:35.970+0000: 3183: error : qemuMonitorOpenUnix:293 : failed to connect to monitor socket: No such process 2014-07-24 10:41:35.970+0000: 3183: error : qemuProcessWaitForMonitor:1806 : internal error process exited while connecting to monitor: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port4,vhost=on: vhost-net requested but could not be initialized qemu-system-x86_64: -netdev type=tap,id=net1,script=no, downscript=no,ifname=port4,vhost=on: Device 'tap' could not be initialized
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
-- Cheers,
Asadullah Hussain
-- Cheers, Asadullah Hussain

Solved the problem, basically libvirt pre-configures network tap devices and pre-opens /dev/vhost-net file and passes these to qemu as open, ready to use file descriptors. . It makes it very difficult to use any other file descriptor for a vhost kernel module. I had to just make sure that the vhost device file descriptor was the default directory i.e., /dev/vhost-net. I also had to change the permissions for this default file descriptor and add it to "cgroup_device_acl". On 24 July 2014 16:00, Asadullah Hussain <asadxflow@gmail.com> wrote:
Currently in the VM XML, I am passing the following command line argument as a passthrough argument: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port3,vhost=on -device virtio-net-pci,netdev=net1,mac=00:00:00:00:00:01,csum=off,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off
Is there another way to represent this in the XML file? maybe that may solve the problem.
On 24 July 2014 15:55, Asadullah Hussain <asadxflow@gmail.com> wrote:
On 24 July 2014 15:52, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jul 24, 2014 at 03:48:06PM +0500, Asadullah Hussain wrote:
Let me clarify my question, I am using unmodified stock qemu (1.4.0) and only the location of vhost file descriptor is different from default (I don't remove the default /dev/vhost-net directory)
The VHOST file descriptor is present in "/dev/vhost-0" directory instead of the default "/dev/vhost-net". When I try to give vhostfd in the XML I get a different error:
Well I suggest you make your system use the expected device name for /dev/vhost-net. Just as libvirt only targets mainline QEMU, we only target mainline kernel / standard device layout
I was able to change my device name to /dev/vhost-net but still I get the error, the error itself isn't telling much about the problem: 2014-07-24 10:41:35.970+0000: 3183: error : qemuMonitorOpenUnix:293 : failed to connect to monitor socket: No such process 2014-07-24 10:41:35.970+0000: 3183: error : qemuProcessWaitForMonitor:1806 : internal error process exited while connecting to monitor: qemu-system-x86_64: -netdev type=tap,id=net1,script=no,downscript=no,ifname=port4,vhost=on: vhost-net requested but could not be initialized qemu-system-x86_64: -netdev type=tap,id=net1,script=no, downscript=no,ifname=port4,vhost=on: Device 'tap' could not be initialized
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
-- Cheers,
Asadullah Hussain
-- Cheers,
Asadullah Hussain
-- Cheers, Asadullah Hussain
participants (3)
-
Asadullah Hussain
-
Daniel P. Berrange
-
Wangkai (Kevin,C)