Richard W.M. Jones
2012-Nov-14 11:04 UTC
[Libguestfs] Notes on compiling libguestfs 1.19.59 on Debian 7 (Wheezy) beta
In no particular order. Some of these need further investigation. ---------------------------------------------------------------------- I had to patch libguestfs not to use febootstrap-supermin-helper --copy-kernel option. See attachment #1. This could be avoided by providing a newer febootstrap in Wheezy. I had to patch libguestfs to make it not use the (not working) virtio-scsi in old kvm. See attachment #2. mdadm is missing as a dependency from the Debian package. test_mke2fs_0 fails: this seems to be a bug in libguestfs block device renaming code: libguestfs: trace: mke2fs "/dev/sda2" "blocksize:4096" "journaldevice:/dev/sda1" "fstype:ext2" libguestfs: send_to_daemon: 276 bytes: 00 00 01 10 | 20 00 f5 f5 | 00 00 00 04 | 00 00 01 70 | 00 00 00 00 | ... guestfsd: main_loop: proc 368 (mke2fs) took 4.52 seconds guestfsd: main_loop: new request, len 0x110 /dev/sda2: No such file or directory mke2fs -b 4096 -J device=/dev/sda1 -t ext2 /dev/vda2 mke2fs 1.42.5 (29-Jul-2012) test_tune2fs* fail because the output (username) expected by the test script is different from what the test expects. This is not important and this test should just be skipped. For some reason, the behaviour of vfat with the utf8 option is different from the same driver in the Fedora kernel. The Debian kernel prints this warning: [ 65.576097] FAT-fs (vda1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive! and indeed the resulting filesystem is case sensitive, which is definitely not expected or correct for vfat. It's probably some kernel config option. The udev rule (appliance/99-guestfs-serial.rules) either isn't being installed or doesn't work for some reason. I didn't look into it, but this breaks /dev/disk/guestfs/<label> disk names (see 7786d56db8c2241). tests/regressions/rhbz690819.sh fails, because either the kernel or qemu doesn't support the IDE interface. This will break virt-v2v. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora -------------- next part -------------->From 5a2a450b0b54e3d004f558c353594a3452cf0403 Mon Sep 17 00:00:00 2001From: "Richard W.M. Jones" <rjones at redhat.com> Date: Tue, 13 Nov 2012 18:33:33 +0000 Subject: [PATCH 1/2] DEBIAN 7: REVERT 3ed3e23ed (NO FEBOOTSTRAP COPY-KERNEL OPTION). --- src/appliance.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/appliance.c b/src/appliance.c index 8a22064..aa2a5b5 100644 --- a/src/appliance.c +++ b/src/appliance.c @@ -102,7 +102,7 @@ gl_lock_define_initialized (static, building_lock); * $TMPDIR/.guestfs-$UID/ and consists of four files: * * $TMPDIR/.guestfs-$UID/checksum - the checksum - * $TMPDIR/.guestfs-$UID/kernel - the kernel + * $TMPDIR/.guestfs-$UID/kernel - symlink to the kernel * $TMPDIR/.guestfs-$UID/initrd - the febootstrap initrd * $TMPDIR/.guestfs-$UID/root - the appliance * @@ -645,7 +645,7 @@ hard_link_to_cached_appliance (guestfs_h *g, perrorf (g, "link: %s %s", filename, *kernel); goto error; } - (void) utimes (filename, NULL); + (void) lutimes (filename, NULL); /* lutimes because it's a symlink */ snprintf (filename, len, "%s/initrd", cachedir); (void) unlink (*initrd); @@ -697,7 +697,6 @@ run_supermin_helper (guestfs_h *g, const char *supermin_path, guestfs___cmd_add_arg (cmd, "-g"); guestfs___cmd_add_arg_format (cmd, "%d", egid); } - guestfs___cmd_add_arg (cmd, "--copy-kernel"); guestfs___cmd_add_arg (cmd, "-f"); guestfs___cmd_add_arg (cmd, "ext2"); guestfs___cmd_add_arg_format (cmd, "%s/supermin.d", supermin_path); -- 1.7.10.4 -------------- next part -------------->From 1556cc9e8056a0e72c6ad945e45804c30e06da0b Mon Sep 17 00:00:00 2001From: "Richard W.M. Jones" <rjones at redhat.com> Date: Tue, 13 Nov 2012 18:45:59 +0000 Subject: [PATCH 2/2] DEBIAN 7: FORCE VIRTIO-BLK, DISABLE VIRTIO-SCSI. Ancient KVM on Debian 7 means virtio-scsi isn't working. --- src/launch-appliance.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/launch-appliance.c b/src/launch-appliance.c index 17e90d9..6cc9e97 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -39,7 +39,9 @@ static int is_openable (guestfs_h *g, const char *path, int flags); static void print_qemu_command_line (guestfs_h *g, char **argv); static int qemu_supports (guestfs_h *g, const char *option); +#if 0 static int qemu_supports_device (guestfs_h *g, const char *device_name); +#endif static int qemu_supports_virtio_scsi (guestfs_h *g); static char *qemu_drive_param (guestfs_h *g, const struct drive *drv, size_t index); @@ -826,6 +828,7 @@ qemu_supports (guestfs_h *g, const char *option) return strstr (g->app.qemu_help, option) != NULL; } +#if 0 /* Test if device is supported by qemu (currently just greps the -device ? * output). */ @@ -839,6 +842,7 @@ qemu_supports_device (guestfs_h *g, const char *device_name) return strstr (g->app.qemu_devices, device_name) != NULL; } +#endif /* Check if a file can be opened. */ static int @@ -857,6 +861,7 @@ is_openable (guestfs_h *g, const char *path, int flags) static int qemu_supports_virtio_scsi (guestfs_h *g) { +#if 0 int r; /* g->app.virtio_scsi has these values: @@ -876,6 +881,8 @@ qemu_supports_virtio_scsi (guestfs_h *g) } return g->app.virtio_scsi == 1; +#endif + return 0; } static char * -- 1.7.10.4
Olaf Hering
2012-Nov-14 13:59 UTC
[Libguestfs] Notes on compiling libguestfs 1.19.59 on Debian 7 (Wheezy) beta
On Wed, Nov 14, Richard W.M. Jones wrote:> In no particular order. Some of these need further investigation. > > ---------------------------------------------------------------------- > > I had to patch libguestfs not to use febootstrap-supermin-helper > --copy-kernel option. See attachment #1. This could be avoided by > providing a newer febootstrap in Wheezy. > > I had to patch libguestfs to make it not use the (not working) > virtio-scsi in old kvm. See attachment #2.This is the patch I use to force virtio-blk for sles11sp2, opensuse12.1 and older: # From 61db8e97180efa70243d8b7b116f11ca1f36b375 Mon Sep 17 00:00:00 2001 # From: Olaf Hering <olaf at 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 at aepfle.de> --- df/output.c | 13 +++++++++---- fish/options.c | 8 +++++++- src/guestfs-internal.h | 2 ++ src/handle.c | 16 ++++++++++++++++ src/inspect-fs-unix.c | 4 ++-- src/launch-appliance.c | 3 +++ src/launch-libvirt.c | 7 +++++++ test-tool/test-tool.c | 16 +++++++++++++--- 8 files changed, 59 insertions(+), 10 deletions(-) diff --git a/df/output.c b/df/output.c index 5729dd4..fb33ca1 100644 --- a/df/output.c +++ b/df/output.c @@ -42,6 +42,7 @@ #include "virt-df.h" static void write_csv_field (const char *field); +static int use_virtio_blk; void print_title (void) @@ -82,7 +83,7 @@ print_title (void) } } -static char *adjust_device_offset (const char *device, int offset); +static char *adjust_device_offset (guestfs_h *g, const char *device, int offset); void print_stat (const char *name, const char *uuid_param, @@ -110,7 +111,7 @@ print_stat (const char *name, const char *uuid_param, exit (EXIT_FAILURE); if (offset >= 0) { char *p = dev; - dev = adjust_device_offset (p, offset); + dev = adjust_device_offset (g, p, offset); free (p); } @@ -237,8 +238,9 @@ write_csv_field (const char *field) static char *drive_name (int index, char *ret); static char * -adjust_device_offset (const char *device, int offset) +adjust_device_offset (guestfs_h *g, const char *device, int offset) { + ; int index; int part_num; char *whole_device; @@ -282,7 +284,10 @@ adjust_device_offset (const char *device, int offset) exit (EXIT_FAILURE); } - strcpy (ret, "/dev/sd"); +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + use_virtio_blk = 1; +#endif + strcpy (ret, use_virtio_blk ? "/dev/vd" : "/dev/sd"); drive_name (index, &ret[7]); len = strlen (ret); if (part_num > 0) diff --git a/fish/options.c b/fish/options.c index 0db790e..54190bc 100644 --- a/fish/options.c +++ b/fish/options.c @@ -27,6 +27,8 @@ #include "options.h" +static int use_virtio_blk; + char add_drives (struct drv *drv, char next_drive) { @@ -40,13 +42,17 @@ add_drives (struct drv *drv, char next_drive) exit (EXIT_FAILURE); } +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + use_virtio_blk = 1; +#endif + if (drv) { next_drive = add_drives (drv->next, next_drive); 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); } diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 6e0b368..fe7b7dd 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -350,6 +350,8 @@ struct guestfs_h virDomainPtr dom; /* libvirt domain */ } virt; #endif + + int use_virtio_blk; }; /* Per-filesystem data stored for inspect_os. */ diff --git a/src/handle.c b/src/handle.c index fd7db69..d9ecc5d 100644 --- a/src/handle.c +++ b/src/handle.c @@ -210,6 +210,22 @@ parse_environment (guestfs_h *g, 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. + */ +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + 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); +#endif + return 0; } diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index a48d176..b2d6766 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -1411,7 +1411,7 @@ resolve_fstab_device_diskbyid (guestfs_h *g, const char *part, 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; @@ -1488,7 +1488,7 @@ resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table *md_map) 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) { diff --git a/src/launch-appliance.c b/src/launch-appliance.c index 17e90d9..902cf9a 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -875,6 +875,9 @@ qemu_supports_virtio_scsi (guestfs_h *g) g->app.virtio_scsi = 3; } + if (g->use_virtio_blk) + g->app.virtio_scsi = 2; + return g->app.virtio_scsi == 1; } diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index e4df2a6..dbeb97a 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -150,6 +150,13 @@ launch_libvirt (guestfs_h *g, const char *libvirt_uri) return -1; } +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + if (g->use_virtio_blk) { + error (g, "Using libvirt is not possible with this binary package due to forced virtio-blk usage."); + return -1; + } +#endif + guestfs___launch_send_progress (g, 0); TRACE0 (launch_libvirt_start); diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index 67e778b..74ea6d6 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -35,6 +35,7 @@ #include <guestfs.h> +static int use_virtio_blk; #define _(str) dgettext(PACKAGE, (str)) //#define N_(str) dgettext(PACKAGE, (str)) @@ -103,7 +104,11 @@ main (int argc, char *argv[]) int i; struct guestfs_version *vers; char *p; + char *disk_name, *partition_name; +#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK + use_virtio_blk = 1; +#endif /* Everyone ignores the documentation, so ... */ printf (" ************************************************************\n" " * IMPORTANT NOTICE\n" @@ -129,6 +134,11 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } + if (asprintf(&disk_name, "/dev/%s", use_virtio_blk ? "vda" : "sda") < 0) + exit (EXIT_FAILURE); + if (asprintf(&partition_name, "%s1", disk_name) < 0) + exit (EXIT_FAILURE); + for (;;) { c = getopt_long (argc, argv, options, long_options, &option_index); if (c == -1) break; @@ -257,19 +267,19 @@ 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, disk_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", partition_name) == -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, partition_name, "/") == -1) { fprintf (stderr, _("libguestfs-test-tool: failed to mount /dev/sda1 on /\n")); exit (EXIT_FAILURE); -- 1.8.0
Maybe Matching Threads
- [PATCH stable-1.24] Fix fstab block device resolution for FreeBSD
- [PATCH] common/options: Change drv struct to store drive index instead of device name.
- [PATCH] : Adding dlabel option to chain.c32
- [PATCH v2] New tool: virt-format
- [PATCH v10 00/10] Reimplement inspection in the daemon.