All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] libxl: fix soft reset for PVHv2 guests
@ 2017-03-20 18:03 Vitaly Kuznetsov
  2017-03-20 18:03 ` [PATCH 1/2] libxl: don't try to rename dm save file for PVH Vitaly Kuznetsov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2017-03-20 18:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson

Hi,

I'm trying to make kexec/kdump work for PVHv2 guests too. PVHv2 guests are
almost HVM guests so no major changes to the soft reset procedures are
required. A few issues, however, arose during testing.

Linux also requires some changes to boot after kexec. As PVH guests boot
like normal HVM guests after kexec we need to detect their 'PVH-ness'
somehow here's a hack which utilizes XEN_IOPORT_MAGIC:

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index ec1d5c4..b9f3fdf 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -51,6 +51,7 @@
 #include <xen/hvm.h>
 #include <xen/hvc-console.h>
 #include <xen/acpi.h>
+#include <xen/platform_pci.h>
 
 #include <asm/paravirt.h>
 #include <asm/apic.h>
@@ -1765,6 +1766,19 @@ void __init xen_prepare_pvh(void)
 
        x86_init.oem.arch_setup = xen_pvh_arch_setup;
 }
+
+static void xen_detect_pvh(void) {
+       short magic;
+
+       if (xen_pvh)
+               return;
+
+       magic = inw(XEN_IOPORT_MAGIC);
+       if (magic != XEN_IOPORT_MAGIC_VAL) {
+               xen_pvh = 1;
+               xen_pvh_arch_setup();
+       }
+}
 #endif
 
 void __ref xen_hvm_init_shared_info(void)
@@ -1912,6 +1926,9 @@ static void __init xen_hvm_guest_init(void)
 
        init_hvm_pv_info();
 
+       /* Detect PVH booting after kexec */
+       xen_detect_pvh();
+
        xen_hvm_init_shared_info();
 
        xen_panic_handler_init();

With the hack I was able to do kdump on a PVHv2 guest. I'll start a separate
mail thread to discuss how we should do it right.

Vitaly Kuznetsov (2):
  libxl: don't try to rename dm save file for PVH
  libxl: preserve console tty across soft reset

 tools/libxl/libxl_console.c  |  5 ++++-
 tools/libxl/libxl_create.c   | 24 +++++++++++++++++-------
 tools/libxl/libxl_internal.h |  1 +
 3 files changed, 22 insertions(+), 8 deletions(-)

-- 
2.9.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 1/2] libxl: don't try to rename dm save file for PVH
  2017-03-20 18:03 [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Vitaly Kuznetsov
@ 2017-03-20 18:03 ` Vitaly Kuznetsov
  2017-03-21 17:03   ` Wei Liu
  2017-03-20 18:03 ` [PATCH 2/2] libxl: preserve console tty across soft reset Vitaly Kuznetsov
  2017-03-22 11:30 ` [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Wei Liu
  2 siblings, 1 reply; 7+ messages in thread
From: Vitaly Kuznetsov @ 2017-03-20 18:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson

Guests with LIBXL_DEVICE_MODEL_VERSION_NONE don't have a device model
running so there is no save file to rename.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 tools/libxl/libxl_create.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 25389e1..95fd96b 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1664,12 +1664,16 @@ static void domain_soft_reset_cb(libxl__egc *egc,
         goto error;
     }
 
-    savefile = GCSPRINTF(LIBXL_DEVICE_MODEL_SAVE_FILE".%d", dds->domid);
-    restorefile = GCSPRINTF(LIBXL_DEVICE_MODEL_RESTORE_FILE".%d", dds->domid);
-    rc = rename(savefile, restorefile);
-    if (rc) {
-        LOGD(ERROR, dds->domid, "failed to rename dm save file.");
-        goto error;
+    if (cdcs->dcs.guest_config->b_info.device_model_version !=
+        LIBXL_DEVICE_MODEL_VERSION_NONE) {
+        savefile = GCSPRINTF(LIBXL_DEVICE_MODEL_SAVE_FILE".%d", dds->domid);
+        restorefile = GCSPRINTF(LIBXL_DEVICE_MODEL_RESTORE_FILE".%d",
+                                dds->domid);
+        rc = rename(savefile, restorefile);
+        if (rc) {
+            LOGD(ERROR, dds->domid, "failed to rename dm save file.");
+            goto error;
+        }
     }
 
     initiate_domain_create(egc, &cdcs->dcs);
-- 
2.9.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] libxl: preserve console tty across soft reset
  2017-03-20 18:03 [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Vitaly Kuznetsov
  2017-03-20 18:03 ` [PATCH 1/2] libxl: don't try to rename dm save file for PVH Vitaly Kuznetsov
@ 2017-03-20 18:03 ` Vitaly Kuznetsov
  2017-03-21 17:03   ` Wei Liu
  2017-03-22 11:30 ` [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Wei Liu
  2 siblings, 1 reply; 7+ messages in thread
From: Vitaly Kuznetsov @ 2017-03-20 18:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson

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>
---
 tools/libxl/libxl_console.c  | 5 ++++-
 tools/libxl/libxl_create.c   | 8 +++++++-
 tools/libxl/libxl_internal.h | 1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index cbc70b7..446e766 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -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");
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 95fd96b..ad8a424 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1696,7 +1696,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     libxl__domain_create_state *dcs;
     libxl__domain_build_state *state;
     libxl__domain_save_state *dss;
-    char *dom_path, *xs_store_mfn, *xs_console_mfn;
+    char *dom_path, *xs_store_mfn, *xs_console_mfn, *xs_console_tty;
     uint32_t domid_out;
     int rc;
 
@@ -1737,6 +1737,12 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     state->console_mfn = xs_console_mfn ? atol(xs_console_mfn): 0;
     free(xs_console_mfn);
 
+    xs_console_tty = xs_read(ctx->xsh, XBT_NULL,
+                             GCSPRINTF("%s/console/tty", dom_path),
+                             NULL);
+    state->console_tty = libxl__strdup(gc, xs_console_tty);
+    free(xs_console_tty);
+
     dss->ao = ao;
     dss->domid = dss->dsps.domid = domid_soft_reset;
     dss->dsps.dm_savefile = GCSPRINTF(LIBXL_DEVICE_MODEL_SAVE_FILE".%d",
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 7722665..88fca8e 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1123,6 +1123,7 @@ typedef struct {
     uint32_t console_port;
     uint32_t console_domid;
     unsigned long console_mfn;
+    char *console_tty;
 
     char *saved_state;
 
-- 
2.9.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] libxl: preserve console tty across soft reset
  2017-03-20 18:03 ` [PATCH 2/2] libxl: preserve console tty across soft reset Vitaly Kuznetsov
@ 2017-03-21 17:03   ` Wei Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Liu @ 2017-03-21 17:03 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: Wei Liu, Ian Jackson, xen-devel

On Mon, Mar 20, 2017 at 07:03:11PM +0100, Vitaly Kuznetsov wrote:
>  
> @@ -1737,6 +1737,12 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
>      state->console_mfn = xs_console_mfn ? atol(xs_console_mfn): 0;
>      free(xs_console_mfn);
>  
> +    xs_console_tty = xs_read(ctx->xsh, XBT_NULL,
> +                             GCSPRINTF("%s/console/tty", dom_path),
> +                             NULL);

Please use one of the libxl__xs_read variants here.

I think libxl__xs_read_mandatory fits the bill.

> +    state->console_tty = libxl__strdup(gc, xs_console_tty);
> +    free(xs_console_tty);
> +
>      dss->ao = ao;
>      dss->domid = dss->dsps.domid = domid_soft_reset;
>      dss->dsps.dm_savefile = GCSPRINTF(LIBXL_DEVICE_MODEL_SAVE_FILE".%d",
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 7722665..88fca8e 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -1123,6 +1123,7 @@ typedef struct {
>      uint32_t console_port;
>      uint32_t console_domid;
>      unsigned long console_mfn;
> +    char *console_tty;
>  
>      char *saved_state;
>  
> -- 
> 2.9.3
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] libxl: don't try to rename dm save file for PVH
  2017-03-20 18:03 ` [PATCH 1/2] libxl: don't try to rename dm save file for PVH Vitaly Kuznetsov
@ 2017-03-21 17:03   ` Wei Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Liu @ 2017-03-21 17:03 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: Wei Liu, Ian Jackson, xen-devel

On Mon, Mar 20, 2017 at 07:03:10PM +0100, Vitaly Kuznetsov wrote:
> Guests with LIBXL_DEVICE_MODEL_VERSION_NONE don't have a device model
> running so there is no save file to rename.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---

Acked-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] libxl: fix soft reset for PVHv2 guests
  2017-03-20 18:03 [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Vitaly Kuznetsov
  2017-03-20 18:03 ` [PATCH 1/2] libxl: don't try to rename dm save file for PVH Vitaly Kuznetsov
  2017-03-20 18:03 ` [PATCH 2/2] libxl: preserve console tty across soft reset Vitaly Kuznetsov
@ 2017-03-22 11:30 ` Wei Liu
  2017-03-22 12:06   ` Vitaly Kuznetsov
  2 siblings, 1 reply; 7+ messages in thread
From: Wei Liu @ 2017-03-22 11:30 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: Wei Liu, Ian Jackson, xen-devel

On Mon, Mar 20, 2017 at 07:03:09PM +0100, Vitaly Kuznetsov wrote:
> Vitaly Kuznetsov (2):
>   libxl: don't try to rename dm save file for PVH

I've pushed this patch.

>   libxl: preserve console tty across soft reset
> 

I will wait for v2 for this one.

>  tools/libxl/libxl_console.c  |  5 ++++-
>  tools/libxl/libxl_create.c   | 24 +++++++++++++++++-------
>  tools/libxl/libxl_internal.h |  1 +
>  3 files changed, 22 insertions(+), 8 deletions(-)
> 
> -- 
> 2.9.3
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] libxl: fix soft reset for PVHv2 guests
  2017-03-22 11:30 ` [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Wei Liu
@ 2017-03-22 12:06   ` Vitaly Kuznetsov
  0 siblings, 0 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2017-03-22 12:06 UTC (permalink / raw)
  To: Wei Liu; +Cc: Ian Jackson, xen-devel

Wei Liu <wei.liu2@citrix.com> writes:

> On Mon, Mar 20, 2017 at 07:03:09PM +0100, Vitaly Kuznetsov wrote:
>> Vitaly Kuznetsov (2):
>>   libxl: don't try to rename dm save file for PVH
>
> I've pushed this patch.
>
>>   libxl: preserve console tty across soft reset
>> 
>
> I will wait for v2 for this one.
>

Sure, thanks! I also plan to replace other occurances of raw xs_read()
in do_domain_soft_reset() with libxl__xs_read_* to be consistent. I'll
test and send these patches soon.

-- 
  Vitaly

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-22 12:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-20 18:03 [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Vitaly Kuznetsov
2017-03-20 18:03 ` [PATCH 1/2] libxl: don't try to rename dm save file for PVH Vitaly Kuznetsov
2017-03-21 17:03   ` Wei Liu
2017-03-20 18:03 ` [PATCH 2/2] libxl: preserve console tty across soft reset Vitaly Kuznetsov
2017-03-21 17:03   ` Wei Liu
2017-03-22 11:30 ` [PATCH 0/2] libxl: fix soft reset for PVHv2 guests Wei Liu
2017-03-22 12:06   ` Vitaly Kuznetsov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.