2013-02-25 21:54:52 +01:00
|
|
|
From f010abe024b47057f814e369b7b647e52d001019 Mon Sep 17 00:00:00 2001
|
2012-09-03 20:00:34 +02:00
|
|
|
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>
|
|
|
|
---
|
2013-08-20 20:43:14 +02:00
|
|
|
fish/options.c | 7 +++++--
|
|
|
|
src/guestfs-internal.h | 1 +
|
|
|
|
src/handle.c | 16 ++++++++++++++++
|
|
|
|
src/inspect-fs-unix.c | 4 ++--
|
|
|
|
src/launch-direct.c | 2 ++
|
|
|
|
5 files changed, 26 insertions(+), 4 deletions(-)
|
2012-09-03 20:00:34 +02:00
|
|
|
|
2013-08-20 20:43:14 +02:00
|
|
|
Index: libguestfs-1.22.5/fish/options.c
|
|
|
|
===================================================================
|
|
|
|
--- libguestfs-1.22.5.orig/fish/options.c
|
|
|
|
+++ libguestfs-1.22.5/fish/options.c
|
|
|
|
@@ -286,7 +286,10 @@ add_drives (struct drv *drv, char next_d
|
|
|
|
int r;
|
|
|
|
struct guestfs_add_drive_opts_argv ad_optargs;
|
|
|
|
char **server;
|
|
|
|
-
|
|
|
|
+ int use_virtio_blk = 0;
|
2012-10-10 17:23:26 +02:00
|
|
|
+#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK
|
2012-10-10 16:55:01 +02:00
|
|
|
+ use_virtio_blk = 1;
|
|
|
|
+#endif
|
2013-08-20 20:43:14 +02:00
|
|
|
if (next_drive > 'z') {
|
|
|
|
fprintf (stderr,
|
|
|
|
_("%s: too many drives added on the command line\n"),
|
|
|
|
@@ -300,7 +303,7 @@ add_drives (struct drv *drv, char next_d
|
2012-10-10 16:55:01 +02:00
|
|
|
free (drv->device);
|
|
|
|
drv->device = NULL;
|
|
|
|
|
|
|
|
- if (asprintf (&drv->device, "/dev/sd%c", next_drive) == -1) {
|
|
|
|
+ if (asprintf (&drv->device, "/dev/%s%c", use_virtio_blk ? "vd" : "sd", next_drive) == -1) {
|
|
|
|
perror ("asprintf");
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
2013-08-20 20:43:14 +02:00
|
|
|
Index: libguestfs-1.22.5/src/guestfs-internal.h
|
|
|
|
===================================================================
|
|
|
|
--- libguestfs-1.22.5.orig/src/guestfs-internal.h
|
|
|
|
+++ libguestfs-1.22.5/src/guestfs-internal.h
|
|
|
|
@@ -432,6 +432,7 @@ struct guestfs_h
|
|
|
|
char *virt_selinux_label;
|
|
|
|
char *virt_selinux_imagelabel;
|
|
|
|
bool virt_selinux_norelabel_disks;
|
2012-10-10 16:55:01 +02:00
|
|
|
+ int use_virtio_blk;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Per-filesystem data stored for inspect_os. */
|
2013-08-20 20:43:14 +02:00
|
|
|
Index: libguestfs-1.22.5/src/handle.c
|
|
|
|
===================================================================
|
|
|
|
--- libguestfs-1.22.5.orig/src/handle.c
|
|
|
|
+++ libguestfs-1.22.5/src/handle.c
|
|
|
|
@@ -230,6 +230,22 @@ parse_environment (guestfs_h *g,
|
|
|
|
}
|
2012-10-19 14:33:23 +02:00
|
|
|
}
|
2012-10-10 16:55:01 +02:00
|
|
|
|
2012-09-03 20:00:34 +02:00
|
|
|
+/*
|
|
|
|
+ * 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.
|
|
|
|
+ */
|
|
|
|
+#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK
|
2012-10-10 16:55:01 +02:00
|
|
|
+ static const char env_string[] = "GUESTFS_QEMU_NO_VIRTIO_BLK";
|
|
|
|
+ str = getenv(env_string);
|
|
|
|
+ g->use_virtio_blk = str == NULL;
|
|
|
|
+ if (str)
|
|
|
|
+ debug (g, "SuSE: %s in environment, preserving virtio-scsi setting.", env_string);
|
|
|
|
+ else
|
|
|
|
+ debug (g, "SuSE: %s not in environment, preventing virtio-scsi usage in old guest kernel.", env_string);
|
2012-09-03 20:00:34 +02:00
|
|
|
+#endif
|
|
|
|
+
|
2012-10-19 14:33:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-20 20:43:14 +02:00
|
|
|
Index: libguestfs-1.22.5/src/inspect-fs-unix.c
|
|
|
|
===================================================================
|
|
|
|
--- libguestfs-1.22.5.orig/src/inspect-fs-unix.c
|
|
|
|
+++ libguestfs-1.22.5/src/inspect-fs-unix.c
|
|
|
|
@@ -1404,7 +1404,7 @@ resolve_fstab_device_diskbyid (guestfs_h
|
2012-10-10 16:55:01 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Make the partition name and check it exists. */
|
|
|
|
- device = safe_asprintf (g, "/dev/sda%s", part);
|
|
|
|
+ device = safe_asprintf (g, "/dev/%sa%s", g->use_virtio_blk ? "vd" : "sd", part);
|
|
|
|
if (!is_partition (g, device)) {
|
|
|
|
free (device);
|
|
|
|
return 0;
|
2013-08-20 20:43:14 +02:00
|
|
|
@@ -1481,7 +1481,7 @@ resolve_fstab_device (guestfs_h *g, cons
|
2012-10-10 16:55:01 +02:00
|
|
|
if (disk_i != -1 && disk_i <= 26 &&
|
|
|
|
slice_i > 0 && slice_i <= 1 /* > 4 .. see comment above */ &&
|
|
|
|
part_i >= 0 && part_i < 26) {
|
|
|
|
- device = safe_asprintf (g, "/dev/sd%c%d", disk_i + 'a', part_i + 5);
|
|
|
|
+ device = safe_asprintf (g, "/dev/%s%c%d", g->use_virtio_blk ? "vd" : "sd", disk_i + 'a', part_i + 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((part = match1 (g, spec, re_diskbyid)) != NULL) {
|
2013-08-20 20:43:14 +02:00
|
|
|
Index: libguestfs-1.22.5/src/launch-direct.c
|
|
|
|
===================================================================
|
|
|
|
--- libguestfs-1.22.5.orig/src/launch-direct.c
|
|
|
|
+++ libguestfs-1.22.5/src/launch-direct.c
|
|
|
|
@@ -961,6 +961,8 @@ qemu_supports_virtio_scsi (guestfs_h *g)
|
|
|
|
g->direct.virtio_scsi = 3;
|
2012-12-13 17:10:28 +01:00
|
|
|
}
|
2012-09-03 20:00:34 +02:00
|
|
|
}
|
2013-08-20 20:43:14 +02:00
|
|
|
+ if (g->use_virtio_blk)
|
|
|
|
+ g->direct.virtio_scsi = 2;
|
2012-09-03 20:00:34 +02:00
|
|
|
|
2013-08-20 20:43:14 +02:00
|
|
|
return g->direct.virtio_scsi == 1;
|
2012-09-03 20:00:34 +02:00
|
|
|
}
|