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] add 'hibernate' option to xm

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] add 'hibernate' option to xm
From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
Date: Sat, 8 Aug 2009 21:30:48 +1000
Delivery-date: Sat, 08 Aug 2009 04:31:19 -0700
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
Thread-index: AcoYG606ICxqgYGZQkS+psp5Ygrfag==
Thread-topic: add 'hibernate' option to xm
For review, the following patch adds an 'xm hibernate' (and 'xm shutdown
-i' (-h and -H were already taken)) option to xm, which will do the same
as shutdown but instead ultimately write 'hibernate' to control/shutdown
instead of 'shutdown'.

I added it because I want to test the hibernate ability of the GPLPV
drivers and this was just as easy as writing a script to manually write
'hibernate' to control/shutdown. Much easier to add in a loop script now
(eg 'xm hibernate -w <domain> && xm create <domain> && sleep 300' on
repeat).

I don't think it hurts anything, but on the other hand, outside of my
testing and few specific scenarios I'm not sure exactly how useful it
is, given that xen already has the 'save' and 'restore' ability.

Let me know if could be useful to someone and I'll submit properly (eg
as an attachment with a signed off by etc).

James

# hg diff
diff -r 13fe7f07df15 tools/python/xen/xend/XendConstants.py
--- a/tools/python/xen/xend/XendConstants.py    Thu Aug 06 13:27:53 2009
+0100
+++ b/tools/python/xen/xend/XendConstants.py    Sat Aug 08 21:23:53 2009
+1000
@@ -21,18 +21,20 @@
 # Shutdown codes and reasons.
 #

-DOMAIN_POWEROFF = 0
-DOMAIN_REBOOT   = 1
-DOMAIN_SUSPEND  = 2
-DOMAIN_CRASH    = 3
-DOMAIN_HALT     = 4
+DOMAIN_POWEROFF  = 0
+DOMAIN_REBOOT    = 1
+DOMAIN_SUSPEND   = 2
+DOMAIN_CRASH     = 3
+DOMAIN_HALT      = 4
+DOMAIN_HIBERNATE = 5

 DOMAIN_SHUTDOWN_REASONS = {
-    DOMAIN_POWEROFF: "poweroff",
-    DOMAIN_REBOOT  : "reboot",
-    DOMAIN_SUSPEND : "suspend",
-    DOMAIN_CRASH   : "crash",
-    DOMAIN_HALT    : "halt"
+    DOMAIN_POWEROFF  : "poweroff",
+    DOMAIN_REBOOT    : "reboot",
+    DOMAIN_SUSPEND   : "suspend",
+    DOMAIN_CRASH     : "crash",
+    DOMAIN_HALT      : "halt",
+    DOMAIN_HIBERNATE : "hibernate"
 }
 REVERSE_DOMAIN_SHUTDOWN_REASONS = \
     dict([(y, x) for x, y in DOMAIN_SHUTDOWN_REASONS.items()])
diff -r 13fe7f07df15 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Aug 06 13:27:53 2009 +0100
+++ b/tools/python/xen/xm/main.py       Sat Aug 08 21:23:53 2009 +1000
@@ -121,6 +121,7 @@
     'save'        : ('[-c] <Domain> <CheckpointFile>',
                      'Save a domain state to restore later.'),
     'shutdown'    : ('<Domain> [-waRH]', 'Shutdown a domain.'),
+    'hibernate'   : ('<Domain> [-wa]', 'Hibernate a domain.'),
     'top'         : ('', 'Monitor a host and the domains in real
time.'),
     'unpause'     : ('<Domain>', 'Unpause a paused domain.'),
     'uptime'      : ('[-s] [Domain, ...]',
@@ -334,6 +335,7 @@
     "resume",
     "save",
     "shutdown",
+    "hibernate",
     "start",
     "suspend",
     "sysrq",
@@ -1289,6 +1291,11 @@
     arg_check(args, "shutdown", 1, 4)
     from xen.xm import shutdown
     shutdown.main(["shutdown"] + args)
+
+def xm_hibernate(args):
+    arg_check(args, "hibernate", 1, 3)
+    from xen.xm import shutdown
+    shutdown.main(["shutdown", "-i"] + args)

 def xm_reset(args):
     arg_check(args, "reset", 1)
@@ -2850,6 +2857,7 @@
     "resume": xm_resume,
     "save": xm_save,
     "shutdown": xm_shutdown,
+    "hibernate": xm_hibernate,
     "start": xm_start,
     "sysrq": xm_sysrq,
     "trigger": xm_trigger,
diff -r 13fe7f07df15 tools/python/xen/xm/shutdown.py
--- a/tools/python/xen/xm/shutdown.py   Thu Aug 06 13:27:53 2009 +0100
+++ b/tools/python/xen/xm/shutdown.py   Sat Aug 08 21:23:53 2009 +1000
@@ -50,6 +50,10 @@
 gopts.opt('reboot', short='R',
           fn=set_true, default=0,
           use='Shutdown and reboot.')
+
+gopts.opt('hibernate', short='i',
+          fn=set_true, default=0,
+          use='Hibernate.')

 def wait_reboot(opts, doms, rcs):
     if serverType == SERVER_XEN_API:
@@ -127,6 +131,8 @@
         return 'halt'
     elif opts.vals.reboot:
         return 'reboot'
+    elif opts.vals.hibernate:
+        return 'hibernate'
     else:
         return 'poweroff'




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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] add 'hibernate' option to xm, James Harper <=