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

Re: [libvirt] PATCH: 23/25: Add domain events to test driver



"Daniel P. Berrange" <berrange redhat com> wrote:
> This adds support for the domain events in the test driver. Code
> is following the same pattern as the impl in the QEMU driver.
>
>  test.c |  223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 217 insertions(+), 6 deletions(-)

ACK.
Looks fine.
One minor optimization below:

> diff --git a/src/test.c b/src/test.c
...
> @@ -924,6 +985,7 @@ static int testPauseDomain (virDomainPtr
>  {
>      testConnPtr privconn = domain->conn->privateData;
>      virDomainObjPtr privdom;
> +    virDomainEventPtr event = NULL;
>      int ret = -1;
>
>      testDriverLock(privconn);
> @@ -945,11 +1007,18 @@ static int testPauseDomain (virDomainPtr
>      }
>
>      privdom->state = VIR_DOMAIN_PAUSED;
> +    event = virDomainEventNewFromObj(privdom,
> +                                     VIR_DOMAIN_EVENT_SUSPENDED,
> +                                     VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
>      ret = 0;
>
>  cleanup:
>      if (privdom)
>          virDomainObjUnlock(privdom);
> +    testDriverLock(privconn);
> +    if (event)
> +        testDomainEventQueue(privconn, event);
> +    testDriverUnlock(privconn);

If event is NULL, don't fiddle with the lock at all:

       if (event) {
           testDriverLock(privconn);
           testDomainEventQueue(privconn, event);
           testDriverUnlock(privconn);
       }

There is at least one other just like this.


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