[PATCH] Use srandom (time (NULL) + getpid ()) throughout.
by Richard W.M. Jones
It avoids two programs which start at exactly the same time from
having the same random number seed, which helps in some tests.
---
edit/edit.c | 3 ++-
fish/fish.c | 2 +-
tests/mount-local/test-parallel-mount-local.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/edit/edit.c b/edit/edit.c
index 2f986a3..1e2641c 100644
--- a/edit/edit.c
+++ b/edit/edit.c
@@ -29,6 +29,7 @@
#include <error.h>
#include <assert.h>
#include <libintl.h>
+#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <utime.h>
@@ -103,7 +104,7 @@ main (int argc, char *argv[])
textdomain (PACKAGE);
/* We use random(3) below. */
- srandom (time (NULL));
+ srandom (time (NULL) + getpid ());
enum { HELP_OPTION = CHAR_MAX + 1 };
diff --git a/fish/fish.c b/fish/fish.c
index b7d63cf..52a9093 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -181,7 +181,7 @@ main (int argc, char *argv[])
textdomain (PACKAGE);
/* We use random(3) in edit.c. */
- srandom (time (NULL));
+ srandom (time (NULL) + getpid ());
parse_config ();
diff --git a/tests/mount-local/test-parallel-mount-local.c b/tests/mount-local/test-parallel-mount-local.c
index 3e5d95c..542f1ed 100644
--- a/tests/mount-local/test-parallel-mount-local.c
+++ b/tests/mount-local/test-parallel-mount-local.c
@@ -85,7 +85,7 @@ main (int argc, char *argv[])
int r, errors = 0;
void *status;
- srandom (time (NULL));
+ srandom (time (NULL) + getpid ());
/* If the --test flag is given, then this is the test subprocess. */
if (argc == 3 && STREQ (argv[1], "--test")) {
--
2.9.3
7 years, 11 months
[nbdkit PATCH v2 0/6] bind .zero to Python
by Eric Blake
Fix some things I noticed while reviewing v1, and follow Rich's
idea to add a new nbdkit_set_error() utility function with a
binding for Python users to request a particular error (rather
than being forced to live with whatever stale value is in errno
after all the intermediate binding glue code).
I could not easily find out how to register a C function callable
from perl bindings, and have not got enough experience with Ruby
or Ocaml (those will probably require me to do lots of copy-and-paste
and language learning), but if the code looks good for python, I
suspect the other languages will take a similar approach.
Maybe we want to also make nbdkit.error() and nbdkit.debug()
callable from Python (so that we have a more complete binding
of all the utility functions that C plugins can use); this
can be used as a starting point for that.
Eric Blake (6):
file: Optimize writing zeroes without holes
protocol: Map EROFS to EPERM
protocol: Support ESHUTDOWN error
plugins: Add new nbdkit_set_error() utility function
python: Expose nbdkit_set_error to python script
python: Support zero callback
docs/nbdkit-plugin.pod | 16 +++++++--
include/nbdkit-plugin.h | 3 +-
plugins/file/file.c | 19 +++++++---
plugins/python/example.py | 11 ++++++
plugins/python/nbdkit-python-plugin.pod | 47 +++++++++++++++++++++---
plugins/python/python.c | 64 +++++++++++++++++++++++++++++++++
src/connections.c | 37 +++++++++++++++----
src/errors.c | 6 ++++
src/internal.h | 2 ++
src/plugins.c | 10 ++++--
src/protocol.h | 1 +
src/tls.c | 28 +++++++++++++--
12 files changed, 221 insertions(+), 23 deletions(-)
--
2.9.3
7 years, 11 months
[nbdkit PATCH 0/5] Add WRITE_ZEROES support
by Eric Blake
The upstream protocol recently promoted NBD_CMD_WRITE_ZEROES from
experimental to a documented extension. Exposing support for this
allows plugin writers to create sparse files when driven by a
client that knows how to use the extension; meanwhile, even if a
plugin does not support this extension, the server benefits from
less network traffic from the client.
Eric Blake (5):
protocol: Support NBD_FLAG_NO_ZEROES
protocol: Validate request flags
plugins: Add callback for writing zeroes
protocol: Implement NBD_CMD_WRITE_ZEROES
file: Support punching holes for write zero
docs/nbdkit-plugin.pod | 19 +++++++++++++++++++
include/nbdkit-plugin.h | 1 +
plugins/file/file.c | 32 +++++++++++++++++++++++++++++++
src/connections.c | 47 +++++++++++++++++++++++++++++++++++++++++-----
src/internal.h | 1 +
src/plugins.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
src/protocol.h | 18 +++++++++++-------
7 files changed, 156 insertions(+), 12 deletions(-)
--
2.9.3
7 years, 11 months
[nbdkit PATCH 0/2] bind .zero to more languages
by Eric Blake
Begin the language binding followups to my new .zero callback, since
Rich was indeed correct that we want them.
I'm more familiar with python and perl (at least to the point that
I was able to modify the appropriate example files and prove to
myself that the bindings worked), so I've started with those.
I'm less familiar with ruby and ocaml, so I've left those for
tomorrow (it will rely heavily on copy-and-paste); it is also a
chance to review if my decision of requiring a return value in
order to trigger the graceful fallback is the best approach.
Eric Blake (2):
perl: Support zero callback
python: Support zero callback
plugins/perl/nbdkit-perl-plugin.pod | 25 ++++++++++++++++++++++
plugins/perl/perl.c | 37 +++++++++++++++++++++++++++++++++
plugins/python/nbdkit-python-plugin.pod | 18 ++++++++++++++++
plugins/python/python.c | 35 +++++++++++++++++++++++++++++++
4 files changed, 115 insertions(+)
--
2.9.3
7 years, 11 months
[PATCH] p2v: log also environment on conversion server
by Pino Toscano
Save the content of the environment on the conversion server, so it is
one additional help when debugging failed conversions.
---
p2v/conversion.c | 5 +++++
p2v/virt-p2v.pod | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/p2v/conversion.c b/p2v/conversion.c
index 3c379cb..b8bab34 100644
--- a/p2v/conversion.c
+++ b/p2v/conversion.c
@@ -1061,6 +1061,11 @@ generate_wrapper_script (struct config *config, const char *remote_dir,
fprintf (fp, "\n");
fprintf (fp,
+ "# Log the environment where virt-v2v will run.\n");
+ fprintf (fp, "printenv > environment\n");
+ fprintf (fp, "\n");
+
+ fprintf (fp,
"# Run virt-v2v. Send stdout back to virt-p2v. Send stdout\n"
"# and stderr (debugging info) to the log file.\n");
fprintf (fp, "v2v 2>> $log | tee -a $log\n");
diff --git a/p2v/virt-p2v.pod b/p2v/virt-p2v.pod
index 075256e..ec8eff2 100644
--- a/p2v/virt-p2v.pod
+++ b/p2v/virt-p2v.pod
@@ -662,6 +662,12 @@ The dmesg output from the physical machine. Useful for detecting
problems such as missing device drivers or firmware on the virt-p2v
ISO.
+=item F<environment>
+
+I<(before conversion)>
+
+The content of the environment where L<virt-v2v(1)> will run.
+
=item F<lscpu>
=item F<lspci>
--
2.9.3
7 years, 11 months
virt-p2v on RHEL 5
by Richard W.M. Jones
When virtualizing a physical machine ("P2V"), the conversion step is
done by virt-v2v, but there is a small GUI / front end component
called virt-p2v which has to run on the source physical machine in a
special environment.
http://libguestfs.org/virt-p2v.1.html#network-setup
Because the nature of the problem is that we want to virtualize old
machines, this means virt-p2v sometimes has to be run with old drivers
or on machines which would be considered obsolete today as servers
(eg. 32 bit machines).
We have a customer who wishes to virtualize a machine with an ancient
LSI controller that is only supported by a proprietary kernel module
for RHEL 5, and so I spent some time getting virt-p2v to compile and
run on RHEL 5.
These are my notes in case anyone needs to reproduce this (or *I* need
to reproduce it at some later date).
I needed both virt-p2v with the Gtk GUI, and qemu-nbd (also not
available on RHEL 5).
I started with libguestfs from git. I have added a few upstreamable
RHEL 5 patches. I also needed the attached patches which are not
upstreamable.
You will need to run bootstrap and/or autogen.sh on more recent
machine, since autotools on RHEL 5 is far too old. (This was easy for
me because I was building on an NFS homedir shared between Fedora 25
and RHEL 5).
Configure libguestfs like this:
export vmchannel_test=no
export LIBTINFO_CFLAGS=-D_GNU_SOURCE
export LIBTINFO_LIBS=-lncurses
export YAJL_CFLAGS=-D_GNU_SOURCE
export YAJL_LIBS=-lyajl
./configure \
--prefix /usr \
--libdir /usr/lib64 \
--disable-static \
--disable-appliance --disable-daemon \
--disable-ocaml --disable-perl --disable-python --disable-ruby \
--disable-php --disable-lua \
--with-qemu=no
We only want virt-p2v to be compiled, so at this point you can do one
of:
make -k
make -C p2v
This should get you a virt-p2v binary.
For qemu-nbd, the latest qemu is not even close to compiling on RHEL
5. However going back to qemu tag v1.5.0 worked, and it compiled
easily from git. This will give you a qemu-nbd binary.
Provided that both qemu-nbd and virt-p2v are available on the $PATH,
you can now run virt-p2v as normal. Note that you should run it
against virt-v2v on a modern machine (conversion server).
There is a case for making virt-p2v work with other NBD servers
(eg. nbd or nbdkit), or with a minimal built-in NBD server.
To build the RHEL 5 virt-p2v ISO, I had to quite heavily modify the
p2v.ks (kickstart) file. The file is rather large so I could not
attach it, but I placed it here instead:
http://oirase.annexia.org/tmp/p2v-rhel-5.ks
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
7 years, 11 months
[PATCH 0/5] Rename src/ to lib/ and move common code to common/
by Richard W.M. Jones
This patch series moves some files and directories around but is only
code motion (or supposed to be).
A new directory, common/, is created for all of the common code which
is currently shared in random ways between parts of the project.
And src/ becomes lib/ (the largest change, but mostly mechanical).
In full this series makes the following changes:
src/libprotocol -> common/protocol
src/liberrnostring -> common/errnostring
src/utils -> common/utils
cat/visit -> common/visit
fish/[various] -> common/options
src -> lib
I'm planning some other changes in future patches, assuming I have the
energy as this is rather tedious work:
df/parallel -> common/parallel
df/domains -> common/domains
fish/file-edit -> common/edit
fish/progress -> common/progress
fish/config -> common/config
fish/windows -> common/windows
mllib -> mlcommon or common/mllib?
Rich.
7 years, 11 months
[PATCH v3 0/6] Import directly from OVA tar archive if possible
by Tomáš Golembiovský
v3: Addressed Pino's comments, namely:
- input_ova.ml
- untar takes list of paths
- renamed untar_partial to untar_metadata
- replaced uggly regex with nsplit
- tests
- test changes are part of the main commit
- renamed test-data/guestfs-hashsums.sh to test-data/test-utils.sh
- renamed qemu_version to qemu_is_version and moved it to
test-data/test-utils.sh
- normalize paths in expect files
v2:
- rewritten the tar invocations, the output processing is now done in
OcaML rather than with a shell code; it turned out to be easier and
more readable than I have feared.
- added QEMU version check
- addressed Pino's comments
- changed tests; the expected result is now based on the QEMU used
during testing
This series is related to the problem of inefficient import of OVA
files. The needed enhancements of QEMU were merged into the codebase and
should be available in QEMU 2.8. From there we can use 'size' and
'offset' options in raw driver to tell QEMU to use only subset of a file
as an image.
The patch set is more or less complete. The only outstanding issue is
the missing detection of sparse files inside tar. But this can be done
in a separate patch. As pointed out before I didn't find a way how to
detect that by using the tar tool only and would probably require use of
some external library.
The first three patches are just preparation. The main work is in patch
four. Last patch fixes the tests.
Tomáš Golembiovský (6):
mllib: compute checksum of file inside tar
v2v: ova: don't detect compressed disks, read the OVF instead
v2v: ova: move the untar function
mllib: modify nsplit to take optional noempty and count arguments
tests: rename guestfs-hashsums.sh to test-utils.sh
v2v: ova: don't extract files from OVA if it's not needed
mllib/checksums.ml | 11 +-
mllib/checksums.mli | 7 +-
mllib/common_utils.ml | 12 +-
mllib/common_utils.mli | 12 +-
test-data/Makefile.am | 2 +-
test-data/{guestfs-hashsums.sh => test-utils.sh} | 20 +++
tests/qemu/qemu-liveness.sh | 2 +-
tests/qemu/qemu-snapshot-isolation.sh | 2 +-
v2v/Makefile.am | 1 +
v2v/input_ova.ml | 211 ++++++++++++++++++++---
v2v/test-v2v-i-ova-formats.sh | 7 +-
v2v/test-v2v-i-ova-gz.ovf | 2 +-
v2v/test-v2v-i-ova-gz.sh | 2 +-
v2v/test-v2v-i-ova-subfolders.expected2 | 18 ++
v2v/test-v2v-i-ova-subfolders.sh | 15 +-
v2v/test-v2v-i-ova-tar.expected | 18 ++
v2v/test-v2v-i-ova-tar.expected2 | 18 ++
v2v/test-v2v-i-ova-tar.ovf | 138 +++++++++++++++
v2v/test-v2v-i-ova-tar.sh | 71 ++++++++
v2v/test-v2v-i-ova-two-disks.expected2 | 19 ++
v2v/test-v2v-i-ova-two-disks.sh | 15 +-
v2v/test-v2v-i-ova.sh | 2 +-
v2v/test-v2v-in-place.sh | 2 +-
23 files changed, 553 insertions(+), 54 deletions(-)
rename test-data/{guestfs-hashsums.sh => test-utils.sh} (73%)
create mode 100644 v2v/test-v2v-i-ova-subfolders.expected2
create mode 100644 v2v/test-v2v-i-ova-tar.expected
create mode 100644 v2v/test-v2v-i-ova-tar.expected2
create mode 100644 v2v/test-v2v-i-ova-tar.ovf
create mode 100755 v2v/test-v2v-i-ova-tar.sh
create mode 100644 v2v/test-v2v-i-ova-two-disks.expected2
--
2.10.2
7 years, 11 months