[PATCH] fish: Increase default size of prepared disks (-N) to 1G.
by Richard W.M. Jones
The guestfish prepared disks (-N option) all defaulted to 100M. This
has always been too small for btrfs (so for example ‘-N fs:btrfs’ has
failed for a long time), and can be too small for LVs with new LVM2 /
kernel >= 4.16.
This changes the default from 100M to 1G. The beginning of the 1.39
branch seems like a good time to make this change.
---
fish/guestfish.pod | 14 +++++++-------
generator/prepopts.ml | 28 ++++++++++++++--------------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/fish/guestfish.pod b/fish/guestfish.pod
index bbf43aad5..4f24006b8 100644
--- a/fish/guestfish.pod
+++ b/fish/guestfish.pod
@@ -120,8 +120,8 @@ Create a 100MB disk containing an ext2-formatted partition:
=head2 Start with a prepared disk
-An alternate way to create a 100MB disk called F<test1.img> containing
-a single ext2-formatted partition:
+Create a 1G disk called F<test1.img> containing a single
+ext2-formatted partition:
guestfish -N fs
@@ -1084,10 +1084,10 @@ C<filename=> before the type (see examples below).
The type briefly describes how the disk should be sized, partitioned,
how filesystem(s) should be created, and how content should be added.
Optionally the type can be followed by extra parameters, separated by
-C<:> (colon) characters. For example, I<-N fs> creates a default
-100MB, sparsely-allocated disk, containing a single partition, with
-the partition formatted as ext2. I<-N fs:ext4:1G> is the same, but
-for an ext4 filesystem on a 1GB disk instead.
+C<:> (colon) characters. For example, I<-N fs> creates a default 1G,
+sparsely-allocated disk, containing a single partition, with the
+partition formatted as ext2. I<-N fs:ext4:2G> is the same, but for an
+ext4 filesystem on a 2GB disk instead.
Note that the prepared filesystem is not mounted. You would usually
have to use the C<mount /dev/sda1 /> command or add the
@@ -1098,7 +1098,7 @@ is automatically launched.
=head2 EXAMPLES
-Create a 100MB disk with an ext4-formatted partition, called
+Create a 1G disk with an ext4-formatted partition, called
F<test1.img> in the current directory:
guestfish -N fs:ext4
diff --git a/generator/prepopts.ml b/generator/prepopts.ml
index 5a1ba3d88..a0a1925da 100644
--- a/generator/prepopts.ml
+++ b/generator/prepopts.ml
@@ -27,17 +27,17 @@ type prepopt = string * string * optargs * string
let prepopts = [
("disk",
"create a blank disk",
- [ "size", "100M", "the size of the disk image" ],
- "Create a blank disk, size 100MB (by default).
+ [ "size", "1G", "the size of the disk image" ],
+ "Create a blank disk, size 1G (by default).
The default size can be changed by supplying an optional parameter.");
("part",
"create a partitioned disk",
- [ "size", "100M", "the size of the disk image";
+ [ "size", "1G", "the size of the disk image";
"partition", "mbr", "partition table type" ],
"Create a disk with a single partition. By default the size of the disk
-is 100MB (the available space in the partition will be a tiny bit smaller)
+is 1G (the available space in the partition will be a tiny bit smaller)
and the partition table will be MBR (old DOS-style).
These defaults can be changed by supplying optional parameters.");
@@ -45,10 +45,10 @@ These defaults can be changed by supplying optional parameters.");
("fs",
"create a filesystem",
[ "filesystem", "ext2", "the type of filesystem to use";
- "size", "100M", "the size of the disk image";
+ "size", "1G", "the size of the disk image";
"partition", "mbr", "partition table type" ],
"Create a disk with a single partition, with the partition containing
-an empty filesystem. This defaults to creating a 100MB disk (the available
+an empty filesystem. This defaults to creating a 1G disk (the available
space in the filesystem will be a tiny bit smaller) with an MBR (old
DOS-style) partition table and an ext2 filesystem.
@@ -57,11 +57,11 @@ These defaults can be changed by supplying optional parameters.");
("lv",
"create a disk with logical volume",
[ "name", "/dev/VG/LV", "the name of the VG and LV to use";
- "size", "100M", "the size of the disk image";
+ "size", "1G", "the size of the disk image";
"partition", "mbr", "partition table type" ],
"Create a disk with a single partition, set up the partition as an
LVM2 physical volume, and place a volume group and logical volume
-on there. This defaults to creating a 100MB disk with the VG and
+on there. This defaults to creating a 1G disk with the VG and
LV called C</dev/VG/LV>. You can change the name of the VG and LV
by supplying an alternate name as the first optional parameter.
@@ -71,20 +71,20 @@ Note this does not create a filesystem. Use 'lvfs' to do that.");
"create a disk with logical volume and filesystem",
[ "name", "/dev/VG/LV", "the name of the VG and LV to use";
"filesystem", "ext2", "the type of filesystem to use";
- "size", "100M", "the size of the disk image";
+ "size", "1G", "the size of the disk image";
"partition", "mbr", "partition table type" ],
"Create a disk with a single partition, set up the partition as an
LVM2 physical volume, and place a volume group and logical volume
on there. Then format the LV with a filesystem. This defaults to
-creating a 100MB disk with the VG and LV called C</dev/VG/LV>, with an
+creating a 1G disk with the VG and LV called C</dev/VG/LV>, with an
ext2 filesystem.");
("bootroot",
"create a boot and root filesystem",
[ "bootfs", "ext2", "the type of filesystem to use for boot";
"rootfs", "ext2", "the type of filesystem to use for root";
- "size", "100M", "the size of the disk image";
- "bootsize", "32M", "the size of the boot filesystem";
+ "size", "1G", "the size of the disk image";
+ "bootsize", "128M", "the size of the boot filesystem";
"partition", "mbr", "partition table type" ],
"Create a disk with two partitions, for boot and root filesystem.
Format the two filesystems independently. There are several optional
@@ -95,8 +95,8 @@ parameters which control the exact layout and filesystem types.");
[ "name", "/dev/VG/LV", "the name of the VG and LV for root";
"bootfs", "ext2", "the type of filesystem to use for boot";
"rootfs", "ext2", "the type of filesystem to use for root";
- "size", "100M", "the size of the disk image";
- "bootsize", "32M", "the size of the boot filesystem";
+ "size", "1G", "the size of the disk image";
+ "bootsize", "128M", "the size of the boot filesystem";
"partition", "mbr", "partition table type" ],
"This is the same as C<bootroot> but the root filesystem (only) is
placed on a logical volume, named by default C</dev/VG/LV>. There are
--
2.15.1
6 years, 7 months
[PATCH 0/5] Some improvements in bootstrap, m4 and configure.ac
by Lin Ma
Lin Ma (5):
configure: error out if using libvirt backend and no header files
configure: output the default backend in summary
configure: try pcre-config if pcre pkg-config file not found
configure: output clearer message when missing libmagic
configure: support using local gnulib src directory as $GNULIB_SRCDIR
bootstrap | 78 +++++++++++++++++++++++++++++++++++++++++++++----
configure.ac | 1 +
m4/guestfs-libraries.m4 | 21 ++++++++++---
3 files changed, 91 insertions(+), 9 deletions(-)
--
2.15.1
6 years, 7 months
[PATCH 0/3] daemon: generate almost all the API OCaml interfaces
by Pino Toscano
Hi,
as a followup for the signature fix for mount_vfs [1], here it is a
patch series to generate automatically most of the OCaml interfaces of
daemon actions. Only the Lvm and Mount modules are left with
hand-written interfaces.
[1] https://www.redhat.com/archives/libguestfs/2018-April/msg00059.html
Thanks,
Pino Toscano (3):
daemon: directly use Optgroups
daemon: use the structs from the Structs module
daemon: autogenerate most of OCaml interfaces
.gitignore | 15 ++++++++
daemon/blkid.mli | 19 ----------
daemon/btrfs.mli | 26 --------------
daemon/devsparts.mli | 25 -------------
daemon/file.mli | 19 ----------
daemon/filearch.mli | 19 ----------
daemon/findfs.mli | 20 -----------
daemon/inspect.mli | 41 ---------------------
daemon/inspect_fs_windows.ml | 4 +--
daemon/is.mli | 21 -----------
daemon/ldm.ml | 2 --
daemon/ldm.mli | 22 ------------
daemon/link.mli | 19 ----------
daemon/listfs.ml | 8 ++---
daemon/listfs.mli | 19 ----------
daemon/lvm.ml | 2 --
daemon/lvm.mli | 2 --
daemon/md.mli | 20 -----------
daemon/parted.mli | 34 ------------------
daemon/realpath.mli | 20 -----------
daemon/statvfs.mli | 33 -----------------
generator/daemon.ml | 85 ++++++++++++++++++++++++++++++++++++++++++++
generator/daemon.mli | 1 +
generator/main.ml | 10 ++++++
24 files changed, 117 insertions(+), 369 deletions(-)
delete mode 100644 daemon/blkid.mli
delete mode 100644 daemon/btrfs.mli
delete mode 100644 daemon/devsparts.mli
delete mode 100644 daemon/file.mli
delete mode 100644 daemon/filearch.mli
delete mode 100644 daemon/findfs.mli
delete mode 100644 daemon/inspect.mli
delete mode 100644 daemon/is.mli
delete mode 100644 daemon/ldm.mli
delete mode 100644 daemon/link.mli
delete mode 100644 daemon/listfs.mli
delete mode 100644 daemon/md.mli
delete mode 100644 daemon/parted.mli
delete mode 100644 daemon/realpath.mli
delete mode 100644 daemon/statvfs.mli
--
2.14.3
6 years, 7 months
Re: [Libguestfs] libguestfs.org repo not working
by Richard W.M. Jones
On Sun, Apr 08, 2018 at 12:07:43PM +0200, Francesco Provino wrote:
> Hi Richard,
> it seems that the images repo on libguestfs.org is not working
> properly, the dowload is extremely slow and often fails. It always
> fail with virt-builder. I've tried to download images with several
> tools and from different servers located around the world, but I
> cannot complete a single download.
>
> I don't know if this mail is the right place to report a problem like
> that, please forgive me if I was wrong.
Is it still happening now?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
6 years, 7 months
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
by Eric Blake
In preparation for adding other optional flag arguments to the
python bindings, start by making the existing 'may_trim' flag
to 'zero' be optional. That is, the plugin need not define
the parameter if it does not make any semantic difference (ie.
if the plugin ignores the hint and never trims); while if the
parameter exists, we now pass it as a keyword argument rather
than as a positional argument. This requires the plugin to
give the parameter a specific name, and works whether or not
the plugin provides a default for the parameter (although we do
now recommend that plugins provide a default value, as it makes
plugins built against newer nbdkit more likely to run even on
older nbdkit). We can't see through a plugin that used
'**kwargs', but that is less likely.
If we are super-worried about back-compatibility to older
plugins which hard-coded 4 required parameters, we could also
tweak the introspection to assume that a 'zero' with 4
parameters and no defaults also supports 'may_trim', but pass
it via positional rather than a keyword argument. However, I
suspect most plugins just copied from our examples, which means
they used the right parameter naming to just keep working.
The introspection framework here will also make it easy to
probe for future flag additions.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
At least the plugin for rhv-upload [1] used the right naming:
[1] https://github.com/libguestfs/libguestfs/blob/53b31df7c/v2v/rhv-upload-pl...
plugins/python/nbdkit-python-plugin.pod | 35 +++++++++++----
plugins/python/python.c | 80 +++++++++++++++++++++++++++++++--
plugins/python/example.py | 2 +-
tests/test.py | 2 +-
4 files changed, 105 insertions(+), 14 deletions(-)
diff --git a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod
index c3a564e..19f9eff 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/python/nbdkit-python-plugin.pod
@@ -51,11 +51,24 @@ C<__main__> module):
def pread(h, count, offset):
# see below
-Note that the subroutines must have those literal names (like C<open>),
-because the C part looks up and calls those functions directly. You
-may want to include documentation and globals (eg. for storing global
-state). Any other top level statements are run when the script is
-loaded, just like ordinary Python.
+Note that the functions must have those literal names (like C<open>),
+because the C part looks up and calls those functions directly. Where
+this documentation lists a parameter as mandatory, you can name the
+parameter what you would like (the C part sets that parameter
+positionally); however, where this documentation lists a parameter
+with a default value, you must either omit that parameter or use that
+exact parameter name (the C part inspects the function signature to
+see whether your callback implemented that parameter, and if so, sets
+the parameter via keyword). In this way, newer versions of nbdkit can
+add additional flags with default values that can be useful to newer
+plugins, but still run older plugins without requiring them to be
+rewritten to add support for the new flags. Note that using
+C<**kwargs> in your function instead of named parameters would defeat
+the C code that inspects the signature.
+
+You may want to include documentation and globals (eg. for storing
+global state). Any other top level statements are run when the script
+is loaded, just like ordinary Python.
=head2 EXECUTABLE SCRIPT
@@ -231,13 +244,17 @@ exception, optionally using C<nbdkit.set_error> first.
(Optional)
- def zero(h, count, offset, may_trim):
+ def zero(h, count, offset, may_trim=False):
# no return value
The body of your C<zero> function should ensure that C<count> bytes
-of the disk, starting at C<offset>, will read back as zero. If
-C<may_trim> is true, the operation may be optimized as a trim as long
-as subsequent reads see zeroes.
+of the disk, starting at C<offset>, will read back as zero.
+
+Your function may support an optional C<may_trim> parameter; if it is
+present and the caller sets it to True, then your callback may
+optimize the operation by using a trim, as long as subsequent reads
+see zeroes. If you omit the optional parameter, or if the caller sets
+it to False, writing zeroes should not punch holes.
NBD only supports whole writes, so your function should try to
write the whole region (perhaps requiring a loop). If the write
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 35e8df2..d944905 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -64,6 +64,8 @@ static PyObject *module;
static int last_error;
+static int zero_may_trim = -1;
+
static PyObject *
set_error (PyObject *self, PyObject *args)
{
@@ -108,6 +110,68 @@ callback_defined (const char *name, PyObject **obj_rtn)
return 1;
}
+/* Checks whether a list of strings contains the given name */
+static int
+check_list (PyObject *list, const char *name)
+{
+ ssize_t i = 0;
+ PyObject *elt;
+
+ if (!list)
+ return 0;
+ while ((elt = PyList_GetItem(list, i++))) {
+ char *str = PyString_AsString(elt);
+ if (str && !strcmp(str, name))
+ return 1;
+ }
+ return 0;
+}
+
+/* Does a callback support the given keyword parameter? */
+static int
+callback_has_parameter (PyObject *fn, const char *name)
+{
+ int r = 0;
+ PyObject *inspect, *pname, *spec, *args;
+
+ assert (script != NULL);
+ assert (module != NULL);
+
+ pname = PyString_FromString ("inspect");
+ if (!pname)
+ return -1;
+ inspect = PyImport_Import (pname);
+ Py_DECREF (pname);
+
+ if (!inspect)
+ return -1;
+
+#if PY_MAJOR_VERSION >= 3
+ pname = PyString_FromString ("getfullargspec");
+#else
+ pname = PyString_FromString ("getargspec");
+#endif
+ spec = PyObject_CallMethodObjArgs (inspect, pname, fn, NULL);
+ Py_DECREF (pname);
+ Py_DECREF (inspect);
+ if (!spec)
+ return -1;
+
+ /* Yay, we got the signature; now inspect if it contains keyword 'name' */
+ args = PyTuple_GetItem(spec, 0);
+ if (check_list(args, name))
+ r = 1;
+ else {
+ /* inspecting kwonly args is only available in python 3 */
+ args = PyTuple_GetItem(spec, 5);
+ if (check_list(args, name))
+ r = 1;
+ }
+
+ Py_DECREF (spec);
+ return r;
+}
+
/* Convert bytes/str/unicode into a string. Caller must free. */
static char *
python_to_string (PyObject *str)
@@ -530,21 +594,31 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim)
PyObject *obj = handle;
PyObject *fn;
PyObject *args;
+ PyObject *kwargs = NULL;
PyObject *r;
if (callback_defined ("zero", &fn)) {
+ if (zero_may_trim < 0)
+ zero_may_trim = callback_has_parameter (fn, "may_trim");
+ if (zero_may_trim < 0) {
+ check_python_failure ("zero");
+ return -1;
+ }
+
PyErr_Clear ();
last_error = 0;
- args = PyTuple_New (4);
+ args = PyTuple_New (3);
Py_INCREF (obj); /* decremented by Py_DECREF (args) */
PyTuple_SetItem (args, 0, obj);
PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count));
PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset));
- PyTuple_SetItem (args, 3, PyBool_FromLong (may_trim));
- r = PyObject_CallObject (fn, args);
+ if (zero_may_trim)
+ kwargs = Py_BuildValue("{s:i}", "may_trim", may_trim);
+ r = PyObject_Call (fn, args, kwargs);
Py_DECREF (fn);
Py_DECREF (args);
+ Py_XDECREF (kwargs);
if (last_error == EOPNOTSUPP) {
/* When user requests this particular error, we want to
gracefully fall back, and to accomodate both a normal return
diff --git a/plugins/python/example.py b/plugins/python/example.py
index 60f9d7f..9205f10 100644
--- a/plugins/python/example.py
+++ b/plugins/python/example.py
@@ -65,7 +65,7 @@ def pwrite(h, buf, offset):
disk[offset:end] = buf
-def zero(h, count, offset, may_trim):
+def zero(h, count, offset, may_trim=False):
global disk
if may_trim:
disk[offset:offset+count] = bytearray(count)
diff --git a/tests/test.py b/tests/test.py
index 630ac2f..518cdd4 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -41,7 +41,7 @@ def pwrite(h, buf, offset):
disk[offset:end] = buf
-def zero(h, count, offset, may_trim=False):
+def zero(h, count, offset):
global disk
disk[offset:offset+count] = bytearray(count)
--
2.14.3
6 years, 7 months
[nbdkit PATCH] tests: Skip guestfs tests on CentOS 6
by Eric Blake
CentOS 6 has libguestfs-devel 1.20.11, which predates the support
in guestfs_add_drive_opts() for requesting an nbd drive instead
of a local file. The guestfs plugin can still be built, so no
configure changes are needed; but skip the tests that fail to
compile so that 'make check' can at least complete.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Even with this patch, there are still failures:
/home/dummy/nbdkit/src/nbdkit -U /tmp/nbdkitC8Hm6H/sock -P /tmp/nbdkitC8Hm6H/pid
-f -v /home/dummy/nbdkit/plugins/gzip/.libs/nbdkit-gzip-plugin.so -r file=disk.
gz
nbdkit: debug: TLS disabled: nbdkit was not compiled with GnuTLS support
nbdkit: /home/dummy/nbdkit/plugins/gzip/.libs/nbdkit-gzip-plugin.so: /home/dummy
/nbdkit/plugins/gzip/.libs/nbdkit-gzip-plugin.so: undefined symbol: gzbuffer
test-gzip FAILED: nbdkit exited before starting to serve files
waitpid: No child processes
FAIL: test-gzip
./test-dump-plugin-example4.sh: unexpected output from nbdkit example4 --dump-pl
ugin
path=/home/dummy/nbdkit/plugins/perl/.libs/nbdkit-perl-plugin.so
...
has__zero_old=1
FAIL: test-dump-plugin-example4.sh
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
libguestfs: trace: set_attach_method "appliance"
libguestfs: trace: set_attach_method = 0
libguestfs: create: flags = 0, handle = 0xf8fac0
nbd://?socket=cache.sock: No such file or directory
libguestfs: trace: close
libguestfs: closing guestfs handle 0xf8fac0 (state 0)
./test-cache.sh: line 64: kill: (14315) - No such process
FAIL: test-cache.sh
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
libguestfs: trace: set_attach_method "appliance"
libguestfs: trace: set_attach_method = 0
libguestfs: create: flags = 0, handle = 0xf89ac0
guestfish: -N parameter 'cow-base.img=fs': no such prepared disk image known.
Use 'guestfish -N help' to list possible values for the -N parameter.
libguestfs: trace: close
libguestfs: closing guestfs handle 0xf89ac0 (state 0)
FAIL: test-cow.sh
=======================
4 of 19 tests failed
(21 tests were not run)
=======================
but that's better than not compiling
---
tests/test-connect.c | 5 +++++
tests/test-delay.c | 5 +++++
tests/test-file.c | 5 +++++
tests/test-gzip.c | 5 +++++
tests/test-lang-plugins.c | 5 +++++
tests/test-memory.c | 5 +++++
tests/test-nbd.c | 5 +++++
tests/test-newstyle.c | 5 +++++
tests/test-null.c | 7 +++++++
tests/test-ocaml.c | 5 +++++
tests/test-offset.c | 5 +++++
tests/test-oldstyle.c | 5 +++++
tests/test-partition.c | 5 +++++
tests/test-split.c | 5 +++++
tests/test-streaming.c | 5 +++++
tests/test-xz.c | 5 +++++
16 files changed, 82 insertions(+)
diff --git a/tests/test-connect.c b/tests/test-connect.c
index 32ba79a..06c6163 100644
--- a/tests/test-connect.c
+++ b/tests/test-connect.c
@@ -62,6 +62,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
@@ -70,6 +74,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-delay.c b/tests/test-delay.c
index 47bf380..f037097 100644
--- a/tests/test-delay.c
+++ b/tests/test-delay.c
@@ -63,6 +63,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -70,6 +74,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-file.c b/tests/test-file.c
index 65a2568..6a81b9e 100644
--- a/tests/test-file.c
+++ b/tests/test-file.c
@@ -61,6 +61,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -68,6 +72,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-gzip.c b/tests/test-gzip.c
index 8e9c286..13e243f 100644
--- a/tests/test-gzip.c
+++ b/tests/test-gzip.c
@@ -60,6 +60,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
@@ -68,6 +72,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-lang-plugins.c b/tests/test-lang-plugins.c
index fc3cbef..915256f 100644
--- a/tests/test-lang-plugins.c
+++ b/tests/test-lang-plugins.c
@@ -70,6 +70,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -77,6 +81,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-memory.c b/tests/test-memory.c
index fb2ff2a..281996e 100644
--- a/tests/test-memory.c
+++ b/tests/test-memory.c
@@ -60,6 +60,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -67,6 +71,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-nbd.c b/tests/test-nbd.c
index 646c0c3..22f6424 100644
--- a/tests/test-nbd.c
+++ b/tests/test-nbd.c
@@ -80,6 +80,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -87,6 +91,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-newstyle.c b/tests/test-newstyle.c
index 9835931..b6f193a 100644
--- a/tests/test-newstyle.c
+++ b/tests/test-newstyle.c
@@ -64,6 +64,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
/* Using any exportname causes qemu to use the newstyle protocol. */
r = guestfs_add_drive_opts (g, EXPORTNAME,
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
@@ -72,6 +76,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-null.c b/tests/test-null.c
index d7cf5e5..29ed280 100644
--- a/tests/test-null.c
+++ b/tests/test-null.c
@@ -64,6 +64,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -71,6 +75,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
@@ -93,6 +98,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifdef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -100,6 +106,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-ocaml.c b/tests/test-ocaml.c
index 707c762..5471d06 100644
--- a/tests/test-ocaml.c
+++ b/tests/test-ocaml.c
@@ -70,6 +70,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -77,6 +81,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-offset.c b/tests/test-offset.c
index d47066f..77e2005 100644
--- a/tests/test-offset.c
+++ b/tests/test-offset.c
@@ -89,6 +89,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -96,6 +100,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-oldstyle.c b/tests/test-oldstyle.c
index a9ba01c..0fabdf8 100644
--- a/tests/test-oldstyle.c
+++ b/tests/test-oldstyle.c
@@ -61,6 +61,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
/* Using exportname = "" causes qemu to use the oldstyle protocol. */
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
@@ -69,6 +73,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-partition.c b/tests/test-partition.c
index 0087548..3e27b2c 100644
--- a/tests/test-partition.c
+++ b/tests/test-partition.c
@@ -64,6 +64,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
@@ -72,6 +76,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-split.c b/tests/test-split.c
index f20e64b..22c9e72 100644
--- a/tests/test-split.c
+++ b/tests/test-split.c
@@ -63,6 +63,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -70,6 +74,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-streaming.c b/tests/test-streaming.c
index 7807501..fbdf34b 100644
--- a/tests/test-streaming.c
+++ b/tests/test-streaming.c
@@ -108,6 +108,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
@@ -115,6 +119,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
diff --git a/tests/test-xz.c b/tests/test-xz.c
index ef58d59..34bc1ac 100644
--- a/tests/test-xz.c
+++ b/tests/test-xz.c
@@ -60,6 +60,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
+#ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
+ printf ("libguestfs too old to support nbd disk, skipping\n");
+ exit (77);
+#else
r = guestfs_add_drive_opts (g, "",
GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
@@ -68,6 +72,7 @@ main (int argc, char *argv[])
-1);
if (r == -1)
exit (EXIT_FAILURE);
+#endif
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
--
2.14.3
6 years, 7 months