]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
Arrange for core dumps to be placed in /var/core and collect them
authorIan Campbell <ian.campbell@citrix.com>
Tue, 24 Mar 2015 14:23:58 +0000 (14:23 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Sat, 2 May 2015 09:00:59 +0000 (10:00 +0100)
Refactor the $kvp_replace helper in ts-xen-install into a generic
helper (which requires using ::EO and ::EI for namespacing) for use
with target_editfile and use it to edit /etc/sysctl.conf to set
kernel.core_pattern on boot.

Tested in standalone mode by installing and running a C program
containing "*(int *)0 = 1;" which, after running "ulimit -c unlimited"
produces the expected core file. ts-logs-capture when run in
standalone mode then picks them up.

I've not yet figured out how to make the desired rlimit take affect
for all processes (including e.g. daemons spawned on boot). Likely
this will involve some combination of pam_limits.so PAM module and
adding explicit ulimit calls to the initscripts which we care about
(primarily xencommons and libvirt initscripts).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/TestSupport.pm
ts-host-install
ts-leak-check
ts-logs-capture
ts-xen-install

index 3c2af90abd636fd4a9b8fe35859e8c28434d799f..b50ad0aebe87e32a3747fd41dffd48e83f8a8ff1 100644 (file)
@@ -57,6 +57,7 @@ BEGIN {
                       target_put_guest_image target_editfile
                       target_editfile_cancel
                       target_editfile_root target_file_exists
+                      target_editfile_kvp_replace
                       target_run_apt
                       target_install_packages target_install_packages_norec
                       target_jobdir target_extract_jobdistpath_subdir
@@ -542,6 +543,27 @@ sub teditfileex {
        if $install;
 }
 
+# Replace a Key=Value style line in a config file.
+#
+# To be used as 3rd argument to target_editfile(_root) as:
+#    target_editfile_root($ho, "/path/to/a/file",
+#                       sub { target_editfile_kvp_replace($key, $value) });
+sub target_editfile_kvp_replace ($$)
+{
+    my ($key,$value) = @_;
+    my $prnow;
+    $prnow= sub {
+       print ::EO "$key=$value\n" or die $!;
+       $prnow= sub { };
+    };
+    while (<::EI>) {
+       print ::EO or die $! unless m/^$key\b/;
+       $prnow->() if m/^#$key/;
+    }
+    print ::EO "\n" or die $!;
+    $prnow->();
+};
+
 sub target_editfile_root ($$$;$$) { teditfileex('root',@_); }
 sub target_editfile      ($$$;$$) { teditfileex('osstest',@_); }
     # my $code= pop @_;
index a8543a41811c3d7ace7492208b101b8b95840bf5..cfd51180b6892e27164e69df6693ce0f3ab84faf 100755 (executable)
@@ -139,6 +139,14 @@ END
        });
     }
 
+    target_cmd_root($ho, 'mkdir -p /var/core');
+    target_editfile_root($ho, '/etc/sysctl.conf',
+       sub { target_editfile_kvp_replace(
+                 "kernel.core_pattern",
+                 # %p==pid,%e==executable name,%t==timestamp
+                 "/var/core/%t.%p.%e.core") });
+    target_cmd_root($ho, "sysctl --load /etc/sysctl.conf");
+
     target_cmd_root($ho, "update-rc.d osstest-confirm-booted start 99 2 .");
 
     logm('OK: install completed');
index ec40435e7b26ed14b3c6694164173997d28c4b2b..fdade3687b096cf1f63e0aab30dd69c5dcd5d22f 100755 (executable)
@@ -157,7 +157,7 @@ sub inventory () {
     inventory_domains();
     inventory_processes();
     inventory_xenstore();
-    inventory_files('/tmp /var/run /var/tmp /var/lib/xen');
+    inventory_files('/tmp /var/run /var/tmp /var/lib/xen /var/core');
 }
 
 if (!eval {
index 453b03d1ff340c0798451de21d5b53e97df0182d..45b0a38320bd5c128a494f37baee2ff197ce40ef 100755 (executable)
@@ -136,6 +136,8 @@ sub fetch_logs_host_guests () {
 
                   /home/osstest/osstest-confirm-booted.log
 
+                  /var/core/*.core
+
                   )];
     if (!try_fetch_logs($ho, $logs)) {
         logm("log fetching failed, trying hard host reboot...");
index b3f4387f42527084c19f6c7ba2e0bec27792deab..2db0b29507fc223a97ded7c0b97d9eb4c6d18745 100755 (executable)
@@ -116,26 +116,11 @@ sub adjustconfig () {
     }
     die unless defined $trace_config_file;
 
-    my $kvp_replace = sub($$) {
-       my ($key,$value) = @_;
-        my $prnow;
-        $prnow= sub {
-            print EO "$key=$value\n" or die $!;
-            $prnow= sub { };
-        };
-        while (<EI>) {
-            print EO or die $! unless m/^$key\b/;
-            $prnow->() if m/^#$key/;
-        }
-        print EO "\n" or die $!;
-        $prnow->();
-    };
-
     target_editfile_root($ho, $trace_config_file,
-                        sub { $kvp_replace->("XENCONSOLED_TRACE", "guest") });
+       sub { target_editfile_kvp_replace("XENCONSOLED_TRACE", "guest") });
 
     target_editfile_root($ho, '/etc/libvirt/libvirtd.conf',
-                        sub { $kvp_replace->("log_level", "1") })
+               sub { target_editfile_kvp_replace("log_level", "1") })
        if toolstack($ho)->{Name} eq "libvirt";
 
     target_cmd_root($ho, 'mkdir -p /var/log/xen/console');