virt-v2v: default graphics driver for SUSE guests
by Pino Toscano
Hi Mike,
in 2013 you added the support for SUSE guests in the old virt-v2v (the
one written in Perl); the commit doing it is attached, since the old
virt-v2v was hosted on fedorahosted.org, which is no more.
As part of that change, the default graphics driver was changed to be
cirrus for SUSE guests, and qxl (as before) for any other.
When Rich Jones rewrote virt-v2v in 2014 in OCaml, he kept the same
logic [1]; this is still there today [2], and none of the other
SUSE-related changes that were done (mostly by another SUSE guy,
Cédric Bosdonnat) changed that in any way.
My question is: is using cirrus still the best choice for SUSE guests?
If not, what about using qxl as well, as done for any non-SUSE guest?
(We can also do that depending on the version of the guest, in case
only newer SUSE versions work fine with qxl).
[1] https://github.com/libguestfs/libguestfs/commit/3d1cb74b3eee51c5d015032ad...
[2] https://github.com/libguestfs/libguestfs/blob/master/v2v/convert_linux.ml...
Thanks,
--
Pino Toscano
5 years, 9 months
[PATCH] inspect: return osinfo short IDs for recent Windows versions
by Pino Toscano
Return the right osinfo short IDs for the majority of Windows versions
since Windows XP.
---
lib/inspect-osinfo.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c
index 816d317f1..f93f7ac52 100644
--- a/lib/inspect-osinfo.c
+++ b/lib/inspect-osinfo.c
@@ -69,6 +69,66 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root)
if (STREQ (distro, "msdos"))
return safe_strdup (g, "msdos6.22");
}
+ else if (STREQ (type, "windows")) {
+ CLEANUP_FREE char *product_name = NULL;
+ CLEANUP_FREE char *product_variant = NULL;
+
+ product_name = guestfs_inspect_get_product_name (g, root);
+ if (!product_name)
+ return NULL;
+ product_variant = guestfs_inspect_get_product_variant (g, root);
+ if (!product_variant)
+ return NULL;
+
+ switch (major) {
+ case 5:
+ switch (minor) {
+ case 1:
+ return safe_strdup (g, "winxp");
+ case 2:
+ if (strstr (product_name, "XP"))
+ return safe_strdup (g, "winxp");
+ else if (strstr (product_name, "R2"))
+ return safe_strdup (g, "win2k3r2");
+ else
+ return safe_strdup (g, "win2k3");
+ }
+ break;
+ case 6:
+ switch (minor) {
+ case 0:
+ if (strstr (product_variant, "Server"))
+ return safe_strdup (g, "win2k8");
+ else
+ return safe_strdup (g, "winvista");
+ case 1:
+ if (strstr (product_variant, "Server"))
+ return safe_strdup (g, "win2k8r2");
+ else
+ return safe_strdup (g, "win7");
+ case 2:
+ if (strstr (product_variant, "Server"))
+ return safe_strdup (g, "win2k12");
+ else
+ return safe_strdup (g, "win8");
+ case 3:
+ if (strstr (product_variant, "Server"))
+ return safe_strdup (g, "win2k12r2");
+ else
+ return safe_strdup (g, "win8.1");
+ }
+ break;
+ case 10:
+ switch (minor) {
+ case 0:
+ if (strstr (product_variant, "Server"))
+ return safe_strdup (g, "win2k16");
+ else
+ return safe_strdup (g, "win10");
+ }
+ break;
+ }
+ }
/* No ID could be guessed, return "unknown". */
return safe_strdup (g, "unknown");
--
2.20.1
5 years, 9 months
New extents structure proposal
by Richard W.M. Jones
I think the extents map is just too complicated and is unnecessarily
so. How about instead we define the plugin interface to be:
int can_extents (void *handle); // as before
int extents (void *handle, uint32_t count, uint64_t offset, uint32_t flags,
struct nbdkit_extents_list *list);
and have the extents_list be a simple list. The first extent you add
must start at offset. And you're only allowed to append monotonically
increasing adjacent extents to it. Plugins must return at least one
extent, but are not required to return more than one extent
(regardless of flags).
This would be simple enough to implement for both VDDK and file. (For
VDDK the plugin needs to synthesize the holes but that's only a slight
complication).
NBDKIT_FLAG_REQ_ONE is now simple to implement (if generating the
extents, stop after generating the first one; if it's the server
processing the extents, take the first extent in the list).
The ‘end’ that we discussed before is now implicit (it's the byte of
the last extent in the list).
Also an observation: qemu's nbd client only ever issues block status
requests with the req-one flag set, so perhaps we should optimize for
that case.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
5 years, 9 months
[PATCH] v2v: fix directory check for virtio-win as directory
by Pino Toscano
When trying to install files from virtio-win as directory, check for
directory existance using absolute paths. Otherwise, is_directory is
called on relative paths such as "linux/el7" which obviously do not
exist.
Fixes commit 1c85b64c1c3a4d5267b952102375cb78f18a85c4.
---
v2v/windows_virtio.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 92bf3ec60..3a3559cb2 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -311,7 +311,7 @@ and copy_from_virtio_win g inspect srcdir destdir filter missing =
let dir = virtio_win // srcdir in
debug "windows: copy_from_virtio_win: guest tools source directory %s" dir;
- if not (is_directory srcdir) then missing ()
+ if not (is_directory dir) then missing ()
else (
let cmd = sprintf "cd %s && find -L -type f" (quote dir) in
let paths = external_command cmd in
--
2.20.1
5 years, 9 months
[PATCH] v2v: linux: canonicalize module path for arch detection (RHBZ#1690574)
by Pino Toscano
Kernel modules can be also symlinks to files available outside the
"canonical" module directory; since `file` by default does not deference
symlinks, passing directly symlinks to the architecture detection
results in errors, as the "file" API does not recognize "symbolic link"
as architecture.
To prevent this situation, canonicalize the path of the module picked
for architecture detection: this way, "file-architecture" will run on a
real file.
---
v2v/linux_kernels.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
index 3313aabc7..889ec2f2a 100644
--- a/v2v/linux_kernels.ml
+++ b/v2v/linux_kernels.ml
@@ -189,7 +189,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
*)
let arch =
let any_module = modpath ^ List.hd modules in
- g#file_architecture any_module in
+ g#file_architecture (g#realpath any_module) in
(* Just return the module names, without path or extension. *)
let modules = List.filter_map (
--
2.20.1
5 years, 9 months
[PATCH] v2v: linux: improve archtecture detection from modules (RHBZ#1690574)
by Pino Toscano
Try to look for a well known kernel module (so far only virtio, or kvm)
to use for detecting the architecture of a kernel. This way, we can
avoid picking 3rd party modules that cause troubles.
---
v2v/linux_kernels.ml | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
index 3313aabc7..f1b9bdd97 100644
--- a/v2v/linux_kernels.ml
+++ b/v2v/linux_kernels.ml
@@ -185,11 +185,35 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
assert (List.length modules > 0);
(* Determine the kernel architecture by looking at the
- * architecture of an arbitrary kernel module.
+ * architecture of a kernel module.
+ *
+ * To avoid architecture detection issues with 3rd party
+ * modules (RHBZ#1690574), try to pick one of the well
+ * known modules, if available. Otherwise, an arbitrary
+ * module is used.
*)
let arch =
- let any_module = modpath ^ List.hd modules in
- g#file_architecture any_module in
+ (* Well known kernel modules. *)
+ let candidates = [ "virtio"; "kvm" ] in
+ let all_candidates = List.flatten (
+ List.map (
+ fun f ->
+ [ "/" ^ f ^ ".o"; "/" ^ f ^ ".ko"; "/" ^ f ^ ".ko.xz" ]
+ ) candidates
+ ) in
+ let candidate =
+ try
+ List.find (
+ fun m ->
+ List.exists (String.is_suffix m) all_candidates
+ ) modules
+ with Not_found ->
+ (* No known module found, pick an arbitrary one
+ * (the first).
+ *)
+ List.hd modules in
+ let candidate = modpath ^ candidate in
+ g#file_architecture candidate in
(* Just return the module names, without path or extension. *)
let modules = List.filter_map (
--
2.20.1
5 years, 9 months
[PATCH nbdkit] wrapper: Set MALLOC_CHECK=1 and MALLOC_PERTURB_ (randomly).
by Richard W.M. Jones
This is a cheap way to find some use-after-free and uninitialized read
problems when using glibc.
This in fact reveals a race during filter shutdown (which this
commit does not fix):
Thread 2 (Thread 0x7f1caaa5ffc0 (LWP 7223)):
#0 0x00007f1cab0a05f8 in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
#1 0x0000000000408842 in lock_unload () at locks.c:97
#2 0x00000000004066ff in filter_free (b=0x203c330) at filters.c:77
#3 0x000000000040a6f4 in main (argc=11, argv=0x7ffc1f4486e8) at main.c:649
Thread 1 (Thread 0x7f1caaa5e700 (LWP 7226)):
#0 0x000000000040732a in filter_finalize (b=0x203c330, conn=0x203d870)
at filters.c:421
#1 0x0000000000404d07 in _handle_single_connection (sockin=6, sockout=6)
at connections.c:239
#2 0x0000000000404d76 in handle_single_connection (sockin=6, sockout=6)
at connections.c:258
#3 0x00000000004119f6 in start_thread (datav=0x203b450) at sockets.c:263
#4 0x00007f1cab09b5a2 in start_thread () from /lib64/libpthread.so.0
#5 0x00007f1caafc85c3 in clone () from /lib64/libc.so.6
What's happening here is that the filter / plugin chain is freed by
Thread 2, while Thread 1 is calling filter->finalize. At this point
filter->finalize points to freed memory, but "normally" this would
still contain the correct function pointer. However when
MALLOC_PERTURB_ is set the function pointer is overwritten with the
non-zero dead memory pattern which we then attempt to call, causing a
segfault (in Thread 1).
---
wrapper.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/wrapper.c b/wrapper.c
index ffb058b..6b5118c 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -70,6 +70,7 @@
#include <unistd.h>
#include <getopt.h>
#include <limits.h>
+#include <time.h>
#include "options.h"
@@ -133,6 +134,9 @@ main (int argc, char *argv[])
{
bool verbose = false;
char *s;
+ time_t t;
+ unsigned tu;
+ char ts[32];
/* If NBDKIT_VALGRIND=1 is set in the environment, then we run the
* program under valgrind. This is used by the tests. Similarly if
@@ -250,6 +254,19 @@ main (int argc, char *argv[])
if (verbose)
print_command ();
+ /* This is a cheap way to find some use-after-free and uninitialized
+ * read problems when using glibc, and doesn't affect normal
+ * operation or other libc. We don't overwrite existing values so
+ * this can be disabled or overridden at runtime.
+ */
+ setenv ("MALLOC_CHECK_", "1", 0);
+ time (&t);
+ tu = t;
+ tu %= 255;
+ tu++;
+ snprintf (ts, sizeof ts, "%u", tu);
+ setenv ("MALLOC_PERTURB_", ts, 0);
+
/* Run the final command. */
execvp (cmd[0], (char **) cmd);
perror (cmd[0]);
--
2.20.1
5 years, 9 months