[libvirt] [PATCH v2] nwfilter: extend nwfilter reload support
Daniel P. Berrange
berrange at redhat.com
Fri Aug 13 14:44:51 UTC 2010
On Thu, Aug 12, 2010 at 02:18:26PM -0400, Stefan Berger wrote:
> Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
> ===================================================================
> --- libvirt-acl.orig/src/nwfilter/nwfilter_driver.c
> +++ libvirt-acl/src/nwfilter/nwfilter_driver.c
> @@ -143,15 +143,25 @@ conf_init_err:
> */
> static int
> nwfilterDriverReload(void) {
> + virConnectPtr conn;
> if (!driverState) {
> return -1;
> }
>
> - nwfilterDriverLock(driverState);
> - virNWFilterPoolLoadAllConfigs(NULL,
> - &driverState->pools,
> - driverState->configDir);
> - nwfilterDriverUnlock(driverState);
> + conn = virConnectOpen("qemu:///system");
> +
> + if (conn) {
> + /* shut down all threads -- qemud for example will restart them */
> + virNWFilterLearnThreadsTerminate();
> +
> + nwfilterDriverLock(driverState);
> + virNWFilterPoolLoadAllConfigs(conn,
> + &driverState->pools,
> + driverState->configDir);
> + nwfilterDriverUnlock(driverState);
> +
> + virConnectClose(conn);
> + }
>
> return 0;
There's a small indentation issue here
> }
> Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
> ===================================================================
> --- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
> +++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
> @@ -855,6 +855,16 @@ virNWFilterLearnInit(void) {
> }
>
>
> +void
> +virNWFilterLearnThreadsTerminate() {
> + threadsTerminate = true;
> +
> + while (virHashSize(pendingLearnReq) != 0)
> + usleep((PKT_TIMEOUT_MS * 1000) / 3);
> +
> + threadsTerminate = false;
> +}
Is there any risk of thread's failing to terminate, requiring
us to kill them, or ignore them instead of blocking forever ?
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list