Blame SOURCES/libvirt-nwfilter-fix-deadlock-caused-updating-network-device-and-nwfilter.patch

9119d9
From 3188a720b9f7d9335af7718862ca96f1cae6d4b1 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <3188a720b9f7d9335af7718862ca96f1cae6d4b1@dist-git>
9119d9
From: Pavel Hrdina <phrdina@redhat.com>
9119d9
Date: Thu, 13 Nov 2014 11:19:10 +0100
9119d9
Subject: [PATCH] nwfilter: fix deadlock caused updating network device and
9119d9
 nwfilter
9119d9
9119d9
Commit 6e5c79a1 tried to fix deadlock between nwfilter{Define,Undefine}
9119d9
and starting of guest, but this same deadlock exists for
9119d9
updating/attaching network device to domain.
9119d9
9119d9
The deadlock was introduced by removing global QEMU driver lock because
9119d9
nwfilter was counting on this lock and ensure that all driver locks are
9119d9
locked inside of nwfilter{Define,Undefine}.
9119d9
9119d9
This patch extends usage of virNWFilterReadLockFilterUpdates to prevent
9119d9
the deadlock for all possible paths in QEMU driver. LXC and UML drivers
9119d9
still have global lock.
9119d9
9119d9
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1143780
9119d9
9119d9
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9119d9
(cherry picked from commit 41127244fb90f08cf5032a5d7553f5f0390d925e)
9119d9
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_driver.c    | 12 ++++++++++++
9119d9
 src/qemu/qemu_migration.c |  4 ++++
9119d9
 src/qemu/qemu_process.c   |  5 +++++
9119d9
 3 files changed, 21 insertions(+)
9119d9
9119d9
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
9119d9
index d419689..6ed830c 100644
9119d9
--- a/src/qemu/qemu_driver.c
9119d9
+++ b/src/qemu/qemu_driver.c
9119d9
@@ -5902,6 +5902,8 @@ qemuDomainRestoreFlags(virConnectPtr conn,
9119d9
                   VIR_DOMAIN_SAVE_PAUSED, -1);
9119d9
 
9119d9
 
9119d9
+    virNWFilterReadLockFilterUpdates();
9119d9
+
9119d9
     fd = qemuDomainSaveImageOpen(driver, path, &def, &header, &xml,
9119d9
                                  (flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0,
9119d9
                                  &wrapperFd, false, false);
9119d9
@@ -5979,6 +5981,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
9119d9
     virFileWrapperFdFree(wrapperFd);
9119d9
     if (vm)
9119d9
         virObjectUnlock(vm);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
     return ret;
9119d9
 }
9119d9
 
9119d9
@@ -7412,6 +7415,8 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
9119d9
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
9119d9
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
9119d9
 
9119d9
+    virNWFilterReadLockFilterUpdates();
9119d9
+
9119d9
     cfg = virQEMUDriverGetConfig(driver);
9119d9
 
9119d9
     affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
9119d9
@@ -7528,6 +7533,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
9119d9
         virObjectUnlock(vm);
9119d9
     virObjectUnref(caps);
9119d9
     virObjectUnref(cfg);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
     return ret;
9119d9
 }
9119d9
 
9119d9
@@ -7558,6 +7564,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
9119d9
                   VIR_DOMAIN_AFFECT_CONFIG |
9119d9
                   VIR_DOMAIN_DEVICE_MODIFY_FORCE, -1);
9119d9
 
9119d9
+    virNWFilterReadLockFilterUpdates();
9119d9
+
9119d9
     cfg = virQEMUDriverGetConfig(driver);
9119d9
 
9119d9
     affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
9119d9
@@ -7674,6 +7682,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
9119d9
         virObjectUnlock(vm);
9119d9
     virObjectUnref(caps);
9119d9
     virObjectUnref(cfg);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
     return ret;
9119d9
 }
9119d9
 
9119d9
@@ -14415,6 +14424,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
9119d9
      * and use of FORCE can cause multiple transitions.
9119d9
      */
9119d9
 
9119d9
+    virNWFilterReadLockFilterUpdates();
9119d9
+
9119d9
     if (!(vm = qemuDomObjFromSnapshot(snapshot)))
9119d9
         return -1;
9119d9
 
9119d9
@@ -14736,6 +14747,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
9119d9
         virObjectUnlock(vm);
9119d9
     virObjectUnref(caps);
9119d9
     virObjectUnref(cfg);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
 
9119d9
     return ret;
9119d9
 }
9119d9
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
9119d9
index 98fd376..d6c8553 100644
9119d9
--- a/src/qemu/qemu_migration.c
9119d9
+++ b/src/qemu/qemu_migration.c
9119d9
@@ -57,6 +57,7 @@
9119d9
 #include "virstring.h"
9119d9
 #include "virtypedparam.h"
9119d9
 #include "virprocess.h"
9119d9
+#include "nwfilter_conf.h"
9119d9
 
9119d9
 #define VIR_FROM_THIS VIR_FROM_QEMU
9119d9
 
9119d9
@@ -2525,6 +2526,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
9119d9
     if (virTimeMillisNow(&now) < 0)
9119d9
         return -1;
9119d9
 
9119d9
+    virNWFilterReadLockFilterUpdates();
9119d9
+
9119d9
     if (flags & VIR_MIGRATE_OFFLINE) {
9119d9
         if (flags & (VIR_MIGRATE_NON_SHARED_DISK |
9119d9
                      VIR_MIGRATE_NON_SHARED_INC)) {
9119d9
@@ -2834,6 +2837,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
9119d9
         qemuDomainEventQueue(driver, event);
9119d9
     qemuMigrationCookieFree(mig);
9119d9
     virObjectUnref(caps);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
     return ret;
9119d9
 
9119d9
  stop:
9119d9
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
9119d9
index ed095a2..9c640f0 100644
9119d9
--- a/src/qemu/qemu_process.c
9119d9
+++ b/src/qemu/qemu_process.c
9119d9
@@ -68,6 +68,7 @@
9119d9
 #include "virhostdev.h"
9119d9
 #include "storage/storage_driver.h"
9119d9
 #include "configmake.h"
9119d9
+#include "nwfilter_conf.h"
9119d9
 
9119d9
 #define VIR_FROM_THIS VIR_FROM_QEMU
9119d9
 
9119d9
@@ -3420,6 +3421,8 @@ qemuProcessReconnect(void *opaque)
9119d9
 
9119d9
     VIR_FREE(data);
9119d9
 
9119d9
+    virNWFilterReadLockFilterUpdates();
9119d9
+
9119d9
     virObjectLock(obj);
9119d9
 
9119d9
     cfg = virQEMUDriverGetConfig(driver);
9119d9
@@ -3571,6 +3574,7 @@ qemuProcessReconnect(void *opaque)
9119d9
 
9119d9
     virObjectUnref(conn);
9119d9
     virObjectUnref(cfg);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
 
9119d9
     return;
9119d9
 
9119d9
@@ -3606,6 +3610,7 @@ qemuProcessReconnect(void *opaque)
9119d9
     }
9119d9
     virObjectUnref(conn);
9119d9
     virObjectUnref(cfg);
9119d9
+    virNWFilterUnlockFilterUpdates();
9119d9
 }
9119d9
 
9119d9
 static int
9119d9
-- 
9119d9
2.1.3
9119d9