]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoutil: storagefile: Properly set transport type when parsing NBD strings
Peter Krempa [Thu, 16 Jan 2020 11:34:13 +0000 (12:34 +0100)]
util: storagefile: Properly set transport type when parsing NBD strings

When parsing legacy NBD backing file strings such as
'nbd:unix:/tmp/sock:exportname=/' we'd fail to set the transport to
VIR_STORAGE_NET_HOST_TRANS_UNIX. This started to be a problem once we
actually started to generate config of the backing store on the command
line with -blockdev as the JSON code would try to format it as TCP and
fail with:

 internal error: argument key 'host' must not have null value

Set the type properly and add a test.

This bug was found by the libguestfs test suite in:

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reported-by: Ming Xie <mxie@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
5 years agobootstrap: remove 26 more gnulib modules
Daniel P. Berrangé [Wed, 8 Jan 2020 11:19:48 +0000 (11:19 +0000)]
bootstrap: remove 26 more gnulib modules

 * send, recv: we use write & read for sockets so don't
   need these portability wrappers
 * ioctl, fcntl, fcntl-h: any usage of these is conditionally
   compiled and excludes Windows
 * ttyname_r: this exists in all supported platforms that
   we require now
 * environ: the tests explicitly declare this global variable
 * intprops: the code has been converted / simplified
 * nonblocking: we have a custom impl now to work with our
   own sockets wrappers
 * openpty: custom checks in configure.ac cope with portability
 * accept, bind, connect, getpeername, getsockname, listen,
   setsockopt, socket: code needing Windows portability uses
   our wrapper functions
 * close: avoids abort when passed invalid FD on Windows.
   Our VIR_FORCE_CLOSE wrapper avoids calling close(-1)
   and it is reasonable to abort in other scenarios in
   the RPC client
 * physmem: the gnulib code has been partially imported
 * warnings, manywarnings: copy the files directly into
   our local m4 dir
 * verify: replaced by G_STATIC_ASSERT
 * pthread_sigmask: none of the fixed portability problems
   affect libvirt's usage on current supported platforms
 * termios: the header is now conditionally included only
   when needed
 * time_r: replaced with GDateTime APIs

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: replace gmtime_r/localtime_r/strftime with GDateTime
Daniel P. Berrangé [Thu, 9 Jan 2020 14:07:15 +0000 (14:07 +0000)]
src: replace gmtime_r/localtime_r/strftime with GDateTime

gmtime_r/localtime_r are mostly used in combination with
strftime to format timestamps in libvirt. This can all
be replaced with GDateTime resulting in simpler code
that is also more portable.

There is some boundary condition problem in parsing POSIX
timezone offsets in GLib which tickles our test suite.
The test suite is hacked to avoid the problem. The upsteam
GLib bug report is

  https://gitlab.gnome.org/GNOME/glib/issues/1999

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: conditionally exclude cfmakeraw/termios.h on WIN32
Daniel P. Berrangé [Thu, 9 Jan 2020 13:18:50 +0000 (13:18 +0000)]
src: conditionally exclude cfmakeraw/termios.h on WIN32

The GNULIB termios module ensures termios.h exists (but
is none the less empty) when building for Windows. We
already exclude usage of the functions that would exist
in a real termios.h, so having an empty termios.h is
not especially useful.

It is simpler to just put all use of termios.h related
functions behind a "#ifndef WIN32" conditional.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: replace verify(expr) with G_STATIC_ASSERT(expr)
Daniel P. Berrangé [Thu, 9 Jan 2020 10:39:55 +0000 (10:39 +0000)]
src: replace verify(expr) with G_STATIC_ASSERT(expr)

G_STATIC_ASSERT() is a drop-in functional equivalent of
the GNULIB verify() macro.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: replace atomic ops impls with g_atomic_int*
Daniel P. Berrangé [Thu, 9 Jan 2020 12:54:51 +0000 (12:54 +0000)]
util: replace atomic ops impls with g_atomic_int*

Libvirt's original atomic ops impls were largely copied
from GLib's code at the time. The only API difference
was that libvirt's virAtomicIntInc() would return a
value, but g_atomic_int_inc was void. We thus use
g_atomic_int_add(v, 1) instead, though this means
virAtomicIntInc() now returns the original value,
instead of the new value.

This rewrites libvirt's impl in terms of g_atomic_int*
as a short term conversion. The key motivation was to
quickly eliminate use of GNULIB's verify_expr() macro
which is not a direct match for G_STATIC_ASSERT_EXPR.
Long term all the callers should be updated to use
g_atomic_int* directly.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: pull gnulib physmem impl into local code
Daniel P. Berrangé [Wed, 8 Jan 2020 13:54:17 +0000 (13:54 +0000)]
util: pull gnulib physmem impl into local code

We don't need all the platforms gnulib deals with, so
this is a cut down version of GNULIB's physmem.c
code. This also allows us to integrate libvirt's
error reporting functions closer to the error cause.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: convert code to use new socket portability wrappers
Daniel P. Berrangé [Wed, 8 Jan 2020 12:11:16 +0000 (12:11 +0000)]
src: convert code to use new socket portability wrappers

Convert to use socket wrappers. Aside from the header file
include change, this requires changing close -> closesocket
since our portability isn't trying to replace the close
function.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: introduce compat wrappers for Winsock2
Daniel P. Berrangé [Wed, 8 Jan 2020 10:41:00 +0000 (10:41 +0000)]
util: introduce compat wrappers for Winsock2

Windows sockets take a SOCKET HANDLE object instead of a
file descriptor. Wrap them in the same way that gnulib
does so that they use C runtime file descriptors.

While we could in theory use GSocket, it is hard to get
the exact same semantics libvirt has for its current
socket usage. Wrapping the Winsock2 APIs is thus the
easiest approach in the short term.

In changing the socke wrappers we need to re-implement
the nonblocking function too, since the GNULIB impl
expects to be used with the GNULIB sockets wrappers.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: add detection of openpty function
Daniel P. Berrangé [Tue, 7 Jan 2020 16:19:52 +0000 (16:19 +0000)]
util: add detection of openpty function

All UNIX platforms we care about have openpty() in the libutil
library. Use of pty.h must also be made conditional, excluding
Win32.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: validate headers against local gnulib not git repo
Daniel P. Berrangé [Wed, 8 Jan 2020 18:03:12 +0000 (18:03 +0000)]
build: validate headers against local gnulib not git repo

Some syntax check rules validate usage of headers provided
by gnulib. We want to validate these only against the gnulib
modules we've chosen to use, not all modules, since we're
trying to eliminate them.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: always declare environ
Daniel P. Berrangé [Tue, 7 Jan 2020 16:16:19 +0000 (16:16 +0000)]
tests: always declare environ

Some UNIX platforms don't declare 'environ' in their
header files. We can unconditionally declare it ourselves
to avoid this problem.

There is no need to do this in the aa-helper code
since that is Linux only code.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: remove use of the INT_MULTIPLY_OVERFLOW macro
Daniel P. Berrangé [Tue, 14 Jan 2020 15:59:35 +0000 (15:59 +0000)]
src: remove use of the INT_MULTIPLY_OVERFLOW macro

The GLib g_size_checked_mul() function is not quite the
same signature, and gives compiler warnings due to not
correctly casting from gsize to guint64/32. Implementing
a replacement for INT_MULTIPLY_OVERFLOW is easy enough
to do ourselves.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: replace use of INT_BUFSIZE_BOUND macros
Daniel P. Berrangé [Tue, 14 Jan 2020 13:30:07 +0000 (13:30 +0000)]
src: replace use of INT_BUFSIZE_BOUND macros

Introduce a vastly simpler VIR_INT64_STR_BUFLEN constant
which is large enough for all cases where we currently
use INT_BUFSIZE_BOUND. This eliminates most use of the
gnulib intprops.h header.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoesx: remove compatibility for old libcurl
Daniel P. Berrangé [Wed, 15 Jan 2020 17:54:29 +0000 (17:54 +0000)]
esx: remove compatibility for old libcurl

RHEL7 has libcurl 7.29.0, which is the oldest of any
supported build platform. Thus we no longer need the
back compat for libcurl < 7.28.0.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoUse glib alloc API for virDomainFSInfo
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:17 +0000 (17:32 -0600)]
Use glib alloc API for virDomainFSInfo

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: use glib allocation apis for qemuAgentFSInfo
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:16 +0000 (17:32 -0600)]
qemu: use glib allocation apis for qemuAgentFSInfo

Switch from old VIR_ allocation APIs to glib equivalents.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: use glib alloc in qemuAgentGetFSInfoFillDisks()
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:15 +0000 (17:32 -0600)]
qemu: use glib alloc in qemuAgentGetFSInfoFillDisks()

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: remove qemuDomainObjBegin/EndJobWithAgent()
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:14 +0000 (17:32 -0600)]
qemu: remove qemuDomainObjBegin/EndJobWithAgent()

This function potentially grabs both a monitor job and an agent job at
the same time. This is problematic because it means that a malicious (or
just buggy) guest agent can cause a denial of service on the host. The
presence of this function makes it easy to do the wrong thing and hold
both jobs at the same time. All existing uses have already been removed
by previous commits.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: don't access vmdef within qemu_agent.c
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:13 +0000 (17:32 -0600)]
qemu: don't access vmdef within qemu_agent.c

In order to avoid holding an agent job and a normal job at the same
time, we want to avoid accessing the domain's definition while holding
the agent job. To achieve this, qemuAgentGetFSInfo() only returns the
raw information from the agent query to the caller. The caller can then
release the agent job and then proceed to look up the disk alias from
the vm definition. This necessitates moving a few helper functions to
qemu_driver.c and exposing the agent data structure (qemuAgentFSInfo) in
the header.

In addition, because the agent function no longer returns the looked-up
disk alias, we can't test the alias within qemuagenttest.  Instead we
simply test that we parse and return the raw agent data correctly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Don't store disk alias in qemuAgentDiskInfo
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:12 +0000 (17:32 -0600)]
qemu: Don't store disk alias in qemuAgentDiskInfo

The qemuAgentDiskInfo structure is filled with information received from
the agent command response, except for the 'alias' field, which is
retrieved from the vm definition. Limit this structure only to data that
was received from the agent message.

This is another intermediate step in moving the responsibility for
searching the vmdef from qemu_agent.c to qemu_driver.c so that we can
avoid holding an agent job and a normal job at the same time.

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: store complete agent filesystem information
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:11 +0000 (17:32 -0600)]
qemu: store complete agent filesystem information

In an effort to avoid holding both an agent and normal job at the same
time, we shouldn't access the vm definition from within qemu_agent.c
(i.e. while the agent job is being held). In preparation, we need to
store the full filesystem disk information in qemuAgentDiskInfo.  In a
following commit, we can pass this information back to the caller and
the caller can search the vm definition to match the filsystem disk to
an alias.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: rename qemuAgentGetFSInfoInternalDisk()
Jonathon Jongsma [Fri, 10 Jan 2020 23:32:10 +0000 (17:32 -0600)]
qemu: rename qemuAgentGetFSInfoInternalDisk()

The function name doesn't give a good idea of what the function does.
Rename to qemuAgentGetFSInfoFillDisks() to make it more obvious than it
is filling in the disk information in the fsinfo struct.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: add host CPU data files for validating die_id
Daniel P. Berrangé [Mon, 16 Dec 2019 18:08:24 +0000 (18:08 +0000)]
tests: add host CPU data files for validating die_id

Only Cascadelake-AP CPUs appear to report "die_id" values != 0 on Linux
right now - AMD EPYC's don't report "die_id" (at least with Fedora 31
kernel). Lacking access to Cascadelake-AP CPUs, this test data was from
a Fedora 31 QEMU guest launched with

 -cpu qemu64 -smp sockets=2,dies=3,cores=2,threads=1

Ideally we'd replace this data with some from a real machine reporting
"die_id", to ensure we're not mislead by QEMU's impl.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agohostcpu: add support for reporting die_id in NUMA topology
Daniel P. Berrangé [Mon, 16 Dec 2019 18:10:29 +0000 (18:10 +0000)]
hostcpu: add support for reporting die_id in NUMA topology

Update the host CPU code to report the die_id in the NUMA topology
capabilities. On systems with multiple dies, this fixes the bug
where CPU cores can't be distinguished:

 <cpus num='12'>
   <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
   <cpu id='1' socket_id='0' core_id='1' siblings='1'/>
   <cpu id='2' socket_id='0' core_id='0' siblings='2'/>
   <cpu id='3' socket_id='0' core_id='1' siblings='3'/>
 </cpus>

Notice how core_id is repeated within the scope of the same socket_id.

It now reports

 <cpus num='12'>
   <cpu id='0' socket_id='0' die_id='0' core_id='0' siblings='0'/>
   <cpu id='1' socket_id='0' die_id='0' core_id='1' siblings='1'/>
   <cpu id='2' socket_id='0' die_id='1' core_id='0' siblings='2'/>
   <cpu id='3' socket_id='0' die_id='1' core_id='1' siblings='3'/>
 </cpus>

So core_id is now unique within a (socket_id, die_id) pair.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add support for specifying CPU "dies" topology parameter
Daniel P. Berrangé [Mon, 16 Dec 2019 15:28:09 +0000 (15:28 +0000)]
qemu: add support for specifying CPU "dies" topology parameter

QEMU since 4.1.0 supports the "dies" parameter for -smp

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: remove unused virCapabilitiesSetHostCPU method
Daniel P. Berrangé [Wed, 18 Dec 2019 15:51:18 +0000 (15:51 +0000)]
conf: remove unused virCapabilitiesSetHostCPU method

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: add support for specifying CPU "dies" parameter
Daniel P. Berrangé [Mon, 16 Dec 2019 11:16:51 +0000 (11:16 +0000)]
conf: add support for specifying CPU "dies" parameter

Recently CPU hardware vendors have started to support a new structure
inside the CPU package topology known as a "die". Thus the hierarchy
is now:

  sockets > dies > cores > threads

This adds support for "dies" in the XML parser, with the value
defaulting to 1 if not specified for backwards compatibility.

For example a system with 64 logical CPUs might report

   <topology sockets="4" dies="2" cores="4" threads="2"/>

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Don't emit SUSPENDED_POSTCOPY event on destination
Jiri Denemark [Wed, 15 Jan 2020 14:24:55 +0000 (15:24 +0100)]
qemu: Don't emit SUSPENDED_POSTCOPY event on destination

When pause-before-switchover QEMU capability is enabled, we get STOP
event before MIGRATION event with postcopy-active state. To properly
handle post-copy migration and emit correct events commit
v4.10.0-rc1-4-geca9d21e6c added a hack to
qemuProcessHandleMigrationStatus which translates the paused state
reason to VIR_DOMAIN_PAUSED_POSTCOPY and emits
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY event when migration state changes
to post-copy.

However, the code was effective on both sides of migration resulting in
a confusing VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY event on the destination
host, where entering post-copy mode is already properly advertised by
VIR_DOMAIN_EVENT_RESUMED_POSTCOPY event.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirchrdev: Drop needless 'cleanup' label in virChrdevLockFileCreate()
Michal Privoznik [Wed, 8 Jan 2020 08:18:32 +0000 (09:18 +0100)]
virchrdev: Drop needless 'cleanup' label in virChrdevLockFileCreate()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirchrdev: Use more g_autofree and VIR_AUTOCLOSE
Michal Privoznik [Wed, 8 Jan 2020 08:18:31 +0000 (09:18 +0100)]
virchrdev: Use more g_autofree and VIR_AUTOCLOSE

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirchrdev: Don't leak mutex if virChrdevAlloc() fails
Michal Privoznik [Wed, 8 Jan 2020 08:18:30 +0000 (09:18 +0100)]
virchrdev: Don't leak mutex if virChrdevAlloc() fails

This is only a theoretical leak, but in virChrdevAlloc() we
initialize a mutex and if creating a hash table fails,
then virChrdevFree() is called which because of incorrect check
doesn't deinit the mutex.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirchrdev: Don't leak @dev member of virChrdevHashEntry struct
Michal Privoznik [Wed, 8 Jan 2020 08:18:29 +0000 (09:18 +0100)]
virchrdev: Don't leak @dev member of virChrdevHashEntry struct

When opening a console to a domain, we put a tuple of {path,
virStreamPtr} into a hash table that's private to the domain.
This is to ensure only one client at most has the console stream
open. Later, when the console is closed, the tuple is removed
from the hash table and freed. Except, @path won't be freed.

==234102== 60 bytes in 5 blocks are definitely lost in loss record 436 of 651
==234102==    at 0x4836753: malloc (vg_replace_malloc.c:307)
==234102==    by 0x5549110: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
==234102==    by 0x5562D1E: g_strdup (in /usr/lib64/libglib-2.0.so.0.6000.6)
==234102==    by 0x4A5A917: virChrdevOpen (virchrdev.c:412)
==234102==    by 0x17B64645: qemuDomainOpenConsole (qemu_driver.c:17309)
==234102==    by 0x4BC8031: virDomainOpenConsole (libvirt-domain.c:9662)
==234102==    by 0x13F854: remoteDispatchDomainOpenConsole (remote_daemon_dispatch_stubs.h:9211)
==234102==    by 0x13F72F: remoteDispatchDomainOpenConsoleHelper (remote_daemon_dispatch_stubs.h:9178)
==234102==    by 0x4AB0685: virNetServerProgramDispatchCall (virnetserverprogram.c:430)
==234102==    by 0x4AB01F0: virNetServerProgramDispatch (virnetserverprogram.c:302)
==234102==    by 0x4AB700B: virNetServerProcessMsg (virnetserver.c:136)
==234102==    by 0x4AB70CB: virNetServerHandleJob (virnetserver.c:153)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agogitpublish: add a subject prefix
Daniel P. Berrangé [Thu, 16 Jan 2020 12:35:15 +0000 (12:35 +0000)]
gitpublish: add a subject prefix

Now that we removed the subject prefix tag from the mailman config
we should set 'libvirt' as the subject when sending patches.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Stop domain on failed restore
Michal Privoznik [Mon, 13 Jan 2020 10:07:53 +0000 (11:07 +0100)]
qemu: Stop domain on failed restore

When resuming a domain from a save file, we read the domain XML
from the file, add it onto our internal list of domains, start
the qemu process, let it load the incoming migration stream and
resume its vCPUs afterwards. If anything goes wrong, the domain
object is removed from the list of domains and error is returned
to the caller. However, the qemu process might be left behind -
if resuming vCPUs fails (e.g. because qemu is unable to acquire
write lock on a disk) then due to a bug the qemu process is not
killed but the domain object is removed from the list.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1718707
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Use g_autoptr() for qemuDomainSaveCookie
Michal Privoznik [Mon, 13 Jan 2020 10:06:39 +0000 (11:06 +0100)]
qemu: Use g_autoptr() for qemuDomainSaveCookie

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuDomainSaveImageStartVM: Use g_autoptr() for virCommand
Michal Privoznik [Mon, 13 Jan 2020 10:05:41 +0000 (11:05 +0100)]
qemuDomainSaveImageStartVM: Use g_autoptr() for virCommand

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuDomainSaveImageStartVM: Use VIR_AUTOCLOSE for @intermediatefd
Michal Privoznik [Mon, 13 Jan 2020 09:07:32 +0000 (10:07 +0100)]
qemuDomainSaveImageStartVM: Use VIR_AUTOCLOSE for @intermediatefd

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirsh: Expose virDomainGetHostnameFlags
Julio Faracco [Fri, 27 Dec 2019 20:36:25 +0000 (17:36 -0300)]
virsh: Expose virDomainGetHostnameFlags

Our virsh already has 'domhostname' command. Add '--source'
argument to it so that users can chose between 'lease' and
'agent' sources. Also, implement completer for the argument.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolxc: Implement virDomainGetHostnameFlags
Julio Faracco [Thu, 9 Jan 2020 10:15:05 +0000 (11:15 +0100)]
lxc: Implement virDomainGetHostnameFlags

Since there is no guest agent in LXC world (yet), we can
implement _LEASE flag only.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu: Implement virDomainGetHostnameFlags
Julio Faracco [Thu, 9 Jan 2020 12:19:21 +0000 (13:19 +0100)]
qemu: Implement virDomainGetHostnameFlags

We have to keep the default - querying the agent if no flag is
set.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoIntroduce source flags to virDomainGetHostname()
Julio Faracco [Thu, 9 Jan 2020 10:12:37 +0000 (11:12 +0100)]
Introduce source flags to virDomainGetHostname()

There is a lots of possibilities to retrieve hostname information
from domain. Libvirt could use lease information from dnsmasq to
get current hostname too. QEMU supports QEMU-agent but it can use
lease source.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agognulib: Pull in latest changes
Andrea Bolognani [Tue, 14 Jan 2020 16:59:02 +0000 (17:59 +0100)]
gnulib: Pull in latest changes

In particular, we're interested in the following commits:

  commit 43b5194d5b156f8dd7ae576952568d331978f5f0
  Author: Bruno Haible <bruno@clisp.org>
  Date:   Sun Jan 5 20:42:12 2020 +0100

    tests: Avoid GCC over-optimization caused by _GL_ARG_NONNULL attributes.

    * lib/stdlib.in.h: Tweak last commit.

  commit b7d7afe10ddf599452bd80b8a840c830cd474b09
  Author: Bruno Haible <bruno@clisp.org>
  Date:   Sun Jan 5 09:13:25 2020 +0100

    tests: Avoid GCC over-optimization caused by _GL_ARG_NONNULL attributes.

    Reported by Jim Meyering in
    <https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00040.html>.

    * lib/stdlib.in.h (GNULIB_defined_canonicalize_file_name): New macro.
    (GNULIB_defined_ptsname_r): New macro.
    * tests/test-canonicalize.c (_GL_ARG_NONNULL): Define to empty.
    (main): Disable the NULL argument test if canonicalize_file_name does
    not come from gnulib.
    * tests/test-canonicalize-lgpl.c (_GL_ARG_NONNULL): Define to empty.
    (main): Disable the NULL argument test if canonicalize_file_name does
    not come from gnulib.
    * tests/test-ptsname_r.c (_GL_ARG_NONNULL): Define to empty.
    (test_errors): Disable the NULL argument test if ptsname_r does not come
    from gnulib.

since they fix a build failure caused by the gnulib tests failing
on ppc64le, as reported in

  https://www.redhat.com/archives/libvir-list/2020-January/msg00616.html

Reported-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Tracked-down-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoconf: do not generate machine names ending with a dash
Ján Tomko [Tue, 14 Jan 2020 05:20:52 +0000 (06:20 +0100)]
conf: do not generate machine names ending with a dash

As of systemd commit:

commit d65652f1f21a4b0c59711320f34266c635393c89
Author:     Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
CommitDate: 2018-12-10 09:56:56 +0100

    Partially unify hostname_is_valid() and dns_name_is_valid()

Dashes are no longer allowed at the end of machine names.

Trim the trailing dashes from the generated name before passing
it to machined.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoutil: add virBufferTrimChars
Ján Tomko [Tue, 14 Jan 2020 07:04:14 +0000 (08:04 +0100)]
util: add virBufferTrimChars

A new helper for trimming combinations of specified characters from
the tail of the buffer.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirbuftest: use field names when initalizing test info
Ján Tomko [Tue, 14 Jan 2020 07:06:34 +0000 (08:06 +0100)]
virbuftest: use field names when initalizing test info

Allow adding new fields without changing all the macros.

Otherwise the compiler complains that not all have been initialized:
../../tests/virbuftest.c:419:5: error: missing field 'arg' initializer [-Werror,-Wmissing-field-initializers]
    DO_TEST_ESCAPE("<td></td><td></td>",
    ^
../../tests/virbuftest.c:414:56: note: expanded from macro 'DO_TEST_ESCAPE'
        struct testBufAddStrData info = { data, expect }; \

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirbuftest: declare testBufAddStrData earlier
Ján Tomko [Tue, 14 Jan 2020 07:04:29 +0000 (08:04 +0100)]
virbuftest: declare testBufAddStrData earlier

Move the declaration to the beginning of the file for reuse.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirbuftest: remove unnecessary labels
Ján Tomko [Tue, 14 Jan 2020 07:10:25 +0000 (08:10 +0100)]
virbuftest: remove unnecessary labels

Remove the ret variables and labels from functions that no longer need
them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirbuftest: use g_autofree
Ján Tomko [Tue, 14 Jan 2020 07:04:54 +0000 (08:04 +0100)]
virbuftest: use g_autofree

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirbuftest: remove extra G_GNUC_UNUSED markers
Ján Tomko [Tue, 14 Jan 2020 07:05:56 +0000 (08:05 +0100)]
virbuftest: remove extra G_GNUC_UNUSED markers

These functions do use the opaque argument.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agomaint: Post-release version bump to 6.1.0
Ján Tomko [Tue, 3 Dec 2019 04:20:37 +0000 (21:20 -0700)]
maint: Post-release version bump to 6.1.0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoRelease of libvirt-6.0.0
Daniel Veillard [Wed, 15 Jan 2020 15:18:42 +0000 (16:18 +0100)]
Release of libvirt-6.0.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agonews: Document <disk type='nvme'/>
Michal Privoznik [Tue, 14 Jan 2020 08:24:52 +0000 (09:24 +0100)]
news: Document <disk type='nvme'/>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonews: News for RDT-MBM feature
Han Han [Tue, 14 Jan 2020 05:48:23 +0000 (13:48 +0800)]
news: News for RDT-MBM feature

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agovircgroupv2devices: free BPF map when replacing with new one
Pavel Hrdina [Mon, 13 Jan 2020 11:50:41 +0000 (12:50 +0100)]
vircgroupv2devices: free BPF map when replacing with new one

This leaks the FD of BPF map which means it will not be freed.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agonews: Update for libvirt 6.0.0
Andrea Bolognani [Mon, 13 Jan 2020 10:47:09 +0000 (11:47 +0100)]
news: Update for libvirt 6.0.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Rearrange a few entries
Andrea Bolognani [Mon, 13 Jan 2020 09:30:05 +0000 (10:30 +0100)]
news: Rearrange a few entries

Some were in the wrong section, some in the wrong version.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Fix typo (Libivrt -> Libvirt)
Andrea Bolognani [Mon, 13 Jan 2020 10:49:47 +0000 (11:49 +0100)]
news: Fix typo (Libivrt -> Libvirt)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_capabilities: Do not report USB as subsystem type if it is not available
Thomas Huth [Mon, 13 Jan 2020 08:04:57 +0000 (09:04 +0100)]
qemu_capabilities: Do not report USB as subsystem type if it is not available

libvirt currently always reports that USB is available as a bus subsystem
type when running "virsh domcapabilities". However, this is not always
true, for example the qemu-system-s390x binary normally never has support
for USB. Thus we should only report that USB is available if there is
also a USB host controller available where we can attach USB devices.

Reported-by: Sebastian Mitterle <smitterl@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1759849
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodomain_conf: Do not use USB by default for <input> devices on s390x
Thomas Huth [Mon, 13 Jan 2020 08:30:14 +0000 (09:30 +0100)]
domain_conf: Do not use USB by default for <input> devices on s390x

When trying to specify an input device on s390x without bus like this:

 <input type='keyboard'/>

... then libvirt currently complains:

 error: unsupported configuration: USB is disabled for this domain,
 but USB devices are present in the domain XML

This is somewhat confusing since the user did not specify an USB
device here. Since USB is not available on s390x, we should default
to the "virtio" bus here instead.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1790189
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Always format storage source auth and encryption under <source> for backing...
Peter Krempa [Fri, 10 Jan 2020 16:25:16 +0000 (17:25 +0100)]
conf: Always format storage source auth and encryption under <source> for backing files

Historically there are two places where we format authentication and
encryption for a disk. The logich which formats it for backing files was
flawed though and didn't format it at all. This worked if the image
became a backing file through the means of a snapshot but not directly.

Force formatting of the source and encryption for any non-disk case to
fix the issue.

This caused problems in many places as we use the formatter to copy the
definition. Effectively any copy lost the secret definition.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agotests: qemuxml2xml: Enable luks-disks-source-qcow2 case
Peter Krempa [Fri, 10 Jan 2020 16:35:10 +0000 (17:35 +0100)]
tests: qemuxml2xml: Enable luks-disks-source-qcow2 case

The test data was used only in xml->argv testing but it will have some
interresting fallout soon.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agotests: qemuxml2argv: Run luks-disks-source-qcow2 case with latest caps
Peter Krempa [Fri, 10 Jan 2020 16:49:42 +0000 (17:49 +0100)]
tests: qemuxml2argv: Run luks-disks-source-qcow2 case with latest caps

Try also the modern incarnation of the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agotests: qemuxml2argv: Add disk image with encrypted backing file
Peter Krempa [Fri, 10 Jan 2020 16:32:33 +0000 (17:32 +0100)]
tests: qemuxml2argv: Add disk image with encrypted backing file

Add another disk to luks-disks-source-qcow2 case to cover a backing
chain with encrypted members.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemuxml2*test: Fix hugepages-default-system-size tests
Jiri Denemark [Mon, 13 Jan 2020 08:39:22 +0000 (09:39 +0100)]
qemuxml2*test: Fix hugepages-default-system-size tests

Commit v5.10.0-269-g62065a6cb5 moved NUMA validation code to domain
definition time and appropriately adjusted affected test cases except
for hugepages-default-system-size. And since we don't mock
virGetSystemPageSizeKB in our tests, hugepages-default-system-size test
would fail on architectures (ppc64le) with default page size other than
4KiB.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoFix typo (cetificate -> certificate)
Andrea Bolognani [Mon, 13 Jan 2020 10:47:41 +0000 (11:47 +0100)]
Fix typo (cetificate -> certificate)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agovirerror: Make it easier to add new error number
Michal Privoznik [Thu, 9 Jan 2020 08:53:31 +0000 (09:53 +0100)]
virerror: Make it easier to add new error number

In v5.0.0-rc1~94 we switched from one huge switch() to an array
for translating error numbers into error messages. However, the
array is declared to have VIR_ERR_NUMBER_LAST items which makes
it impossible to spot this place by compile checking when adding
new error number.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonews: Mention problems with backing image format probing
Peter Krempa [Fri, 10 Jan 2020 11:28:19 +0000 (12:28 +0100)]
news: Mention problems with backing image format probing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: storage: Link to knowledge base when reporting missing image backing format
Peter Krempa [Fri, 10 Jan 2020 11:27:07 +0000 (12:27 +0100)]
util: storage: Link to knowledge base when reporting missing image backing format

Mention the knowledge base article which has tips how to fix the backing
chain to work with current libvirt.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: avoid re-execing test once for each mock
Daniel P. Berrangé [Thu, 9 Jan 2020 18:01:44 +0000 (18:01 +0000)]
tests: avoid re-execing test once for each mock

When debugging tests under GDB/valgrind there is a significant
delay each time an execve is done as they scan shared libraries
once again. For tests which use many mock libraries, we have
been invoking execve many times which makes the debug experience
horrible. This changes our framework to activate the full
set of mock libraries in one single execve.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: Add snapshot-revert qemu managedsave force
Michael Weiser [Fri, 3 Jan 2020 18:43:25 +0000 (19:43 +0100)]
docs: Add snapshot-revert qemu managedsave force

Add documentation for additional reason why snapshot-revert might need
to be forced. This explains why restoring an inactive snapshot while
there is managed saved state is refused by default.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Reformat snapshot-revert force reasons
Michael Weiser [Fri, 3 Jan 2020 18:43:24 +0000 (19:43 +0100)]
docs: Reformat snapshot-revert force reasons

Reformat explanations of the snapshot-revert force reasons in
preparation for more to be added. This is a simple reformat without any
wording changes.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Warn of restore with managed save being risky
Michael Weiser [Fri, 3 Jan 2020 18:43:23 +0000 (19:43 +0100)]
qemu: Warn of restore with managed save being risky

Internal snapshots of a non-running domain do not carry any memory state
and restoring such a snapshot will not replace existing saved memory
state. This allows a scenario, where a user first suspends a domain into
managedsave, restores a non-running snapshot and then resumes the domain
from managedsave. After that, the guest system will run with its
previous memory state atop a different disk state. The most obvious
possible fallout from this is extensive file system corruption. Swap
content and RAID bitmaps might also be off.

This has been discussed[1] and fixed[2] from the end-user perspective for
virt-manager.

This patch marks the restore operation as risky at the libvirt level,
requiring the user to remove the saved memory state first or force the
operation.

[1] https://www.redhat.com/archives/virt-tools-list/2019-November/msg00011.html
[2] https://www.redhat.com/archives/virt-tools-list/2019-December/msg00049.html

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Harmonize hypervisor names for QEMU and LXC
Michael Weiser [Fri, 3 Jan 2020 18:39:56 +0000 (19:39 +0100)]
docs: Harmonize hypervisor names for QEMU and LXC

Trivially replace usages of qemu and lxc in the virsh manpage with their
more heavily used and (according to Wikipedia) correct upper-case
spellings QEMU and LXC.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Suggested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Don't use NULL path from qemuDomainGetHostdevPath
Jiri Denemark [Thu, 9 Jan 2020 14:40:14 +0000 (15:40 +0100)]
qemu: Don't use NULL path from qemuDomainGetHostdevPath

Commit v5.10.0-290-g3a4787a301 refactored qemuDomainGetHostdevPath to
return a single path rather than an array of paths. When the function is
called on a missing device, it will now return NULL in @path rather than
a NULL array with zero items and the callers need to be adapted
properly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh migrate: Require --tls for --tls-destination
Jiri Denemark [Tue, 17 Dec 2019 13:31:10 +0000 (14:31 +0100)]
virsh migrate: Require --tls for --tls-destination

--tls-destination would be just ignored unless --tls is not specified,
which is correct, but let's provide a bit of a guidance is a user
forgets to add --tls.

This is just a virsh-only check targeted to end users as we don't
currently have such checks at the API level for migration parameters
that depend on flags.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: avoid probing host CPU from bhyve test
Daniel P. Berrangé [Wed, 8 Jan 2020 18:17:58 +0000 (18:17 +0000)]
tests: avoid probing host CPU from bhyve test

bhyveargv2xmlmock calls virBhyveCapsBuild which in turn
calls virCPUProbeHost, probing the real host CPU. This
causes a test failure if the host CPU happens to contain
the 'arch-capabilities' feature as it triggers a call
to virHostCPUGetMSR() which fails on FreeBSD.

Fortunately we already have convenient code for mocking
the host CPU probing.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoschema: Allow iSCSI source to have interleaved children
Michal Privoznik [Wed, 8 Jan 2020 16:03:42 +0000 (17:03 +0100)]
schema: Allow iSCSI source to have interleaved children

There is no need to require users to produce iSCSI disk source
following our ordering of children elements. In fact, we don't
even accept our own order in the schema :(.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agobhyve_parse_command: Undefine CONSUME_ARG macro when no longer needed
Michal Privoznik [Wed, 8 Jan 2020 10:17:23 +0000 (11:17 +0100)]
bhyve_parse_command: Undefine CONSUME_ARG macro when no longer needed

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobhyve_parse_command.c: Don't jump onto non-existent label in CONSUME_ARG()
Michal Privoznik [Wed, 8 Jan 2020 10:13:55 +0000 (11:13 +0100)]
bhyve_parse_command.c: Don't jump onto non-existent label in CONSUME_ARG()

In v5.10.0-508-gfbf3f3d86a, the 'error' label was removed from
bhyveParseBhyveCommandLine(), however the CONSUME_ARG() macro
still uses it. Fix the macro to return an error instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fix implicit fallthrough warning
Ján Tomko [Wed, 8 Jan 2020 09:20:39 +0000 (10:20 +0100)]
qemu: fix implicit fallthrough warning

src/qemu/qemu_domain_address.c:680:13: error: this statement may fall through [-Werror=implicit-fallthrough=]
             switch ((virDomainFSModel) dev->data.fs->model) {

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: f363af7e351c6cac0ff442390d0dab283cbd9fae
5 years agovz: Don't try to jump on a non-existent label in prlsdkRemoveBootDevices()
Michal Privoznik [Wed, 8 Jan 2020 08:46:27 +0000 (09:46 +0100)]
vz: Don't try to jump on a non-existent label in prlsdkRemoveBootDevices()

Commit v5.10.0-522-g9000b2f298 was too aggressive and removed the
'error' label from prlsdkRemoveBootDevices() even though it's
used. Luckily, it's used only from one place and we have an
alternative for it that doesn't require the label.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu_firmware: Accept int in qemuFirmwareOSInterfaceTypeFromOsDefFirmware()
Michal Privoznik [Wed, 8 Jan 2020 08:42:47 +0000 (09:42 +0100)]
qemu_firmware: Accept int in qemuFirmwareOSInterfaceTypeFromOsDefFirmware()

The point of this function is to translate virDomainOsDefFirmware
enum to qemuFirmwareOSInterface enum. However, with my commit
v5.10.0-507-g8e1804f9f6 we are passing a variable type of
virDomainLoader enum. Make the function accept both enums and
make the enum members correspond to each other.

This fixes clang build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: formatdomain: use 'element' instead of 'block'
Ján Tomko [Wed, 18 Dec 2019 14:09:20 +0000 (15:09 +0100)]
docs: formatdomain: use 'element' instead of 'block'

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: command: take fsdriver type into account
Ján Tomko [Tue, 6 Aug 2019 15:57:44 +0000 (17:57 +0200)]
qemu: command: take fsdriver type into account

Split the formatting by fsdriver type to allow adding a new type.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: address: take fsdriver type into account
Ján Tomko [Tue, 16 Jul 2019 06:27:28 +0000 (08:27 +0200)]
qemu: address: take fsdriver type into account

Split the switch by fsdriver type to allow adding a new one.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: pass private data to qemuBuildFilesystemCommandLine
Ján Tomko [Tue, 6 Aug 2019 16:22:24 +0000 (18:22 +0200)]
qemu: pass private data to qemuBuildFilesystemCommandLine

This will be used by a future patch.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: add private data to virDomainFSDef
Ján Tomko [Tue, 10 Dec 2019 12:53:10 +0000 (13:53 +0100)]
qemu: add private data to virDomainFSDef

Wire up the allocation and disposal of private data.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: add private data to virDomainFSDef
Ján Tomko [Tue, 10 Dec 2019 12:52:52 +0000 (13:52 +0100)]
conf: add private data to virDomainFSDef

Add an object to hold the private data and call the
allocation function if it's present in xmlopt.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: add xmlopt to virDomainFSDefNew
Ján Tomko [Tue, 10 Dec 2019 12:51:54 +0000 (13:51 +0100)]
conf: add xmlopt to virDomainFSDefNew

This will be needed in the future for allocating private data.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: rename gluster_debug_entry
Ján Tomko [Wed, 11 Dec 2019 21:22:31 +0000 (22:22 +0100)]
qemu: rename gluster_debug_entry

Remove the 'gluster' part and decouple the return from
the gluster_debug_level parsing to allow adding more options
to this section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: error out when check-augeas fails
Ján Tomko [Wed, 18 Dec 2019 13:42:46 +0000 (14:42 +0100)]
build: error out when check-augeas fails

Fixes: 2ffbdabb859594256d45c1b48521dd6501629852
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: backup: Move capability check after inactive check
Peter Krempa [Mon, 6 Jan 2020 11:27:40 +0000 (12:27 +0100)]
qemu: backup: Move capability check after inactive check

Inactive VM doesn't have qemuCaps set thus we'd never properly report
that VM backups are supported only for running VMs.

Move the capability check after the active check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agopo: Fix indentation of SED_PO_FIXUP_ARGS variable
Michal Privoznik [Tue, 7 Jan 2020 16:36:59 +0000 (17:36 +0100)]
po: Fix indentation of SED_PO_FIXUP_ARGS variable

The variable value is split on multiple lines, which have too
long indentation prefix leading to needless long lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoremote_daemon: Initialize host boot time global variable
Michal Privoznik [Tue, 17 Dec 2019 13:08:42 +0000 (14:08 +0100)]
remote_daemon: Initialize host boot time global variable

This is not strictly needed, but it makes sure we initialize the
@bootTime global variable. Thing is, in order to validate XATTRs
and prune those set in some previous runs of the host, a
timestamp is recorded in XATTRs. The host boot time was unique
enough so it was chosen as the timestamp value. And to avoid
querying and parsing /proc/uptime every time, the query function
does that only once and stores the boot time in a global
variable. However, the only time the query function is called is
in a child process that does lock files and changes seclabels. So
effectively, we are doing exactly what we wanted to prevent from
happening.

The fix is simple, call the virHostBootTimeInit() function which
sets the global variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agovirhostuptime: Introduce virHostBootTimeInit()
Michal Privoznik [Thu, 19 Dec 2019 09:11:04 +0000 (10:11 +0100)]
virhostuptime: Introduce virHostBootTimeInit()

The idea is to offer callers an init function that they can call
independently to ensure that the global variables get
initialized.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agovirt-aa-helper: Drop unused variable in verify_xpath_context()
Michal Privoznik [Tue, 7 Jan 2020 15:55:50 +0000 (16:55 +0100)]
virt-aa-helper: Drop unused variable in verify_xpath_context()

After one of previous commits (v5.10.0-524-gce56408e5f) there is
a variable left unused in verify_xpath_context() which breaks the
build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoexamples: remove unneeded labels
Daniel Henrique Barboza [Mon, 6 Jan 2020 21:57:50 +0000 (18:57 -0300)]
examples: remove unneeded labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotests: remove unneeded labels
Daniel Henrique Barboza [Mon, 6 Jan 2020 21:57:49 +0000 (18:57 -0300)]
tests: remove unneeded labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agologging: remove unneeded labels
Daniel Henrique Barboza [Mon, 6 Jan 2020 21:57:48 +0000 (18:57 -0300)]
logging: remove unneeded labels

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>