Re: [PATCH sandbox 4/4] Don't close immediately when getting EOF on RPC console

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

 



On Fri, 2015-09-04 at 12:40 +0100, Daniel P. Berrange wrote:
> The RPC console is closed when the libvirt-sandbox-init-common
> binary reports the exit of the guest process. We still have
> some cleanup code that runs in the guest, for example, syncing
> and ummounting filesystems. We want to be able to see debug
> and/or error messages from this code, so we should not quit
> until we get a close on that console. This should happen a
> few ms after the close on the RPC console, but just in case
> something causes shutdown to hang, we have a delayed timer
> registered.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  bin/virt-sandbox.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c
> index 195515f..332e53e 100644
> --- a/bin/virt-sandbox.c
> +++ b/bin/virt-sandbox.c
> @@ -34,6 +34,22 @@ static gboolean do_close(GVirSandboxConsole *con G_GNUC_UNUSED,
>      return FALSE;
>  }
>  
> +static gboolean do_delayed_close(gpointer opaque)
> +{
> +    GMainLoop *loop = opaque;
> +    g_main_loop_quit(loop);
> +    return FALSE;
> +}
> +
> +static gboolean do_pending_close(GVirSandboxConsole *con G_GNUC_UNUSED,
> +                                 gboolean error G_GNUC_UNUSED,
> +                                 gpointer opaque)
> +{
> +    GMainLoop *loop = opaque;
> +    g_timeout_add(2000, do_delayed_close, loop);
> +    return FALSE;
> +}
> +
>  static gboolean do_exited(GVirSandboxConsole *con G_GNUC_UNUSED,
>                            int status,
>                            gpointer opaque)
> @@ -256,7 +272,12 @@ int main(int argc, char **argv) {
>                     error && error->message ? error->message : _("Unknown failure"));
>          goto cleanup;
>      }
> -    g_signal_connect(con, "closed", (GCallback)do_close, loop);
> +    /* We don't close right away - we want to ensure we read any
> +     * final debug info from the log console. We should get an
> +     * EOF on that console which will trigger the real close,
> +     * but we schedule a timer just in case.
> +     */
> +    g_signal_connect(con, "closed", (GCallback)do_pending_close, loop);
>      g_signal_connect(con, "exited", (GCallback)do_exited, &ret);
>  
>      if (!(gvir_sandbox_console_attach_stdio(con, &error))) {

ACK

--
Cedric


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