[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH]util: Helper function for checking existence of hook files for specific driver



On Wed, Sep 25, 2013 at 05:50:47PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao cn fujitsu com>
> 
> We refresh the status of hook scripts
> only when start/restart libvirt or reloads its configuration.
> But hooks scripts may be changed.
> This function will help to check its existence.
> And we do not need to start/restart libvirt if
> we add/remove hook files.
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao cn fujitsu com>
> ---
>  src/util/virhook.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/util/virhook.c b/src/util/virhook.c
> index 159efdb..c4a1a15 100644
> --- a/src/util/virhook.c
> +++ b/src/util/virhook.c
> @@ -129,6 +129,12 @@ virHookCheck(int no, const char *driver) {
>      return ret;
>  }
>  
> +static int
> +virHookDriverCheck(int driver) {
> +    return virHookCheck(driver,
> +                        virHookDriverTypeToString(driver));
> +}
> +
>  /*
>   * virHookInitialize:
>   *
> @@ -170,11 +176,12 @@ virHookPresent(int driver) {
>      if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
>          (driver >= VIR_HOOK_DRIVER_LAST))
>          return 0;
> -    if (virHooksFound == -1)
> +    if (virHookDriverCheck(driver) != 1) {
> +        VIR_DEBUG("Driver %s hooks files not found",
> +                  virHookDriverTypeToString(driver));
>          return 0;
> +    }
>  
> -    if ((virHooksFound & (1 << driver)) == 0)
> -        return 0;
>      return 1;
>  }

This is no more thread safe than your previous patch.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]