[Libguestfs] [PATCH 3/5] sysprep: remove the custom kdump configurations

Wanlong Gao gaowanlong at cn.fujitsu.com
Fri Sep 6 07:52:40 UTC 2013


This removes the custom kdump configurations by emptying
the configuration file /etc/kdump.conf.

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

diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 9894baf..eb372aa 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -44,6 +44,7 @@ operations = \
 	firstboot \
 	fs_uuids \
 	hostname \
+	kdump_config \
 	kerberos_data \
 	lvm_uuids \
 	logfiles \
diff --git a/sysprep/sysprep_operation_kdump_config.ml b/sysprep/sysprep_operation_kdump_config.ml
new file mode 100644
index 0000000..358f97d
--- /dev/null
+++ b/sysprep/sysprep_operation_kdump_config.ml
@@ -0,0 +1,44 @@
+(* virt-sysprep
+ * Copyright (C) 2013 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 Common_gettext.Gettext
+
+module G = Guestfs
+
+let kdump_config_perform g root =
+  let typ = g#inspect_get_type root in
+  if typ <> "windows" then (
+    let path = "/etc/kdump.conf" in
+    (try g#rm path with G.Error _ -> ());
+    (try g#touch path with G.Error _ -> ());
+    [ `Created_files ]
+  )
+  else []
+
+let op = {
+  defaults with
+    name = "kdump-config";
+    enabled_by_default = false;
+    heading = s_"Remove the kdump configurations";
+    pod_description = Some (s_"\
+This removes the kdump configurations by emptying C</etc/kdump.conf>.");
+    perform_on_filesystems = Some kdump_config_perform;
+}
+
+let () = register_operation op
-- 
1.8.4.27.g0a41de8




More information about the Libguestfs mailing list