xm dump command add on (TAKE 2)
PATCH 1/1 xm dump command add on (TAKE 2)
This is a TAKE 2 to the xm dump-core command to xend. Changes:
-the command name is now xm dump-core instead of xm dump -the command takes long options --live, and --crash.
-with pause dump, the message that the domain will be paused has been taken out
-when an interrupt is received during execution, the command will automatically unpause the domain in question.
The below is basically the same info as before.
-----------------------------------------------------------------
The command outputs the memory contents of the specified domU to a coredump file.
This will fail if tried on dom0.
The specification is as follows:
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.
In this patch, the xc_domain_dumpcore_via_callback() in xc_core.c of libxc is also modified. Previously, the xc_domain_dumpcore_via_callback() did not respond to error when copy_from_domain_page() failed. In other words, the dump core remained silent even if mapping the domain memory failed and its page could not be copied. When this happened, erroneous data had been dumped to the file without the user realizing it. Now, it has been modified so that if copy_from_domain_page fails, this fact is recorded in the logfile. However even in such cases, the dumping will continue as before.
Reference
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00181.html
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00259.html
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00483.html
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00742.html
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00831.html
tools/libxc/xc_core.c +10 -1
@@ -37,6 +37,7 @@ xc_domain_dumpcore_via_callback(int xc_hchar dummy[PAGE_SIZE ];int dummy_len;int sts; +unsigned int cpy_err_cnt =0 ;if ( (dump_mem_start =malloc (DUMP_INCREMENT *PAGE_SIZE )) ==NULL ) {
@@ -103,7 +104,11 @@ xc_domain_dumpcore_via_callback(int xc_hfor ( dump_mem = dump_mem_start, i =0 ; i < nr_pages; i++ ) { -copy_from_domain_page (xc_handle, domid, page_array[i], dump_mem); + sts =copy_from_domain_page (xc_handle, domid, page_array[i], dump_mem); + +if ( sts !=0 ) + cpy_err_cnt++; + dump_mem +=PAGE_SIZE ;if ( ((i +1 ) %DUMP_INCREMENT ==0 ) || ((i +1 ) == nr_pages) ) {
@@ -112,6 +117,10 @@ xc_domain_dumpcore_via_callback(int xc_h goto error_out; dump_mem = dump_mem_start; } + } +if ( cpy_err_cnt !=0 ){ +IPRINTF ("Could not copy from domid=%d (%d)pages\n" , domid, cpy_err_cnt); + goto error_out; }free (dump_mem_start);
tools/python/xen/xend/XendDomain.py +16 -0
@@ -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("Domain core dump requested 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."""
tools/python/xen/xend/XendDomainInfo.py +3 -2
@@ -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)
tools/python/xen/xm/main.py +42 -0
72 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel