[PATCH] v2v: vddk: Print passthrough options.
by Richard W.M. Jones
Changes the output to look like:
[ 0.0] Opening the source -i libvirt -ic vpx://... guestname --vddk ... --vddk-thumbprint ...
---
v2v/input_libvirt_vddk.ml | 43 ++++++++++++++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/v2v/input_libvirt_vddk.ml b/v2v/input_libvirt_vddk.ml
index 13a6a1561..e5122ccdd 100644
--- a/v2v/input_libvirt_vddk.ml
+++ b/v2v/input_libvirt_vddk.ml
@@ -102,8 +102,34 @@ See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.") library_path
error (f_"You must pass the ‘--vddk-thumbprint’ option with the SSL thumbprint of the VMware server. To find the thumbprint, see the nbdkit-vddk-plugin(1) manual. See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.")
in
+ (* List of passthrough parameters. *)
+ let passthrus =
+ [ "config", (fun { vddk_config } -> vddk_config);
+ "cookie", (fun { vddk_cookie } -> vddk_cookie);
+ "nfchostport", (fun { vddk_nfchostport } -> vddk_nfchostport);
+ "port", (fun { vddk_port } -> vddk_port);
+ "snapshot", (fun { vddk_snapshot } -> vddk_snapshot);
+ "thumbprint", (fun { vddk_thumbprint } -> vddk_thumbprint);
+ "transports", (fun { vddk_transports } -> vddk_transports);
+ "vimapiver", (fun { vddk_vimapiver } -> vddk_vimapiver) ] in
+
object
- inherit input_libvirt password libvirt_uri guest
+ inherit input_libvirt password libvirt_uri guest as super
+
+ method as_options =
+ let pt_options =
+ String.concat "" (
+ List.map (
+ fun (name, get_field) ->
+ match get_field vddk_options with
+ | None -> ""
+ | Some field -> sprintf " --vddk-%s %s" name field
+ ) passthrus
+ ) in
+ sprintf "%s --vddk %s%s"
+ super#as_options (* superclass prints "-i libvirt etc" *)
+ vddk_options.vddk_libdir
+ pt_options
method source () =
error_unless_vddk_libdir ();
@@ -210,16 +236,11 @@ object
add_arg (sprintf "libdir=%s" libdir);
(* The passthrough parameters. *)
- let pt name =
- Option.may (fun field -> add_arg (sprintf "%s=%s" name field)) in
- pt "config" vddk_options.vddk_config;
- pt "cookie" vddk_options.vddk_cookie;
- pt "nfchostport" vddk_options.vddk_nfchostport;
- pt "port" vddk_options.vddk_port;
- pt "snapshot" vddk_options.vddk_snapshot;
- pt "thumbprint" vddk_options.vddk_thumbprint;
- pt "transports" vddk_options.vddk_transports;
- pt "vimapiver" vddk_options.vddk_vimapiver;
+ List.iter (
+ fun (name, get_field) ->
+ Option.may (fun field -> add_arg (sprintf "%s=%s" name field))
+ (get_field vddk_options)
+ ) passthrus;
get_args () in
--
2.13.2
7 years, 1 month
[PATCH 0/5] v2v: Handle disks with snapshots (RHBZ#1172425).
by Richard W.M. Jones
The first commit removes the --dcpath parameter, which just makes the
following stuff simpler. Since libvirt has supported getting
datacenterpath from VMware since Oct 2015, it's time to drop this
hairy parameter.
The rest is quite a complicated series of refactorings, followed by a
very simple change to add handling of snapshots taken from old
virt-v2v.
Rich.
7 years, 1 month
[PATCH v2] daemon: proto: Make the guestfsd main loop messages consistent and useful.
by Richard W.M. Jones
After this change the debugging output looks like this:
guestfsd: enter: mount (0x1) request length 64 bytes
commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle -E /dev/sda1
calling: settle
command: mount '/dev/sda1' '/sysroot//'
[ 0.951731] EXT4-fs (sda1): mounting ext2 file system using the ext4 subsystem
[ 0.954585] EXT4-fs (sda1): mounted filesystem without journal. Opts: (null)
guestfsd: leave: mount (0x1) took 0.01 secs
guestfsd: enter: touch (0x3) request length 52 bytes
guestfsd: leave: touch (0x3) took 0.00 secs
---
daemon/proto.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/daemon/proto.c b/daemon/proto.c
index 14f7efe94..9abc46962 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -96,11 +96,6 @@ main_loop (int _sock)
xdr_u_int (&xdr, &len);
xdr_destroy (&xdr);
- if (verbose)
- fprintf (stderr,
- "guestfsd: main_loop: new request, len 0x%" PRIx32 "\n",
- len);
-
/* Cancellation sent from the library and received after the
* previous request has finished processing. Just ignore it.
*/
@@ -175,6 +170,13 @@ main_loop (int _sock)
progress_hint = hdr.progress_hint;
optargs_bitmask = hdr.optargs_bitmask;
+ if (verbose)
+ fprintf (stderr,
+ "guestfsd: enter: %s (0x%x) request length %" PRIu32 " bytes\n",
+ proc_nr >= 0 && proc_nr <= GUESTFS_MAX_PROC_NR
+ ? function_names[proc_nr] : "UNKNOWN PROCEDURE",
+ (unsigned) proc_nr, len);
+
/* Clear errors before we call the stub functions. This is just
* to ensure that we can accurately report errors in cases where
* error handling paths don't set errno correctly.
@@ -200,10 +202,10 @@ main_loop (int _sock)
elapsed_us = end_us - start_us;
fprintf (stderr,
- "guestfsd: main_loop: proc %d (%s) took %d.%02d seconds\n",
- proc_nr,
+ "guestfsd: leave: %s (0x%x) took %d.%02d secs\n",
proc_nr >= 0 && proc_nr <= GUESTFS_MAX_PROC_NR
? function_names[proc_nr] : "UNKNOWN PROCEDURE",
+ (unsigned) proc_nr,
(int) (elapsed_us / 1000000),
(int) ((elapsed_us / 10000) % 100));
}
--
2.13.2
7 years, 1 month
[PATCH] daemon: inspection: Add support for NeoKylin (RHBZ#1476081).
by Richard W.M. Jones
Thanks: Qingzheng Zhang
---
daemon/inspect_fs.ml | 7 +++++++
daemon/inspect_fs_unix.ml | 16 +++++++++++++++-
daemon/inspect_types.ml | 2 ++
daemon/inspect_types.mli | 1 +
generator/actions_inspection.ml | 4 ++++
inspector/virt-inspector.rng | 1 +
6 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml
index 93a9f4732..f639bf3b9 100644
--- a/daemon/inspect_fs.ml
+++ b/daemon/inspect_fs.ml
@@ -253,6 +253,7 @@ and check_package_format { distro } =
| Some DISTRO_MAGEIA
| Some DISTRO_MANDRIVA
| Some DISTRO_MEEGO
+ | Some DISTRO_NEOKYLIN
| Some DISTRO_OPENSUSE
| Some DISTRO_ORACLE_LINUX
| Some DISTRO_REDHAT_BASED
@@ -307,6 +308,12 @@ and check_package_management { distro; version } =
(* Probably parsing the release file failed, see RHBZ#1332025. *)
None
+ | Some DISTRO_NEOKYLIN ->
+ (* We don't have access to NeoKylin for testing, but it is
+ * supposed to be a Fedora derivative.
+ *)
+ Some PACKAGE_MANAGEMENT_DNF
+
| Some DISTRO_CENTOS
| Some DISTRO_ORACLE_LINUX
| Some DISTRO_REDHAT_BASED
diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
index ce48942bd..3b57899cc 100644
--- a/daemon/inspect_fs_unix.ml
+++ b/daemon/inspect_fs_unix.ml
@@ -53,6 +53,7 @@ let re_minix = PCRE.compile "^(\\d+)\\.(\\d+)(\\.(\\d+))?"
let re_openbsd = PCRE.compile "^OpenBSD (\\d+|\\?)\\.(\\d+|\\?)"
let re_frugalware = PCRE.compile "Frugalware (\\d+)\\.(\\d+)"
let re_pldlinux = PCRE.compile "(\\d+)\\.(\\d+) PLD Linux"
+let re_neokylin_version = PCRE.compile "^V(\\d+)Update(\\d+)$"
let arch_binaries =
[ "/bin/bash"; "/bin/ls"; "/bin/echo"; "/bin/rm"; "/bin/sh" ]
@@ -94,7 +95,7 @@ let rec parse_os_release release_file data =
else if key = "PRETTY_NAME" then
data.product_name <- Some value
else if key = "VERSION_ID" then
- parse_version_from_major_minor value data
+ parse_os_release_version_id value data
)
) lines;
@@ -124,6 +125,18 @@ let rec parse_os_release release_file data =
| _ -> true
)
+and parse_os_release_version_id value data =
+ (* NeoKylin uses a non-standard format in the VERSION_ID
+ * field (RHBZ#1476081).
+ *)
+ if PCRE.matches re_neokylin_version value then (
+ let major = int_of_string (PCRE.sub 1)
+ and minor = int_of_string (PCRE.sub 2) in
+ data.version <- Some (major, minor)
+ )
+ else
+ parse_version_from_major_minor value data
+
(* ID="fedora" => Some DISTRO_FEDORA *)
and distro_of_os_release_id = function
| "alpine" -> Some DISTRO_ALPINE_LINUX
@@ -135,6 +148,7 @@ and distro_of_os_release_id = function
| "fedora" -> Some DISTRO_FEDORA
| "frugalware" -> Some DISTRO_FRUGALWARE
| "mageia" -> Some DISTRO_MAGEIA
+ | "neokylin" -> Some DISTRO_NEOKYLIN
| "opensuse" -> Some DISTRO_OPENSUSE
| "pld" -> Some DISTRO_PLD_LINUX
| "rhel" -> Some DISTRO_RHEL
diff --git a/daemon/inspect_types.ml b/daemon/inspect_types.ml
index 1da41064d..333d2679a 100644
--- a/daemon/inspect_types.ml
+++ b/daemon/inspect_types.ml
@@ -82,6 +82,7 @@ and distro =
| DISTRO_MAGEIA
| DISTRO_MANDRIVA
| DISTRO_MEEGO
+ | DISTRO_NEOKYLIN
| DISTRO_NETBSD
| DISTRO_OPENBSD
| DISTRO_OPENSUSE
@@ -210,6 +211,7 @@ and string_of_distro = function
| DISTRO_MAGEIA -> "mageia"
| DISTRO_MANDRIVA -> "mandriva"
| DISTRO_MEEGO -> "meego"
+ | DISTRO_NEOKYLIN -> "neokylin"
| DISTRO_NETBSD -> "netbsd"
| DISTRO_OPENBSD -> "openbsd"
| DISTRO_OPENSUSE -> "opensuse"
diff --git a/daemon/inspect_types.mli b/daemon/inspect_types.mli
index 5c2151e14..d873df8c9 100644
--- a/daemon/inspect_types.mli
+++ b/daemon/inspect_types.mli
@@ -89,6 +89,7 @@ and distro =
| DISTRO_MAGEIA
| DISTRO_MANDRIVA
| DISTRO_MEEGO
+ | DISTRO_NEOKYLIN
| DISTRO_NETBSD
| DISTRO_OPENBSD
| DISTRO_OPENSUSE
diff --git a/generator/actions_inspection.ml b/generator/actions_inspection.ml
index d67d00833..675a7e2e2 100644
--- a/generator/actions_inspection.ml
+++ b/generator/actions_inspection.ml
@@ -226,6 +226,10 @@ Mandriva.
MeeGo.
+=item \"neokylin\"
+
+NeoKylin.
+
=item \"netbsd\"
NetBSD.
diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng
index 857a02766..314785202 100644
--- a/inspector/virt-inspector.rng
+++ b/inspector/virt-inspector.rng
@@ -90,6 +90,7 @@
<value>mageia</value>
<value>mandriva</value>
<value>meego</value>
+ <value>neokylin</value>
<value>netbsd</value>
<value>openbsd</value>
<value>opensuse</value>
--
2.13.2
7 years, 1 month
[PATCH] p2v: Enable miniexpect debugging.
by Richard W.M. Jones
---
p2v/ssh.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/p2v/ssh.c b/p2v/ssh.c
index 991888348..4966097ff 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -392,6 +392,9 @@ start_ssh (unsigned spawn_flags, struct config *config,
set_ssh_internal_error ("ssh: mexp_spawnvf: %m");
return NULL;
}
+#if DEBUG_STDERR
+ mexp_set_debug_file (h, stderr);
+#endif
/* We want the ssh ConnectTimeout to be less than the miniexpect
* timeout, so that if the server is completely unresponsive we
@@ -414,7 +417,8 @@ start_ssh (unsigned spawn_flags, struct config *config,
{ 0 }
}, ovector, ovecsize)) {
case 100: /* Got password prompt. */
- if (mexp_printf (h, "%s\n", config->password) == -1) {
+ if (mexp_printf_password (h, "%s", config->password) == -1 ||
+ mexp_printf (h, "\n") == -1) {
set_ssh_mexp_error ("mexp_printf");
mexp_close (h);
return NULL;
@@ -658,6 +662,9 @@ scp_file (struct config *config, const char *target, const char *local, ...)
set_ssh_internal_error ("scp: mexp_spawnv: %m");
return -1;
}
+#if DEBUG_STDERR
+ mexp_set_debug_file (h, stderr);
+#endif
/* We want the ssh ConnectTimeout to be less than the miniexpect
* timeout, so that if the server is completely unresponsive we
@@ -680,7 +687,8 @@ scp_file (struct config *config, const char *target, const char *local, ...)
{ 0 }
}, ovector, ovecsize)) {
case 100: /* Got password prompt. */
- if (mexp_printf (h, "%s\n", config->password) == -1) {
+ if (mexp_printf_password (h, "%s", config->password) == -1 ||
+ mexp_printf (h, "\n") == -1) {
set_ssh_mexp_error ("mexp_printf");
mexp_close (h);
return -1;
--
2.13.2
7 years, 1 month
[PATCH] daemon: proto: Remove pervasive but useless debugging messages.
by Richard W.M. Jones
If you spend your time looking at libguestfs debugging output you'll
see many messages from the daemon main loop like this:
guestfsd: main_loop: new request, len 0x54
guestfsd: main_loop: proc 278 (mkfs) took 0.02 seconds
I don't think these messages really bring much value. This commit
removes them entirely.
An alternative might be to change them to make them shorter and/or
less useless, but I'm not sure what that would be.
Rich.
7 years, 1 month
ZFS Support
by Miha Pleško
Dear libguestfs developers,
as explained yesterday by Ubuntu guys on my bug report https://bugs.launchpad.net/ubuntu/+source/libguestfs/+bug/1722800
the libguestfs currently supports ZFS filesystem only partially i.e. for virt-rescue.
Q: Would it be possible to bring ZFS support also to other libguestfs utils, like guestfish and virt-format?
I would need to have two usecases supported:
a) create a new volume with ZFS filesystem / format existing volume into ZFS filesystem
b) manage files from ZFS volume (read, write)
I'm looking forward to be hearing your opinion/plans regarding this.
Thank you and Best Regards,
Miha
7 years, 1 month
[PATCH] v2v: -i vmx: Refuse to load a disk image by accident.
by Richard W.M. Jones
If you accidentally point -i vmx at a disk image, it will try to load
the whole thing into memory and crash. Catch this narrow case and
print an error.
However don't fail if ‘file’ is not installed or if we don't know what
the file is.
---
v2v/parse_vmx.ml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/v2v/parse_vmx.ml b/v2v/parse_vmx.ml
index 65d5a0edd..f6c34e2cf 100644
--- a/v2v/parse_vmx.ml
+++ b/v2v/parse_vmx.ml
@@ -268,6 +268,18 @@ let remove_vmx_escapes str =
(* Parsing. *)
let rec parse_file vmx_filename =
+ (* One person pointed -i vmx at the VMDK file, resulting in an out
+ * of memory error. Avoid this narrow case.
+ *)
+ let () =
+ let cmd = sprintf "file -b %s ||:" (quote vmx_filename) in
+ let out = external_command cmd in
+ match out with
+ | line :: _ when String.find line "disk image" >= 0 ->
+ error (f_"-i vmx: %s: this may be a disk image. You must specify the .vmx file only on the command line.")
+ vmx_filename
+ | _ -> () in
+
(* Read the whole file as a list of lines. *)
let str = read_whole_file vmx_filename in
if verbose () then eprintf "VMX file:\n%s\n" str;
--
2.13.2
7 years, 1 month
[PATCH] common/mlutils: fix f_type comparisons
by Pino Toscano
statfs::f_type is usually a signed type, so cast it to unsigned to check
its value against magic values of filesystems.
---
common/mlutils/unix_utils-c.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/common/mlutils/unix_utils-c.c b/common/mlutils/unix_utils-c.c
index f8c4f8abe..2afdc9e5f 100644
--- a/common/mlutils/unix_utils-c.c
+++ b/common/mlutils/unix_utils-c.c
@@ -357,9 +357,9 @@ guestfs_int_mllib_statvfs_is_network_filesystem (value pathv)
#define SMB_SUPER_MAGIC 0x517b
#endif
- return Val_bool (buf.f_type == CIFS_MAGIC_NUMBER ||
- buf.f_type == NFS_SUPER_MAGIC ||
- buf.f_type == SMB_SUPER_MAGIC);
+ return Val_bool ((unsigned int) buf.f_type == CIFS_MAGIC_NUMBER ||
+ (unsigned int) buf.f_type == NFS_SUPER_MAGIC ||
+ (unsigned int) buf.f_type == SMB_SUPER_MAGIC);
#else
return Val_bool (0);
#endif
--
2.13.6
7 years, 1 month