]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
network: Add midonet virtual port type support to qemu
authorAntoni Segura Puimedon <toni@midokura.com>
Mon, 23 Feb 2015 20:54:56 +0000 (21:54 +0100)
committerLaine Stump <laine@laine.org>
Tue, 17 Mar 2015 17:10:17 +0000 (13:10 -0400)
Use the utilities introduced in the previous patches so the qemu
driver is able to create tap devices that are bound (and unbound
on domain destroyal) to Midonet virtual ports.

Signed-off-by: Antoni Segura Puimedon <toni+libvirt@midokura.com>
src/qemu/qemu_hotplug.c
src/qemu/qemu_process.c
src/util/virnetdevtap.c

index 45aaa0f7354ec4a6c4b41ac56427cdb355612514..32596a787577cd0811e74442c7a735dc207d5e24 100644 (file)
@@ -47,6 +47,7 @@
 #include "virnetdev.h"
 #include "virnetdevbridge.h"
 #include "virnetdevtap.h"
+#include "virnetdevmidonet.h"
 #include "device_conf.h"
 #include "virstoragefile.h"
 #include "virstring.h"
@@ -1139,9 +1140,15 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
             }
 
             vport = virDomainNetGetActualVirtPortProfile(net);
-            if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-               ignore_value(virNetDevOpenvswitchRemovePort(
-                               virDomainNetGetActualBridgeName(net), net->ifname));
+            if (vport) {
+                if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+                    ignore_value(virNetDevMidonetUnbindPort(vport));
+                } else if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+                    ignore_value(virNetDevOpenvswitchRemovePort(
+                                     virDomainNetGetActualBridgeName(net),
+                                     net->ifname));
+                }
+            }
         }
 
         virDomainNetRemoveHostdev(vm->def, net);
@@ -2934,10 +2941,15 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
     }
 
     vport = virDomainNetGetActualVirtPortProfile(net);
-    if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-        ignore_value(virNetDevOpenvswitchRemovePort(
-                        virDomainNetGetActualBridgeName(net),
-                        net->ifname));
+    if (vport) {
+        if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+            ignore_value(virNetDevMidonetUnbindPort(vport));
+        } else if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+            ignore_value(virNetDevOpenvswitchRemovePort(
+                             virDomainNetGetActualBridgeName(net),
+                             net->ifname));
+        }
+    }
 
     networkReleaseActualDevice(vm->def, net);
     virDomainNetDefFree(net);
index ae315df09e0570a2800ac97e433ee1893a9404ce..c395b5b981686932e9e323145db71fa20f91c04f 100644 (file)
@@ -62,6 +62,7 @@
 #include "virprocess.h"
 #include "virtime.h"
 #include "virnetdevtap.h"
+#include "virnetdevmidonet.h"
 #include "virbitmap.h"
 #include "viratomic.h"
 #include "virnuma.h"
@@ -5235,10 +5236,15 @@ void qemuProcessStop(virQEMUDriverPtr driver,
         /* release the physical device (or any other resources used by
          * this interface in the network driver
          */
-        if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-            ignore_value(virNetDevOpenvswitchRemovePort(
-                                       virDomainNetGetActualBridgeName(net),
-                                       net->ifname));
+        if (vport) {
+            if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+                ignore_value(virNetDevMidonetUnbindPort(vport));
+            } else if (vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+                ignore_value(virNetDevOpenvswitchRemovePort(
+                                 virDomainNetGetActualBridgeName(net),
+                                 net->ifname));
+            }
+        }
 
         /* kick the device out of the hostdev list too */
         virDomainNetRemoveHostdev(def, net);
index 83b4131951496865516aacd0467e5847ce2d29ea..b34cbb7e8ad3a908f430bcb536c7b811e18811a6 100644 (file)
@@ -26,6 +26,7 @@
 #include "virnetdevtap.h"
 #include "virnetdev.h"
 #include "virnetdevbridge.h"
+#include "virnetdevmidonet.h"
 #include "virnetdevopenvswitch.h"
 #include "virerror.h"
 #include "virfile.h"
@@ -580,9 +581,13 @@ int virNetDevTapCreateInBridgePort(const char *brname,
         goto error;
 
     if (virtPortProfile) {
-        if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuuid,
-                                        virtPortProfile, virtVlan) < 0) {
-            goto error;
+        if (virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
+            if (virNetDevMidonetBindPort(*ifname, virtPortProfile) < 0)
+                goto error;
+        } else if (virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+            if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuuid,
+                                            virtPortProfile, virtVlan) < 0)
+                goto error;
         }
     } else {
         if (virNetDevBridgeAddPort(brname, *ifname) < 0)