WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 5/5] libxl: add 2 consoles to stubdoms for save/resto

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 5/5] libxl: add 2 consoles to stubdoms for save/restore
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Wed, 19 Jan 2011 13:53:36 +0000
Delivery-date: Wed, 19 Jan 2011 05:57:41 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Add two "special" PV consoles to stubdoms that are going to be used
to send and receive the qemu-xen save files on save/restore.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

diff -r 34e519b679cf tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Jan 19 12:47:24 2011 +0000
+++ b/tools/libxl/libxl.c       Wed Jan 19 12:49:43 2011 +0000
@@ -750,7 +750,8 @@ int libxl_primary_console_exec(libxl_ctx
 {
     uint32_t stubdomid = libxl_get_stubdom_id(ctx, domid_vm);
     if (stubdomid)
-        return libxl_console_exec(ctx, stubdomid, 1, LIBXL_CONSTYPE_PV);
+        return libxl_console_exec(ctx, stubdomid,
+                STUBDOM_CONSOLE_SERIAL, LIBXL_CONSTYPE_PV);
     else {
         if (libxl__domain_is_hvm(ctx, domid_vm))
             return libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSTYPE_SERIAL);
diff -r 34e519b679cf tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Wed Jan 19 12:47:24 2011 +0000
+++ b/tools/libxl/libxl_dm.c    Wed Jan 19 12:49:43 2011 +0000
@@ -430,7 +430,7 @@ static int libxl_create_stubdom(libxl_ct
                                 libxl__device_model_starting **starting_r)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
-    int i, num_console = 1, ret;
+    int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret;
     libxl_device_console *console;
     libxl_domain_create_info c_info;
     libxl_domain_build_info b_info;
@@ -533,15 +533,31 @@ retry_transaction:
         console[i].devid = i;
         console[i].consback = LIBXL_CONSBACK_IOEMU;
         console[i].domid = domid;
-        if (!i) {
+        /* STUBDOM_CONSOLE_LOGGING (console 0) is for minios logging
+         * STUBDOM_CONSOLE_SAVE (console 1) is for writing the save file
+         * STUBDOM_CONSOLE_RESTORE (console 2) is for reading the save file
+         */
+        switch (i) {
             char *filename;
-            char *name = libxl__sprintf(&gc, "qemu-dm-%s", 
libxl_domid_to_name(ctx, info->domid));
-            libxl_create_logfile(ctx, name, &filename);
-            console[i].output = libxl__sprintf(&gc, "file:%s", filename);
-            console[i].build_state = &state;
-            free(filename);
-        } else
-            console[i].output = "pty";
+            char *name;
+            case STUBDOM_CONSOLE_LOGGING:
+                name = libxl__sprintf(&gc, "qemu-dm-%s", 
libxl_domid_to_name(ctx, info->domid));
+                libxl_create_logfile(ctx, name, &filename);
+                console[i].output = libxl__sprintf(&gc, "file:%s", filename);
+                console[i].build_state = &state;
+                free(filename);
+                break;
+            case STUBDOM_CONSOLE_SAVE:
+                console[i].output = libxl__sprintf(&gc, "file:"SAVEFILE".%d", 
info->domid);
+                break;
+            case STUBDOM_CONSOLE_RESTORE:
+                if (info->saved_state)
+                    console[i].output = libxl__sprintf(&gc, "pipe:%s", 
info->saved_state);
+                break;
+            default:
+                console[i].output = "pty";
+                break;
+        }
         ret = libxl_device_console_add(ctx, domid, &console[i]);
         if (ret)
             goto out_free;
diff -r 34e519b679cf tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Wed Jan 19 12:47:24 2011 +0000
+++ b/tools/libxl/libxl_internal.h      Wed Jan 19 12:49:43 2011 +0000
@@ -45,6 +45,11 @@
 #define LIBXL_HVM_EXTRA_MEMORY 2048
 #define LIBXL_MIN_DOM0_MEM (128*1024)
 #define QEMU_SIGNATURE "DeviceModelRecord0002"
+#define STUBDOM_CONSOLE_LOGGING 0
+#define STUBDOM_CONSOLE_SAVE 1
+#define STUBDOM_CONSOLE_RESTORE 2
+#define STUBDOM_CONSOLE_SERIAL 3
+#define STUBDOM_SPECIAL_CONSOLES 3
 #define SAVEFILE "/var/lib/xen/qemu-save"
 #define RESTOREFILE "/var/lib/xen/qemu-resume"
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>