[PATCH] Add internal documentation to C files.
by Richard W.M. Jones
As in libvirt, allow internal documentation comments in C files.
These are marked using '/**' comments. Unlike libvirt which has an
ill-defined and inconsistent markup, the markup we use is Perl POD.
These comments are added to guestfs-internals(1), but are most likely
to be read in-place.
This commit changes some existing comments in src/launch.c to
demonstrate how this can be used.
---
.gitignore | 1 +
docs/Makefile.am | 15 ++-
docs/guestfs-internals.pod | 9 ++
docs/make-internal-documentation.pl | 234 ++++++++++++++++++++++++++++++++++++
po/POTFILES | 1 +
src/launch.c | 70 +++++++----
6 files changed, 305 insertions(+), 25 deletions(-)
create mode 100755 docs/make-internal-documentation.pl
diff --git a/.gitignore b/.gitignore
index ca4e89c..ff5f2de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -153,6 +153,7 @@ Makefile.in
/docs/guestfs-release-notes.1
/docs/guestfs-security.1
/docs/guestfs-testing.1
+/docs/internal-documentation.pod
/docs/stamp-guestfs-building.pod
/docs/stamp-guestfs-faq.pod
/docs/stamp-guestfs-hacking.pod
diff --git a/docs/Makefile.am b/docs/Makefile.am
index f880e72..f765966 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -27,6 +27,7 @@ EXTRA_DIST = \
guestfs-release-notes.pod \
guestfs-security.pod \
guestfs-testing.pod \
+ make-internal-documentation.pl \
README
CLEANFILES = \
@@ -39,6 +40,7 @@ CLEANFILES = \
guestfs-release-notes.1 \
guestfs-security.1 \
guestfs-testing.1 \
+ internal-documentation.pod \
stamp-guestfs-building.pod \
stamp-guestfs-faq.pod \
stamp-guestfs-hacking.pod \
@@ -105,15 +107,26 @@ stamp-guestfs-hacking.pod: guestfs-hacking.pod
guestfs-internals.1 $(top_builddir)/website/guestfs-internals.1.html: stamp-guestfs-internals.pod
-stamp-guestfs-internals.pod: guestfs-internals.pod
+stamp-guestfs-internals.pod: guestfs-internals.pod internal-documentation.pod
$(PODWRAPPER) \
--section 1 \
--man guestfs-internals.1 \
--html $(top_builddir)/website/guestfs-internals.1.html \
+ --insert internal-documentation.pod:__INTERNAL_DOCUMENTATION__ \
--license LGPLv2+ \
$<
touch $@
+source_files := $(shell grep -Ev '^(gobject/|builder/index-scan.c)' $(top_srcdir)/po/POTFILES)
+
+internal-documentation.pod: $(source_files:%=$(top_srcdir)/%)
+ rm -f $@ $@-t
+ ./make-internal-documentation.pl \
+ --srcdir $(top_srcdir) \
+ -o $@-t \
+ $(source_files)
+ mv $@-t $@
+
guestfs-performance.1 $(top_builddir)/website/guestfs-performance.1.html: stamp-guestfs-performance.pod
stamp-guestfs-performance.pod: guestfs-performance.pod
diff --git a/docs/guestfs-internals.pod b/docs/guestfs-internals.pod
index a554b13..bbb278d 100644
--- a/docs/guestfs-internals.pod
+++ b/docs/guestfs-internals.pod
@@ -397,6 +397,15 @@ on a platform that does support supermin using
L<libguestfs-make-fixed-appliance(1)>, copy it over, and use that
to run libguestfs.
+=head1 INTERNAL DOCUMENTATION
+
+This section documents internal functions inside libguestfs and
+various utilities. It is intended for libguestfs developers only.
+These functions are not publicly exported, and may change or be
+removed at any time.
+
+__INTERNAL_DOCUMENTATION__
+
=head1 SEE ALSO
L<guestfs(3)>,
diff --git a/docs/make-internal-documentation.pl b/docs/make-internal-documentation.pl
new file mode 100755
index 0000000..4edb5bc
--- /dev/null
+++ b/docs/make-internal-documentation.pl
@@ -0,0 +1,234 @@
+#!/usr/bin/env perl
+# Copyright (C) 2016 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.
+
+use warnings;
+use strict;
+
+use Getopt::Long;
+
+=head1 NAME
+
+make-internal-documentation.pl - Generate internal documentation from C files
+
+=head1 SYNOPSIS
+
+ make-internal-documentation.pl --output internal-documentation.pod
+ [C source files ...]
+
+=head1 DESCRIPTION
+
+C<make-internal-documentation.pl> is a script that generates
+L<guestfs-internals(1)/INTERNAL DOCUMENTATION>.
+
+You must specify the name of the output file using the I<-o> or
+I<--output> option, and a list of the C source files in the project.
+
+Internal documentation is added to the C source files using special
+comments which look like this:
+
+ /**
+ * Returns true if C<foo> equals C<bar>.
+ */
+ bool
+ is_equal (const char *foo, const char *bar)
+ ...
+
+The comment is written in POD format (see L<perlpod(1)>). It may be
+on several lines, and be split into paragraphs using blank lines.
+
+The function being documented should appear immediately after the
+special comment, and is also copied into the documentation.
+
+In addition, each C file may have a special comment at the top of the
+file (before any C<#include> lines) which outlines what the file does.
+
+=head1 OPTIONS
+
+=over 4
+
+=cut
+
+my $help;
+
+=item B<--help>
+
+Display brief help.
+
+=cut
+
+my $output;
+
+=item B<-o output.pod>
+
+=item B<--output output.pod>
+
+Set the name of the output file (required).
+
+=cut
+
+my $srcdir = ".";
+
+=item B<--srcdir top_srcdir>
+
+Path to the top source directory. Input filenames are
+located relative to this path.
+
+=back
+
+=cut
+
+# Clean up the program name.
+my $progname = $0;
+$progname =~ s{.*/}{};
+
+# Parse options.
+GetOptions ("help|?" => \$help,
+ "output=s" => \$output,
+ "srcdir=s" => \$srcdir,
+ ) or pod2usage (2);
+pod2usage (1) if $help;
+
+die "$progname: missing -o/--output parameter\n" unless defined $output;
+
+die "$progname: missing argument: make-internal-documentation [C source files ...]\n" unless @ARGV >= 1;
+
+# Only consider input files which
+# - are C source files
+# - exist
+# - contain /** comments.
+
+my @inputs = ();
+my $input;
+my $path;
+foreach $input (@ARGV) {
+ if ($input =~ /\.c$/) {
+ $path = "$srcdir/$input";
+ if (-r $path) {
+ my @cmd = ("grep", "-q", "^/\\*\\*", $path);
+ if (system (@cmd) == 0) {
+ push @inputs, $input
+ }
+ }
+ }
+}
+@inputs = sort @inputs;
+
+open OUTPUT, ">$output" or die "$progname: $output: $!";
+
+foreach $input (@inputs) {
+ $path = "$srcdir/$input";
+
+ print OUTPUT ("=head2 F<$input>\n\n");
+
+ open INPUT, $path or die "$progname: $input: $!";
+
+ # A single special comment seen before any #includes can be used
+ # to outline the purpose of the source file.
+ my $seen_includes = 0;
+ my $lineno = 0;
+
+ while (<INPUT>) {
+ chomp;
+ $lineno++;
+ $seen_includes = 1 if /^#include/;
+
+ if (m{^/\*\*$}) {
+ # Found a special comment. Read the whole comment.
+ my @comment = ();
+ my $found_end = 0;
+ my $start_lineno = $lineno;
+ while (<INPUT>) {
+ chomp;
+ $lineno++;
+
+ if (m{^ \*/$}) {
+ $found_end = 1;
+ last;
+ }
+ elsif (m{^ \* (.*)}) {
+ push @comment, $1;
+ }
+ elsif (m{^ \*$}) {
+ push @comment, "";
+ }
+ else {
+ die "$progname: $input: $lineno: special comment with incorrect format\n";
+ }
+ }
+ die "$progname: $input: $start_lineno: unterminated special comment"
+ unless $found_end;
+
+ unless ($seen_includes) {
+ # If we've not seen the includes yet, then this is the
+ # top of file special comment, so we just write it out.
+ print OUTPUT join("\n", @comment), "\n";
+ print OUTPUT "\n";
+ }
+ else {
+ # Otherwise it's a function description, so now we
+ # need to read in the function definition.
+ my @function = ();
+ $found_end = 0;
+ $start_lineno = $lineno;
+ while (<INPUT>) {
+ chomp;
+ $lineno++;
+
+ if (m/^{/) {
+ $found_end = 1;
+ last;
+ }
+ else {
+ push @function, $_;
+ }
+ }
+
+ die "$progname: $input: $start_lineno: unterminated function definition"
+ unless $found_end;
+
+ # Print the function definition, followed by the comment.
+ print OUTPUT " ", join ("\n ", @function), "\n";
+ print OUTPUT "\n";
+ print OUTPUT join("\n", @comment), "\n";
+ print OUTPUT "\n";
+ }
+ }
+ elsif (m{^/\*\*}) {
+ die "$progname: $input: $lineno: special comment with incorrect format\n";
+ }
+ }
+
+
+ close INPUT;
+}
+
+close OUTPUT or die "$progname: $output: close: $!";
+
+exit 0;
+
+=head1 SEE ALSO
+
+L<perlpod(1)>,
+libguestfs.git/README.
+
+=head1 AUTHOR
+
+Richard W.M. Jones.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2012-2016 Red Hat Inc.
diff --git a/po/POTFILES b/po/POTFILES
index 20a330e..9e4d9cc 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -126,6 +126,7 @@ df/main.c
df/output.c
df/parallel.c
diff/diff.c
+docs/make-internal-documentation.pl
edit/edit.c
erlang/erl-guestfs-proto.c
erlang/erl-guestfs.c
diff --git a/src/launch.c b/src/launch.c
index 7bc9cf9..32f725b 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -16,6 +16,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * This file implements L<guestfs(3)/guestfs_launch>.
+ *
+ * Most of the work is done by the backends (see
+ * L<guestfs(3)/BACKEND>), which are implemented in
+ * F<src/launch-direct.c>, F<src/launch-libvirt.c> etc, so this file
+ * mostly passes calls through to the current backend.
+ */
+
#include <config.h>
#include <stdio.h>
@@ -119,9 +128,11 @@ guestfs_int_launch_send_progress (guestfs_h *g, int perdozen)
}
}
-/* Compute Y - X and return the result in milliseconds.
+/**
+ * Compute C<y - x> and return the result in milliseconds.
+ *
* Approximately the same as this code:
- * http://www.mpp.mpg.de/~huber/util/timevaldiff.c
+ * L<http://www.mpp.mpg.de/~huber/util/timevaldiff.c>
*/
int64_t
guestfs_int_timeval_diff (const struct timeval *x, const struct timeval *y)
@@ -148,7 +159,10 @@ guestfs_impl_get_pid (guestfs_h *g)
return g->backend_ops->get_pid (g, g->backend_data);
}
-/* Maximum number of disks. */
+/**
+ * Returns the maximum number of disks allowed to be added to the
+ * backend (backend dependent).
+ */
int
guestfs_impl_max_disks (guestfs_h *g)
{
@@ -159,8 +173,10 @@ guestfs_impl_max_disks (guestfs_h *g)
return g->backend_ops->max_disks (g, g->backend_data);
}
-/* You had to call this function after launch in versions <= 1.0.70,
- * but it is now a no-op.
+/**
+ * Implementation of L<guestfs(3)/guestfs_wait_ready>. You had to
+ * call this function after launch in versions E<le> 1.0.70, but it is
+ * now an (almost) no-op.
*/
int
guestfs_impl_wait_ready (guestfs_h *g)
@@ -251,25 +267,6 @@ guestfs_impl_config (guestfs_h *g,
return 0;
}
-/* Construct the Linux command line passed to the appliance. This is
- * used by the 'direct' and 'libvirt' backends, and is simply
- * located in this file because it's a convenient place for this
- * common code.
- *
- * The 'appliance_dev' parameter must be the full device name of the
- * appliance disk and must have already been adjusted to take into
- * account virtio-blk or virtio-scsi; eg "/dev/sdb".
- *
- * The 'flags' parameter can contain the following flags logically
- * or'd together (or 0):
- *
- * GUESTFS___APPLIANCE_COMMAND_LINE_IS_TCG: If we are launching a qemu
- * TCG guest (ie. KVM is known to be disabled or unavailable). If you
- * don't know, don't pass this flag.
- *
- * Note that this returns a newly allocated buffer which must be freed
- * by the caller.
- */
#if defined(__powerpc64__)
#define SERIAL_CONSOLE "console=hvc0 console=ttyS0"
#elif defined(__arm__) || defined(__aarch64__)
@@ -284,6 +281,31 @@ guestfs_impl_config (guestfs_h *g,
#define EARLYPRINTK ""
#endif
+/**
+ * Construct the Linux command line passed to the appliance. This is
+ * used by the C<direct> and C<libvirt> backends, and is simply
+ * located in this file because it's a convenient place for this
+ * common code.
+ *
+ * The C<appliance_dev> parameter must be the full device name of the
+ * appliance disk and must have already been adjusted to take into
+ * account virtio-blk or virtio-scsi; eg C</dev/sdb>.
+ *
+ * The C<flags> parameter can contain the following flags logically
+ * or'd together (or 0):
+ *
+ * =over 4
+ *
+ * =item C<GUESTFS___APPLIANCE_COMMAND_LINE_IS_TCG>
+ *
+ * If we are launching a qemu TCG guest (ie. KVM is known to be
+ * disabled or unavailable). If you don't know, don't pass this flag.
+ *
+ * =back
+ *
+ * Note that this function returns a newly allocated buffer which must
+ * be freed by the caller.
+ */
char *
guestfs_int_appliance_command_line (guestfs_h *g, const char *appliance_dev,
int flags)
--
2.7.4
8 years, 8 months
[PATCH] customize/perl_edit-c.c: Don't use internal APIs.
by Richard W.M. Jones
We can now use the Guestfs.c_pointer method to access the underlying
guestfs_h *. So no need to use internal APIs for this.
---
customize/perl_edit-c.c | 12 +++---------
customize/perl_edit.ml | 5 +++--
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/customize/perl_edit-c.c b/customize/perl_edit-c.c
index 753d990..dd92b5a 100644
--- a/customize/perl_edit-c.c
+++ b/customize/perl_edit-c.c
@@ -25,16 +25,10 @@
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
+#include <caml/fail.h>
#include "file-edit.h"
-/**
- * We try to reuse the internals of the OCaml binding (for extracting
- * the guestfs handle, and raising errors); hopefully this should be safe,
- * as long as it's kept internal within the libguestfs sources.
- */
-#include "../ocaml/guestfs-c.h"
-
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
value
@@ -43,12 +37,12 @@ virt_customize_edit_file_perl (value verbosev, value gv, value filev,
{
CAMLparam4 (verbosev, gv, filev, exprv);
int r;
- guestfs_h *g = Guestfs_val (gv);
+ guestfs_h *g = (guestfs_h *) Int64_val (gv);
r = edit_file_perl (g, String_val (filev), String_val (exprv), NULL,
Bool_val (verbosev));
if (r == -1)
- guestfs_int_ocaml_raise_error (g, "edit_file_perl");
+ caml_failwith (guestfs_last_error (g) ? : "edit_file_perl: unknown error");
CAMLreturn (Val_unit);
}
diff --git a/customize/perl_edit.ml b/customize/perl_edit.ml
index f1f06cc..992a001 100644
--- a/customize/perl_edit.ml
+++ b/customize/perl_edit.ml
@@ -18,6 +18,7 @@
open Common_utils
-external c_edit_file : verbose:bool -> Guestfs.t -> string -> string -> unit
+external c_edit_file : verbose:bool -> int64 -> string -> string -> unit
= "virt_customize_edit_file_perl"
-let edit_file g file expr = c_edit_file (verbose ()) g file expr
+let edit_file g file expr =
+ c_edit_file (verbose ()) (Guestfs.c_pointer g) file expr
--
2.7.4
8 years, 8 months
[PATCH v5 0/5] New API: filesystem_walk
by Matteo Cafasso
v5:
- fixed compile-time warning
- removed unused flag enumeration
- new version 1.33.19
Patch ready for review.
Matteo Cafasso (5):
generator: Added tsk_dirent struct
configure: Added libtsk compile-time check
New API: internal_filesystem_walk
New API: filesystem_walk
lib: Added filesystem_walk command tests
daemon/Makefile.am | 4 +-
daemon/tsk.c | 226 ++++++++++++++++++++++++++++++++++++++
docs/guestfs-building.pod | 4 +
generator/actions.ml | 106 ++++++++++++++++++
generator/structs.ml | 15 ++-
m4/guestfs_daemon.m4 | 8 ++
src/MAX_PROC_NR | 2 +-
src/Makefile.am | 1 +
src/tsk.c | 123 +++++++++++++++++++++
tests/tsk/Makefile.am | 3 +-
tests/tsk/test-filesystem-walk.sh | 64 +++++++++++
11 files changed, 552 insertions(+), 4 deletions(-)
create mode 100644 daemon/tsk.c
create mode 100644 src/tsk.c
create mode 100755 tests/tsk/test-filesystem-walk.sh
--
2.8.0.rc3
8 years, 8 months
[PATCH] RFC: php: support PHP 7
by Pino Toscano
Adapt to the API changes in the newer versions of the Zend framework, in
particular regarding:
- strings handling
- resources handling (used for the guestfs_h pointer)
- iterating in hash maps
- data types for function arguments
Introduce helper macros to reduce greatly the amount of #if's all around
the generated C code.
---
generator/php.ml | 96 +++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 74 insertions(+), 22 deletions(-)
diff --git a/generator/php.ml b/generator/php.ml
index 926ac4f..5f06c0f 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -93,6 +93,32 @@ and generate_php_c () =
static int res_guestfs_h;
+#if ZEND_MODULE_API_NO >= 20151012
+# define GUESTFS_RETURN_STRING(x, duplicate) \\
+ do { if (duplicate) RETURN_STRING(x) else { RETVAL_STRING(x); efree ((char *)x); return; } } while (0)
+# define guestfs_add_assoc_string(arg, key, str, dup) \\
+ add_assoc_string(arg, key, str)
+# define guestfs_add_assoc_stringl(arg, key, str, len, dup) \\
+ add_assoc_stringl(arg, key, str, len)
+# define guestfs_add_next_index_string(retval, val, x) \\
+ add_next_index_string (retval, val)
+# define GUESTFS_ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, resource_type_name, resource_type) \\
+ (rsrc) = (rsrc_type) zend_fetch_resource (Z_RES_P(passed_id), resource_type_name, resource_type)
+typedef size_t guestfs_string_length;
+#else
+# define GUESTFS_RETURN_STRING(x, duplicate) \\
+ RETURN_STRING(x, duplicate)
+# define guestfs_add_assoc_string(arg, key, str, dup) \\
+ add_assoc_string(arg, key, str, dup)
+# define guestfs_add_assoc_stringl(arg, key, str, len, dup) \\
+ add_assoc_stringl(arg, key, str, len, dup)
+# define guestfs_add_next_index_string(retval, val, x) \\
+ add_next_index_string (retval, val, x)
+# define GUESTFS_ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, resource_type_name, resource_type) \\
+ ZEND_FETCH_RESOURCE(rsrc, rsrc_type, &(passed_id), -1, resource_type_name, resource_type)
+typedef int guestfs_string_length;
+#endif
+
/* Convert array to list of strings.
* http://marc.info/?l=pecl-dev&m=112205192100631&w=2
*/
@@ -103,16 +129,28 @@ get_stringlist (zval *val)
HashTable *a;
int n;
HashPosition p;
+#if ZEND_MODULE_API_NO >= 20151012
+ zval *d;
+#else
zval **d;
+#endif
size_t c = 0;
a = Z_ARRVAL_P (val);
n = zend_hash_num_elements (a);
ret = safe_emalloc (n + 1, sizeof (char *), 0);
for (zend_hash_internal_pointer_reset_ex (a, &p);
+#if ZEND_MODULE_API_NO >= 20151012
+ d = zend_hash_get_current_data_ex (a, &p);
+#else
zend_hash_get_current_data_ex (a, (void **) &d, &p) == SUCCESS;
+#endif
zend_hash_move_forward_ex (a, &p)) {
+#if ZEND_MODULE_API_NO >= 20151012
+ zval t = *d;
+#else
zval t = **d;
+#endif
zval_copy_ctor (&t);
convert_to_string (&t);
ret[c] = estrndup (Z_STRVAL(t), Z_STRLEN (t));
@@ -133,8 +171,13 @@ guestfs_efree_stringlist (char **p)
efree (p);
}
+#if ZEND_MODULE_API_NO >= 20151012
+static void
+guestfs_php_handle_dtor (zend_resource *rsrc)
+#else
static void
guestfs_php_handle_dtor (zend_rsrc_list_entry *rsrc TSRMLS_DC)
+#endif
{
guestfs_h *g = (guestfs_h *) rsrc->ptr;
if (g != NULL)
@@ -191,7 +234,11 @@ PHP_FUNCTION (guestfs_create)
guestfs_set_error_handler (g, NULL, NULL);
+#if ZEND_MODULE_API_NO >= 20151012
+ ZVAL_RES(return_value, zend_register_resource(g, res_guestfs_h));
+#else
ZEND_REGISTER_RESOURCE (return_value, g, res_guestfs_h);
+#endif
}
PHP_FUNCTION (guestfs_last_error)
@@ -204,15 +251,15 @@ PHP_FUNCTION (guestfs_last_error)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE (g, guestfs_h *, &z_g, -1, PHP_GUESTFS_HANDLE_RES_NAME,
- res_guestfs_h);
+ GUESTFS_ZEND_FETCH_RESOURCE (g, guestfs_h *, z_g,
+ PHP_GUESTFS_HANDLE_RES_NAME, res_guestfs_h);
if (g == NULL) {
RETURN_FALSE;
}
const char *err = guestfs_last_error (g);
if (err) {
- RETURN_STRING (err, 1);
+ GUESTFS_RETURN_STRING (err, 1);
} else {
RETURN_NULL ();
}
@@ -237,10 +284,10 @@ PHP_FUNCTION (guestfs_last_error)
| BufferIn n
| GUID n ->
pr " char *%s;\n" n;
- pr " int %s_size;\n" n
+ pr " guestfs_string_length %s_size;\n" n
| OptString n ->
pr " char *%s = NULL;\n" n;
- pr " int %s_size;\n" n
+ pr " guestfs_string_length %s_size;\n" n
| StringList n
| DeviceList n
| FilenameList n ->
@@ -270,7 +317,7 @@ PHP_FUNCTION (guestfs_last_error)
| OInt n | OInt64 n -> pr " long optargs_t_%s = -1;\n" n
| OString n ->
pr " char *optargs_t_%s = NULL;\n" n;
- pr " int optargs_t_%s_size = -1;\n" n
+ pr " guestfs_string_length optargs_t_%s_size = -1;\n" n
| OStringList n ->
pr " zval *optargs_t_%s = NULL;\n" n
) optargs
@@ -343,8 +390,8 @@ PHP_FUNCTION (guestfs_last_error)
pr " RETURN_FALSE;\n";
pr " }\n";
pr "\n";
- pr " ZEND_FETCH_RESOURCE (g, guestfs_h *, &z_g, -1, PHP_GUESTFS_HANDLE_RES_NAME,\n";
- pr " res_guestfs_h);\n";
+ pr " GUESTFS_ZEND_FETCH_RESOURCE (g, guestfs_h *, z_g,\n";
+ pr " PHP_GUESTFS_HANDLE_RES_NAME, res_guestfs_h);\n";
pr " if (g == NULL) {\n";
pr " RETURN_FALSE;\n";
pr " }\n";
@@ -499,23 +546,23 @@ PHP_FUNCTION (guestfs_last_error)
| RInt64 _ ->
pr " RETURN_LONG (r);\n"
| RConstString _ ->
- pr " RETURN_STRING (r, 1);\n"
+ pr " GUESTFS_RETURN_STRING (r, 1);\n"
| RConstOptString _ ->
- pr " if (r) { RETURN_STRING (r, 1); }\n";
+ pr " if (r) { GUESTFS_RETURN_STRING (r, 1); }\n";
pr " else { RETURN_NULL (); }\n"
| RString _ ->
pr " char *r_copy = estrdup (r);\n";
pr " free (r);\n";
- pr " RETURN_STRING (r_copy, 0);\n"
+ pr " GUESTFS_RETURN_STRING (r_copy, 0);\n"
| RBufferOut _ ->
pr " char *r_copy = estrndup (r, size);\n";
pr " free (r);\n";
- pr " RETURN_STRING (r_copy, 0);\n"
+ pr " GUESTFS_RETURN_STRING (r_copy, 0);\n"
| RStringList _ ->
pr " size_t c = 0;\n";
pr " array_init (return_value);\n";
pr " for (c = 0; r[c] != NULL; ++c) {\n";
- pr " add_next_index_string (return_value, r[c], 1);\n";
+ pr " guestfs_add_next_index_string (return_value, r[c], 1);\n";
pr " free (r[c]);\n";
pr " }\n";
pr " free (r);\n";
@@ -523,7 +570,7 @@ PHP_FUNCTION (guestfs_last_error)
pr " size_t c = 0;\n";
pr " array_init (return_value);\n";
pr " for (c = 0; r[c] != NULL; c += 2) {\n";
- pr " add_assoc_string (return_value, r[c], r[c+1], 1);\n";
+ pr " guestfs_add_assoc_string (return_value, r[c], r[c+1], 1);\n";
pr " free (r[c]);\n";
pr " free (r[c+1]);\n";
pr " }\n";
@@ -545,18 +592,18 @@ and generate_php_struct_code typ cols =
List.iter (
function
| name, FString ->
- pr " add_assoc_string (return_value, \"%s\", r->%s, 1);\n" name name
+ pr " guestfs_add_assoc_string (return_value, \"%s\", r->%s, 1);\n" name name
| name, FBuffer ->
- pr " add_assoc_stringl (return_value, \"%s\", r->%s, r->%s_len, 1);\n"
+ pr " guestfs_add_assoc_stringl (return_value, \"%s\", r->%s, r->%s_len, 1);\n"
name name name
| name, FUUID ->
- pr " add_assoc_stringl (return_value, \"%s\", r->%s, 32, 1);\n"
+ pr " guestfs_add_assoc_stringl (return_value, \"%s\", r->%s, 32, 1);\n"
name name
| name, (FBytes|FUInt64|FInt64|FInt32|FUInt32) ->
pr " add_assoc_long (return_value, \"%s\", r->%s);\n"
name name
| name, FChar ->
- pr " add_assoc_stringl (return_value, \"%s\", &r->%s, 1, 1);\n"
+ pr " guestfs_add_assoc_stringl (return_value, \"%s\", &r->%s, 1, 1);\n"
name name
| name, FOptPercent ->
pr " add_assoc_double (return_value, \"%s\", r->%s);\n"
@@ -568,25 +615,30 @@ and generate_php_struct_list_code typ cols =
pr " array_init (return_value);\n";
pr " size_t c = 0;\n";
pr " for (c = 0; c < r->len; ++c) {\n";
+ pr "#if ZEND_MODULE_API_NO >= 20151012\n";
+ pr " zval elem;\n";
+ pr " zval *z_elem = &elem;\n";
+ pr "#else\n";
pr " zval *z_elem;\n";
pr " ALLOC_INIT_ZVAL (z_elem);\n";
+ pr "#endif\n";
pr " array_init (z_elem);\n";
List.iter (
function
| name, FString ->
- pr " add_assoc_string (z_elem, \"%s\", r->val[c].%s, 1);\n"
+ pr " guestfs_add_assoc_string (z_elem, \"%s\", r->val[c].%s, 1);\n"
name name
| name, FBuffer ->
- pr " add_assoc_stringl (z_elem, \"%s\", r->val[c].%s, r->val[c].%s_len, 1);\n"
+ pr " guestfs_add_assoc_stringl (z_elem, \"%s\", r->val[c].%s, r->val[c].%s_len, 1);\n"
name name name
| name, FUUID ->
- pr " add_assoc_stringl (z_elem, \"%s\", r->val[c].%s, 32, 1);\n"
+ pr " guestfs_add_assoc_stringl (z_elem, \"%s\", r->val[c].%s, 32, 1);\n"
name name
| name, (FBytes|FUInt64|FInt64|FInt32|FUInt32) ->
pr " add_assoc_long (z_elem, \"%s\", r->val[c].%s);\n"
name name
| name, FChar ->
- pr " add_assoc_stringl (z_elem, \"%s\", &r->val[c].%s, 1, 1);\n"
+ pr " guestfs_add_assoc_stringl (z_elem, \"%s\", &r->val[c].%s, 1, 1);\n"
name name
| name, FOptPercent ->
pr " add_assoc_double (z_elem, \"%s\", r->val[c].%s);\n"
--
2.5.5
8 years, 8 months
[PATCH] fish: improve formatting of help text of generated commands
by Pino Toscano
In the generated description of the guestfish commands, wrap and indent
the help text, so it is a multiline string instead of a very long single
one.
This has no behaviour changes, only makes cmds.c more readable (and
easier to diff when the description of actions change).
---
generator/fish.ml | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/generator/fish.ml b/generator/fish.ml
index 864f65d..646674d 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -71,6 +71,11 @@ let all_functions_commands_and_aliases_sorted =
) (fish_functions_sorted @ fish_commands) [] in
List.sort func_compare all
+let c_quoted_indented ~indent str =
+ let str = c_quote str in
+ let str = replace_str str "\\n" ("\\n\"\n" ^ indent ^ "\"") in
+ str
+
(* Generate a lot of different functions for guestfish. *)
let generate_fish_cmds () =
generate_header CStyle GPLv2plus;
@@ -138,7 +143,7 @@ let generate_fish_cmds () =
pr "struct command_entry %s_cmd_entry = {\n" name;
pr " .name = \"%s\",\n" name2;
- pr " .help = \"%s\",\n" (c_quote text);
+ pr " .help = \"%s\",\n" (c_quoted_indented ~indent:" " text);
pr " .synopsis = NULL,\n";
pr " .run = run_%s\n" name;
pr "};\n";
@@ -200,7 +205,7 @@ Guestfish will prompt for these separately."
pr "struct command_entry %s_cmd_entry = {\n" name;
pr " .name = \"%s\",\n" name2;
- pr " .help = \"%s\",\n" (c_quote text);
+ pr " .help = \"%s\",\n" (c_quoted_indented ~indent:" " text);
pr " .synopsis = \"%s\",\n" (c_quote synopsis);
pr " .run = run_%s\n" name;
pr "};\n";
--
2.5.5
8 years, 8 months
[PATCH] v2v: Reject duplicate -b/-n parameters on the command line (RHBZ#1325825).
by Richard W.M. Jones
---
v2v/Makefile.am | 3 +-
v2v/cmdline.ml | 31 ++++++++++++++------
v2v/cmdline.mli | 16 ++++++++++-
v2v/test-v2v-bad-networks-and-bridges.sh | 49 ++++++++++++++++++++++++++++++++
v2v/v2v.ml | 4 +--
5 files changed, 91 insertions(+), 12 deletions(-)
create mode 100755 v2v/test-v2v-bad-networks-and-bridges.sh
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 4b77ba2..18c2007 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -291,7 +291,8 @@ TESTS = \
test-v2v-i-ova-formats.sh \
test-v2v-i-ova-gz.sh \
test-v2v-i-ova-two-disks.sh \
- test-v2v-copy-to-local.sh
+ test-v2v-copy-to-local.sh \
+ test-v2v-bad-networks-and-bridges.sh
if HAVE_OCAML_PKG_OUNIT
TESTS += v2v_unit_tests
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 35d18b6..befd8a0 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -26,12 +26,18 @@ open Common_utils
open Types
open Utils
+module NetTypeAndName = struct
+ type t = Types.vnet_type * string option
+ let compare = Pervasives.compare
+end
+module NetworkMap = Map.Make (NetTypeAndName)
+
type cmdline = {
compressed : bool;
debug_overlays : bool;
do_copy : bool;
in_place : bool;
- network_map : ((vnet_type * string) * string) list;
+ network_map : string NetworkMap.t;
no_trim : string list;
output_alloc : output_allocation;
output_format : string option;
@@ -81,16 +87,25 @@ let parse_cmdline () =
error (f_"unknown -i option: %s") s
in
- let network_map = ref [] in
+ let network_map = ref NetworkMap.empty in
let add_network, add_bridge =
- let add t str =
+ let add flag name t str =
match String.split ":" str with
- | "", "" -> error (f_"invalid --bridge or --network parameter")
- | out, "" | "", out -> network_map := ((t, ""), out) :: !network_map
- | in_, out -> network_map := ((t, in_), out) :: !network_map
+ | "", "" ->
+ error (f_"invalid %s parameter") flag
+ | out, "" | "", out ->
+ let key = t, None in
+ if NetworkMap.mem key !network_map then
+ error (f_"duplicate %s parameter. Only one default mapping is allowed.") flag;
+ network_map := NetworkMap.add key out !network_map
+ | in_, out ->
+ let key = t, Some in_ in
+ if NetworkMap.mem key !network_map then
+ error (f_"duplicate %s parameter. Duplicate mappings specified for %s '%s'.") flag name in_;
+ network_map := NetworkMap.add key out !network_map
in
- let add_network str = add Network str
- and add_bridge str = add Bridge str in
+ let add_network str = add "-n/--network" (s_"network") Network str
+ and add_bridge str = add "-b/--bridge" (s_"bridge") Bridge str in
add_network, add_bridge
in
diff --git a/v2v/cmdline.mli b/v2v/cmdline.mli
index 8a37686..5d5b39c 100644
--- a/v2v/cmdline.mli
+++ b/v2v/cmdline.mli
@@ -18,12 +18,26 @@
(** Command line argument parsing. *)
+module NetTypeAndName : sig
+ type t = Types.vnet_type * string option
+ (** To find the mapping for a specific named network or bridge, use
+ the key [(Network|Bridge, Some name)]. To find the default mapping
+ use [(Network|Bridge, None)]. *)
+ val compare : t -> t -> int
+end
+module NetworkMap : sig
+ type key = NetTypeAndName.t
+ type 'a t = 'a Map.Make(NetTypeAndName).t
+ val mem : key -> 'a t -> bool
+ val find : key -> 'a t -> 'a
+end
+
type cmdline = {
compressed : bool;
debug_overlays : bool;
do_copy : bool;
in_place : bool;
- network_map : ((Types.vnet_type * string) * string) list;
+ network_map : string NetworkMap.t;
no_trim : string list;
output_alloc : Types.output_allocation;
output_format : string option;
diff --git a/v2v/test-v2v-bad-networks-and-bridges.sh b/v2v/test-v2v-bad-networks-and-bridges.sh
new file mode 100755
index 0000000..f336620
--- /dev/null
+++ b/v2v/test-v2v-bad-networks-and-bridges.sh
@@ -0,0 +1,49 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2016 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 detection of duplicate --network and --bridge parameters.
+
+unset CDPATH
+export LANG=C
+set -e
+set -x
+
+if [ -n "$SKIP_TEST_V2V_BAD_NETWORKS_AND_BRIDGES_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+# We expect all of these to print an error. NB LANG=C above.
+
+virt-v2v -i disk -b b1 -b b1 |& grep "duplicate -b"
+virt-v2v -i disk -n n1 -n n1 |& grep "duplicate -n"
+virt-v2v -i disk -b b1 -n b1 -b b1 |& grep "duplicate -b"
+virt-v2v -i disk -b b1 -n b1 -n b2 |& grep "duplicate -n"
+
+virt-v2v -i disk -b b1:r1 -b b1:r2 |& grep "duplicate -b"
+virt-v2v -i disk -n n1:r1 -n n1:r2 |& grep "duplicate -n"
+
+# The -b and -n parameters are OK in these tests, but because we
+# didn't specify a disk image name on the command line it will give
+# a different error.
+
+virt-v2v -i disk |& grep "expecting a disk image"
+virt-v2v -i disk -b b1 |& grep "expecting a disk image"
+virt-v2v -i disk -n n1 |& grep "expecting a disk image"
+virt-v2v -i disk -b b1 -n n1 |& grep "expecting a disk image"
+virt-v2v -i disk -b b1:r1 -b b2 -n n1:r1 -n n2 |& grep "expecting a disk image"
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index f0c118e..4d0d525 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -189,12 +189,12 @@ and amend_source cmdline source =
(* Look for a --network or --bridge parameter which names this
* network/bridge (eg. --network in:out).
*)
- let new_name = List.assoc (t, vnet) cmdline.network_map in
+ let new_name = NetworkMap.find (t, Some vnet) cmdline.network_map in
{ nic with s_vnet = new_name }
with Not_found ->
try
(* Not found, so look for a default mapping (eg. --network out). *)
- let new_name = List.assoc (t, "") cmdline.network_map in
+ let new_name = NetworkMap.find (t, None) cmdline.network_map in
{ nic with s_vnet = new_name }
with Not_found ->
(* Not found, so return the original NIC unchanged. *)
--
2.7.4
8 years, 8 months
Help: Is it possible to use libguestfs in Xen guest OS
by Baochuan Wu
Hi All,
I installed CentOS 7 as Xen Guest OS(DomU OS), I wonder if it is possible
to use libguestfs in this CentOS 7 VM? libguestfs-test-tools reports error:
*-bash-4.2# libguestfs-test-tool *
************************************************************
* IMPORTANT NOTICE
*
* When reporting bugs, include the COMPLETE, UNEDITED
* output below in your bug report.
*
************************************************************
LIBGUESTFS_BACKEND=libvirt
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/opt/vpxxcm/conversion
SELinux: sh: getenforce: command not found
guestfs_get_append: (null)
guestfs_get_autosync: 1
guestfs_get_backend: libvirt
guestfs_get_backend_settings: []
guestfs_get_cachedir: /var/tmp
guestfs_get_direct: 0
guestfs_get_hv: /usr/libexec/qemu-kvm
guestfs_get_memsize: 500
guestfs_get_network: 0
guestfs_get_path: /usr/lib64/guestfs
guestfs_get_pgroup: 0
guestfs_get_program: libguestfs-test-tool
guestfs_get_recovery_proc: 1
guestfs_get_selinux: 0
guestfs_get_smp: 1
guestfs_get_tmpdir: /tmp
guestfs_get_trace: 0
guestfs_get_verbose: 1
host_cpu: x86_64
Launching appliance, timeout set to 600 seconds.
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.28.1rhel=7,release=1.55.el7.centos.2,libvirt
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=libvirt
libguestfs: launch: tmpdir=/tmp/libguestfsqw6Xky
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: libvirt version = 1002017 (1.2.17)
libguestfs: guest random name = guestfs-eln5avlfeu8xgpd8
libguestfs: [00000ms] connect to libvirt
libguestfs: opening libvirt handle: URI = qemu:///system, auth =
default+wrapper, flags = 0
libguestfs: successfully opened libvirt handle: conn = 0x7f08e0053d80
libguestfs: qemu version (reported by libvirt) = 1005003 (1.5.3)
libguestfs: [00001ms] get libvirt capabilities
libguestfs: [00002ms] parsing capabilities XML
libguestfs: [00003ms] build appliance
libguestfs: [00003ms] begin building supermin appliance
libguestfs: [00003ms] run supermin
libguestfs: command: run: /usr/bin/supermin5
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
supermin: version: 5.1.10
supermin: rpm: detected RPM version 4.11
supermin: package handler: fedora/rpm
supermin: acquiring lock on /var/tmp/.guestfs-0/lock
supermin: if-newer: output does not need rebuilding
libguestfs: [00011ms] finished building supermin appliance
libguestfs: command: run: qemu-img
libguestfs: command: run: \ create
libguestfs: command: run: \ -f qcow2
libguestfs: command: run: \ -o
backing_file=/var/tmp/.guestfs-0/appliance.d/root,backing_fmt=raw
libguestfs: command: run: \ /tmp/libguestfsqw6Xky/overlay2
Formatting '/tmp/libguestfsqw6Xky/overlay2', fmt=qcow2 size=4294967296
backing_file='/var/tmp/.guestfs-0/appliance.d/root' backing_fmt='raw'
encryption=off cluster_size=65536 lazy_refcounts=off
libguestfs: set_socket_create_context: context_new failed: kernel: Invalid
argument [you can ignore this UNLESS using SELinux + sVirt]
libguestfs: [00031ms] create libvirt XML
libguestfs: command: run: dmesg | grep -Eoh 'lpj=[[:digit:]]+'
libguestfs: read_lpj_from_dmesg: calculated lpj=2200086
libguestfs: libvirt XML:\n<?xml version="1.0"?>\n<domain type="qemu"
xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">\n
<name>guestfs-eln5avlfeu8xgpd8</name>\n <memory unit="MiB">500</memory>\n
<currentMemory unit="MiB">500</currentMemory>\n <vcpu>1</vcpu>\n <clock
offset="utc">\n <timer name="rtc" tickpolicy="catchup"/>\n <timer
name="pit" tickpolicy="delay"/>\n <timer name="hpet" present="no"/>\n
</clock>\n <os>\n <type>hvm</type>\n
<kernel>/var/tmp/.guestfs-0/appliance.d/kernel</kernel>\n
<initrd>/var/tmp/.guestfs-0/appliance.d/initrd</initrd>\n
<cmdline>panic=1 console=ttyS0 udevtimeout=6000 udev.event-timeout=6000
no_timer_check lpj=2200086 acpi=off printk.time=1 cgroup_disable=memory
root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm</cmdline>\n <bios
useserial="yes"/>\n </os>\n <on_reboot>destroy</on_reboot>\n <devices>\n
<controller type="scsi" index="0" model="virtio-scsi"/>\n <disk
device="disk" type="file">\n <source
file="/tmp/libguestfsqw6Xky/scratch.1"/>\n <target dev="sda"
bus="scsi"/>\n <driver name="qemu" type="raw" cache="unsafe"/>\n
<address type="drive" controller="0" bus="0" target="0" unit="0"/>\n
</disk>\n <disk type="file" device="disk">\n <source
file="/tmp/libguestfsqw6Xky/overlay2"/>\n <target dev="sdb"
bus="scsi"/>\n <driver name="qemu" type="qcow2" cache="unsafe"/>\n
<address type="drive" controller="0" bus="0" target="1" unit="0"/>\n
<shareable/>\n </disk>\n <serial type="unix">\n <source
mode="connect" path="/tmp/libguestfsqw6Xky/console.sock"/>\n <target
port="0"/>\n </serial>\n <channel type="unix">\n <source
mode="connect" path="/tmp/libguestfsqw6Xky/guestfsd.sock"/>\n <target
type="virtio" name="org.libguestfs.channel.0"/>\n </channel>\n
</devices>\n <qemu:commandline>\n <qemu:env name="TMPDIR"
value="/var/tmp"/>\n </qemu:commandline>\n</domain>\n
libguestfs: command: run: ls
libguestfs: command: run: \ -a
libguestfs: command: run: \ -l
libguestfs: command: run: \ -Z /var/tmp/.guestfs-0
libguestfs: drwxr-xr-x root root ? .
libguestfs: drwxrwxrwt root root ? ..
libguestfs: drwxr-xr-x root root ?
appliance.d
libguestfs: -rw-r--r-- root root ? lock
libguestfs: command: run: ls
libguestfs: command: run: \ -a
libguestfs: command: run: \ -l
libguestfs: command: run: \ -Z /tmp/libguestfsqw6Xky
libguestfs: drwxr-xr-x root root ? .
libguestfs: drwxrwxrwt root root ? ..
libguestfs: srw-rw---- root qemu ?
console.sock
libguestfs: srw-rw---- root qemu ?
guestfsd.sock
libguestfs: -rw-r--r-- root root ? overlay2
libguestfs: -rw-r--r-- root root ? scratch.1
libguestfs: -rwxr-xr-x root root ?
umask-check
libguestfs: [00041ms] launch libvirt guest
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: Cannot set up guest memory 'pc.ram': Cannot allocate
memory
[code=1 domain=10]
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x7f08e0053620 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsqw6Xky
*-bash-4.2# export LIBGUESTFS_BACKEND=direct*
*-bash-4.2# libguestfs-test-tool *
************************************************************
* IMPORTANT NOTICE
*
* When reporting bugs, include the COMPLETE, UNEDITED
* output below in your bug report.
*
************************************************************
LIBGUESTFS_BACKEND=direct
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/opt/vpxxcm/conversion
SELinux: sh: getenforce: command not found
guestfs_get_append: (null)
guestfs_get_autosync: 1
guestfs_get_backend: direct
guestfs_get_backend_settings: []
guestfs_get_cachedir: /var/tmp
guestfs_get_direct: 0
guestfs_get_hv: /usr/libexec/qemu-kvm
guestfs_get_memsize: 500
guestfs_get_network: 0
guestfs_get_path: /usr/lib64/guestfs
guestfs_get_pgroup: 0
guestfs_get_program: libguestfs-test-tool
guestfs_get_recovery_proc: 1
guestfs_get_selinux: 0
guestfs_get_smp: 1
guestfs_get_tmpdir: /tmp
guestfs_get_trace: 0
guestfs_get_verbose: 1
host_cpu: x86_64
Launching appliance, timeout set to 600 seconds.
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.28.1rhel=7,release=1.55.el7.centos.2,libvirt
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=direct
libguestfs: launch: tmpdir=/tmp/libguestfsvt8tnf
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: is_openable: /dev/kvm: No such file or directory
libguestfs: [00000ms] begin building supermin appliance
libguestfs: [00000ms] run supermin
libguestfs: command: run: /usr/bin/supermin5
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
supermin: version: 5.1.10
supermin: rpm: detected RPM version 4.11
supermin: package handler: fedora/rpm
supermin: acquiring lock on /var/tmp/.guestfs-0/lock
supermin: if-newer: output does not need rebuilding
libguestfs: [00013ms] finished building supermin appliance
libguestfs: [00013ms] begin testing qemu features
libguestfs: command: run: /usr/libexec/qemu-kvm
libguestfs: command: run: \ -display none
libguestfs: command: run: \ -help
libguestfs: command: run: /usr/libexec/qemu-kvm
libguestfs: command: run: \ -display none
libguestfs: command: run: \ -version
libguestfs: qemu version 1.5
libguestfs: command: run: /usr/libexec/qemu-kvm
libguestfs: command: run: \ -display none
libguestfs: command: run: \ -machine accel=kvm:tcg
libguestfs: command: run: \ -device ?
libguestfs: [00099ms] finished testing qemu features
libguestfs: command: run: dmesg | grep -Eoh 'lpj=[[:digit:]]+'
libguestfs: read_lpj_from_dmesg: calculated lpj=2200086
[00107ms] /usr/libexec/qemu-kvm \
-global virtio-blk-pci.scsi=off \
-nodefconfig \
-enable-fips \
-nodefaults \
-display none \
-machine accel=kvm:tcg \
-m 500 \
-no-reboot \
-rtc driftfix=slew \
-no-hpet \
-global kvm-pit.lost_tick_policy=discard \
-kernel /var/tmp/.guestfs-0/appliance.d/kernel \
-initrd /var/tmp/.guestfs-0/appliance.d/initrd \
-device virtio-scsi-pci,id=scsi \
-drive
file=/tmp/libguestfsvt8tnf/scratch.1,cache=unsafe,format=raw,id=hd0,if=none
\
-device scsi-hd,drive=hd0 \
-drive
file=/var/tmp/.guestfs-0/appliance.d/root,snapshot=on,id=appliance,cache=unsafe,if=none
\
-device scsi-hd,drive=appliance \
-device virtio-serial-pci \
-serial stdio \
-device sga \
-chardev socket,path=/tmp/libguestfsvt8tnf/guestfsd.sock,id=channel0 \
-device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
-append 'panic=1 console=ttyS0 udevtimeout=6000 udev.event-timeout=6000
no_timer_check lpj=2200086 acpi=off printk.time=1 cgroup_disable=memory
root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm'
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Cannot set up guest memory 'pc.ram': Cannot allocate memory
libguestfs: error: appliance closed the connection unexpectedly, see
earlier error messages
libguestfs: child_cleanup: 0x7fd127b2d620: child process died
libguestfs: sending SIGTERM to process 17471
libguestfs: error: /usr/libexec/qemu-kvm exited with error status 1, see
debug messages above
libguestfs: error: guestfs_launch failed, see earlier error messages
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x7fd127b2d620 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsvt8tnf
-bash-4.2#
After running "*export LIBGUESTFS_BACKEND=direct*", it seems libguestfs
will launch another VM inside my VM. Is this necessary?
Any response is highly appreciated.
Thanks,
Allen
8 years, 8 months
[PATCH v4 0/5] New API: filesystem_walk
by Matteo Cafasso
v4:
- Changed tsk_allocated struct field into tsk_flags.
- Added optional dependency in documentation.
- Use asprintf and perror instead of asprintf_nowarn and fprintf.
- Ensure CLEANUP_FREE vars are initialised.
- Reworked the function documentation.
- Improved tests robustness.
Matteo Cafasso (5):
generator: Added tsk_dirent struct
configure: Added libtsk compile-time check
New API: internal_filesystem_walk
New API: filesystem_walk
lib: Added filesystem_walk command tests
daemon/Makefile.am | 4 +-
daemon/tsk.c | 229 ++++++++++++++++++++++++++++++++++++++
docs/guestfs-building.pod | 4 +
generator/actions.ml | 104 +++++++++++++++++
generator/structs.ml | 15 ++-
m4/guestfs_daemon.m4 | 8 ++
src/MAX_PROC_NR | 2 +-
src/Makefile.am | 1 +
src/tsk.c | 123 ++++++++++++++++++++
tests/tsk/Makefile.am | 3 +-
tests/tsk/test-filesystem-walk.sh | 64 +++++++++++
11 files changed, 553 insertions(+), 4 deletions(-)
create mode 100644 daemon/tsk.c
create mode 100644 src/tsk.c
create mode 100755 tests/tsk/test-filesystem-walk.sh
--
2.8.0.rc3
8 years, 8 months
[PATCH 0/7] Add support for SUSE virtio windows drivers
by Cédric Bosdonnat
Hi there,
SUSE ships Virtual Machine Driver Pack for the virtio windows drivers. Get v2v
and customize to discover them and use them if available.
Cédric Bosdonnat (7):
v2v: check next free oem%d.inf in /Windows/Inf
v2v: extract controller offset discovery as a function
customize: add support for pvvxsvc
v2v: extract reusable parts of viostor regedits
v2v: adapt the subkey in Enum registry to windows version
v2v: quiet virtio net and balloon devices wizards
v2v: add support for SUSE VMDP drivers
builder/virt-builder.pod | 13 +-
customize/firstboot.ml | 169 ++++++++-------
customize/virt-customize.pod | 6 +
sysprep/virt-sysprep.pod | 6 +
v2v/convert_windows.ml | 59 ++++--
v2v/virt-v2v.pod | 6 +
v2v/windows_virtio.ml | 493 +++++++++++++++++++++++++++----------------
7 files changed, 476 insertions(+), 276 deletions(-)
--
2.6.2
8 years, 8 months
[PATCH v3 0/5] Added filesystem_walk command
by Matteo Cafasso
v3:
- File size will be reported as - 1 if it cannot be retrieved.
- Code improvements based on comments.
Matteo Cafasso (5):
generator: Added tsk_dirent struct
configure: Added libtsk compile-time check
daemon: Added internal_filesystem_walk command
appliance: Added filesystem_walk command
appliance: Added filesystem_walk command tests
daemon/Makefile.am | 4 +-
daemon/tsk.c | 233 ++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 78 +++++++++++++
generator/structs.ml | 16 ++-
m4/guestfs_daemon.m4 | 8 ++
src/MAX_PROC_NR | 2 +-
src/Makefile.am | 1 +
src/tsk.c | 123 ++++++++++++++++++++
tests/tsk/Makefile.am | 3 +-
tests/tsk/test-filesystem-walk.sh | 62 ++++++++++
10 files changed, 525 insertions(+), 5 deletions(-)
create mode 100644 daemon/tsk.c
create mode 100644 src/tsk.c
create mode 100755 tests/tsk/test-filesystem-walk.sh
--
2.8.0.rc3
8 years, 8 months