Re: [PATCHv3 1/2] qemu: support vhost in attach-interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/09/2011 03:42 PM, Eric Blake wrote:
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Honor vhost
designations, similar to qemu_command code paths.
* src/qemu/qemu_command.h (qemuOpenVhostNet): New prototype.
* src/qemu/qemu_command.c (qemuOpenVhostNet): Export.
---

Hmm, I just realized that it might be nice to have a --driver-name
flag in the virsh attach-interface wrapper command.  Oh well, that can
be a separate patch.

  src/qemu/qemu_command.c |    3 +-
  src/qemu/qemu_command.h |    4 +++
  src/qemu/qemu_hotplug.c |   54 ++++++++++++++++++++++++++++++++++++++++++----
  3 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 198a4e2..8cf1737 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -303,12 +303,11 @@ cleanup:
  }


-static int
+int
  qemuOpenVhostNet(virDomainNetDefPtr net,
                   virBitmapPtr qemuCaps,
                   int *vhostfd)
  {
-
      *vhostfd = -1;   /* assume we won't use vhost */

      /* If the config says explicitly to not use vhost, return now */
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 1902472..2ae364c 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -129,6 +129,10 @@ int qemuPhysIfaceConnect(virConnectPtr conn,
                           const unsigned char *vmuuid,
                           enum virVMOperationType vmop);

+int qemuOpenVhostNet(virDomainNetDefPtr net,
+                     virBitmapPtr qemuCaps,
+                     int *vhostfd);
+
  int qemudCanonicalizeMachine(struct qemud_driver *driver,
                               virDomainDefPtr def);

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7895062..e8567ad 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -552,6 +552,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
      qemuDomainObjPrivatePtr priv = vm->privateData;
      char *tapfd_name = NULL;
      int tapfd = -1;
+    char *vhostfd_name = NULL;
+    int vhostfd = -1;
      char *nicstr = NULL;
      char *netstr = NULL;
      int ret = -1;
@@ -592,6 +594,24 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
              return -1;
      }

+    if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
+        net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+        net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
+        /* Attempt to use vhost-net mode for these types of
+           network device */
+        if (qemuOpenVhostNet(net, qemuCaps,&vhostfd)<  0)
+            goto cleanup;
+
+        if (vhostfd>= 0&&
+            priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                            _("network device type '%s' cannot be attached: "
+                            "qemu is not using a unix socket monitor"),
+                            virDomainNetTypeToString(net->type));
+            goto cleanup;
+        }


The above check has already been handled by a combination of the checks in the if { } else if { } block above, so it's superfluous here.

ACK with this extra check for monConfig-type removed.


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]