[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Implement the parts of vm save which need interaction with xend



ChangeSet 1.1527.2.1, 2005/05/24 18:47:14+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        Implement the parts of vm save which need interaction with xend
        as part of xend, instead of using xfrd.
        Execute xc_linux_save in a seperate process so that it can't
        crash xend.  Also handle errors passed from xc_linux_save.
        xen_domain.c:
          Disable save in xfrd.
        xc_save.c:
          new file
        Makefile:
          Add xc_save.
        XendDomainInfo.py:
          Add suspended state and threading Condition with notification, 
allowing
          easy waiting for state changes.
        XendDomain.py:
          Implement the parts of vm save which need interaction with xend
          as part of xend, instead of using xfrd.  Set state to "suspended"
          when detecting a suspended domain.
          Fix reading output from subprocesses.
          Fix ValueError in xen_domain().
        xc.c:
          Remove python binding for xc_linux_save.
        xc_linux_save.c:
          Implement the parts of vm save which need interaction with xend
          as part of xend, instead of using xfrd.  Also run xc_linux_save
          in a seperate process.
        xc_linux_restore.c:
          Flush output so that xend picks it up timely.
          Also disable debug output again.
        xc.h:
          Update xc_linux_save prototype and fix comments for 
xc_linux_{save,restore}.
        ignore:
          Add tools/xcutils/xc_save.
        xpopen.py:
          Exit with 127 if exec fails.
        Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>



 libxc/xc.h                        |   17 -
 libxc/xc_linux_restore.c          |    8 
 libxc/xc_linux_save.c             |  339 ++++++++++++++++++--------------------
 python/xen/lowlevel/xc/xc.c       |   96 ----------
 python/xen/util/xpopen.py         |    2 
 python/xen/xend/XendDomain.py     |   90 ++++++++--
 python/xen/xend/XendDomainInfo.py |   16 +
 xcutils/Makefile                  |    3 
 xcutils/xc_save.c                 |   29 +++
 xfrd/xen_domain.c                 |    2 
 10 files changed, 302 insertions(+), 300 deletions(-)


diff -Nru a/tools/libxc/xc.h b/tools/libxc/xc.h
--- a/tools/libxc/xc.h  2005-05-24 14:02:18 -04:00
+++ b/tools/libxc/xc.h  2005-05-24 14:02:18 -04:00
@@ -225,23 +225,22 @@
 struct XcIOContext;
 
 /**
- * This function will save a domain running Linux to an IO context.  This
- * IO context is currently a private interface making this function difficult
- * to call.  It's interface will likely change in the future.
+ * This function will save a domain running Linux.
  *
  * @parm xc_handle a handle to an open hypervisor interface
- * @parm ioctxt the IO context to save a domain to
+ * @parm fd the file descriptor to save a domain to
+ * @parm dom the id of the domain
  * @return 0 on success, -1 on failure
  */
-int xc_linux_save(int xc_handle, struct XcIOContext *ioctxt);
+int xc_linux_save(int xc_handle, int fd, u32 dom);
 
 /**
- * This function will restore a saved domain running Linux to an IO context.
- * Like xc_linux_save(), this function uses a parameter who's structure is
- * privately defined.  It's interface will also likely change.
+ * This function will restore a saved domain running Linux.
  *
  * @parm xc_handle a handle to an open hypervisor interface
- * @parm ioctxt the IO context to restore a domain from
+ * @parm fd the file descriptor to restore a domain from
+ * @parm dom the id of the domain
+ * @parm nr_pfns the number of pages
  * @return 0 on success, -1 on failure
  */
 int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns);
diff -Nru a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    2005-05-24 14:02:19 -04:00
+++ b/tools/libxc/xc_linux_restore.c    2005-05-24 14:02:19 -04:00
@@ -11,23 +11,23 @@
 
 #define MAX_BATCH_SIZE 1024
 
-#define DEBUG 01
+#define DEBUG 0
 
 #if 1
-#define ERR(_f, _a...) fprintf ( stderr, _f , ## _a )
+#define ERR(_f, _a...) fprintf ( stderr, _f , ## _a ); fflush(stderr)
 #else
 #define ERR(_f, _a...) ((void)0)
 #endif
 
 #if DEBUG
-#define DPRINTF(_f, _a...) fprintf ( stdout, _f , ## _a )
+#define DPRINTF(_f, _a...) fprintf ( stdout, _f , ## _a ); fflush(stdout)
 #else
 #define DPRINTF(_f, _a...) ((void)0)
 #endif
 
 #define PROGRESS 0
 #if PROGRESS
-#define PPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a )
+#define PPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a ); fflush(stderr)
 #else
 #define PPRINTF(_f, _a...)
 #endif
diff -Nru a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c       2005-05-24 14:02:19 -04:00
+++ b/tools/libxc/xc_linux_save.c       2005-05-24 14:02:19 -04:00
@@ -17,19 +17,25 @@
 
 #define MAX_MBIT_RATE 500
 
-#define DEBUG  0
-#define DDEBUG 0
+#define DEBUG 0
+
+#if 1
+#define ERR(_f, _a...) fprintf ( stderr, _f , ## _a )
+#else
+#define ERR(_f, _a...) ((void)0)
+#endif
 
 #if DEBUG
-#define DPRINTF(_f, _a...) printf ( _f , ## _a )
+#define DPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a )
 #else
 #define DPRINTF(_f, _a...) ((void)0)
 #endif
 
-#if DDEBUG
-#define DDPRINTF(_f, _a...) printf ( _f , ## _a )
+#define PROGRESS 0
+#if PROGRESS
+#define PPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a )
 #else
-#define DDPRINTF(_f, _a...) ((void)0)
+#define PPRINTF(_f, _a...)
 #endif
 
 /*
@@ -144,7 +150,7 @@
 }
 
 
-#define START_MBIT_RATE ioctxt->resource
+#define START_MBIT_RATE 0 //ioctxt->resource
 
 static int mbit_rate, ombit_rate = 0;
 static int burst_time_us = -1;
@@ -167,7 +173,8 @@
 #define RATE_TO_BTU 781250
 #define BURST_TIME_US burst_time_us
 
-static int xcio_ratewrite(XcIOContext *ioctxt, void *buf, int n)
+static int
+ratewrite(int io_fd, void *buf, int n)
 {
     static int budget = 0;
     static struct timeval last_put = { 0 };
@@ -176,16 +183,15 @@
     long long delta;
 
     if (START_MBIT_RATE == 0)
-       return xcio_write(ioctxt, buf, n);
+       return write(io_fd, buf, n);
     
     budget -= n;
     if (budget < 0) {
        if (MBIT_RATE != ombit_rate) {
            BURST_TIME_US = RATE_TO_BTU / MBIT_RATE;
            ombit_rate = MBIT_RATE;
-           xcio_info(ioctxt,
-                     "rate limit: %d mbit/s burst budget %d slot time %d\n",
-                     MBIT_RATE, BURST_BUDGET, BURST_TIME_US);
+           DPRINTF("rate limit: %d mbit/s burst budget %d slot time %d\n",
+                   MBIT_RATE, BURST_BUDGET, BURST_TIME_US);
        }
        if (last_put.tv_sec == 0) {
            budget += BURST_BUDGET;
@@ -213,7 +219,7 @@
            }
        }
     }
-    return xcio_write(ioctxt, buf, n);
+    return write(io_fd, buf, n);
 }
 
 static int print_stats( int xc_handle, u32 domid, 
@@ -235,7 +241,7 @@
     d1_cpu_now = xc_domain_get_cpu_usage(xc_handle, domid, /* FIXME */ 0)/1000;
 
     if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) ) 
-        printf("ARRHHH!!\n");
+        fprintf(stderr, "ARRHHH!!\n");
 
     wall_delta = tv_delta(&wall_now,&wall_last)/1000;
 
@@ -245,14 +251,15 @@
     d1_cpu_delta  = (d1_cpu_now - d1_cpu_last)/1000;
 
     if ( print )
-        printf("delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, "
-               "dirtied %dMb/s %" PRId32 " pages\n",
-               wall_delta, 
-               (int)((d0_cpu_delta*100)/wall_delta),
-               (int)((d1_cpu_delta*100)/wall_delta),
-               (int)((pages_sent*PAGE_SIZE)/(wall_delta*(1000/8))),
-               (int)((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8))),
-               stats->dirty_count);
+        fprintf(stderr,
+               "delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, "
+               "dirtied %dMb/s %" PRId32 " pages\n",
+               wall_delta, 
+               (int)((d0_cpu_delta*100)/wall_delta),
+               (int)((d1_cpu_delta*100)/wall_delta),
+               (int)((pages_sent*PAGE_SIZE)/(wall_delta*(1000/8))),
+               (int)((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8))),
+               stats->dirty_count);
 
     if (((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8))) > mbit_rate) {
        mbit_rate = (int)((stats->dirty_count*PAGE_SIZE)/(wall_delta*(1000/8)))
@@ -268,24 +275,6 @@
     return 0;
 }
 
-/** Write the vmconfig string.
- * It is stored as a 4-byte count 'n' followed by n bytes.
- *
- * @param ioctxt i/o context
- * @return 0 on success, non-zero on error.
- */
-static int write_vmconfig(XcIOContext *ioctxt)
-{
-    int err = -1;
-    if(xcio_write(ioctxt, &ioctxt->vmconfig_n, sizeof(ioctxt->vmconfig_n))) 
-        goto exit;
-    if(xcio_write(ioctxt, ioctxt->vmconfig, ioctxt->vmconfig_n)) 
-        goto exit;
-    err = 0;
-  exit:
-    return err;
-}
-
 static int analysis_phase( int xc_handle, u32 domid, 
                            int nr_pfns, unsigned long *arr, int runs )
 {
@@ -302,7 +291,7 @@
         xc_shadow_control( xc_handle, domid, 
                            DOM0_SHADOW_CONTROL_OP_CLEAN,
                            arr, nr_pfns, NULL);
-        printf("#Flush\n");
+        fprintf(stderr, "#Flush\n");
         for ( i = 0; i < 40; i++ )
         {     
             usleep(50000);     
@@ -311,11 +300,11 @@
                                DOM0_SHADOW_CONTROL_OP_PEEK,
                                NULL, 0, &stats);
 
-            printf("now= %lld faults= %" PRId32 " dirty= %" PRId32
-                   " dirty_net= %" PRId32 " dirty_block= %" PRId32"\n", 
-                   ((now-start)+500)/1000, 
-                   stats.fault_count, stats.dirty_count,
-                   stats.dirty_net_count, stats.dirty_block_count);
+            fprintf(stderr, "now= %lld faults= %" PRId32 " dirty= %" PRId32
+                   " dirty_net= %" PRId32 " dirty_block= %" PRId32"\n", 
+                   ((now-start)+500)/1000, 
+                   stats.fault_count, stats.dirty_count,
+                   stats.dirty_net_count, stats.dirty_block_count);
         }
     }
 
@@ -323,26 +312,36 @@
 }
 
 
-int suspend_and_state(int xc_handle, XcIOContext *ioctxt,                    
+int suspend_and_state(int xc_handle, int io_fd,        int dom,              
                       xc_dominfo_t *info,
                       vcpu_guest_context_t *ctxt)
 {
     int i=0;
-    
-    xcio_suspend_domain(ioctxt);
+    char ans[30];
+
+    printf("suspend\n");
+    fflush(stdout);
+    if (fgets(ans, sizeof(ans), stdin) == NULL) {

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.