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

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

 



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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]