Currently, need for use of vhost-net is signalized by returning
zero, and setting passed FD to a value different to negative one.
However, when using multiple vhost-net devices, it is not so easy
so we should use return value for that.
---
src/qemu/qemu_command.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 58c81d7..dfcfedc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -320,6 +320,19 @@ cleanup:
}
+/**
+ * qemuOpenVhostNet:
+ * @def: domain definition
+ * @net: network definition
+ * @qemuCaps: qemu binary capabilities
+ * @vhostfd: array of opened vhost-net device
+ * @vhostfdSize: size of @vhostfd array
+ *
+ * Open vhost-net, multiple times - if request.
+ * Returns: 1 if no vhost-net is required for @net type
+ * 0 on success
+ * -1 on failure
+ */
int
qemuOpenVhostNet(virDomainDefPtr def,
virDomainNetDefPtr net,
@@ -333,9 +346,8 @@ qemuOpenVhostNet(virDomainDefPtr def,
vhostfd[i] = -1; /* assume we won't use vhost */
/* If the config says explicitly to not use vhost, return now */
- if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU) {
- return 0;
- }
+ if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU)
+ return 1;
/* If qemu doesn't support vhost-net mode (including the -netdev command
* option), don't try to open the device.
@@ -349,7 +361,7 @@ qemuOpenVhostNet(virDomainDefPtr def,
"this QEMU binary"));
return -1;
}
- return 0;
+ return 1;
}
/* If the nic model isn't virtio, don't try to open. */
@@ -360,7 +372,7 @@ qemuOpenVhostNet(virDomainDefPtr def,
"virtio network interfaces"));
return -1;
}
- return 0;
+ return 1;
}
for (i = 0; i < vhostfdSize; i++) {
--
1.8.1.5