1 GB should be enough to create a btrfs filesystem, even with 64K page
size; hence, make the /dev/sda and /dev/sdb test devices smaller so
there is less space taken during the test run.
Followup of commit 8ffad75e5b and
commit 9e9b648770.
This patch updates the guestfs_inspect_get_drive_mappings API call to
also return drive letters for GPT paritions. Previously this worked
only for MBR partitions. This is achieved by matching the GPT partition
GUID with the info stored in the blob from
HKLM\SYSTEM\MountedDevices\DosDevices keys. For GPT partions this blob
contains a "DMIO:ID:" prefix followed by a 16 byte binary GUID.
Support globbing in paths passed to --delete, telling glob to not
return directories with leading slash.
This re-adds back globbing for --delete in virt-sysprep, which was
available before the integration with common code from virt-customize.
Add a new optional bool "directoryslash" to indicate whether the caller
wants trailing slashes in names of directories, defaulting to true (the
current behaviour); this helps with interoperability with other tools
(such as rm).
Related to RHBZ#1293271.
The current VDSM .meta file parser is incorrect:
https://code.engineering.redhat.com/gerrit/gitweb?p=vdsm.git;a=blob;f=vdsm/storage/fileVolume.py;h=20573bd2a3fe6909a8474bd7c53c8d0fea79091c;hb=c1289fd70edcde0a0b3bc8e37ecad1e2a5babe1a#l285
When parsing the key=value fields in the .meta file, it uses the
Python expression:
key, value = l.split("=")
which throws an exception "ValueError: too many values to unpack" if
the value part also contains an "=" character (because split returns
an n-tuple with n > 2). The correct way to split the string in this
situation is to use l.split("=", 1).
In commit 399e031c25 I changed the
DESCRIPTION field in .meta so that in RHEL it would look like this:
DESCRIPTION=generated by libguestfs 1.32.2rhel=7,release=1.el7,libvirt
thus containing an "=" character in the value and throwing an
exception in VDSM.
Although this is a bug in VDSM which needs to be fixed separately,
change any occurrence of "=" in the value to "_" to avoid this
problem.
Thanks: Derrick Ornelas for helping to diagnose this bug and finding
the offending code in VDSM.
One of the mkfs-btrfs tests used two 200 MB partitions. That isn't
enough to create a btrfs filesystem on aarch64 (with 64K page size).
Since we now have a 10 GB disk, we can make the test partition 10
times larger.
In btrfs-progs 4.4, the --leafsize parameter is deprecated. It's now
just an alias for --nodesize.
On aarch64, --nodesize 4096 does not work because it's smaller than
the page size (64K). Luckily we can test a 64K nodesize on any
platform, so use that instead.
Previously these were rather small - just 500 MB. This is too small
to create a btrfs device on aarch64 (where page size may be 64K), and
barely enough even on x86-64. This change makes both these devices
10 GB, and adjusts a few tests so they continue to pass.
Introduce a new read-only API to get a path where to store temporary
sockets: this is different from tmpdir, as we need short paths for
sockets (due to sockaddr_un::sun_path), and it is either
XDG_RUNTIME_DIR if set, or /tmp; adapt guestfs_int_create_socketname
to create sockets in that location.
Furthermore, print sockdir and XDG_RUNTIME_DIR in test-tool for
debugging.
Introduce an internal helper to create paths for sockets -- will be
useful for changing later the logic for placing sockets.
Futhermore, check that the length of sockets won't overflow the buffer
for their filenames.
Extract the bit of code for lazy creation of a temporary directory, so
it can be used for more directories as well.
This is just code motion, with no behaviour changes.
Move the paths of the sockets used, from the libvirt_xml_params struct
to backend_libvirt_data; this way, they will be usable also outside the
launch callback.
Simply code motion.
I find the code slightly easier to read if we get rid of the ~write
flag, and instead split the with_hive function into two functions, one
for readonly access, and one for write access.
This is just code refactoring.
Add a common module `Windows_virtio' and move all the code related to
finding and installing Windows virtio drivers to this module.
This is just code motion and code refactoring, there is no change in
functionality.
Instead of pass 0x3fffffff as mask value, pass a simplier 0xfff, which
is the value of the IN_ALL_EVENTS define. This will still catch all
the inotify events, and avoid a EINVAL error with Linux 4.4.
Actually these are all static functions, so they don't really need the
'guestfs_' prefix at all, but using a prefix avoids any possibility of
a collision with a standard C function.
This is a mechanical refactoring.
For functions linked to virt tools, make sure the name of the function
actually matches the virt tool. Because of the history of moving
functions across tools, some names no longer matched.
For mllib, use `guestfs_int_mllib_' prefix.
For OCaml bindings, use `guestfs_int_ocaml_' prefix.
This commit is by no means complete. There are many other C functions
in other language bindings which could do with being more consistently
named.
There is no functional change, this is just refactoring.
lvm2 2.02.107 adds the -S/--select option used in lvs to filter out only
public LVs (see RHBZ#1278878). To make this work again with versions
of lvm2 older than that, only on old versions filter out thin layouts
and compose the resulting device strings ourselves.
The filtering done is much simplier than what "-S lv_role=public" will
do, but should be good enough for our need.
In Fedora 23, dracut moved to /usr/bin. However we only looked for
/sbin/dracut, so we didn't find it. You would have seen a failure
like this:
virt-v2v: error: unable to rebuild initrd
(/boot/initramfs-4.2.3-300.fc23.x86_64.img) because mkinitrd or dracut was
not found in the guest
Look for dracut in /usr/bin as well.
Thanks: Arnaud Bougeard.
print "" is no more available in Python 3, and print(...) is available
since Python 2.7; as one of the tests was using print(), use this form
everywhere so the tests can run fine with Python 3.
The warning (see below) is fairly useless. This modification to the
code avoids it.
inotify.c: In function 'do_inotify_read':
inotify.c:219:32: error: logical 'or' of equal expressions [-Werror=logical-op]
if (errno == EWOULDBLOCK || errno == EAGAIN) /* End of list. */
^~
The btrfs implementation of vfs_minimum_size requires
btrfs-progs >= 4.2, erroring with ENOTSUP otherwise; thus mark the btrfs
test case of the vfs_minimum_size tests as TestRunOrUnsupported, so it
will not cause failures if the available btrfs-progs is not enough.
Create a new TestRunOrUnsupported test type, which represents a test
sequence where a failure with ENOTSUP in the last command only marks the
test as skipped. To be used mainly when testing features available only
with some versions of helper tools used in the appliance, for example.
Having to choose the os-version of the virt-p2v disk was confusing.
Users thought it had something to do with the physical machine being
converted.
In some cases, virt-p2v-make-disk can now choose a suitable os-version
for the user. Usually it's the latest numeric version of Fedora or
Debian, depending on the host distro. If we don't recognize the host
distro, we bail and ask the user to choose, but this is still an
improvement.
Actually the OCaml compiler rewrites all printf functions at compile
time to a series of primitive string operations, so the use of sprintf
here doesn't really matter. Still, it's a bit tidier not to use
sprintf where it's not needed.
Also this commit contains some code reformatting.
This is just refactoring.
When the user clicks on the second column of the list of network
interfaces, run 'ethtool --identify <if_name> 10', which (on supported
cards) flashes a light on the physical interface for 10 seconds,
allowing it to be identified by the operator.
Resolve the paths of the binaries we are looking in the guest to
identify the architecture. This way we can identify also busybox-based
guests such as Alpine Linux, where all the "base" binaries in /bin are
symlinks to busybox.
Apparent newer versions of that report everything on stdout, including
error messages; since we only print something on failure, fold stdout to
stderr so we can see everything on failure.
This flag cannot be disabled (yet) in V5 xfs filesystems; since 2 out
of the current 3 tests of xfs_admin check other results than that flag,
avoid setting it when not needed.
Apparently with newer btrfs-progs (seen with 4.4) 100M are not enough
for a btrfs filesystem; hence double the size of the partitions
created in the test of btrfs_image, so now 200M are enough for btrfs.
In commit af762e4342 (2015-03-05)
I stopped libguestfs from using the supermin -dtb parameter when
building appliances.
It has not been necessary for quite a long time to specify a DTB,
since qemu itself creates a device tree structure in the guest
(appliance) memory from the devices presented to the guest. Qemu does
this on the fly each time the guest starts.
As I promised in the commit mentioned above I would remove this code,
and this commit does that (for libguestfs only).
This allows you to build a 32 bit virt-p2v USB key, even on a 64 bit
host.
Because of problems with the Fedora build system it's unfortunately
not easy to build a 32 bit virt-p2v binary, so this patch punts on
this issue and assumes that the user can supply the binary themselves.
This action moves second(backup) GPT header to the end of the disk.
It is usable in in-place image expanding, since free space after
second GPT header is unusable. To use additional space, we have
to move second header. This is what sgdisk -e does.
However, sgdisk -e may perform additional actions if the partition
table has unexpected params (e.g. if we call sgdisk -e /dev/sda1,
it may fix partition table thus destroying the filesystem).
To prevent such cases, we do a dry-run at first and fail if
additional actions are scheduled.
If present, Parallels Tools may stand in the way of proper running the
windows guests in non-Parallels hypervisors, so we're better off
uninstalling them on the first boot into the new environment.
With this patch, the uninstall records for Parallels Tools are looked up
in the registry and, if found, corresponding firstboot actions are
registered, taking special care that those actions are run fully
unattended.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
This test would fail on machines with around 4 GB of free memory.
Adjust the test so it would now work on such machines (it will however
still fail on a machine with around 2 GB of free memory).
Some OSes (e.g. Windows Server 2012 R2) fail to boot if the disk
GPT GUID has changed. To preserve disk guid e.g. during virt-resize,
we need a way to get/set disk GUIDs.
Libvirt has a fixed 15 second timeout for qemu to exit. If qemu is
writing to a slow USB key, it can hang (in D state) for much longer
than this - many minutes usually.
The solution is to check specifically for the libvirt EBUSY error when
this happens, and retry the virDomainDestroyFlags operation
(indefinitely).
See also the description here:
https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html
Similar to the following OpenStack Nova commit:
http://git.openstack.org/cgit/openstack/nova/commit/?id=3907867
Thanks: Kashyap Chamarthy and Daniel Berrange.
The err->domain field is essentially random from the point of view
of libguestfs.
The err->int1 field has some useful information in some circumstances:
it has the errno value from the failed system call.
Resolve in the guest the given path, so absolute symlinks can be listed
using appliance tools without resolution errors.
Also remove the note about the possibility to escape the sysroot using
ll and llz, since realpath won't return paths outside sysroot.
Fixes part of RHBZ#1293276.
Fedora/i686 does not have a package called 'kernel', so the command
'rpm -q kernel' fails. In any case the method used wasn't exactly
very robust.
The new method is based on how febootstrap used to do this.
This updates commit d723b352f8.
Sometimes the user wants to know minimum size
for dirty (e.g. mounted) filesystems. In this case,
resize2fs -P will require calling e2fsck -f, while
"in general, it is not safe to run e2fsck on mounted filesystems".
Since resize2fs -P does not modify filesystem, we force it
to display (probably approximate) minimum size.
Allow the user to specify a template in --list mode, which will be the
only result in the resulting output (instead of all the available
templates).
This makes it easier to find out the details of a specific template.
For every user command line tool (eg. guestfish or virt-cat) require
that the manual page has a DESCRIPTION section. This doesn't apply to
non-CLI man pages (eg. guestfs-perl, guestfs-faq).
Require qemu >= 1.3.0, the first version that supported
`qemu-img --output=json'.
This means we require yajl (for parsing the JSON output of qemu-img),
and that in turn has consequences elsewhere.
Move the creation of iscsi URIs away from make_uri, composing them
manually: this is needed because libxml assumes colons (':') to separate
user and password for the authority part, while with iscsi URIs the
separator is percentage ('%'), which would be percent-encoded by libxml.
It's a bitmask, so unsigned is the right choice. eg. We can more
easily print it using %x.
This patch changes the size of the fd mask and the values of the
COMMAND_FLAG_* constants, but since these are internal definitions
that doesn't matter.
Commit e6f7d23782 added new po files for
pt_BR to po/ and po-docs/ (they are only very minimal). However they
were not added to the list of linguas, so amongst other things the
files were not included in EXTRA_DIST automatically.
./uk.po:1049: 'msgid' and 'msgstr' entries do not both end with '\n'
./uk.po:9638: format specifications in 'msgid' and 'msgstr' for argument 2 are not the same
This updates commit e6f7d23782.
Two tests opened the phony Fedora image in parallel without the
readonly flag. This occasionally resulted in strange errors
(especially observed in test-inspect.sh). Add the --readonly flag to
avoid this.
- add a flag to request chroot for the process, which is done only as
very last (before chdir) operation before exec'ing the process in the
child: this avoids using CHROOT_IN & CHROOT_OUT around command*
invocations, and reduces the code spent in chroot mode
- add failure checks for dup2, open, and chdir done in child, not
proceeding to executing the process if they fail
- open /dev/null without O_CLOEXEC, so it stays available for the
exec'ed process, and thus we don't need to provide an own fd for stdin
Followup of commit fd2f175ee7, thanks also
to the notes and hints provided by Mateusz Guzik.
Prior to this commit:
$ virt-builder --help
[...]
--sm-attach SELECTOR Attach to a subscription-manager pool
--sm-credentials SELECTOR credentials for subscription-manager
--sm-register Register using subscription-manager
Really the generator ought to check this.
'sfdisk --part-type' used to merely set the MBR ID byte in the
partition. However since sfdisk was rewritten, it now "helpfully"
corrupts the first sector of the partition if you change the type byte
from an ordinary partition to an extended partition.
So we need to change the order in which we sets the partition type
byte, to do it before copying the partition content.
This fixes a major regression in the way that virt-resize handles any
guest with logical partitions (specifically Ubuntu guests).
If uncompressing a template to a filesystem which is nearly full,
virt-builder displays an error which points to the wrong (source) file:
$ virt-builder fedora-22
[ 1.2] Downloading: http://libguestfs.org/download/builder/fedora-22.xz
[ 1.7] Planning how to build this image
[ 1.7] Uncompressing
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
/home/rjones/.cache/virt-builder/fedora-22.x86_64.1: No space left on device
(The error message is usually printed once by each thread, so it is
printed several times.)
Change the error message to point to the output file, which might be a
temporary or the final file depending on the build plan:
$ virt-builder fedora-22
[ 1.1] Downloading: http://libguestfs.org/download/builder/fedora-22.xz
[ 1.6] Planning how to build this image
[ 1.6] Uncompressing
fedora-22.img: No space left on device
fedora-22.img: No space left on device
fedora-22.img: No space left on device
fedora-22.img: No space left on device
On ARM machines with vGICv3, we need to use the extra -M
parameter gic-version=3 (or gic-version=2 for the old vGIC).
qemu can detect this feature for us if we pass gic-version=host,
so add that to the -M option. Unfortunately we cannot detect if
qemu itself supports this parameter, but this change only affects
aarch64.
Thanks: Wei Huang
Exit with 3 as return value when fusermount fails, because the specified
mount point is not considered mounted for the user. This is in line
with what the guestunmount documentation says.
Adapt the test-guestunmount-fd test to the updated return value.
Thanks to: Maxim Perevedentsev.
When running commands in the mounted guest (using the "command" API, and
APIs based on it), provide the /dev/null from the appliance as open fd
for stdin. Commands usually assume stdin is open if they didn't close
it explicitly, so this should avoid crashes or misbehavings due to that.
Older GCC versions (e.g. < 4.9) may complain about inline functions that
cannot be inlined (growing the generated code). It is not really a
problem for us, so just suppress again the warning.
Followup of commit c37c554fc5.
This allows certain guests which virt-v2v cannot access to be copied
off the remote hypervisor and converted. Essentially this just
automates the process of copying the guest's disks and adjusting the
libvirt XML.
This also adds a test of the new tool.
Split the map_source_to_uri function up so that we can get at just the
https://... URI.
This is almost refactoring. It doesn't quite handle the case where we
are passed a source path from the libvirt VMware driver that doesn't
match the expected "[datastore] path" format, but probably if we hit
that case it's a bug anyway.
If you try to convert a guest that has a zero-sized disk, it
will currently fail in a rather strange way. Usually you will
see errors in the debug output:
[ 0.562714] sd 2:0:0:0: [sda] Read Capacity(16) failed: Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 0.563884] sd 2:0:0:0: [sda] Sense Key : Not Ready [current]
[ 0.564587] sd 2:0:0:0: [sda] Add. Sense: Logical unit not ready, manual intervention required
followed by virt-v2v failing with:
libguestfs: trace: v2v: inspect_os = []
virt-v2v: error: inspection could not detect the source guest (or physical
machine).
Additionally, because of a problem with the ssh driver in qemu (or
perhaps, with sftp-server on the remote side) it is not possible to
use the ssh driver to open a block device path on the remote server.
The drive will appear as zero-sized, triggering the above error.
Therefore detect this situation, and emit an error (see below). Also
add a section to the manual describing the workaround required for
converting RHEL 5 Xen guests which are located on block devices.
virt-v2v: error: guest disk sda appears to be zero bytes in size.
There could be several reasons for this:
Check that the guest doesn't really have a zero-sized disk. virt-v2v
cannot convert such a guest.
If you are converting a guest from an ssh source and the guest has a disk
on a block device (eg. on a host partition or host LVM LV), then
conversions of this type are not supported. See "XEN OR SSH CONVERSIONS
FROM BLOCK DEVICES" in the virt-v2v(1) manual for a workaround.
If the user tries to close the running dialog during a running
conversion, act as if the cancel button was pressed (cancelling the
conversion).
If the conversion has finished/been cancelled, then this closes the
dialog and exits virt-p2v, as now.
Cancelling the conversion in this way ensures that qemu-nbd and ssh
subprocesses are cleaned up.
If the virt-p2v ISO doesn't contain the correct drivers for the
hardware on the physical server, that can cause peculiar conversion
problems. This was hard to diagnose because we could not see the
'dmesg' output from the physical server.
Upload 'dmesg' output from the physical server (more precisely: from
the virt-p2v ISO's kernel running on the physical server) to the
virt-v2v conversion server debugging directory, so that this
information is available for debugging later.
Unfortunately this involves yet another copy of the 'read_whole_file'
function.
Instead of creating a special 'Exported by ...' string just for this
module, use the Common_utils.generated_by string. Since the string is
just descriptive, this should make no difference.
Adding this causes 'make dist' to fail with:
make[1]: *** No rule to make target 'ChangeLog', needed by 'distdir'. Stop.
This updates commit a2edda266e.
See the description in the bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1281578
Thanks: Richard Tollerton for alerting me to this change in the way
that Windows version numbers are stored in the Registry starting with
Windows ≥ 10.
The separator character (currently comma) was picked arbitrarily to
allow us to parse the output of commands like 'lvs' for APIs such as
'lvs-full'. Unfortunately the choice of comma conflicts with the 'lvs
-o modules' column, since the list of modules is separated by commas,
breaking our parser.
Change the separator to another arbitrary character (colon) which
hopefully is not used by any column.
See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1278878#c11
When a disk image uses LVM thinp (thin provisioning), the guestfs_lvs
API would return the thinp pools. This confused other APIs because
thinp pools don't have corresponding /dev/VG/LV device nodes.
Filter the LVs that are returned using "lv_role=public".
Thanks: Fabian Deutsch
I enabled the -Wshadow warning temporarily in order to do these fixes,
but had to disable it again afterwards. The reason is that this warns
about shadowing globals, which is sort of a good thing, but because we
have a global called "verbose" just about everywhere, and at the same
time we baked a function argument called "verbose" into several
unchangable APIs, well, we're stuck without being able to use this
warning.
This seemingly redundant change avoids a gcc warning/error:
error: cannot optimize possibly infinite loops
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34114#c3 and
following for an explanation.
Of course gcc is completely wrong and stupid here, because there's no
possibility on current or future hardware that an array of size
SSIZE_MAX could be allocated since it would by definition occupy at
least all addressible memory (if it was an array of bytes, which this
isn't), leaving no room for the code that is being compiled.
'virt-inspector --xpath' can segfault.
When run under valgrind, it shows this error:
==2254== Invalid free() / delete / delete[] / realloc()
==2254== at 0x4C29D6A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2254== by 0x53BA198: xmlFreeNodeList (tree.c:3690)
==2254== by 0x53B9F65: xmlFreeDoc (tree.c:1247)
==2254== by 0x405BFA: do_xpath (inspector.c:808)
==2254== by 0x405BFA: main (inspector.c:250)
==2254== Address 0x1030a037 is 311 bytes inside a block of size 1,048 alloc'd
==2254== at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2254== by 0x545DE86: xmlDictAddString.isra.0 (dict.c:270)
==2254== by 0x545E961: xmlDictLookup (dict.c:923)
==2254== by 0x539C6DC: xmlDetectSAX2 (parser.c:1067)
==2254== by 0x53B0B92: xmlParseDocument (parser.c:10725)
==2254== by 0x53B1276: xmlDoRead (parser.c:15295)
==2254== by 0x40587D: do_xpath (inspector.c:772)
==2254== by 0x40587D: main (inspector.c:250)
The cause appears to be that when copying the matching node(s) found
by the xpath expression, we have to copy them into the new document
(using xmlDocCopyNode instead of xmlCopyNode).
This bug has existed since this functionality was originally added in
commit d1ee71782a.
Extend open_guestfs to take an optional ?identifier parameter.
Use this parameter in virt-v2v which is currently the only place where
we use the handle identifier.
This higher order function encapsulates the following pattern:
match x with
| None -> ()
| Some x -> f x
(replaced with: `may f x`)
This is taken from OCaml lablgtk (Gtk bindings) where this pattern is
used frequently.
See also: https://ocaml.org/learn/tutorials/labels.html
Instead of creating Guestfs handles and manually apply common options
(e.g. debug and trace), use the open_guestfs in Common_utils.
This also applies the common options to handles which didn't set them
before, so we can inspect also their messages if needed.
Resolve also symlinks when checking whether a path passed to --edit is a
file: the file editing code supports symlinks anyway (properly changes
the target file, instead of overwrite the symlink with a real file), so
it is safe to allow this operation in customize/builder.
Check that a path provided to --edit exists already; while the is_file
call later will fail for non-existing files, with an explicit check a
better error message can be provided.
With commit bc2b417784
HAVE_LIBVIRT_BACKEND is defined based on the libvirt version (using its
version macro), although libvirt.h is included only after that check:
because of this, variables in the guestfs_h struct after the
HAVE_LIBVIRT_BACKEND block would be used wrongly if libvirt.h was not
included before guestfs-internal.h, like in the recently added
available.c (all the other places using libvirt features in the handle
already happened to do so).
Considering guestfs-internal.h already includes libvirt.h, move its
inclusion up, right before the libvirt version check.
Replace the custom XSLT + script to turn output from $RUN_OUTPUT_FILE
(from previous run.in versions) with a OCaml script to analyze .trs and
.log files of the automake test framework.
The final result should be the same, just with classname= for each test
set to the "path" (subdirectories) to that test.
Use (implicitly) parallel tests on new enough automake. The tests run
a bit quicker with this change. On my laptop, I measured 27 mins down
to 18 mins.
Change the ./run function so that ./run --test no longer spools the
test output to a file. That is not necessary when using parallel
tests, since the test harness does the same thing.
Note: This commit removes the $RUN_OUTPUT_FILE functionality. We will
change the CI integration in a future commit so it uses the .trs and
.log files.
The user did not have the 'file' command installed, and when they
attempted to do a v2v conversion of a Windows guest, inspection
succeeded, but the Types.i_arch field was found to contain "unknown".
virt-v2v conversion failed to locate the correct virtio drivers as a
result.
The 'file' command is required, and there's no other reason we should
not be able to detect the architecture of any Windows guest, so fail
hard in this situation.
We want to test if virt-v2v can find drivers using the *.inf files.
For this to work, one field is important:
[Version]
DriverVer = 07/17/2013,6.1.0.10018
Copy the [Version] section header and DriverVer field from the real
*.inf files to our fake *.inf files, which is enough for testing.
See also:
https://www.redhat.com/archives/libguestfs/2015-October/msg00352.html
Note that the fields are case insensitive and may or may not contain
spaces.
The virtio-win ISO has a different layout and superset of drivers
compared to the virtio-win RPM directory. Previously we simply put
all the RPM files into the fake ISO. Instead create a fake ISO which
has the same layout and (fake) drivers as the real ISO.
Refactor the internal_feature_available to return the result for just
one group, so it is easier to know on the library side what was the
actual error, and which group refers to; drop internal_available, as no
more needed after this.
On the library side, implement in available and feature_available the
real logic to iterate through the requested group, and error out or
return whether the groups are available. This also introduces caching
for the features, so each needs to be queried just once in each
appliance run.
The result of this is that there should be much less communication with
the daemon to know about available features; the downside is that
queries for more than one group at once, not already cached, will be
cause more queries to the daemon.
Rename the current available and feature_available into internal daemon
functions, and provide non-daemon functions wrapping them at library
side. This will make it possible to e.g. add caching for them.
Should be only refactoring, no actual behaviour change.
The error messages changes from:
$ virt-v2v -i disk /tmp/blank.img -o null
[...]
[ 14.6] Inspecting the overlay
virt-v2v: error: no root device found in this operating system image.
to:
$ virt-v2v -i disk /tmp/blank.img -o null
[...]
[ 15.2] Inspecting the overlay
virt-v2v: error: inspection could not detect the source guest (or physical
machine).
Assuming that you are running virt-v2v/virt-p2v on a source which is
supported (and not, for example, a blank disk), then this should not
happen. You should run 'virt-v2v -v -x ... >& log' and attach the complete
log to a new bug report (see http://libguestfs.org).
No root device found in this operating system image.
Various tests cannot be run in parallel just because they happen to
use conflicting names for temporary output files (eg. "test.out").
Change these tests to use unique temporary names, so the tests could
be run in parallel.
When virt-sparsify receives a user quit signal (eg from ^C) it
currently kills virt-sparsify and qemu instantly, meaning any mount +
fstrim in progress is uncleanly stopped. The (minor) side effect of
this is that the guest filesystem may require a journal replay or fsck
on boot.
Let virt-sparsify capture the user quit signal and shut down
gracefully.
It is not thought that the previous behaviour could cause guest
corruption; see
https://lists.nongnu.org/archive/html/qemu-devel/2015-11/threads.html#00402
for discussion.
- include <sys/un.h> for sockaddr_un, on any OS (removing the Mac OS X
blocks)
- include <fcntl.h> for O_* flags
This commits reverts a couple of changes in these files done in
commit 3b17152ec3.
Remove man pages and other pages which 'make clean' did not remove
before.
To evaluate which pages could be removed, I did a full build and
check, and then ran 'make clean' followed by 'git clean -xdf'. By
examining the output of the git clean command I could see which files
were being missed.
Files that are _not_ removed by make clean or make distclean:
- generator-built files
- Makefile, Makefile.in, .deps, .depend
- any ./configure output files (maybe they should be?)
It's a nice idea, but has never actually found a problem. After using
afl to find bugs in qemu-img, it's pretty clear to me that no
successful approach could be run in the short time demanded by the
libguestfs test suite. Afl tests run for days, weeks or even months.
A better approach may be to use a proven fuzz tester (such as afl) on
the inspection code; or to run this code for days on end on a separate
testing machine.
This reverts commit c2dcd10964.
Also move guestfs-performance to the right place on the website.
This updates commit 2eb01004bf
and commit d07515b947
and commit 74fba6e692
and commit 15b8b6453d.
Move the random set of HTML files we build from html/ into
the website/ directory.
Also in the website/ directory, put the index.html file from
http://libguestfs.org, which was previously not under version control.
It is generated from index.html.in so we can automatically add the
current version and release date.
Also in the website/ directory, put various CSS file, images, etc.
which are required by the website and were also previously not under
version control.
Change the 'make website' rule to 'make maintainer-upload-website'.
As the name suggests, it is only useful for the maintainer, and will
fail with an error for anyone else.
When I conceived commit dc1d0880b0, I
thought it would be a good idea to build test-data files, including
the phony guest images, during the 'make' phase. Previously these
were built early in the 'make check' phase.
However this has two disadvantages: (a) We run the appliance
unnecessarily during builds. For example, it is not necessary to
build the phony guests if we are going to do an 'installcheck'.
(b) Even if we are testing, the critical first time we run the
appliance is not in 'quickcheck' or 'tests/qemu', but some random
guest build.
Reorder the build sequence to fix this, and also a few other things.
This updates commit dc1d0880b0.
This test failed during release testing. It turned out to be because
the tests are run with LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 which
causes other messages to be printed.
Updates commit b5a6f899cd.
Create a new top-level directory called test-data, which will carry
all the test data which is large and/or shared between multiple tests.
There are actually several new subdirectories created:
test-data/binaries: The pre-built binary and library files for random
architectures that we use to test various architecture detection
features (was part of tests/data).
test-data/blank-disks: The blank disks which are used for disk format
detection (was part of tests/data).
test-data/files: Other miscellaneous test files from tests/data that
are not included in the above.
test-data/phony-guests: The phony guests (was tests/guests).
test-data: The top-level directory builds the 'test.iso' image file
that is used for testing the C API and in miscellaneous other tests.
Create a Windows module, analogous to the Linux module we already
have. Move utility functions related to Windows into this module.
In particular:
- detect_antivirus function moves here, and the Detect_antivirus
module goes away entirely
- copy_virtio_drivers / virtio_iso_path_matches_guest_os moves here,
and the virtio_iso_path_matches_guest_os can now be hidden
This is just refactoring, but allows us to make deeper changes to
copy_virtio_drivers.
The three utility functions xml_quote_attr, xml_quote_pcdata and
uri_escape were only used in a single module. Move them close to
where they are used.
This is just code refactoring.
Unfortunately Coccinelle places a Config module in the ocaml libdir,
and this confuses ocamlfind (only when Coccinelle is installed).
Since this is a private module that only libguestfs tools use
internally, just rename it from Config -> Guestfs_config.
Do this early since these tests generally don't depend on anything
else (the external program is either there or its not), and because
other things depend on some of these tests.
The error was:
libguestfs: trace: pread_device = "NTFS "
libguestfs: trace: part_to_dev "/dev/sda"
guestfsd: main_loop: new request, len 0x34
guestfsd: error: device name is not a partition
guestfsd: main_loop: proc 272 (part_to_dev) took 0.00 seconds
libguestfs: trace: part_to_dev = NULL (error)
virt-v2v: error: libguestfs error: part_to_dev: device name is not a
partition
This way, we can make sure that if a template needs to be expanded, the
result will have all the filesystems correctly expanded, fitting into
the new sizes of their partitions.
Introduce a new option to control how virt-resize behaves when asking to
expand a filesystem, either unknown to libguestfs or that virt-resize
cannot expand. The default keeps the current behaviour, i.e. just warn.
Replace ExtUtils::MakeMaker with Module::Build.
'perllocal.pod' and 'bindtests.pl' are no longer incorrectly
installed.
This change also removes the following phony deps: appliance src_deps
test_images. No other language binding needs explicit dependencies
for their tests, they just rely on the top level build order being
correct (ie. SUBDIRS in /Makefile.am).
'ocamlfind install' doesn't like to install the same package if it is
already installed. It will give errors like:
ocamlfind: Package guestfs is already installed
or:
ocamlfind: Conflict with file: /usr/lib64/ocaml/guestfs/mlguestfs.cmxa
Fix this by removing the old installed files before running
'ocamlfind install'. An alternative would be to use
'ocamlfind uninstall', but this seems more direct.
The error is:
ln -s xdg/virt-builder /tmp/p/etc/virt-builder
ln: failed to create symbolic link '/etc/virt-builder/virt-builder': File exists
There is no 'LN_SF' macro, but according to the documentation at
least, it should be safe to add a '-f' flag since it will work for
both the 'ln' and 'cp' variants of the macro.
When running in verbose mode, dump the XML we created for libvirt:
this way it is easier to debug mismatches between what we want to setup
in libvirt, and what actually gets defined.
Create the correct tags for <video> in the libvirtxml, so all the
attributes are in a <model> child of <video> instead of <video> itself.
Adapt the XML of test-v2v-i-ova to the different expected XML.
Move most of the content of either po-docs/ja/Makefile.am or
po-docs/uk/Makefile.am to po-docs/language.mk, and use it exclusively
instead of the former contents of the languange-specific Makefile.am.
This way, either adding a new documentation or enabling a new language
will not require copying over the same make code.
Move most of open_guestfs to Types, so a common function to open a
Guestfs handle is available. Since it does not do all the things the
old open_guestfs did, the two operations have been moved to the only
place requiring them.
This function has been placed in Types and not Utils, as will be needed
by other functions in Types; Utils uses Types, so this avoids a circular
dependency.
Use FilenameList as type for lists of file names, as used in some
listing-alike APIs. This way we can ensure anything different than just
file names in those lists is rejected outright.
As a consequence, test-big-dirs.pl does not need to prepend the
directory name anymore before calling listing-alike APIs: previously
they didn't fail, but the returned lists contained only invalid
elements (and only their size was checked).
Furthermore, add a new regression test for it.
We have phony tools for v2v tests, introduced with
commit c1af1ba32f126b7be275bcc8cd4ea4e5af27a88e; make use of it also in
tests related to v2v outside the v2v directory.
I have also removed the text equivalent of this file. Originally I
added this because it was thought good to have the release notes
available in a format that doesn't require any special tools to read.
But:
- POD files are basically text.
- Debian tooling generates the text file in a slightly different way
from Fedora tooling, resulting in git marking the file as being
updated when it isn't really.
- github can format and display POD files.
In this mode, converting of the VM configuration, setting up the
rollback path for error cases, transforming the VM storage and so on is
taken care of by a third-party toolset, and virt-v2v is only supposed to
tune up the guest OS directly inside the source VM, to enable it to boot
and run under the input hypervisor.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Factor out perfoming the actual convertion of the guest, which includes
determinig the appropriate guest os specific conversion module and
running its conversion routine.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Iterating over source disks and creating temporary overlays for easy
rollback fits nicely into a separate function. In addition, determining
their size doesn't need to wait until the guestfs is launched: the size
can be obtained via disk_virtual_size() method.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Opening the source VM and amending the properties in its internal
representation in accordance with command-line options fit nicely into
two isolated functions.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
If Augeas fails to parse a file, more information is available in at
least these fields:
><fs> aug-ls /augeas/files/etc/fstab/error
/augeas/files/etc/fstab/error/char
/augeas/files/etc/fstab/error/lens
/augeas/files/etc/fstab/error/line
/augeas/files/etc/fstab/error/message
/augeas/files/etc/fstab/error/pos
Pull out some of these fields and add them to the error message.
The new error message looks like this:
virt-v2v: error: libguestfs error: /etc/fstab:17:4: augeas parse failure:
Iterated lens matched less than it should
This updates commit 279addeb7d.
In the case where libvirt was installed, but is too old to run the
backend, the libvirt backend would be compiled out but still
referenced by the library.
Fix this by splitting the definition of HAVE_LIBVIRT (libvirt is
installed at all) and HAVE_LIBVIRT_BACKEND (libvirt is new enough to
run the libvirt backend).
Reported by: Efstratios Skleparis.
During the inspection phase, check for errors after aug_load: if any of
the errors happened in any of the requested files, then report the error
straight away; ignoring the error means that information would be
silently lost. For example, a malformed /etc/fstab would have caused
the inspection to not handle any of the additional mount points, giving
cryptic errors later on when trying to access files in any of the mount
points.
Now guests with invalid files such as /etc/fstab, /etc/mdadm.conf, and
/etc/sysconfig/network will cause the inspection to fail, instead of
being reported with a single mount point ('/').
Now that virtio driver copying is localized in a single function and the
auxiliary guestfs handle doesn't leak outside of it (and thus an extra
qemu instance doesn't survive beyond that function's runtime) there's no
need in the forced GC which used to trigger closing of that handle and
termination of that qemu instance.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Refactor copying of virtio windows drivers into the guest so that the
matching of the drivers to the guest os flavor and copying the files
happens one next to the other in a single function, and no guestfs
handle (nor any other irrelevant info) is leaked outside.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Copy the appropriate driver files from the virtio-win storage into
%SYSTEMROOT%\Drivers\VirtIO once they are discovered, and stick to using
those copies later on.
This way the knowledge of where the drivers come from originally is
consolidated in one place, so the lifetime of the associated entities
becomes easier to control (to be implemented in followup patches).
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Move this function to the VCenter module. This is easier since it
doesn't have to do dcPath calculation (see previous commit).
The readhead parameter is no longer labelled.
In libvirt >= 1.2.20, the VMware libvirt driver supplies the correct
dcPath to use via <vmware:datacenterpath> in the libvirt XML. If
libvirt passes us this element, use it.
This code still allows the user to override dcPath using the --dcPath
option on the command line, but that's mainly for safety so we can fix
any problems in virt-v2v or libvirt in the field. As we get more
confident in libvirt and as libvirt 1.2.20 is more widely adopted, we
will be able to deprecate this parameter entirely.
Thanks: Matthias Bolte for adding the <vmware:datacenterpath> element
to libvirt in
https://libvirt.org/git/?p=libvirt.git;a=commit;h=636a99058758a0447482f3baad94de8de3ab1151
libguestfs: trace: v2v: read_lines "/etc/os-release"
[...]
libguestfs: trace: v2v: read_lines = ["NAME=Fedora", "VERSION="20 (Heisenbug)"", "ID=fedora", "VERSION_ID=20", "PRETTY_NAME="Fedora 20 (Heisenbug)"", "ANSI_COLOR="0;34"", "CPE_NAME="cpe:/o:fedoraproject:fedora:20"", "HOME_URL="https://fedoraproject.org/"", "BUG_REPORT_URL="https://bugzilla.redhat.com/"", "REDHAT_BUGZILLA_PRODUCT="Fedora"", "REDHAT_BUGZILLA_PRODUCT_VERSION=20", "REDHAT_SUPPORT_PRODUCT="Fedora"", "REDHAT_SUPPORT_PRODUCT_VERSION=20"]
At this point libguestfs segfaulted.
It seems as if 'major' is not used here, so don't try to free it.
This fixes commit 32d19e3289.
On 32 bit platforms, reading the memory values can cause some numbers
to be read as negative numbers. Fix this by treating memory values as
64 bit integers throughout the parsing and calculation.
The log file was not being closed at the right time, resulting in the
process running out of open files. Also the log filename buffer was
not freed.
This fixes commit 7bbf5cab28.
Set the handle identifier of the main handle to "v2v".
Whenever we open a second handle for any substantial operation, set
the handle identifier for that handle too.
This should make traces clearer.
For that, add autofoo machinery to generate the iso out of the fake
virtio-win drivers introduced in the previous patches, and pass the
resulting image in $VIRTIO_WIN to v2v in a new test otherwise similar to
test-v2v-windows-conversion.sh.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
In order to test the copying of virtio-win drivers into the guest during
v2v, create a set of fake virtio-win drivers and make use of them in the
corresponding v2v tests.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
This option can be used to direct output from each individual
boot test to a different file. Usual usage is:
qemu-boot --log /tmp/output.% -v -x -n 1000
Add a per-handle identifier. The main effect of this is to change
trace output from:
libguestfs: trace: foo
to:
libguestfs: trace: ID: foo
which makes it simpler to follow traces from multi-threaded programs.
v2v/test-v2v-windows-conversion.sh used to query if the expected
directories and files were present in the VM upon conversion; however it
would ignore the results of that query.
That lead to the test passing even though the checks failed.
To fix it, parse the output of guestfish and verify that all is-file and
is-dir commands report the expected "true".
The approach taken is slightly more elaborate than what is being used in
other components, but it allows to generate comprehensible reports in
case of test failure, and facilitates future expansion of the set of
checks including negative ones.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Without rhev-apt.exe the code path where firstboot scripts are created
isn't taken, so it isn't tested and v2v/test-v2v-windows-conversion.sh
is supposed to fail (it actually doesn't but for another reason,
addressed in a followup patch).
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
The tests that depend on rhsrvany.exe being available, actually don't
need it to be the real one: all they want is the file being present.
So, instead of skipping the tests if the real rhsrvany.exe is not found,
store a fake one in the repository, and point $VIRT_TOOLS_DATA_DIR at
its location.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Make sure to close the open files even when test_fuse() returns earlier
because of failures, otherwise the mountpoint is still in use by open
files when later guestunmount is called on it.
** NB: This is an API break for OCaml programs using Guestfs.event_callback. **
Because of the way I implemented Guestfs.event_callback which had the
Guestfs.t handle as the first parameter, we had to store the (OCaml)
Guestfs.t handle in the C handle's private data area. To do that, we
had to create a global root pointing to the handle.
This of course meant that the handle could not be garbage collected
(thanks Roman Kagan for spotting this).
This changes the API of Guestfs.event_callback so that a handle is no
longer passed. The OCaml handle can now be garbage collected again.
For programs that need the Guestfs.t handle in the callback function
(which turns out to be *none* of the OCaml programs we have written),
you can do:
g#set_event_callback (callback_fn g) [Guestfs.EVENT_FOO];
In this case, since the closure passed to Guestfs.set_event_callback
is still registered as a global root, that will capture a reference to
the handle, so the handle won't be able to be garbage collected until
you delete the callback.
These are considerably more efficient than ordinary global roots, but
with the caveat that the program is not allowed to modify them without
calling a special function. We don't modify them, so this change is
safe.
This requires OCaml >= 3.11, but we have that on RHEL 6
(since we dropped support for RHEL 5).
See also:
http://caml.inria.fr/pub/ml-archives/caml-list/2008/03/c3bf86990088236ceeb9a0f0f4c35390.en.html
This is just a straight refactoring. Various ad hoc string_*
functions that appeared in Common_utils have been renamed and placed
in the String.* namespace. The old vs "new" functions are:
string_prefix -> String.is_prefix
string_suffix -> String.is_suffix
string_find -> String.find
replace_str -> String.replace
string_nsplit -> String.nsplit
string_split -> String.split
string_lines_split -> String.lines_split
string_random8 -> String.random8
In Common_utils, override the Char and String modules from stdlib.
This hides the original (stdlib) modules, and means that whenever you
use Char.foo or String.foo you are in fact calling the
Common_utils.Char.foo or Common_utils.String.foo function.
As it stands, this change does nothing, but it will allow us to drop
unsafe functions (like String.lowercase) and add extra functions.
Calling _exit(2) in the child process has the side effect that
tmp/libguestfsXXXXXX is not cleaned up. Clean it up by ensuring the
handle is properly closed before _exit.
This test has been broken for a while. It is meant to test that when
the appliance cachedir is empty, two simultaneous runs of libguestfs
(both rebuilding the full appliance) will not cause conflicts, because
(eg) the locking in either supermin or libguestfs is not working.
However the test only set $TMPDIR, but the ./run script sets
$LIBGUESTFS_CACHEDIR which overrides $TMPDIR, so it was simply reusing
the existing appliance, and hence not testing anything.
Fix this by clearing $LIBGUESTFS_CACHEDIR.
Note the test now takes a lot longer to run since it does a full
appliance rebuild.
Accoding to its documentation [1], it takes as second parameter a
PangoWrapMode and not a GtkWrapMode. While the change should reflect
the actual value intended, it should slightly change the label wrap
mode: GTK_WRAP_WORD is 2, which corresponds (as int value) to
PANGO_WRAP_WORD_CHAR.
[1] https://developer.gnome.org/gtk2/stable/GtkLabel.html#gtk-label-set-line-wrap-mode
There is GUESTFSD_EXT_CMD defining a string for udevadm (so it is marked
as "used tool" in the appliance), but it is not actually used when
starting udevadm.
There should be no behaviour change.
Instead of hardcoding the location of perl (assuming it is installed in
/usr), use /usr/bin/env to run it, and thus picking it from $PATH.
This makes it possible to run these scripts also on installations with
perl in a different prefix than /usr.
Also, given that we want enable warnings on scripts, turn the -w
previously in shebang to explicit "use warnings;" in scripts which
didn't have it before.
Apparently implicitly pulled by something else on Linux, it is not when
building on e.g. FreeBSD.
This reverts the change to this file of
commit 3b17152ec3.
We don't support RHEL 5 upstream (see the 'oldlinux' branch for a
version that works with RHEL 5). Therefore remove a bunch of hacks
that were only needed on RHEL 5.
Because of previous automated commits, such as changing 'guestfs___'
-> 'guestfs_int_', several function calls no longer lined up with
their parameters, and some lines were too long.
The bulk of this commit was done using emacs batch mode and the
technique described here:
http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html
The changes suggested by emacs were then reviewed by hand.
When searching for virtio drivers, it makes no sense to fail if we
encounter a file without extension.
Ignore such files instead, just like we do for the files whose extension
doesn't match that of a driver-related file.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Our documentation of set-label says that labels for btrfs are limited
to 256 characters, while btrfs-filesystem(1) says:
Note
the maximum allowable length shall be less than 256 chars
which is indeed true, as trying to set a label with 256 characters
fails. Hence, fix our documentation to say that the limit is actually
255 characters.
Related to RHBZ#1164708.
Previously we used (on arm): -M virt -machine accel=...
After this change, we use: -machine virt,accel=...
On x86 there is no change.
The -M option is an abbreviation for -machine, and we can combine the
two options together. (Qemu combines the two options internally, but
it's more predictable if we do it ourselves).
Upstream qemu has supported the -machine option for over 5 years, and
in fact we implicitly relied on it (despite what the comment in the
code said).
- fix the syntax of hyperlinks
- replace the deprecation text with a simplier named list item, so it's
more visible
- use a named list item for the pointer to the C documentation of each
API
- add a named list item for the version of each API
If you've ever tried to use this option, you'll know that it didn't
work well. It broke random things (probably RHBZ#1020216, definitely
RHBZ#1023630), and caused random failures generally, while often not
actually failing when valgrind itself found problems.
Commit f6a790b67d changed the Makefile
so it only builds the tests when you run 'make check'.
If you didn't run 'make check' then (in particular) bindtests won't be
built, and so when you install it cannot be removed.
The simple fix for this is to make the removal of bindtests.*
conditional.
This fixes commit f6a790b67d.
Use the generator_built variable to list any files which are built by
the generator. This ensures they get automatically rebuilt.
Three files were missing from EXTRA_DIST, so they were not included in
the tarball, meaning you would have needed OCaml to build from the
tarball. You would have seen this when building:
cd .. && /builddir/build/BUILD/libguestfs-1.31.9/generator/generator
written gobject/docs/guestfs-title.sgml
written customize/customize-synopsis.pod
written customize/customize-options.pod
generated 476921 lines of code
Miscellaneous improvements to the ocamldoc:
- Generate more sub-headings.
- Document the object-oriented API.
- Use a common function to generate the doc for module and OO APIs.
Using 'ocamlfind ocamldoc' is much faster than running 'ocamldoc'
directly, because ocamlfind will run the native code program
'ocamldoc.opt' if it is available.
This change approximately halves the time taken to compile the ocaml
bindings.
Modify the copy-in/copy-out APIs to use the new guestfs_int_cmd_pipe
internal API.
This new API allows us to capture the stderr from the tar subprocess
if it fails, fixing RHBZ#1267032. The user will now see errors like
this:
$ guestfish -N fs -m /dev/sda1 copy-in '/tmp/d/*' / : ll /
libguestfs: error: tar subprocess failed: tar: *: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Anything that doesn't involve pipes [parent-child communication] is
moved into the run_child function, so we can reuse the same code when
writing the new pipe APIs (see following commit). Anything involving
setting up pipes stays in the existing run_command function.
This is just refactoring.
Allow this useful function to be called from elsewhere.
This commit is almost, but not completely refactoring. I made a minor
change to the function so that it \0-terminates the returned data,
which is convenient for some callers.
When building from git, you need OCaml to compile the generator to
build the generated files. Previously configure didn't detect that
situation, resulting in failed builds. This commit causes the
configure script to error out if the generated files are not present
and OCaml is not installed.
Note that you can still build without OCaml, if you get the generated
files from somewhere else. The source tarballs distributed on the
website contain the generated files.
As in commit e102bcf3cf (for Perl), any
Python program has the handle program name field set to 'python'. Set
it to the true name (derived from sys.argv[0]).
When compiling the libguestfs bindings as a pip module, it's helpful
if you can compile the bindings with a different version of libguestfs
(eg. installed 1.28, pip module 1.30).
That broke the previous assumption that we were always compiling
against precisely the same version of libguestfs (which made sense
because the python bindings are part of the libguestfs source tree).
Python distutils has no way to check a C library to find out if
functions are defined. Therefore we have to rely on GUESTFS_HAVE_*
macros from <guestfs.h>.
Previously we only defined GUESTFS_HAVE_* macros for functions that
were not deprecated, test or debug functions. The reasoning for that
is given in this commit message [note that 'LIBGUESTFS_HAVE_' is the
old/deprecated macro]:
commit 2d8fd7dacd
Author: Richard Jones <rjones@redhat.com>
Date: Thu Sep 2 22:45:54 2010 +0100
Define LIBGUESTFS_HAVE_<shortname> for C API functions.
The actions each have a corresponding define, eg:
#define LIBGUESTFS_HAVE_VGUUID 1
extern char *guestfs_vguuid (guestfs_h *g, const char *vgname);
However functions which are for testing, debugging or deprecated do
not have the corresponding define. Also a few functions are so
basic (eg. guestfs_create) that there is no point defining a symbol
for them.
This wasn't in fact carried through very consistently, since when we
replaced s/LIBGUESTFS_HAVE_/GUESTFS_HAVE_/, we kept the old
LIBGUESTFS_HAVE_* macros, but defined them for every function. Oops.
This commit defines GUESTFS_HAVE_* for every function in <guestfs.h>,
making it easier to write the Python language bindings (see following
commits).
Allow the tests to be run on the installed libguestfs.so library and
on installed programs (but not installed language bindings, yet).
To run the tests, you have to have a copy of the libguestfs source
tree with exactly the same version as the installed libguestfs. You
have to build the libguestfs source tree. Then you do:
make installcheck
I investigated making automake 'make installcheck' work, but it's
basically broken (no surprise there).
This is derived from the old 'make-check-on-installed.pl'
script (which is also removed in this patch).
If either zcat or cpio fails when spawned in initrd-list, pclose will
return the actual return value of it, but reply_with_perror still uses
errno regardless; thus, the reported error is:
libguestfs: error: initrd_list: pclose: Success
which is not much helpful.
Instead, when pclose returns > 0, extract the actual return value of the
subprocess, and print that. Thus now we get for example:
libguestfs: error: initrd_list: pclose: command failed with return code 1
It's currently impossible to correctly predict the dcPath parameter
from the data that libvirt gives us. So allow the user to override
--dcpath themselves.
Eventually we will get better support in libvirt for this, and this
option will no longer be needed:
https://www.redhat.com/archives/libvir-list/2015-September/thread.html#00201
This enhances commit 51bc573d0c
and commit 20f1eb400b.
If a Linux guest has /etc/os-release (mandatory for systemd, so all the
recent Linux distributions have it), try to parse it for the distro, its
version, and its product name. If we cannot get all of them, the
detection as done so far continues.
Other than changes in the product_name string (which is free-form
anyway, and already documented to not be parseable), there should be no
regressions in the detected distro and version.
Filter out from the git ls-files output the files we don't care they
appeared (gnulib and intltools stuff), and use comm to only show the
remaining added files (i.e. files not being distributed).
The output of comm is redirected to file and then printed, so we can
check it is empty (failing the target if not).
Add a new "simplestreams" repository type, and a simple parser for
fetching and reading the JSON indexes of the Simple Streams v1.0
format.
Read only datatype=image-downloads contents, and only the latest
versions of each content available as disk image (disk.img or
disk1.img).
Add a simple test, using the "released" images from the CirrOS project.
Check if the Windows guest has Group Policy Objects installed, or one
of several popular pieces of anti-virus software. If we are
installing a virtio block driver, then experience has shown this may
cause a 7B boot failure.
Print a warning when this combination happens.
The warnings look like this:
[ 19.9] Converting Windows Server 2008 R2 Enterprise to run on KVM
virt-v2v: warning: this guest has Windows Group Policy Objects (GPO) and a
new virtio block device driver was installed. In some circumstances, Group
Policy may prevent new drivers from working (resulting in a 7B boot error).
If this happens, try disabling Group Policy before doing the conversion.
virt-v2v: warning: this guest has Anti-Virus (AV) software and a new virtio
block device driver was installed. In some circumstances, AV may prevent
new drivers from working (resulting in a 7B boot error). If this happens,
try disabling AV before doing the conversion.
virt-v2v: This guest has virtio drivers installed.
Change the handling of -ic, -if, -oc, -of, -on, -os, --password-file,
--vdsm-vm-uuid, --vdsm-ovf-output, --vmtype options, so that if any
appear multiple times on the command line we error out:
$ virt-v2v -i disk /tmp/centos-6.img -o null -of qcow2 -of raw
virt-v2v: error: -of option used more than once on the command line
Thanks: Juquin Zhou for finding the bug.
Turns out that some of the Windows guests in the test suite try to
reactivate if the date is more than some time delta (maybe 1 year?)
after the previous activation. Just disabling the network wasn't
enough to prevent this.
qemu allows us to boot guests with the clock set to a particular date
in the past, and libvirt exposes this (albeit very clumsily):
https://docs.fedoraproject.org/en-US/Fedora/18/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Libvirt_Managed_Timers.html
Allow guests to be booted with the date set to a particular past date,
by setting the test_plan.guest_clock field.
This required adding some more libxml2 bindings.
When calling test_connection to test the connection to a conversion
server, we also query for the remote server's version and driver
information (using 'virt-v2v --version' and
'virt-v2v --machine-readable').
However we didn't clear the existing information from previous runs.
One consequence of this was that if you used the back button in the
GUI, the list of output drivers would be repopulated two or more
times. https://bugzilla.redhat.com/show_bug.cgi?id=1227609
Another is that connecting to a different server could confuse
test_connection into thinking the connection was successful (because
of data from the previous run) when in fact it was not.
Thanks: Tingting Zheng for finding the original bug.
Split in an own function the code dong the mounting, the inspection of
the kernel files, and the downloading, including a per-OS function for
the actual kernel files. This gives few advantages:
- the download phease is not repeated for all the files to fetch
- it is easier to eventually support multi-root disk images
- it is possible to support OSes different than Linux; virt-get-kernel
now will just report the unsupported OS, instead of a generic
"no kernel found" message
This is mostly code refactoring, with (on Linux) no actual behaviour
change.
Make print_version_and_exit, long_options, display_short_options, and
display_long_options private, as set_standard_options now takes care of
handling the job for the common command line options.
Move --debug-gc as common option for all the OCaml-based tools, even a
couple of them which didn't have it previously.
As implementation note, make set_debug_gc private to
set_standard_options, as it needed to be moved otherwise, and it is no
more required as public function.
Introduce a new common helper to add the common options for libguestfs
tools (short/long options, version, verbose, trace), and sort them.
All the OCaml-based tools had these options already, so there are no
functional changes in the interface they provide.
The only difference is that now the options are always sorted, while
some tools didn't had them like that previously: because of this, a
couple of ditto markers (as descriptions) don't match what's above them
anymore, and thus their full description is put instead.
When running (eg) dnf on a 32 bit i686 guest when the host is 64 bit
x86_64, dnf believes it is running on a 64 bit machine and so tries to
install x86_64 packages. We can 'trick' dnf into believing it's a 32
bit machine using the setarch program.
$ virt-builder fedora-22 --arch i686 --install 'gperf'
...
[ 27.4] Installing packages: gperf
...
Running transaction test
Error: Transaction check error:
package libgcc-5.1.1-4.fc22.x86_64 is intended for a different architecture
...
The use of a heredoc to solve quoting issues comes from:
http://stackoverflow.com/a/3435460
Thanks: Jan Sedlák for finding the solution.
In -i libvirtxml, -i ova and -o libvirt drivers, replace the ad hoc
xpath_to_* functions with use of the new xpath convenience functions
introduced in the previous commit.
This is not entirely refactoring because I fixed a few bugs found by
type safety.
Previously given a path such as:
vpx://vcenter/Folder/Datacenter/esxi
we calculated dcPath=Folder. However this is obviously wrong. We
should chop the path at the final (esxi) element to give
dcPath=Folder/Datacenter.
In vCenter, the datacenter is identified by a path, and the parameter
used for this is called 'dcPath'. Rename the function to avoid any
confusion about what we're getting here.
This is just renaming function/variable names and has no other effect.
Several tools handle --debug-gc command-line option, by explicitly
forcing GC on every exit path. This is tedious and prone to forgetting
some of the exit paths.
Instead, add a generic handler for --debug-gc, which installs an at_exit
hook to do the GC consistency check, and which can be called right in
the command-line parser. Also adjust all users of --debug-gc to use
that handler.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Build the P2V disk image and boot it. We don't actually use PXE
specifically, but we do test the whole PXE / kernel command line path
much more thoroughly.
This is a 'check-slow' test because it takes ages to run.
When using the virt-p2v ISO in command line mode, we did not wait for
the network to come online before starting virt-p2v. Therefore
virt-p2v could exit with an error when testing the ssh connection (or
on the other hand, it might work randomly). If the user logs in and
runs 'launch-virt-p2v' by hand, then it would usually work because the
network had been brought online in the meantime.
Fix this by waiting for NetworkManager to bring the connection online
before calling test_connection(). Note that the obvious way to fix
this (changing the systemd service to wait for network-online.target)
does *not* work - I added a comment to the service about this.
Thanks: Tingting Zheng
Raise a warning for each kernel specified in grub which does not
actually exist, keep going on with the conversion using the remaining
(existing) kernels.
Put in a list the errnos to expose, filling the content of the
Guestfs.Errno submodule from that.
Also, generate a separate guestfs-c-errnos.c with the implementations of
the functions returning the errno codes.
Only code motion and refactoring, no actual changes on the content of
the ocaml Guestfs module.
pcre < 8 has limitations on the types of partial matching
possible. As noted in the pcrepartial(3) man page, these can
be worked around by adding non-capturing parentheses around
various subexpressions, as I have done here.
Apparently gtk_init_check doesn't (always?) print an error message
when it returns false, so virt-p2v just exits without any message.
This was observed on RHEL 6 when $DISPLAY was not set.
File input_libvirt_other.ml, line 1, characters 0-1:
Error: The implementation input_libvirt_other.ml
does not match the interface input_libvirt_other.cmi:
Class declarations do not match:
class virtual input_libvirt :
'a ->
string option ->
string ->
object
method adjust_overlay_parameters : Types.overlay -> unit
method as_options : string
method virtual source : unit -> Types.source
end
does not match
class virtual input_libvirt :
string option ->
string option ->
string ->
object
method adjust_overlay_parameters : Types.overlay -> unit
method as_options : string
method virtual source : unit -> Types.source
end
A parameter has type 'a but is expected to have type string option
When the output format is qcow2 and -oa preallocated is used,
previously it would only allocate the metadata. That was a regression
over previous behaviour of virt-v2v 0.9. Change it so it allocates
the full file size in this case.
For raw, this allows "off" as a synonym for "sparse" (to make it
consistent with qcow2).
For qcow2, this allows "sparse" as a synonym for "off".
It also adds qcow2 "full" preallocation, which is actually mapped to
the qemu option "falloc" (see arguments about this on the qemu-devel
mailing list, which we lost).
This also updates the test.
Normalize the target architecture, and also each architecture when
checking for a compatible image.
This sort of reverts the effects of
commit 8864c47b94, but at least it is
possible to build e.g. Debian-based amd64 images on any x86_64 system
without being considered as foreign architecture.
Small helper to normalize an architecture string, so it is easier to
compare them and check for compatibilities.
Make use of it in guest_arch_compatible, simplifying it.
If a function name, with its trailing parentheses, is in the
environment , trying to unset it will error out with a message of "not
a valid identifier". Handle this as a special case, and unset it with
the -f option which can handle the parentheses in the supplied
identifier.
It turns out that -- some of the time -- systemd ignores unit files
which are not placed in one of the official unit directories. This
caused the service to be timed out and killed when the systemd daemon
was reloaded, as could happen for long-running package installs at
first boot.
Thanks: Marius Vollmer for diagnosing the problem and finding the
solution.
If the format of the disk image of the template is not specified in the
index, virt-builder would print
Converting auto to qcow2
when asking to generate a qcow2 image. Instead, in this case print only
the destination format, like
Converting to qcow2
I discovered that 'dnf upgrade' doesn't actually upgrade to the latest
versions of packages unless you also supply the '--best' flag.
This also changes update -> upgrade, since apparently 'dnf update'
is deprecated.
Because this 'feature' is broken (since 2013):
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
we have to replace all instances of $(top_srcdir) in *_SOURCES lines
with a relative path. According to what I read, this shouldn't break
split builds, but I didn't test it.
The only things automake moans about now are:
* Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake line 3936.
- This is another bug in automake
* autoreconf: configure.ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION
- This is a feature, not a bug.
dhcpcd requires an interface name as parameter to work. We are now
getting it from /proc/sys/net/ipv4/conf/ folder children. dhclient
on Debian also has the problem, thus use the guessed interface name
for it too.
Instead of rm + touch, just truncate the file if existing.
In case there was no file previously, now nothing is created, as most
probably the system was fine even without it.
Also, turn the single path into a list, so more machine-id files can be
handled at once.
When importing a key, read the list of the valid subkeys of it, and use
it to check whether a signature was done by one of them.
This allows index provides to sign them using a subkey instead of the
main key.
Extend Index_parser.entry to hold a list of checksums to validate, and
validate all of them.
This does change nothing currently, as only sha512 is read, while still
allowing us to fetch more checksums if needed.
Introduce a new Checksums module to handle the check of checksums,
moving part of the Sigchecker code to it.
Adapt the rest of virt-builder to this new module.
When warning that there is no known default password encryption for the
current guest, print also its minor version (help debugging unsupported
guests).
Also, fix wrapping (and indentation) of the message.
I also sorted the list.
Between libguestfs 1.28 and 1.30, the appliance grew from 95MB to 213MB.
Using guestmount and filelight (see link below) I could see that the
main contributor was these two directories, which should not be
necessary.
With this change, the size goes down to 119MB.
See also:
https://rwmj.wordpress.com/2015/07/23/why-has-the-libguestfs-appliance-grown-by-118-mb/
Run `qemu-nbd --help` to know whether it supports --format, and if so
pass it explicitly. This avoids warnings with newer qemu versions,
where they really recommends to explicit the format of disk images being
specified on command line.
virt-p2v looks in /sys/block to find disks, and ignores the hard disk
containing the root device. This is correct when virt-p2v runs off
the ISO, but when running the tests on a machine that has a single
hard disk, all_disks would be NULL, resulting in a test failure.
Fix this by allowing all_disks to be NULL, but adding an extra check
later so that we don't perform the conversion with no hard disks (the
gui.c path already has this check, so it is only needed in the
kernel.c path).
Move the read_password_from_file helper in Password to mllib with a more
generic name, and use it in place of the former.
Also, use it in v2v instead of reading the whole file contaning a
password: given that the documentation says that the whole content is
used, there will not be newlines in the password file, so the behaviour
will be preserved. The oly difference is that newline is no more an
acceptable character for passwords, but that is a really unlikely
(if not impossible at all) situation.
We are no longer planning to ship virt-v2v as an appliance. In RHEL 7.2
it will be included in the base RHEL Server product.
This reverts commit 4e4ece5364.
If UEFI is required by the guest, but not supported by the host, then
you wouldn't see an error message until after copying.
Add an additional method to the output object so we can check this
before copying, to avoid a long wait.
Thanks: Junqin Zhou
https://bugzilla.redhat.com/show_bug.cgi?id=1184690#c22
When converting the old Perl virt-v2v code, I made a silly mistake
with the exception that aug_get throws when it doesn't find any node.
It throws a 'Guestfs.Error' exception, not 'Not_found'.
As a result of this, the exception was escaping and the proper error
message was not displayed. With a malformed grub configuration you
would see this error:
$ virt-v2v -i disk centos-6.img -o null
[...]
virt-v2v: error: libguestfs error: aug_get: no matching node
After applying this patch:
$ virt-v2v -i disk centos-6.img -o null
[...]
virt-v2v: error: no kernels were found in the grub configuration.
This probably indicates that virt-v2v was unable to parse the grub
configuration of this guest.
which is the correct error message.
Updating gnulib has caused -Wformat-signedness to be enabled. This
has revealed many problems in C format strings. The fixes here fall
into the following main categories:
- Using %d with an unsigned parameter.
- %x and %o expect an unsigned argument.
- uid_t and gid_t are unsigned on Linux. The safe way to print these
is to cast them to uintmax_t and then print them using the %ju
modifier (see http://stackoverflow.com/a/1401581).
- Using %d to print an enum. Since enums may be either char or int,
I fixed this by casting the enum to int.
- strtol_error & lzma_ret are both unsigned types.
Pass the target_buses assignment to the output#create_metadata method.
Now output modes have a choice: they can either ignore the new
parameter and continue to use the flat list of targets. This is
suitable for output modes that cannot model multiple buses (eg.
-o glance) or can model it but don't bother (currently -o rhev).
Or they can ignore the flat targets parameter and use the new
target_buses parameter, translating that into the appropriate list of
devices. This is implemented in this commit for these modes:
-o libvirt
-o local
-o qemu
The target VM will have several buses to which disks can be attached.
Commonly it will have an IDE bus, and possibly a virtio-blk "bus" (not
really a bus) and/or a SCSI bus.
Virt-v2v does not model this at the moment. Disks are just added to
the output XML in the order that we write them, and so they can move
around with respect to the target VM.
This commit introduces the idea that we should model the target disk
buses, and we should try to assign fixed and removable disks to slots
on each of those buses. In this commit, the modelling is not used by
any output mode, but that will be fixed in the next commit.
When we see libvirt source XML for a removable drive like this:
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
</disk>
as well as recording the bus (s_removable_controller) as we do at the
moment, also record the slot number (eg. hdc == 2 in the example
above).
Do the same for OVA input files.
They create an own partition layout, so don't do that over the
testing-created layout.
At least for me, this fixes parted issues when creating the new
partition layout and the old one is still reported as in use.
Followup/fix for commit 52d1b0c593.
When cleaning the directories with cron/at jobs, remove only files
there, as subdirectories might be used by other systems; for example
in Debian under /var/spool/cron/ there is the atjobs subdirectory with
the actual at queue.
Make sure to not remove .SEQ files anymore, as they represent the at job
counter which is needed by the at daemon. Instead, reset these files to
0.
Furthermore, add also the path to the .SEQ location in Debian-based
systems.
Collect this small snippet to get the part of a string after the last
occurrency of a character; replace with it the current snippets doing
the same.
Should be just code motion.
When checking if a Windows variant is a server variant, assume it is a
server variant unless the i_product_variant field is "Client".
Windows 2008 and Windows 2008R2 does not have an InstallationType key
in the registry at all, so for these the product variant is returned
as "unknown".
Windows "Core" would have, according to the reference below,
"Server Core".
https://msdn.microsoft.com/en-us/library/ee391629%28v=vs.85%29.aspx
This fixes commit 47b5f245be.
"my" variable $output masks earlier declaration in same scope at /home/libguestfs/tests/daemon/test-btrfs.pl line 66.
"my" variable @r masks earlier declaration in same scope at /home/libguestfs/tests/daemon/test-btrfs.pl line 72.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This refines the previous commit by shutting down the daemon cleanly
at the end of the test (assuming the test was successful). It
repurposes the 'internal_exit' API for this, which was previously used
by the now defunct --enable-valgrind-daemon functionality.
This allows us to test the daemon running as a host process, allowing
us to meaningfully test it using valgrind.
This commit only adds a single test that check that the daemon starts
up, can be pinged, and exits.
Instead of parsing /proc/cmdline from the daemon, move all of that
parsing into the init script, and pass the argument via the daemon
command line.
For example, previously the daemon and init script both looked for
guestfs_network=1 in /proc/cmdline. Now the init script still looks
for it, and if found it runs `guestfsd --network'.
This option, used for testing, causes the daemon to create the Unix
domain socket (from guestfs_channel), listen on it, and accept a
single connection.
We'll now just require that valgrind is new enough.
As best as I can tell from the valgrind subversion(!) repository, this
option was added to valgrind in around 2011.
If you free an xmlDocPtr before any xmlXPathObjectPtrs that reference
the doc, you'll get valgrind errors like this:
==7390== Invalid read of size 4
==7390== at 0x4EB8BC6: xmlXPathFreeNodeSet (xpath.c:4185)
==7390== by 0x4EB8CC5: xmlXPathFreeObject (xpath.c:5492)
==7390== by 0x400A56: main (in /tmp/test)
==7390== Address 0x60c0928 is 8 bytes inside a block of size 120 free'd
==7390== at 0x4C29D2A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7390== by 0x4E8784F: xmlFreeNodeList (tree.c:3683)
==7390== by 0x4E87605: xmlFreeDoc (tree.c:1242)
==7390== by 0x400A4A: main (in /tmp/test)
The following simple test program demonstrates the problem:
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <libxml/xpath.h>
int
main (int argc, char *argv[])
{
xmlDocPtr doc;
xmlXPathContextPtr xpathctx;
xmlXPathObjectPtr xpathobj;
doc = xmlReadMemory ("<test/>", 7, NULL, NULL, XML_PARSE_NONET);
assert (doc);
xpathctx = xmlXPathNewContext (doc);
assert (xpathctx);
xpathobj = xmlXPathEvalExpression (BAD_CAST "/test", xpathctx);
assert (xpathobj);
xmlFreeDoc (doc);
xmlXPathFreeObject (xpathobj);
xmlXPathFreeContext (xpathctx);
exit (EXIT_SUCCESS);
}
In virt-v2v we were not freeing up objects in the correct order,
because we didn't express the dependency between objects at the C
level into the OCaml, where the OCaml garbage collector could see
those dependencies. For example code like:
let doc = ... in
let xpathctx = xpath_new_context doc in
let xpathobj = xpath_eval_expression xpathctx "/foo" in
might end up freeing the 'doc' (xmlDocPtr) if, say, there were no
further references to it in the code, even though the 'xpathobj'
(xmlXPathObjectPtr) remains live.
To avoid this, we change the OCaml-level representation of objects
like xpathobj so they contain a reference back to the higher-level
objects (xpathctx & doc). Therefore holding an xpathobj means that
the doc cannot be freed.
However that alone is not quite sufficient. There is a further
problem when the program calls Gc.full_major, Gc.compact etc., or even
just when xpathctx & doc happen to be freed at the same time. The GC
won't necessarily free them in the right order as it knows both need
to be freed but doesn't know that one must be freed before the other.
To solve this we have to move the finalisers into OCaml code, since
the OCaml Gc.finalise function comes with an explicit ordering
guarantee (that finalisers are always called in reverse order that
they were created), which the C-level finaliser does not.
The 'note:' comment is added, as below:
<Section xsi:type='ovf:DiskSection_Type'>
<Info>List of Virtual Disks</Info>
<!-- note: actual_size field is estimated -->
<Disk ovf:actual_size='7' [...]/>
</Section>
This allows you to append one file to another:
copy-file-to-file /input.txt /output.txt append:true
will append the contents of /input.txt to /output.txt.
This makes several changes to the handling of virtio-win drivers:
The VIRTIO_WIN_DIR environment variable has been renamed
VIRTIO_WIN (but you can still use the old name).
You can point the VIRTIO_WIN either at a RHEL virtio-win directory
(ie. /usr/share/virtio-win), OR at a loopback-mounted virtio-win ISO,
OR at the virtio-win.iso file itself. In the latter case, libguestfs
is used to open the ISO file and read drivers from it.
The code is more flexible about the pathnames of drivers, because the
paths in the ISO are completely different from the paths in RHEL
/usr/share/virtio-win.
Modify the function from a fixed delimiter to a variable. So,
it can be used in more APIs later. Also modified the existing
callers
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Gerd is making EDK2 builds available here:
https://www.kraxel.org/repos/
These are convenient for Fedora/aarch64 users, so use this firmware if
available.
This commit also refactors the UEFI searching code.
In commit 4c73d1d4f1, I changed the
behaviour of virt-v2v so it ignores all errors from the
g#part_get_parttype method. However that would ignore I/O errors and
similar.
Only ignore the "unrecognised disk label" error from parted, by
testing if the return code is EINVAL.
This fixes commit 4c73d1d4f1.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1232241#c3
However adding the -s parameter changes the error code returned by
parted when it processes a blank disk (or other unrecognized partition
table). Without -s it prints an error but returns a non-error exit
code (0). With -s it prints an error and returns an error exit code.
Because it's useful to be able to catch this case in user code, turn
"unrecognised disk label" into EINVAL.
Change virt-alignment-scan to catch this error and ignore it.
Mold split_lines_sb from split_lines, so it returns the strings buffer
with the result of the split. This way, we can have the number of lines
in the array, with no need to count them again later.
split_lines is rewritten to take the ownership of the result of
split_lines_sb.
If we are not interested in output of a command being run, then there's
no need to still capture it in a (automatically freed, but still)
variable.
If any of those outputs is needed, a variable for it can be easily added
back.
Move the "FIXED APPLIANCE" section from
libguestfs-make-fixed-appliance(1) to the "INTERNALS" section of
guestfs(3), so it's more visible and less hidden in the documentation
of a rarely-used tool. Also slightly improve it.
Expand the FAQ question about libguestfs without supermin, mentioning
the build options needed and pointing to the aforementioned new section.
When hitting a filesystem which we cannot or don't know how to expand,
instead of print a warning in verbose mode only, print it always when
showing the summary of the changes.
In the virt-resize documentation, add a paragraph about this warning.
Thanks to: Luigi Toscano.
Extract the guest kernel/ramdisk extraction from virt-builder into a
separate utility, so it can be used and improved without cluttering
virt-builder.
Currently it does what virt-builder --get-kernel did, adding also the
options for remote disks and libvirt access, much like other libguestfs
tools.
virt-builder --get-kernel now just spawns virt-get-kernel.
Done using a sequence of regular expressions like this:
perl -pi.bak -e 's{C</}{F</}g' `git ls-files \*.pod` generator/actions.ml
perl -pi.bak -e 's{C<C:\\}{F<C:\\}g' `git ls-files \*.pod` generator/actions.ml
[etc]
and then tediously checking every change by hand.
This also adds a couple of deliberately undocumented (and unsupported)
command line parameters to make testing simpler:
p2v.skip_test_connection - don't try to test the connection
p2v.dump_config_and_exit - after parsing command line, print it and exit
This updates commit 716244c337.
The sscanf call always failed because we checked for the wrong return
code.
We don't need to allocate two characters for the mem_code field since
sscanf doesn't append a nul byte.
This commit also allows you to use lowercase 'm' or 'g' as a memory
unit.
Also clarify the documentation: the memory unit must be given.
Fix the parsing of /proc/cmdline, including allowing double quoting of
parameters.
This allows you to pass parameters to p2v on the command line which
include spaces.
When convering a POD documentation, possibily combining various
sub-documents together, simplify the L<> links that explicitly point to
the very same documentation being generated.
For example, when generating the virt-builder documentation, links like
L<virt-builder(1)/SECTION>
will be turned into
L</SECTION>
thus not making Pod::Simple parse them as external reference.
While it is a slightly crude hack, it seems there's no easy way to
process the link parsing with Pod::Simple subclasses.
When using the kernel command line to configure virt-p2v, if any p2v.*
parameter appeared right at the end of the kernel command line, then a
bogus \n would be appended. Remove this.
This is essentially the same fix as:
4819655b3c
I'm trying to think if there was any reason why we would have set
g->last_errnum directly instead of using the proper function
(guestfs_int_error_errno), but I cannot think of one.
Since error (g, ...) is just a macro that calls
guestfs_int_error_errno (g, 0, ...), this code is equivalent.
Currently if /tmp (on the host) is a symlink, then the symlink is
copied into the appliance, probably pointing to a non-existent
directory, and everything goes downhill from there.
Avoid this by making sure that /tmp and /var/tmp are real directories.
In newer CentOS 7 versions /etc/redhat-release says that the distro is
derived from RHEL, so we need to look at /etc/centos-release for
actually identifying it as CentOS.
The old code is needed as sub-case of /etc/redhat-release, as on
CentOS < 7 that file is a symlink to /etc/centos-release.
In RHEL-based distros, the provided icons have (obviously) different
sizes than the RHEL ones, used in icon_rhel as reference.
Since 100K should be a reasonable threshold for avoid keeping a
per-distro list of limits, just use it as only size limit.
Add a new guestfs_int_merge_fs_inspections() function that merges the OS
inspection information of two inspect_fs instances into one. This
function is useful if the inspection information for an OS are gathered
by inspecting multiple filesystems.
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
Instead of having virt-p2v-make-disk and virt-p2v-make-kickstart
separately contain a list of the virt-p2v ISO dependencies, combine
the dependencies into a single file ('p2v/dependencies.m4') and use
that to generate the respective dependencies in each script.
After fuzzing 'qemu-img info' I found that certain files can cause the
command to use lots of memory and time. Modify the command
mini-library to allow us to place resource limits on subprocesses, and
use these to limit the amount of space and time used by 'qemu-img info'.
This change was generated automatically using the following Perl
script, with a few hand corrections afterwards.
use strict;
my %map;
open ADDED, "src/api-support/added" or die "added: $!";
while (<ADDED>) {
chomp;
if (/^guestfs_(.*)_(argv|va|opts) /) {
# ignore _argv, _va, _opts entries.
}
elsif (/^guestfs_(compare|copy)_/) {
# ignore guestfs_compare_*, guestfs_copy_* struct functions.
}
elsif (/^guestfs_(.*) [01]\.(\d+)\.(\d+)$/) {
$map{$1} = [1, $2, $3];
}
elsif (/^guestfs_(.*) 0\.(\d+)$/) {
$map{$1} = [0, 0, $2];
}
else {
die "cannot parse line: `$_'\n"
}
}
close ADDED;
open ACTIONS, "generator/actions.ml" or die "actions.ml: $!";
open ACTIONS_OUT, ">generator/actions.ml.out" or die "actions.ml.out: $!";
while (<ACTIONS>) {
chomp;
if (/name = "(.*)";$/ && exists $map{$1}) {
my @v = @{$map{$1}};
$_ .= sprintf (" added = (%d, %d, %d);", $v[0], $v[1], $v[2]) ;
delete $map{$1};
}
print ACTIONS_OUT "$_\n";
}
close ACTIONS_OUT;
close ACTIONS;
In APIs such as guestfs_download, when the FileOut parameter exactly
matches "/dev/stdout" or "/dev/stderr", don't reopen the possibly
redirected output file with O_TRUNC (truncate). Instead dup the file
descriptor.
This magic behaviour doesn't happen for /dev/fd/* (or any other output
file) allowing callers the choice of using /dev/stderr or /dev/fd/2
depending on whether or not they want truncation.
This works around an annoying virt-builder bug. If you do:
$ virt-builder fedora-21 --install no_such_package -v -x >& /tmp/log
then when the `--install' command fails, virt-builder will download
the log file using `guestfs_download (g, log, "/dev/stderr")'. Since
this truncates the redirected /dev/stderr, the final log file is
truncated and corrupted.
With this patch the log file is no longer corrupted.
Previously it was only being pulled in implicitly. However virt-p2v
runs this binary from the "Configure Network" button.
This fixes commit e464774a79.
This patch will add fields of sector size for:
- partition sector data size
- target partition sector data size
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
In cases where we are asked to run commands in the guest (eg. options
such as --run-command or --install), give a clear error in the cases
where the guest arch is not compatible with the host arch.
Similar code existed in virt-builder, but I have removed that. Users
will still get an error message, it will just happen a bit later on.
There is a slight change in semantics here, in that architectures are
no longer normalized when matching, but that's probably fine since
`virt-builder -l' prints the exact arch string that people should use.
When you get an error in tools, it will print a message like:
If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:
virt-v2v -v -x [...]
Only print this message if -v or -x were not already specified on the
command line.
This large commit is just code refactoring. Instead of having
every OCaml tool define 'prog' the same way, always as:
let prog = Filename.basename Sys.executable_name
move that into a single place, Common_utils.prog. Then we can use
that global value everywhere else, instead of having to pass it as a
parameter into a dozen different functions.
The common error function already prints the program name, so
we don't need to print it twice.
Before:
$ virt-resize --expand ""
virt-resize: error: virt-resize: empty --expand option
After:
$ virt-resize --expand ""
virt-resize: error: empty --expand option
This displays the MAC address and vendor next to each network
interface, aiding users in determining which network cards they want
to transfer to the virtualized machine.
The man page for getline says:
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
[...]
If *lineptr is set to NULL and *n is set 0 before the call, then get‐
line() will allocate a buffer for storing the line. This buffer should
be freed by the user program even if getline() failed.
which seems to indicate that we must initialize both line and len to 0
before the first call to getline.
In several places we were not initializing len. The program still
worked fine, but it seems better to initialize the length anyway.
Show partition sector data and target partition sector data
in debug_partition.
Also, if --verbose, call debug_partition again before
parted partitions.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
RWMJ: Changed ~sectsize:sectsize => ~sectsize
Create a single ocaml-link.sh script, which supports a -cclib parameter
so it can be used instead of the per-project link.sh scripts.
As result, the libraries for each OCaml application can be moved back to
each Makefile.am.
The new behaviour is as follows:
Skip all of the fuse tests:
SKIP_TEST_FUSE_SH=1
Individual tests can be skipped by setting:
SKIP_TEST_FUSE_UMOUNT_RACE_SH=1
SKIP_TEST_GUESTMOUNT_FD=1
SKIP_TEST_GUESTUNMOUNT_FD=1
SKIP_TEST_GUESTUNMOUNT_NOT_MOUNTED_SH=1
When running gpg to validate a signature, use also --batch in
non-verbose mode to avoid the extra "Good signature" messages that are
printed by gpg2 even in quiet mode.
We are parsing the status output anyway to check the validation result,
so this should be harmless (and the full gpg output is printed in
verbose mode anyway).
In every SigChecker, trust by default the keys imported.
This should make gpg happier when using the keys later, used only when
validating the signatures of index files.
Since RHEV 3.3, OS variant names like "RHEL6x64" were deprecated and
replaced by names like "rhel_6x64". "RHEL7x64" was never valid, and
we should have used "rhel_7x64". "Windows2012R2x64" was also never
valid and should have been "windows_2012R2x64".
For backwards compatibility, RHEV still understands the old names, and
we still pass them for compatiblity with old RHEV.
However for the new OS variants supported by virt-v2v in RHEL 7.2, use
the new names.
This commit also adds support for SLES and ppc64.
This updates commit 3c51302d69
and also RHBZ#1213324.
This is for consistency with the rest of the documentation.
This commit also adds the files to EXTRA_DIST so they are shipped in
the tarball.
This updates commit 4e4ece5364.
The old version of virt-p2v had a whole custom-written dialog which
interacted with NetworkManager over dbus. After trying that approach,
it's really complex to get right.
Instead this button simply opens NetworkManager's connection editor.
This also adds nm-applet to the disk and starts it. However nm-applet
does not display any visible indication -- probably because we are
lacking a system tray.
Matchbox only supports a single window on screen. This worked fine
until we added the NetworkManager connection dialog -- which tries to
open in a new top level window, and of course fails.
Metacity supports multiple top-level windows so doesn't suffer this
problem.
Apart from that it's hard to tell the difference between the two.
Display a warning if the number of vCPUs or memory selected in the GUI
would be larger than the limits currently supported on RHEL 6 and RHEL 7.
This is just a warning -- the user is free to ignore it and continue
anyway.
This warning does not apply if the selections were made through the
kernel command line, because there is no place to display the warning
for automated conversions.
Add the Types.target_firmware type, which stores our final decision
for whether the guest requires BIOS or UEFI on the target.
Not all output modes support UEFI. In order to fail as early as
possible if conversion isn't going to be possible, there is an
output#supported_firmware method which returns the list of supported
target_firmware.
Add the target_firmware parameter to output#create_metadata so it can
select the correct firmware in the final metadata.
Use a heuristic to detect if the guest could boot with UEFI.
This is only used where we have missing metadata (in the
source.s_firmware == UnknownFirmware case). Currently that only
applies for `-i disk' and `-i libvirt/libvirtxml'.
Eventually we'll be able to get this information from the libvirt
metadata (RHBZ#1217444), so it'll only be used for `-i disk'.
Also modify the input_* drivers so they pull out the firmware from the
metadata. Currently this is only possible for `-i ova', since libvirt
does not expose it (RHBZ#1217444).
Old virt-v2v had a bunch of code for removing EFI configuration from a
Linux guest, and replacing it with grub. I copied this code to new
virt-v2v but it was never tested.
Now that OVMF exists, we can simply boot EFI guests directly on KVM.
Thus these hacks can finally be removed.
This test fails on recent kernels, sometimes.
Apparently calling 'fusermount -u mp' can exit with an EBUSY error,
but still unmount the filesystem. Or possibly guestmount crashes
coincidentally. It's impossible to debug because debugging tools like
strace prevent fuse from working at all.
guestunmount had a -v / --verbose option, but it didn't change the
behaviour of the program in any way.
Make it print the invocations of the underlying fusermount program.
Collect sound card information from the source, and where possible,
create a compatible sound card on the target.
Notes:
* VMware's libvirt driver, and also OVF files, do not appear to
contain any sound card information, so it cannot be collected from
VMware sources.
* Xen does emulate sound cards and makes that information available
through libvirt XML.
* There are no paravirt drivers for sound that I'm aware of.
Therefore we can just copy the same sound model to the target (so
the sound device does not appear to change). If the target, KVM,
does not support the device, it is dropped. But ...
* ... Unfortunately we cannot easily tell which sound cards are
supported by KVM on the target. This is especially a problem for
RHEL, where many sound drivers have been removed. There is a
convenience function, `Utils.qemu_supports_sound_card', which can be
modified by packagers to hard code the list of supported sound
cards.
* If a sound card is dubious / not supported by the target / has any
other problem, then we drop it, since it is more important that the
guest boots on the target than that sound works.
virt-v2v understands relative paths in libvirt XML (even though they
are not legal and libvirt itself wouldn't generate it). We don't need
to generate this file.
Create a version string that includes the "extra" string as well, and
make use of it in print_version_and_exit (which can avoid creating a new
Guestfs handle).
Folloup of commit 478a552ab4.
fstrim is an optimization. If it fails, it's not fatal (although
virt-v2v will run a lot more slowly).
We also expect that it will fail for non-aligned NTFS partitions found
on old versions of Windows, and in that case there's nothing that can
be done about it.
Therefore only emit the warning when we are debugging.
When generating OVF (eg. for -o rhev, -o vdsm) we have to put the
operating system type into a particular field of the output, in a
format that oVirt/RHEV will understand. Add further Windows OS
variants to this list. The variants are derived by examining
ovirt-engine sources.
Thanks: Tingting Zheng for testing Windows conversions to RHEV and
finding this bug.
Rename test-v2v-i-ova-zip.sh (and associated data) to
test-v2v-i-ova-formats, and generalize it a bit so it can test different
compression types for the ova "envelope".
Since I created these with virt-builder without specifying the format,
they have format=qcow2 (not raw). Instead of tediously recreating or
reuploading these images, just change the metadata.
Do not rely on .ovf and .mf files being in the top-level of the ova
archive, but search them anywhere within the content of the ova.
This also changes the result of the search of the .ovf file: previously,
one (random) file was picked in case there were more than one, while now
this situation triggers an error.
Related to RHBZ#1186800.
When dealing with a ova detected as gzip of xz, uncompress few bytes of
it to check whether it is a compressed tarball, and if so untar it.
Related to RHBZ#1186800.
Factor out the connection and pool loading out of v2v_pool_dumpxml, so
it can be used in later implementations requiring a pool.
Should be just code motion.
Read the port configuration from the XML of libvirt domains, restoring
it when writing new libvirt XMLs instead of always setting the
"autoport" option.
Extract them to find out the architecture of the data they hold.
Useful to detect the architecture of e.g. compressed Linux modules.
Provide in the test.iso two samples (compressing existing test data) of
binaries compressed with gzip and xz.
vCenter 5.0 was released in 2011. We have not tested against any
earlier versions, but it was reported that it does not work with
vCenter 4.
Thanks: Sokratis
I don't think it's worth building the test harness as a separate
Fedora package. It just means the harness gets out of date
quickly and is hard to install. Instead the test cases can now
be configured to use the libguestfs source directory to get the
test harness.
Grub2 in RHEL 6 responds to any key including shift keys by entering
the grub menu (and thus waiting for the 'user' to press Enter). This
means our previous strategy of always hitting the shift key before
taking a screenshot didn't work well.
Instead, take a screenshot, if it's all (or mostly) black, hit a shift
key and take another screenshot.
Previously we fuzzy-matched on screenshots of the entire display.
There were several problems:
- dates/times in images required fuzzy matching, but it's not clear
how much fuzz to use (Windows 8.1/2012R2 timestamp is huge,
requiring an enormous amount of fuzz)
- cannot cope with Windows 7 irregular placement of windows on
the desktop
It's better to match on subimages.
This requires some changes to the test data, using gimp to clip the
images and remove any changing elements (dates/times/etc) but in the
long run it's more flexible than fuzzy matching on the whole display.
Note that because of peculiarities in 'compare' we still need to have
a little bit of fuzz in the matching. Seemingly bit-for-bit identical
images still have a similarity > 0.
Take screenshots each time around the loop (every 10 seconds). These
are very useful for debugging.
Check for the final screenshot on every iteration. If the final
screenshot is encountered then the guest is terminated immediately.
Reverse a few loop tests to try to make the code more readable.
unxz --keep fails on the symlinks used by git-annex with this
rather unnecessary error:
unxz --keep 'rhel_511_x86_64_pv.img.xz'
unxz: rhel_511_x86_64_pv.img.xz: Is a symbolic link, skipping
Use xzcat instead.
Make the location of the Windows virtio drivers overridable with the
environment variable VIRTIO_WIN_DIR, in the same vein as is done for
virt-tools.
Signed-off-by: Roman Kagan <rkagan@parallels.com>
Add p_mbr_p_type as member of type partition
to describe mbr partition type.
Currently we use:
List.filter (fun p -> parttype <> MBR || p.G.part_num <= 4_l)
to filter out logical partitions.
Commit 0c396a4bce
introduce API part_get_mbr_part_type,
we could use this to know the part_type.
Furthermore, we could also use p_mbr_p_type for resizing
logical partitions.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Rebuilding the ruby documentation takes 51 seconds on my laptop, and
that's a significant fraction of the entire build. Make sure we only
rebuild the documentation when necessary.
RHEL 5 was unusual in having separate sub-repositories (Server, VT,
Cluster etc) within the main RHEL-5-Server directory. Thankfully no
other version of RHEL does this. Previously we set up the repository
baseurl incorrectly so it didn't include .../Server in the path.
In commit 1a1cb1ec3c, I tried to fix the
RHEL 5 repo location to include .../Server. However that broke the
virt-install --location parameter.
Use a separate baseurl path, which should fix both problems.
This fixes commit 1a1cb1ec3c and
commit 3bc9ba6c84.
The error you would have seen before was:
File "v2v_test_harness.ml", line 1:
Error: The files ../../ocaml/guestfs.cmi and v2v_test_harness.cmi
make inconsistent assumptions over interface Guestfs
btrfs-prog commit:
58a39524619f38d193b8adc3d57888ec07b612aa
change the default output to binary prefix,
and introduced a new option '--raw'
to keep the traditional behaviour.
This patch will add a check function to determine
whether to add '--raw' option to 'btrfs show qgroup'.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Properly skip empty lines before the first section, otherwise they will
trigger a syntax error in parsing.
Add a simple test for it, so it doesn't regress.
Instead of save every time there's a new element in the cache, batch the
saving to disk every 100 changes, saving the unsaved remainder at the
exit.
While not a big optimization, this reduces a bit the disk usage during
generator run.
The --lcontext option was removed from coreutils ls (in 2007, cough).
Fedora carried a patch re-adding these options [I believe
unintentionally], but that patch was dropped in Fedora 23, so the
--lcontext option is gone for good.
This reverts commit f9c5b4aa2a.
Since wallclock time differs between boots, we cannot just compare two
screenshots by checking if they are identical -- if the screenshot
contains any time information, then that will be different, and it
turns out that VMs print the current time at boot.
Therefore parse out and use the "similarity" metric printed by the
ImageMagick "compare" command when it compares the screenshots, and
allow a small epsilon for the case where a few oixels are different.
block.header_size is uint32_t so cannot be compared directly with n (ssize_t).
pxzcat-c.c: In function 'worker_thread':
pxzcat-c.c:602:21: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (n >= 0 && n != block.header_size-1) {
^
This API converts the C guestfs_h pointer to a 64 bit integer,
which should always be possible on reasonable architectures.
Therefore silence a GCC warning (which only occurs on 32 bit ARM).
Fix the 'make check-valgrind' rule in the ocaml subdirectory so it
doesn't run '$VG run-bindtests', effectively running valgrind on bash.
Bash in Fedora Rawhide has added a new memory leak, resulting in a
failure, but we don't want to test bash anyway.
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.
- use <p>..</p> for text paragraphs, instead of just using <p> to
separate them
- slightly improve the metadata in eventToString and set_event_callback
- fix the textual @see in set_event_callback, so it is accepted also in
JDK 8
- escape the doc text, so &, <, and > will not be considered as HTML
tags but actual text
- use the @deprecated tag instead of adding the customary deprecation
note to the doc text
The gnulib 'error' module uses 'program_name'. On some platforms --
but not Linux / glibc -- it references it as:
extern char *program_name;
This means when you compile libguestfs on non-glibc (eg. Mac OS X)
gnulib requires 'program_name' as an external string reference, which
we don't provide.
This change doesn't define this string reference for gnulib, but it
does change the name of the macro we use to avoid conflicts if we
eventually need to export 'program_name' as a string.
Thanks: Margaret Lewicka
When copying disks that use EFI, we created a new partition table,
randomizing the GPT GUID of the first partition. Since EFI may store
the GUID in its NVRAM variables, this could make the guest unbootable.
In GPT, each partition has a GUID assigned randomly. Allow this GUID
to be written and read.
Note this is different from the GUID type code which is used to
identify the type of the partition.
Commit 9135129b0f changed
two stack buffers to pointers:
- uint8_t buf[BUFFER_SIZE];
- unsigned char outbuf[BUFFER_SIZE];
+ CLEANUP_FREE uint8_t *buf = NULL;
+ CLEANUP_FREE uint8_t *outbuf = NULL;
but we were still using sizeof buf to calculate the size of the
buffer. sizeof buf == 8 so the original code which used large buffers
for reading/writing the file changed to using 8 byte buffers.
Currently implemented as guestfish commands, provide them instead as
single source -> destination functions for the library, so they can be
used also in other places.
These functions are not added to guestfish, since guestfish has its own
implementation (which will soon switch to call copy-in and copy-out for
multiple paths).
test-dlopen needs to be added only when libdl is available, and it is
like that already (within if HAVE_LIBDL); hence don't unconditionally
add it as well.
Check whether --part-type is supported (in the rewritten sfdisk in
util-linux >= 2.26), and use it instead of --print-id & --change-id.
The actual result should be the same, just not using a (recently)
deprecated command line API.
Unlike -o rhev which have only one data domin, -o vdsm can and usually
does have multiple data domain.
The path to vdsm is pre mounted so no need to assume nfs path with -os
Example:
-o vdsm -os /rhev/data-center/<data-center-uuid>/<data-domain-uuid>
Bug-Url: https://bugzilla.redhat.com/1176591
Signed-off-by: Shahar Havivi <shaharh@redhat.com>
Kernel 3.19 has problems uncompressing the RAM disk with <= 500 MB.
(This is likely to be a kernel bug)
64 KB pages are common on aarch64, so treat this case the same as ppc,
and use a larger default appliance memory size.
Thanks: Laszlo Ersek for help and reproducing the bug.
Since libguestfs >= 1.26 / supermin 5, the appliance has lived in a
subdirectory of $TMPDIR/.guestfs-$UID. As a result using 'ls -l'
didn't display any information about the files in the appliance.
Using '-R' causes this information to be displayed again.
ls -Z stops ls from displaying the size field. --lcontext uses longer
lines but has the advantage of still displaying the size field as well
as the SELinux context.
It is documented as 'p2v', but in fact this was not implemented
so there is no way to log in as root on the console.
On RHEL we also have to add the 'passwd' package, else you get:
Error creating Live CD : Unable to set unencrypted password due to lack of /usr/bin/passwd
Covert common_utils_tests to use oUnit as testing framework, replacing
the hand-made assert in favour of structured unit tests and better
error reporting.
common_utils_tests is now built only when the oUnit module has been
found.
Pass to --commands-from-file the name of a file containing customization
commands in each line, as if they were specified as command line
arguments.
This eases the reuse of commands among different
builder/customize/sysprep invocations.
When libguestfs is running using TCG on aarch64, we need to pass the
-cpu cortex-a57 parameter to qemu. Libvirt doesn't let us do this,
complaining "Unable to find CPU definition".
As a temporary workaround only, use <qemu:commandline> to pass this
argument directly to qemu. When libvirt is fixed we can remove this
hack.
This is a workaround for libvirt bug RHBZ#1184411.
See:
https://www.redhat.com/archives/libvirt-users/2014-August/msg00043.htmlhttps://bugzilla.redhat.com/show_bug.cgi?id=1184411
AAVMF is an open source UEFI implementation for aarch64 based on OVMF.
As aarch64 is heading for requiring UEFI even inside guests, if the
AAVMF firmware is installed on the host, use it as a hint that we
should boot the guest using AAVMF instead of the default "empty
machine".
Note this requires very recent AAVMF, libvirt, qemu. However that's
OK since it's only applicable to aarch64. On non-aarch64, this patch
does nothing.
Thanks: Laszlo Ersek for a lot of help getting this right.
If "strdup (d->d_name)" fails with "i" > 0, then both "p" and
"ret->guestfs_int_dirent_list_val" are non-null pointers, but the latter
is no more valid (since "p" is the new realloc'ed buffer). Hence, trying
to free both will access to invalid memory.
Make sure to free only one of them, "p" if not null or
"ret->guestfs_int_dirent_list_val" otherwise.
wait_qemu_nbd would fail in Rawhide where /etc/hosts contains:
127.0.0.1 localhost [...]
::1 localhost [...]
This peculiar mapping caused qemu-nbd to always select an IPv6
address. However since we used the obsolete inet_pton function and
forced AF_INET, we were always trying to connect to the IPv4
localhost.
As this was never going to work anyway, fix the code to use
getaddrinfo to resolve "localhost", and use a loop to connect to all
possible addresses.
Also: Add a short sleep in the reconnection loop so that we don't
hammer the qemu-nbd server while it is starting up.
This test launches a dummy guest using IDE. Aarch64 doesn't support
IDE, and because it also doesn't support PCI (virtio-mmio instead)
it's hard to formulate libvirt XML that will work on both x86 and
virtio-mmio.
Since this bug is not architecture specific (RHBZ#912499), skip it on
non-x86. The test will print:
skipping test: arch is not x86 and does not support IDE
Since systemd 209, all the functionalities of the former libsystemd-*
(including libsystemd-journal) have been merged into a single
libsystemd, with the former libraries left as compatibility ones.
Thus, first look for libsystemd, and if not found try again with the
libsystemd-journal as used before.
With commit a594b7f90a the checks for
input and output files with ':' were removed; while the input file is
handled correctly by the disk_create API, an output filename with ':'
could still be handled as specifying a transport, failing the last
"qemu-img convert" call.
Use the new qemu_input_filename helper to handle the output filename
correctly.
It mimics a bit in OCaml the logic used in
commit a95214b198 (for the main library)
and commit 588af1953e (in disk-create),
so in OCaml tools direct calls to qemu/qemu-img with filenames provided
by the user can properly handle filenames with e.g. ':'.
Since mkfifo, mknod_b, and mknod_c add the correct file type to the
modes of the resulting file, make sure the specified mode contains only
permissions bits.
blkid(1) (or actually, libblkid) seems to handle filesystem labels up
to 127 characters. Considering that btrfs labels can be up to 128
characters, this means long labels are not read correctly (i.e. get
truncated) by blkid. Furthermore, ntfs labels are actually unicode,
and libblkid seems to not decode them correctly.
Hence, if ntfsprogs is available invoke `ntfslabel` to get the label
of ntfs filesystems.
Related to RHBZ#1164708.
blkid(1) (or actually, libblkid) seems to handle filesystem labels up
to 127 characters. Considering that btrfs labels can be up to 255
characters, this means long labels are not read correctly (i.e. get
truncated) by blkid.
Get the filesystem type, and if btrfs is available invoke
`btrfs filesystem` to get the label of btrfs filesystems.
Related to RHBZ#1164708.
Add the 'label' optional argument to the mkfs action, so it is possible
to set a filesystem label direct when creating it. There may be
filesystems not supporting changing the label of existing filesystems
but only setting it at creation time, so this new optarg will help.
Implement it for the most common filesystems (ext*, fat, ntfs, btrfs,
xfs), giving an error for all the others, just like set_label does.
Obviously no one reads the FAQ, so make the error message
even clearer.
The new error messages are variation on this:
libguestfs: error: /bin/false exited with error status 1.
To see full error messages you may need to enable debugging.
Do:
export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
and run the command again. For further information, read:
http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
You can also run 'libguestfs-test-tool' and post the *complete* output
into a bug report or message to the libguestfs mailing list.
The test assumed (for no particular reason) that it could always run a
KVM guest. When run on a machine without KVM, or in a VM without
nested KVM, you get this error:
libvirt: Domain Config error : internal error: no supported architecture for os type 'hvm'
Traceback (most recent call last):
File "./t/820-rhbz912499.py", line 77, in <module>
dom = conn.createXML (xml, libvirt.VIR_DOMAIN_START_AUTODESTROY)
File "/usr/lib64/python2.7/site-packages/libvirt.py", line 3523, in createXML
if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirt.libvirtError: internal error: no supported architecture for os type 'hvm'
FAIL: ./t/820-rhbz912499.py
Use a qemu guest instead, which should have a better chance of working
on all hosts.
Builds of bison-generated files currently fail with:
index-parse.y: In function 'yyparse':
index-parse.c:1256:6: error: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Werror=strict-overflow]
if (yyss + yystacksize - 1 <= yyssp)
^
This error only occurred on one machine, and it was unclear why. It
turned out to be because the other build machines I use had:
CFLAGS="-Wall" ./configure ...
whereas on the failing machine I was just using ./configure w/o CFLAGS.
This caused the compile flags of index-parse.c to be changed from:
gcc -Wstrict-overflow ... index-parse.c
to:
gcc -Wstrict-overflow -Wall ... index-parse.c
but since -Wstrict-overflow is short for -Wstrict-overflow=2, and
-Wall is short for -Wstrict-overflow=1, and since the error only
occurs at level >= 2, using CFLAGS="-Wall" was effectively turned off
the warning.
Anyway, I believe the optimizations that GCC does when
-fstrict-overflow is enabled to be dubious, frequently dangerous, and
useless. They are only done because we want C99 to work on
architectures that don't exist in reality (and which even if they did
exist, libguestfs would probably not support).
The Linux kernel uses -fno-strict-overflow, and we should too, for the
same reasons.
Normally this requires the program to have at least one C source file.
virt-sysprep doesn't have this, but it uses C sources from other
directories, and therefore we can make it work.
This returns the C pointer to the guestfs_h handle (ie. guestfs_h *).
The purpose of this API is to interwork with other non-C libraries.
See RHBZ#1075164 for the rationale when applied to another library.
This allows the Perl binding of guestfs_add_libvirt_dom to work.
This relies on the internal Perl representation of virDomainPtr, but
Dan assures me this isn't going to change.
Commit 96158d42f5 enabled the previously
private guestfs_add_libvirt_dom API. It also tried to enable the
existing test for this API, but failed to do that correctly. Also the
test was broken. Fix all of this.
This fixes commit 96158d42f5.
YACC index-parse.c
index-parse.y:97.34-41: warning: type <fields> is used, but is not associated to any symbol [-Wother]
%destructor { field_free ($$); } <fields>
^^^^^^^^
index-parse.y:95.36-45: warning: type <sections> is used, but is not associated to any symbol [-Wother]
%destructor { section_free ($$); } <sections>
^^^^^^^^^^
We had code (added for RHBZ#912499) which labels overlay files
correctly so that libvirt can read them. Unfortunately this code was
broken by subsequent commits: the new backend setting for the
imagelabel is only copied to the 'data' struct during launch, but the
create_cow_overlay callback is called before launch (when adding
drives).
The fix is easy: ensure create_cow_overlay_libvirt checks for the
backend setting and initializes the 'data' struct.
This change also means we need to free (data->selinux_imagelabel)
before setting it in launch (and we do the same for
data->selinux_label, although that's not strictly necessary).
For background on this, see:
https://bugzilla.redhat.com/show_bug.cgi?id=912499#c10
This allows the Python binding of guestfs_add_libvirt_dom to work.
There is a regression test to ensure this keeps working.
Note this requires a patched libvirt-python, supporting the
c_pointer() method.
This API already existed (as guestfs___add_libvirt_dom), and was used
by a few tools.
This commit changes it to a public API.
Note that for reasons outlined in the previous commit message, it is
impossible to call this from guestfish or from non-C language
bindings.
This implements Pointer arguments properly, at least for certain
limited definitions of "implements" and "properly".
'Pointer' as an argument type is meant to indicate a pointer passed to
an API. The canonical example is the following proposed API:
int guestfs_add_libvirt_dom (guestfs_h *g, virDomainPtr dom, ...);
where 'dom' is described in the generator as:
Pointer ("virDomainPtr", "dom")
Pointer existed already in the generator, but the implementation was
broken. It is not used by any existing API.
There are two basic difficulties of implementing Pointer:
(1) In language bindings there is no portable way to turn (eg.) a Perl
Sys::Virt 'dom' object into a C virDomainPtr.
(2) We can't rely on <libvirt/libvirt.h> being included (since it's an
optional dependency).
In this commit, we solve (2) by using a 'void *'.
We don't solve (1), really. Instead we have a macro
POINTER_NOT_IMPLEMENTED which is used by currently all the non-C
language bindings. It complains loudly and passes a NULL to the
underlying function. The underlying function detects the NULL and
safely returns an error. It is to be hoped that people will
contribute patches to make each language binding work, although in
some bindings it will always remain impossible to implement.
This didn't work at all because the regular expression did not match
the returned Augeas path.
In future if the regular expression doesn't match, this will give an
internal error instead of continuing with a bogus value.
Thanks: Junqin Zhou for providing the test case and debug information.
Regular EFI disks have /EFI on the first (VFAT) partition, but they
are not installers.
Fix this by only considering something to be an installer if it has a
single partition (or whole disks like ISOs).
Implementing this is quite complex since when checking a filesystem,
we don't have information about whether we are even looking at a
partition, nor about whether it's the first partition out of how many.
The majority of the commit is changing the code to collect that
information.
Because of the size of an extended partition reported by Linux is always 1024
bytes, so it will always fail to copy to an extended partition.
This patch fixes this problem by copying to the offset of an extended
partition in the destination disk.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Wait up to 10 seconds for qemu-nbd to start up and respond to clients.
Otherwise the conversion server may attempt to connect before qemu-nbd
is ready to serve it.
After a very long and trying episode with a Windows guest that refused
to boot after conversion, we managed to successfully boot it by
disabling Windows Group Policy. It appears that Group Policy
prevented the virtio driver from being used.
Document this in the manual.
Prior to this commit the distro for a FreeBSD or a NetBSD system, in
conjuction to what happened for OpenBSD, was shown as 'unknown'.
*BSDs are complete OSes, not a kernel like Linux, but theoritically you
could have FreeBSD as ostype and PC-BSD as distro.
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
Take into granted that partition 'c' has a special purpose. It has
always the same size as the enclosing slice and is not mapped under
Linux.
This is a best effort try. The mapping will be incorrect if there is a
gap in the disklabel partitions sequence, e.g. 'b' (swap) partition is
missing but 'd' partition is defined.
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
Make a best effort try to map NetBSD disklabel partitions to Linux
partitions. The mapping will be incorrect if there is a gap in the
disklabel partitions sequence, e.g. 'b' (swap) partition is missing but
'e' partition is defined.
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
This patch lets guestfish show command synopsis if the syntax of command issued
by user is wrong, rather than telling user that the number of parameters is wrong.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
The assumption that Linux will map the MBR partition to /dev/sda1
and the BSD 'a' partition to /dev/sda5 is not always correct.
Signed-off-by: Nikos Skalkotos <skalkoto@grnet.gr>
Because get-uuid looks more like a counterpart to set-uuid, and is
more likely come to mind if one knows set-uuid.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Just like --long-options, it makes it possible to know which short
options are supported by each tool; this can help improving the bash
completion, for example.
As contrast to shortdesc which is forced to begin with lowercase, this
patch forces longdesc to begin with uppercase.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Commit 588af1953e started with a very
conservative list of permitted backing formats (just "raw" or
"qcow2"). We can allow almost any format permitted by qemu, but this
commit just adds "vmdk" to this whitelist.
Include the version of virt-p2v and its MD5 checksum in the source
kickstart. This is useful for working out which version of virt-p2v
the kickstart corresponds to.
This relies on the remote to keep sending us data. If it hangs, then
the cancel button won't work. This could also be fixed by introducing
a timeout to the read syscall.
I was fetching cancel_button from the wrong dialog (conv_dlg, not
run_dlg), and therefore getting the wrong button.
This explains why the back button on the conversion dialog was always
insensitive. It's because cancel_button was assigned to this button,
and then I was setting cancel_button to insensitive.
It did nothing and was left over from an earlier attempt to add
fullscreen mode. That is not needed any longer since we now run
virt-p2v under the matchbox window manager.
The <target dev> attribute in libvirt isn't very informative. What we
really want to know is whether the source disk used IDE or SCSI, as
that allows us to remap block devices accurately during conversion.
For example, if the source was IDE and RHEL 5, and after conversion
virtio will be supported, then we know that we need to remap
"/dev/hda" to "/dev/vda".
Drop the s_target_dev and s_removable_target_dev fields and replace
them with s_controller and s_removable_controller.
For -i libvirt, use the <target bus> attribute to get this information.
For -i ova, use the OVF disk controller's ResourceType.
(http://blogs.vmware.com/vapp/2009/11/virtual-hardware-in-ovf-part-1.html)
If /etc/favicon.png is a symbolic link, follow it.
Unfortunately RHEL 7 and Fedora have crappy 16x16 /etc/favicon.png
symlinks in the base distro. It would be nice to ignore this symlink,
but it's almost impossible to determine if the symlink is part of the
base distro or was added by the user. (This is a bug in those
distros.) virt-inspector and virt-mananger both ignore favicons.
Commit fd70cdc3c5 passes the -annot flag
to the compiler, generating *.annot files (containing type information
used by emacs and IDEs). Remove these files when doing 'make clean'.
Use AS_CASE to properly map from the host cpu to the qemu cpu suffix;
this avoids doing multiple string replacements using sed, and it is
possible to use case-like syntax.
Hardcoding -ltinfo breaks on distros that do not build the sep library
(which is the default ncurses behavior). Use pkg-config to look up the
right libraries regardless of how the distro built things.
The labels 'hw_disk_bus' and 'hw_vif_model' were swapped. This
happened to work for virtio guests. For non-virtio guests you ended
up with absurdities like requiring an rtl8139 driver for the disk.
Thanks: Junquin Zhou
Previously we used to try to find the 'vmlinuz' file by running 'rpm
-ql kernel' and looking for any file called 'vmlinuz-*'.
If there were multiple 'kernel' packages installed, the rpm command
would list files from all of them, resulting in a random 'vmlinuz-*'
being chosen, not necessarily the one corresponding to the kernel
package we were looking at.
Use 'rpm -ql kernel-<VERSION>-<RELEASE>' instead so that we only look
for files in the right kernel package.
Thanks: James Mighion
In tools except guestfish, we don't use ncurses, or even curses, just
2 termcap functions and a global variable. These are provided by
libtinfo, so just link to that.
In guestfish we use readline which needs ncurses. Leave that alone.
md5sum(1) does not exist everywhere, so wrap it in an own function so
the right implementation can be chosen on each OS. Also, wrapping it
avoid using awk everytime.
Query RbConfig::CONFIG for "libdir", and use that when trying to link to
the ruby library. This fixes the libruby detection when it is installed
in a non-standard library directory.
Create an autoconf macro to deal with the possible combinations of names
and versions of the libdb tools. This also eases the addition of a libdb
version, or a new pattern for the names of tools.
There is no functional change.
Use a %top block for including <config.h>, so it is included prior to
any other include, even for system ones. This makes sure its definitions
are properly used in gnulib replacement headers.
Do a configure check to see whether UNIX_PATH_MAX is defined; if it is
not defined, provide it with the size of sun_path in the struct
sockaddr_un, thus with the proper size for any libc.
Use CLEANFILES to remove the generated symlinks, and just ignore the
errors when copying the scripts in srcdir!=builddir situations.
Followup of commit 40ac54829d.
If a script does not finish, hangs, etc, it would be executed again at
the next boot, since the injected firstboot.sh helper removes it only
after it finished.
Before executing a script, move it to another internal subdirectory
(scripts-done) and execute it from there, so it is not run again by
firstboot.sh. The downside is that now scripts are executed only once
at all, so if a script fails it will not be attempted at the next boot.
Also, remove all the files found in scripts-done, as they have been run
(or at least attempted) in a previous boot.
This fixes RHBZ#1159651.
This adds a customize option:
virt-customize --ssh-inject USER
virt-customize --ssh-inject USER:string:KEY_STRING
virt-customize --ssh-inject USER:file:FILENAME
(ditto for virt-builder and virt-sysprep)
In each case this injects into the guest user USER
a) the current (host) user's ssh pubkey
b) the key specified as KEY_STRING
c) the key in FILENAME
adding it to ~USER/.ssh/authorized_keys in the guest.
For example:
virt-builder fedora-20 --ssh-inject root
will add the local user's ssh pubkey into the root account of the
newly created guest. Or:
virt-customize -a disk.img \
--ssh-inject 'mary:string:ssh-rsa AAAA.... mary@localhost'
adds the given ssh pubkey to mary's account in the guest.
This doesn't set the SELinux labels correctly on newly created files
and directories, so you have to use --selinux-relabel (probably we
should fix this as part of the general effort to fix SELinux
relabelling). However it should preserve the labels if the
~/.ssh/authorized_keys file already exists.
Most of this work is based on a patch sent to the mailing list by
Richard W.M. Jones <rjones@redhat.com>:
https://www.redhat.com/archives/libguestfs/2014-November/msg00000.html
Since the daemon has long since used the same build system as the rest
of libguestfs, it no longer needs its own gnulib.
This arcane bit of code was left over from
commit e05ddc70f1 (added 2009-08-03 !)
Implement the GUESTFS_ADD_DRIVE_OPTS_SECRET argument of
guestfs_add_drive_opts. For libvirt we have to save the secret in
libvirtd first, get a UUID, and then pass the UUID back through the
domain XML.
On filesystems whose dirent.d_type is DT_UNKNOWN or some unknown value,
manually check whether an entry is a directory, thus completing in the
proper way.
Instead of passing the (uri, key, proxy) tuple around, pass the whole
Sources.source record; this requires creating proper Sources.source also
for uri+fingerprint passed via command line.
No functional changes.
Instead of making up an ordinary curl command line, write a temporary
config file and use 'curl --config tmpfile' to pass the arguments.
The advantage is that it's more secure if we want to supply passwords
to curl, since a '--user username:password' parameter on the command
line could be read (eg. by 'ps ax'), but the temporary file has mode
0600 and cannot be read by other users.
This is mostly code motion, but it also passes the '-q' option to curl
to stop it from reading default configuration files.
Must NOT use:
- One of the interim versions of virt-v2v (1.27.x) that we published
during development.
- Old virt-v2v (0.9.x).
Also use the --version option (instead of -V) since old virt-v2v
required it:
$ virt-v2v -V
Option v is ambiguous (version, vmtype)
Usage:
[...]
$ virt-v2v --version
0.9.1
Include the usb-storage kernel module, to permit booting from USB
keys.
Rerun dracut to rebuild the initramfs. This is complicated because by
default dracut will try to build an initramfs for the running
(ie. appliance) kernel, which is completely useless. We need to find
the latest installed kernel and rebuild the initramfs for that
instead, which is hairy.
This also does a small refactoring of the distro-specific code,
removing the $selinux_relabel variable and replacing it with a generic
$extra_args variable.
I only added this to the virt-builder script, since one assumes that
livecd-creator/whatever should make the kickstart ISO bootable by
installing whatever drivers and modules are necessary.
Running 'dracut -f' installs a dracut for the running kernel (of the
appliance) not the installed kernel. Stupid stupid stupid.
This reverts commit 7a6d44ebfe.
I only added this to the virt-builder script, since one assumes that
livecd-creator/whatever should make the kickstart ISO bootable by
installing whatever drivers and modules are necessary.
Add common error/warning/info functions.
Examine every existing call to printf/eprintf and change where
necessary so that:
- error is used instead of eprintf + exit 1
- warning no longer needs ~prog argument (it is added by Utils module)
- any verbose output should go to stdout, not stderr
- info is used to print general informational messages
Also, don't indent summary of changes.
Add a Customize_utils module. This contains common error/warning/info
functions, and also quote = Filename.quote.
Examine every existing call to printf/eprintf and change where
necessary so that:
- error is used instead of eprintf + exit 1
- warning no longer needs ~prog argument (it is added by Utils module)
- any verbose output should go to stdout, not stderr
- info is used to print general informational messages
Also, don't pass ~prog parameter around. Instead we just get it from
the executable name.
Add a Utils module. This contains common error/warning/info functions,
and also quote = Filename.quote.
Examine every existing call to printf/eprintf and change where
necessary so that:
- error is used instead of eprintf + exit 1
- warning no longer needs ~prog argument (it is added by Utils module)
- any verbose output should go to stdout, not stderr
- info is used to print general informational messages
get_current_dir_name exists on GNU libc only, so not portable.
On the other hand, while POSIX leaves a null buffer argument for getcwd
as unspecified behaviour, basically the most used/important Unix
implementations (GNU libc, FreeBSD's libc, etc) allow such value,
returning a new allocated buffer with the current directory.
In any case, the change just affects two tests, so even if it hits a
libc not implementing this behaviour for getcwd, only tests are
affected.
uri-c.c and perl_edit-c.c end up (directly or indirectly) including
guestfs-internal-frontend.h, which in turns includes libvirt/libvirt.h;
hence, make sure to use the libvirt CFLAGS.
Add a IfNotCrossAppliance prereq for tests, so a test using it can only
be run when the appliance is a copy of the running host system; this can
help marking tests which run stuff (usually built in the host) inside
the appliance.
Since the signature of iconv() changes between implementations (the
constness of the second parameter, in particular), make use of the iconv
module of gnulib to handle these potential differences, including an
external (out of libc) iconv implementation.
Previously I modified the parse_libvirt_xml function to get rid of the
awkward 'map_source*' functions, and have the callers map over and
modify the source disks afterwards. However this broke the case where
an "nbd:..." URL was returned by parse_libvirt_xml, since the callers
might try to map this URL (eg. turning it into an absolute path).
This broke virt-p2v specifically.
This commit changes parse_libvirt_xml to return a list of tuples
containing disk information, giving the callers more information with
which to do the mapping.
This fixes commit 3596165282.
Take the opportunity presented by the refactoring in the previous
commit to inline and simplify functions in these input subclasses.
This finally removes the map_source* functions.
This refactors the code into more logical units, based on the previous
commits. So Xen + the input_libvirt Xen code is grouped and moved
into a new module called Input_libvirt_xen_ssh. Similarly VCenter +
input_libvirt vCenter code is moved to Input_libvirt_vcenter_https.
There is no change here, purely code motion.
Previously we fixed RHBZ#1151033 by increasing the cURL readahead
parameter to a large value. Unfortunately this is too large -- and
hence slow -- for the conversion phase, which broke on slow vCenter
servers (RHBZ#1153589).
What we do now is to perform the conversion phase with the default
readahead (2MB) to ensure stability, since performance of the
conversion phase is not critical. Then before copying we change the
readahead to the larger value (64MB) to ensure efficient copying.
This is called before the copying phase to allow the input method to
adjust overlay/backing parameters.
The default implementation does nothing, so this commit has no effect.
Note that it doesn't matter what the number is, as long as it's
different for each disk.
The unique number lets us store extra data in input objects which is
associated with each disk.
Get rid of the awkward map_source* functions, and replace it with
equivalent code which modifies the source disks objects coming back
from Input_libvirtxml.parse_libvirt_xml.
This is just code refactoring. Apart from the order in which certain
tests are done, this should be equivalent to the previous code.
Previously we had one class ('input_libvirt') which handled all three
cases. Now we have one superclass ('input_libvirt') and three
subclasses of that ('input_libvirt_vcenter_https',
'input_libvirt_xen_ssh', 'input_libvirt_other') which handle the three
cases separately.
This is just code motion, and should be functionally equivalent to
what was here before.
Unfortunately udev removed the udevtimeout setting on the kernel
command line. This means the default timeout was being set back to 30
seconds, which is way too low for remote disks.
However it was re-added (2014-07-29) as udev.event-timeout. Set both
to be sure.
Note this requires systemd >= 216.
In full_path, skip the trailing slash in the base directory when
different than "/", as the slash will eventually be added when building
the resulting path.
Make sure to output the field for checksum even for non-regular files,
as empty, in CSV output mode. This ensures each line has the same number
of fields, regardless of the file type.
OVA is not a particularly well-specified format. The specification
allows a directory to be an OVA, so enable that. The spec doesn't
mention that ZIP can be used in place of tar, but since we have seen
these in the wild, allow that too.
The way to fix these bugs -- for future reference -- is as follows:
(1) Install the corresponnding Windows version with virtio enabled.
See:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/chap-KVM_Para_virtualized_virtio_Drivers.html
(the ".vfd" method)
(2) Download the SYSTEM and SOFTWARE registries from the
virtio-enabled guest.
(3) Examine each registry using 'hivexsh', especially the keys which
we modify during virt-v2v (see v2v/convert_windows.ml). Remember to
use both the 'ls' and 'lsval' commands in hivexsh.
(4) Download the SYSTEM and SOFTWARE registries from the guest that
fails to boot.
(5) Examine the same registry keys from each registry using 'hivexsh'.
(6) Work out what the differences are, paying particular attention to
quoting and the type of each key (eg. str(1), str(2), etc).
Thanks: Matthew Booth.
There were two large bugs before: (1) It only found one manifest file
(meaning that multi-volume OVAs would be broken). (2) The regular
expression didn't work so it wouldn't check the hash. Bugs (1) + (2)
combined so that the check just didn't do anything at all, which is
why we didn't notice the multi-volume problem.
Actually I suspect we shouldn't be doing this check at all, since I
bet there are OVAs out there with broken SHA-1's.
Ignore an environment variable:
- if an environment variable is an empty string, AND
- if an empty string would have no meaning for that environment
variable (eg. LIBGUESTFS_BACKEND can only take on certain values,
and an empty string is not one of them).
Note that LIBGUESTFS_BACKEND_SETTINGS is meaningful as an empty
string, and for this case I have removed the STRNEQ (str, "") test.
Previously:
$ LIBGUESTFS_BACKEND="" guestfish -a /dev/null run
libguestfs: error: invalid backend:
After this commit:
$ LIBGUESTFS_BACKEND="" guestfish -a /dev/null run
(no error message is printed)
Remove the common 'add_resource' function.
Duplicate that function into code for adding disks, and separate code
for adding removables (floppies & CDROMs).
The removables code should look for all removable devices
(ResourceType 14, 15, 16) in a single query, so that the order doesn't
depend on the order in which we do the queries.
If the user does ^C then this leaves temporary overlay files around
(possibly a bug?). Offer an 'exit' choice to the user which exits
cleanly.
The new message looks like this:
Dual- or multi-boot operating system detected. Choose the root filesystem
that contains the main operating system from the list below:
[1] /dev/sda3 (Fedora release 20 (Heisenbug))
[2] /dev/sdb3
Enter a number between 1 and 2, or 'exit': exit
Improve the homebrew JSON writer:
- add more types (including also nested dictionaries and lists)
- format in a compact way (single line), or indented (multilines)
When copying from file to file, don't leave the destination file
around if the copy fails.
However in the same code don't try unlinking the destination device on
failure.
We never updated the no_trim variable in the case where this option
was supplied, so it never did anything, proving once again that unless
you have a test case, the feature won't work.
When translating the original virt-v2v code, I misunderstood how image
directories are created. There is one directory under images/ per
disk image, not one for all the disks in a single guest.
Note this requires that -o vdsm uses multiple --vdsm-image-uuid
options, one per disk image of the guest.
Reported by: Alain Vondra
Thanks: Tingting Zheng
virt-log uses /dev/stdout as output file for guestfs_download, which
will open the output file in truncate mode, truncating the output of
test-virt-log.sh.
Make sure to redirect the output of virt-log so it does not clobber the
test output.
Thanks to Richard for the hint.
Additional information about URIs, which may contain cluster and/or
folder names (thanks: James Mighion).
Replace esx.example.com with vcenter.example.com to reduce confusion
about vCenter vs ESXi.
Since procps 3.3.10, free does not output the "-/+ buffers/cache" line
anymore. On the other hand, the data from it can be calculated from the
memory values, so just do the calculation manually (with awk).
This effectively demotes UML to unsupported status. This has happened
because UML has regressed quite a lot upstream. There are multiple
grave bugs revealed by running the test suite and I don't have the
inclination to fix them.
When using the libvirt backend, don't use the SLIRP. Use
qemu-bridge-helper via libvirt to give us a full network connection.
One consequence of this is that 'ping' works in
'virt-builder --run-command'.
A less useful consequence is that the host firewall will prevent
connections on non-standard ports to the host. So you can't (eg)
connect to a rsync daemon on the host listening on an arbitrary port,
which worked before.
The default bridge is 'virbr0', but you can override this by setting
LIBGUESTFS_BACKEND_SETTINGS=network_bridge=<some_bridge>
Note: this does not fix virt-rescue (since it overrides the default
backend and uses 'direct' for various reasons).
qemu in SLIRP mode offers DHCP services to the appliance. We don't
use them, but use a fixed IP address intead. This changes the
appliance to get its IP address using DHCP.
Note: This is only used when the network is enabled. dhclient is
somewhat slower, but the penalty (a few seconds) is only paid for
network users.
On SuSE or other distros, dhcpcd could be used if available.
The previous tests were very limited, and ran the same two tests
on every run.
Randomly test:
- MBR vs GPT
- Primary, extended partitions
- Expanding vs shrinking
- Use of multiple --resize parameters
- Source and target raw vs qcow2 formats
- Resizing various different filesystem types
- LV expand
- extra partition or no extra partition
To run the test over and over again (useful for finding regressions in
virt-resize), do:
while (cd resize; LIBGUESTFS_TRACE=1 ../run ./test-virt-resize.pl) >&/tmp/log ; do echo -n .; done
If it fails, you can see the failure in /tmp/log.
To rerun a specific test, search for the 'seed:' in the output of the
original test, and specify it on the command line:
(cd resize; ../run ./test-virt-resize.pl --seed=<SEED>)
When saving a configuration file, Augeas creates a new file and
replaces the old one with it; this creates a /etc/shadow file without
the SELinux xattrs, since they are missing.
Thus, create a temporary file with all the attributes of /etc/shadow, so
all the attributes of it (permissions and xattrs, among others) can be
restored properly on the new /etc/shadow.
As side effect, if a guest is already properly SELinux-labelled, then
there should be no more need to relabel it to make sure /etc/shadow
still has the right SELinux xattrs.
This should be equivalent to the previous code, but it makes it easier
for the compiler to pick up errors (eg. missing cases).
This updates commit fc34e2d16c.
Function mbr_part_type returns one of "primary", "extended" and
"logical". The type is used by parted when adding partitions.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
And introduce parameter create_surplus to indicate whether to
create surplus partition or not. Later this parameter will be
used by when calculating positions for target logical partitions.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Old virt-v2v probably emitted the same warning.
However it seems unlikely that /dev/cdrom needs to be remapped, as
udev or the user should be able to supply a suitable symlink from
/dev/cdrom to the removable device. Therefore suppress this warning.
Switch from acl_to_text to acl_to_any_text, so it is possible to specify
options, like forcing the numeric IDs for users/groups. This ensure the
resulting string has always numberic IDs, so the comparison can always
succeed.
Adapt the comparison string to the lack of final endline now.
You can use this to accelerate testing:
$ virt-v2v --no-copy --debug-overlays [etc]
[...]
[ 82.0] Converting Windows 7 Ultimate to run on KVM
This guest has virtio drivers installed.
[ 86.0] Closing the overlay
[ 91.0] Creating output metadata
Overlay saved as /var/tmp/win7-test-sda.qcow2 [--debug-overlays]
[ 91.0] Finishing off
No disk format conversion/copying is done, so it's very fast.
The overlay file is preserved and can be tested directly (it uses the
source file as backing).
It's not really necessary: we have never needed this for debugging
inspection for example, and if hive open failures did occur we would
ask the user to send us the hive files. And it causes huge amounts of
debugging messages to be printed which fills up the log.
Old virt-v2v did not remap this device, so after conversion from Xen
the file would have something like:
boot=/dev/xvda
Although this does not appear to affect anything, better to remap it.
Otherwise you get lots of errors like:
rm: cannot remove ‘/var/tmp/mm/42f5e571-21af-44bd-8164-3ebe6bbc9f5a/images/7b28b0e6-79ce-4d78-a6cb-769760a3d373/31e2b06b-85cb-46ed-aac3-8bcef93dc704.meta’: Permission denied
rm: cannot remove ‘/var/tmp/mm/42f5e571-21af-44bd-8164-3ebe6bbc9f5a/images/7b28b0e6-79ce-4d78-a6cb-769760a3d373/31e2b06b-85cb-46ed-aac3-8bcef93dc704’: Permission denied
because the code is running as root.
For '-o rhev' this is likely to fail (although for obscure reasons it
*doesn't* fail on a real RHEV server, I don't quite understand why).
The reason is because virt-v2v may be running as root, and with root
squashing we don't have permissions to write into the storage domain
directory.
For '-o vdsm', VDSM is supposed to make sure we are running as the
correct user, so there's no reason to doubt things will work.
Make the input/output ordering of command line arguments clearer by
changing:
virt-v2v -i disk -o local -os /var/tmp disk.img
to:
virt-v2v -i disk disk.img -o local -os /var/tmp
We need to write files and directories as user:group 36:36, else
RHEV-M cannot import the VM. Doing this in the presence of NFS is
difficult. See v2v/kvmuid.mli for how it is done in this commit.
Also we allow the output mode to actually create the disk image. This
lets the output mode set ownership and permissions correctly if
required.
The default method just calls Guestfs#disk_create, so there is no
actual change in this commit.
Change Lib_ovf.create_meta_files so that instead of writing the
.meta files, it just returns the content. Output_rhev and
Output_vdsm are correspondingly changed so that they write the
content to the .meta files.
This is just code refactoring, there is no functional change.
The old virt-v2v code would either edit the grub config file (grub
legacy) or use grubby --set-default (grub2).
When translating this code, I figured we could use grubby in both
cases, since grubby exists for grub legacy guests.
However it doesn't appear to work for grub legacy guests. Use the
configuration file editing method for these, same as old virt-v2v.
Thanks: Tingting Zheng
The existing APIs guestfs_stat, guestfs_lstat and guestfs_lstatlist
return a stat structure that contains atime, mtime and ctime fields
that store only the timestamp in seconds.
Modern filesystems can store timestamps down to nanosecond
granularity, and the ordinary glibc stat(2) wrapper will return these
in "hidden" stat fields:
struct timespec st_atim; /* Time of last access. */
struct timespec st_mtim; /* Time of last modification. */
struct timespec st_ctim; /* Time of last status change. */
with the following macros defined for backwards compatibility:
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
It is not possible to redefine guestfs_stat to return a longer struct
guestfs_stat with room for the extra nanosecond fields, because that
would break the ABI of guestfs_lstatlist as it returns an array
containing consecutive stat structs (not pointers). Changing the
return type of guestfs_stat would break API. Changing the generator
to support symbol versioning is judged to be too intrusive.
Therefore this adds a new struct (guestfs_statns) and new APIs:
guestfs_statns
guestfs_lstatns
guestfs_lstatnslist
which return the new struct (or array of structs in the last case).
The old APIs may of course still be used, forever, but are deprecated
and shouldn't be used in new programs.
Because virt tools are compiled with -DGUESTFS_WARN_DEPRECATED=1, I
have updated all the places calling the deprecated functions. This
has revealed some areas for improvement: in particular virt-diff and
virt-ls could be changed to print the nanosecond fields.
FUSE now returns nanoseconds in stat calls where available, fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1144891
Notes about the implementation:
- guestfs_internal_lstatlist has been removed and replaced by
guestfs_internal_lstatnslist. As the former was an internal API no
one should have been calling it, or indeed can call it unless they
start defining their own header files.
- guestfs_stat and guestfs_lstat have been changed into library-side
functions. They, along with guestfs_lstatlist, are now implemented
as wrappers around the new functions which just throw away the
nanosecond fields.
This gives us finer control over how system calls are done,
and also potentially lets us test more.
Currently two tests are disabled:
- utimens because of https://bugzilla.redhat.com/show_bug.cgi?id=1144766
- utimes because our stat call does not return the nanosecond fields
This file causes the test ISO to be rebuilt every time.
Instead of including it as a Makefile dependency, create it just
before making the ISO, which has the same effect.
A test in fish/ also used this file. Change it so it doesn't need it.
Add support for aarch64 to the file_architecture API, so we can
detect aarch64 guests correctly.
Add a test binary and library. These were generated on an aarch64
machine by doing:
echo 'main(){}' > bin.c
gcc bin.c -o bin-aarch64-dynamic
strip --strip-all bin-aarch64-dynamic
echo '' > lib.c
gcc -shared lib.c -o lib-aarch64.so
strip --strip-all lib-aarch64.so
Previously we required that the source hypervisor knew the
architecture of the guest, and passed that through to KVM.
However this was error-prone for several reasons:
- OVF (-i ova) doesn't define the architecture
- Disk images (-i disk) don't have an associated architecture
- Libvirt XML sometimes lacks the <type arch=...> field, especially
for RHEL 5-era libvirt.
- It might not be set correctly for the guest.
We know the real architecture from inspection of the guest, so use
that instead.
The escape sequence \e[0;30m sets the colour to black. This is fine
if you use a black-on-white terminal, but fails rather badly if you
use a white-on-black terminal.
Instead use the escape sequence \e[0m which restores the terminal to
the defaults, and works in both cases.
If the RPM database in the source guest is corrupt, then subsequent
operations will fail randomly.
Old virt-v2v appears to have avoided this by cleaning the RPM database
very early on. When translating the code I inadvertantly moved this
cleanup to a later stage -- in particular, after inspection of kernels
was done which requires running rpm commands. Move this back to the
start.
When chowning the final directories, instead of chowning them to 36.36
(ie. hard-coding those UID/GIDs), use a --reference chown so it should
take the ownership from the parent directory.
Unfortunately chowning is very complex because of:
- NFSv3 vs NFSv4
- root squash
- idmap
which creates approximately 8 different ways for this to fail.
When presented with a RHEL 7 guest, virt-v2v would print the following
warning message:
virt-v2v: warning: could not update grub2 console: aug_get: no matching
node (ignored)
This happened because on RHEL 7, /etc/sysconfig/grub is a symlink to
/etc/default/grub, and the Augeas grub2 lens returns entries under
/files/etc/default/grub/*, but the code was checking for
/files/etc/sysconfig/grub/*.
The fix is to check all the possible Augeas paths until one matches.
(Only the first match gets updated however).
Also, don't rebuild the grub2 config unless we've actually changed it.
This avoids doing a potentially failure-prone operation when it's not
necessary.
I suspect that the old virt-v2v code did not work correctly for RHEL 7
guests, but old virt-v2v didn't print a warning here, it just failed
to update silently.
All tests run under the ./run binary. For a long time the ./run
binary has set the $PATH environment variable to contain all of the
directories with binaries in them.
Therefore there is no reason to use ../fish/guestfish instead of just
plain guestfish (and the same applies to other built binaries).
If do_part_get_parttype returns NULL, then return from the function
instead of dereferencing the NULL pointer and crashing. Note that
do_part_get_parttype has already called reply_with_error in this case.
This fixes commit 0316d24770.
Found by: Lingfei Kong
Old virt-v2v rebuilt the initrd late. Currently we rebuild the initrd
right after choosing a kernel, but it's best to update the initrd
at the end since mkinitrd may depend on other configuration files
that we are changing (especially see next commit).
The old virt-v2v code had:
my $prefix;
if ($virtio) {
$prefix = 'vd';
} elsif ($libata) {
$prefix = 'sd';
} else {
$prefix = 'hd'
}
The translated code dropped the test for virtio by accident, which
meant that device names would be mapped to sd* or hd* even if the
virtio-blk driver was enabled for the guest.
Thanks: Tingting Zheng
For Xen guests, a device can be presented twice as (eg) xvda and sda,
and therefore we should map any otherwise unmapped xvdX.
For non-Xen guests, this should have no effect.
I made a mistake while translating the Perl conversion code and
transcribed --set-default as --set-kernel. grubby has no --set-kernel
option so it failed.
Thanks: Tingting Zheng
Previously only "running" domains were blocked from conversion.
However "blocked" is essentially the same as running (on Xen it just
means the domain is running but waiting on an I/O resource). And
"paused" domains probably shouldn't be converted either since their
disks are only crash-consistent.
Don't rely on libvirt's implicit print-to-stderr. Instead make sure
that libvirt error messages are raised in the exception message.
Also allow error strings to be translated.
When you call close on any block device, udev kicks off a rule which
runs blkid to reexamine the device. We need to wait for this rule to
finish running since it holds the device open and can cause other
operations to fail, notably mkfs.
(cherry picked from commit a9c8123c72)
Estimate the amount of space required on the target by each source
disk after conversion. The estimate is approximately a ceiling on
this, and actual use should be considerably lower.
Provide an extra output method (#check_target_free_space) which output
modules may use to check that there is sufficient free space to
proceed, before conversion starts. None of the output modules
actually implement this at the moment.
In most C tools, virt-sysprep and virt-customize, you have to put the
--format parameter before the corresponding -a parameter. ie. The
following is correct:
guestfish --format qcow2 -a disk1 -a disk2
But the following is incorrect. The --format parameter is dangling
and prior to this commit would have been silently ignored:
guestfish -a disk1 -a disk2 --format qcow2
After this change, dangling --format parameters now lead to an error:
guestfish: --format parameter must appear before -a parameter
In virt-customize, also check that --attach-format parameter appears
before --attach parameter.
Thanks: Lingfei Kong
If there is an authentication error when getting the session cookie,
emphasize in the error message that the username can be specified in
the URI.
Unfortunately libvirt asks for the username previously, but we cannot
access that.
In theory this discards the output. Unfortunately in practice we have
to write the output to a temporary file and delete it (because of
limitations in qemu-img convert).
You will see an error like this:
$ virt-sysprep --remove-user-accounts foo,bar -a /dev/null
virt-sysprep: error: user-accounts: --remove-user-accounts parameter was
used, but the "user-account" operation is not enabled
The --user-accounts option, with its double-negative '-' prefix on
user names, is confusing. Replace it with '--remove-user-accounts'
and '--keep-user-accounts' options.
This updates commit 128d474095.
-o rhev: This is "traditional" output to a RHEV-M Export Storage Domain.
It requires no cooperation from RHEV itself, and in all other respects
works the same way as old virt-v2v did.
-o vdsm: This is the new mode which requires VDSM cooperation. VDSM
manages the conversion, creating the directories, suggesting UUIDs,
and cleaning up on failure. This allows direct import into a Data
Domain.
The --rhev* command arguments now only apply to -o vdsm, and therefore
have been renamed to --vdsm*
The --vmtype command line argument may be used with -o rhev or -o vdsm.
Also give an error if users use the incorrect one:
$ virt-builder --list --format json
virt-builder: virt-builder --list: use '--list-format', not '--format'.
The default charset for these filesystems depends on how the kernel was
configured with, so explicitly set the default one (as specified in
Linux sources), eventually setting later a new one for the tests.
Previously the core virt-v2v code had to know which Convert_* module
to call for each guest type (based on inspection). After this change
the core code doesn't need to know that, but instead Convert_* modules
register their interest in particular guest types.
Fedora patches OCaml's Arg module to support --option=arg. Since this
won't work on other distros or upstream OCaml, don't include such
examples in the documentation.
The two adjacent sections can be read separately, and the second
section doesn't mention not using make install / using ./run, so
repeat it a second time.
Before trying to perform the conversion, estimate if there is
sufficient free space on the guest filesystem(s) for the conversion to
be successful.
If not, you will see an error similar to this one:
[ 6.0] Checking for sufficient free disk space in the guest
virt-v2v: error: not enough free space for conversion on filesystem '/'.
4354048 bytes free < 20000000 bytes needed
virt-p2v can run without a window manager. However it then sits in
the top left corner of the screen. Add a lightweight window manager
to the ISO so that position and geometry hints work.
Two scripts are added, replacing the make targets from the
previous commit:
virt-p2v-make-disk: Builds a virt-p2v disk or USB key using
virt-builder.
virt-p2v-make-kickstart: Builds a kickstart file (only) which can be
fed to livecd-creator or similar tools on Red Hat-derived distros.
Kickstart generation is slightly different: Instead of requiring the
downstream 'libguestfs-pvhelper' package, the kickstart now embeds the
virt-p2v binary(!) making it self-contained and downstream packaging
simpler.
In addition there are documentation changes.
As part of reworking the scripts that are used to build the P2V ISO,
first remove the separate p2v-iso directory. Similar scripts and
documentation will be introduced back into the p2v/ directory in
following commits.
Import the upstream lens for the shadow file, just with a different
identifier and not matching /etc/shadow by default. Instead, apply a
transformation to have it match /etc/shadow only if the version of
augeas is at least 1.2.1 [1].
[1] While the last upstream version is 1.2.0, all the development seems
to happen in master, so whatever the next version is going to be
numbered (e.g. 1.2.1 or 1.3.0), the check will be fine anyway.
It will print an error like this:
virt-v2v: error: internal error: invalid argument: libvirt domain 'windows'
is running, it must be shut down in order to perform virt-v2v conversion
This only works for libvirt domains, and is explicitly disabled for
test:/// URIs since these domains are always "running", but we use
these URIs for testing.
Unhelpfully, Filename.chop_extension throws an exception if the
filename has no extension (instead of just returning the filename).
Therefore the -i disk option would fail if you passed any filename
that didn't have an extension.
When setting the password for a locked account, make sure to still write
the password after the "!!" marker, otherwise the account will have no
password.
Previously we only looked for <driver name=qemu type=...>. However
for Xen imports, the name field could be name=tap (or other values in
fact). Since there can only be one <driver/> element under <disk/>,
look for any <driver type=...> in order to get the disk format.
A further complication for Xen is that type=aio means "raw" (for
obscure historical reasons), so map that.
Thanks: Dan Berrangé.
The empty_element macro was not safe when used in a "naked" if
statement such as:
if (config->flags & FLAG_ACPI) empty_element ("acpi");
Fix the macro so it uses do { ... } while (0) to make it safe here.
The new output of virt-v2v --machine-readable now lists the input and
output drivers available in the binary:
$ virt-v2v --machine-readable
virt-v2v
libguestfs-rewrite
input:disk
input:libvirt
input:libvirtxml
output:glance
output:libvirt
output:local
output:rhev
With this information, we can now pre-populate the virt-p2v GUI
combo box.
Instead of having all interfaces connect to the "default" network on
the hypervisor target, you can now create a map of interface to target
network, either on the kernel command line, eg:
p2v.network=em1:rhevm
p2v.network=em1:rhevm,em2:management,other
or through the GUI.
Enhance the user-account sysprep operation, so it is possible to select
which user accounts should be removed only (instead of all), or which to
eventually keep.
Name these the same as the virt-v2v options, so for example
'-oa' -> 'p2v.oa'.
Also add the missing p2v.oc (-oc) option.
This updates commit c516d2d07d.
On Ubuntu, exclude the Ubuntu-only 85-lvm2.rules since it causes the
automatic activation of volume groups on addition or change. This
interferes with libguestfs, as vgs which are disables suddently get
enabled.
ocamldep -all (introduced in commit a3881445ef) creates a dependency
rule
optgroups.cmi ... : utils.cmx ...
Because we never build a native code version of the generator,
utils.cmx can never be remade, and so this results in optgroups.cmi
being always rebuilt and hence rebuilding the whole directory.
It's unclear how to fix this, but reverting the ocamldep -all change
in this directory works around it.
Partially reverts commit a3881445ef.
In v2v, 'stringMap.ml' has no corresponding *.mli file. ocamldep does
not generate a *.cmi dependency for such modules, and this can result
in parallel builds failing rarely because:
(1) stringMap.ml is built (which has the side-effect of generating
stringMap.cmi)
(2) at the same time, types.mli is compiled. types.mli depends on
stringMap.cmi, but it is half way through being created by (1).
There is no dependency to serialize (1) and (2).
The resulting error is:
File "types.mli", line 1:
Error: Corrupted compiled interface
stringMap.cmi
Using 'ocamldep -all' generates extra deps for the *.cmi files, and
otherwise appears to be safe, so use it.
There are currently a few upstream OCaml bugs with dependencies and
parallel builds:
http://caml.inria.fr/mantis/view.php?id=3190http://caml.inria.fr/mantis/view.php?id=4991http://caml.inria.fr/mantis/view.php?id=5000
It's not clear which of these apply here.
The parsing of p2v.disks, p2v.removable and p2v.interfaces did not
correctly end at the first space, and therefore any other parameters
that happened to be on the command line afterwards would be consumed
as a list of disks or interfaces.
In commit 53e0d3ea5f I fixed a cause of
disk corruption in the overlay file during conversion.
To ensure this doesn't occur again unexpectedly, add a simple test to
the virt-v2v code and to the tests.
When saving, resolve the path of the file being edited and use that as
real target to write to. Otherwise, if the file name is a symlink then
it will be replaced by a regular file with the new content, leaving the
old file untouched.
Extend test-edit.sh to check for this situation.
Allow null as value for the editor parameter of edit_file_editor, which
will then get it from the EDITOR envvar (falling back on vi).
This is basically code motion from the two edit_file_editor users to it.
To speed up conversions by storing everything we read during
conversion in the overlay instead of having to reread it from the
remote server during copying.
Thanks: Matthew Booth.
When drives are added with this flag, reads from the backing file are
copied into the overlay, improving performance of reads to the same
area of disk (at the expense of local storage). This is excellent for
reading remote / slow sources like HTTP.
Add the perl file editing, mostly based in the virt-edit implementation.
This introduces a mild code duplication with edit_file_editor; will deal
with it in a later commit.
Do not unconditionally exit if guestfs_case_sensitive_path, but let
windows_path still return null. Make virt-edit then check for that, and
eventually exit on its own.
Move the code handling Windows paths from virt-edit to a common file,
so that can be shared by various tools.
Mostly code motion, with a minimum touch (the additional guestfs_h*
parameter in mount_drive_letter) to make it build and work.
This seems* to cause disk corruption in the overlay files. A
manifestation of this is that the qcow2 header is not written back
correctly to disk, resulting in the backing file of the overlay
"disappearing" and hence hardly any data being copied over to the
target.
* Note this could be for a variety of reasons and doesn't necessarily
indicate a fault in qemu or qcow2.
Previously if you used `-i libvirt -ic [a remote URI]' then the remote
URI would be opened during object creation, which occurs during
command line parsing. The practical effect was that virt-v2v could
appear to hang or give an error (eg if the remote URI is inaccessible)
before printing any log messages. This could be very confusing for
the user.
Split out -i libvirtxml into a separate module, containing the libvirt
XML to source parsing code as a function called
Input_libvirtxml.parse_libvirt_xml.
Modify -i libvirt so it does all initialization and calls the helper
function during the #source method, and not at object creation time.
This was based an incorrect translation of what the old virt-v2v was
doing. %systemroot%\Drivers is not expected to exist already, and
indeed does not exist in a real Windows 7 guest.
Add a mini-binding to libvirt virStoragePoolGetXMLDesc to get the pool
XML directly using the libvirt API. Change existing external calls to
`virsh pool-dumpxml' to use this API instead.
The `virsh dumpxml' command doesn't work properly when the libvirt
source requires authentication. This is because the authentication
prompts are sent to stdout, but stdout is also the place where we are
reading the output XML from.
Add a mini-binding to libvirt virDomainGetXMLDesc which avoids this,
getting the XML directly using the libvirt API. Change existing
external calls to `virsh dumpxml' to use this API instead.
The way to set the filter for lvm devices was to open lvm.conf, look
for uncommented "filter =" lines and replace the configuration there.
This had the issue that if there is no uncommented filter line, then the
filter cannot be changed at all; considering newer lvm2 releases ship a
sample configuration with no uncommented filter lines, then the old way
became wrong and not sufficient.
Instead, take a copy of the upstream lvm.aug lens, with a simple change
to allow parsing also negative values in configuration, and install it
in the daemon. When asking to change the lvm filter, use augeas making
sure to use this custom lens for the lvm.conf copy used within the
appliance.
The C code didn't have -Werror enabled (when configured) and didn't
enable the full set of warnings we would want.
However OCaml-C bindings commonly declare functions which are
called directly from OCaml, eg:
external parse_memory : string -> doc = "v2v_xml_parse_memory"
value v2v_xml_parse_memory (value xmlv)
These do not require prototypes as no other C code will call them, so
we have to switch off the GCC -Werror=missing-prototypes flag for
these files.
Also fixes some confusion between _CPPFLAGS and _CFLAGS.
Move the fields from Types.overlay which were related to the target
file out. Now Types.overlay is only concerned with the actual qcow2
overlay files, not with a mixture of both files.
For every guest disk, there is one chain which looks like this:
source_disk overlay target
+------------+ +----------------+ +---------------+
| s_qemu_uri |<------ ov_source |<------ target_overlay|
| etc | | ov_overlay_file| | target_file |
+------------+ | ov_sd | | target_format |
| ov_virtual_size| +---------------+
+----------------+
describes source describes temp. describes target
disk file overlay (qcow2) file
This is just refactoring.
This function had got smaller and smaller until now we might as well
just inline it. Having it after the main function just obscured the
order that the code runs.
No functional change, just refactoring.
The ov_preallocation field was essentially an implementation detail of
the V2v module. There was no need to carry it around in the overlay
struct, and nothing else used it. This also allows us to simplify
other code.
If the <memory> or <vcpu> elements was missing from the source
metadata then we would choose useless defaults, resulting in (for
example) <vcpu>0</vcpu> being written to the output.
Choose sensible defaults for these integer values.
When we map the network or bridge names (using --network or --bridge
command line options), this commit keeps the original name and adds it
as a comment to the output metadata.
The comment will look something like this:
<interface type='bridge'>
<!-- bridge mapped from "VM Network" to "bridge1" -->
<source bridge='bridge1'/>
<model type='rtl8139'/>
</interface>
Previously Types.input and Types.output were variants, resulting in
the main v2v.ml code having to have knowledge of all the input and
output types. So you would end up with code in v2v.ml like:
match output with
| OutputLibvirt -> (* call some libvirt-specific code *)
| OutputRHEV -> (* call some RHEV-specific code *)
This changes these types to be abstract superclasses, with specific
implementations provided by (and hidden inside) each input/output
module. The above code in v2v.ml now becomes:
output#call ... (* no backend-specific knowledge needed *)
Although this commit is very large, it is just refactoring. There is
no functional change in the code.
This allows `-ic esx://...' to work because we map the strange source
URI used by ESX to a remote HTTPS connection.
Example disk section that this handles:
<disk type='file' device='disk'>
<source file='[datastore1] Windows/Windows.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
Instead of the ?dir parameter which was essentially a hack, allow
callers of create_xml to provide functions that map
<source file="..."> or <source dev="..."> to qemu URIs.
The default for these mappings is the identity function.
For -i libvirtxml we replace the old absolute_path_of_disk function
with a source file mapping function which does the same thing.
There is no functional change in this patch.
<source dev=...> in the libvirt XML should always refer to a block
device, eg. /dev/sda1. Don't attempt to make these paths absolute
(they should already be absolute paths, and if they are not it's wrong
to try to make them).
There is already a partial binding for this in fish/uri.c &
mllib/uri-c.c. However it is specialized to parsing the -a parameter
on the command line and we want access to the full underlying
functionality of xmlParseURI.
These are now collected from the source metadata and (where
possible) passed through to the destination.
For reference, see the metadata structure of the old virt-v2v (roughly
equivalent to Types.source in the new code):
https://git.fedorahosted.org/cgit/virt-v2v.git/tree/metadata-format.txt
As you can see the new code now covers all the metadata features of
the old code.
Mostly complete and making most of the features work.
The notable lack is ntfsprogs and ntfs-3g, which due to the way
mount.ntfs is handled (i.e. using alternatives) do not work properly.
This is simpler to use and more convenient than -i libvirtxml, because
users don't need to bother with writing libvirt XML. However it is
less expressive because many source capabilities such as memory and
number of vCPUs cannot be specified this way.
As initializing the target (-o ...) is a distinct operation, which can
fail if the user supplied the wrong command line arguments, make sure
we display an explicit message before we perform this step.
It prints something like this:
[ 5.0] Initializing the target -o libvirt -os default
Since `-o local' and `-o libvirt' both need to generate libvirt XML
they should share the same code to generate it.
Also generate it using the DOM module instead of printing the XML
directly. This is cleaner and avoids quoting issues.
No functional change here.
Notes:
- Drop the acpi feature for RHEL 3. Old virt-v2v says there is
a problem presenting ACPI to RHEL 3 guests although it is not
specific about what this is.
- Old virt-v2v does not pass features through to OVF at all.
This seems to be the new way [1] in Archlinux to specify, as symlink,
the default version of Java.
Thanks to Peter Wu for the notice about it.
[1] https://wiki.archlinux.org/index.php/Java
This warning was meant for the case where /dev/kvm is inaccessible and
the user must add themselves to a special group.
However we didn't take into account whether /dev/kvm was openable in
this test. If it's openable, no point issuing the warning.
Move the is_openable ("/dev/kvm") test earlier, and don't issue the
warning if that was successful.
The virt-v2v tests here are not meant to be thorough tests of guest
conversion. There is a test suite used to test conversion which is
kept outside libguestfs because it contains lots of proprietary
unredistributable guests like Windows.
The tests here instead are testing:
- virt-v2v command line arguments
- virt-v2v reads and writes files to the correct places
- valgrind & memory leaks
- any conversion properties that can be tested using just the
phony guests (but we don't go out of our way here)
- that up to date guests don't crash virt-v2v
Fix the Name and Packages database so it looks enough like a modern
RPM database to fool inspection. I'm not sure whether or not the old
version ever worked, but it doesn't work now.
The format is not documented, but in brief:
The Name database contains (Name, link) pairs. The link is an
arbitrary 32 bit integer.
The Packages database contains (link, RPM-blob) pairs.
The RPM-blob is a binary blob formatted like this:
* Number of fields 4 bytes, big endian
* Size in bytes of the store 4 bytes, big endian
* Field descriptions:
list of (RPMTAG, 0, offset in store, 0)
4 * 4 * nr_fields bytes, big endian
* The store binary data containing ASCIIZ strings
For the values of RPMTAG_* that we understand, see src/inspect-apps.c.
The calling code allows Fedora guests to be used when calling
Convert_linux. However Convert_linux itself would fail with an
assertion error when you did this.
Previous virt-v2v would write to a temporary destination file then
atomically rename everything at the end.
However this appears to be unnecessary since we write the OVF file
after copying the disks, so (I assume) RHEV-M won't see the disks
before then.
In any case nothing used ov_target_file_tmp so we can remove this
feature to simplify the code.
Currently various UUIDs used by `-o rhev' are generated randomly.
This means they are different on every run of the program.
Allow some of them to be specified on the command line. (If not
specified they are still generated randomly).
This allows RHEV-M to run virt-v2v several times (eg to examine the
OVF output) while having paths to files and OVF be stable across runs.
At the moment there is just one "miscellaneous RHEV command line
option" (--vmtype), but we may add more in future. Put them in a
single struct for convenience.
This is just code motion.
If the environment variables LIBGUESTFS_TRACE=1 or LIBGUESTFS_DEBUG=1
were set, then the current code would end up disabling trace/debug if
the command line arguments did not contain -x/-v.
Fix this so the effect of enabling trace/debug is cumulative.
Previously it was called 'libvirt.conf' which is more than a little
bit confusing.
This is only an internal name, so there is no visible change in
functionality.
It seems that Automake cannot handle properly the files generated by
flex and bison, leaving them in the dist tarball.
For now, add a dist-hook to manually prune them from distdir.
When using optional arguments of type OStringList, the code free'ing
the member in the optargs_s struct corresponding to that optional
argument would just check for a non-PyNone PyObject for that argument.
If before that optional argument there are other arguments which can
cause an earlier error return from that binding function, the free'ing
code will then act on garbage values.
Enhance the check by also checking whether the optargs struct has the
bitmask with the element for that argument, meaning that the
corresponding struct member was initialized.
The error is:
../src/.libs/libutils.a(
libutils_la-cleanup.o): In function `guestfs___cleanup_xmlBufferFree':
cleanup.c:(.text+0x79): undefined reference to `xmlBufferFree'
../src/.libs/libutils.a(libutils_la-cleanup.o): In function
`guestfs___cleanup_xmlFreeDoc':
cleanup.c:(.text+0x99): undefined reference to `xmlFreeDoc'
[etc.]
Thanks: Arnaud Gaboury
If pthread_cond_wait fails and the thread worker ends, make sure to
unlock retire_mutex, which has been locked for the condition.
The return value of pthread_mutex_unlock is ignored, as there's nothing
that can be done with it at that point.
Fix the memory issues in the implementation that uses no -p nor -i:
- use add_string_nodup to add results from get_blkid_tag (which returns
new strings), so those strings are not leaked
- use free_stringslen to clean the hash on error, as in such case the
stringbuf will not be terminated with a null entry, thus causing
free_strings to crash
When dealing with DeviceList parameters, the generator produces code
similar to the following:
CLEANUP_FREE_STRING_LIST char **devices = NULL;
[...]
devices = malloc (sizeof (char *) * (args.devices.devices_len+1));
{
size_t i;
for (i = 0; i < args.devices.devices_len; ++i)
RESOLVE_DEVICE (args.devices.devices_val[i], devices[i],
, goto done);
devices[i] = NULL;
}
The block hidden within the RESOLVE_DEVICE macro is supposed to
assign something to devices[i]; on the other hand, the code in
RESOLVE_DEVICE can cause to just end (with an error) the current RPC,
which would cause the cleanup of the "devices" array... whose members
from the i-th to the (args.devices.devices_len-1)-th would be garbage
pointers, causing random memory to be free'd (and thus crashing the
daemon).
Avoid the access to garbage memory just by having a cleaned "devices"
array, so there will be always a NULL element after the initialized
members.
Add a test for vgcreate which passes a wrong device path causing the
situation above, to test that vgcreate would fail gracefully.
Use %d to parse them as int (since the variables for them as int)
instead of %u, even if they both need to be at least > 0; the library
will check for the validity of them anyway.
Move the minimum memory check from the environment parsing to
set_memsize, so the limit is actually enforced also when using the API.
Adapt the rhbz557655.sh test to the invalid memsize values being
rejected now, and add a new test for checking invalid parameters
explicitly.
Even if luaL_error is a "no return" function for the Lua runtime, adopt
also in action functions the "return" idiom recommeded for it.
This also helps code analyzers in not thinking that "g" might still be
null after the null check followed by luaL_error.
Handy macro to reply the right way for an unavailable feature.
While generally used so far in generated code, it can shorten that a
bit, and avoid copy&paste when wanting to do manual feature checking.
This refactors existing code to close file descriptors in the recovery
process, and also adds code to close file descriptors between the
fork() and exec() of QEMU or User-Mode Linux.
The reason is to avoid leaking main process file descriptors where the
main process (or other libraries in the main process) are not setting
O_CLOEXEC at all or not setting it atomically. Python is a particular
culprit.
See also this OpenStack Nova bug report:
https://bugs.launchpad.net/nova/+bug/1313477
Thanks: Qin Zhao for identifying and characterizing the problem in Nova.
This is version 2 of this commit. This commit is identical to the
reverted commit 115fcc3432 except that
we don't close stderr.
This attempted fix for RHBZ#1123007 causes the qemu command line to be
lost when verbose mode is enabled. Since this is essential for
debugging many problems, I am reverting the patch.
This reverts commit 115fcc3432.
This is useful when analysing with `perf' since it allows us to
increase the amount of time in the test versus the amount of time
spent starting the appliance.
This refactors existing code to close file descriptors in the recovery
process, and also adds code to close file descriptors between the
fork() and exec() of QEMU or User-Mode Linux.
The reason is to avoid leaking main process file descriptors where the
main process (or other libraries in the main process) are not setting
O_CLOEXEC at all or not setting it atomically. Python is a particular
culprit.
See also this OpenStack Nova bug report:
https://bugs.launchpad.net/nova/+bug/1313477
Thanks: Qin Zhao for identifying and characterizing the problem in Nova.
We were mounting different filesystems on top of each other. In fact
this is not a problem, but it's nicer to unmount each filesystem
properly after examining it.
This test worked by uploading a 100MB file into a 100MB container and
seeing the inevitable crash. Unfortunately virtio-mmio (used on
aarch64) is quite slow. Since this test is not testing the speed of
virtio-mmio, use a smaller test file so the test finishes in a
reasonable time.
This library replaces Win::Hivex::Regedit, or at least enough for us
to be able to make the simple Registry modifications needed for
installing firstboot scripts.
To fix RHBZ#1056290, I prevented virt-sparsify being used if the
output device is a block device.
I have now retested this scenario and it does work (in both copying
and in-place mode), and does not delete the output device, and
therefore we can relax this restriction so only char devices are
banned.
This is useful for oVirt which uses a qcow2 formatted block device to
store virtual machines.
For example:
$ time ./run ./tests/qemu/qemu-boot -n 100
real 1m19.794s
user 0m10.001s
sys 0m5.928s
will run 100 appliance start/stops, from multiple threads.
This test has not been run since 2012 as it depends on specifics of
how supermin and new-style appliances work (see
commit 2d89aef897).
This commit removes the test entirely.
In OCaml 4.02, the 'string' type can be made immutable. All String.*
functions that are concerned with creating or mutating strings now
give a warning like this:
Warning 3: deprecated feature: String.unsafe_set
Disable this warning since we don't want to turn on immutable strings
yet.
This still only prints early console messages. Output stops
after:
bootconsole [earlycon0] disabled
but I have not found any way to get later kernel messages.
This option allows oVirt to pass a prebuilt qcow2 file to use as the
temporary overlay. The file must be qcow2, and must have indisk as a
backing file - the code does minimal checks to ensure this is correct.
Example usage:
qemu-img create -f qcow2 -b indisk overlay.qcow2
virt-sparsify indisk --tmp prebuilt:overlay.qcow2 outdisk
Note this only applies in copying mode.
Run ldconfig early in the init script, so libraries outside standard
library paths but with a proper ld.so configuration file pointing at
them can be found.
Just like no /etc/fstab is not an error, having one with no entries
shouldn't be an issue either.
With systemd, this could be a valid setup, with mount points set its own
way.
We were passing an int64_t which happens to be the same as time_t, but
only on 64 bit. This didn't work on 32 bit (or rather, it works on
little endian, but only by accident).
This fixes commit fb546eaee0.
sd_journal_get_realtime_usec is defined as:
int sd_journal_get_realtime_usec(sd_journal* j, uint64_t* usec);
Unfortunately we passed size_t* as the second argument. This happened
to work on 64 bit machines because size_t is 64 bit there, but failed
on 32 bit machines, where we didn't pass a sufficiently large result
buffer.
This fixes commit 2d996df66c.
These log files can get pretty big, and that causes problems
like this one:
http://linuxforum.ru/viewtopic.php?id=35381
and this one:
https://bugzilla.redhat.com/show_bug.cgi?id=1099172
In both cases the problem was /var/log/lastlog which is apparently a
large sparse file. Supermin cannot cope with sparseness, so it copies
the whole file non-sparse. But since this could affect other log
files this commit covers various common log file names and patterns.
Thanks: semperN
Sort the structs when generating code. Since the structs are
logically indepedent of each other, this should have no effect except
to make generated files list the structs in a different order.
However this also fixes the following build problem:
File "convert_linux.ml", line 322, characters 43-50:
Error: This expression has type G.stat = Guestfs.stat
but an expression was expected of type G.dirent = Guestfs.dirent
It turns out the OCaml bindings don't like the fact that we have
two structs with a common field name (dirent.ino and stat.ino).
In OCaml < 4.01, this means that any attempt to reference stat.ino
would fail because dirent.ino appears second in the file, overriding
stat.ino.
Sorting the structs has the side effect of making stat.ino appear
second, thus resolving the build failure above.
In OCaml >= 4.01 the compiler now uses some disambiguation rules based
on the known types to resolve this problem, so accessing either field
would work no matter what order they are listed in.
See:
http://ocaml.org/releases/4.01.0.htmlhttp://www.lexifi.com/blog/type-based-selection-label-and-constructorshttp://www.lexifi.com/blog/ocaml-extensions-lexifi-overidding-record-labels-and-constructors
virt-customize:
virt-sparsify:
virt-sysprep:
virt-v2v:
- These tools consistently used -v to mean verbose/debugging
and -x to mean enable libguestfs tracing.
virt-builder:
virt-resize:
- These two tools did not recognize -x at all, and used -v
to enable libguestfs tracing and general debugging.
- This commit changes these two tools to consume -v/-x
consistently with the other tools.
Unfortunately this has a cascade of effects through the code.
It turned out that Common_utils was exporting the 'G' module (an alias
for Guestfs). We want any code that uses G as a shortcut to declare:
module G = Guestfs
at the top, since that avoids confusion for newbie (or experienced)
OCaml programmers.
Old Xen PV guests had:
<driver name='tap' type='aio'/>
The previous xpath expression matched any driver type attribute in
order to pick up the format. However we only want to match:
<driver name='qemu' type='raw'/>
so we need to check the name attribute as well.
I'm not sure if this indicates that the xpath expression is wrong, but
in any case it can be that xpathobj->nodesetval is NULL. In this
case, return 0 from xpathobj_nr_nodes instead of segfaulting.
Commit c4dc70f8c4 broke the man pages
for the Perl scripts in the tools/ directory.
It inserted the =encoding line at the top of the file, instead of in
front of the first =head1 entry, and this meant that the #!/usr/bin/perl
and the prologue became a part of the POD, which was not intended.
Add the virt-sparsify --tmp option.
This works in two ways. Either you can specify a temporary directory,
in which case it's just the same as setting $TMPDIR before:
virt-sparsify indisk outdisk --tmp /var/tmp
Or, as a new feature, you can specify a block device which is directly
used (and OVERWRITTEN):
virt-sparsify indisk outdisk --tmp /dev/sdX
This is useful for oVirt nodes, where there is limited temporary
space, but a block device can be assigned to the node.
In both cases it is only used in copying mode. In-place
sparsification doesn't require large amounts of temporary space.
Previously if you were root, and you tried to change directory into a
directory which was not owned by you and not readable (eg. 0700
bin:bin), it would fail.
This doesn't fail on regular directories because when you are root the
kernel just ignores permissions.
Although libguestfs in general tries not to duplicate kernel code, in
the case where we emulate the FUSE access(2) system call,
unfortunately we have to do it by stat-ing the object and performing
some (half-arsed) heuristics.
This commit modifies the FUSE access(2) system call, so root is now
able to chdir to any directory.
It also adds some debugging so we can debug these complex permissions
checks in the field if some other problem arises in future.
This commit also removes the disk image signature. These have not
been needed since virt-builder 1.24.1. No one should be running that
version of virt-builder since there are newer 1.24 branch versions.
See:
https://www.redhat.com/archives/libguestfs/2014-June/thread.html#00045
Notes:
(1) Edit dracut configuration to make sure the change is permanent, in
case kickstart, virt-builder or something else installs a kernel or
runs dracut.
(2) We need to run dracut on the just-installed kernel, not on the
running kernel. The snippet to do this was copied from the Fedora
cloud kickstart.
Thanks: Olaf Hering, George Dunlap, Dario Faggioli.
This device is not present at least on ARM. Unfortunately libvirt
doesn't give us any way to query when the device is present.
This fixes commit bed592498d.
Setting environment variables such as PS1 for bash before starting it
might not be effective when the startup scripts provided by the
distribution unconditionally change it.
Hence, set PS1 and TERM in a ~/.bashrc, which will be source'd last and
thus be able to set them the way we want.
Augeas has been a mandatory dependency of libguestfs for quite some
time, so the aug_* functions could have been always called (without even
checking the augeas feature). Thus retire the feature, marking it as
always available with no more functions depending on it.
It seems recent (?) NetBSD versions have their kernel as /netbsd, so
also check for it to detect NetBSD installations.
The current detection so far basically relied on generic files and
directories which can potentially be in every UNIX system, misdetecting
them if a /etc/release file is present in them.
If the image is located on NFS, and the NFS mount is performing a
large copy, then all other NFS operations stop. This delay can be
large enough that we hit the current 10 minute timeout in udev.
Increasing this to 100 minutes is reported to cure the problem (in
reality we want udev to wait indefinitely).
This implements the guestmount --fd option to allow you to run
guestmount captive under another process (typically using
`guestmount --fd=<FD> --no-fork').
See: https://bugzilla.redhat.com/show_bug.cgi?id=1100498
Resolve the given path within the chroot, so scrub can be invoked
outside the chroot on an already-resolved path.
Add few tests in scrub-file for this and other similar issues.
commit a86eb0e0d2 made it an optional
feature, as on Windows it was not available; on the other hand, realpath
has been used unconditionally already for quite some time, so having
just the "realpath" command conditional on the presence of it does not
make much sense.
Drop the configure/build system handling of it, make the "realpath"
command no more optional, and keep the "realpath" feature as
unconditionally available now.
Support the possibility to have optional groups always enabled (e.g.
because they were present in the past, and they need to be kept for
users).
Add and use few helper optgroups-related functions to deal also with
them.
console=ttyS0 used to work. Now it's broken again, and the correct
setting appears to be console=hvc0. Since we can pass multiple
console settings, do that to try and catch the right console.
This is just a whitespace change. The new output looks like this:
Output file: fedora-20.img
Output size: 4.0G
Output format: raw
Total usable space: 5.2G
Free space: 4.5G (86%)
Previously it wasn't installed at all. However it makes sense to
install it somewhere so that it can be placed in a package (a
requirement if we're going to create a kickstart). By placing it in
libexecdir it is hopefully clear that it should not be used.
Note on Red Hat distros, libexecdir is usually /usr/libexec. On
Debian it is usually /usr/lib/libguestfs.
Bump to >= v196 the minimum version of libsystemd-journal needed for the
journal integration, since that version provides
sd_journal_get_data_threshold and sd_journal_set_data_threshold.
It is not possible to have the ISO be built automatically when the
user runs 'make'. The README file describes how you should go about
building the ISO or disk image.
This is a graphical standalone front-end to virt-v2v which can be run
on physical machines (usually linked into a ISO or PXE boot image) to
convert the physical machine to a virtual machine.
Copy the information about the proxy of a source in all the entries of
that source; this way it is possible to use it later when accessing to
the actual image of an entry.
Root partition is on /dev/sda2:
$ virt-filesystems -a rhel-5.10 --all --long -h
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem ext2 /boot - 510M -
/dev/sda2 filesystem ext4 / - 4.5G -
/dev/sda3 filesystem swap SWAP-hda3 - 1.0G -
/dev/sda1 partition - - 83 510M /dev/sda
/dev/sda2 partition - - 83 4.5G /dev/sda
/dev/sda3 partition - - 82 1.0G /dev/sda
/dev/sda device - - - 6.0G -
It would be better if we could mount by label in guestfish ...
There is another problem with RHEL 5 guests in that the
yum URL is slightly wrong.
Get rid of --enable-gcc-warnings and just add all the warnings in any
case; they are tested anyway, so only warnings supported by the compiler
will be used.
Regarding -Werror, add a new --enable-werror which enables its use.
Allow to skip testing the filesystem "foo" if the environment variable
SKIP_TEST_CHARSET_FIDELITY_foo=1 is set. This way it possible to not
test one or more filesystems without disabling the test altogether.
So far, passwords in URLs (eg http://user:password@host..) have been
handled as part of the username, and thus passing
add-drive path username:username:password ...
instead of
add-drive path username:username secret:password ...
Fix the parsing of URLs to handle passwords as separate elements,
properly passing it as "secret" parameter for add-drive, and properly
readd it when building URLs in the direct backend.
Furthmore, to keep curl- and ssh-based qemu drivers working with
authenticated resources, make sure they can accept secrets.
Reported in comment #1 of RHBZ#1092583.
This is useful for generating Linux initramfses from other types of
filesystems. For example:
guestfish --ro -a disk.img -i cpio-out / - | gzip -9 > initrd.img
Switch from xmlParse* to xmlRead* so we can explicitly specify parsing
flags, including no network usage and no entity resolution.
The two behaviours mentioned above were not done before either, so this
should not introduce behaviour changes in libguestfs.
qemu-system-arm 2.0 as currently available through Debian/unstable
doesn't want to tell us anything about available devices unless we
specify a machine type.
When parallel builds are enabled it was possible for index-parse.c to
be compiled before the file had been completely written by bison. The
usual symptom was that the 'do_parse' symbol was missing -- this
simply happened because that symbol is defined at the end of this
file, and the compiler compiled the file before the end part was
written out. But you could also see other strange & random compile
failures as you would expect.
This was tested by running this script on an 8 core server:
cd builder/
export MAKEFLAGS=-j9
while make clean >/dev/null; make all V=1 >& /tmp/log; do echo -n . ; done
Previously it would fail after <= 5 iterations. With this change it
runs for at least 100 iterations.
Parsing sources .conf files is not a fatal error (that file would just
be ignored), so explicitly state that such parsing errors are ignored.
This should address the last bit in RHBZ#1077817.
Convert the tests to the MiniTest test framework, but keeping the usage
of the old Test::Unit as fallback in case MiniTest is not available.
In the latter case, use a bit of "glue" to make the old API look like
the new API, so we can just rely on the newer MiniTest API.
Isolate in a common file all the standard boilerplate in tests, i.e. the
import of the test framework and the guestfs module (including the
import path hack needed for the latter).
Thanks to Vít Ondruch for the precious hints and suggestions.
Use parted to get the name of partitions in GPT layouts instead of
sgdisk, to reduce the possible discrepancy between output of tools.
The actual case here is that recent parted versions fixed/improved their
UTF-16 handling of partition names in GPT, and sgdisk seems to not be
properly handling them, returning also unicode control bytes.
Since parted can provide partition names already, just make use of it.
Since sgdisk is no more needed for part_get_name, the function is no
more optional on it.
Add the possibility to configure the proxy in each repository .conf
file, specifying whether use no proxy at all, follow the system
configuration or use a specific proxy.
Previous commit 97c57a8887 added a
potential bug in the sparsify build. If virt-sparsify had used a
*.mli file then it would have tried to run a command like:
ocamlc mlguestfs.cmxa -c foo.mli -o foo.cmi
This would fail because ocamlc doesn't know about native code
libraries (*.cmxa). In fact virt-sparsify was not affected by this
because it doesn't use any *.mli files.
Fix this by adjusting the automake variables.
If a disk has type 0x42 partition (which would indicate LDM), but LDM
is not available then try parsing the partition anyway. It might be
parseable as plain old NTFS.
There are two observations which make this possible: (1) virt-sparsify
contains at least one C unit, so automake thinks it is compiling a C
program. (2) Automake lets us add a *_LINK rule to override linking.
We list the C sources of virt-sparsify as virt_sparsify_SOURCES, so
automake thinks it is building a C program as normal.
We override virt_sparsify_LINK to make it actually link an OCaml
program.
We add virt_sparsify_DEPENDENCIES listing the OCaml objects so that
they get built before linking.
We need a small linker script (link.sh) which adds some options at the
end of the linker command line which are impossible to add using pure
automake.
Inspired by the same idea in supermin:
https://github.com/libguestfs/supermin/blob/master/src/Makefile.am
As long as over ~300MB is recovered, declare sparsification to be
successful in this test.
It looks as if the journal or other metadata takes up a variable
amount of space after sparsification.
We must avoid touching appliance/supermin.d unless it is necessary, so
that we avoid unnecessary rebuilds of the full appliance.
Unfortunately since we created temporary files there, even if we
didn't decide to keep those temporary files they would still end up
touching supermin.d. To stop this, move the temporary files out.
Exclude the arch-independent pkg-config files (no pkg-config available
in the appliance).
Exclude also the doc-base and reportbug files, typically found in Debian
systems.
Add a new lexer token, unused in the grammar, for the unknown lines in
index files; this should allow to better handle such kind of parsing
errors, removing the need to exit() directly (and leave things in an
unclean state).
Since HPET is specific to x86, we can safely add it its option only on
x86 and x86_64 when creating the libvirt XML (no more hitting the
launching failures due to that on other architectures).
Regarding the direct qemu launch, since qemu 1.1 (which is our current
minimum) "-ho-hpet" appears in the help only where actually supported,
so we could just checking for it and adding it only if present. This
should fix the architecture issues on this backend as well.
The boot partition name is /dev/ubda1 in this case, so use a small sed
script to canonicalize it for the test comparison.
This fixes commit f6a37740f2.
61323fa introduced a mandatory arch field within index files to
identify the architecture of the OS installed within a given template.
This change simply documents the requirement within the relevant
section of the virt-builder man page.
Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
This removes the internal APIs internal_set_libvirt_selinux_label and
internal_set_libvirt_selinux_norelabel_disks. The communication
between the libvirt domain and the backend now uses the backend
settings.
Currently the backend settings are treated as a list of strings. You
can set the whole list (clearing any strings there previously), but
you cannot search for an individual string or replace an individual
string.
This adds further APIs allowing you to do that. We treat the backend
settings as a list of environment-like strings (ie. name=value), and
add the following functions:
- set-backend-setting (name, value)
Set name=value. Any previous settings of name are cleared.
- get-backend-setting (name)
Search for name or name=value and return the value.
- clear-backend-setting (name)
Remove any name or name=value settings.
This also adds a regression test.
This is not used by libguestfs right now, but it does allow you to
build a python "distribution" of libguestfs, like this:
make -C python sdist
The distribution tarball will be in python/dist/
You can copy the distribution tarball somewhere, unpack it, and use
regular 'python setup.py' commands such as:
python setup.py build
python setup.py install [--prefix=...]
python setup.py --name
In future we hope to be able to upload the distribution tarball to
PyPi, but licensing issues prevent this at present.
guestfs___validate_guid was a new function added to utils.c in
commit beef77403c.
However utils.c should not include <guestfs-internal.h> since the
other functions in this file can be used by all front-end code, not
just libguestfs.so.
This function is only needed in libguestfs.so, so move it to another
source file, and remove include of <guestfs-internal.h> from utils.c.
Also: use 'size_t' for counting, not 'int'.
This fixes commit beef77403c.
Breaks Python distutils which doesn't use C99:
utils.c: In function ‘guestfs___copy_string_list’:
utils.c:79:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t j = 0; j < i; ++j)
^
utils.c:79:7: note: use option -std=c99 or -std=gnu99 to compile your code
[Gnulib tries to replace getopt because of the bug shown below.
However because -lgnu was not used in the Makefile, the replacement
failed. -- RWMJ]
from config.log:
/* This code dumps core on glibc 2.14. */
{
static char program[] = "program";
static char w[] = "-W";
static char dummy[] = "dummy";
char *argv[] = { program, w, dummy, NULL };
optind = opterr = 1;
if (getopt (3, argv, "W;") != 'W')
result |= 64;
}
gdb --quiet --readnow ./conftest -ex r -ex bt -ex detach -ex q
Reading symbols from /usr/src/packages/BUILD/libguestfs-1.26.0/conftest...expanding to full symbols...done.
Starting program: /usr/src/packages/BUILD/libguestfs-1.26.0/conftest
Missing separate debuginfo for /lib64/ld-linux-x86-64.so.2
Try: zypper install -C "debuginfo(build-id)=5d1a12e6f0e95331cc4e39df74ecbd5adb76a1f7"
Missing separate debuginfo for /lib64/libc.so.6
Try: zypper install -C "debuginfo(build-id)=a06caa12df8f953a453befa827c3145adaf6269a"
main(323) result 0
main(344) result 0
main(357) result 0
main(370) result 0
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b2dbf8 in _getopt_internal_r () from /lib64/libc.so.6
Detaching from program: /usr/src/packages/BUILD/libguestfs-1.26.0/conftest, process 31042
This change actually fixes build for me on sles11sp3 and 11.4.
1028650 POST https://bugzilla.redhat.com/show_bug.cgi?id=1028650
virt-* argument parser doesn't accept --arg=value (you have to use --arg value)
1099976 POST https://bugzilla.redhat.com/show_bug.cgi?id=1099976
virt-builder gives GPG warning message with gnupg2
1072062 POST https://bugzilla.redhat.com/show_bug.cgi?id=1072062
Ruby bindings for libguestfs throws an error periodically
1164708 POST https://bugzilla.redhat.com/show_bug.cgi?id=1164708
set-label can only set <=127 bytes for btrfs and <=126 bytes for ntfs filesystem which not meet the help message. Also for ntfs it should give a warning message when the length >128 bytes
1073917 POST https://bugzilla.redhat.com/show_bug.cgi?id=1073917
Remove files in package libguestfs-bash-completion, these files are bash completion files, some of the virt tool completion are already implement in another file, so can remove its completion file
set-label can only set <=63 bytes for btrfs and ntfs filesystem which not meet the help message. Also for btrfs and ntfs it should give a warning message when the length exceed the limited length
(* qemu-img convert is always possible, and quicker. It doesn't
* resize, but it does change the format.
@@ -439,50 +487,49 @@ let main () =
in
(* Plan how to create the disk image. *)
msg(f_"Planning how to build this image");
message(f_"Planning how to build this image");
letplan=
tryplan~max_depth:5transitionsitagsgoal
with
Failure"plan"->
eprintf(f_"%s: no plan could be found for making a disk image with\nthe required size, format etc. This is a bug in libguestfs!\nPlease file a bug, giving the command line arguments you used.\n")prog;
exit1
error(f_"no plan could be found for making a disk image with\nthe required size, format etc. This is a bug in libguestfs!\nPlease file a bug, giving the command line arguments you used.");
eprintf(f_"%s: no guest operating systems or multiboot OS found in this disk image\nThis is a failure of the source repository. Use -v for more information.\n")prog;
exit1in
error(f_"no guest operating systems or multiboot OS found in this disk image\nThis is a failure of the source repository. Use -v for more information.")
in
Customize_run.run~prog~debug~quietgrootops;
Customize_run.rungrootcmdline.ops;
(* Collect some stats about the final output file.
* Notes:
@@ -632,7 +686,7 @@ let main () =
* - Never fail here.
*)
letstats=
ifnotquietthen(
ifnot(quiet())then(
try
(* Calculate the free space (in bytes) across all mounted
* 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.
*)
openCommon_gettext.Gettext
openCommon_utils
openUtils
openPrintf
typecsum_t=
|SHA256ofstring
|SHA512ofstring
letstring_of_csum_t=function
|SHA256_->"sha256"
|SHA512_->"sha512"
letstring_of_csum=function
|SHA256c->c
|SHA512c->c
letverify_checksumcsumfilename=
letprog,csum_ref=
matchcsumwith
|SHA256c->"sha256sum",c
|SHA512c->"sha512sum",c
in
letcmd=sprintf"%s %s"prog(quotefilename)in
ifverbose()thenprintf"%s\n%!"cmd;
letlines=external_commandcmdin
matchlineswith
|[]->
error(f_"%s did not return any output")prog
|line::_->
letcsum_actual=fst(String.split""line)in
ifcsum_ref<>csum_actualthen
error(f_"%s checksum of template did not match the expected checksum!\n found checksum: %s\n expected checksum: %s\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!")
eprintf(f_"virt-builder: error: could not export public key\nUse the '-v' option and look for earlier error messages.\n");
exit1
);
ignore(import_keyfilegpgtmpdirdebugfilename);
fp
ifr<>0then
error(f_"could not export public key\nUse the '-v' option and look for earlier error messages.");
import_keyfilegpgtmpdirfilename
)else
""in
"",[]in
{
debug=debug;
gpg=gpg;
fingerprint=fingerprint;
subkeys_fingerprints=subkeys;
check_signature=check_signature;
gpghome=tmpdir;
}
@@ -138,6 +163,9 @@ and getxdigit = function
|'A'..'F'asc->Some(Char.codec-Char.code'A')
|_->None
letverifying_signaturest=
t.check_signature
letrecverifytfilename=
ift.check_signaturethen(
letargs=quotefilenamein
@@ -148,72 +176,57 @@ and verify_detached t filename sigfile =
ift.check_signaturethen(
matchsigfilewith
|None->
eprintf(f_"virt-builder: error: there is no detached signature file\nThis probably means the index file is missing a sig=... line.\nYou can use --no-check-signature to ignore this error, but that means\nyou are susceptible to man-in-the-middle attacks.\n");
exit1
error(f_"there is no detached signature file\nThis probably means the index file is missing a sig=... line.\nYou can use --no-check-signature to ignore this error, but that meansyou are susceptible to man-in-the-middle attacks.")
eprintf(f_"virt-builder: error: GPG failure: could not verify digital signature of file\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!\n");
exit1
);
ifr<>0then
error(f_"GPG failure: could not verify digital signature of file\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!");
eprintf(f_"virt-builder: error: fingerprint of signature does not match the expected fingerprint!\n found fingerprint: %s\n expected fingerprint: %s\n")
eprintf(f_"virt-builder: error: could not run sha512sum command to verify checksum\n");
exit1
);
letcsum_actual=read_whole_filecsum_filein
letcsum_actual=
letlen=String.lengthcsum_actualin
iflen>0&&csum_actual.[len-1]='\n'then
String.subcsum_actual0(len-1)
else
csum_actualin
ifcsum<>csum_actualthen(
eprintf(f_"virt-builder: error: checksum of template did not match the expected checksum!\n found checksum: %s\n expected checksum: %s\nTry:\n - Use the '-v' option and look for earlier error messages.\n - Delete the cache: virt-builder --delete-cache\n - Check no one has tampered with the website or your network!\n")
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.