mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
qemuBuildHostNetStr: Support VIR_DOMAIN_NET_TYPE_VHOSTUSER
https://bugzilla.redhat.com/show_bug.cgi?id=1366505 So far, this function lacked support for VIR_DOMAIN_NET_TYPE_VHOSTUSER leaving callers to hack around the problem by constructing the command line on their own. This is not ideal as it blocks hot plug support. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b093e85224
commit
e1844d85cb
@ -3733,7 +3733,13 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
|
||||
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:
|
||||
@ -7791,7 +7797,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
|
||||
{
|
||||
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;
|
||||
|
||||
@ -7828,25 +7834,27 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
|
||||
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))) {
|
||||
@ -7863,8 +7871,8 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
|
||||
|
||||
error:
|
||||
virObjectUnref(cfg);
|
||||
VIR_FREE(netdev);
|
||||
VIR_FREE(chardev);
|
||||
virBufferFreeAndReset(&netdev_buf);
|
||||
VIR_FREE(nic);
|
||||
|
||||
return -1;
|
||||
|
@ -20,17 +20,17 @@ QEMU_AUDIO_DRV=none \
|
||||
-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
|
||||
|
@ -20,11 +20,11 @@ QEMU_AUDIO_DRV=none \
|
||||
-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 \
|
||||
|
Loading…
Reference in New Issue
Block a user