ia64/xen-unstable

changeset 11477:0008fca70351

xm dump command add on

xm dump-core [-L|--live][-C| --crash] <domID> [output path]

-L| --live Live dump:
By default, xm dump does an xm pause, unpause before and
after taking the dump, respectively. This option disables
the pause/unpause and simply takes the dump.

-C :| --crash crash dump:
This executes an xm destroy after the dump file is complete.

The output path is optional, and if it is not specified, the path will be
/var/xen/dump/<domU name>.<domU ID>.core

This command uses the existant dumpCore(), which has been used for
coredump when a domU crashed.

Signed-off-by: Ken Hironaka <hironaka.ken@soft.fujitsu.com>
Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>
author root@procyon
date Thu Sep 14 08:19:38 2006 +0100 (2006-09-14)
parents 97f3368d1dd3
children 30c659b655f1
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Sep 14 08:18:56 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Sep 14 08:19:38 2006 +0100
     1.3 @@ -390,6 +390,22 @@ class XendDomain:
     1.4          except Exception, ex:
     1.5              raise XendError(str(ex))
     1.6  
     1.7 +    def domain_dump(self, domid, filename, live, crash):
     1.8 +        """Dump domain core."""
     1.9 +
    1.10 +        dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.11 +        if not dominfo:
    1.12 +            raise XendInvalidDomain(str(domid))
    1.13 +
    1.14 +        if dominfo.getDomid() == PRIV_DOMAIN:
    1.15 +            raise XendError("Cannot dump core for privileged domain %s" % domid)
    1.16 +
    1.17 +        try:
    1.18 +            log.info("Domain core dump requested for domain %s (%d) live=%d crash=%d.",
    1.19 +                     dominfo.getName(), dominfo.getDomid(), live, crash)
    1.20 +            return dominfo.dumpCore(filename)
    1.21 +        except Exception, ex:
    1.22 +            raise XendError(str(ex))
    1.23  
    1.24      def domain_destroy(self, domid):
    1.25          """Terminate domain immediately."""
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Sep 14 08:18:56 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Sep 14 08:19:38 2006 +0100
     2.3 @@ -977,11 +977,12 @@ class XendDomainInfo:
     2.4          self.restart(True)
     2.5  
     2.6  
     2.7 -    def dumpCore(self):
     2.8 +    def dumpCore(self,corefile=None):
     2.9          """Create a core dump for this domain.  Nothrow guarantee."""
    2.10          
    2.11          try:
    2.12 -            corefile = "/var/xen/dump/%s.%s.core" % (self.info['name'],
    2.13 +            if not corefile:
    2.14 +                corefile = "/var/xen/dump/%s.%s.core" % (self.info['name'],
    2.15                                                       self.domid)
    2.16              xc.domain_dumpcore(self.domid, corefile)
    2.17  
     3.1 --- a/tools/python/xen/xm/main.py	Thu Sep 14 08:18:56 2006 +0100
     3.2 +++ b/tools/python/xen/xm/main.py	Thu Sep 14 08:19:38 2006 +0100
     3.3 @@ -57,6 +57,9 @@ console_help = "console <DomId>         
     3.4  create_help =  """create [-c] <ConfigFile>
     3.5                 [Name=Value]..       Create a domain based on Config File"""
     3.6  destroy_help = "destroy <DomId>                  Terminate a domain immediately"
     3.7 +dump_core_help =   """dump-core [-L|--live][-C|--crash]
     3.8 +            <DomId> [FileName]      Dump core of the specified domain"""
     3.9 +
    3.10  help_help =    "help                             Display this message"
    3.11  list_help =    "list [--long] [DomId, ...]       List information about domains"
    3.12  list_label_help = "list [--label] [DomId, ...]      List information about domains including their labels"
    3.13 @@ -138,6 +141,7 @@ short_command_list = [
    3.14      "console",
    3.15      "create",
    3.16      "destroy",
    3.17 +    "dump-core",
    3.18      "help",
    3.19      "list",
    3.20      "mem-set",
    3.21 @@ -159,6 +163,7 @@ domain_commands = [
    3.22      "destroy",
    3.23      "domid",
    3.24      "domname",
    3.25 +    "dump-core",
    3.26      "list",
    3.27      "list_label",
    3.28      "mem-max",
    3.29 @@ -590,6 +595,43 @@ def xm_unpause(args):
    3.30  
    3.31      server.xend.domain.unpause(dom)
    3.32  
    3.33 +def xm_dump_core(args):
    3.34 +    arg_check(args, "dump-core",1,3)
    3.35 +    live = False
    3.36 +    crash = False
    3.37 +    import getopt
    3.38 +    (options, params) = getopt.gnu_getopt(args, 'LC', ['live','crash'])
    3.39 +
    3.40 +    for (k, v) in options:
    3.41 +        if k in ['-L', '--live']:
    3.42 +            live = True
    3.43 +        if k in ['-C', '--crash']:
    3.44 +            crash = True
    3.45 +
    3.46 +    if len(params) == 0 or len(params) > 2:
    3.47 +        err("invalid number of parameters")
    3.48 +        usage("dump-core")
    3.49 +
    3.50 +    dom = params[0]
    3.51 +    if len(params) == 2:
    3.52 +        filename = os.path.abspath(params[1])
    3.53 +    else:
    3.54 +        filename = None
    3.55 +
    3.56 +    if not live:
    3.57 +        server.xend.domain.pause(dom)
    3.58 +
    3.59 +    try:
    3.60 +        print "dumping core of domain:%s ..." % str(dom)
    3.61 +        server.xend.domain.dump(dom, filename, live, crash)
    3.62 +    finally:
    3.63 +        if not live:
    3.64 +            server.xend.domain.unpause(dom)
    3.65 +
    3.66 +    if crash:
    3.67 +        print "destroying domain:%s ..." % str(dom)
    3.68 +        server.xend.domain.destroy(dom)
    3.69 +
    3.70  def xm_rename(args):
    3.71      arg_check(args, "rename", 2)
    3.72  
    3.73 @@ -1168,6 +1210,7 @@ commands = {
    3.74      "destroy": xm_destroy,
    3.75      "domid": xm_domid,
    3.76      "domname": xm_domname,
    3.77 +    "dump-core": xm_dump_core,
    3.78      "rename": xm_rename,
    3.79      "restore": xm_restore,
    3.80      "save": xm_save,