[libvirt] [PATCH libvirt v2 2/9] test: Convert testDriver to virObjectLockable

John Ferlan jferlan at redhat.com
Thu Apr 26 15:07:12 UTC 2018



On 04/12/2018 08:40 AM, Marc Hartmayer wrote:
> The test driver state (@testDriver) uses it's own reference counting
> and locking implementation. Instead of doing that, convert @testDriver
> into a virObjectLockable and use the provided functionalities.
> 
> Signed-off-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
> ---
>  src/test/test_driver.c | 200 ++++++++++++++++++++++---------------------------
>  1 file changed, 90 insertions(+), 110 deletions(-)
> 
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 856869c9d3a9..1a219316e7c5 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -94,7 +94,7 @@ typedef struct _testAuth testAuth;
>  typedef struct _testAuth *testAuthPtr;
>  
>  struct _testDriver {
> -    virMutex lock;
> +    virObjectLockable parent;
>  
>      virNodeInfo nodeInfo;
>      virInterfaceObjListPtr ifaces;
> @@ -126,9 +126,22 @@ typedef struct _testDriver testDriver;
>  typedef testDriver *testDriverPtr;
>  
>  static testDriverPtr defaultPrivconn;
> -static int defaultConnections;
>  static virMutex defaultLock = VIR_MUTEX_INITIALIZER;
>  
> +static virClassPtr testDriverClass;
> +static void testDriverDispose(void *obj);
> +static int testDriverOnceInit(void)
> +{
> +    if (!(testDriverClass = virClassNew(virClassForObjectLockable(),
> +                                        "testDriver",
> +                                        sizeof(testDriver),
> +                                        testDriverDispose)))

Probably posted/pushed after this posting, but commit id '10f94828'
added a new VIR_CLASS_NEW definition and commit id '825bb9b8' required
using it.

Simple to change:

    if (!(VIR_CLASS_NEW(testDriver, virClassForObjectLockable())))

But figured you should know.

> +        return -1;
> +
> +    return 0;
> +}
> +VIR_ONCE_GLOBAL_INIT(testDriver)
> +

Reviewed-by: John Ferlan <jferlan at redhat.com>

John




More information about the libvir-list mailing list