Build the qemu-command line for vhost-user.
Signed-off-by: Michele Paolino <m.paolino(a)virtualopensystems.com>
---
src/qemu/qemu_command.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ab8cec5..c1cf001 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6930,6 +6930,61 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
}
static int
+qemuBuildVhostuserCommandLine(virCommandPtr cmd,
+ virDomainDefPtr def,
+ virDomainNetDefPtr net,
+ virQEMUCapsPtr qemuCaps)
+{
+ virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
+ virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
+
+ char* nic = NULL;
+
+ if (!qemuDomainSupportsNetdev(def, qemuCaps, net)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Netdev support unavailable"));
+ goto error;
+ }
+
+ if ((net->data.vhostuser)->type == 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" : "");
+ }
+
+ virBufferAsprintf(&netdev_buf,
"type=vhost-user,id=host%s,chardev=char%s",
+ net->info.alias, net->info.alias);
+
+ if (virBufferError(&chardev_buf) || virBufferError(&netdev_buf)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ virCommandAddArgList(cmd, "-chardev",
virBufferContentAndReset(&chardev_buf),
+ NULL);
+ virCommandAddArgList(cmd, "-netdev",
virBufferContentAndReset(&netdev_buf),
+ NULL);
+
+ if (!(nic = qemuBuildNicDevStr(def, net, -1, 0, 0, qemuCaps))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Error generating NIC -device
string"));
+ goto error;
+ }
+
+ virCommandAddArgList(cmd, "-device", nic, NULL);
+ VIR_FREE(nic);
+
+ return 0;
+
+ error:
+ virBufferFreeAndReset(&chardev_buf);
+ virBufferFreeAndReset(&netdev_buf);
+ VIR_FREE(nic);
+
+ return -1;
+}
+
+static int
qemuBuildInterfaceCommandLine(virCommandPtr cmd,
virQEMUDriverPtr driver,
virConnectPtr conn,
@@ -6952,6 +7007,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
int actualType = virDomainNetGetActualType(net);
size_t i;
+ if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
+ return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps);
+
if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
/* NET_TYPE_HOSTDEV devices are really hostdev devices, so
* their commandlines are constructed with other hostdevs.
--
1.9.3