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

Re: [PATCH 3/3] tools/xl: move some logic needed only once earlier in


  • To: ehem+xen@xxxxxxx
  • From: chunjie.zhu@xxxxxxxxxx
  • Date: Fri, 16 Oct 2026 13:07:21 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i3KqU4Zic7f+WsVGd29gdNe6+S4IF+atkhQGf6BfB+o=; b=TO25cLfybF5nr8lsWaQ6+9cBJCXMeUJta0YyxdUZ4SnJOUbM+tHSfQLxWGAjNojPaCxiXJc4qR39zrFgGsiiaYHKQJ9Gvm8rW+fVNL9X64ib3xkhZzdyf/e8ni0zAgSvOtm6c7qPLDWsLvF8nOwy56bO3NgVjdlgJaf3Zd79/2jgfRTGoATK5vgEk+UPmU8pUe04rDWBS3vs9ZfdbZmvcp+Nz40fV6aoPa8cwSGLA4vzLFFkSbuz3CVdcLdCcAvtxUnzXDocYLm81w5y2Gl+nAlvqOc/4l7z5eQjE7sYmGgJyHj4lzoyIaylnefS4EyQQXIkALJUtszeF33ArLktgQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QB8KqD7/c/kkSd2S1GjaQzAWuaAxMNv5eKnCxgRbMBnAhgD6MEhJhBZv8zXvSEHE4zlxGaQuHM6XXFgXaAheH3AGJzNROw01Y1SrNPur75YzUzLMiGY5Uhfygvt7PzUf/6n+gVVqrucC4lTERtO8CgKLbFlsuxhhUi/PB9xK5lRsrie27Lmn/a3tSXncUKnqpT76GjptzqOTDnw3vQ/6naj4O44AsRLSjjBbFAoaqu7klm9cpN6SXjO4Xkh+Y1tSa+jcUqECU1ywdfnH3Cz66ad7L6HJLvt7olDm2DD8PTRtoLbmLmLKCIrfQLOcjkDiAvKhpM27IvuhI1JsUmBSrA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-Id:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: anthony.perard@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 16 Oct 2026 05:10:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Oct 12, 2026 at 06:03:49 PM, Elliott Mitchell <ehem+xen@xxxxxxx> wrote:

> The value of dom_info->console_autoconnect isn't going to change if a
> domain is rebooted.  Nor does this logic need the lock to be held.  As
> such moving this earlier makes sense.
>
> The policy domain is set once and then never changed.  Similar to above
> simply move before the reboot start point.
>
> Signed-off-by: Elliott Mitchell <ehem+xen@xxxxxxx>
> ---
>  tools/xl/xl_vmcontrol.c | 32 +++++++++++++++-----------------
>  1 file changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
> index 76c2a07ee8..ae7985122f 100644
> --- a/tools/xl/xl_vmcontrol.c
> +++ b/tools/xl/xl_vmcontrol.c
> @@ -717,7 +717,8 @@ int create_domain(struct domain_create *dom_info)
>      int restore_fd = -1;
>      int restore_fd_to_close = -1;
>      int send_back_fd = -1;
> -    const libxl_asyncprogress_how *autoconnect_console_how;
> +    const libxl_asyncprogress_how *autoconnect_console_how = NULL;
> +    libxl_asyncprogress_how autoconnect_console_how_buf;
>      int notify_pipe[2] = { -1, -1 };
>      struct save_file_header hdr;
>      uint32_t domid_soft_reset = INVALID_DOMID;
> @@ -921,6 +922,19 @@ int create_domain(struct domain_create *dom_info)
>      if (dryrun_only)
>          goto out;
>
> +    if (dom_info->console_autoconnect) {
> +        if (libxl_pipe(ctx, notify_pipe)) {
> +            ret = ERROR_FAIL;
> +            goto error_out;
> +        }

It looks like a functional regression for the reboot path. Right before
"goto start;" on the guest-reboot path there is:

    /*
     * Do not attempt to reconnect if we come round again due to a
     * guest reboot -- the stdin/out will be disconnected by then.
     */
    dom_info->console_autoconnect = 0;

On reboot, dom_info->console_autoconnect is cleared before "goto start",
but autoconnect_console_how now stays non-NULL, since it is no longer
recomputed after "start:". The second create call will invoke
autoconnect_console with the already-closed notify_pipe[1], and the
read(notify_pipe[0]) will fail with EBADF.

> +        autoconnect_console_how_buf.callback = autoconnect_console;
> +        autoconnect_console_how_buf.for_callback = &notify_pipe[1];
> +        autoconnect_console_how = &autoconnect_console_how_buf;
> +    }
> +
> +    if (!libxl_domid_valid_guest(d_config.c_info.domid))
> +        d_config.c_info.domid = domid_policy;
> +
>  start:
>      assert(domid == INVALID_DOMID);
>
> @@ -938,22 +952,6 @@ start:
>          }
>      }
>
> -    libxl_asyncprogress_how autoconnect_console_how_buf;
> -    if ( dom_info->console_autoconnect ) {
> -        if (libxl_pipe(ctx, notify_pipe)) {
> -            ret = ERROR_FAIL;
> -            goto error_out;
> -        }
> -        autoconnect_console_how_buf.callback = autoconnect_console;
> -        autoconnect_console_how_buf.for_callback = &notify_pipe[1];
> -        autoconnect_console_how = &autoconnect_console_how_buf;
> -    }else{
> -        autoconnect_console_how = 0;
> -    }
> -
> -    if (!libxl_domid_valid_guest(d_config.c_info.domid))
> -        d_config.c_info.domid = domid_policy;
> -
>      if ( restoring ) {
>          libxl_domain_restore_params params;
>
> -- 
> 2.47.3
>
>
>




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.