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-changelog

[Xen-changelog] [xen-unstable] xm: Add a new command: xm reset

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xm: Add a new command: xm reset
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Apr 2008 07:10:43 -0700
Delivery-date: Tue, 22 Apr 2008 07:13:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1208855893 -3600
# Node ID 65802c51edb5577faae351194b8b6b495cebfaa8
# Parent  b3e53e17d87ac82c7f296963b4fbb72de41d87b8
xm: Add a new command: xm reset

If a hang-up of a guest OS occurs, we will restart the guest OS by
using
the following commands.
 1. xm destroy
 2. xm create or xm start

To reduce the number of xm commands to use, this patch adds a new
command.  The command is "xm reset".  The command executes destruction
of a domain, and then creation of the domain.

Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendDomain.py     |   26 +++++++++++++++++++++++++-
 tools/python/xen/xend/XendDomainInfo.py |   28 ++++++++++++++++++++++++++++
 tools/python/xen/xm/main.py             |   11 +++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)

diff -r b3e53e17d87a -r 65802c51edb5 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Mon Apr 21 20:21:39 2008 +0100
+++ b/tools/python/xen/xend/XendDomain.py       Tue Apr 22 10:18:13 2008 +0100
@@ -1622,7 +1622,31 @@ class XendDomain:
                                           vcpu)
         except Exception, ex:
             raise XendError(str(ex))
- 
+
+    def domain_reset(self, domid):
+        """Terminate domain immediately, and then create domain.
+
+        @param domid: Domain ID or Name
+        @type domid: int or string.
+        @rtype: None
+        @raise XendError: Failed to destroy or create
+        @raise XendInvalidDomain: Domain is not valid
+        """
+
+        dominfo = self.domain_lookup_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
+        if dominfo and dominfo.getDomid() == DOM0_ID:
+            raise XendError("Cannot reset privileged domain %s" % domid)
+        if dominfo._stateGet() not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+            raise VMBadState("Domain '%s' is not started" % domid,
+                             POWER_STATE_NAMES[DOM_STATE_RUNNING],
+                             POWER_STATE_NAMES[dominfo._stateGet()])
+        try:
+            dominfo.resetDomain()
+        except Exception, ex:
+            raise XendError(str(ex))
+
 
 def instance():
     """Singleton constructor. Use this instead of the class constructor.
diff -r b3e53e17d87a -r 65802c51edb5 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Mon Apr 21 20:21:39 2008 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Apr 22 10:18:13 2008 +0100
@@ -2323,6 +2323,34 @@ class XendDomainInfo:
         self._cleanup_phantom_devs(paths)
 
 
+    def resetDomain(self):
+        log.debug("XendDomainInfo.resetDomain(%s)", str(self.domid))
+
+        old_domid = self.domid
+        prev_vm_xend = self._listRecursiveVm('xend')
+        new_dom_info = self.info
+        try:
+            self._unwatchVm()
+            self.destroy()
+
+            new_dom = None
+            try:
+                from xen.xend import XendDomain
+                new_dom_info['domid'] = None
+                new_dom = XendDomain.instance().domain_create_from_dict(
+                    new_dom_info)
+                for x in prev_vm_xend[0][1]:
+                    new_dom._writeVm('xend/%s' % x[0], x[1])
+                new_dom.waitForDevices()
+                new_dom.unpause()
+            except:
+                if new_dom:
+                    new_dom.destroy()
+                raise
+        except:
+            log.exception('Failed to reset domain %s.', str(old_domid))
+
+
     def resumeDomain(self):
         log.debug("XendDomainInfo.resumeDomain(%s)", str(self.domid))
 
diff -r b3e53e17d87a -r 65802c51edb5 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Mon Apr 21 20:21:39 2008 +0100
+++ b/tools/python/xen/xm/main.py       Tue Apr 22 10:18:13 2008 +0100
@@ -107,6 +107,7 @@ SUBCOMMAND_HELP = {
                      'Migrate a domain to another machine.'),
     'pause'       : ('<Domain>', 'Pause execution of a domain.'),
     'reboot'      : ('<Domain> [-wa]', 'Reboot a domain.'),
+    'reset'       : ('<Domain>', 'Reset a domain.'),
     'restore'     : ('<CheckpointFile> [-p]',
                      'Restore a domain from a saved state.'),
     'save'        : ('[-c] <Domain> <CheckpointFile>',
@@ -274,6 +275,7 @@ common_commands = [
     "migrate",
     "pause",
     "reboot",
+    "reset",
     "restore",
     "resume",
     "save",
@@ -303,6 +305,7 @@ domain_commands = [
     "pause",
     "reboot",
     "rename",
+    "reset",
     "restore",
     "resume",
     "save",
@@ -1247,6 +1250,13 @@ def xm_shutdown(args):
     arg_check(args, "shutdown", 1, 4)
     from xen.xm import shutdown
     shutdown.main(["shutdown"] + args)
+
+def xm_reset(args):
+    arg_check(args, "reset", 1)
+    dom = args[0]
+
+    # TODO: XenAPI
+    server.xend.domain.reset(dom)
 
 def xm_pause(args):
     arg_check(args, "pause", 1)
@@ -2474,6 +2484,7 @@ commands = {
     "dump-core": xm_dump_core,
     "reboot": xm_reboot,
     "rename": xm_rename,
+    "reset": xm_reset,
     "restore": xm_restore,
     "resume": xm_resume,
     "save": xm_save,

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xm: Add a new command: xm reset, Xen patchbot-unstable <=