[PATCH v2] launch: add support for autodetection of appliance image format
by Pavel Butsykin
This feature allows you to use different image formats for the fixed
appliance. The raw format is used by default.
Signed-off-by: Pavel Butsykin <pbutsykin(a)virtuozzo.com>
---
lib/launch-direct.c | 2 ++
lib/launch-libvirt.c | 19 ++++++++++++-------
m4/guestfs_appliance.m4 | 11 +++++++++++
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/lib/launch-direct.c b/lib/launch-direct.c
index 0be662e25..b9b54857a 100644
--- a/lib/launch-direct.c
+++ b/lib/launch-direct.c
@@ -592,7 +592,9 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
append_list ("id=appliance");
append_list ("cache=unsafe");
append_list ("if=none");
+#ifndef APPLIANCE_FMT_AUTO
append_list ("format=raw");
+#endif
} end_list ();
start_list ("-device") {
append_list ("scsi-hd");
diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c
index 4adb2cfb3..030ea6911 100644
--- a/lib/launch-libvirt.c
+++ b/lib/launch-libvirt.c
@@ -212,9 +212,10 @@ get_source_format_or_autodetect (guestfs_h *g, struct drive *drv)
/**
* Create a qcow2 format overlay, with the given C<backing_drive>
- * (file). The C<format> parameter, which must be non-NULL, is the
- * backing file format. This is used to create the appliance overlay,
- * and also for read-only drives.
+ * (file). The C<format> parameter is the backing file format.
+ * The C<format> parameter can be NULL, in this case the backing
+ * format will be determined automatically. This is used to create
+ * the appliance overlay, and also for read-only drives.
*/
static char *
make_qcow2_overlay (guestfs_h *g, const char *backing_drive,
@@ -223,8 +224,6 @@ make_qcow2_overlay (guestfs_h *g, const char *backing_drive,
char *overlay;
struct guestfs_disk_create_argv optargs;
- assert (format != NULL);
-
if (guestfs_int_lazy_make_tmpdir (g) == -1)
return NULL;
@@ -232,8 +231,10 @@ make_qcow2_overlay (guestfs_h *g, const char *backing_drive,
optargs.bitmask = GUESTFS_DISK_CREATE_BACKINGFILE_BITMASK;
optargs.backingfile = backing_drive;
- optargs.bitmask |= GUESTFS_DISK_CREATE_BACKINGFORMAT_BITMASK;
- optargs.backingformat = format;
+ if (format) {
+ optargs.bitmask |= GUESTFS_DISK_CREATE_BACKINGFORMAT_BITMASK;
+ optargs.backingformat = format;
+ }
if (guestfs_disk_create_argv (g, overlay, "qcow2", -1, &optargs) == -1) {
free (overlay);
@@ -461,7 +462,11 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
/* Note that appliance can be NULL if using the old-style appliance. */
if (appliance) {
+#ifdef APPLIANCE_FMT_AUTO
+ params.appliance_overlay = make_qcow2_overlay (g, appliance, NULL);
+#else
params.appliance_overlay = make_qcow2_overlay (g, appliance, "raw");
+#endif
if (!params.appliance_overlay)
goto cleanup;
}
diff --git a/m4/guestfs_appliance.m4 b/m4/guestfs_appliance.m4
index 81c43879f..4e1ec8135 100644
--- a/m4/guestfs_appliance.m4
+++ b/m4/guestfs_appliance.m4
@@ -139,3 +139,14 @@ AC_SUBST([GUESTFS_DEFAULT_PATH])
AC_DEFINE_UNQUOTED([GUESTFS_DEFAULT_PATH], ["$GUESTFS_DEFAULT_PATH"],
[Define guestfs default path.])
+
+AC_ARG_ENABLE([appliance-fmt-auto],
+ [AS_HELP_STRING([--enable-appliance-fmt-auto],
+ [enable autodetection of appliance image format @<:@default=no@:>@])],
+ [ENABLE_APPLIANCE_FMT_AUTO="$enableval"],
+ [ENABLE_APPLIANCE_FMT_AUTO=no])
+
+if test "x$ENABLE_APPLIANCE_FMT_AUTO" = "xyes"; then
+ AC_DEFINE([APPLIANCE_FMT_AUTO], [1],
+ [Define to 1 if enabled autodetection of appliance image format.])
+fi
--
2.13.0
4 years, 10 months
[PATCH v2 0/2] lib: Allow db_dump package to be a weak dependency
by Richard W.M. Jones
Previously posted:
https://www.redhat.com/archives/libguestfs/2017-October/msg00032.html
This takes a completely different approach. It turns out that POSIX /
the shell already defines a special exit code 127 for ‘command not
found’. We can make a small adjustment to lib/command.c to return
this exit code in that case.
Then we just have to modify the db_dump code to test for this exit
code.
I also made db_dump unconditional, allowing the packager to either
build without db_dump present at all, and/or to make db_dump into a
weak runtime dependency which will be silently ignored if not present
by the mechanism above.
Rich.
7 years, 1 month
[PATCH v11 0/8] virt-builder-repository
by Cédric Bosdonnat
Hi all,
Here is the latest version of the series.
Diffs to v10:
* Make Index.arch a (string, string option) maybe and use it
to guess arch at parse time
* Compute the image size at parse time when the template flag
is set and the value is missing.
* Add virt-repository_main slow test
* Other fixes from Richard's comments
Cédric Bosdonnat (7):
Ignore builder/*.out and *.img files
builder: change arch type to (string, string option) maybe.
builder: add Utils.get_image_infos function
builder: add a template parameter to get_index
builder: add Index.write_entry function
mllib: add XPath helper xpath_get_nodes
New tool: virt-builder-repository
Pino Toscano (1):
builder: add simple OCaml osinfo-db reader
.gitignore | 8 +
builder/Makefile.am | 129 ++++++-
builder/builder.ml | 9 +-
builder/cache.ml | 10 +
builder/cache.mli | 6 +-
builder/downloader.mli | 2 +-
builder/index.ml | 13 +-
builder/index.mli | 10 +-
builder/index_parser.ml | 94 ++++-
builder/index_parser.mli | 9 +-
builder/index_parser_tests.ml | 130 +++++++
builder/list_entries.ml | 16 +-
builder/osinfo.ml | 76 ++++
builder/osinfo.mli | 22 ++
builder/repository_main.ml | 607 ++++++++++++++++++++++++++++++++
builder/simplestreams_parser.ml | 2 +-
builder/test-docs.sh | 2 +
builder/test-virt-builder-repository.sh | 98 ++++++
builder/utils.ml | 10 +
builder/utils.mli | 7 +
builder/virt-builder-repository.pod | 213 +++++++++++
builder/virt-builder.pod | 4 +
common/mltools/xpath_helpers.ml | 9 +
common/mltools/xpath_helpers.mli | 4 +
fish/guestfish.pod | 1 +
installcheck.sh.in | 1 +
lib/guestfs.pod | 1 +
v2v/output_libvirt.ml | 11 +-
v2v/test-harness/v2v_test_harness.ml | 51 +--
29 files changed, 1481 insertions(+), 74 deletions(-)
create mode 100644 builder/index_parser_tests.ml
create mode 100644 builder/osinfo.ml
create mode 100644 builder/osinfo.mli
create mode 100644 builder/repository_main.ml
create mode 100755 builder/test-virt-builder-repository.sh
create mode 100644 builder/virt-builder-repository.pod
--
2.13.2
7 years, 1 month
[PATCH] builder: ignore spaces after repo identifiers (RHBZ#1506511)
by Pino Toscano
---
builder/index-scan.l | 5 +++--
builder/test-virt-index-validate-good-4 | 3 +++
builder/test-virt-index-validate.sh | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)
create mode 100644 builder/test-virt-index-validate-good-4
diff --git a/builder/index-scan.l b/builder/index-scan.l
index bdb474b33..49dad72bc 100644
--- a/builder/index-scan.l
+++ b/builder/index-scan.l
@@ -78,8 +78,9 @@ extern void scanner_destroy (yyscan_t scanner);
^\n { return EMPTY_LINE; }
/* [...] marks beginning of a section. */
-^"["[-A-Za-z0-9._]+"]"\n {
- yylval->str = strndup (yytext+1, yyleng-3);
+^"["[-A-Za-z0-9._]+"]"[[:blank:]]*\n {
+ const char *end = strrchr (yytext, ']');
+ yylval->str = strndup (yytext+1, end-yytext-1);
return SECTION_HEADER;
}
diff --git a/builder/test-virt-index-validate-good-4 b/builder/test-virt-index-validate-good-4
new file mode 100644
index 000000000..8e8d1065b
--- /dev/null
+++ b/builder/test-virt-index-validate-good-4
@@ -0,0 +1,3 @@
+# Empty spaces after the repository identifier
+[foo]
+key=value
diff --git a/builder/test-virt-index-validate.sh b/builder/test-virt-index-validate.sh
index b00a086b0..851285a1e 100755
--- a/builder/test-virt-index-validate.sh
+++ b/builder/test-virt-index-validate.sh
@@ -23,3 +23,4 @@ set -e
$VG virt-index-validate test-virt-index-validate-good-1
$VG virt-index-validate test-virt-index-validate-good-2
$VG virt-index-validate test-virt-index-validate-good-3
+$VG virt-index-validate test-virt-index-validate-good-4
--
2.13.6
7 years, 1 month
[PATCH] rescue: initialize CLEANUP pointer variable
by Pino Toscano
This way it will not try to free uninitialized memory when going out of
scope, and the inspector mode is not enabled.
Fixes commit 3637c42f4e521eb647d7dfae7f48eb1689d0af54.
---
rescue/escape.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rescue/escape.c b/rescue/escape.c
index 3bb69578b..a6af99ae1 100644
--- a/rescue/escape.c
+++ b/rescue/escape.c
@@ -236,7 +236,7 @@ print_help (void)
static void
print_inspector (void)
{
- CLEANUP_FREE_STRING_LIST char **roots;
+ CLEANUP_FREE_STRING_LIST char **roots = NULL;
size_t i;
const char *root;
char *str;
--
2.13.6
7 years, 2 months
[PATCH] rescue: fix size check
by Pino Toscano
Compare it to the right variable, not to the pointer itself.
Fixes commit 3637c42f4e521eb647d7dfae7f48eb1689d0af54.
---
rescue/escape.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rescue/escape.c b/rescue/escape.c
index a7949972a..3bb69578b 100644
--- a/rescue/escape.c
+++ b/rescue/escape.c
@@ -49,7 +49,7 @@ parse_escape_key (const char *arg)
return 0;
len = strlen (arg);
- if (arg == 0)
+ if (len == 0)
return -1;
switch (arg[0]) {
--
2.13.6
7 years, 2 months