Richard W.M. Jones | 18 Oct 23:05 2014
Picon

GIT: [PATCH 0/5] v2v: Multiple fixes for handling semi-standard OVA files (RHBZ#1152998).

OVA not a real standard.  Colour me surprised ...
Richard W.M. Jones | 17 Oct 19:42 2014
Picon

Re: Virt-v2v conversion issue

[Please keep replies on the list]

On Thu, Oct 16, 2014 at 04:23:52PM +0000, VONDRA Alain wrote:
> It would be great in my case to import the VM in ovirt without using
> a nfs connection because the share is on the same server...  But at
> my knowledge, when you put the option -o rhev, you have to link with
> a nfs server, am I right ?

It's simply not possible to make it work without the NFS server.
That's just how it works.  I suggest you need to ask whoever runs your
NFS server to fix it so it has more capacity.

BTW 1.27.64, uploading later today, will fix some Windows conversion bugs.

Rich.

--

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
Olaf Hering | 16 Oct 17:49 2014
Picon

[PATCH] btrfs: list only subvolumes below path

The current code does not cover all subvolume variants. If a subvolume
exists which covers the entire root filesystem the result is two
mountables that have is_root set. This leads to failures in virt-ls and
other tools because they work only with a single root.

Update the btrfs subvolume call to use the "-o" option. This fixes two
cases: first it skips the subvolume for the root filesystem, so the
virt-ls case is covered. Second case is failure of mount(1) in
guestfs___check_for_filesystem_on. Without this change the subvol would
be a relative path, which causes mount(1) to return with ENOENT.

The option "-o" changes the output to print <path> as absolute:

 ><rescue> btrfs subvolume list  /sysroot/
ID 257 gen 135 top level 5 path  <at> 
ID 258 gen 124 top level 257 path boot/grub2/i386-pc

vs.

 ><rescue> btrfs subvolume list -o /sysroot/
ID 258 gen 124 top level 257 path  <at> /boot/grub2/i386-pc

mount -osubvol=boot/grub2/i386-pc $dev /sysroot will fail, while
mount -osubvol= <at> /boot/grub2/i386-pc $dev /sysroot will succeed.

Signed-off-by: Olaf Hering <olaf <at> aepfle.de>
---
 daemon/btrfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(Continue reading)

Artur Krzywdzinski | 16 Oct 16:34 2014
Picon

[libguestfs] conversion issue on NFS shares

Hi

T'm trying to convert XEN virtual machine image into raw. Source file is on NFS export and destination is also on nfs export. (both exports are mounted on migration servers RW access). I'm getting permission denied.
I have RW access to both exports - I can create, delete objects on both exports from migration server. But when I copy img file onto migration server local filesystem, conversion works, from local fs to nfs export. However when I tried to run guestfish against file located on NFS - I'm getting the same erro - Permission denied .

[root <at> kvm01 export]# virt-v2v -i disk migr01.img -o local -os /tmp
[   0.0] Opening the source -i disk migr01.img
[   0.0] Creating an overlay to protect the source from being modified
[   0.0] Opening the overlay
virt-v2v: error: libguestfs error: could not create appliance through
libvirt.

Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct

Original error from libvirt: internal error: process exited while
connecting to monitor: 2014-10-16T14:25:13.729270Z qemu-kvm: -drive
file=/var/tmp/v2vovl60e1a0.qcow2,if=none,id=drive-scsi0-0-0-0,format=qcow2,cache=unsafe,discard=unmap:
could not open disk image /var/tmp/v2vovl60e1a0.qcow2: Could not open
backing file: Could not open '/mnt/xen01/export/migr01.img': Permission
denied
 [code=1 domain=10]

If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

  virt-v2v -v -x [...]
[root <at> kvm01 export]#


--

Artur Krzywdzinski

_______________________________________________
Libguestfs mailing list
Libguestfs <at> redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs
Olaf Hering | 16 Oct 11:09 2014
Picon

make install of ocaml libs fails


Today I did it, for the very first time:
Did not build a package. Just ran "make install". Twice!

...
ocamlfind install \
  -ldconf ignore -destdir /usr/lib64/ocaml \
  guestfs \
  META *.so *.a *.cma *.cmi ./*.mli *.cmx *.cmxa
ocamlfind: Package guestfs is already installed
 - (file /usr/lib64/ocaml/guestfs/META already exists)
Makefile:2053: recipe for target 'install-data-hook' failed
make[3]: *** [install-data-hook] Error 2

I wonder if that is failing just for my version of ocamlfind or if this
is a common failure. How do you guys handle that situation?

Olaf
Richard W.M. Jones | 15 Oct 11:11 2014
Picon

[PATCH nbdkit] streaming plugin: Add support for a sliding window


[Sorry, can't use git-send-email at the moment ...]

These patches implement a sliding window for the streaming plugin[1]
in nbdkit.

I would like to be able to stream a filesystem from tools such as
'virt-make-fs'[2].  This is a fairly frequently requested feature.

Unfortunately:

(a) The patches make the code significantly more complex and therefore
likely to have bugs.

(b) They are not practically useful.  'parted' likes to write to the
beginning and end of a disk, even when creating a simple MBR, and of
course 'mkfs' scribbles the group headers across the whole disk when
creating a filesystem.

A simple window approach is obviously not sufficient.  A better
approach might be something like a sparse, size-limited map recording
writes at any point in the disk.  But that has the problem that you
don't know when you can commit a write to the stream -- some heuristic
would have to be used.

I'm posting them to the mailing list for the record and in case anyone
has any better ideas.

Rich.

[1] http://rwmj.wordpress.com/2014/10/14/streaming-nbd-server/#content
[2] http://libguestfs.org/virt-make-fs.1.html

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
>From be039f70da0c3ece9075724bf5ff29a45038dce5 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones <at> redhat.com>
Date: Tue, 14 Oct 2014 16:38:50 +0200
Subject: [PATCH 1/2] streaming: Implement sliding window and add window=SIZE
 parameter.

---
 plugins/streaming/nbdkit-streaming-plugin.pod |  17 +-
 plugins/streaming/streaming.c                 | 290 +++++++++++++++++++++-----
 2 files changed, 256 insertions(+), 51 deletions(-)

diff --git a/plugins/streaming/nbdkit-streaming-plugin.pod b/plugins/streaming/nbdkit-streaming-plugin.pod
index a21ed4f..635af69 100644
--- a/plugins/streaming/nbdkit-streaming-plugin.pod
+++ b/plugins/streaming/nbdkit-streaming-plugin.pod
 <at>  <at>  -6,7 +6,7  <at>  <at>  nbdkit-streaming-plugin - nbdkit streaming plugin

 =head1 SYNOPSIS

- nbdkit streaming pipe=FILENAME [size=SIZE]
+ nbdkit streaming pipe=FILENAME [size=SIZE] [window=SIZE]

 =head1 DESCRIPTION

 <at>  <at>  -50,12 +50,23  <at>  <at>  Whether you need to specify this parameter depends on the client.
 Some clients don't check the size and just write/stream, others do
 checks or calculations based on the apparent size.

+=item B<window=SIZE>
+
+Specify a sliding window of data, allowing limited seeking backwards
+and reads.  You can use any size specifier permitted by
+C<nbdkit_parse_size>, eg. C<window=1M>.
+
+Note that this is disabled (set to 0) by default, since enabling it
+causes writes to be delayed until the client moves the window forward
+or until nbdkit exits.
+
 =back

 =head1 TO DO

-This plugin would be much nicer if it supported the concept of a
-"window" of data, allowing limited reverse seeks and reads.
+Separate read and write windows would make more sense, allowing a
+large read window and a small write window.  The smaller (or zero)
+write window would mean that writes are not delayed.

 =head1 SEE ALSO

diff --git a/plugins/streaming/streaming.c b/plugins/streaming/streaming.c
index f58fa46..2d08803 100644
--- a/plugins/streaming/streaming.c
+++ b/plugins/streaming/streaming.c
 <at>  <at>  -41,20 +41,28  <at>  <at> 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <assert.h>

 #include <nbdkit-plugin.h>

+#define min(a,b) ((a)<(b)?(a):(b))
+
 static char *filename = NULL;
 static int fd = -1;

 /* In theory INT64_MAX, but it breaks qemu's NBD driver. */
 static int64_t size = INT64_MAX/2;

-/* Flag if we have entered the unrecoverable error state because of
- * a seek backwards.
+/* Flag if we have entered the unrecoverable error state because of a
+ * seek backwards beyond the window.
  */
 static int errorstate = 0;

+/* Window. */
+static int64_t window_max_size = 0; /* window= parameter */
+static int64_t window_size = 0;     /* current size */
+static char *window = NULL;
+
 /* Highest byte (+1) that has been written in the data stream. */
 static uint64_t highestwrite = 0;

 <at>  <at>  -73,6 +81,11  <at>  <at>  streaming_config (const char *key, const char *value)
     if (size == -1)
       return -1;
   }
+  else if (strcmp (key, "window") == 0) {
+    window_max_size = nbdkit_parse_size (value);
+    if (window_max_size == -1)
+      return -1;
+  }
   else {
     nbdkit_error ("unknown parameter '%s'", key);
     return -1;
 <at>  <at>  -110,18 +123,10  <at>  <at>  streaming_config_complete (void)
   return 0;
 }

-/* nbdkit is shutting down. */
-static void
-streaming_unload (void)
-{
-  if (fd >= 0)
-    close (fd);
-  free (filename);
-}
-
 #define streaming_config_help \
   "pipe=<FILENAME>     (required) The filename to serve.\n" \
-  "size=<SIZE>         (optional) Stream size."
+  "size=<SIZE>         (optional) Stream size.\n" \
+  "window=<SIZE>       (optional) Window size."

 /* Create the per-connection handle. */
 static void *
 <at>  <at>  -160,13 +165,66  <at>  <at>  streaming_get_size (void *handle)
   return size;
 }

+static int
+xwrite (int fd, const char *buf, size_t n)
+{
+  ssize_t r;
+
+  while (n > 0) {
+    r = write (fd, buf, n);
+    if (r == -1) {
+      nbdkit_error ("write: %m");
+      return -1;
+    }
+    buf += r;
+    n -= r;
+  }
+  return 0;
+}
+
+static int
+xwrite_zeroes (int fd, size_t n)
+{
+  ssize_t r;
+  char buf[4096];
+
+  memset (buf, 0, sizeof buf);
+
+  while (n > 0) {
+    r = write (fd, buf, min (n, sizeof buf));
+    if (r == -1) {
+      nbdkit_error ("write: %m");
+      return -1;
+    }
+    n -= r;
+  }
+  return 0;
+}
+
+/*
+This diagram should help when trying to understand the pread and
+pwrite calls below.
+
+Note that we recursively split read and write calls to make the cases
+tractable.
+
+                           |<------- window_max_size ------->|
+                           |<---- window_size ----->|
+  +------------------------+------------------------+--------+----------
+  ^                        ^                        ^        ^
+  0                    windowstart         highestwrite   maxwindow
+
+ */
+
 /* Write data to the stream. */
 static int
 streaming_pwrite (void *handle, const void *buf,
                   uint32_t count, uint64_t offset)
 {
-  size_t n;
-  ssize_t r;
+  int r;
+  uint64_t windowstart;
+  uint64_t maxwindow;
+  int64_t delta;

   if (errorstate) {
     nbdkit_error ("unrecoverable error state");
 <at>  <at>  -174,63 +232,199  <at>  <at>  streaming_pwrite (void *handle, const void *buf,
     return -1;
   }

-  if (offset < highestwrite) {
-    nbdkit_error ("client tried to seek backwards and write: the streaming plugin does not currently
support this");
+  /* This just makes the recursive case easier to reason about. */
+  if (count == 0)
+    return 0;
+
+  windowstart = highestwrite - window_size;
+
+  if (offset < windowstart) {
+    nbdkit_error ("client seeked backwards > window size: you must increase the window size");
     errorstate = 1;
     errno = EIO;
     return -1;
   }

-  /* Need to write some zeroes. */
-  if (offset > highestwrite) {
-    int64_t size = offset - highestwrite;
-    char buf[4096];
-
-    memset (buf, 0, sizeof buf);
-
-    while (size > 0) {
-      n = size > sizeof buf ? sizeof buf : size;
-      r = write (fd, buf, n);
-      if (r == -1) {
-        nbdkit_error ("write: %m");
-        errorstate = 1;
-        return -1;
-      }
-      highestwrite += r;
-      size -= r;
-    }
+  /* Split writes across highestwrite and maxwindow boundaries.
+   * Splitting here means we do not have to deal with writes across
+   * the boundary in the code below.
+   */
+  if (offset < highestwrite && offset + count > highestwrite) {
+    uint64_t size = highestwrite - offset;
+
+    r = streaming_pwrite (handle, buf, size, offset);
+    if (r == -1)
+      return -1;
+    buf += size;
+    offset += size;
+    count -= size;
+    return streaming_pwrite (handle, buf, count, offset);
+  }
+
+  maxwindow = windowstart + window_max_size;
+
+  if (offset < maxwindow && offset + count > maxwindow) {
+    uint64_t size = maxwindow - offset;
+
+    r = streaming_pwrite (handle, buf, size, offset);
+    if (r == -1)
+      return -1;
+    buf += size;
+    offset += size;
+    count -= size;
+    return streaming_pwrite (handle, buf, count, offset);
+  }
+
+  /* Handle a write entirely within the current window. */
+  if (offset < highestwrite) {
+    uint64_t windowoffset = window_size - (highestwrite - offset);
+    memcpy (&window[windowoffset], buf, count);
+    return 0;
   }

-  /* Write the data. */
-  while (count > 0) {
-    r = write (fd, buf, count);
-    if (r == -1) {
-      nbdkit_error ("write: %m");
-      errorstate = 1;
+  /* A write after highestwrite but not larger than maxwindow causes
+   * the window to be extended but not moved.
+   */
+  if (offset < maxwindow) {
+    uint64_t new_highestwrite = offset + count;
+    uint64_t new_size = new_highestwrite - windowstart;
+    char *new_window;
+
+    new_window = realloc (window, new_size);
+    if (new_window == NULL) {
+      nbdkit_error ("realloc: %m");
       return -1;
     }
-    buf += r;
-    highestwrite += r;
-    count -= r;
+    window = new_window;
+    /* Make sure the extended window is zeroes to start with. */
+    memset (&window[window_size], 0, new_size - window_size);
+    highestwrite = new_highestwrite;
+    /* Copy the buffer to the new window. */
+    memcpy (&window[offset - windowstart], buf, count);
+    return 0;
+  }
+
+  /* Split writes after maxwindow at highestwrite + window_max_size. */
+  if (offset < highestwrite + window_max_size &&
+      offset + count > highestwrite + window_max_size) {
+    uint64_t size = highestwrite + window_max_size - offset;
+
+    r = streaming_pwrite (handle, buf, size, offset);
+    if (r == -1)
+      return -1;
+    buf += size;
+    offset += size;
+    count -= size;
+    return streaming_pwrite (handle, buf, count, offset);
+  }
+
+  /* Any write here is going to cause the window to move.  Delta is
+   * the amount by which the window will move (NB: might be greater
+   * than the window size).
+   */
+  delta = offset + count - highestwrite;
+
+  if (delta <= window_size) {
+    /* Write out the oldest part of the window. */
+    if (xwrite (fd, window, delta) == -1)
+      return -1;
+
+    /* Move the data in the window down. */
+    memmove (window, window + delta, window_size - delta);
+
+    /* Copy the buffer to the new window. */
+    memcpy (window + window_size - count, buf, count);
+    highestwrite += delta;
+    return 0;
   }

-  return 0;
+  /* The window will move by more than a single window size.  Write out
+   * the whole of the old window, then write zeroes, then continue the
+   * write.
+   */
+  if (xwrite (fd, window, window_size) == -1)
+    return -1;
+  memset (window, 0, window_size);
+
+  if (xwrite_zeroes (fd, delta - window_size) == -1)
+    return -1;
+
+  highestwrite += delta - window_size;
+
+  return streaming_pwrite (handle, buf, count, offset);
 }

 /* Read data back from the stream. */
 static int
 streaming_pread (void *handle, void *buf, uint32_t count, uint64_t offset)
 {
+  uint64_t windowstart;
+  int r;
+
   if (errorstate) {
     nbdkit_error ("unrecoverable error state");
     errno = EIO;
     return -1;
   }

-  nbdkit_error ("client tried to read: the streaming plugin does not currently support this");
-  errorstate = 1;
-  errno = EIO;
-  return -1;
+  /* This just makes the recursive case easier to reason about. */
+  if (count == 0)
+    return 0;
+
+  windowstart = highestwrite - window_size;
+
+  if (offset < windowstart) {
+    nbdkit_error ("client seeked backwards > window size: you must increase the window size");
+    errorstate = 1;
+    errno = EIO;
+    return -1;
+  }
+
+  /* Split reads across highestwrite boundary.  Splitting here means
+   * we do not have to deal with reads across the boundary in the code
+   * below.
+   */
+  if (offset < highestwrite && offset + count > highestwrite) {
+    uint64_t size = highestwrite - offset;
+
+    r = streaming_pread (handle, buf, size, offset);
+    if (r == -1)
+      return -1;
+    buf += size;
+    offset += size;
+    count -= size;
+    return streaming_pread (handle, buf, count, offset);
+  }
+
+  /* Handle a read entirely within the window by simply reading the
+   * window contents.
+   */
+  if (offset < highestwrite) {
+    uint64_t windowoffset = window_size - (highestwrite - offset);
+    memcpy (buf, &window[windowoffset], count);
+    return 0;
+  }
+
+  /* Else any read ahead of the current highest write is returned as
+   * all zeroes.
+   */
+  memset (buf, 0, count);
+  return 0;
+}
+
+/* nbdkit is shutting down - the rest of the window should be written out. */
+static void
+streaming_unload (void)
+{
+  if (fd >= 0) {
+    /* XXX impossible to report an error to the client here */
+    xwrite (fd, window, window_size);
+
+    close (fd);
+  }
+
+  free (window);
+  free (filename);
 }

 static struct nbdkit_plugin plugin = {
-- 
2.0.4

>From 0c4ffccc7258dcff94cc40abcf470a3c5ad788c3 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones <at> redhat.com>
Date: Tue, 14 Oct 2014 14:31:08 +0200
Subject: [PATCH 2/2] tests: Enable streaming test.

---
 plugins/streaming/streaming.c | 13 +++++++++++--
 tests/Makefile.am             | 17 +++++------------
 tests/test-streaming.c        | 16 +++++++---------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/plugins/streaming/streaming.c b/plugins/streaming/streaming.c
index 2d08803..da4de63 100644
--- a/plugins/streaming/streaming.c
+++ b/plugins/streaming/streaming.c
 <at>  <at>  -35,6 +35,8  <at>  <at> 

 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
 <at>  <at>  -232,6 +234,10  <at>  <at>  streaming_pwrite (void *handle, const void *buf,
     return -1;
   }

+  nbdkit_debug ("pwrite: offset=%" PRIi64 " count=%" PRIu32
+                " highestwrite=%" PRIu64,
+                offset, count, highestwrite);
+
   /* This just makes the recursive case easier to reason about. */
   if (count == 0)
     return 0;
 <at>  <at>  -239,7 +245,8  <at>  <at>  streaming_pwrite (void *handle, const void *buf,
   windowstart = highestwrite - window_size;

   if (offset < windowstart) {
-    nbdkit_error ("client seeked backwards > window size: you must increase the window size");
+    nbdkit_error ("pwrite: client backwards seek > window size: you must increase the window size
(highestwrite=%" PRIu64 ", window_size=%" PRIi64 ")",
+                  highestwrite, window_size);
     errorstate = 1;
     errno = EIO;
     return -1;
 <at>  <at>  -298,6 +305,7  <at>  <at>  streaming_pwrite (void *handle, const void *buf,
     window = new_window;
     /* Make sure the extended window is zeroes to start with. */
     memset (&window[window_size], 0, new_size - window_size);
+    window_size = new_size;
     highestwrite = new_highestwrite;
     /* Copy the buffer to the new window. */
     memcpy (&window[offset - windowstart], buf, count);
 <at>  <at>  -374,7 +382,8  <at>  <at>  streaming_pread (void *handle, void *buf, uint32_t count, uint64_t offset)
   windowstart = highestwrite - window_size;

   if (offset < windowstart) {
-    nbdkit_error ("client seeked backwards > window size: you must increase the window size");
+    nbdkit_error ("pread: client backwards seek > window size: you must increase the window size
(highestwrite=%" PRIu64 ", window_size=%" PRIi64 ")",
+                  highestwrite, window_size);
     errorstate = 1;
     errno = EIO;
     return -1;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a50e26b..cccd45b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
 <at>  <at>  -172,18 +172,11  <at>  <at>  test_python_LDADD = libtest.la $(LIBGUESTFS_LIBS)
 endif

 # streaming plugin test.
+check_PROGRAMS += test-streaming
+TESTS += test-streaming

-# This is disabled at the moment because the libguestfs appliance
-# kernel tries to read from the device (eg to read the partition
-# table) and the current streaming plugin cannot handle this.
-# Implementing a sliding window in the plugin would fix this. (XXX)
-EXTRA_DIST += test-streaming.c
-
-#check_PROGRAMS += test-streaming
-#TESTS += test-streaming
-#
-#test_streaming_SOURCES = test-streaming.c test.h
-#test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
-#test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
+test_streaming_SOURCES = test-streaming.c test.h
+test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
+test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)

 endif
diff --git a/tests/test-streaming.c b/tests/test-streaming.c
index 1631c19..4610fb9 100644
--- a/tests/test-streaming.c
+++ b/tests/test-streaming.c
 <at>  <at>  -48,7 +48,7  <at>  <at> 

 #include "test.h"

-static char data[4096];
+static char data[1024];

 int
 main (int argc, char *argv[])
 <at>  <at>  -69,6 +69,8  <at>  <at>  main (int argc, char *argv[])

   if (test_start_nbdkit (NBDKIT_PLUGIN ("streaming"),
                          "pipe=streaming.fifo",
+                         "size=128k",
+                         "window=128k",
                          NULL) == -1)
     exit (EXIT_FAILURE);

 <at>  <at>  -121,14 +123,10  <at>  <at>  main (int argc, char *argv[])
     exit (EXIT_FAILURE);

   /* Write linearly to the virtual disk. */
-  for (i = 0; i < 10; ++i) {
-    memset (data, i+1, sizeof data);
-
-    /* Note that we deliberately skip forwards, in order to
-     * exercise seeking code in the streaming plugin.
-     */
+  memset (data, 1, sizeof data);
+  for (i = 0; i < 32; ++i) {
     guestfs_pwrite_device (g, "/dev/sda", data, sizeof data,
-                           (2 * i) * sizeof data);
+                           i * sizeof data);
   }

   if (guestfs_shutdown (g) == -1)
 <at>  <at>  -148,7 +146,7  <at>  <at>  main (int argc, char *argv[])
   }
   md5[32] = '\0';

-  if (strcmp (md5, "0123456789abcdef0123456789abcdef") != 0) {
+  if (strcmp (md5, "51ae9fa5fb90e9d51c4f1b4260285c99") != 0) {
     fprintf (stderr, "unexpected hash: %s\n", md5);
     exit (EXIT_FAILURE);
   }
--

-- 
2.0.4

_______________________________________________
Libguestfs mailing list
Libguestfs <at> redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs
Pino Toscano | 14 Oct 11:10 2014
Picon

[PATCH] diff: do not pad uid/gid in CSV mode

---
 diff/diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/diff/diff.c b/diff/diff.c
index f4b25e9..ad371b0 100644
--- a/diff/diff.c
+++ b/diff/diff.c
 <at>  <at>  -1108,7 +1108,7  <at>  <at>  output_int64_uid (int64_t i)
 {
   next_field ();
   /* csv doesn't need escaping */
-  if (printf ("%4" PRIi64, i) < 0) {
+  if (printf (csv ? "%" PRIi64 : "%4" PRIi64, i) < 0) {
     perror ("printf");
     exit (EXIT_FAILURE);
   }
--

-- 
1.9.3
Pino Toscano | 13 Oct 16:49 2014
Picon

[PATCH] cat, diff: avoid double slashes in paths (RHBZ#1151910).

In full_path, skip the trailing slash in the base directory when
different than "/", as the slash will eventually be added when building
the resulting path.
---
 cat/visit.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cat/visit.c b/cat/visit.c
index 963beb8..49b779e 100644
--- a/cat/visit.c
+++ b/cat/visit.c
 <at>  <at>  -138,13 +138,18  <at>  <at>  full_path (const char *dir, const char *name)
 {
   int r;
   char *path;
+  int len;
+
+  len = strlen (dir);
+  if (len > 0 && dir[len - 1] == '/')
+    --len;

   if (STREQ (dir, "/"))
     r = asprintf (&path, "/%s", name ? name : "");
   else if (name)
-    r = asprintf (&path, "%s/%s", dir, name);
+    r = asprintf (&path, "%.*s/%s", len, dir, name);
   else
-    r = asprintf (&path, "%s", dir);
+    r = asprintf (&path, "%.*s", len, dir);

   if (r == -1) {
     perror ("asprintf");
--

-- 
1.9.3
Pino Toscano | 13 Oct 15:51 2014
Picon

[PATCH] ls: in CSV mode, always have a checksum field (RHBZ#1151900).

Make sure to output the field for checksum even for non-regular files,
as empty, in CSV output mode. This ensures each line has the same number
of fields, regardless of the file type.
---
 cat/ls.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/cat/ls.c b/cat/ls.c
index de8248e..2cb4e74 100644
--- a/cat/ls.c
+++ b/cat/ls.c
 <at>  <at>  -524,12 +524,15  <at>  <at>  show_file (const char *dir, const char *name,

   path = full_path (dir, name);

-  if (checksum && is_reg (stat->st_mode)) {
-    csum = guestfs_checksum (g, checksum, path);
-    if (!csum)
-      exit (EXIT_FAILURE);
+  if (checksum) {
+    if (is_reg (stat->st_mode)) {
+      csum = guestfs_checksum (g, checksum, path);
+      if (!csum)
+        exit (EXIT_FAILURE);

-    output_string (csum);
+      output_string (csum);
+    } else if (csv)
+      output_string ("");
   }

   output_string (path);
--

-- 
1.9.3
Richard W.M. Jones | 13 Oct 11:06 2014
Picon

Re: Virt-v2v conversion issue

[Please keep replies on the list]
On Mon, Oct 13, 2014 at 07:47:34AM +0000, VONDRA Alain wrote:
> I give you some news about the conversion issue, I don't have the
> same problem, but I can't finalize the conversion, the process
> freezes randomly, sometimes during the conversion of the first disk
> or the third...

Can you run virt-v2v with the -x and -v options and post the
complete output.

Rich.

--

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
Pino Toscano | 10 Oct 17:10 2014
Picon

[PATCH 1/3] Move JSON to mllib

Move the simple OCaml JSON writer to mllib, so that can be enhanced and
used also outside v2v.
---
 mllib/JSON.ml     | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 mllib/JSON.mli    | 26 ++++++++++++++++++++++++++
 mllib/Makefile.am |  5 ++++-
 po/POTFILES-ml    |  2 +-
 v2v/JSON.ml       | 53 -----------------------------------------------------
 v2v/JSON.mli      | 26 --------------------------
 v2v/Makefile.am   |  3 +--
 7 files changed, 85 insertions(+), 83 deletions(-)
 create mode 100644 mllib/JSON.ml
 create mode 100644 mllib/JSON.mli
 delete mode 100644 v2v/JSON.ml
 delete mode 100644 v2v/JSON.mli

diff --git a/mllib/JSON.ml b/mllib/JSON.ml
new file mode 100644
index 0000000..5e3a879
--- /dev/null
+++ b/mllib/JSON.ml
 <at>  <at>  -0,0 +1,53  <at>  <at> 
+(* virt-v2v
+ * Copyright (C) 2009-2014 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(* Poor man's JSON generator. *)
+
+open Printf
+
+open Common_utils
+
+type field = string * json_t
+and json_t = String of string | Int of int
+and doc = field list
+
+(* JSON quoting. *)
+let json_quote str =
+  let str = replace_str str "\\" "\\\\" in
+  let str = replace_str str "\"" "\\\"" in
+  let str = replace_str str "'" "\\'" in
+  let str = replace_str str "\008" "\\b" in
+  let str = replace_str str "\012" "\\f" in
+  let str = replace_str str "\n" "\\n" in
+  let str = replace_str str "\r" "\\r" in
+  let str = replace_str str "\t" "\\t" in
+  let str = replace_str str "\011" "\\v" in
+  str
+
+let string_of_doc fields =
+  "{ " ^
+    String.concat ", " (
+      List.map (
+        function
+        | (n, String v) ->
+          sprintf "\"%s\" : \"%s\"" n (json_quote v)
+        | (n, Int v) ->
+          sprintf "\"%s\" : %d" n v
+      ) fields
+    )
+  ^ " }"
diff --git a/mllib/JSON.mli b/mllib/JSON.mli
new file mode 100644
index 0000000..1e3a1b3
--- /dev/null
+++ b/mllib/JSON.mli
 <at>  <at>  -0,0 +1,26  <at>  <at> 
+(* virt-v2v
+ * Copyright (C) 2009-2014 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(** Poor man's JSON generator. *)
+
+type field = string * json_t
+and json_t = String of string | Int of int
+and doc = field list
+
+val string_of_doc : doc -> string
+  (** Serialize {!doc} object as a string. *)
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index ac953ac..653b8aa 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
 <at>  <at>  -32,6 +32,8  <at>  <at>  SOURCES = \
 	fsync-c.c \
 	fsync.mli \
 	fsync.ml \
+	JSON.mli \
+	JSON.ml \
 	mkdtemp.mli \
 	mkdtemp.ml \
 	mkdtemp-c.c \
 <at>  <at>  -65,7 +67,8  <at>  <at>  ocaml_modules = config \
 	uRI \
 	mkdtemp \
 	planner \
-	regedit
+	regedit \
+	JSON

 OBJECTS = \
 	$(top_builddir)/fish/guestfish-progress.o \
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index df39e7b..d919b6f 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
 <at>  <at>  -25,6 +25,7  <at>  <at>  customize/perl_edit.ml
 customize/random_seed.ml
 customize/timezone.ml
 customize/urandom.ml
+mllib/JSON.ml
 mllib/common_gettext.ml
 mllib/common_utils.ml
 mllib/common_utils_tests.ml
 <at>  <at>  -83,7 +84,6  <at>  <at>  sysprep/sysprep_operation_user_account.ml
 sysprep/sysprep_operation_utmp.ml
 sysprep/sysprep_operation_yum_uuid.ml
 v2v/DOM.ml
-v2v/JSON.ml
 v2v/OVF.ml
 v2v/cmdline.ml
 v2v/convert_linux.ml
diff --git a/v2v/JSON.ml b/v2v/JSON.ml
deleted file mode 100644
index 5e3a879..0000000
--- a/v2v/JSON.ml
+++ /dev/null
 <at>  <at>  -1,53 +0,0  <at>  <at> 
-(* virt-v2v
- * Copyright (C) 2009-2014 Red Hat Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *)
-
-(* Poor man's JSON generator. *)
-
-open Printf
-
-open Common_utils
-
-type field = string * json_t
-and json_t = String of string | Int of int
-and doc = field list
-
-(* JSON quoting. *)
-let json_quote str =
-  let str = replace_str str "\\" "\\\\" in
-  let str = replace_str str "\"" "\\\"" in
-  let str = replace_str str "'" "\\'" in
-  let str = replace_str str "\008" "\\b" in
-  let str = replace_str str "\012" "\\f" in
-  let str = replace_str str "\n" "\\n" in
-  let str = replace_str str "\r" "\\r" in
-  let str = replace_str str "\t" "\\t" in
-  let str = replace_str str "\011" "\\v" in
-  str
-
-let string_of_doc fields =
-  "{ " ^
-    String.concat ", " (
-      List.map (
-        function
-        | (n, String v) ->
-          sprintf "\"%s\" : \"%s\"" n (json_quote v)
-        | (n, Int v) ->
-          sprintf "\"%s\" : %d" n v
-      ) fields
-    )
-  ^ " }"
diff --git a/v2v/JSON.mli b/v2v/JSON.mli
deleted file mode 100644
index 1e3a1b3..0000000
--- a/v2v/JSON.mli
+++ /dev/null
 <at>  <at>  -1,26 +0,0  <at>  <at> 
-(* virt-v2v
- * Copyright (C) 2009-2014 Red Hat Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *)
-
-(** Poor man's JSON generator. *)
-
-type field = string * json_t
-and json_t = String of string | Int of int
-and doc = field list
-
-val string_of_doc : doc -> string
-  (** Serialize {!doc} object as a string. *)
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 8bf8f07..dafe27e 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
 <at>  <at>  -37,7 +37,6  <at>  <at>  SOURCES_MLI = \
 	input_libvirt.mli \
 	input_libvirtxml.mli \
 	input_ova.mli \
-	JSON.mli \
 	kvmuid.mli \
 	linux.mli \
 	modules_list.mli \
 <at>  <at>  -62,7 +61,6  <at>  <at>  SOURCES_ML = \
 	xml.ml \
 	domainxml.ml \
 	DOM.ml \
-	JSON.ml \
 	kvmuid.ml \
 	vCenter.ml \
 	xen.ml \
 <at>  <at>  -122,6 +120,7  <at>  <at>  BOBJECTS = \
 	$(top_builddir)/mllib/progress.cmo \
 	$(top_builddir)/mllib/config.cmo \
 	$(top_builddir)/mllib/mkdtemp.cmo \
+	$(top_builddir)/mllib/JSON.cmo \
 	$(top_builddir)/customize/urandom.cmo \
 	$(top_builddir)/customize/random_seed.cmo \
 	$(top_builddir)/customize/hostname.cmo \
--

-- 
1.9.3

Gmane