return NULL;
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
- /* Unsupported yet. */
+ virBufferAsprintf(&buf, "vhost-user%cchardev=char%s",
+ type_sep,
+ net->info.alias);
+ type_sep = ',';
+ if (net->driver.virtio.queues > 1)
+ virBufferAsprintf(&buf, ",queues=%u",
+ net->driver.virtio.queues);
break;
case VIR_DOMAIN_NET_TYPE_LAST:
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
char *chardev = NULL;
- virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
+ char *netdev = NULL;
unsigned int queues = net->driver.virtio.queues;
char *nic = NULL;
goto error;
}
- virBufferAsprintf(&netdev_buf, "vhost-user,id=host%s,chardev=char%s",
- net->info.alias, net->info.alias);
-
- if (queues > 1) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("multi-queue is not supported for vhost-user "
- "with this QEMU binary"));
- goto error;
- }
- virBufferAsprintf(&netdev_buf, ",queues=%u", queues);
+ if (queues > 1 &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("multi-queue is not supported for vhost-user "
+ "with this QEMU binary"));
+ goto error;
}
+ if (!(netdev = qemuBuildHostNetStr(net, driver,
+ ',', -1,
+ NULL, 0, NULL, 0)))
+ goto error;
+
+
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, chardev);
VIR_FREE(chardev);
virCommandAddArg(cmd, "-netdev");
- virCommandAddArgBuffer(cmd, &netdev_buf);
+ virCommandAddArg(cmd, netdev);
+ VIR_FREE(netdev);
if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
queues, qemuCaps))) {
error:
virObjectUnref(cfg);
+ VIR_FREE(netdev);
VIR_FREE(chardev);
- virBufferFreeAndReset(&netdev_buf);
VIR_FREE(nic);
return -1;
-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 \
--netdev vhost-user,id=hostnet0,chardev=charnet0 \
+-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-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 vhost-user,id=hostnet1,chardev=charnet1 \
+-netdev vhost-user,chardev=charnet1,id=hostnet1 \
-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 \
-chardev socket,id=charnet3,path=/tmp/vhost2.sock \
--netdev vhost-user,id=hostnet3,chardev=charnet3,queues=4 \
+-netdev vhost-user,chardev=charnet3,queues=4,id=hostnet3 \
-device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\
mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6
-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 \
--netdev vhost-user,id=hostnet0,chardev=charnet0 \
+-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-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 vhost-user,id=hostnet1,chardev=charnet1 \
+-netdev vhost-user,chardev=charnet1,id=hostnet1 \
-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 \