Blob Blame History Raw
From 0294bbbfa178f4328c4f95c2686210f1dd08b93d Mon Sep 17 00:00:00 2001
Message-Id: <0294bbbfa178f4328c4f95c2686210f1dd08b93d.1382534061.git.jdenemar@redhat.com>
From: Laine Stump <laine@laine.org>
Date: Mon, 21 Oct 2013 10:12:59 -0600
Subject: [PATCH] qemu: move qemuDomainRemoveNetDevice to avoid forward
 reference

This is a prerequisite for the fix to

    https://bugzilla.redhat.com/show_bug.cgi?id=1005682

pure code movement to setup for next patch.

(cherry picked from commit c5561644d8551d80d94b648b9ab828c9859e1667)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_hotplug.c | 122 ++++++++++++++++++++++++------------------------
 1 file changed, 61 insertions(+), 61 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index dcee86c..4d29e18 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2332,67 +2332,6 @@ qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver,
 
 
 static void
-qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
-                          virDomainObjPtr vm,
-                          virDomainNetDefPtr net)
-{
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virNetDevVPortProfilePtr vport;
-    virDomainEventPtr event;
-    size_t i;
-
-    VIR_DEBUG("Removing network interface %s from domain %p %s",
-              net->info.alias, vm, vm->def->name);
-
-    virDomainAuditNet(vm, net, NULL, "detach", true);
-
-    event = virDomainEventDeviceRemovedNewFromObj(vm, net->info.alias);
-    if (event)
-        qemuDomainEventQueue(driver, event);
-
-    for (i = 0; i < vm->def->nnets; i++) {
-        if (vm->def->nets[i] == net) {
-            virDomainNetRemove(vm->def, i);
-            break;
-        }
-    }
-
-    qemuDomainReleaseDeviceAddress(vm, &net->info, NULL);
-    virDomainConfNWFilterTeardown(net);
-
-    if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
-        ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
-                         net->ifname, &net->mac,
-                         virDomainNetGetActualDirectDev(net),
-                         virDomainNetGetActualDirectMode(net),
-                         virDomainNetGetActualVirtPortProfile(net),
-                         cfg->stateDir));
-        VIR_FREE(net->ifname);
-    }
-
-    if (cfg->macFilter && (net->ifname != NULL)) {
-        if ((errno = networkDisallowMacOnPort(driver,
-                                              net->ifname,
-                                              &net->mac))) {
-            virReportSystemError(errno,
-             _("failed to remove ebtables rule on '%s'"),
-                                 net->ifname);
-        }
-    }
-
-    vport = virDomainNetGetActualVirtPortProfile(net);
-    if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-        ignore_value(virNetDevOpenvswitchRemovePort(
-                        virDomainNetGetActualBridgeName(net),
-                        net->ifname));
-
-    networkReleaseActualDevice(net);
-    virDomainNetDefFree(net);
-    virObjectUnref(cfg);
-}
-
-
-static void
 qemuDomainRemovePCIHostDevice(virQEMUDriverPtr driver,
                               virDomainObjPtr vm,
                               virDomainHostdevDefPtr hostdev)
@@ -2523,6 +2462,67 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
 
 
 static void
+qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
+                          virDomainObjPtr vm,
+                          virDomainNetDefPtr net)
+{
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    virNetDevVPortProfilePtr vport;
+    virDomainEventPtr event;
+    size_t i;
+
+    VIR_DEBUG("Removing network interface %s from domain %p %s",
+              net->info.alias, vm, vm->def->name);
+
+    virDomainAuditNet(vm, net, NULL, "detach", true);
+
+    event = virDomainEventDeviceRemovedNewFromObj(vm, net->info.alias);
+    if (event)
+        qemuDomainEventQueue(driver, event);
+
+    for (i = 0; i < vm->def->nnets; i++) {
+        if (vm->def->nets[i] == net) {
+            virDomainNetRemove(vm->def, i);
+            break;
+        }
+    }
+
+    qemuDomainReleaseDeviceAddress(vm, &net->info, NULL);
+    virDomainConfNWFilterTeardown(net);
+
+    if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
+        ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
+                         net->ifname, &net->mac,
+                         virDomainNetGetActualDirectDev(net),
+                         virDomainNetGetActualDirectMode(net),
+                         virDomainNetGetActualVirtPortProfile(net),
+                         cfg->stateDir));
+        VIR_FREE(net->ifname);
+    }
+
+    if (cfg->macFilter && (net->ifname != NULL)) {
+        if ((errno = networkDisallowMacOnPort(driver,
+                                              net->ifname,
+                                              &net->mac))) {
+            virReportSystemError(errno,
+             _("failed to remove ebtables rule on '%s'"),
+                                 net->ifname);
+        }
+    }
+
+    vport = virDomainNetGetActualVirtPortProfile(net);
+    if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
+        ignore_value(virNetDevOpenvswitchRemovePort(
+                        virDomainNetGetActualBridgeName(net),
+                        net->ifname));
+
+    networkReleaseActualDevice(net);
+    virDomainNetDefFree(net);
+    virObjectUnref(cfg);
+}
+
+
+static void
 qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
                           virDomainChrDefPtr chr)
-- 
1.8.4