Pino Toscano | 28 Jul 19:53 2014

[PATCH] make-fs: respect libguestfs' temporary dir

Do not hardcode /tmp.
 make-fs/make-fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/make-fs/make-fs.c b/make-fs/make-fs.c
index 1bec3e2..9c11fef 100644
--- a/make-fs/make-fs.c
+++ b/make-fs/make-fs.c
 <at>  <at>  -381,8 +381,9  <at>  <at>  estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn)
   char line[256];
   size_t len;
+  CLEANUP_FREE char *tmpdir = guestfs_get_tmpdir (g);

-  if (asprintf (&tmpfile, "/tmp/makefsXXXXXX") == -1) {
+  if (asprintf (&tmpfile, "%s/makefsXXXXXX", tmpdir) == -1) {
     perror ("asprintf");
     return -1;

Pino Toscano | 25 Jul 17:36 2014

[PATCH] p2v: properly call va_end

 p2v/miniexpect.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/p2v/miniexpect.c b/p2v/miniexpect.c
index ec81030..1baab5f 100644
--- a/p2v/miniexpect.c
+++ b/p2v/miniexpect.c
 <at>  <at>  -114,6 +114,7  <at>  <at>  mexp_spawnl (const char *file, const char *arg, ...)
     new_argv = realloc (argv, sizeof (char *) * (i+1));
     if (new_argv == NULL) {
       free (argv);
+      va_end (args);
       return NULL;
     argv = new_argv;
 <at>  <at>  -122,6 +123,7  <at>  <at>  mexp_spawnl (const char *file, const char *arg, ...)

   h = mexp_spawnv (file, argv);
   free (argv);
+  va_end (args);
   return h;


Richard W.M. Jones | 25 Jul 15:07 2014

[PATCH] launch: Close file descriptors after fork (RHBZ#1123007).

This refactors existing code to close file descriptors in the recovery
process, and also adds code to close file descriptors between the
fork() and exec() of QEMU or User-Mode Linux.

The reason is to avoid leaking main process file descriptors where the
main process (or other libraries in the main process) are not setting
O_CLOEXEC at all or not setting it atomically.  Python is a particular

See also this OpenStack Nova bug report:

Thanks: Qin Zhao for identifying and characterizing the problem in Nova.
 src/guestfs-internal-frontend.h | 16 +++++++++++++++-
 src/launch-direct.c             | 17 +++++++++--------
 src/launch-uml.c                | 13 +++++--------
 3 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index 6bf0a94..3129018 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
 <at>  <at>  -1,5 +1,5  <at>  <at> 
 /* libguestfs
- * Copyright (C) 2013 Red Hat Inc.
+ * Copyright (C) 2013-2014 Red Hat Inc.
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
(Continue reading)

Richard W.M. Jones | 23 Jul 16:06 2014

[PATCH] sparsify: Relax requirement that output device cannot be block device.

To fix RHBZ#1056290, I prevented virt-sparsify being used if the
output device is a block device.

I have now retested this scenario and it does work (in both copying
and in-place mode), and does not delete the output device, and
therefore we can relax this restriction so only char devices are

This is useful for oVirt which uses a qcow2 formatted block device to
store virtual machines.
 sparsify/ | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/sparsify/ b/sparsify/
index a99c851..b1fb83f 100644
--- a/sparsify/
+++ b/sparsify/
 <at>  <at>  -167,11 +167,7  <at>  <at>  read the man page virt-sparsify(1).
           Sys.getcwd () // indisk in

-      (* Check the output is not a block or char special (RHBZ#1056290). *)
-      if is_block_device outdisk then
-        error (f_"output '%s' cannot be a block device, it must be a regular file")
-          outdisk;
+      (* Check the output is not a char special (RHBZ#1056290). *)
       if is_char_device outdisk then
         error (f_"output '%s' cannot be a character device, it must be a regular file")
(Continue reading)

Richard W.M. Jones | 22 Jul 16:30 2014

Reminder: libguestfs preview for RHEL 7.1 is available

Just a reminder that if you're using RHEL 7.0 or CentOS 7.0, you
might be interested in using the RHEL 7.1 libguestfs preview

The general plan is to rebase to libguestfs 1.28 when it is available.
I have just updated them to:

 - libguestfs 1.27.22
 - hivex 1.3.10
 - supermin 5.1.9

To install these packages, follow the simple instructions here:



Richard Jones, Virtualization Group, Red Hat
Read my programming and virtualization blog:
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
Richard W.M. Jones | 20 Jul 20:02 2014

IRC question: Ruby gems

  18:24 < cknapp> rwmjones: is the RPM the best way to grab the guestfs gem?

[Please stay in the channel after asking a question!]

We currently ship the Ruby bindings as an extension in the ruby/
subdirectory of the source tarball.  (Note that because the extension
is mostly generated during the build, you will have to download the
tarball from which contains the
generated bits; or, much less conveniently, you will have to do a full
build from git).

So there is no gem as such.  In particular there is nothing on

However it should be possible to take the ruby/ subdirectory and turn
it into a gem with minimal effort, since it is already in mostly the
right format.  In particular, see the Gem::Specification section in

I don't know how the gem relates to the Fedora RPM.  Possibly not at



Richard Jones, Virtualization Group, Red Hat
Read my programming and virtualization blog:
virt-builder quickly builds VMs from scratch
(Continue reading)

Pino Toscano | 17 Jul 16:28 2014

[PATCH] configure: look for "default-java" as directory for Java

In Debian-based systems, /usr/lib/jvm/default-java is a symlink
pointing to the location of the default Java version.
--- | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ b/
index ec98e4b..932bad1 100644
--- a/
+++ b/
 <at>  <at>  -1250,6 +1250,7  <at>  <at>  if test "x$with_java" != "xno"; then
         # Look for Java in some likely locations.
         for d in \
             /usr/lib/jvm/java \
+            /usr/lib/jvm/default-java \
             if test -d $d && test -f $d/bin/java; then

Vasiliy Tolstov | 15 Jul 13:33 2014

working with mount-local

Hi. I'm try to use guestfish inside golang (extract some files from
image and create squashfs from root).
Now i can't understand how can i work with mount-local/mount-local-run.
Where i can specify what partition i'm export to local? Does i need
firstly mount /dev/sda1 to / for example and after that run
mount-local /tmp/xxx ?
Second - i'm work with guestfish via writing to stdin and getting
result from stdout. In case of mount-local-run does i need fully fork
new binary or i can only dup stdin descriptor and work with it?


Vasiliy Tolstov,
e-mail: v.tolstov <at>
jabber: vase <at>
Pino Toscano | 14 Jul 11:29 2014

[PATCH] appliance: init: run ldconfig

Run ldconfig early in the init script, so libraries outside standard
library paths but with a proper configuration file pointing at
them can be found.
 appliance/init | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/appliance/init b/appliance/init
index b407bf9..94e77cf 100755
--- a/appliance/init
+++ b/appliance/init
 <at>  <at>  -10,6 +10,10  <at>  <at>  RUNLEVEL=S

+# Make sure to find all the libraries, also those in non-standard place
+# but with a proper configuration pointing at them
+ldconfig || :
 # Try to print a stack trace for segfaults inside the appliance.
 for d in /lib64 /lib; do

Vasiliy Tolstov | 11 Jul 16:18 2014

golang binding help

Hello. I'm very happy with libguestfs, but now i'm try to write packer
plugin to strip images:
1) resize filesystem to minimum
2) resize partitions to minimum
3) create/resize file with needed size

But golang binding have not docs. Is that possible to generate
something suitable to to determine api methods and
input,output variables for functions?


Vasiliy Tolstov,
e-mail: v.tolstov <at>
jabber: vase <at>
Gleb Voronich | 11 Jul 14:00 2014

File not found by ext2_lookup


I've been trying to clone one disk image (LVM) to another using virt-resize.
Unfortunately I get the following error:

# virt-resize /dev/vm/vm6 /dev/vm/vm7

supermin helper [00004ms] finished creating kernel
supermin helper [00251ms] finished mke2fs
<domain type='kvm'>
supermin helper [00252ms] visiting /usr/lib64/guestfs/supermin.d
supermin helper [00252ms] visiting /usr/lib64/guestfs/supermin.d/base.img.gz
supermin helper [03505ms] visiting 
supermin helper [03527ms] visiting /usr/lib64/guestfs/supermin.d/hostfiles
libguestfs: trace: launch = -1 (error)
Fatal error: exception Guestfs.Error("supermin-helper exited with error 
status 1, see debug messages above")
libguestfs: trace: close

Is there any known issue that could cause this?
I have CentOS 7.0.1406 at the host node at CentOS 6.5 at the guest.