Signed-off-by: Rafael Fonseca <r4f4rfs@xxxxxxxxx> --- src/conf/nwfilter_conf.c | 21 +++++++++++---------- src/conf/nwfilter_conf.h | 5 ++++- src/libvirt_private.syms | 3 ++- src/lxc/lxc_driver.c | 4 ++-- src/nwfilter/nwfilter_driver.c | 6 +++--- src/nwfilter/nwfilter_gentech_driver.c | 2 +- src/qemu/qemu_driver.c | 12 ++++++------ src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_process.c | 4 ++-- 9 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 680f4184c3..405cedd002 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -154,27 +154,33 @@ static const struct int_map chain_priorities[] = { /* * only one filter update allowed */ -static virRWLock updateLock; +static GRWLock updateLock; static bool initialized; void virNWFilterReadLockFilterUpdates(void) { - virRWLockRead(&updateLock); + g_rw_lock_reader_lock(&updateLock); } void virNWFilterWriteLockFilterUpdates(void) { - virRWLockWrite(&updateLock); + g_rw_lock_writer_lock(&updateLock); } void -virNWFilterUnlockFilterUpdates(void) +virNWFilterReadUnlockFilterUpdates(void) { - virRWLockUnlock(&updateLock); + g_rw_lock_reader_unlock(&updateLock); +} + +void +virNWFilterWriteUnlockFilterUpdates(void) +{ + g_rw_lock_writer_unlock(&updateLock); } @@ -3090,9 +3096,6 @@ virNWFilterConfLayerInit(virNWFilterTriggerRebuildCallback cb, initialized = true; - if (virRWLockInit(&updateLock) < 0) - return -1; - return 0; } @@ -3103,8 +3106,6 @@ virNWFilterConfLayerShutdown(void) if (!initialized) return; - virRWLockDestroy(&updateLock); - initialized = false; rebuildCallback = NULL; rebuildOpaque = NULL; diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 13db58e380..875c3a1e0d 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -582,7 +582,10 @@ void virNWFilterReadLockFilterUpdates(void); void -virNWFilterUnlockFilterUpdates(void); +virNWFilterWriteUnlockFilterUpdates(void); + +void +virNWFilterReadUnlockFilterUpdates(void); typedef int (*virNWFilterTriggerRebuildCallback)(void *opaque); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ec367653d5..c95c1a078c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -874,6 +874,7 @@ virNWFilterJumpTargetTypeToString; virNWFilterPrintStateMatchFlags; virNWFilterPrintTCPFlags; virNWFilterReadLockFilterUpdates; +virNWFilterReadUnlockFilterUpdates; virNWFilterRuleActionTypeToString; virNWFilterRuleDirectionTypeToString; virNWFilterRuleIsProtocolEthernet; @@ -882,8 +883,8 @@ virNWFilterRuleIsProtocolIPv6; virNWFilterRuleProtocolTypeToString; virNWFilterSaveConfig; virNWFilterTriggerRebuild; -virNWFilterUnlockFilterUpdates; virNWFilterWriteLockFilterUpdates; +virNWFilterWriteUnlockFilterUpdates; # conf/nwfilter_ipaddrmap.h diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 851894c459..7b232b4bac 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1030,7 +1030,7 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom, virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return ret; } @@ -1158,7 +1158,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(caps); virObjectUnref(cfg); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return dom; } diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 1c407727db..650ef19746 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -333,7 +333,7 @@ nwfilterStateReload(void) virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir); - virNWFilterUnlockFilterUpdates(); + virNWFilterWriteUnlockFilterUpdates(); virNWFilterBuildAll(driver, false); @@ -602,7 +602,7 @@ nwfilterDefineXML(virConnectPtr conn, if (obj) virNWFilterObjUnlock(obj); - virNWFilterUnlockFilterUpdates(); + virNWFilterWriteUnlockFilterUpdates(); nwfilterDriverUnlock(); return nwfilter; } @@ -643,7 +643,7 @@ nwfilterUndefine(virNWFilterPtr nwfilter) if (obj) virNWFilterObjUnlock(obj); - virNWFilterUnlockFilterUpdates(); + virNWFilterWriteUnlockFilterUpdates(); nwfilterDriverUnlock(); return ret; } diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 6789a4a3fa..4b369e5b1a 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -807,7 +807,7 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverStatePtr driver, } } - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); virMutexUnlock(&updateMutex); return rc; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31f199fdef..d6ed6d3b3f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1796,7 +1796,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn, virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); virObjectEventStateQueue(driver->domainEventState, event2); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return dom; } @@ -7053,7 +7053,7 @@ qemuDomainRestoreFlags(virConnectPtr conn, if (vm && ret < 0) qemuDomainRemoveInactiveJob(driver, vm); virDomainObjEndAPI(&vm); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return ret; } @@ -7590,7 +7590,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) cleanup: virDomainObjEndAPI(&vm); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return ret; } @@ -8802,7 +8802,7 @@ qemuDomainAttachDeviceFlags(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return ret; } @@ -8920,7 +8920,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, virDomainDeviceDefFree(dev_copy); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); return ret; } @@ -16695,7 +16695,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, virObjectEventStateQueue(driver->domainEventState, event); virObjectEventStateQueue(driver->domainEventState, event2); virDomainObjEndAPI(&vm); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); virCPUDefFree(origCPU); virDomainDefFree(config); virDomainDefFree(inactiveConfig); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index bc280e856a..5057aa2528 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2716,7 +2716,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, virDomainObjEndAPI(&vm); virObjectEventStateQueue(driver->domainEventState, event); qemuMigrationCookieFree(mig); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); virErrorRestore(&origErr); return ret; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8ea470f75f..803994afe8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8196,7 +8196,7 @@ qemuProcessReconnect(void *opaque) qemuDomainRemoveInactiveJob(driver, obj); } virDomainObjEndAPI(&obj); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); virIdentitySetCurrent(NULL); return; @@ -8272,7 +8272,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj, qemuDomainRemoveInactiveJobLocked(src->driver, obj); virDomainObjEndAPI(&obj); - virNWFilterUnlockFilterUpdates(); + virNWFilterReadUnlockFilterUpdates(); g_clear_object(&data->identity); VIR_FREE(data); return -1; -- 2.25.2