]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agovirsh: alphabetize domain commands in man page
Jonathon Jongsma [Tue, 27 Aug 2019 20:35:56 +0000 (15:35 -0500)]
virsh: alphabetize domain commands in man page

It appears that all commands were originally fully in alphabetical order
but as new commands were added, they were sometimes inserted out of
order.  Fix up all domain commands so that they're in alphabetical order
again.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh: add 'guestinfo' command
Jonathon Jongsma [Tue, 27 Aug 2019 20:35:55 +0000 (15:35 -0500)]
virsh: add 'guestinfo' command

The 'guestinfo' command uses the new virDomainGetGuestInfo() API to
query information about the specified domain and print it out for the
user. The output is modeled roughly on the 'domstats' command.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: guestinfo: handle unsupported agent commands
Jonathon Jongsma [Tue, 27 Aug 2019 20:35:54 +0000 (15:35 -0500)]
qemu: guestinfo: handle unsupported agent commands

When we're collecting guest information, older agents may not support
all agent commands. In the case where the user requested all info
types (i.e. types == 0), ignore unsupported command errors and gather as
much information as possible. If the agent command failed for some other
reason, or if the user explciitly requested a specific info type (i.e.
types != 0), abort on the first error.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolib: minor fixes to virDomainGetGuestInfo docs
Jonathon Jongsma [Tue, 27 Aug 2019 20:35:53 +0000 (15:35 -0500)]
lib: minor fixes to virDomainGetGuestInfo docs

Due to a typo, some of the field names didn't have closing quotes,
the information about the hostname was omitted and there was an
empty line missing after filesystem info description (which helps
our docs generator produce better looking HTML).

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Mention new --precopy-bandwidth parameter for virsh migrate
Jim Fehlig [Tue, 27 Aug 2019 20:16:47 +0000 (14:16 -0600)]
news: Mention new --precopy-bandwidth parameter for virsh migrate

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Make anchors follow HTML5
Michal Privoznik [Tue, 27 Aug 2019 15:21:32 +0000 (17:21 +0200)]
docs: Make anchors follow HTML5

According to HTML specification, <a name=''> works in HTML4, but
<a id=''> works in both HTML4 and HTML5. This is followed even in
docs/page.xsl where HTML bookmark links are generated only for
those anchors which have @id attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: support bootindex on vfio-ccw mdev devices
Boris Fiuczynski [Tue, 27 Aug 2019 14:19:23 +0000 (16:19 +0200)]
qemu: support bootindex on vfio-ccw mdev devices

Add support to specify a boot order on vfio-ccw passthrough devices.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: refactor mdev validation method signatures
Boris Fiuczynski [Tue, 27 Aug 2019 14:19:22 +0000 (16:19 +0200)]
qemu: refactor mdev validation method signatures

Refactoring the method signatures in preparation for
checking boot index of the mediated devices.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: make error messages device specific
Boris Fiuczynski [Tue, 27 Aug 2019 14:19:21 +0000 (16:19 +0200)]
qemu: make error messages device specific

Changing the error messages to report the problem encountered.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: move hostdev boot validation into domain validation
Boris Fiuczynski [Tue, 27 Aug 2019 14:19:20 +0000 (16:19 +0200)]
qemu: move hostdev boot validation into domain validation

Moving the hostdev boot support validation from the command line
generator code into the domain validation code.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: add vhost scsi hostdev boot unsupported test
Boris Fiuczynski [Tue, 27 Aug 2019 14:19:19 +0000 (16:19 +0200)]
tests: add vhost scsi hostdev boot unsupported test

Adding a failure test for booting from a vhost scsi hostdev device.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: add vfio-ap mdev tests
Boris Fiuczynski [Tue, 27 Aug 2019 14:19:18 +0000 (16:19 +0200)]
tests: add vfio-ap mdev tests

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoremote_daemon_dispatch: Don't open code xdr_free()
Michal Privoznik [Tue, 27 Aug 2019 09:49:27 +0000 (11:49 +0200)]
remote_daemon_dispatch: Don't open code xdr_free()

At two places we are open coding xdr_free():
remoteRelayDomainEventTunable() and
remoteRelayDomainEventJobCompleted().
Bot of these functions use make_nonnull_domain() to put domain
IDs tuple into return structure and then continue encoding the
rest of structure. If that fails, they call VIR_FREE() directly.
While this okay, we should use xdr_free() which frees the whole
return structure for us.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoremote_daemon_dispatch: Don't leak @ret on failure
Michal Privoznik [Tue, 27 Aug 2019 09:47:52 +0000 (11:47 +0200)]
remote_daemon_dispatch: Don't leak @ret on failure

If there's a problem in encoding @ret (for instance
virTypedParamsSerialize() fails) then @ret is leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoremote: Check for limits when encoding typed params
Michal Privoznik [Tue, 27 Aug 2019 08:57:49 +0000 (10:57 +0200)]
remote: Check for limits when encoding typed params

The same way we check for limits when decoding typed parameters
(virTypedParamsDeserialize()) we should do the same check when
serializing them so that we don't put onto the wire more than our
limits allow. Surprisingly, we were doing so explicitly in some
places but not all of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoremote_daemon_dispatch: Check for limit properly in remoteDispatchConnectGetAllDomain...
Michal Privoznik [Tue, 27 Aug 2019 09:05:21 +0000 (11:05 +0200)]
remote_daemon_dispatch: Check for limit properly in remoteDispatchConnectGetAllDomainStats

The return structure is a bit complicated and that's why it is
very easy to check for RPC limits incorrectly. The structure is
an array of remote_domain_stats_record structures with the limit
of REMOTE_DOMAIN_LIST_MAX. The latter structure then poses a
different limit on typed params:
REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX (which is what we are
checking for mistakenly).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agovirsh: Add support for setting bandwidth in migrate
Jim Fehlig [Mon, 26 Aug 2019 19:41:25 +0000 (13:41 -0600)]
virsh: Add support for setting bandwidth in migrate

Commit f15789ec added support for setting postcopy migration bandwidth to
the migrate subcommand. This change does the same for precopy migration.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirhostdevtest: Reset libvirt error on expected failure
Michal Privoznik [Tue, 27 Aug 2019 14:08:12 +0000 (16:08 +0200)]
virhostdevtest: Reset libvirt error on expected failure

If a libvirt error occurred during a test, then virTestRun()
reports it (regardless of test returning success or failure).
For instance, in this specific case, a hostdev is detached twice
and the second attempt is expected to fail. It does fail and
libvirt error is reported which is then printed onto stderr.
Insert virResetLastError() calls on appropriate places to avoid
that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhostdevtest: s/VIR_DEBUG/VIR_TEST_DEBUG/
Michal Privoznik [Tue, 27 Aug 2019 14:07:36 +0000 (16:07 +0200)]
virhostdevtest: s/VIR_DEBUG/VIR_TEST_DEBUG/

There's no need to have VIR_DEBUG() really.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhostdevtest: Drop useless VIR_TEST_DEBUG
Michal Privoznik [Tue, 27 Aug 2019 14:04:53 +0000 (16:04 +0200)]
virhostdevtest: Drop useless VIR_TEST_DEBUG

The virTestRun() already reports the same.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhostdevtest: Drop most of 'cleanup' and 'out' labels
Michal Privoznik [Tue, 27 Aug 2019 14:00:55 +0000 (16:00 +0200)]
virhostdevtest: Drop most of 'cleanup' and 'out' labels

In this test there is this macro CHECK_LIST_COUNT() which checks
if a list of PCI devices contains expected count. If it doesn't
an error is reported and 'goto cleanup' is invoked. There's no
real reason for that as even since its introduction there is no
cleanup done and all 'cleanup' labels contain nothing but
'return'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhostdevtest: Check for integer retval in more verbose way
Michal Privoznik [Tue, 27 Aug 2019 14:00:10 +0000 (16:00 +0200)]
virhostdevtest: Check for integer retval in more verbose way

There are few functions called from the test which return an
integer but their retval is compared as if it was a pointer.
Now, there is nothing wrong with that from machine POV, but
from readability perspective it's wrong.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirhashtest: Drop useless new line
Michal Privoznik [Fri, 3 May 2019 08:30:44 +0000 (10:30 +0200)]
virhashtest: Drop useless new line

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Always put '\n' at the end of VIR_TEST_VERBOSE
Michal Privoznik [Fri, 3 May 2019 08:45:58 +0000 (10:45 +0200)]
tests: Always put '\n' at the end of VIR_TEST_VERBOSE

Similarly to the previous commit, VIR_TEST_VERBOSE should put
'\n' at the end of each call so that the output is not broken.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Always put a '\n' after each debug print
Michal Privoznik [Fri, 3 May 2019 08:31:02 +0000 (10:31 +0200)]
tests: Always put a '\n' after each debug print

There is an inconsistency with VIR_TEST_DEBUG() calls. One half
(roughly) of calls does have the newline character the other one
doesn't. Well, it doesn't have it because it assumed blindly that
new line will be printed, which is not the case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Don't duplicate domain def in qemuDomainGetFSInfo
Michal Privoznik [Tue, 27 Aug 2019 07:07:39 +0000 (09:07 +0200)]
qemu: Don't duplicate domain def in qemuDomainGetFSInfo

Introduced in v3.0.0-rc1~336, the commit message doesn't really
justifies the expensive domain def copy creation. Now, that
vm->def is guarded in this function by job acquirement we can use
vm->def directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Acquire domain job in qemuDomainGetFSInfo and qemuDomainGetGuestInfo
Michal Privoznik [Tue, 27 Aug 2019 06:53:53 +0000 (08:53 +0200)]
qemu: Acquire domain job in qemuDomainGetFSInfo and qemuDomainGetGuestInfo

These two functions work with vm->def in their critical sections
(i.e. after the job was acquired and before it is released). But
that means, they need QUERY domain job too to prevent vm->def
change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agorpm: move nc dep into the libvirt-daemon sub-RPM
Daniel P. Berrangé [Tue, 20 Aug 2019 09:15:47 +0000 (10:15 +0100)]
rpm: move nc dep into the libvirt-daemon sub-RPM

The remote client invokes the 'nc' binary on the remote server to tunnel
access to the socket. As such the 'nc' binary needs to be pulled in only
by the libvirt-daemon sub-RPM, not the libvirt-client sub-RPM.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpm: depend on /usr/bin/nc instead of nc
Daniel P. Berrangé [Tue, 20 Aug 2019 09:13:01 +0000 (10:13 +0100)]
rpm: depend on /usr/bin/nc instead of nc

The 'nc' RPM does not in fact exist anymore, this is a virtual provide
from the nmap-ncat RPM which the maintainer wishes to delete. Change the
dep to use the actual binary path we want to invoke.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpm: don't enable socket activation in upgrade if --listen present
Daniel P. Berrangé [Fri, 23 Aug 2019 12:13:40 +0000 (13:13 +0100)]
rpm: don't enable socket activation in upgrade if --listen present

Currently during RPM upgrade we restart libvirtd and unconditionally
enable use of systemd socket activation for the UNIX sockets.

If the user had previously given the --listen arg to libvirtd though,
this will no longer be honoured if socket activation is used.

We could start libvirtd-tcp.socket or libvirtd-tls.socket for this,
but mgmt tools like puppet/ansible might not be expecting this.
So for now we silently disable socket activation if we see --listen
was previously set on the host.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: forbid the --listen arg when systemd socket activation
Daniel P. Berrangé [Thu, 22 Aug 2019 13:52:16 +0000 (14:52 +0100)]
remote: forbid the --listen arg when systemd socket activation

When using systemd socket activation the --listen arg has no
effect. This is confusing to users upgrading from previous versions of
libvirt as their config is silently ignored. Turn use of --listen into a
fatal error when sockets are passed from systemd.

This helps the admin discover the change in behaviour and thus decide
whether to stick with socket activation or revert to previous behaviour.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: move timeout arg into sysconf file
Daniel P. Berrangé [Thu, 22 Aug 2019 13:51:06 +0000 (14:51 +0100)]
remote: move timeout arg into sysconf file

We need to give users the ability to customize the length of the
shutdown timeout, or even disable timeouts entirely. Thus we must move
the timeout arg into the sysconf file, instead of the service unit.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: use Wants instead of Requires for libvirtd sockets
Daniel P. Berrangé [Thu, 22 Aug 2019 13:48:46 +0000 (14:48 +0100)]
remote: use Wants instead of Requires for libvirtd sockets

To facilitate upgrades from earlier versions of libvirt which did not
use socket activation for libvirtd, we want to allow the libvirtd socket
units to be disabled (masked). This can only be supported if we use the
weaker Wants statement instead of Requires.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpm: set runstatedir to /run directory
Daniel P. Berrangé [Tue, 20 Aug 2019 16:38:58 +0000 (17:38 +0100)]
rpm: set runstatedir to /run directory

Use the %{_rundir} RPM variable to set the configure runstatedir
variable to /run.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: support customization of runstatedir variable with old autoconf
Daniel P. Berrangé [Tue, 20 Aug 2019 10:44:24 +0000 (11:44 +0100)]
build: support customization of runstatedir variable with old autoconf

Many distros have moved /var/run to /run with the introduction of
systemd. /var/run still exists as a symlink to /run, but its usage
is deprecated.

autoconf added a --runstatedir option back in 2013 but there's still no
new release of autoconf that includes this.

gnulib meanwhile added support to propagate this arg's value to
configmake.h, but it falls back to $localstatedir/run for autoconf 2.69
and older, which is what every distro today has.

To deal with this problem we add a --with-runstatedir arg that then sets
the $runstatedir env variable that future autoconf's --runstatedir arg
will also use. This finally enables $runstatedir to be pointed to /run.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: honour the RUNSTATEDIR variable in all code
Daniel P. Berrangé [Tue, 20 Aug 2019 15:05:12 +0000 (16:05 +0100)]
src: honour the RUNSTATEDIR variable in all code

All code using LOCALSTATEDIR "/run" is updated to use RUNSTATEDIR
instead. The exception is the remote driver client which still
uses LOCALSTATEDIR "/run". The client needs to connect to remote
machines which may not be using /run, so /var/run is more portable
due to the /var/run -> /run symlink.

Some duplicate paths in the apparmor code are also purged.

There's no functional change by default yet since both expressions
expand to the same value.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: honour $(runstatedir) in make rules
Daniel P. Berrangé [Tue, 20 Aug 2019 15:08:19 +0000 (16:08 +0100)]
build: honour $(runstatedir) in make rules

Creating various directories using $(runstatedir) instead of
$(localstatedir)/run.

There's no functional change by default yet since both expressions
expand to the same value.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosystemd: honour $runstatedir in socket unit files
Daniel P. Berrangé [Tue, 20 Aug 2019 10:57:46 +0000 (11:57 +0100)]
systemd: honour $runstatedir in socket unit files

If a systemd socket uses /var/run in its path, systemd prints a warning
at runtime

[   15.139976] systemd[1]: /usr/lib/systemd/system/virtlockd.socket:5:
  ListenStream= references a path below legacy directory /var/run/,
  updating /var/run/libvirt/virtlockd-sock → /run/libvirt/virtlockd-sock;
  please update the unit file accordingly.

This minimal change updates the socket unit files to honour the
$runstatedir path.

There's no functional change by default yet since both expressions
expand to the same value.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: use $(COMMON_UNIT_VARS) for logging/locking systemd units
Daniel P. Berrangé [Wed, 21 Aug 2019 10:12:00 +0000 (11:12 +0100)]
build: use $(COMMON_UNIT_VARS) for logging/locking systemd units

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_command: remove unnecessary labels and ret variables
Ján Tomko [Tue, 20 Aug 2019 12:33:44 +0000 (14:33 +0200)]
qemu_command: remove unnecessary labels and ret variables

The recent cleanups allow us to clean up the code a bit.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildCommandLine: use VIR_RETURN_PTR for cmd
Ján Tomko [Mon, 26 Aug 2019 19:32:36 +0000 (21:32 +0200)]
qemuBuildCommandLine: use VIR_RETURN_PTR for cmd

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_command: use VIR_AUTOUNREF
Ján Tomko [Tue, 20 Aug 2019 11:59:10 +0000 (13:59 +0200)]
qemu_command: use VIR_AUTOUNREF

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildShmemCommandLine: use VIR_AUTOFREE for devstr
Ján Tomko [Tue, 20 Aug 2019 11:25:24 +0000 (13:25 +0200)]
qemuBuildShmemCommandLine: use VIR_AUTOFREE for devstr

Now that it's only used once.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildShmemCommandLine: add chardev variable
Ján Tomko [Tue, 20 Aug 2019 11:24:57 +0000 (13:24 +0200)]
qemuBuildShmemCommandLine: add chardev variable

That way devstr will only be used for the device string.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildSmpCommandLine: use virCommandAddArgBuffer directly
Ján Tomko [Tue, 20 Aug 2019 11:23:36 +0000 (13:23 +0200)]
qemuBuildSmpCommandLine: use virCommandAddArgBuffer directly

Instead of getting the string then passing it to virCommand.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildRNGCommandLine: use VIR_AUTOFREE
Ján Tomko [Tue, 20 Aug 2019 11:22:53 +0000 (13:22 +0200)]
qemuBuildRNGCommandLine: use VIR_AUTOFREE

Use separate variables for the chardev and the device.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE
Ján Tomko [Tue, 20 Aug 2019 11:21:28 +0000 (13:21 +0200)]
qemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE

Reduce the scope of the variable to get it freed for every controller
processed.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildNetworkDriveURI: use VIR_AUTOPTR for virURI
Ján Tomko [Tue, 20 Aug 2019 11:11:13 +0000 (13:11 +0200)]
qemuBuildNetworkDriveURI: use VIR_AUTOPTR for virURI

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_command: use VIR_AUTOFREE for variables used once
Ján Tomko [Tue, 20 Aug 2019 11:05:03 +0000 (13:05 +0200)]
qemu_command: use VIR_AUTOFREE for variables used once

Remove the VIR_FREE's from the cleanup sections.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_command: use VIR_AUTOPTR for virJSONValue
Ján Tomko [Tue, 20 Aug 2019 10:39:39 +0000 (12:39 +0200)]
qemu_command: use VIR_AUTOPTR for virJSONValue

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_command: switch to VIR_AUTOCLEAN for virBuffer
Ján Tomko [Tue, 20 Aug 2019 10:33:02 +0000 (12:33 +0200)]
qemu_command: switch to VIR_AUTOCLEAN for virBuffer

Simplify the code by annotating all the temporary virBuffers
with VIR_AUTOCLEAN.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoapi: fix typo in virDomainGetGuestInfo docs
Ján Tomko [Mon, 26 Aug 2019 19:01:22 +0000 (21:01 +0200)]
api: fix typo in virDomainGetGuestInfo docs

s/strign/string/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoxenconfig: move contents to libxl driver and remove directory
Jim Fehlig [Fri, 23 Aug 2019 18:34:46 +0000 (12:34 -0600)]
xenconfig: move contents to libxl driver and remove directory

After the legacy xen driver was removed the libxl driver became
the only consumer of xenconfig. Move the few files in xenconfig
to the libxl driver and remove the directory.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Implement virDomainGetGuestInfo()
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:22 +0000 (11:31 -0500)]
qemu: Implement virDomainGetGuestInfo()

Iimplements the new guest information API by querying requested
information via the guest agent.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: add helper for getting full FSInfo
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:21 +0000 (11:31 -0500)]
qemu: add helper for getting full FSInfo

This function adds the complete filesystem information returned by the
qemu agent to an array of typed parameters with field names intended to
to be returned by virDomainGetGuestInfo()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: add support for new fields in FSInfo
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:20 +0000 (11:31 -0500)]
qemu: add support for new fields in FSInfo

Since version 3.0, qemu has returned disk usage statistics in
guest-get-fsinfo. And since 3.1, it has returned information about the
disk serial number and device node of disks that are targeted by the
filesystem.

Unfortunately, the public API virDomainGetFSInfo() returns the
filesystem info using a virDomainFSInfo struct, and due to API/ABI
guarantees it cannot be extended. So this new information cannot
easily be added to the public API. However, it is possible to add this
new filesystem information to a new virDomainGetGuestInfo() API which
will be based on typed parameters and is thus more extensible.

In order to support these two use cases, I added an internal struct
which the agent code uses to return all of the new data fields. This
internal struct can be converted to the public struct at a cost of some
extra memory allocation.

In a following commit, this additional information will be used within
virDomainGetGuestInfo().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: add helper for querying timezone info
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:19 +0000 (11:31 -0500)]
qemu: add helper for querying timezone info

This function queries timezone information within the guest and adds
the information to an array of typed parameters with field names
intended to be returned to virDomainGetGuestInfo()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: add helper function for querying OS info
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:18 +0000 (11:31 -0500)]
qemu: add helper function for querying OS info

This function queries the guest operating system information and adds
the returned information to an array of typed parameters with field
names intended to be returned in virDomainGetGuestInfo().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: add helper for getting guest users
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:17 +0000 (11:31 -0500)]
qemu: add helper for getting guest users

This function fetches the list of logged-in users from the qemu agent
and adds them to a list of typed parameters so that they can be used
internally in libvirt.

Also add some basic tests for the function.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoremote: implement virDomainGetGuestInfo
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:16 +0000 (11:31 -0500)]
remote: implement virDomainGetGuestInfo

Add daemon and client code to serialize/deserialize
virDomainGetGuestInfo().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agolib: add virDomainGetGuestInfo()
Jonathon Jongsma [Fri, 23 Aug 2019 16:31:15 +0000 (11:31 -0500)]
lib: add virDomainGetGuestInfo()

This API is intended to aggregate several guest agent information
queries and is ispired by stats API virDomainListGetStats(). It is
anticipated that this information will be provided by a guest agent
running within the domain.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Split out preparing of single snapshot from qemuDomainSnapshotDiskDataCollect
Peter Krempa [Mon, 12 Aug 2019 13:03:37 +0000 (15:03 +0200)]
qemu: Split out preparing of single snapshot from qemuDomainSnapshotDiskDataCollect

Move the internals into qemuDomainSnapshotDiskDataCollectOne to make it
obvious what's happening after moving more code here.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Restrict file existence check only for local storage
Peter Krempa [Mon, 12 Aug 2019 11:48:51 +0000 (13:48 +0200)]
qemu: snapshot: Restrict file existence check only for local storage

Soon we'll allow more protocols and storage types with snapshots where
we in some cases can't check whether the storage already exists.
Restrict the sanity checks whether the destination images exist or not
for local storage where it's easy. For any other case we will fail
later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Remove cleanup label in qemuDomainSnapshotPrepareDiskExternal
Peter Krempa [Mon, 12 Aug 2019 11:47:36 +0000 (13:47 +0200)]
qemu: Remove cleanup label in qemuDomainSnapshotPrepareDiskExternal

Refactor the code to avoid having a cleanup label. This will simplify
the change necessary when restricting this check in an upcoming patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Remove dead code from qemuDomainSnapshotUpdateDiskSources
Peter Krempa [Mon, 12 Aug 2019 10:16:35 +0000 (12:16 +0200)]
qemu: driver: Remove dead code from qemuDomainSnapshotUpdateDiskSources

dd->src is always allocated in this function as it contains the new
source for the snapshot which is meant to replace the disk source.

The label handling code executed if that source was not present thus is
dead code. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Don't modify persistent XML if disk source is different
Peter Krempa [Fri, 9 Aug 2019 13:15:07 +0000 (15:15 +0200)]
qemu: snapshot: Don't modify persistent XML if disk source is different

While the VM is running the persistent source of a disk might differ
e.g. as the 'newDef' was redefined. Our snapshot code would blindly
rewrite the source of such disk if it shared the 'target'. Fix this by
checking whether the source is the same in the first place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Flag backing store strings with authentication
Peter Krempa [Thu, 15 Aug 2019 17:29:43 +0000 (19:29 +0200)]
util: storagefile: Flag backing store strings with authentication

Using inline authentication for storage volumes will not work properly
as libvirt requires use of the secret driver for the auth data and
thus would not be able to represent the passwords stored in the backing
store string.

Make sure that the backing store parsers return 1 which is a sign for
the caller to not use the file in certain cases.

The test data include iscsi via a json pseudo-protocol string and URIs
with the userinfo part being present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Don't traverse storage sources unusable by VM
Peter Krempa [Fri, 16 Aug 2019 09:34:27 +0000 (11:34 +0200)]
util: storagefile: Don't traverse storage sources unusable by VM

virStorageFileGetMetadataRecurse would include files in the backing
chain which would not really be usable by libvirt directly e.g.
when such file would be promoted to the top layer by an active block
commit as for example inline authentication data can't be represented in
the VM xml file. The idea is to use secrets for this.

With the changes to the backing store string parsers we can report and
propagate if such a thing is present in the configuration and thus start
skipping those files in the backing chain traversal code. This approach
still allows to report the appropriate backing store string in the
storage driver which doesn't directly use the backing file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Clarify docs for '@report_broken' of virStorageFileGetMetadata
Peter Krempa [Fri, 16 Aug 2019 09:28:03 +0000 (11:28 +0200)]
util: storagefile: Clarify docs for '@report_broken' of virStorageFileGetMetadata

virStorageFileGetMetadata does not report error if we can't interrogate
the file somehow. Clarify this in the description of the @report_broken
flag as it implies we should report an error in that case. The problem
is that we don't know whether there's a problem and unfortunately just
offload it to qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Add handling of unusable storage sources
Peter Krempa [Fri, 16 Aug 2019 09:14:31 +0000 (11:14 +0200)]
util: storagefile: Add handling of unusable storage sources

Introduce new semantics to virStorageSourceNewFromBacking and some
of the helpers used by it which propagate the return value from the
callers.

The new return value introduced by this patch allows to notify the
calller that the parsed virStorageSource correctly describes the source
but contains data such as inline authentication which libvirt does not
want to support directly. This means that such file would e.g. unusable
as a storage source (e.g. when actively commiting the overlay to it) or
would not work with blockdev.

The caller will then be able to decide whether to consider this backing
file as viable or just fall back to qemu dealing with it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virstorage: Allow testing return value of virStorageSourceNewFromBackingAbsolute
Peter Krempa [Thu, 15 Aug 2019 17:27:43 +0000 (19:27 +0200)]
tests: virstorage: Allow testing return value of virStorageSourceNewFromBackingAbsolute

Modify testBackingParse to allow testing other return values of the
backing store string parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Modify arguments of virStorageSourceNewFromBackingAbsolue
Peter Krempa [Thu, 15 Aug 2019 14:43:40 +0000 (16:43 +0200)]
util: storagefile: Modify arguments of virStorageSourceNewFromBackingAbsolue

Return the parsed storage source via an pointer in arguments and return
an integer from the function. Describe the semantics with a comment for
the function and adjust callers to the new semantics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Preserve return value in virStorageSourceParseBackingJSONUriStr
Peter Krempa [Thu, 15 Aug 2019 14:21:55 +0000 (16:21 +0200)]
util: storagefile: Preserve return value in virStorageSourceParseBackingJSONUriStr

virStorageSourceParseBackingURI will report special return values in
some cases. Preserve it in virStorageSourceParseBackingJSONUriStr.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storage: Modify return value of virStorageSourceNewFromBacking
Peter Krempa [Thu, 15 Aug 2019 12:49:49 +0000 (14:49 +0200)]
util: storage: Modify return value of virStorageSourceNewFromBacking

Return the storage source definition via a pointer in the arguments and
document the returned values. This will simplify the possibility to
ignore certain backing store types which are not representable by
libvirt.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: storage: Refactor cleanup in testBackingParse
Peter Krempa [Thu, 15 Aug 2019 17:16:21 +0000 (19:16 +0200)]
tests: storage: Refactor cleanup in testBackingParse

Automatically clean the temporary buffer and get rid of the cleanup
label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: viruri: Add test for password in URI userinfo
Peter Krempa [Thu, 15 Aug 2019 14:16:59 +0000 (16:16 +0200)]
tests: viruri: Add test for password in URI userinfo

While it's a bad idea to use userinfo to pass credentials via a URI add
a test that we at least do the correct thing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON
Peter Krempa [Thu, 15 Aug 2019 14:25:47 +0000 (16:25 +0200)]
util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON

Automatically free the 'root' temporary variable to get rid of some
complexity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Simplify cleanup handling in virStorageSourceParseBackingURI
Peter Krempa [Thu, 15 Aug 2019 14:06:51 +0000 (16:06 +0200)]
util: storagefile: Simplify cleanup handling in virStorageSourceParseBackingURI

Automatically clean the 'uri' variable and get rid of the 'cleanup'
label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storagefile: Remove cleanup label from virStorageSourceParseBackingJSONiSCSI
Peter Krempa [Thu, 15 Aug 2019 13:54:04 +0000 (15:54 +0200)]
util: storagefile: Remove cleanup label from virStorageSourceParseBackingJSONiSCSI

There is no cleanup code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: storage: Simplify cleanup path handling in virStorageSourceParseBackingJSONInternal
Peter Krempa [Thu, 15 Aug 2019 13:41:58 +0000 (15:41 +0200)]
util: storage: Simplify cleanup path handling in virStorageSourceParseBackingJSONInternal

Automatically free the intermediate JSON data to get rid of the cleanup
section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: alias: Generate 'qomName' of disk with useraliases
Peter Krempa [Fri, 16 Aug 2019 15:01:10 +0000 (17:01 +0200)]
qemu: alias: Generate 'qomName' of disk with useraliases

Commit fb64e176f4f forgot to delete the check that short-circuits the
disk alias creation if the alias is already present. The side effect
of this is that the creation qomName which is necessary to be able to
refer to disk frontends when -blockdev is used was skipped when user
aliases are used.

Fix it by deleting the check. Also prevent any potential memory leaks
from calling this function repeatedly by creating the qomName only when
it's not present.

https://bugzilla.redhat.com/show_bug.cgi?id=1741838

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Allow graceful console shutdown
Michal Privoznik [Fri, 23 Aug 2019 11:37:25 +0000 (13:37 +0200)]
virsh: Allow graceful console shutdown

Currently, whenever there's a regular EOF on the console stream
or an error the virStreamAbort() is called regardless. While this
may not actually break anything, we should call virStreamFinish()
to let the daemon know we've successfully received all the data
and are shutting down the stream gracefully.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agostorage_driver: Don't crash in storagePoolCreateXML
Michal Privoznik [Fri, 23 Aug 2019 13:11:20 +0000 (15:11 +0200)]
storage_driver: Don't crash in storagePoolCreateXML

In my recent patches I've introduced
virStoragePoolObjIsStarting() which is then used to protect
storage pool definition when the pool object is locked and
unlocked during long running jobs. Well, my patches did not
anticipate that @obj can be NULL under 'cleanup' label in
storagePoolCreateXML() (for instance when parsing XML fails).
This imperfection is causing libvirtd to crash then.

Fixes: 13284a6b83 storage_driver: Protect pool def during startup and build
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agotools: console: Relax stream EOF handling
Roman Bolshakov [Wed, 21 Aug 2019 13:33:18 +0000 (16:33 +0300)]
tools: console: Relax stream EOF handling

Regular VM shutdown triggers the error for existing session of virsh
console and it returns with non-zero exit code:
  error: internal error: console stream EOF

The message and status code are misleading because there's no real
error. virStreamRecv returns 0 correctly when EOF is reached.

Existing implementations of esx, fd, and remote streams behave the same
for virStreamFinish and virStreamAbort: they close the stream. So, we
can continue to use virStreamAbort to handle EOF and errors from
virStreamRecv but additonally we can report error if virStreamAbort
fails.

Fixes: 29f2b5248c6 ("tools: console: pass stream/fd errors to user")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Make references to global symbols indirect in test drivers
Roman Bolshakov [Wed, 21 Aug 2019 16:13:23 +0000 (19:13 +0300)]
tests: Make references to global symbols indirect in test drivers

A library has to be built with -flat_namespace to get all references to
global symbols indirected. That can also be achieved with two-level
namespace interposition but we're not using explicit symbol
interposition since it's more verbose and requires massive changes to
the mocks.

This provides a way to interpose a mock for virQEMUCapsProbeHostCPU from
qemucpumock and fixes domaincapstest on macOS.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Avoid gnulib replacements in mocks
Roman Bolshakov [Wed, 21 Aug 2019 16:13:22 +0000 (19:13 +0300)]
tests: Avoid gnulib replacements in mocks

gnulib headers change stat, lstat and open to replacement functions,
even for function definitions. This effectively disables standard
library overrides in virfilewrapper and virmockstathelpers since they
are never reached.

Rename the functions and provide a declartion that uses correct
assembler name for the mocks.

This fixes firmware lookup in domaincapstest on macOS.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Use flat namespace on macOS
Roman Bolshakov [Wed, 21 Aug 2019 16:13:21 +0000 (19:13 +0300)]
tests: Use flat namespace on macOS

Test executables and mocks have assumption that any symbol can be
replaced with LD_PRELOAD. That's not a case for macOS unless flat
namespace is used, because every external symbol reference records the
library to be looked up. And the symbols cannot be replaced unless dyld
interposing is used.

Setting DYLD_FORCE_FLAT_NAMESPACE changes symbol lookup behaviour to be
similar to Linux dynamic linker. It's more lightweight solution than
explicitly decorating all mock symbols as interpositions and building
libvirt as interposable dynamic library.

This fixes vircryptotest and allows to proceed other tests that rely on
mocks a little bit further.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Lookup extended stat/lstat in mocks
Roman Bolshakov [Wed, 21 Aug 2019 16:13:20 +0000 (19:13 +0300)]
tests: Lookup extended stat/lstat in mocks

macOS syscall interface (/usr/lib/system/libsystem_kernel.dylib) has
three kinds of stat but only one of them can be used to fill
"struct stat": stat$INODE64.

virmockstathelpers looks up regular stat instead of stat$INODE64.  That
causes a failure in qemufirmwaretest because "struct stat" is laid out
differently from the values returned by stat.

Introduce VIR_MOCK_REAL_INIT_ALIASED that can be used to lookup
stat$INODE64 and lstat$INODE64 and use it to setup real functions on
macOS.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agobuild: Use flat namespace for libvirt on macOS
Roman Bolshakov [Wed, 21 Aug 2019 16:13:19 +0000 (19:13 +0300)]
build: Use flat namespace for libvirt on macOS

>From ld(1):

  By default all references resolved to a dynamic library record the
  library to which they were resolved. At runtime, dyld uses that
  information to directly resolve symbols. The alternative is to use the
  -flat_namespace option.  With flat namespace, the library is not
  recorded.  At runtime, dyld will search each dynamic library in load
  order when resolving symbols. This is slower, but more like how other
  operating systems resolve symbols.

That fixes the set of tests that preload a mock library to replace
library symbols:
  qemublocktest
  qemumonitorjsontest
  viriscsitest
  virmacmaptest
  virnetserverclienttest

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Drop /private CWD prefix in commandhelper
Roman Bolshakov [Wed, 21 Aug 2019 16:13:18 +0000 (19:13 +0300)]
tests: Drop /private CWD prefix in commandhelper

/tmp is a symbolic link to /private/tmp on macOS. That causes failures
in commandtest, because getcwd returns /private/tmp and the expected
output doesn't match to "CWD: /tmp".

Rathern than making a copy of commanddata solely for macOS, the /private
prefix is stripped.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Remove -module flag for mocks
Roman Bolshakov [Wed, 21 Aug 2019 16:13:17 +0000 (19:13 +0300)]
tests: Remove -module flag for mocks

macOS has two kinds of loadable libraries: MH_BUNDLE, and MH_DYLIB.
bundle is used for plugins that are loaded with dlopen/dlsym/dlclose.
And there's no way to preload a bundle into an application. dynamic
linker (dyld) will reject it when finds it in DYLD_INSERT_LIBRARIES.

Unfortunately, a bundle is built if -module flag is provided to libtool.
The flag has been removed to build dylibs with ".dylib" suffix.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Add lib- prefix to all mocks
Roman Bolshakov [Wed, 21 Aug 2019 16:13:16 +0000 (19:13 +0300)]
tests: Add lib- prefix to all mocks

In preparation libtool "-module" flag removal, add lib prefix to all
mock shared objects.

While at it, introduce VIR_TEST_MOCK macros that makes path out of mock
name to be used with VIR_TEST_PRELOAD or VIR_TEST_MAIN_PRELOAD.  That,
hopefully, improves readability, reduces line length and allows to
tailor VIR_TEST_MOCK for specific platform if it has shared library
suffix different from ".so".

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Preload mocks with DYLD_INSERT_LIBRARIES on macOS
Roman Bolshakov [Wed, 21 Aug 2019 16:13:15 +0000 (19:13 +0300)]
tests: Preload mocks with DYLD_INSERT_LIBRARIES on macOS

LD_PRELOAD has no effect on macOS. Instead, dyld(1) provides a way for
symbol hooking via DYLD_INSERT_LIBRARIES. The variable should contain
colon-separated paths to the dylibs to be inserted.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Avoid IPv4-translated IPv6 address in sockettest
Roman Bolshakov [Wed, 21 Aug 2019 16:13:14 +0000 (19:13 +0300)]
tests: Avoid IPv4-translated IPv6 address in sockettest

getnameinfo on macOS formats certain IPv6 addresses as IPv4-translated
addresses. The following pattern has been observed:
  ::ffff is formated as ::0.0.255.255
  ::fffe is formated as ::0.0.255.254
  ::ffff:0 is formated as ::255.255.0.0
  ::fffe:0 is formated as ::255.254.0.0
  ::ffff:0:0 is formated as ::ffff:0.0.0.0
  ::fffe:0:0 is formated as ::fffe:0:0
  ::ffff:0:0:0 is formated as ::ffff:0:0:0

The getnameinfo behavior causes a failure for:
  DO_TEST_PARSE_AND_FORMAT("::ffff", AF_UNSPEC, true);

Use non-ambigious IPv6 for parse/format testing.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agotests: Don't test octal localhost IP in sockettest on macOS
Roman Bolshakov [Wed, 21 Aug 2019 16:13:13 +0000 (19:13 +0300)]
tests: Don't test octal localhost IP in sockettest on macOS

getaddrinfo on macOS doesn't interpret octal IPv4 addresses. Only
inet_aton can be used for that. Therefore, from macOS standpoint
"0177.0.0.01" is not the same as "127.0.0.1".

The issue was also discovered by python and dotnet core:
  https://bugs.python.org/issue27612
  https://github.com/dotnet/corefx/issues/8362

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
5 years agovirpci: Rename virPCIDevice{Bind,Unbind}FromStubWithOverride
Michal Privoznik [Fri, 23 Aug 2019 09:45:01 +0000 (11:45 +0200)]
virpci: Rename virPCIDevice{Bind,Unbind}FromStubWithOverride

After my previous patches we have virPCIDeviceBindToStub() and
virPCIDeviceUnbindFromStub() which really do nothing but call
virPCIDeviceBindToStubWithOverride() and
virPCIDeviceUnbindFromStubWithOverride() respectively.
Drop "WithOverride" from the names and drop the thin wrappers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Document KVM assignment removal
Michal Privoznik [Tue, 20 Aug 2019 14:22:08 +0000 (16:22 +0200)]
news: Document KVM assignment removal

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Drop @driverActions enum
Michal Privoznik [Tue, 20 Aug 2019 11:52:55 +0000 (13:52 +0200)]
virpcimock: Drop @driverActions enum

This enum was introduced to model how RHEL-7 kernel behaves - for
some reason going with the old way (via new_id + bind) fails but
using driver_override succeeds. Well, we don't need to care about
that anymore since we don't create new_id file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Don't create new_id or remove_id files
Michal Privoznik [Tue, 20 Aug 2019 11:49:54 +0000 (13:49 +0200)]
virpcimock: Don't create new_id or remove_id files

Now that PCI attach/detach happens solely via driver_override
these two files are no longer needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirpcimock: Don't create "pci-stub" driver
Michal Privoznik [Tue, 20 Aug 2019 11:31:27 +0000 (13:31 +0200)]
virpcimock: Don't create "pci-stub" driver

Now that nothing supports "pci-stub" driver (aka KVM style of PCI
device assignment) there is no need for virpcimock to create it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>