add patch to force virtio_blk or virtio_scsi via environment variable

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=64
This commit is contained in:
Olaf Hering 2012-09-03 18:00:34 +00:00 committed by Git OBS Bridge
parent e7c418f9f1
commit edd8433ad0
3 changed files with 57 additions and 18 deletions

View File

@ -0,0 +1,55 @@
From e823035a30944ba71b9d8e60b30a650425dc9711 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 ++++++++++++++++++++++++
1 Datei geändert, 24 Zeilen hinzugefügt(+)
diff --git a/src/launch-appliance.c b/src/launch-appliance.c
index 328cd19..796c268 100644
--- a/src/launch-appliance.c
+++ b/src/launch-appliance.c
@@ -881,6 +881,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)
@@ -903,6 +925,8 @@ qemu_supports_virtio_scsi (guestfs_h *g)
g->app.virtio_scsi = 3;
}
+ qemu_force_virtio_blk(g);
+
return g->app.virtio_scsi == 1;
}
--
1.7.11.5

View File

@ -1,16 +0,0 @@
---
src/launch-appliance.c | 1 +
1 file changed, 1 insertion(+)
Index: libguestfs-1.19.37/src/launch-appliance.c
===================================================================
--- libguestfs-1.19.37.orig/src/launch-appliance.c
+++ libguestfs-1.19.37/src/launch-appliance.c
@@ -885,6 +885,7 @@ is_openable (guestfs_h *g, const char *p
static int
qemu_supports_virtio_scsi (guestfs_h *g)
{
+ return 0;
int r;
/* g->app.virtio_scsi has these values:

View File

@ -149,8 +149,8 @@ License: LGPL-2.1
Group: System/Filesystems
Version: 1.19.37
Release: 0
Patch0: libguestfs-1.19.37.patch
Patch5: libguestfs-1.13.14-ruby.patch
Patch100: 0001-force-virtio_blk-in-old-guest-kernel.patch
Source0: %{name}-%{version}.tar.gz
Source10: libguestfs.mkinitrd.boot.sh
Source11: libguestfs.mkinitrd.setup.sh
@ -309,8 +309,8 @@ virtual machines.
%prep
%setup -q
%patch0 -p1
%patch5 -p1
%patch100 -p1
%build
# disable qemu test.