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

Jim Meyering jim at meyering.net
Tue Jan 20 13:40:59 UTC 2009


"Daniel P. Berrange" <berrange at 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.




More information about the libvir-list mailing list