Instead of doing all firstboot actions in a single script, take the
advantage of the firstboot infrastructure and store and run unrelated
actions as individual steps.
This facilitates troubleshooting and fault recovery; besides it makes
adding more actions easier.
Signed-off-by: Roman Kagan <rkagan@parallels.com>
The firstboot infrastructure used to give the firstboot scripts some
cryptic names which were impossible to relate to the actions they were
supposed to take.
This patch reworks the scheme such that the caller registering a
firstboot script has to provide a descriptive name for the action. That
name, with non-alphanumeric characters replaced with dashes, prefixed by
the serial number, is then used as the name of the script, e.g.
0004-install-gcc
or
0002-msiexec--i-foo-msi.bat
OTOH the numbering becomes internal to the API, i.e. the scripts are
numbered and executed in the order they are registered.
This greatly facilitates debugging and troubleshooting in case when
there are multiple firstboot scripts.
Signed-off-by: Roman Kagan <rkagan@parallels.com>
This patch is an attempt to enhance the firstboot driver script for
Windows, and make it somewhat closer in functionality to what is done
for Linux guests.
Specifically, for every firstboot script it now will log its exit
status, and, if the script reported success, move it to -done directory.
Signed-off-by: Roman Kagan <rkagan@parallels.com>
This patch moves line ending conversion for windows scripts into a
separate helper function.
This simplifies code a bit, and fixes the problem that actual firstboot
scripts used to remain with unix-style line endings.
Signed-off-by: Roman Kagan <rkagan@parallels.com>
Use commandrvf() instead of commandvf() to execute e2fsck. A non-zero
exit status does not always indicate a failure.
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
When the user chooses to not verify the signatures on the indexes
(using --no-check-signature), there is no point in requiring as many
--fingerprint as --source (or even just one), as they will not be used
anyway.
In this case just ignore all the values of the specified --fingerprint
arguments.
Process the sources specified via the --source command line arguments
before sources read from repositories, so the former have a chance to
"override" the latter.
Related to RHBZ#1193238.
Ensure the arch string is sane before using it in the following XPath
expression. Since the arch string can be derived from untrusted guest
data [see src/filearch.c], this prevents a possible XPath injection
vulnerability.
We also need to be more careful about PyString_FromString and similar
functions returning NULL on failure. Currently we don't check this
every time. This commit adds more checks, but is still not complete.
libguestfs has used double and triple underscores in identifiers.
These aren't valid for global names in C++.
The second step is to replace all guestfs__* (2 underscores) with
guestfs_impl_*.
These functions are used where a libguestfs API call is implemented on
the library side. The generator creates a wrapper function which
calls guestfs_impl_* to do the work. (Libguestfs APIs which are
passed directly by the daemon work differently and don't require a
guestfs_impl_* function).
This is an entirely mechanical change done using:
git ls-files | xargs perl -pi.bak -e 's/guestfs___/guestfs_impl_/g'
Reference: http://stackoverflow.com/a/228797
libguestfs has used double and triple underscores in identifiers.
These aren't valid for global names in C++.
The first step is to replace all guestfs___* (3 underscores) with
guestfs_int_*. We've used guestfs_int_* elsewhere already as a prefix
for internal identifiers.
This is an entirely mechanical change done using:
git ls-files | xargs perl -pi.bak -e 's/guestfs___/guestfs_int_/g'
Reference: http://stackoverflow.com/a/228797
* fusermount is Linux-only; on BSD and OS X umount should be used
* fuser has no -v flag on BSD/OSX, and -c is the
POSIX-compatible equivalent of -m
* Does not solve the lack of pretty output of fuser -v, but does make it
work on Mac OS X.
Add a bash function 'prepend' for intelligently prepending elements to
paths. eg:
prepend PYTHONPATH "/foo"
would set PYTHONPATH to "/foo" or "/foo:<previous-contents-of-PYTHONPATH>"
Tested by:
(1) Building and testing libguestfs twice: first without libguestfs
installed as a system library, and then with it installed.
(2) Examining the output of './run printenv' by hand and comparing
environment variables to the expected values.
As advised by Daniel P. Berrange, the third parameter can be passed on all
platforms rather than specifically Mac.
Quoting a libvirt commit rationale after Daniel:
commit 9fa3a8ab6fd82ad2f5a14b490696085061418718
Author: Doug Goldstein <cardoe@cardoe.com>
Date: Wed Oct 30 11:22:58 2013 -0500
MacOS: Handle changes to xdrproc_t definition
With Mac OS X 10.9, xdrproc_t is no longer defined as:
typedef bool_t (*xdrproc_t)(XDR *, ...);
but instead as:
typedef bool_t (*xdrproc_t)(XDR *, void *, unsigned int);
For reference, Linux systems typically define it as:
typedef bool_t (*xdrproc_t)(XDR *, void *, ...);
The rationale explained in the header is that using a vararg is
incorrect and has a potential to change the ABI slightly do to compiler
optimizations taken and the undefined behavior. They decided
to specify the exact number of parameters and for compatibility with old
code decided to make the signature require 3 arguments. The third
argument is ignored for cases that its not used and its recommended to
supply a 0.
Generate a simple bindtests test for the PHP binding, so it is possible
to easily test all the argument types.
Unlike the bindtests for other languages, optional arguments are not
tested, due to the limitations of optional arguments in PHP (or maybe
they way we implement them).
Make sure to copy the strings we add to the char** array, otherwise they
are stale pointers which we'll try to free later.
Also, properly destruct the temporary zval.
OptString maps to a "s!" argument, which makes zend_parse_parameters not
touch the variables (char* and length) when NULL is passed as parameter.
Hence, set both to NULL/0, and check for non-NULL char* variable before
checking its length.