Re: [Libguestfs] libguestfs powerpc package
by Richard W.M. Jones
[Please keep message on the list]
On Mon, Sep 30, 2013 at 12:58:38AM +0200, Roberto Innocenti wrote:
> [libguestfs on ppc]
You should be able to compile from the latest source on ppc64, since I
spent some time a few weeks ago getting it to work:
http://comments.gmane.org/gmane.linux.redhat.fedora.virtualization/2268
Start with git (not 1.22), read the README file, and let us know on
the mailing list what precise errors you get when you try to compile it.
Note you'll require the latest supermin (from git) first, and qemu
from git, and IIRC there was an endianness bug in hivex too which is
fixed in git. The latest hivex isn't required unless you're doing
Widows guest inspection.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
10 years, 8 months
enable build for ocaml bytecode
by Olaf Hering
This is a first attempt to build libguestfs with just a ocaml bytecode
compiler. The three tools written in ocaml will be build only when an
ocamlopt compiler is available.
Olaf
---
Makefile.am | 5 ++++-
configure.ac | 2 ++
ocaml/Makefile.am | 20 +++++++++++++++++---
resize/Makefile.am | 2 +-
sparsify/Makefile.am | 2 +-
sysprep/Makefile.am | 2 +-
6 files changed, 26 insertions(+), 7 deletions(-)
Index: libguestfs-1.20.1/Makefile.am
===================================================================
--- libguestfs-1.20.1.orig/Makefile.am
+++ libguestfs-1.20.1/Makefile.am
@@ -74,7 +74,10 @@ if HAVE_PERL
SUBDIRS += perl perl/examples
endif
if HAVE_OCAML
-SUBDIRS += ocaml ocaml/examples
+SUBDIRS += ocaml
+endif
+if HAVE_OCAMLOPT
+SUBDIRS += ocaml/examples
endif
if HAVE_PYTHON
SUBDIRS += python python/examples
Index: libguestfs-1.20.1/configure.ac
===================================================================
--- libguestfs-1.20.1.orig/configure.ac
+++ libguestfs-1.20.1/configure.ac
@@ -865,6 +865,8 @@ AS_IF([test "x$enable_ocaml" != "xno"],
])
AM_CONDITIONAL([HAVE_OCAML],
[test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"])
+AM_CONDITIONAL([HAVE_OCAMLOPT],
+ [test "x$OCAMLOPT" != "xno" && test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"])
AM_CONDITIONAL([HAVE_OCAMLDOC],
[test "x$OCAMLDOC" != "xno"])
Index: libguestfs-1.20.1/ocaml/Makefile.am
===================================================================
--- libguestfs-1.20.1.orig/ocaml/Makefile.am
+++ libguestfs-1.20.1/ocaml/Makefile.am
@@ -43,10 +43,20 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/
if HAVE_OCAML
+DATA_HOOK_FILES = META *.so *.a *.cma \
+ *.cmi $(srcdir)/*.mli
+if HAVE_OCAMLOPT
+DATA_HOOK_FILES += *.cmx *.cmxa
+endif
+
OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
-noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
+noinst_DATA = mlguestfs.cma
+if HAVE_OCAMLOPT
+noinst_DATA += mlguestfs.cmxa
+endif
+noinst_DATA += META
# Build the C part into a library, so that automake handles the C
# compilation step for us. Note that we don't directly use this
@@ -101,9 +111,13 @@ TESTS = run-bindtests \
$(patsubst %,%.opt,$(test_progs)))
noinst_DATA += \
- bindtests.bc bindtests.opt \
+ bindtests.bc
+if HAVE_OCAMLOPT
+noinst_DATA += \
+ bindtests.opt \
$(test_progs:%=%.bc) \
$(test_progs:%=%.opt)
+endif
bindtests.bc: bindtests.cmo mlguestfs.cma
mkdir -p t
@@ -217,7 +231,7 @@ install-data-hook:
$(OCAMLFIND) install \
-ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
guestfs \
- META *.so *.a *.cma *.cmx *.cmxa *.cmi $(srcdir)/*.mli
+ $(DATA_HOOK_FILES)
rm $(DESTDIR)$(OCAMLLIB)/guestfs/bindtests.*
rm $(DESTDIR)$(OCAMLLIB)/guestfs/libguestfsocaml.a
Index: libguestfs-1.20.1/resize/Makefile.am
===================================================================
--- libguestfs-1.20.1.orig/resize/Makefile.am
+++ libguestfs-1.20.1/resize/Makefile.am
@@ -40,7 +40,7 @@ SOURCES = \
resize_utils.ml \
resize_utils_tests.ml
-if HAVE_OCAML
+if HAVE_OCAMLOPT
# Note this list must be in dependency order.
OBJECTS = \
Index: libguestfs-1.20.1/sparsify/Makefile.am
===================================================================
--- libguestfs-1.20.1.orig/sparsify/Makefile.am
+++ libguestfs-1.20.1/sparsify/Makefile.am
@@ -36,7 +36,7 @@ SOURCES = \
sparsify_gettext.ml \
sparsify_utils.ml
-if HAVE_OCAML
+if HAVE_OCAMLOPT
# Note this list must be in dependency order.
OBJECTS = \
Index: libguestfs-1.20.1/sysprep/Makefile.am
===================================================================
--- libguestfs-1.20.1.orig/sysprep/Makefile.am
+++ libguestfs-1.20.1/sysprep/Makefile.am
@@ -86,7 +86,7 @@ SOURCES = \
utils.ml \
utils.mli
-if HAVE_OCAML
+if HAVE_OCAMLOPT
# Note this list must be in dependency order.
OBJECTS = \
10 years, 10 months
[PATCH] fuse: provide a stub "flush" implementation (RHBZ#660687).
by Pino Toscano
It seems that FUSE can invoke flush to make sure the pending changes
(e.g. to the attributes) of a file are set. Since a missing flush
implementation is handled as if it were returning ENOSYS, this can cause
issues later.
To overcome this, just provide a stub implementation which does nothing,
since we have nothing to do and don't want to have FUSE error out.
Furthermore, uncomment the timestamp checks in test-fuse.sh, since now
they should be working fine.
---
fuse/test-fuse.sh | 23 +++++++++++------------
src/fuse.c | 15 +++++++++++++++
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/fuse/test-fuse.sh b/fuse/test-fuse.sh
index f1e03d0..30b3c31 100755
--- a/fuse/test-fuse.sh
+++ b/fuse/test-fuse.sh
@@ -220,18 +220,17 @@ if truncate --help >/dev/null 2>&1; then
rm -f truncated
fi
-# Disabled because of RHBZ#660687 on Debian.
-# stage Checking utimens and timestamps
-# for ts in 12345 1234567 987654321; do
-# # NB: It's not possible to set the ctime with touch.
-# touch -a -d @$ts timestamp
-# [ "$(stat -c %X timestamp)" -eq $ts ]
-# touch -m -d @$ts timestamp
-# [ "$(stat -c %Y timestamp)" -eq $ts ]
-# touch -d @$ts timestamp
-# [ "$(stat -c %X timestamp)" -eq $ts ]
-# [ "$(stat -c %Y timestamp)" -eq $ts ]
-# done
+stage Checking utimens and timestamps
+for ts in 12345 1234567 987654321; do
+ # NB: It's not possible to set the ctime with touch.
+ touch -a -d @$ts timestamp
+ [ "$(stat -c %X timestamp)" -eq $ts ]
+ touch -m -d @$ts timestamp
+ [ "$(stat -c %Y timestamp)" -eq $ts ]
+ touch -d @$ts timestamp
+ [ "$(stat -c %X timestamp)" -eq $ts ]
+ [ "$(stat -c %Y timestamp)" -eq $ts ]
+done
stage Checking writes
cp hello.txt copy.txt
diff --git a/src/fuse.c b/src/fuse.c
index 967a744..748b933 100644
--- a/src/fuse.c
+++ b/src/fuse.c
@@ -876,6 +876,20 @@ mount_local_removexattr(const char *path, const char *name)
return 0;
}
+static int
+mount_local_flush(const char *path, struct fuse_file_info *fi)
+{
+ DECL_G ();
+ DEBUG_CALL ("%s", path);
+
+ /* Just a stub. This method is called whenever FUSE wants to flush the
+ * pending changes (f.ex. to attributes) to a file. Since we don't have
+ * anything to do and don't want FUSE to think something went badly,
+ * just return 0.
+ */
+ return 0;
+}
+
static struct fuse_operations mount_local_operations = {
.getattr = mount_local_getattr,
.access = mount_local_access,
@@ -902,6 +916,7 @@ static struct fuse_operations mount_local_operations = {
.getxattr = mount_local_getxattr,
.listxattr = mount_local_listxattr,
.removexattr = mount_local_removexattr,
+ .flush = mount_local_flush,
};
int
--
1.8.3.1
10 years, 11 months
[PATCH 1/2] lib: write: Remove unused variable.
by Richard W.M. Jones
---
lib/write.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/write.c b/lib/write.c
index 8c4dd8e..384c6b2 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -954,7 +954,6 @@ hivex_node_set_values (hive_h *h, hive_node_h node,
for (i = 0; i < nr_values; ++i) {
/* Allocate vk record to store this (key, value) pair. */
static const char vk_id[2] = { 'v', 'k' };
- size_t name_len = strlen (values[i].key);
size_t recoded_name_len;
int use_utf16;
char* recoded_name = _hivex_encode_string (values[i].key, &recoded_name_len,
--
1.8.4.2
10 years, 11 months
libguestfs build fails with: /usr/lib64/golang/pkg/linux_amd64/libguestfs.org/guestfs.a -- no such file
by Kashyap Chamarthy
I'm on libguestfs Fedora git master branch:
$ git log | head -1
commit 8eb1aa2406632eb4202bbd976459334854295a77
$ yum-builddep libguestfs
$ fedpkg local
Results in:
==========
.
.
.
make[4]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject'
Making all in docs
make[4]: Entering directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject/docs'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject/docs'
make[3]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject'
make[2]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject'
Making all in golang
make[2]: Entering directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/golang'
../run go install libguestfs.org/guestfs
go install libguestfs.org/guestfs: open
/usr/lib64/golang/pkg/linux_amd64/libguestfs.org/guestfs.a: permission denied
make[2]: *** [pkg/linux_amd64/libguestfs.org/guestfs.a] Error 1
make[2]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/golang'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18'
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.wnFopm (%build)
==========
There's no such file as guestfs.a in the above said directory:
==========
$ tree /usr/lib64/golang/pkg/linux_amd64/libguestfs.org/
/usr/lib64/golang/pkg/linux_amd64/libguestfs.org/
└── guestfs
1 directory, 0 files
==========
What am I missing?
Thanks in advance.
--
/kashyap
10 years, 11 months
[PATCH] ruby: Fix .new method (RHBZ#1046509).
by Richard W.M. Jones
The .new method was unintentionally broken in
commit 9466060201600db47016133d80af22eb38091a49.
This fixes the .new method and allows it to be called with multiple
parameters, so you can use:
Guestfs::Guestfs.new
Guestfs::Guestfs.new()
Guestfs::Guestfs.new(:close_on_exit => false)
etc.
For backwards compatibility, Guestfs::create may still be used.
This commit also adds regression tests:
- Use .new method in regular tests. (Because this was not done
before, we didn't catch the breakage.)
- Test that ::create still works.
- Test that args can be passed to .new method.
---
generator/bindtests.ml | 2 +-
generator/ruby.ml | 98 ++++++++++++++++++++++++++++++--------
ruby/t/tc_020_create.rb | 2 +-
ruby/t/tc_030_create_flags.rb | 29 +++++++++++
ruby/t/tc_040_create_multiple.rb | 32 +++++++++++++
ruby/t/tc_050_handle_properties.rb | 36 ++++++++++++++
ruby/t/tc_060_explicit_close.rb | 29 +++++++++++
ruby/t/tc_070_optargs.rb | 2 +-
ruby/t/tc_100_launch.rb | 2 +-
ruby/t/tc_410_close_event.rb | 2 +-
ruby/t/tc_420_log_messages.rb | 2 +-
ruby/t/tc_800_rhbz507346.rb | 2 +-
ruby/t/tc_810_rhbz664558c6.rb | 2 +-
ruby/t/tc_820_rhbz1046509.rb | 42 ++++++++++++++++
14 files changed, 254 insertions(+), 28 deletions(-)
create mode 100644 ruby/t/tc_030_create_flags.rb
create mode 100644 ruby/t/tc_040_create_multiple.rb
create mode 100644 ruby/t/tc_050_handle_properties.rb
create mode 100644 ruby/t/tc_060_explicit_close.rb
create mode 100644 ruby/t/tc_820_rhbz1046509.rb
diff --git a/generator/bindtests.ml b/generator/bindtests.ml
index 306dc83..ef57fb4 100644
--- a/generator/bindtests.ml
+++ b/generator/bindtests.ml
@@ -451,7 +451,7 @@ and generate_ruby_bindtests () =
pr "\
require 'guestfs'
-g = Guestfs::create()
+g = Guestfs::Guestfs.new()
";
let mkargs args optargs =
diff --git a/generator/ruby.ml b/generator/ruby.ml
index d6ca430..b8ec655 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -42,6 +42,7 @@ let rec generate_ruby_c () =
#include <stdint.h>
#include <string.h>
#include <errno.h>
+#include <assert.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
@@ -135,28 +136,33 @@ ruby_guestfs_free (void *gvp)
}
}
-/*
- * call-seq:
- * Guestfs::Guestfs.new([{:environment => false, :close_on_exit => false}]) -> Guestfs::Guestfs
- *
- * Call
- * +guestfs_create+[http://libguestfs.org/guestfs.3.html#guestfs_create]
- * to create a new libguestfs handle. The handle is represented in
- * Ruby as an instance of the Guestfs::Guestfs class.
+/* This is the ruby internal alloc function for the class. We do nothing
+ * here except allocate an object containing a NULL guestfs handle.
+ * Note we cannot call guestfs_create here because we need the extra
+ * parameters, which ruby passes via the initialize method (see next
+ * function).
*/
static VALUE
-ruby_guestfs_create (int argc, VALUE *argv, VALUE m)
+ruby_guestfs_alloc (VALUE klass)
{
- guestfs_h *g;
+ guestfs_h *g = NULL;
- if (argc > 1)
- rb_raise (rb_eArgError, \"expecting 0 or 1 arguments\");
-
- volatile VALUE optargsv = argc == 1 ? argv[0] : rb_hash_new ();
- Check_Type (optargsv, T_HASH);
+ /* Wrap it, and make sure the close function is called when the
+ * handle goes away.
+ */
+ return Data_Wrap_Struct (c_guestfs, NULL, ruby_guestfs_free, g);
+}
+static unsigned
+parse_flags (int argc, VALUE *argv)
+{
+ volatile VALUE optargsv;
unsigned flags = 0;
volatile VALUE v;
+
+ optargsv = argc == 1 ? argv[0] : rb_hash_new ();
+ Check_Type (optargsv, T_HASH);
+
v = rb_hash_lookup (optargsv, ID2SYM (rb_intern (\"environment\")));
if (v != Qnil && !RTEST (v))
flags |= GUESTFS_CREATE_NO_ENVIRONMENT;
@@ -164,6 +170,56 @@ ruby_guestfs_create (int argc, VALUE *argv, VALUE m)
if (v != Qnil && !RTEST (v))
flags |= GUESTFS_CREATE_NO_CLOSE_ON_EXIT;
+ return flags;
+}
+
+/*
+ * call-seq:
+ * Guestfs::Guestfs.new([{:environment => false, :close_on_exit => false}]) -> Guestfs::Guestfs
+ *
+ * Call
+ * +guestfs_create_flags+[http://libguestfs.org/guestfs.3.html#guestfs_create_flags]
+ * to create a new libguestfs handle. The handle is represented in
+ * Ruby as an instance of the Guestfs::Guestfs class.
+ */
+static VALUE
+ruby_guestfs_initialize (int argc, VALUE *argv, VALUE m)
+{
+ guestfs_h *g;
+ unsigned flags;
+
+ if (argc > 1)
+ rb_raise (rb_eArgError, \"expecting 0 or 1 arguments\");
+
+ /* Should have been set to NULL by prior call to alloc function. */
+ assert (DATA_PTR (m) == NULL);
+
+ flags = parse_flags (argc, argv);
+
+ g = guestfs_create_flags (flags);
+ if (!g)
+ rb_raise (e_Error, \"failed to create guestfs handle\");
+
+ DATA_PTR (m) = g;
+
+ /* Don't print error messages to stderr by default. */
+ guestfs_set_error_handler (g, NULL, NULL);
+
+ return m;
+}
+
+/* For backwards compatibility. */
+static VALUE
+ruby_guestfs_create (int argc, VALUE *argv, VALUE module)
+{
+ guestfs_h *g;
+ unsigned flags;
+
+ if (argc > 1)
+ rb_raise (rb_eArgError, \"expecting 0 or 1 arguments\");
+
+ flags = parse_flags (argc, argv);
+
g = guestfs_create_flags (flags);
if (!g)
rb_raise (e_Error, \"failed to create guestfs handle\");
@@ -171,9 +227,6 @@ ruby_guestfs_create (int argc, VALUE *argv, VALUE m)
/* Don't print error messages to stderr by default. */
guestfs_set_error_handler (g, NULL, NULL);
- /* Wrap it, and make sure the close function is called when the
- * handle goes away.
- */
return Data_Wrap_Struct (c_guestfs, NULL, ruby_guestfs_free, g);
}
@@ -707,10 +760,10 @@ Init__guestfs (void)
#ifndef HAVE_TYPE_RB_ALLOC_FUNC_T
#define rb_alloc_func_t void*
#endif
- rb_define_alloc_func (c_guestfs, (rb_alloc_func_t) ruby_guestfs_create);
+ rb_define_alloc_func (c_guestfs, (rb_alloc_func_t) ruby_guestfs_alloc);
#endif
- rb_define_module_function (m_guestfs, \"create\", ruby_guestfs_create, -1);
+ rb_define_method (c_guestfs, \"initialize\", ruby_guestfs_initialize, -1);
rb_define_method (c_guestfs, \"close\", ruby_guestfs_close, 0);
rb_define_method (c_guestfs, \"set_event_callback\",
ruby_set_event_callback, 2);
@@ -719,6 +772,11 @@ Init__guestfs (void)
rb_define_module_function (m_guestfs, \"event_to_string\",
ruby_event_to_string, 1);
+ /* For backwards compatibility with older code, define a ::create
+ * module function.
+ */
+ rb_define_module_function (m_guestfs, \"create\", ruby_guestfs_create, -1);
+
";
(* Constants. *)
diff --git a/ruby/t/tc_020_create.rb b/ruby/t/tc_020_create.rb
index 2b57ba1..4a04e97 100644
--- a/ruby/t/tc_020_create.rb
+++ b/ruby/t/tc_020_create.rb
@@ -22,7 +22,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_create
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
assert_not_nil (g)
end
end
diff --git a/ruby/t/tc_030_create_flags.rb b/ruby/t/tc_030_create_flags.rb
new file mode 100644
index 0000000..7ec2ce9
--- /dev/null
+++ b/ruby/t/tc_030_create_flags.rb
@@ -0,0 +1,29 @@
+# libguestfs Ruby bindings -*- ruby -*-
+# Copyright (C) 2013 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.
+
+require 'test/unit'
+$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
+$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
+require 'guestfs'
+
+class TestLoad < Test::Unit::TestCase
+ def test_create_flags
+ g = Guestfs::Guestfs.new(:environment => false, :close_on_exit => true)
+ assert_not_nil (g)
+ g.parse_environment()
+ end
+end
diff --git a/ruby/t/tc_040_create_multiple.rb b/ruby/t/tc_040_create_multiple.rb
new file mode 100644
index 0000000..339b699
--- /dev/null
+++ b/ruby/t/tc_040_create_multiple.rb
@@ -0,0 +1,32 @@
+# libguestfs Ruby bindings -*- ruby -*-
+# Copyright (C) 2013 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.
+
+require 'test/unit'
+$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
+$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
+require 'guestfs'
+
+class TestLoad < Test::Unit::TestCase
+ def test_create_multiple
+ g1 = Guestfs::Guestfs.new()
+ g2 = Guestfs::Guestfs.new()
+ g3 = Guestfs::Guestfs.new()
+ assert_not_nil (g1)
+ assert_not_nil (g2)
+ assert_not_nil (g3)
+ end
+end
diff --git a/ruby/t/tc_050_handle_properties.rb b/ruby/t/tc_050_handle_properties.rb
new file mode 100644
index 0000000..cf4a7a7
--- /dev/null
+++ b/ruby/t/tc_050_handle_properties.rb
@@ -0,0 +1,36 @@
+# libguestfs Ruby bindings -*- ruby -*-
+# Copyright (C) 2013 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.
+
+require 'test/unit'
+$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
+$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
+require 'guestfs'
+
+class TestLoad < Test::Unit::TestCase
+ def test_handle_properties
+ g = Guestfs::Guestfs.new()
+ assert_not_nil (g)
+ v = g.get_verbose()
+ g.set_verbose(v)
+ v = g.get_trace()
+ g.set_trace(v)
+ v = g.get_memsize()
+ g.set_memsize(v)
+ v = g.get_path()
+ g.set_path(v)
+ end
+end
diff --git a/ruby/t/tc_060_explicit_close.rb b/ruby/t/tc_060_explicit_close.rb
new file mode 100644
index 0000000..74456e4
--- /dev/null
+++ b/ruby/t/tc_060_explicit_close.rb
@@ -0,0 +1,29 @@
+# libguestfs Ruby bindings -*- ruby -*-
+# Copyright (C) 2013 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.
+
+require 'test/unit'
+$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
+$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
+require 'guestfs'
+
+class TestLoad < Test::Unit::TestCase
+ def test_explicit_close
+ g = Guestfs::Guestfs.new()
+ assert_not_nil (g)
+ g.close()
+ end
+end
diff --git a/ruby/t/tc_070_optargs.rb b/ruby/t/tc_070_optargs.rb
index 4506466..e28f944 100644
--- a/ruby/t/tc_070_optargs.rb
+++ b/ruby/t/tc_070_optargs.rb
@@ -22,7 +22,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_optargs
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
g.add_drive("/dev/null", {})
g.add_drive("/dev/null", :readonly => 1)
diff --git a/ruby/t/tc_100_launch.rb b/ruby/t/tc_100_launch.rb
index f6c1c16..2b4b535 100644
--- a/ruby/t/tc_100_launch.rb
+++ b/ruby/t/tc_100_launch.rb
@@ -22,7 +22,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_launch
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
g.add_drive_scratch(500*1024*1024)
g.launch()
diff --git a/ruby/t/tc_410_close_event.rb b/ruby/t/tc_410_close_event.rb
index ebf4bbc..d7e53d4 100644
--- a/ruby/t/tc_410_close_event.rb
+++ b/ruby/t/tc_410_close_event.rb
@@ -22,7 +22,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_events
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
close_invoked = 0
close = Proc.new {| event, event_handle, buf, array |
diff --git a/ruby/t/tc_420_log_messages.rb b/ruby/t/tc_420_log_messages.rb
index 3fe70de..b734fb8 100644
--- a/ruby/t/tc_420_log_messages.rb
+++ b/ruby/t/tc_420_log_messages.rb
@@ -22,7 +22,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_events
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
log_invoked = 0
log = Proc.new {| event, event_handle, buf, array |
diff --git a/ruby/t/tc_800_rhbz507346.rb b/ruby/t/tc_800_rhbz507346.rb
index e380b73..66e0e92 100644
--- a/ruby/t/tc_800_rhbz507346.rb
+++ b/ruby/t/tc_800_rhbz507346.rb
@@ -22,7 +22,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_rhbz507346
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
g.add_drive_scratch(10*1024*1024)
g.launch()
diff --git a/ruby/t/tc_810_rhbz664558c6.rb b/ruby/t/tc_810_rhbz664558c6.rb
index 290deac..5eb373e 100644
--- a/ruby/t/tc_810_rhbz664558c6.rb
+++ b/ruby/t/tc_810_rhbz664558c6.rb
@@ -26,7 +26,7 @@ require 'guestfs'
class TestLoad < Test::Unit::TestCase
def test_rhbz664558c6
- g = Guestfs::create()
+ g = Guestfs::Guestfs.new()
close_invoked = 0
close = Proc.new {| event, event_handle, buf, array |
diff --git a/ruby/t/tc_820_rhbz1046509.rb b/ruby/t/tc_820_rhbz1046509.rb
new file mode 100644
index 0000000..978decd
--- /dev/null
+++ b/ruby/t/tc_820_rhbz1046509.rb
@@ -0,0 +1,42 @@
+# libguestfs Ruby bindings -*- ruby -*-
+# Copyright (C) 2013 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.
+
+# Test that we don't break the old ::create module function while
+# fixing https://bugzilla.redhat.com/show_bug.cgi?id=1046509
+
+require 'test/unit'
+$:.unshift(File::join(File::dirname(__FILE__), "..", "lib"))
+$:.unshift(File::join(File::dirname(__FILE__), "..", "ext", "guestfs"))
+require 'guestfs'
+
+class TestLoad < Test::Unit::TestCase
+ def _handleok(g)
+ g.add_drive("/dev/null")
+ g.close()
+ end
+
+ def test_rhbz1046509
+ g = Guestfs::create()
+ _handleok(g)
+
+ g = Guestfs::create(:close_on_exit => true)
+ _handleok(g)
+
+ g = Guestfs::create(:close_on_exit => true, :environment => true)
+ _handleok(g)
+ end
+end
--
1.8.4.2
11 years
[PATCH] tests/mountable: skip if btrfs is not available
by Pino Toscano
This test uses btrfs, so skip it if the "btrfs" feature is not
available.
---
tests/mountable/test-internal-parse-mountable.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/mountable/test-internal-parse-mountable.c b/tests/mountable/test-internal-parse-mountable.c
index ed3264e..bf03743 100644
--- a/tests/mountable/test-internal-parse-mountable.c
+++ b/tests/mountable/test-internal-parse-mountable.c
@@ -33,6 +33,7 @@ main (int argc, char *argv[])
guestfs_h *g;
struct guestfs_internal_mountable *mountable;
const char *devices[] = { "/dev/VG/LV", NULL };
+ const char *feature[] = { "btrfs", NULL };
g = guestfs_create ();
if (g == NULL) {
@@ -48,6 +49,12 @@ main (int argc, char *argv[])
if (guestfs_launch (g) == -1) goto error;
+ if (!guestfs_feature_available (g, (char **) feature)) {
+ printf ("skipping test because btrfs is not available\n");
+ guestfs_close (g);
+ exit (77);
+ }
+
if (guestfs_part_disk (g, "/dev/sda", "mbr") == -1) goto error;
if (guestfs_pvcreate (g, "/dev/sda1") == -1) goto error;
--
1.8.3.1
11 years
[PATCH] inspect: fix detection of newer CirrOS versions (RHBZ#1045450).
by Pino Toscano
Add an own case for CirrOS, based on the /etc/cirros/version file
provided in newer version instead of the Buildroot-generated
/etc/br-version.
---
src/inspect-fs-unix.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index a9e5cad..c70960a 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -574,6 +574,18 @@ guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs)
return -1;
}
+ /* CirrOS versions providing a own version file.
+ */
+ else if (guestfs_is_file_opts (g, "/etc/cirros/version",
+ GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
+ fs->distro = OS_DISTRO_CIRROS;
+
+ if (parse_release_file (g, fs, "/etc/cirros/version") == -1)
+ return -1;
+
+ if (guestfs___parse_major_minor (g, fs) == -1)
+ return -1;
+ }
/* Buildroot (http://buildroot.net) is an embedded Linux distro
* toolkit. It is used by specific distros such as Cirros.
*/
--
1.8.3.1
11 years
[PATCH] drives: add CD-ROM disk images as read-only drives (RHBZ#563450).
by Pino Toscano
The current add_cdrom way basically appends a new raw "-cdrom /path"
parameter to the qemu invocation (even when using libvirt as backend),
hence such images are seen as "CD-ROM drives" inside the appliance.
However, there is no need for such particular behaviour, as they need to
be handled as normal (read-only) drives.
Adding CD-ROM disk images as drives also changes the device names used
for them inside the appliance from /dev/srN to the usual e.g. /dev/sdX.
These changes fix different issues:
- it is possible to start guestfish without adding disks with -a, then
just add-cdrom and run
- list-devices does not cause guestfishd to crash when sorting the list
of devices (exposed by the test case in RHBZ#563450)
- the result of list-devices now reflects the order images were added
(RHBZ#563450)
Add two small regression tests for the fixes described above.
---
src/drives.c | 7 +-----
tests/regressions/Makefile.am | 2 ++
tests/regressions/rhbz563450.sh | 54 ++++++++++++++++++++++++++++++++++++++++
tests/regressions/rhbz563450b.sh | 43 ++++++++++++++++++++++++++++++++
4 files changed, 100 insertions(+), 6 deletions(-)
create mode 100755 tests/regressions/rhbz563450.sh
create mode 100755 tests/regressions/rhbz563450b.sh
diff --git a/src/drives.c b/src/drives.c
index 16798a3..4b65dda 100644
--- a/src/drives.c
+++ b/src/drives.c
@@ -1087,12 +1087,7 @@ guestfs__add_cdrom (guestfs_h *g, const char *filename)
return -1;
}
- if (access (filename, F_OK) == -1) {
- perrorf (g, "%s", filename);
- return -1;
- }
-
- return guestfs_config (g, "-cdrom", filename);
+ return guestfs__add_drive_ro (g, filename);
}
/* Depending on whether we are hotplugging or not, this function
diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am
index 5b0d1c3..741f45f 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -21,6 +21,8 @@ TESTS = \
rhbz501893 \
rhbz503169c13.sh \
rhbz557655.sh \
+ rhbz563450.sh \
+ rhbz563450b.sh \
rhbz576879.sh \
rhbz578407.sh \
rhbz580246.sh \
diff --git a/tests/regressions/rhbz563450.sh b/tests/regressions/rhbz563450.sh
new file mode 100755
index 0000000..6fa6f2b
--- /dev/null
+++ b/tests/regressions/rhbz563450.sh
@@ -0,0 +1,54 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2013 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.
+
+# https://bugzilla.redhat.com/show_bug.cgi?id=563450
+# Test the order of added images
+
+set -e
+export LANG=C
+
+rm -f test.out
+
+../../fish/guestfish --ro > test.out <<EOF
+add-drive-ro ../guests/fedora.img
+add-cdrom ../data/test.iso
+add-drive-ro ../guests/debian.img
+
+run
+
+list-devices
+echo ----
+list-partitions
+
+ping-daemon
+EOF
+
+if [ "$(cat test.out)" != "/dev/sda
+/dev/sdb
+/dev/sdc
+----
+/dev/sda1
+/dev/sda2
+/dev/sdc1
+/dev/sdc2" ]; then
+ echo "$0: unexpected output:"
+ cat test.out
+ exit 1
+fi
+
+rm -f test.out
diff --git a/tests/regressions/rhbz563450b.sh b/tests/regressions/rhbz563450b.sh
new file mode 100755
index 0000000..bae641a
--- /dev/null
+++ b/tests/regressions/rhbz563450b.sh
@@ -0,0 +1,43 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2013 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.
+
+# https://bugzilla.redhat.com/show_bug.cgi?id=563450
+# Test only CD-ROM disk images can be added
+
+set -e
+export LANG=C
+
+rm -f test.out
+
+../../fish/guestfish --ro > test.out <<EOF
+add-cdrom ../data/test.iso
+
+run
+
+list-devices
+
+ping-daemon
+EOF
+
+if [ "$(cat test.out)" != "/dev/sda" ]; then
+ echo "$0: unexpected output:"
+ cat test.out
+ exit 1
+fi
+
+rm -f test.out
--
1.8.3.1
11 years
[PATCH] launch: libvirt: Don't default to using NULL for libvirt connection URI (RHBZ#1045033).
by Richard W.M. Jones
From: "Richard W.M. Jones" <rjones(a)redhat.com>
NULL means that libvirt gets to guess what connection URI we meant.
Currently it guesses qemu:///session for non-root and qemu:///system
for root. Except if LIBVIRT_DEFAULT_URI is set in which case this is
used even if it's not appropriate. Except if Xen is installed in
which case it guesses xen:/// which is not helpful at all.
Instead use qemu:///session (or qemu:///system for root -- that's
likely to be wrong, but we can't help that).
If the user really wants to use NULL and let libvirt guess, then they
can now specify the libvirt:null backend.
See:
https://bugzilla.redhat.com/show_bug.cgi?id=1045033
https://bugzilla.redhat.com/show_bug.cgi?id=886915
A good way to test this is:
LIBVIRT_DEFAULT_URI=iambroken libguestfs-test-tool
The libguestfs libvirt backend should (after this commit) ignore
LIBVIRT_DEFAULT_URI. However other parts of libguestfs will still use
it, eg. guestfs_add_drive_opts, guestfish '-d' option.
---
src/guestfs.pod | 16 +++++++++++++---
src/launch-libvirt.c | 10 ++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/guestfs.pod b/src/guestfs.pod
index 1e4b16c..0aab4a9 100644
--- a/src/guestfs.pod
+++ b/src/guestfs.pod
@@ -1429,13 +1429,23 @@ note below.
=item C<libvirt>
+=item C<libvirt:null>
+
=item C<libvirt:I<URI>>
Use libvirt to launch and manage the appliance.
-The optional I<URI> is the libvirt connection URI to use (see
-L<http://libvirt.org/uri.html>). The typical libvirt backend
-with a URI would be C<libvirt:qemu:///session>
+C<libvirt> causes libguestfs to choose a suitable URI for creating
+session guests. If using the libvirt backend, you almost always
+should use this.
+
+C<libvirt:null> causes libguestfs to use the C<NULL> connection URI,
+which causes libvirt to try to guess what the user meant. You
+probably don't want to use this.
+
+C<libvirt:I<URI>> uses I<URI> as the libvirt connection URI (see
+L<http://libvirt.org/uri.html>). The typical libvirt backend with a
+URI would be C<libvirt:qemu:///session>
The libvirt backend supports more features, including
hotplugging (see L</HOTPLUGGING>) and sVirt.
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index 36e3df0..984c5aa 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -216,6 +216,16 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
if (g->verbose)
guestfs___print_timestamped_message (g, "connect to libvirt");
+ /* Decode the URI string. */
+ if (!libvirt_uri) { /* "libvirt" */
+ if (!params.current_proc_is_root)
+ libvirt_uri = "qemu:///session";
+ else
+ libvirt_uri = "qemu:///system";
+ } else if (STREQ (libvirt_uri, "null")) { /* libvirt:null */
+ libvirt_uri = NULL;
+ } /* else nothing */
+
/* Connect to libvirt, get capabilities. */
conn = guestfs___open_libvirt_connection (g, libvirt_uri, 0);
if (!conn) {
--
1.8.3.1
11 years