diff -r 0e32095a7b46 tools/libxc/xc_core.c --- a/tools/libxc/xc_core.c Wed Aug 09 21:34:27 2006 +0100 +++ b/tools/libxc/xc_core.c Fri Aug 11 17:03:39 2006 +0900 @@ -36,7 +36,7 @@ xc_domain_dumpcore_via_callback(int xc_h vcpu_guest_context_t ctxt[MAX_VIRT_CPUS]; char dummy[PAGE_SIZE]; int dummy_len; - int sts; + int sts,cpy_sts; if ( (dump_mem_start = malloc(DUMP_INCREMENT*PAGE_SIZE)) == NULL ) { @@ -101,9 +101,11 @@ xc_domain_dumpcore_via_callback(int xc_h if ( sts != 0 ) goto error_out; - for ( dump_mem = dump_mem_start, i = 0; i < nr_pages; i++ ) + for ( dump_mem = dump_mem_start, i = 0,cpy_sts=0; i < nr_pages; i++ ) { - copy_from_domain_page(xc_handle, domid, page_array[i], dump_mem); + if((sts=copy_from_domain_page(xc_handle, domid, page_array[i], dump_mem))<0) + cpy_sts=sts; + dump_mem += PAGE_SIZE; if ( ((i + 1) % DUMP_INCREMENT == 0) || ((i + 1) == nr_pages) ) { @@ -113,6 +115,8 @@ xc_domain_dumpcore_via_callback(int xc_h dump_mem = dump_mem_start; } } + if(cpy_sts!=0) + goto error_out; free(dump_mem_start); free(page_array); diff -r 0e32095a7b46 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Wed Aug 09 21:34:27 2006 +0100 +++ b/tools/python/xen/xend/XendDomain.py Fri Aug 11 16:29:41 2006 +0900 @@ -390,6 +390,22 @@ class XendDomain: except Exception, ex: raise XendError(str(ex)) + def domain_dump(self, domid, filename): + """Dump domain core.""" + + dominfo = self.domain_lookup_by_name_or_id_nr(domid) + if not dominfo: + raise XendInvalidDomain(str(domid)) + + if dominfo.getDomid() == PRIV_DOMAIN: + raise XendError("Cannot dump core for privileged domain %s" % domid) + + try: + log.info("Dumping Core for Domain %s (%d).", dominfo.getName(), + dominfo.getDomid()) + return dominfo.dumpCore(filename) + except Exception, ex: + raise XendError(str(ex)) def domain_destroy(self, domid): """Terminate domain immediately.""" @@ -402,9 +418,9 @@ class XendDomain: val = dominfo.destroy() else: try: - val = xc.domain_destroy(int(domid)) + val = xc.domain_destroy(domid) except Exception, ex: - raise XendInvalidDomain(str(domid)) + raise XendError(str(ex)) return val def domain_migrate(self, domid, dst, live=False, resource=0, port=0): diff -r 0e32095a7b46 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Wed Aug 09 21:34:27 2006 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Aug 11 15:13:51 2006 +0900 @@ -967,11 +967,12 @@ class XendDomainInfo: self.restart(True) - def dumpCore(self): + def dumpCore(self,corefile=None): """Create a core dump for this domain. Nothrow guarantee.""" try: - corefile = "/var/xen/dump/%s.%s.core" % (self.info['name'], + if not corefile: + corefile = "/var/xen/dump/%s.%s.core" % (self.info['name'], self.domid) xc.domain_dumpcore(self.domid, corefile) diff -r 0e32095a7b46 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Wed Aug 09 21:34:27 2006 +0100 +++ b/tools/python/xen/xm/main.py Fri Aug 11 16:37:02 2006 +0900 @@ -56,6 +56,8 @@ create_help = """create [-c] [Name=Value].. Create a domain based on Config File""" destroy_help = "destroy Terminate a domain immediately" +dump_help = "dump [-LC] [FileName] Dump core of the specified domain" + help_help = "help Display this message" list_help = "list [--long] [DomId, ...] List information about domains" list_label_help = "list [--label] [DomId, ...] List information about domains including their labels" @@ -138,6 +140,7 @@ short_command_list = [ "console", "create", "destroy", + "dump", "help", "list", "mem-set", @@ -158,6 +161,7 @@ domain_commands = [ "destroy", "domid", "domname", + "dump", "list", "list_label", "mem-max", @@ -588,6 +592,43 @@ def xm_unpause(args): server.xend.domain.unpause(dom) +def xm_dump(args): + arg_check(args, "dump",1,3) + live=False + crash=False + import getopt + optlist,args=getopt.gnu_getopt(args,"LC") + for opt in optlist: + if opt[0]=="-L": + live=True + if opt[0]=="-C": + crash=True + + if len(args)==0 or len(args)>2: + err("invalid number of parameters") + usage("dump") + + dom=args[0] + if len(args)==2: + filename=args[1] + else: + filename=None + + if not live: + print "pausing domain:%s ..." % str(dom) + server.xend.domain.pause(dom) + + print "dumping core of domain:%s ..." % str(dom) + server.xend.domain.dump(dom,filename) + + if not live: + print "unpausing domain:%s ..." % str(dom) + server.xend.domain.unpause(dom) + + if crash: + print "destroying domain:%s ..." % str(dom) + server.xend.domain.destroy(dom) + def xm_rename(args): arg_check(args, "rename", 2) @@ -1112,6 +1153,7 @@ commands = { "destroy": xm_destroy, "domid": xm_domid, "domname": xm_domname, + "dump": xm_dump, "rename": xm_rename, "restore": xm_restore, "save": xm_save,