[Libguestfs] [PATCH] sysprep: remove crash data generated by kexec-tools

Wanlong Gao gaowanlong at cn.fujitsu.com
Wed Nov 21 09:50:58 UTC 2012


Remove the kdump generated kernel crash data.

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 sysprep/Makefile.am                     |  1 +
 sysprep/sysprep_operation_crash_data.ml | 47 +++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 sysprep/sysprep_operation_crash_data.ml

diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index a747929..fafb929 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -43,6 +43,7 @@ operations = \
 	bash_history \
 	blkid_tab \
 	ca_certificates \
+	crash_data \
 	cron_spool \
 	dhcp_client_state \
 	dhcp_server_state \
diff --git a/sysprep/sysprep_operation_crash_data.ml b/sysprep/sysprep_operation_crash_data.ml
new file mode 100644
index 0000000..2150e52
--- /dev/null
+++ b/sysprep/sysprep_operation_crash_data.ml
@@ -0,0 +1,47 @@
+(* virt-sysprep
+ * Copyright (C) 2012 Fujitsu Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Sysprep_operation
+open Sysprep_gettext.Gettext
+
+module G = Guestfs
+
+let crash_data_perform g root =
+  let typ = g#inspect_get_type root in
+  if typ <> "windows" then (
+    let paths = g#glob_expand "/var/crash/*" in
+    Array.iter (
+      fun path -> g#rm_rf path;
+    ) paths;
+    []
+  )
+  else []
+
+let crash_data_op = {
+  name = "crash-data";
+  enabled_by_default = true;
+  heading = s_"Remove the crash data generated by kexec-tools";
+  pod_description = Some (s_"\
+Remove the automatically generated kdump kernel crash data in
+C</var/crash/>.");
+  extra_args = [];
+  perform_on_filesystems = Some crash_data_perform;
+  perform_on_devices = None;
+}
+
+let () = register_operation crash_data_op
-- 
1.8.0




More information about the Libguestfs mailing list