Commit Graph

148 Commits

Author SHA1 Message Date
Pino Toscano
8bd80847fe inspect: correct osinfo ID for CentOS >= 8
CentOS 8 is represented with a simpler "centos8" osinfo ID.
2019-12-11 13:35:30 +01:00
Pino Toscano
206ce8bbf1 New API: luks_uuid
Return the UUID of a LUKS device.
2019-11-29 12:04:55 +01:00
Pino Toscano
72d83cc6eb build: remove unused gnulib modules
Remove gnulib modules that provide stuff clearly not used within
libguestfs (library, daemon, and C tools).  Among directly and
indirectly modules used previous (and now no more), they are:

  cycle-check
  d-ino
  dev-ino
  dup3
  dup3-tests
  fcntl-safer
  fcntl-safer-tests
  fdopendir
  fdopendir-tests
  filevercmp
  filevercmp-tests
  ftell
  ftell-tests
  ftello
  ftello-tests
  fts
  getaddrinfo
  getaddrinfo-tests
  getcwd
  getcwd-tests
  gnu-make
  hostent
  i-ring
  i-ring-tests
  iconv
  iconv-tests
  inet_ntop
  inet_ntop-tests
  isatty
  isatty-tests
  openat-safer
  openat-safer-tests
  opendirat
  ptsname_r
  ptsname_r-tests
  read-file
  read-file-tests
  rewinddir
  servent
  ttyname_r
  ttyname_r-tests
  xgetcwd

Some of the removed modules are still used pulled indirectly as
dependency of other modules.  There should be no behaviour change on
recent Linux distros, although older distros were not tested (adding
a module back is easy, anyway).

Remove accordingly unused automake variables, and ignored files.
2019-11-28 13:09:21 +01:00
Richard W.M. Jones
85c99edec1 v2v: Remove virt-v2v.
It has moved to a new repository:
https://github.com/libguestfs/virt-v2v
2019-11-13 12:49:55 +00:00
Eric Blake
730642676b drives: Typo fix
Favor 'atomically' over 'atomicly'.

Signed-off-by: Eric Blake <eblake@redhat.com>
2019-09-10 16:40:17 +01:00
Pino Toscano
c9543de73d launch: libvirt: fix custom hypervisor check
Previously, is_custom_hv() used to compare the QEMU executable found
during configure to the hypervisor set to check whether it is a custom
one; however, the QEMU found at configure time can be different than
what libvirt was configured with.

This fixes the libvirt backend when libguestfs is configured with a
different QEMU, that now will be specified as emulator overriding the
libvirt one.
2019-05-24 14:49:05 +02:00
Pino Toscano
797925cc3c launch: libvirt: get default QEMU from domcapabilities
Parse the libvirt domain capabilities for the default emulator
capabilities, and get the path to the default QEMU executable.
2019-05-24 14:49:05 +02:00
Pino Toscano
9d1fc91cca build: stop using GUESTFS_WARN_DEPRECATED
This is no more used now, as compiler deprecation warnings are triggered
by default.
2019-04-23 18:08:19 +02:00
Pino Toscano
3720900438 inspect: get icon of OpenMandriva guests
Followup of commit a4ef6716b4.
2019-04-08 13:34:11 +02:00
Pino Toscano
c4205809bc inspect: correct osinfo ID for ALT Linux >= 8
ALT Linux 8.x has different IDs in osinfo-db, so return the proper IDs
for the newest stable series.
2019-04-04 10:25:03 +02:00
Pino Toscano
764ee8c74e inspect: return osinfo short IDs for rolling distros
Return the right osinfo short IDs for some rolling Linux distributions,
such as Arch Linux, Gentoo, and Void Linux.  Their IDs were recently
added to osinfo-db.
2019-04-04 10:25:03 +02:00
Pino Toscano
1086599ad8 OCaml tools: fix 3999 -> 3339 typo
RFC 3339 is the actual RFC for date/time strings.
Typo found by Martin 'eagle eyes' Kletzander.

Fixes commit f79129b8dc.
2019-04-01 18:44:00 +02:00
Richard W.M. Jones
e047cc4da8 lib: qemu: rbd: Properly escape IPv6 addresses.
Each ':' character in the address must be escaped from qemu.

Thanks: Jonathan Wright
2019-04-01 17:31:25 +01:00
Pino Toscano
f79129b8dc OCaml tools: output messages into JSON for machine readable
When the machine readable mode is enabled, print all the messages
(progress, info, warning, and errors) also as JSON in the machine
readable stream: this way, users can easily parse the status of the
OCaml tool, and report that back.

The formatting of the current date time into the RFC 3999 format is done
in C, because of the lack of OCaml APIs for this.
2019-03-29 13:57:47 +01:00
Pino Toscano
70514dfaf1 common/mltools: allow fd for machine readable output
Allow to specify a file descriptor for the machine readable output.

Use the same assumption as done in v2v, i.e. that Unix.file_descr is
simply the int file descriptor.
2019-03-29 13:57:47 +01:00
Richard W.M. Jones
ba7fa03923 lib: direct: Set QEMU_AUDIO_DRV=none when testing schema.
Schema parsing was failing with errors such as:

libguestfs: QMP parse error: '[' or '{' expected near end of file (ignored)

This happened because the QMP command was actually completely failing
and never printing a result at all.  This happens because the qemu
audio driver can't be set up without a console.  We can suppress this
by setting the environment variable QEMU_AUDIO_DRV=none, which is the
same thing that libvirt does, and also the same thing that we are
already doing when launching the real appliance subprocess.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=1692047
2019-03-27 11:53:31 +00:00
Pino Toscano
3ed32996dd inspect: return osinfo short IDs for recent Windows versions
Return the right osinfo short IDs for the majority of Windows versions
since Windows XP.
2019-03-25 16:10:20 +01:00
Pino Toscano
c648052690 inspect: fix icon of RHEL
Use a better icon for RHEL guests, still provided by redhat-logos (or
equivalent in downstream distributions), and which fits a better
definition of logo for the distribution.

Thanks to Ray Strode for the hints.
2019-03-25 16:10:20 +01:00
Pino Toscano
c8a26adf1d inspect: get icon of Gentoo guests
The icon is installed by x11-themes/gentoo-artwork, which is not
installed by default (and most probably only on "desktop"
installations), although it's the best hit so far...
2019-02-07 19:00:13 +01:00
Pino Toscano
f41a75cea6 inspect: revamp icon extraction for *SUSE guests
Newer versions do not have the 24px distributor.png icon; OTOH they have
the 48px version, so look for that one before the 24px one.

Also, bump the size limit to 10K, as newer versions of the icon are
bigger than 3K.
2019-02-06 15:19:53 +01:00
Pino Toscano
6ff95acc72 inspect: factor out find_png helper function
Isolate the code for looking for a PNG file among a specified list from
the icon_ubuntu implementation, and switch that function to it.

This is just code refactoring, with no behaviour changes.
2019-02-06 15:15:08 +01:00
Pino Toscano
032b8d4c72 inspect: bump size limit for Mageia guests
Newer versions of the logo in Cauldron are almost 3K, so bump the limit
to 10K for now.
2019-02-06 15:05:51 +01:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
492a945791 Revert "launch: libvirt: Use qemu-bridge-helper to implement a full network (RHBZ#1148012)."
We've been carrying this exact patch in RHEL 7 for several years.  It
reverts the change made in 2014 where we switched to using the virbr0
bridge for libguestfs networking instead of SLIRP.  We thought SLIRP
was going to become unsupported in qemu, but recently there have been
more encouraging signs since it looks like SLIRP will be spun off as a
separate project, running as a modular process and properly secured
and supported.

This reverts commit 224de20b9a.
2019-01-07 15:03:07 +00:00
Richard W.M. Jones
52ec462fea lib: direct: Move serial option from -drive to -device.
qemu deprecated and removed this option from the -drive parameter,
resulting in:

  Block format 'raw' does not support the option 'serial'

See also:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg574583.html
2018-12-12 12:29:33 +00:00
Pino Toscano
78a29dbd1e lib: inspect: tweak limits of package manager files
Tweak the limits of the files of package managers downloaded to list the
installed applications:
- bump RPM 'Packages' up to 500M: Fedora installations upgraded to each
  new Fedora release have an ever-growing file, reported to be even
  slightly bigger than 400M
- reduce the other files down to 50M: they are usually small, not bigger
  than 1M-5M, so 50M is a good enough high threshold
2018-11-30 13:44:28 +01:00
Pino Toscano
b12e168efc lib: inspect: split limits of package manager files
Use different defines for the limits of the package manager files
downloaded during the inspection of applications.  This way it will be
possible to tweak each of them without affecting the others.

This is a minor refactoring, with no behaviour change.
2018-11-30 13:44:28 +01:00
Pino Toscano
8197336a9b lib: move MAX_PKG_DB_SIZE to inspect-apps
It is used only there, so avoid exposing it to all the users of
guestfs-internal.h.

This is just code motion.
2018-11-30 13:44:28 +01:00
Richard W.M. Jones
9c8d133455 Replace -nodefconfig with -no-user-config.
This option was removed from qemu for no apparent reason except to
break existing consumers.  It does the same as -no-user-config, added
in May 2012, so use that instead.
2018-11-30 12:18:01 +00:00
Martin Kletzander
d3478036a8 Fix include for xattr.h
The proper file that should be included is `sys/xattr.h` as that comes from
`glibc` and not `attr/xattr.h` which ships with the `attr` utility.

New enough `attr` utility (at least 2.4.48 in my case) even includes a #warning
in `attr/xattr.h` for projects that still have this mistake in the code.
2018-11-23 08:34:16 +00:00
Richard W.M. Jones
b0daa89ef0 lib/launch-libvirt.c: Fix tabs/spaces issue in this file.
Convert randomly used tabs into spaces.
2018-11-02 19:42:23 +00:00
Richard W.M. Jones
296d6a9fda lib, p2v: Use single_element() macro where possible.
After the previous commit, wherever we had:

  start_element ("foo") {
    string ("bar");
  } end_element ();

this can now be replaced by:

  single_element ("foo", "bar");
2018-11-02 19:38:11 +00:00
Richard W.M. Jones
6d5959a045 common/utils: Move libxml2 writer macros to a common header file.
In some places when generating XML output in C code we use some clever
macros:

  start_element ("memory") {
    attribute ("unit", "MiB");
    string_format ("%d", g->memsize);
  } end_element ();

This commit which is mostly refactoring moves the repeated definitions
of these macros into a common header file.

I also took this opportunity to change / clean up the macros:

 - The macros are now documented properly.

 - comment() and empty_element() macros are now available everywhere.

 - Error handling has been made generic.

 - Added do..while(0) around some of the macros to make them safe to
   use in all contexts.
2018-11-02 15:15:04 +00:00
Richard W.M. Jones
ba82fb023d lib: Increase default memory assigned to the appliance.
With recent Linux kernels, adding and partitioning 255 disks causes
the appliance to run out of memory.  This causes a test failure in
tests/disks/test-255-disks.sh.  This change gives the appliance enough
memory to complete the test.
2018-11-02 13:44:26 +00:00
Richard W.M. Jones
f00f920ad3 lib: Use qemu-img info -U option to avoid locking error.
https://bugs.launchpad.net/qemu/+bug/1740364
2018-11-02 13:19:51 +00:00
Richard W.M. Jones
6f605a0804 lib: direct: Query qemu binary for availability of KVM (RHBZ#1605071).
When using the direct backend, you should see the result of testing
the qemu binary for the availability of KVM:

  libguestfs: qemu KVM: enabled

Thanks: Andrea Bolognani.
2018-09-21 10:56:25 +01:00
Richard W.M. Jones
56318f0b5f ppc64le: Don't use -cpu parameter under any circumstances (RHBZ#1605071). 2018-08-28 22:24:46 +01:00
Pino Toscano
afa8111b75 OCaml tools: add output selection for --machine-readable
Add an optional argument for --machine-readable to select the output,
adding a new function to specifically write data to that output stream.
The possible choices are:
* --machine-readable: to stdout, like before
* --machine-readable=file:name-of-file: to the specified file
* --machine-readable=stream:stdout: explicitly to stdout
* --machine-readable=stream:stderr: explicitly to stderr

Adapt all the OCaml-based tools to use the new function, so the
--machine-readable choice is respected.
2018-08-23 18:03:39 +02:00
Pino Toscano
962e8b6255 lib: create: avoid one extra string allocation
When creating the qemu-img command, use the guestfs_int_cmd_add_arg &
guestfs_int_cmd_add_arg_format APIs to add the proper filename directly,
without creating a string for it.

This should cause no functional change.
2018-08-23 13:22:00 +02:00
Richard W.M. Jones
55dfcb2211 New API: lvm_scan, deprecate vgscan (RHBZ#1602353).
The old vgscan API literally ran vgscan.  When we switched to using
lvmetad (in commit dd162d2cd5) this
stopped working because lvmetad now ignores plain *scan commands
without the --cache option.

We documented that vgscan would rescan PVs, VGs and LVs, but without
activating them.

I have introduced a new API (lvm_scan) which scans or rescans PVs, VGs
and LVs.  It has an optional activate parameter allowing activation of
any new LVs that are found.

With lvmetad this nicely maps to the single command:

 pvscan --cache [--activate ay]
2018-07-26 12:02:59 +01:00
Yuri Chornoivan
adbf1bc320 Fix minor typos 2018-06-25 08:35:43 +01:00
Richard W.M. Jones
70bc83f893 lib: libvirt: Convert all socket parameters to an absolute path (RHBZ#1588451). 2018-06-21 13:19:04 +01:00
Pino Toscano
4f927e58a9 fuse: fix build when not available
The 'localmountpoint' variable in the handle is available only when
building with FUSE support, so guard it in a proper #ifdef block.

Fixes commit 296370fb86.

Thanks to: Corentin Labbe (both reporting, and testing)
2018-06-15 18:36:39 +02:00
Richard W.M. Jones
2add3c6995 utils: Factor out hexdump code used by --enable-packet-dump.
Factor out the common code used to hexdump the protocol when
./configure --enable-packet-dump is used.

It's not quite a straight refactor because I had to fix some
signedness bugs in the code which were not revealed before because
this code is usually disabled.
2018-06-04 05:36:56 -04:00
Adam Robinson
431d8c8c1e macOS: Include <rpc/types.h> before <rpc/xdr.h>.
The ordering of includes is required on this platform.
2018-05-15 11:15:54 +01:00
Pino Toscano
2dd9fd8530 appliance: initialize the appliance_files struct
Some compilers do not manage to figure out that the members of it are
set only when search_appliance() in the end returns 1, which is already
checked.  Help them a bit by resetting the appliance_files struct on our
own, so they will not report that 'appliance.kernel', and the others are
used as uninitialized.
2018-05-04 15:49:20 +02:00
Mykola Ivanets
296370fb86 fuse: mount_local: Fix crash when called from Java binding.
"localmountpoint" parameter is allocated in JNI before calling
mount_local and freed afterward.  But guestfs handle keeps reference
to passed "localmountpoint" parameter and will try to access it in
umount_local and free after mount_local_run caller thread ends
which leads to a crash (an attempt to access to already freed memory).

RWMJ: Remove ‘const’ from definition of localmountpoint, and
wrap a comment at 80 columns.
2018-05-02 12:07:16 +01:00
Pino Toscano
526f6b4012 launch: libvirt: free format string
When the result guestfs_disk_format() is not known, free the string
before returning an error.
2018-05-01 17:26:16 +01:00
Pino Toscano
d00e860ef0 New API: f2fs_expand
Expose the resize.f2fs utility from f2fs-tools, to expand a f2fs
filesystem.
2018-04-19 11:30:29 +02:00
Richard W.M. Jones
e79286f717 qemu: Fix transcription error in conversion of yajl to jansson.
This broke qemu mandatory locking detection.

Fixes commit bd1c5c9f4d.
2018-03-29 20:19:53 +01:00