From 7fb13a547c2db45400bdb444202c82b72b29040d13a9550c8752bf72132cee1d Mon Sep 17 00:00:00 2001
From: Olaf Hering <ohering@suse.com>
Date: Mon, 19 Aug 2013 21:24:42 +0000
Subject: [PATCH 1/6] - Update to version 1.22.5   * full support for btrfs
 guests   * large performance improvements in virt-df and virt-alignment-scan
 tools   * many bug fixes   * full release notes:
 http://libguestfs.org/guestfs-release-notes.1.html

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=221
---
 libguestfs-1.20.10.tar.xz | 3 ---
 libguestfs-1.22.5.tar.xz  | 3 +++
 libguestfs.changes        | 9 +++++++++
 libguestfs.spec           | 8 ++++----
 4 files changed, 16 insertions(+), 7 deletions(-)
 delete mode 100644 libguestfs-1.20.10.tar.xz
 create mode 100644 libguestfs-1.22.5.tar.xz

diff --git a/libguestfs-1.20.10.tar.xz b/libguestfs-1.20.10.tar.xz
deleted file mode 100644
index fb145f7..0000000
--- a/libguestfs-1.20.10.tar.xz
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:25065a6fc1e4bcccda25368b1327d1cc779608b5afb10a0a8de47a8126fbfb54
-size 3997156
diff --git a/libguestfs-1.22.5.tar.xz b/libguestfs-1.22.5.tar.xz
new file mode 100644
index 0000000..8671aca
--- /dev/null
+++ b/libguestfs-1.22.5.tar.xz
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:25d693128110a8936d7686d5f36308dc229ed1f7db6448f143497104cc895e9c
+size 4148564
diff --git a/libguestfs.changes b/libguestfs.changes
index fdba879..9dd0f99 100644
--- a/libguestfs.changes
+++ b/libguestfs.changes
@@ -1,3 +1,12 @@
+-------------------------------------------------------------------
+Mon Aug 19 23:23:31 CEST 2013 - ohering@suse.de
+
+- Update to version 1.22.5
+  * full support for btrfs guests
+  * large performance improvements in virt-df and virt-alignment-scan tools
+  * many bug fixes
+  * full release notes: http://libguestfs.org/guestfs-release-notes.1.html
+
 -------------------------------------------------------------------
 Mon Aug  5 17:48:01 CEST 2013 - ohering@suse.de
 
diff --git a/libguestfs.spec b/libguestfs.spec
index f8436b1..e13be80 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -16,7 +16,9 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
-Version:        1.20.10
+
+Version:        1.22.5
+Release:        0
 
 %define opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
 %if !%opt
@@ -136,7 +138,6 @@ BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Summary:        Compatibility package for guestfs-tools
 License:        GPL-2.0
 Group:          System/Filesystems
-Release:        0
 Patch1000:      1000-force-virtio_blk-in-old-guest-kernel.patch
 Source0:        %{name}-%{version}.tar.xz
 Source789653:   Pod-Simple-3.23.tar.xz
@@ -421,7 +422,7 @@ virtual machines.
 %prep
 : _ignore_exclusive_arch '%{?_ignore_exclusive_arch}'
 %setup -q -a 789653
-%patch1000 -p1
+#patch1000 -p1
 
 %build
 # [Bug 789653] sles11 perl obsoletes perl-Pod-Simple unconditionally
@@ -747,7 +748,6 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/libguestfs-make-fixed-appliance
 %{_bindir}/*
 %config(noreplace) /etc/libguestfs-tools.conf
-%config(noreplace) /etc/bash_completion.d/guestfish-bash-completion.sh
 %{_mandir}/man1/*
 
 %changelog

From a01dec8f28c791972dcaf79ca3b71167973b7d0343b12236ec46c0d8a02a8045 Mon Sep 17 00:00:00 2001
From: Olaf Hering <ohering@suse.com>
Date: Mon, 19 Aug 2013 21:51:11 +0000
Subject: [PATCH 2/6] add libxml2-devel to fix build in <= 11.4

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=222
---
 libguestfs.spec | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libguestfs.spec b/libguestfs.spec
index e13be80..9320bbe 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -108,6 +108,7 @@ BuildRequires:  libconfig-devel
 %endif
 BuildRequires:  libtool
 BuildRequires:  libvirt-devel >= 0.10.2
+BuildRequires:  libxml2-devel
 BuildRequires:  ncurses-devel
 %if %{with perl_bindings}
 %if %suse_version < 1140

From 5fe86c0867331d3a263b0c088eeced869ce1df910af4da35636cad1999800cf3 Mon Sep 17 00:00:00 2001
From: Olaf Hering <ohering@suse.com>
Date: Tue, 20 Aug 2013 11:45:23 +0000
Subject: [PATCH 3/6] -Requires:       perl(Sys::Guestfs::Lib)

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=223
---
 libguestfs.spec | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libguestfs.spec b/libguestfs.spec
index 9320bbe..68b6765 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -181,7 +181,6 @@ Requires:       perl(Locale::TextDomain)
 Requires:       perl(Pod::Usage)
 Requires:       perl(String::ShellQuote)
 Requires:       perl(Sys::Guestfs)
-Requires:       perl(Sys::Guestfs::Lib)
 %{perl_requires}
 %if %{with hivex}
 Requires:       perl(Win::Hivex)

From 032859e39a9d61dbd8a8eb364e7a822bf73d9fabdf918b85b8162f77faf88654 Mon Sep 17 00:00:00 2001
From: Olaf Hering <ohering@suse.com>
Date: Tue, 20 Aug 2013 12:43:18 +0000
Subject: [PATCH 4/6] Add bash-completion

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=224
---
 libguestfs.spec | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libguestfs.spec b/libguestfs.spec
index 68b6765..ea36c7c 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -56,6 +56,11 @@ Release:        0
 %bcond_with ruby_bindings
 %endif
 
+%if %suse_version >= 1230
+%bcond_without bash_completion
+%else
+%bcond_with bash_completion
+%endif
 # The following defines are overridden in the individual subpackages
 %define _configure_fuse --disable-fuse
 %define _configure_lua --disable-lua
@@ -97,6 +102,9 @@ BuildRequires:  attr-devel
 BuildRequires:  augeas-devel
 BuildRequires:  autoconf
 BuildRequires:  automake
+%if %{with bash_completion}
+BuildRequires:  bash-completion >= 2.0
+%endif
 BuildRequires:  file-devel
 BuildRequires:  gcc
 BuildRequires:  gcc-c++
@@ -739,6 +747,9 @@ rm -rf $RPM_BUILD_ROOT
 %files -n guestfsd
 %defattr(-,root,root)
 %{udevrulesdir}
+%if %{with bash_completion}
+%{_datadir}/bash-completion
+%endif
 %{_sbindir}/guestfsd
 %{_mandir}/man8/*
 

From 2302978e867361cfbf7c91e34845bb792bba033eca8cdc9aebfe87aeabcd3fa6 Mon Sep 17 00:00:00 2001
From: Olaf Hering <ohering@suse.com>
Date: Tue, 20 Aug 2013 14:50:12 +0000
Subject: [PATCH 5/6] bash-completion goes into guestfs-tools, not guestfsd

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=225
---
 libguestfs.spec | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libguestfs.spec b/libguestfs.spec
index ea36c7c..e386d82 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -747,9 +747,6 @@ rm -rf $RPM_BUILD_ROOT
 %files -n guestfsd
 %defattr(-,root,root)
 %{udevrulesdir}
-%if %{with bash_completion}
-%{_datadir}/bash-completion
-%endif
 %{_sbindir}/guestfsd
 %{_mandir}/man8/*
 
@@ -759,6 +756,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/libguestfs-make-fixed-appliance
 %{_bindir}/*
 %config(noreplace) /etc/libguestfs-tools.conf
+%if %{with bash_completion}
+%{_datadir}/bash-completion
+%endif
 %{_mandir}/man1/*
 
 %changelog

From 43663c54801bd92e1d173d245bb803c392a2bc44c98d082fd10902391c77b9bf Mon Sep 17 00:00:00 2001
From: Olaf Hering <ohering@suse.com>
Date: Tue, 20 Aug 2013 18:43:14 +0000
Subject: [PATCH 6/6] Enable 1000-force-virtio_blk-in-old-guest-kernel.patch
 again

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=226
---
 ...force-virtio_blk-in-old-guest-kernel.patch | 225 ++++--------------
 libguestfs.spec                               |   2 +-
 2 files changed, 50 insertions(+), 177 deletions(-)

diff --git a/1000-force-virtio_blk-in-old-guest-kernel.patch b/1000-force-virtio_blk-in-old-guest-kernel.patch
index 2659501..3d2fcf9 100644
--- a/1000-force-virtio_blk-in-old-guest-kernel.patch
+++ b/1000-force-virtio_blk-in-old-guest-kernel.patch
@@ -5,93 +5,30 @@ Subject: [PATCH] force virtio_blk in old guest kernel
 
 Signed-off-by: Olaf Hering <olaf@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(-)
+ 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(-)
 
-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");
+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;
 +#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 384ef43..74703ca 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);
- 
+   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
      free (drv->device);
      drv->device = NULL;
  
@@ -100,25 +37,24 @@ index 384ef43..74703ca 100644
        perror ("asprintf");
        exit (EXIT_FAILURE);
      }
-diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
-index 49341e2..1303a7e 100644
---- a/src/guestfs-internal.h
-+++ b/src/guestfs-internal.h
-@@ -318,6 +318,8 @@ struct guestfs_h
-     virDomainPtr dom;           /* libvirt domain */
-   } virt;
- #endif
-+
+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;
 +  int use_virtio_blk;
  };
  
  /* Per-filesystem data stored for inspect_os. */
-diff --git a/src/handle.c b/src/handle.c
-index cb00a2e..b0d75c1 100644
---- a/src/handle.c
-+++ b/src/handle.c
-@@ -215,6 +215,22 @@ parse_environment (guestfs_h *g,
-       return -1;
+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,
+     }
    }
  
 +/*
@@ -140,11 +76,11 @@ index cb00a2e..b0d75c1 100644
    return 0;
  }
  
-diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
-index 40f797d..45d50ee 100644
---- a/src/inspect-fs-unix.c
-+++ b/src/inspect-fs-unix.c
-@@ -1370,7 +1370,7 @@ resolve_fstab_device_diskbyid (guestfs_h *g, const char *part,
+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
      return 0;
  
    /* Make the partition name and check it exists. */
@@ -153,7 +89,7 @@ index 40f797d..45d50ee 100644
    if (!is_partition (g, device)) {
      free (device);
      return 0;
-@@ -1447,7 +1447,7 @@ resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table *md_map)
+@@ -1481,7 +1481,7 @@ resolve_fstab_device (guestfs_h *g, cons
      if (disk_i != -1 && disk_i <= 26 &&
          slice_i > 0 && slice_i <= 1 /* > 4 .. see comment above */ &&
          part_i >= 0 && part_i < 26) {
@@ -162,79 +98,16 @@ index 40f797d..45d50ee 100644
      }
    }
    else if ((part = match1 (g, spec, re_diskbyid)) != NULL) {
-diff --git a/src/launch-appliance.c b/src/launch-appliance.c
-index a86a8cc..1067d17 100644
---- a/src/launch-appliance.c
-+++ b/src/launch-appliance.c
-@@ -935,6 +935,9 @@ qemu_supports_virtio_scsi (guestfs_h *g)
+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;
      }
    }
++ if (g->use_virtio_blk)
++     g->direct.virtio_scsi = 2;
  
-+  if (g->use_virtio_blk)
-+     g->app.virtio_scsi = 2;
-+
-   return g->app.virtio_scsi == 1;
+   return g->direct.virtio_scsi == 1;
  }
- 
-diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
-index 6ad19de..b8efc4f 100644
---- a/src/launch-libvirt.c
-+++ b/src/launch-libvirt.c
-@@ -177,6 +177,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 d71caed..58cc885 100644
---- a/test-tool/test-tool.c
-+++ b/test-tool/test-tool.c
-@@ -95,6 +95,16 @@ main (int argc, char *argv[])
-   guestfs_h *g;
-   char *qemu = NULL;
-   int qemu_use_wrapper;
-+  char *disk_name, *partition_name;
-+  int use_virtio_blk = 0;
-+
-+#ifdef GUESTFS_QEMU_NO_VIRTIO_BLK
-+  use_virtio_blk = 1;
-+#endif
-+  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);
-@@ -281,19 +291,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);
diff --git a/libguestfs.spec b/libguestfs.spec
index e386d82..237187d 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -430,7 +430,7 @@ virtual machines.
 %prep
 : _ignore_exclusive_arch '%{?_ignore_exclusive_arch}'
 %setup -q -a 789653
-#patch1000 -p1
+%patch1000 -p1
 
 %build
 # [Bug 789653] sles11 perl obsoletes perl-Pod-Simple unconditionally