From: Ian Campbell Subject: Re: [PATCH 3/3] libxl, xl: fix bootloader immediate console attach Date: Thu, 17 May 2012 11:51:31 +0100 Message-ID: <1337251891.7781.57.camel@zakaz.uk.xensource.com> References: <1337181914-7199-1-git-send-email-ian.jackson@eu.citrix.com> <1337181914-7199-4-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1337181914-7199-4-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2012-05-16 at 16:25 +0100, Ian Jackson wrote: > Fix bugs related to console handling: > > * In libxl_primary_console_exec, if libxl__domain_type fails, do > not abort, but instead log and return an error. This can occur > if the domid is invalid. > > * In xl's autoconnect_console, rename the ctx formal parameter so > that when postfork creates a new ctx and puts it in the global ctx, > we don't end up using the old one (via the formal parameter which > has shadowed the global). I'll refresh my "xl: remove all local "ctx" variables" after this goes in and resend the remainder (if there is any). > > * In xl's autoconnect_console, pass the domid from the event > to libxl_primary_console_exec, rather than using the global domid > (which has not yet been set, since it is only set at completion > of the ao). > > This causes xl create -c to once more work with pygrub. > > Signed-off-by: Ian Jackson Acked-by: Ian Campbell > --- > tools/libxl/libxl.c | 4 ++++ > tools/libxl/xl_cmdimpl.c | 6 ++++-- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index 4d01cf8..1e0105e 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -1188,6 +1188,10 @@ int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm) > case LIBXL_DOMAIN_TYPE_PV: > rc = libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE_PV); > break; > + case -1: > + LOG(ERROR,"unable to get domain type for domid=%"PRIu32,domid_vm); > + rc = ERROR_FAIL; > + break; > default: > abort(); > } > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 5fc5cde..9f182c2 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -1457,9 +1457,11 @@ static int freemem(libxl_domain_build_info *b_info) > return ERROR_NOMEM; > } > > -static void autoconnect_console(libxl_ctx *ctx, libxl_event *ev, void *priv) > +static void autoconnect_console(libxl_ctx *ctx_ignored, > + libxl_event *ev, void *priv) > { > pid_t *pid = priv; > + uint32_t bldomid = ev->domid; > > libxl_event_free(ctx, ev); > > @@ -1473,7 +1475,7 @@ static void autoconnect_console(libxl_ctx *ctx, libxl_event *ev, void *priv) > postfork(); > > sleep(1); > - libxl_primary_console_exec(ctx, domid); > + libxl_primary_console_exec(ctx, bldomid); > /* Do not return. xl continued in child process */ > fprintf(stderr, "Unable to attach console\n"); > _exit(1);