It works well if we use qmp command to directly interact with qemu 2.1 to hot-add
vhost-user network card. However, libvirt seems not support hotplugging well.
Steps to use qmp commands to directly(without libvirtd) interact with qemu 2.1 :
1 (qemu) chardev-add backend=socket,id=charnet1,path=/var/run/vhost-user/tap1
2 (qemu) netdev_add vhost-user,id=hostnet1,chardev=charnet1
3 (qemu) device_add virtio-net-pci,netdev=hostnet1,id=net1
In libvirt, we found that, Hot-plug is finished with a success result, but the network
card doesn't work afterwards, it could not send/receive IOs.
As we further digged into the problem, the 1st step of qmp commands is missing if we use
libvirt to do the hot-plug job.
1 (qemu) chardev-add backend=socket,id=charnet1,path=/var/run/vhost-user/tap1
After looking into the function qemuDomainAttachNetDevice(), we found that it does have
1) qemuMonitorAddNetdev()
2) qemuMonitorAddDevice()
except for *ChardevAdd*()
The question is : why does qemuDomainAttachNetDevice() not do the *ChardevAdd*() work? It
seems necessary to add chardev to add a vhost-user network card.