xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 3/3] libxl, xl: fix bootloader immediate console attach
Date: Wed, 16 May 2012 16:25:14 +0100	[thread overview]
Message-ID: <1337181914-7199-4-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1337181914-7199-1-git-send-email-ian.jackson@eu.citrix.com>

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).

 * 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 <ian.jackson@eu.citrix.com>
---
 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);
-- 
1.7.2.5

  parent reply	other threads:[~2012-05-16 15:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 15:25 [PATCH 0/3] libxl: event handling fixes related to console/pygrub Roger Pau Monne <roger.pau@citrix.com> Ian Jackson
2012-05-16 15:25 ` [PATCH 1/3] libxl: events: debugging output relating to ao's Ian Jackson
2012-05-17 10:46   ` Ian Campbell
2012-05-18 11:11     ` Ian Jackson
2012-05-16 15:25 ` [PATCH 2/3] libxl: Do not use-after-free on ao progress reporting Ian Jackson
2012-05-17 10:49   ` Ian Campbell
2012-05-16 15:25 ` Ian Jackson [this message]
2012-05-17 10:51   ` [PATCH 3/3] libxl, xl: fix bootloader immediate console attach Ian Campbell
2012-05-17 13:46 ` [PATCH 0/3] libxl: event handling fixes related to console/pygrub Roger Pau Monne <roger.pau@citrix.com> Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337181914-7199-4-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).