Re: [Libguestfs] Hivex, Python and Windows
by Richard W.M. Jones
On Mon, Apr 16, 2012 at 10:05:57AM +0200, Lorenzo Nicolodi wrote:
> I am developing a forensics software using your library but I am stucked
> because I need to run it on windows and, as far as I can see, the python
> module is available only for Linux.
>
> I am not so experienced and so I would ask to you how can I make it happen
> and some tips to start from.... if it will work, I would provide you this
> "hivex porting" ! :-)
Did you try compiling the software on Windows? Were there any
error messages?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
12 years, 8 months
Problem with backporting libguestfs 1.16.5 to squeeze
by Nikita A Menkovich
Hello
I am trying to backport package from debian sid to squeeze.
I backport some needed packages(some dependencies to qemu-kvm, libvirt, etc)
Before building I disable gobject in debian/{control,rules}
--- debian/rules 2012-02-13 22:51:18.000000000 +0400
+++ ../libguestfs-1.16.5_new/debian/rules 2012-02-28 23:53:50.307471412 +0400
@@ -11,7 +11,8 @@
--disable-appliance \
--with-readline \
--disable-haskell \
- --disable-php
+ --disable-php \
+ --disable-gobject
BARE_CONFIG_FLAGS = \
$(DEFAULT_CONFIG_FLAGS) \
@@ -136,4 +138,4 @@
%:
dh $@ \
--without=python-support \
- --with=autotools-dev,ocaml,python2,python3,bash-completion,ruby,gir
+ --with=autotools-dev,ocaml,python2,python3,bash-completion,ruby
When I try to build libguestfs I receive an error(full log attached):
cat: ../podfiles: No such file or directory
make[6]: Entering directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default/po-docs/ja'
make[7]: Entering directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default'
make[7]: Leaving directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default'
/bin/mkdir -p /home/lib/projects/libguestfs-1.16.5/debian/tmp/usr/share/man/ja/man1
/usr/bin/install -c -m 0644 guestfish.1
/home/lib/projects/libguestfs-1.16.5/debian/tmp/usr/share/man/ja/man1
/usr/bin/install: cannot stat `guestfish.1': No such file or directory
make[6]: *** [install-data-hook] Error 1
make[6]: Leaving directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default/po-docs/ja'
make[5]: *** [install-data-am] Error 2
make[5]: Leaving directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default/po-docs/ja'
make[4]: *** [install-am] Error 2
make[4]: Leaving directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default/po-docs/ja'
make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default/po-docs'
make[2]: *** [install-recursive] Ошибка 1
make[2]: Leaving directory
`/home/lib/projects/libguestfs-1.16.5/debian/build-default'
dh_auto_install: make -j1 install
DESTDIR=/home/lib/projects/libguestfs-1.16.5/debian/tmp returned exit
code 2
make[1]: *** [override_dh_auto_install] Ошибка 29
--
Nikita A Menkovich
http://libc6.org/
JID: menkovich(a)gmail.com
12 years, 8 months
[PATCH 0/4] libguestfs cannot open disk images which are symlinks to files that contain ':' (colon) character (RHBZ#812092).
by Richard W.M. Jones
Note: This is a regression in RHEL 6.3. Please review this patch
urgently.
The description of the bug is here:
https://bugzilla.redhat.com/show_bug.cgi?id=812092
This patch set attempts to fix the problem conservatively, because
it's a very high risk codepath and very late in the development of
RHEL 6.3.
The first patch reverts the behaviour of calling realpath(3) and
checking for duplicate filenames.
The second patch fixes 'check_path'. Only ':' is not permitted in
qemu paths. (However symlinks to paths that contain ':' will work
again because the first patch was reverted.)
The third patch adds proper escaping of ',' in qemu command line
parameters.
The fourth patch adds a regression test for filenames containing
unusual characters.
Rich.
12 years, 8 months
[PATCH 1/2] sysprep: remove .ssh directory in users' directory
by Wanlong Gao
Remove the .ssh directory of user "root" and any other
users who have a .ssh directory in their home directorys.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
TODO | 1 -
sysprep/Makefile.am | 2 ++
sysprep/sysprep_operation_ssh_userdir.ml | 46 ++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 sysprep/sysprep_operation_ssh_userdir.ml
diff --git a/TODO b/TODO
index 3d5613c..bf96ab0 100644
--- a/TODO
+++ b/TODO
@@ -543,7 +543,6 @@ virt-sysprep ideas
. run external guestfish script virt-sysprep --fish=/tmp/foo.fish
. rm /var/cache/apt/archives/*
- /var/run/* and pam_faillock's data files
- - homedirs/.ssh directory, especially /root/.ssh (Steve Grubb)
- if drives are encrypted, then dm-crypt key should be changed
and drives all re-encrypted
- /etc/pki
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 3a48702..f51fc07 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -46,6 +46,7 @@ SOURCES = \
sysprep_operation_script.ml \
sysprep_operation_smolt_uuid.ml \
sysprep_operation_ssh_hostkeys.ml \
+ sysprep_operation_ssh_userdir.ml \
sysprep_operation_udev_persistent_net.ml \
sysprep_operation_utmp.ml \
sysprep_operation_yum_uuid.ml \
@@ -70,6 +71,7 @@ OBJECTS = \
sysprep_operation_script.cmx \
sysprep_operation_smolt_uuid.cmx \
sysprep_operation_ssh_hostkeys.cmx \
+ sysprep_operation_ssh_userdir.cmx \
sysprep_operation_udev_persistent_net.cmx \
sysprep_operation_utmp.cmx \
sysprep_operation_yum_uuid.cmx \
diff --git a/sysprep/sysprep_operation_ssh_userdir.ml b/sysprep/sysprep_operation_ssh_userdir.ml
new file mode 100644
index 0000000..5b59416
--- /dev/null
+++ b/sysprep/sysprep_operation_ssh_userdir.ml
@@ -0,0 +1,46 @@
+(* 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
+
+module G = Guestfs
+
+let ssh_userdir_perform g root =
+ let typ = g#inspect_get_type root in
+ if typ <> "windows" then (
+ let dirs = g#glob_expand "/home/*/.ssh" in
+ Array.iter (
+ fun dir -> g#rm_rf dir;
+ ) dirs;
+ g#rm_rf "/root/.ssh";
+ []
+ )
+ else []
+
+let ssh_userdir_op = {
+ name = "ssh-userdir";
+ pod_description = "\
+Remove the C<.ssh> directory in the guest.
+
+Remove the C<.ssh> directory of user \"root\" and any other
+users who have a C<.ssh> directory in their home directorys.";
+ extra_args = [];
+ perform = ssh_userdir_perform;
+}
+
+let () = register_operation ssh_userdir_op
--
1.7.10
12 years, 8 months
[PATCH] sysprep: remove the bash history of users
by Wanlong Gao
Remove the bash history of users in home directory,
and history of root.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
sysprep/Makefile.am | 2 ++
sysprep/sysprep_operation_bash_history.ml | 44 +++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 sysprep/sysprep_operation_bash_history.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 8730bc0..3a48702 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -33,6 +33,7 @@ SOURCES = \
main.ml \
sysprep_operation.ml \
sysprep_operation.mli \
+ sysprep_operation_bash_history.ml \
sysprep_operation_cron_spool.ml \
sysprep_operation_dhcp_client_state.ml \
sysprep_operation_dhcp_server_state.ml \
@@ -56,6 +57,7 @@ if HAVE_OCAML
OBJECTS = \
utils.cmx \
sysprep_operation.cmx \
+ sysprep_operation_bash_history.cmx \
sysprep_operation_cron_spool.cmx \
sysprep_operation_dhcp_client_state.cmx \
sysprep_operation_dhcp_server_state.cmx \
diff --git a/sysprep/sysprep_operation_bash_history.ml b/sysprep/sysprep_operation_bash_history.ml
new file mode 100644
index 0000000..1f33ab6
--- /dev/null
+++ b/sysprep/sysprep_operation_bash_history.ml
@@ -0,0 +1,44 @@
+(* virt-sysprep
+ * Copyright (C) 2012 Fujitsu Inc.
+ *
+ * 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
+
+module G = Guestfs
+
+let bash_history_perform g root =
+ let typ = g#inspect_get_type root in
+ if typ <> "windows" then (
+ let files = g#glob_expand "/home/*/.bash_history" in
+ Array.iter g#rm_rf files;
+ g#rm_rf "/root/.bash_history";
+ []
+ )
+ else []
+
+let bash_history_op = {
+ name = "bash-history";
+ pod_description = "\
+Remove the bash history in the guest.
+
+Remove the bash history of user root and any other users
+who have a bash history file in his home directory.";
+ extra_args = [];
+ perform = bash_history_perform;
+}
+
+let () = register_operation bash_history_op
--
1.7.10.rc3
12 years, 8 months
[PATCH] sysprep: align the help message
by Wanlong Gao
Align the "virt-sysprep --help" output message.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
sysprep/sysprep_operation_hostname.ml | 2 +-
sysprep/sysprep_operation_script.ml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index 51f9386..6f52e48 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -59,7 +59,7 @@ parameter.
If the I<--hostname> parameter is not given, then the hostname is changed
to C<localhost.localdomain>.";
extra_args = [
- ("--hostname", Arg.Set_string hostname, "hostname New hostname"),
+ ("--hostname", Arg.Set_string hostname, "hostname\tNew hostname"),
"\
Change the hostname. If not given, defaults to C<localhost.localdomain>."
];
diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml
index 977d41f..e68468c 100644
--- a/sysprep/sysprep_operation_script.ml
+++ b/sysprep/sysprep_operation_script.ml
@@ -133,7 +133,7 @@ guest's DNS configuration file, but C<rm /etc/resolv.conf> would
Normally a temporary mount point for the guest is used, but you
can choose a specific one by using the I<--scriptdir> parameter.";
extra_args = [
- ("--scriptdir", Arg.String set_scriptdir, "dir Mount point on host"),
+ ("--scriptdir", Arg.String set_scriptdir, "dir\tMount point on host"),
"\
The mount point (an empty directory on the host) used when
the C<script> operation is enabled and one or more scripts
@@ -143,7 +143,7 @@ B<Note:> C<scriptdir> B<must> be an absolute path.
If I<--scriptdir> is not specified then a temporary mountpoint
will be created.";
- ("--script", Arg.String add_script, "script Script or program to run on guest"),
+ ("--script", Arg.String add_script, "script\tScript or program to run on guest"),
"\
Run the named C<script> (a shell script or program) against the
guest. The script can be any program on the host. The script's
--
1.7.10.rc3
12 years, 8 months
[PATCH] virt-sysprep:add logging feature
by Wanlong Gao
Hi Rich,
I did with your suggestions, please help reviewing.
I got a compiling error,
-
File "sysprep_operation.mli", line 23, characters 17-19:
Error: Unbound type parameter 'a
make: *** [sysprep_operation.cmi] Error 2
make: Leaving directory `/work/git/libguestfs/sysprep'
-
Thanks,
Wanlong Gao
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
sysprep/main.ml | 12 +++++++++---
sysprep/sysprep_operation.ml | 6 ++++--
sysprep/sysprep_operation.mli | 6 ++++--
sysprep/sysprep_operation_cron_spool.ml | 10 ++++++++--
sysprep/sysprep_operation_dhcp_client_state.ml | 9 +++++++--
sysprep/sysprep_operation_dhcp_server_state.ml | 8 ++++++--
sysprep/sysprep_operation_hostname.ml | 4 +++-
sysprep/sysprep_operation_logfiles.ml | 11 +++++++++--
sysprep/sysprep_operation_mail_spool.ml | 9 +++++++--
sysprep/sysprep_operation_net_hwaddr.ml | 3 ++-
sysprep/sysprep_operation_random_seed.ml | 3 ++-
sysprep/sysprep_operation_rhn_systemid.ml | 8 ++++++--
sysprep/sysprep_operation_script.ml | 2 +-
sysprep/sysprep_operation_smolt_uuid.ml | 8 ++++++--
sysprep/sysprep_operation_ssh_hostkeys.ml | 8 ++++++--
sysprep/sysprep_operation_udev_persistent_net.ml | 7 +++++--
sysprep/sysprep_operation_utmp.ml | 7 +++++--
sysprep/sysprep_operation_yum_uuid.ml | 8 ++++++--
18 files changed, 96 insertions(+), 33 deletions(-)
diff --git a/sysprep/main.ml b/sysprep/main.ml
index d06b0d2..c456521 100644
--- a/sysprep/main.ml
+++ b/sysprep/main.ml
@@ -29,7 +29,7 @@ let () = Sysprep_operation.bake ()
(* Command line argument parsing. *)
let prog = Filename.basename Sys.executable_name
-let debug_gc, operations, g, selinux_relabel =
+let debug_gc, operations, g, selinux_relabel, show_log =
let debug_gc = ref false in
let domain = ref None in
let dryrun = ref false in
@@ -40,6 +40,7 @@ let debug_gc, operations, g, selinux_relabel =
let selinux_relabel = ref `Auto in
let trace = ref false in
let verbose = ref false in
+ let show_log = ref false in
let display_version () =
let g = new G.guestfs () in
@@ -112,6 +113,7 @@ let debug_gc, operations, g, selinux_relabel =
"-V", Arg.Unit display_version, " Display version and exit";
"--version", Arg.Unit display_version, " -\"-";
"-x", Arg.Set trace, " Enable tracing of libguestfs calls";
+ "--log", Arg.Set show_log, " Enable operation logging";
] @ Sysprep_operation.extra_args () in
let anon_fun _ = raise (Arg.Bad "extra parameter on the command line") in
let usage_msg =
@@ -162,6 +164,7 @@ read the man page virt-sysprep(1).
let selinux_relabel = !selinux_relabel in
let trace = !trace in
let verbose = !verbose in
+ let show_log = !show_log in
(* Connect to libguestfs. *)
let g = new G.guestfs () in
@@ -170,7 +173,7 @@ read the man page virt-sysprep(1).
add g dryrun;
g#launch ();
- debug_gc, operations, g, selinux_relabel
+ debug_gc, operations, g, selinux_relabel, show_log
let () =
(* Inspection. *)
@@ -194,7 +197,10 @@ let () =
) mps;
(* Perform the operations. *)
- let flags = Sysprep_operation.perform_operations ?operations g root in
+ let flags = Sysprep_operation.perform_operations ?operations ~debug g root in
+
+ let debug fs =
+ ksprintf (fun str -> if show_log then prerr_endline str) fs in
(* Parse flags. *)
let relabel = ref false in
diff --git a/sysprep/sysprep_operation.ml b/sysprep/sysprep_operation.ml
index 3fd8afc..5bb870f 100644
--- a/sysprep/sysprep_operation.ml
+++ b/sysprep/sysprep_operation.ml
@@ -20,11 +20,13 @@ open Printf
type flag = [ `Created_files ]
+type debug_fn = ('a, unit, string, unit) format4 -> 'a
+
type operation = {
name : string;
pod_description : string;
extra_args : ((Arg.key * Arg.spec * Arg.doc) * string) list;
- perform : Guestfs.guestfs -> string -> flag list;
+ perform : Guestfs.guestfs -> debug:debug_fn -> string -> flag list;
}
let ops = ref []
@@ -169,7 +171,7 @@ let list_operations () =
*)
List.iter (fun op -> print_endline op.name ) !ops
-let perform_operations ?operations g root =
+let perform_operations ?operations ~debug g root =
assert !baked;
let ops =
diff --git a/sysprep/sysprep_operation.mli b/sysprep/sysprep_operation.mli
index 5fe035f..64976a9 100644
--- a/sysprep/sysprep_operation.mli
+++ b/sysprep/sysprep_operation.mli
@@ -20,6 +20,8 @@
type flag = [ `Created_files ]
+type debug_fn = ('a, unit, string, unit) format4 -> 'a
+
type operation = {
name : string;
(** Operation name, also used to enable the operation on the command
@@ -39,7 +41,7 @@ type operation = {
You can decide the types of the arguments, whether they are
mandatory etc. *)
- perform : Guestfs.guestfs -> string -> flag list;
+ perform : Guestfs.guestfs -> debug:debug_fn -> string -> flag list;
(** The function which is called to perform this operation, when
enabled.
@@ -95,5 +97,5 @@ val add_to_set : string -> set -> set
Note that this will raise [Not_found] if [name] is not
a valid operation name. *)
-val perform_operations : ?operations:set -> Guestfs.guestfs -> string -> flag list
+val perform_operations : ?operations:set -> Guestfs.guestfs -> debug:debug_fn -> string -> flag list
(** Perform all operations, or the subset listed in the [operations] set. *)
diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml
index e67688b..b822be7 100644
--- a/sysprep/sysprep_operation_cron_spool.ml
+++ b/sysprep/sysprep_operation_cron_spool.ml
@@ -17,11 +17,17 @@
*)
open Sysprep_operation
+open Utils
module G = Guestfs
-let cron_spool_perform g root =
- Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*");
+let cron_spool_perform ~debug g root =
+ let files = g#glob_expand "/var/spool/cron/*" in
+ Array.iter (
+ fun glob ->
+ g#rm glob
+ debug "Deleted %s" glob
+ ) files;
[]
let cron_spool_op = {
diff --git a/sysprep/sysprep_operation_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml
index e3e87cb..9048edb 100644
--- a/sysprep/sysprep_operation_dhcp_client_state.ml
+++ b/sysprep/sysprep_operation_dhcp_client_state.ml
@@ -20,11 +20,16 @@ open Sysprep_operation
module G = Guestfs
-let dhcp_client_state_perform g root =
+let dhcp_client_state_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ = "linux" then (
List.iter (
- fun glob -> Array.iter g#rm_rf (g#glob_expand glob)
+ fun glob ->
+ Array.iter (
+ fun glob2 ->
+ g#rm_rf glob2
+ debug "Deleted %s" glob2
+ ) (g#glob_expand glob)
) [ "/var/lib/dhclient/*"; "/var/lib/dhcp/*" (* RHEL 3 *) ]
);
[]
diff --git a/sysprep/sysprep_operation_dhcp_server_state.ml b/sysprep/sysprep_operation_dhcp_server_state.ml
index c5251ce..2d72ab7 100644
--- a/sysprep/sysprep_operation_dhcp_server_state.ml
+++ b/sysprep/sysprep_operation_dhcp_server_state.ml
@@ -20,8 +20,12 @@ open Sysprep_operation
module G = Guestfs
-let dhcp_server_state_perform g root =
- Array.iter g#rm_rf (g#glob_expand "/var/lib/dhcpd/*");
+let dhcp_server_state_perform ~debug g root =
+ Array.iter (
+ fun glob ->
+ g#rm_rf glob
+ debug "Deleted %s" glob
+ ) (g#glob_expand "/var/lib/dhcpd/*");
[]
let dhcp_server_state_op = {
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index 1472a1c..26c14a3 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -25,7 +25,7 @@ module G = Guestfs
let hostname = ref "localhost.localdomain"
-let hostname_perform g root =
+let hostname_perform ~debug g root =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
@@ -42,10 +42,12 @@ let hostname_perform g root =
String.concat "\n" lines ^
sprintf "\nHOSTNAME=%s\n" !hostname in
g#write filename file;
+ debug "Modified HOSTNAME to %s" !hostname
[ `Created_files ]
| "linux", ("debian"|"ubuntu") ->
g#write "/etc/hostname" !hostname;
+ debug "Modified HOSTNAME to %s" !hostname
[ `Created_files ]
| _ -> []
diff --git a/sysprep/sysprep_operation_logfiles.ml b/sysprep/sysprep_operation_logfiles.ml
index b4c6ea9..8bf5838 100644
--- a/sysprep/sysprep_operation_logfiles.ml
+++ b/sysprep/sysprep_operation_logfiles.ml
@@ -50,10 +50,17 @@ let globs = List.sort compare [
]
let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs)
-let logfiles_perform g root =
+let logfiles_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ = "linux" then (
- List.iter (fun glob -> Array.iter g#rm_rf (g#glob_expand glob)) globs
+ List.iter (
+ fun glob ->
+ Array.iter (
+ fun glob2 ->
+ g#rm_rf glob2
+ debug "Deleted %s\n" glob2
+ ) (g#glob_expand glob);
+ ) globs;
);
[]
diff --git a/sysprep/sysprep_operation_mail_spool.ml b/sysprep/sysprep_operation_mail_spool.ml
index 74f2d94..76cc40b 100644
--- a/sysprep/sysprep_operation_mail_spool.ml
+++ b/sysprep/sysprep_operation_mail_spool.ml
@@ -20,9 +20,14 @@ open Sysprep_operation
module G = Guestfs
-let mail_spool_perform g root =
+let mail_spool_perform ~debug g root =
List.iter (
- fun glob -> Array.iter g#rm_rf (g#glob_expand glob)
+ fun glob ->
+ Array.iter (
+ fun glob2 ->
+ g#rm_rf glob2
+ debug "Deleted %s" glob2
+ ) (g#glob_expand glob)
) [
"/var/spool/mail/*";
"/var/mail/*";
diff --git a/sysprep/sysprep_operation_net_hwaddr.ml b/sysprep/sysprep_operation_net_hwaddr.ml
index 8aa102a..86840c1 100644
--- a/sysprep/sysprep_operation_net_hwaddr.ml
+++ b/sysprep/sysprep_operation_net_hwaddr.ml
@@ -21,7 +21,7 @@ open Sysprep_operation
module G = Guestfs
-let net_hwaddr_perform g root =
+let net_hwaddr_perform ~debug g root =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
@@ -36,6 +36,7 @@ let net_hwaddr_perform g root =
) lines in
let file = String.concat "\n" lines ^ "\n" in
g#write filename file
+ debug "Replaced HWADDR in %s\n" filename
) filenames;
if filenames <> [||] then [ `Created_files ] else []
diff --git a/sysprep/sysprep_operation_random_seed.ml b/sysprep/sysprep_operation_random_seed.ml
index 989ffe8..1302918 100644
--- a/sysprep/sysprep_operation_random_seed.ml
+++ b/sysprep/sysprep_operation_random_seed.ml
@@ -20,7 +20,7 @@ open Sysprep_operation
module G = Guestfs
-let random_seed_perform g root =
+let random_seed_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ = "linux" then (
let files = [
@@ -37,6 +37,7 @@ let random_seed_perform g root =
close_in chan;
g#write file buf
+ debug "Modified %s\n" file
)
) files;
[ `Created_files ]
diff --git a/sysprep/sysprep_operation_rhn_systemid.ml b/sysprep/sysprep_operation_rhn_systemid.ml
index 35849e4..c00f262 100644
--- a/sysprep/sysprep_operation_rhn_systemid.ml
+++ b/sysprep/sysprep_operation_rhn_systemid.ml
@@ -20,13 +20,17 @@ open Sysprep_operation
module G = Guestfs
-let rhn_systemid_perform g root =
+let rhn_systemid_perform ~debug g root =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
| "linux", "rhel" ->
- (try g#rm "/etc/sysconfig/rhn/systemid" with G.Error _ -> ());
+ (try
+ let file = "/etc/sysconfig/rhn/systemid" in
+ g#rm file
+ debug "Deleted %s\n" file
+ with G.Error _ -> ());
[]
| _ -> []
diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml
index 977d41f..6364a54 100644
--- a/sysprep/sysprep_operation_script.ml
+++ b/sysprep/sysprep_operation_script.ml
@@ -35,7 +35,7 @@ let set_scriptdir dir =
let scripts = ref []
let add_script script = scripts := script :: !scripts
-let rec script_perform (g : Guestfs.guestfs) root =
+let rec script_perform ~debug (g : Guestfs.guestfs) root =
let scripts = List.rev !scripts in
if scripts <> [] then (
(* Create a temporary directory? *)
diff --git a/sysprep/sysprep_operation_smolt_uuid.ml b/sysprep/sysprep_operation_smolt_uuid.ml
index a85aa9b..aad87a5 100644
--- a/sysprep/sysprep_operation_smolt_uuid.ml
+++ b/sysprep/sysprep_operation_smolt_uuid.ml
@@ -20,14 +20,18 @@ open Sysprep_operation
module G = Guestfs
-let smolt_uuid_perform g root =
+let smolt_uuid_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ = "linux" then (
let files = [ "/etc/sysconfig/hw-uuid";
"/etc/smolt/uuid";
"/etc/smolt/hw-uuid" ] in
List.iter (
- fun file -> try g#rm file with G.Error _ -> ()
+ fun file ->
+ try
+ g#rm file
+ debug "Deleted %s\n" file
+ with G.Error _ -> ()
) files;
[]
diff --git a/sysprep/sysprep_operation_ssh_hostkeys.ml b/sysprep/sysprep_operation_ssh_hostkeys.ml
index 8da405b..4f3b569 100644
--- a/sysprep/sysprep_operation_ssh_hostkeys.ml
+++ b/sysprep/sysprep_operation_ssh_hostkeys.ml
@@ -20,11 +20,15 @@ open Sysprep_operation
module G = Guestfs
-let ssh_hostkeys_perform g root =
+let ssh_hostkeys_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ <> "windows" then (
let files = g#glob_expand "/etc/ssh/*_host_*" in
- Array.iter g#rm files;
+ Array.iter (
+ fun file ->
+ g#rm file
+ debug "Deleted %s\n" file
+ ) files;
[]
)
else []
diff --git a/sysprep/sysprep_operation_udev_persistent_net.ml b/sysprep/sysprep_operation_udev_persistent_net.ml
index e54e140..5b4941e 100644
--- a/sysprep/sysprep_operation_udev_persistent_net.ml
+++ b/sysprep/sysprep_operation_udev_persistent_net.ml
@@ -20,10 +20,13 @@ open Sysprep_operation
module G = Guestfs
-let udev_persistent_net_perform g root =
+let udev_persistent_net_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ = "linux" then (
- (try g#rm "/etc/udev/rules.d/70-persistent-net.rules"
+ (try
+ let file = "/etc/udev/rules.d/70-persistent-net.rules" in
+ g#rm file
+ debug "Deleted %s\n" file
with G.Error _ -> ());
[]
)
diff --git a/sysprep/sysprep_operation_utmp.ml b/sysprep/sysprep_operation_utmp.ml
index 69867e1..4d4950a 100644
--- a/sysprep/sysprep_operation_utmp.ml
+++ b/sysprep/sysprep_operation_utmp.ml
@@ -20,10 +20,13 @@ open Sysprep_operation
module G = Guestfs
-let utmp_perform g root =
+let utmp_perform ~debug g root =
let typ = g#inspect_get_type root in
if typ <> "windows" then (
- try g#rm "/var/run/utmp"
+ try
+ let file = "/var/run/utmp" in
+ g#rm file
+ debug "Deleted %s\n" file
with G.Error _ -> ()
);
[]
diff --git a/sysprep/sysprep_operation_yum_uuid.ml b/sysprep/sysprep_operation_yum_uuid.ml
index 396cac5..3b6738c 100644
--- a/sysprep/sysprep_operation_yum_uuid.ml
+++ b/sysprep/sysprep_operation_yum_uuid.ml
@@ -20,10 +20,14 @@ open Sysprep_operation
module G = Guestfs
-let yum_uuid_perform g root =
+let yum_uuid_perform ~debug g root =
let packager = g#inspect_get_package_management root in
if packager = "yum" then (
- (try g#rm "/var/lib/yum/uuid" with G.Error _ -> ());
+ (try
+ let file = "/var/lib/yum/uuid" in
+ g#rm file
+ debug "Deleted %s\n" file
+ with G.Error _ -> ());
[]
)
else []
--
1.7.10.rc3
12 years, 8 months
[PATCH] virt-sysprep:add logging feature
by Wanlong Gao
Hi Rich,
I tried to implement the logging feature, but I can't though
compiling with this patch now, could you please give me
some comments?
The error message is below,
---
ocamlfind ocamlopt -g -warn-error CDEFLMPSUVYZX -package unix -I ../src/.libs -I ../ocaml -c sysprep_operation.ml -o sysprep_operation.cmx
File "sysprep_operation.ml", line 1, characters 0-1:
Error: The implementation sysprep_operation.ml
does not match the interface sysprep_operation.cmi:
Type declarations do not match:
type operation = {
name : string;
pod_description : string;
extra_args : ((Arg.key * Arg.spec * Arg.doc) * string) list;
perform : Guestfs.guestfs -> string -> bool -> flag list;
}
is not included in
type operation = {
name : string;
pod_description : string;
extra_args : ((Arg.key * Arg.spec * Arg.doc) * string) list;
perform : Guestfs.guestfs -> string -> flag list;
}
The types for field perform are not equal.
make[2]: *** [sysprep_operation.cmx] Error 2
make[2]: Leaving directory `/work/git/libguestfs/sysprep'
Thanks a lot,
Wanlong Gao
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
sysprep/main.ml | 9 ++++++---
sysprep/sysprep_operation.ml | 6 +++---
sysprep/sysprep_operation_cron_spool.ml | 10 ++++++++--
sysprep/sysprep_operation_dhcp_client_state.ml | 9 +++++++--
sysprep/sysprep_operation_dhcp_server_state.ml | 8 ++++++--
sysprep/sysprep_operation_hostname.ml | 4 +++-
sysprep/sysprep_operation_logfiles.ml | 11 +++++++++--
sysprep/sysprep_operation_mail_spool.ml | 9 +++++++--
sysprep/sysprep_operation_net_hwaddr.ml | 3 ++-
sysprep/sysprep_operation_random_seed.ml | 3 ++-
sysprep/sysprep_operation_rhn_systemid.ml | 8 ++++++--
sysprep/sysprep_operation_script.ml | 2 +-
sysprep/sysprep_operation_smolt_uuid.ml | 8 ++++++--
sysprep/sysprep_operation_ssh_hostkeys.ml | 8 ++++++--
sysprep/sysprep_operation_udev_persistent_net.ml | 7 +++++--
sysprep/sysprep_operation_utmp.ml | 7 +++++--
sysprep/sysprep_operation_yum_uuid.ml | 8 ++++++--
sysprep/utils.ml | 4 ++++
18 files changed, 92 insertions(+), 32 deletions(-)
diff --git a/sysprep/main.ml b/sysprep/main.ml
index d06b0d2..7d3ce5e 100644
--- a/sysprep/main.ml
+++ b/sysprep/main.ml
@@ -29,7 +29,7 @@ let () = Sysprep_operation.bake ()
(* Command line argument parsing. *)
let prog = Filename.basename Sys.executable_name
-let debug_gc, operations, g, selinux_relabel =
+let debug_gc, operations, g, selinux_relabel, show_log =
let debug_gc = ref false in
let domain = ref None in
let dryrun = ref false in
@@ -40,6 +40,7 @@ let debug_gc, operations, g, selinux_relabel =
let selinux_relabel = ref `Auto in
let trace = ref false in
let verbose = ref false in
+ let show_log = ref false in
let display_version () =
let g = new G.guestfs () in
@@ -112,6 +113,7 @@ let debug_gc, operations, g, selinux_relabel =
"-V", Arg.Unit display_version, " Display version and exit";
"--version", Arg.Unit display_version, " -\"-";
"-x", Arg.Set trace, " Enable tracing of libguestfs calls";
+ "--log", Arg.Set show_log, " Enable operation logging";
] @ Sysprep_operation.extra_args () in
let anon_fun _ = raise (Arg.Bad "extra parameter on the command line") in
let usage_msg =
@@ -162,6 +164,7 @@ read the man page virt-sysprep(1).
let selinux_relabel = !selinux_relabel in
let trace = !trace in
let verbose = !verbose in
+ let show_log = !show_log in
(* Connect to libguestfs. *)
let g = new G.guestfs () in
@@ -170,7 +173,7 @@ read the man page virt-sysprep(1).
add g dryrun;
g#launch ();
- debug_gc, operations, g, selinux_relabel
+ debug_gc, operations, g, selinux_relabel, show_log
let () =
(* Inspection. *)
@@ -194,7 +197,7 @@ let () =
) mps;
(* Perform the operations. *)
- let flags = Sysprep_operation.perform_operations ?operations g root in
+ let flags = Sysprep_operation.perform_operations ?operations g root show_log in
(* Parse flags. *)
let relabel = ref false in
diff --git a/sysprep/sysprep_operation.ml b/sysprep/sysprep_operation.ml
index 3fd8afc..65013c5 100644
--- a/sysprep/sysprep_operation.ml
+++ b/sysprep/sysprep_operation.ml
@@ -24,7 +24,7 @@ type operation = {
name : string;
pod_description : string;
extra_args : ((Arg.key * Arg.spec * Arg.doc) * string) list;
- perform : Guestfs.guestfs -> string -> flag list;
+ perform : Guestfs.guestfs -> string -> bool -> flag list;
}
let ops = ref []
@@ -169,7 +169,7 @@ let list_operations () =
*)
List.iter (fun op -> print_endline op.name ) !ops
-let perform_operations ?operations g root =
+let perform_operations ?operations g root show_log =
assert !baked;
let ops =
@@ -182,7 +182,7 @@ let perform_operations ?operations g root =
List.map (
fun op ->
(* eprintf "calling %S.perform g %S\n" op.name root; *)
- op.perform g root
+ op.perform g root show_log
) ops in
List.flatten flags
diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml
index e67688b..6bd6ec4 100644
--- a/sysprep/sysprep_operation_cron_spool.ml
+++ b/sysprep/sysprep_operation_cron_spool.ml
@@ -17,11 +17,17 @@
*)
open Sysprep_operation
+open Utils
module G = Guestfs
-let cron_spool_perform g root =
- Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*");
+let cron_spool_perform g root show_log =
+ let files = g#glob_expand "/var/spool/cron/*" in
+ Array.iter (
+ fun glob ->
+ g#rm glob
+ logging show_log "Deleted %s" glob
+ ) files;
[]
let cron_spool_op = {
diff --git a/sysprep/sysprep_operation_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml
index e3e87cb..17bb65b 100644
--- a/sysprep/sysprep_operation_dhcp_client_state.ml
+++ b/sysprep/sysprep_operation_dhcp_client_state.ml
@@ -20,11 +20,16 @@ open Sysprep_operation
module G = Guestfs
-let dhcp_client_state_perform g root =
+let dhcp_client_state_perform g root show_log =
let typ = g#inspect_get_type root in
if typ = "linux" then (
List.iter (
- fun glob -> Array.iter g#rm_rf (g#glob_expand glob)
+ fun glob ->
+ Array.iter (
+ fun glob2 ->
+ g#rm_rf glob2
+ logging show_log "Deleted %s" glob2
+ ) (g#glob_expand glob)
) [ "/var/lib/dhclient/*"; "/var/lib/dhcp/*" (* RHEL 3 *) ]
);
[]
diff --git a/sysprep/sysprep_operation_dhcp_server_state.ml b/sysprep/sysprep_operation_dhcp_server_state.ml
index c5251ce..604a601 100644
--- a/sysprep/sysprep_operation_dhcp_server_state.ml
+++ b/sysprep/sysprep_operation_dhcp_server_state.ml
@@ -20,8 +20,12 @@ open Sysprep_operation
module G = Guestfs
-let dhcp_server_state_perform g root =
- Array.iter g#rm_rf (g#glob_expand "/var/lib/dhcpd/*");
+let dhcp_server_state_perform g root show_log =
+ Array.iter (
+ fun glob ->
+ g#rm_rf glob
+ logging show_log "Deleted %s" glob
+ ) (g#glob_expand "/var/lib/dhcpd/*");
[]
let dhcp_server_state_op = {
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index 1472a1c..caf5358 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -25,7 +25,7 @@ module G = Guestfs
let hostname = ref "localhost.localdomain"
-let hostname_perform g root =
+let hostname_perform g root show_log =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
@@ -42,10 +42,12 @@ let hostname_perform g root =
String.concat "\n" lines ^
sprintf "\nHOSTNAME=%s\n" !hostname in
g#write filename file;
+ logging show_log "Modified HOSTNAME to %s" !hostname
[ `Created_files ]
| "linux", ("debian"|"ubuntu") ->
g#write "/etc/hostname" !hostname;
+ logging show_log "Modified HOSTNAME to %s" !hostname
[ `Created_files ]
| _ -> []
diff --git a/sysprep/sysprep_operation_logfiles.ml b/sysprep/sysprep_operation_logfiles.ml
index b4c6ea9..ba7fe45 100644
--- a/sysprep/sysprep_operation_logfiles.ml
+++ b/sysprep/sysprep_operation_logfiles.ml
@@ -50,10 +50,17 @@ let globs = List.sort compare [
]
let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs)
-let logfiles_perform g root =
+let logfiles_perform g root show_log =
let typ = g#inspect_get_type root in
if typ = "linux" then (
- List.iter (fun glob -> Array.iter g#rm_rf (g#glob_expand glob)) globs
+ List.iter (
+ fun glob ->
+ Array.iter (
+ fun glob2 ->
+ g#rm_rf glob2
+ logging show_log "Deleted %s\n" glob2
+ ) (g#glob_expand glob);
+ ) globs;
);
[]
diff --git a/sysprep/sysprep_operation_mail_spool.ml b/sysprep/sysprep_operation_mail_spool.ml
index 74f2d94..2add3cb 100644
--- a/sysprep/sysprep_operation_mail_spool.ml
+++ b/sysprep/sysprep_operation_mail_spool.ml
@@ -20,9 +20,14 @@ open Sysprep_operation
module G = Guestfs
-let mail_spool_perform g root =
+let mail_spool_perform g root show_log =
List.iter (
- fun glob -> Array.iter g#rm_rf (g#glob_expand glob)
+ fun glob ->
+ Array.iter (
+ fun glob2 ->
+ g#rm_rf glob2
+ logging show_log "Deleted %s" glob2
+ ) (g#glob_expand glob)
) [
"/var/spool/mail/*";
"/var/mail/*";
diff --git a/sysprep/sysprep_operation_net_hwaddr.ml b/sysprep/sysprep_operation_net_hwaddr.ml
index 8aa102a..0a59197 100644
--- a/sysprep/sysprep_operation_net_hwaddr.ml
+++ b/sysprep/sysprep_operation_net_hwaddr.ml
@@ -21,7 +21,7 @@ open Sysprep_operation
module G = Guestfs
-let net_hwaddr_perform g root =
+let net_hwaddr_perform g root show_log =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
@@ -36,6 +36,7 @@ let net_hwaddr_perform g root =
) lines in
let file = String.concat "\n" lines ^ "\n" in
g#write filename file
+ logging show_log "Replaced HWADDR in %s\n" filename
) filenames;
if filenames <> [||] then [ `Created_files ] else []
diff --git a/sysprep/sysprep_operation_random_seed.ml b/sysprep/sysprep_operation_random_seed.ml
index 989ffe8..6bafa09 100644
--- a/sysprep/sysprep_operation_random_seed.ml
+++ b/sysprep/sysprep_operation_random_seed.ml
@@ -20,7 +20,7 @@ open Sysprep_operation
module G = Guestfs
-let random_seed_perform g root =
+let random_seed_perform g root show_log =
let typ = g#inspect_get_type root in
if typ = "linux" then (
let files = [
@@ -37,6 +37,7 @@ let random_seed_perform g root =
close_in chan;
g#write file buf
+ logging show_log "Modified %s\n" file
)
) files;
[ `Created_files ]
diff --git a/sysprep/sysprep_operation_rhn_systemid.ml b/sysprep/sysprep_operation_rhn_systemid.ml
index 35849e4..6b55382 100644
--- a/sysprep/sysprep_operation_rhn_systemid.ml
+++ b/sysprep/sysprep_operation_rhn_systemid.ml
@@ -20,13 +20,17 @@ open Sysprep_operation
module G = Guestfs
-let rhn_systemid_perform g root =
+let rhn_systemid_perform g root show_log =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
| "linux", "rhel" ->
- (try g#rm "/etc/sysconfig/rhn/systemid" with G.Error _ -> ());
+ (try
+ let file = "/etc/sysconfig/rhn/systemid" in
+ g#rm file
+ logging show_log "Deleted %s\n" file
+ with G.Error _ -> ());
[]
| _ -> []
diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml
index 977d41f..65b23c6 100644
--- a/sysprep/sysprep_operation_script.ml
+++ b/sysprep/sysprep_operation_script.ml
@@ -35,7 +35,7 @@ let set_scriptdir dir =
let scripts = ref []
let add_script script = scripts := script :: !scripts
-let rec script_perform (g : Guestfs.guestfs) root =
+let rec script_perform (g : Guestfs.guestfs) root show_log =
let scripts = List.rev !scripts in
if scripts <> [] then (
(* Create a temporary directory? *)
diff --git a/sysprep/sysprep_operation_smolt_uuid.ml b/sysprep/sysprep_operation_smolt_uuid.ml
index a85aa9b..78bca48 100644
--- a/sysprep/sysprep_operation_smolt_uuid.ml
+++ b/sysprep/sysprep_operation_smolt_uuid.ml
@@ -20,14 +20,18 @@ open Sysprep_operation
module G = Guestfs
-let smolt_uuid_perform g root =
+let smolt_uuid_perform g root show_log =
let typ = g#inspect_get_type root in
if typ = "linux" then (
let files = [ "/etc/sysconfig/hw-uuid";
"/etc/smolt/uuid";
"/etc/smolt/hw-uuid" ] in
List.iter (
- fun file -> try g#rm file with G.Error _ -> ()
+ fun file ->
+ try
+ g#rm file
+ logging show_log "Deleted %s\n" file
+ with G.Error _ -> ()
) files;
[]
diff --git a/sysprep/sysprep_operation_ssh_hostkeys.ml b/sysprep/sysprep_operation_ssh_hostkeys.ml
index 8da405b..cd62342 100644
--- a/sysprep/sysprep_operation_ssh_hostkeys.ml
+++ b/sysprep/sysprep_operation_ssh_hostkeys.ml
@@ -20,11 +20,15 @@ open Sysprep_operation
module G = Guestfs
-let ssh_hostkeys_perform g root =
+let ssh_hostkeys_perform g root show_log =
let typ = g#inspect_get_type root in
if typ <> "windows" then (
let files = g#glob_expand "/etc/ssh/*_host_*" in
- Array.iter g#rm files;
+ Array.iter (
+ fun file ->
+ g#rm file
+ logging show_log "Deleted %s\n" file
+ ) files;
[]
)
else []
diff --git a/sysprep/sysprep_operation_udev_persistent_net.ml b/sysprep/sysprep_operation_udev_persistent_net.ml
index e54e140..c4a6696 100644
--- a/sysprep/sysprep_operation_udev_persistent_net.ml
+++ b/sysprep/sysprep_operation_udev_persistent_net.ml
@@ -20,10 +20,13 @@ open Sysprep_operation
module G = Guestfs
-let udev_persistent_net_perform g root =
+let udev_persistent_net_perform g root show_log =
let typ = g#inspect_get_type root in
if typ = "linux" then (
- (try g#rm "/etc/udev/rules.d/70-persistent-net.rules"
+ (try
+ let file = "/etc/udev/rules.d/70-persistent-net.rules" in
+ g#rm file
+ logging show_log "Deleted %s\n" file
with G.Error _ -> ());
[]
)
diff --git a/sysprep/sysprep_operation_utmp.ml b/sysprep/sysprep_operation_utmp.ml
index 69867e1..2f9394d 100644
--- a/sysprep/sysprep_operation_utmp.ml
+++ b/sysprep/sysprep_operation_utmp.ml
@@ -20,10 +20,13 @@ open Sysprep_operation
module G = Guestfs
-let utmp_perform g root =
+let utmp_perform g root show_log =
let typ = g#inspect_get_type root in
if typ <> "windows" then (
- try g#rm "/var/run/utmp"
+ try
+ let file = "/var/run/utmp" in
+ g#rm file
+ logging show_log "Deleted %s\n" file
with G.Error _ -> ()
);
[]
diff --git a/sysprep/sysprep_operation_yum_uuid.ml b/sysprep/sysprep_operation_yum_uuid.ml
index 396cac5..f7940de 100644
--- a/sysprep/sysprep_operation_yum_uuid.ml
+++ b/sysprep/sysprep_operation_yum_uuid.ml
@@ -20,10 +20,14 @@ open Sysprep_operation
module G = Guestfs
-let yum_uuid_perform g root =
+let yum_uuid_perform g root show_log =
let packager = g#inspect_get_package_management root in
if packager = "yum" then (
- (try g#rm "/var/lib/yum/uuid" with G.Error _ -> ());
+ (try
+ let file = "/var/lib/yum/uuid" in
+ g#rm file
+ logging show_log "Deleted %s\n" file
+ with G.Error _ -> ());
[]
)
else []
diff --git a/sysprep/utils.ml b/sysprep/utils.ml
index dfac57d..55c695a 100644
--- a/sysprep/utils.ml
+++ b/sysprep/utils.ml
@@ -69,3 +69,7 @@ let string_random8 =
String.make 1 c
) [1;2;3;4;5;6;7;8]
)
+
+let logging show_log list =
+ if show_log then
+ eprintf list
--
1.7.10.rc3
12 years, 8 months
P2V: Error while converting Windows server
by Ricardo Argüello
Hi,
I'm trying to do a physical-to-virtual migration for a Windows 2003
Server to RHEV 3.0 and I'm getting errors in the conversion.
I created a Virt-P2V.iso using Fedora 16 (i686) using virt-v2v-0.8.7 and
virt-p2v-image-builder-0.8.7 instead of the 0.8.5 version available in
the repos. The conversion server is the same server where I created the ISO.
I edited the /etc/virt-v2v.conf file to configure a RHEV 3.0 Export
Domain as the target:
<virt-v2v>
<profile name="rhev-sparse">
<method>rhev</method>
<storage format='qcow2' allocation='sparse'>
192.168.1.11:/RHEV/export
</storage>
<network type="default">
<network type="network" name="rhevm"/>
</network>
</profile>
<network type='network' name='default'>
<network type='network' name='rhevm'/>
</network>
</virt-v2v>
I created the RHEV Export Domain and I activated it.
I booted the physical server with the Virt-P2V ISO and entered the
conversion server information. I choosed the "rhev-sparse" method and
let the other parameters by default.
The sda hard disk begins to get transfered and after some minutes I get
this error in the virt-p2v-server log:
# cat virt-p2v-server.1333661869.log
virt-v2v: pwrite_device: pwrite_device: offset is negative at
/usr/share/perl5/vendor_perl/Sys/VirtConvert/GuestfsHandle.pm line 203,
<> line 6.
at /usr/share/perl5/vendor_perl/Sys/VirtConvert/Transfer/Local.pm line 271
The transfer file gets deleted in the NFS export 192.168.1.11:/RHEV/export
I tried changing the conversion method to "preallocated" by putting this
in the config file:
<profile name="rhev-preallocated">
<method>rhev</method>
<storage format='raw' allocation='preallocated'>
192.168.1.11:/RHEV/export
</storage>
<network type="default">
<network type="network" name="rhevm"/>
</network>
</profile>
It obviously takes longer to transfer to the conversion server, but
after a few hour it gives me this error in the virt-p2v-server log:
# cat /var/log/virt-p2v-server.1333670581.log
warning: Unable to get device geometry for /var/tmp/guestfs.9vgHe0/root
virt-v2v: Died at /usr/bin/virt-p2v-server line 394, <> line 7.
Any ideas?
--
Ricardo Arguello - RHCE, RHCI
12 years, 8 months