]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Remove the actual hostdev when removing a network
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Sep 2013 15:25:56 +0000 (17:25 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 4 Sep 2013 07:28:05 +0000 (09:28 +0200)
Commit 50348e6edfa reused the code to remove the hostdev portion of a
network definition on multiple places but forgot to take into account
that sometimes the "actual" network is passed and in some cases the
parent of that.

This patch uses the virDomainNetGetActualHostdev() helper to acquire the
correct pointer all the time while removing the hostdev portion from the
list.

src/conf/domain_conf.c

index e412f28dddebe10a1a20012217d7e9ec0ff29845..cef4cf948f8ddadd51237c452595cd612bd6ad03 100644 (file)
@@ -10002,14 +10002,14 @@ void
 virDomainNetRemoveHostdev(virDomainDefPtr def,
                           virDomainNetDefPtr net)
 {
-    if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
-        /* hostdev net devices are normally also be in the hostdevs
-         * array, but might have already been removed by the time we
-         * get here.
-         */
-        virDomainHostdevDefPtr hostdev = &net->data.hostdev.def;
-        size_t i;
+    /* hostdev net devices are normally also be in the hostdevs
+     * array, but might have already been removed by the time we
+     * get here.
+     */
+    virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
+    size_t i;
 
+    if (hostdev) {
         for (i = 0; i < def->nhostdevs; i++) {
             if (def->hostdevs[i] == hostdev) {
                 virDomainHostdevRemove(def, i);