Re: [libvirt PATCH v2 7/7] qemu: convert agent to use the per-VM event loop

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

 



On 5. 3. 2020 13:51, Daniel P. Berrangé wrote:
> This converts the QEMU agent APIs to use the per-VM
> event loop, which involves switching from virEvent APIs
> to GMainContext / GSource APIs.
> 
> A GSocket is used as a convenient way to create a GSource
> for a socket, but is not yet used for actual I/O.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
> ---
>  src/qemu/qemu_agent.c        | 146 +++++++++++++++++++----------------
>  src/qemu/qemu_agent.h        |   1 +
>  src/qemu/qemu_process.c      |   1 +
>  tests/qemumonitortestutils.c |   1 +
>  4 files changed, 84 insertions(+), 65 deletions(-)
> 


> @@ -498,28 +496,62 @@ qemuAgentIORead(qemuAgentPtr agent)
>  }
>  
>  
> -static void qemuAgentUpdateWatch(qemuAgentPtr agent)
> -{
> -    int events =
> -        VIR_EVENT_HANDLE_HANGUP |
> -        VIR_EVENT_HANDLE_ERROR;
> +static gboolean
> +qemuAgentIO(GSocket *socket,
> +            GIOCondition cond,
> +            gpointer opaque);
>  
> -    if (!agent->watch)
> -        return;
> +
> +static void
> +qemuAgentRegister(qemuAgentPtr agent)
> +{
> +    GIOCondition cond = 0;
>  
>      if (agent->lastError.code == VIR_ERR_OK) {
> -        events |= VIR_EVENT_HANDLE_READABLE;
> +        cond |= G_IO_IN;
>  
>          if (agent->msg && agent->msg->txOffset < agent->msg->txLength)
> -            events |= VIR_EVENT_HANDLE_WRITABLE;
> +            cond |= G_IO_OUT;
>      }
>  
> -    virEventUpdateHandle(agent->watch, events);
> +    agent->watch = g_socket_create_source(agent->socket,
> +                                        cond,
> +                                        NULL);
> +
> +    virObjectRef(agent);
> +    g_source_set_callback(agent->watch,
> +                          (GSourceFunc)qemuAgentIO,
> +                          agent,
> +                          NULL);

And again, this needs to be "(GDestroyNotify) virObjectUnref" instead of
NULL.

Michal





[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]

  Powered by Linux