Olaf Hering
68246d27ec
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=107
108 lines
3.3 KiB
Diff
108 lines
3.3 KiB
Diff
From 04b36384e91cf0e6242be9daa1d06d269cb9cf3d Mon Sep 17 00:00:00 2001
|
|
From: Olaf Hering <olaf@aepfle.de>
|
|
Date: Mon, 3 Sep 2012 19:50:44 +0200
|
|
Subject: [PATCH] force virtio_blk in old guest kernel
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
---
|
|
src/launch-appliance.c | 24 ++++++++++++++++++++++++
|
|
test-tool/test-tool.c | 15 ++++++++++-----
|
|
2 files changed, 34 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/launch-appliance.c b/src/launch-appliance.c
|
|
index e353e05..f037d15 100644
|
|
--- a/src/launch-appliance.c
|
|
+++ b/src/launch-appliance.c
|
|
@@ -869,6 +869,28 @@ is_openable (guestfs_h *g, const char *path, int flags)
|
|
return 1;
|
|
}
|
|
|
|
+/*
|
|
+ * Currently virtio_scsi is forced if qemu in the host supports this
|
|
+ * feature. This test does however not take the capabilities of the started
|
|
+ * guest into account. As a result no disks will be found if the guest
|
|
+ * kernel is older than 3.4.
|
|
+ */
|
|
+static void qemu_force_virtio_blk(guestfs_h *g)
|
|
+{
|
|
+#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK
|
|
+ static const char env_string[] = "GUESTFS_QEMU_NO_VIRTIO_BLK";
|
|
+ char *p = getenv(env_string);
|
|
+ if (p) {
|
|
+ if (g->verbose)
|
|
+ guestfs___print_timestamped_message (g, "SuSE: %s in environment, preserving virtio-scsi setting.", env_string);
|
|
+ } else {
|
|
+ if (g->verbose)
|
|
+ guestfs___print_timestamped_message (g, "SuSE: %s not in environment, preventing virtio-scsi usage in old guest kernel.", env_string);
|
|
+ g->app.virtio_scsi = 2;
|
|
+ }
|
|
+#endif
|
|
+}
|
|
+
|
|
/* Returns 1 = use virtio-scsi, or 0 = use virtio-blk. */
|
|
static int
|
|
qemu_supports_virtio_scsi (guestfs_h *g)
|
|
@@ -891,6 +913,8 @@ qemu_supports_virtio_scsi (guestfs_h *g)
|
|
g->app.virtio_scsi = 3;
|
|
}
|
|
|
|
+ qemu_force_virtio_blk(g);
|
|
+
|
|
return g->app.virtio_scsi == 1;
|
|
}
|
|
|
|
diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c
|
|
index 4b764ee..2ba9977 100644
|
|
--- a/test-tool/test-tool.c
|
|
+++ b/test-tool/test-tool.c
|
|
@@ -35,6 +35,11 @@
|
|
|
|
#include <guestfs.h>
|
|
|
|
+#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK
|
|
+#define VDISK_KERNEL_NAME "vda"
|
|
+#else
|
|
+#define VDISK_KERNEL_NAME "sda"
|
|
+#endif
|
|
#define _(str) dgettext(PACKAGE, (str))
|
|
//#define N_(str) dgettext(PACKAGE, (str))
|
|
|
|
@@ -55,7 +60,7 @@
|
|
#define DEFAULT_TIMEOUT 600
|
|
|
|
static int timeout = DEFAULT_TIMEOUT;
|
|
-static char tmpf[] = P_tmpdir "/libguestfs-test-tool-sda-XXXXXX";
|
|
+static char tmpf[] = P_tmpdir "/libguestfs-test-tool-" VDISK_KERNEL_NAME "-XXXXXX";
|
|
static guestfs_h *g;
|
|
|
|
static void make_files (void);
|
|
@@ -240,21 +245,21 @@ main (int argc, char *argv[])
|
|
fflush (stdout);
|
|
|
|
/* Create the filesystem and mount everything. */
|
|
- if (guestfs_part_disk (g, "/dev/sda", "mbr") == -1) {
|
|
+ if (guestfs_part_disk (g, "/dev/" VDISK_KERNEL_NAME "", "mbr") == -1) {
|
|
fprintf (stderr,
|
|
_("libguestfs-test-tool: failed to run part-disk\n"));
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
- if (guestfs_mkfs (g, "ext2", "/dev/sda1") == -1) {
|
|
+ if (guestfs_mkfs (g, "ext2", "/dev/" VDISK_KERNEL_NAME "1") == -1) {
|
|
fprintf (stderr,
|
|
_("libguestfs-test-tool: failed to mkfs.ext2\n"));
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
- if (guestfs_mount (g, "/dev/sda1", "/") == -1) {
|
|
+ if (guestfs_mount (g, "/dev/" VDISK_KERNEL_NAME "1", "/") == -1) {
|
|
fprintf (stderr,
|
|
- _("libguestfs-test-tool: failed to mount /dev/sda1 on /\n"));
|
|
+ _("libguestfs-test-tool: failed to mount /dev/" VDISK_KERNEL_NAME "1 on /\n"));
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
--
|
|
1.7.12
|
|
|