]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
libxl: preserve console tty across soft reset
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 22 Mar 2017 13:59:44 +0000 (14:59 +0100)
committerWei Liu <wei.liu2@citrix.com>
Thu, 23 Mar 2017 12:01:24 +0000 (12:01 +0000)
On soft reset we remove the domain from xenstore and introduce it back to
have everything reconnected. Console, however, stays attached (as xenconsoled
checks if the domain is dying and our domain is not) but we lose the
information about tty:

before soft reset:
   console = ""
    ...
    type = "xenconsoled"
    output = "pty"
    tty = "/dev/pts/1"
    ...

after:
   console = ""
    ...
    type = "xenconsoled"
    output = "pty"
    tty = ""
    ...

The issue applies to both HVM and PVH but for HVM guests serial console
through QEMU is usually in use and for PVH we don't have it.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_console.c
tools/libxl/libxl_create.c
tools/libxl/libxl_internal.h

index cbc70b74102620ea7d88930f8a57f09bf600df2e..446e766911f87d0bd18fcf91e9401d77c6a26daf 100644 (file)
@@ -316,7 +316,10 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
     flexarray_append(ro_front, "output");
     flexarray_append(ro_front, console->output);
     flexarray_append(ro_front, "tty");
-    flexarray_append(ro_front, "");
+    if (state && state->console_tty)
+        flexarray_append(ro_front, state->console_tty);
+    else
+        flexarray_append(ro_front, "");
 
     if (state) {
         flexarray_append(ro_front, "port");
index 95fd96b29cce838a430a8fd58eac14b25ee0a5a9..46b80b216a402e4ee89ca8204345af5388f3145c 100644 (file)
@@ -1697,6 +1697,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     libxl__domain_build_state *state;
     libxl__domain_save_state *dss;
     char *dom_path, *xs_store_mfn, *xs_console_mfn;
+    const char *console_tty;
     uint32_t domid_out;
     int rc;
 
@@ -1737,6 +1738,15 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     state->console_mfn = xs_console_mfn ? atol(xs_console_mfn): 0;
     free(xs_console_mfn);
 
+    rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+                                  GCSPRINTF("%s/console/tty", dom_path),
+                                  &console_tty);
+    if (rc) {
+        LOGD(ERROR, domid_soft_reset, "failed to read console/tty.");
+        goto out;
+    }
+    state->console_tty = libxl__strdup(gc, console_tty);
+
     dss->ao = ao;
     dss->domid = dss->dsps.domid = domid_soft_reset;
     dss->dsps.dm_savefile = GCSPRINTF(LIBXL_DEVICE_MODEL_SAVE_FILE".%d",
index 25cb08ac2d407bf53945c49bbf3c9142e109c73b..f1d8f9a03c68cf9e1e0435093e53a2e52a7d0065 100644 (file)
@@ -1123,6 +1123,7 @@ typedef struct {
     uint32_t console_port;
     uint32_t console_domid;
     unsigned long console_mfn;
+    char *console_tty;
 
     char *saved_state;