]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agoqemuOpenFile: Move to qemu_domain.c
Peter Krempa [Thu, 16 Jul 2020 09:17:47 +0000 (11:17 +0200)] 
qemuOpenFile: Move to qemu_domain.c

Move the code to qemu_domain.c so that it can be reused in other parts
of the qemu driver. 'qemu_domain' was chosen as the permissions are
based on the domain configuration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuOpenFileAs: Move into util/virqemu.c
Peter Krempa [Thu, 16 Jul 2020 08:51:21 +0000 (10:51 +0200)] 
qemuOpenFileAs: Move into util/virqemu.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationCapsCheck: Refactor variable cleanup
Peter Krempa [Wed, 19 Aug 2020 11:20:13 +0000 (13:20 +0200)] 
qemuMigrationCapsCheck: Refactor variable cleanup

Use automatic memory allocation to simplify the code and remove the need
for a 'cleanup:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMigrationParamsParse: Refactor variable cleanup
Peter Krempa [Wed, 19 Aug 2020 11:20:13 +0000 (13:20 +0200)] 
qemuMigrationParamsParse: Refactor variable cleanup

Use automatic memory allocation and move variables into correct scope to
simplify the code and remove the need for a 'cleanup:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMigrationCapsToJSON: Refactor variable cleanup
Peter Krempa [Wed, 19 Aug 2020 11:20:13 +0000 (13:20 +0200)] 
qemuMigrationCapsToJSON: Refactor variable cleanup

Use automatic memory allocation and move variables into correct scope to
simplify the code and remove the need for a 'error:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMigrationParamsToJSON: Refactor variable cleanup
Peter Krempa [Wed, 19 Aug 2020 11:18:31 +0000 (13:18 +0200)] 
qemuMigrationParamsToJSON: Refactor variable cleanup

Use automatic memory allocation and move variables into correct scope to
simplify the code and remove the need for a 'error:' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMigrationParamsFromJSON: Unify return value handling with other functions
Peter Krempa [Wed, 19 Aug 2020 11:17:06 +0000 (13:17 +0200)] 
qemuMigrationParamsFromJSON: Unify return value handling with other functions

This function doesn't have an overly verbose cleanup section as there
isn't any error code path. Unify it with the rest of the functions which
will simplify adding a possible error path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMigrationParamsFromFlags: Use 'g_autoptr' to remove 'error:' label
Peter Krempa [Wed, 19 Aug 2020 11:15:35 +0000 (13:15 +0200)] 
qemuMigrationParamsFromFlags: Use 'g_autoptr' to remove 'error:' label

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMigrationParamsNew: Use new memory allocation to simplify code
Peter Krempa [Wed, 19 Aug 2020 11:13:29 +0000 (13:13 +0200)] 
qemuMigrationParamsNew: Use new memory allocation to simplify code

Use automatic memory cleaning and allocate via g_new0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agonews: Document sparse streams for block devices
Michal Privoznik [Fri, 3 Jul 2020 15:16:31 +0000 (17:16 +0200)] 
news: Document sparse streams for block devices

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfdstream: Emulate skip for block devices
Michal Privoznik [Wed, 1 Jul 2020 19:39:40 +0000 (21:39 +0200)] 
virfdstream: Emulate skip for block devices

This is similar to one of previous patches.

When receiving stream (on virStorageVolUpload() and subsequent
virStreamSparseSendAll()) we may receive a hole. If the volume we
are saving the incoming data into is a regular file we just
lseek() and ftruncate() to create the hole. But this won't work
if the file is a block device. If that is the case we must write
zeroes so that any subsequent reader reads nothing just zeroes
(just like they would from a hole in a regular file).

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirshStreamInData: Handle block devices
Michal Privoznik [Thu, 2 Jul 2020 13:51:20 +0000 (15:51 +0200)] 
virshStreamInData: Handle block devices

This is very similar to previous commit.

The virshStreamInData() callback is used by virStreamSparseSendAll()
to detect whether the file the data is read from is in data or hole
section. The SendAll() will then send corresponding type of virStream
message to make server create a hole or write actual data. But the
callback uses virFileInData() even for block devices, which results in
an error. Just like in previous commit, emulate a DATA section
for block devices.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1852528

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfdstream: Allow sparse stream vol-download
Michal Privoznik [Thu, 2 Jul 2020 13:43:00 +0000 (15:43 +0200)] 
virfdstream: Allow sparse stream vol-download

When handling sparse stream, a thread is executed. This thread
runs a read() or write() loop (depending what API is called; in
this case it's virStorageVolDownload() and  this the thread run
read() loop). The read() is handled in virFDStreamThreadDoRead()
which is then data/hole section aware, meaning it uses
virFileInData() to detect data and hole sections and sends
TYPE_DATA or TYPE_HOLE virStream messages accordingly.

However, virFileInData() does not work with block devices. Simply
because block devices don't have data and hole sections. What we
can do though, is to mimic being always in a DATA section.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1852528

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirshStreamSkip: Emulate skip for block devices
Michal Privoznik [Thu, 2 Jul 2020 13:49:33 +0000 (15:49 +0200)] 
virshStreamSkip: Emulate skip for block devices

This callback is called when the server sends us STREAM_HOLE
meaning there is no real data, only zeroes. For regular files
we would just seek() beyond EOF and ftruncate() to create the
hole. But for block devices this won't work. Not only we can't
seek() beyond EOF, and ftruncate() will fail, this approach won't
fill the device with zeroes. We have to do it manually.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1852528

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsh: Track if vol-upload or vol-download work over a block device
Michal Privoznik [Thu, 2 Jul 2020 06:51:20 +0000 (08:51 +0200)] 
virsh: Track if vol-upload or vol-download work over a block device

We can't use virFileInData() with block devices, but we can
emulate being in data section all the time (vol-upload case).
Alternatively, we can't just lseek() beyond EOF with block
devices to create a hole, we will have to write zeroes
(vol-download case).  But to decide we need to know if the FD we
are reading data from / writing data to is a block device. Store
this information in _virshStreamCallbackData.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsh: Pass virshStreamCallbackDataPtr to virshStreamSink() and virshStreamSkip()
Michal Privoznik [Thu, 2 Jul 2020 06:42:44 +0000 (08:42 +0200)] 
virsh: Pass virshStreamCallbackDataPtr to virshStreamSink() and virshStreamSkip()

These callback will need to know more that the FD they are
working on. Pass the structure that is passed to other stream
callbacks (e.g. virshStreamSource() or virshStreamSourceSkip())
instead of inventing a new one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agolibvirt-storage: Document volume upload/download stream format
Michal Privoznik [Wed, 1 Jul 2020 11:47:04 +0000 (13:47 +0200)] 
libvirt-storage: Document volume upload/download stream format

For libvirt, the volume is just a binary blob and it doesn't
interpret data on volume upload/download. But as it turns out,
this unspoken assumption is not clear to our users. Document it
explicitly.

Suggested in: https://bugzilla.redhat.com/show_bug.cgi?id=1851023#c17

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemumonitorjsontest: Add a last-resort warning if object-add/device_add are QAPIfied
Peter Krempa [Thu, 6 Aug 2020 17:45:24 +0000 (19:45 +0200)] 
qemumonitorjsontest: Add a last-resort warning if object-add/device_add are QAPIfied

When netdev-add was qapified it took us by surprise and we had to
scramble to fix the internals to format conformant monitor arguments.

Add a last-resort early warning system if this happens to object-add or
device_add. Hopefully qemu developers notify us sooner than this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotestutilsqemuschema: Add template checker for schema entries
Peter Krempa [Thu, 6 Aug 2020 17:43:51 +0000 (19:43 +0200)] 
testutilsqemuschema: Add template checker for schema entries

We'll need to match that a certain part of the qemu schema hasn't grown
new properties unexpectedly. Add a helper which matches an 'object' QMP
schema entry against a template and reports errors if expected types
don't match or new entries are added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agomeson: Improve RPATH handling
Andrea Bolognani [Wed, 19 Aug 2020 09:15:35 +0000 (11:15 +0200)] 
meson: Improve RPATH handling

Right now we're unconditionally adding RPATH information to the
installed binaries and libraries, but that's not always desired.

autotools seem to be smart enough to only include that information
when targeting a non-standard prefix, so most distro packages
don't actually contain it; moreover, both Debian and Fedora have
wiki pages encouraging packagers to avoid setting RPATH:

  https://wiki.debian.org/RpathIssue
  https://fedoraproject.org/wiki/RPath_Packaging_Draft

Implement RPATH logic that Does The Right Thing™ in the most
common cases, while still offering users the ability to override
the default behavior if they have specific needs.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoABOUT-NLS: Drop symlink
Andrea Bolognani [Mon, 24 Aug 2020 07:52:43 +0000 (09:52 +0200)] 
ABOUT-NLS: Drop symlink

The ABOUT-NLS symlink pointing to po/README.rst is a leftover
from when we were using autotools as the build system, and now
that we're using Meson we can drop it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirsh: guest-agent-timeout: set default value for optional argument
Tomáš Golembiovský [Fri, 21 Aug 2020 12:34:51 +0000 (14:34 +0200)] 
virsh: guest-agent-timeout: set default value for optional argument

The timeout argument for guest-agent-timeout is optional but it did not
have proper default value specified. Also update the virsh man page
accordingly.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoREADME: Drop symlink
Andrea Bolognani [Sun, 23 Aug 2020 22:07:14 +0000 (00:07 +0200)] 
README: Drop symlink

Having a README file called "README" is necessary when using
autotools, and for quite some time now we've been complying with
that requirement by having a symlink with that name pointing to
README.rst, where the actual contents live. Now that we've moved
to Meson, we can drop the symlink.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoChangeLog: Drop for good
Andrea Bolognani [Sun, 23 Aug 2020 21:51:29 +0000 (23:51 +0200)] 
ChangeLog: Drop for good

Having a ChangeLog file is necessary when using autotools, but
now that we've moved to Meson we are no longer required to keep
it around.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: virsh: Fix names of some commands
Tomáš Golembiovský [Fri, 21 Aug 2020 12:35:32 +0000 (14:35 +0200)] 
docs: virsh: Fix names of some commands

Some commands were improperly converted from original POD file. Their
names were stripped after the first dash.

Fixes: ab06dd9db37f12063c8206c110dcaf9fa626d1bc
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agomeson: Don't hardcode /etc in APPARMOR_DIR
Andrea Bolognani [Tue, 18 Aug 2020 23:39:19 +0000 (01:39 +0200)] 
meson: Don't hardcode /etc in APPARMOR_DIR

src/security/apparmor/meson.build builds this path dynamically
based on the value of sysconfdir, so we should do the same here
or the code and the filesystem might end up disagreeing.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agomeson: Set WITH_APPARMOR_PROFILES
Andrea Bolognani [Tue, 18 Aug 2020 23:39:18 +0000 (01:39 +0200)] 
meson: Set WITH_APPARMOR_PROFILES

This variable is used in src/security/meson.build to decide
whether to install the AppArmor profiles, and at the moment
even when the user specifies -Dapparmor_profiles=true they
don't get installed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agotests: schema: test bhyvexml2xmloutdata schemas
Roman Bogorodskiy [Sat, 18 Jul 2020 11:30:14 +0000 (15:30 +0400)] 
tests: schema: test bhyvexml2xmloutdata schemas

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirnuma: Don't work around numa_node_to_cpus() for non-existent nodes
Michal Privoznik [Fri, 21 Aug 2020 12:43:21 +0000 (14:43 +0200)] 
virnuma: Don't work around numa_node_to_cpus() for non-existent nodes

In a very distant past, we came around machines that has not
continuous node IDs. This made us error out when constructing
capabilities XML. We resolved it by utilizing strange behaviour
of numa_node_to_cpus() in which it returned a mask with all bits
set for a non-existent node. However, this is not the only case
when it returns all ones mask - if the node exists and has enough
CPUs to fill the mask up (e.g. 128 CPUs).

The fix consists of using nodemask_isset(&numa_all_nodes, ..)
prior to calling numa_node_to_cpus() to determine if the node
exists.

Fixes: 628c93574758abb59e71160042524d321a33543f
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1860231
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoXen: Improve parsing of PCI addresses in config converter
Jim Fehlig [Mon, 10 Aug 2020 22:58:59 +0000 (16:58 -0600)] 
Xen: Improve parsing of PCI addresses in config converter

There was a report on libvirt-users [1] about the domxml to/from
native converter in the Xen driver not handling PCI addresses
without a domain specification. This patch improves parsing of PCI
addresses in the converter and allows PCI addresses with only
bb:ss.f. xl.cfg(5) also allows either the dddd:bb:ss.f or bb:ss.f
format. A test has been added to check the conversion from xl.cfg
to domXML.

[1] https://www.redhat.com/archives/libvirt-users/2020-August/msg00040.html

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoexamples: Use GLib event loop impl in events.stp
Han Han [Sun, 26 Jul 2020 11:33:12 +0000 (19:33 +0800)] 
examples: Use GLib event loop impl in events.stp

Update the events stap example because the event loop impl is replaced by
GLib based event loop impl after commit 55fe8110.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>
4 years agokbase: Add knowledge base for libvirt systemtap
Han Han [Thu, 6 Aug 2020 06:34:02 +0000 (14:34 +0800)] 
kbase: Add knowledge base for libvirt systemtap

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>
4 years agolocking: Replace virMutex with GMutex
Han Han [Wed, 5 Aug 2020 07:56:18 +0000 (15:56 +0800)] 
locking: Replace virMutex with GMutex

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>
4 years agologging: Replace virMutex with GMutex
Han Han [Wed, 5 Aug 2020 07:56:17 +0000 (15:56 +0800)] 
logging: Replace virMutex with GMutex

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>
4 years agotools: fix libvirt-guests.sh text assignments
Christian Ehrhardt [Wed, 19 Aug 2020 10:04:58 +0000 (12:04 +0200)] 
tools: fix libvirt-guests.sh text assignments

In libvirt 6.6 stopping guests with libvirt-guests.sh is broken.
As soon as there is more than one guest one can see
`systemctl stop libvirt-guests` failing and in the log we see:
  libvirt-guests.sh[2455]: Running guests on default URI:
  libvirt-guests.sh[2457]: /usr/lib/libvirt/libvirt-guests.sh: 120:
      local: 2a49cb0f-1ff8-44b5-a61d-806b9e52dae2: bad variable name
  libvirt-guests.sh[2462]: no running guests.

That is due do mutliple guests becoming a list of UUIDs. Without
recognizing this as one single string the assignment breaks when using 'local'
(which was recently added in 6.3.0). This is because local is defined as
  local [option] [name[=value] ... | - ]
which makes the shell trying handle the further part of the string as
variable names. In the error above that string isn't a valid variable
name triggering the issue that is seen.

This depends on the shell being used. POSIX shells don't have 'local'
specified yet and for the common shells it depends. It worked in bash and
bash-in-POSIX-mode, but for example dash in POSIX mode triggers the issue.

To resolve that 'textify' all assignments that are strings or potentially
can become such lists (even if they are not using the local qualifier).

Fixes: 08071ec0 "tools: variables clean-up in libvirt-guests script"
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agovirfdstream: Drop some needless labels
Michal Privoznik [Tue, 7 Jul 2020 11:38:26 +0000 (13:38 +0200)] 
virfdstream: Drop some needless labels

After previous cleanups, some labels in some functions have
nothing but 'return' statement in them. Drop the labels and
replace 'goto'-s with respective return statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfdstream: Use VIR_AUTOCLOSE()
Michal Privoznik [Tue, 7 Jul 2020 12:39:22 +0000 (14:39 +0200)] 
virfdstream: Use VIR_AUTOCLOSE()

Again, instead of closing FDs explicitly, we can automatically
close them when they go out of their respective scopes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfdstream: Use g_new0() instead of VIR_ALLOC()
Michal Privoznik [Tue, 7 Jul 2020 12:37:34 +0000 (14:37 +0200)] 
virfdstream: Use g_new0() instead of VIR_ALLOC()

This switch allow us to save a few lines of code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfdstream: Use autoptr for virFDStreamMsg
Michal Privoznik [Tue, 7 Jul 2020 11:32:50 +0000 (13:32 +0200)] 
virfdstream: Use autoptr for virFDStreamMsg

A cleanup function can be declared for virFDStreamMsg type so
that the structure doesn't have to be freed explicitly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirFDStreamMsgQueuePush: Clear pointer to passed message
Michal Privoznik [Tue, 7 Jul 2020 11:08:46 +0000 (13:08 +0200)] 
virFDStreamMsgQueuePush: Clear pointer to passed message

All callers of virFDStreamMsgQueuePush() have the same pattern:
they explicitly set @msg passed to NULL to avoid freeing it later
on. Well, the function can take address of the pointer and clear
it for them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfdstream: Use g_autofree in virFDStreamThreadDoRead()
Michal Privoznik [Tue, 7 Jul 2020 11:04:48 +0000 (13:04 +0200)] 
virfdstream: Use g_autofree in virFDStreamThreadDoRead()

The buffer that allocated in the virFDStreamThreadDoRead() can be
automatically freed, or if saved into the message structure it
can be stolen.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirdevmapper: Ignore all errors when opening /dev/mapper/control
Michal Privoznik [Wed, 19 Aug 2020 11:35:55 +0000 (13:35 +0200)] 
virdevmapper: Ignore all errors when opening /dev/mapper/control

So far, only ENOENT is ignored (to deal with kernels without
devmapper). However, as reported on the list, under certain
scenarios a different error can occur. For instance, when libvirt
is running inside a container which doesn't have permissions to
talk to the devmapper. If this is the case, then open() returns
-1 and sets errno=EPERM.

Assuming that multipath devices are fairly narrow use case and
using them in a restricted container is even more narrow the best
fix seems to be to ignore all open errors BUT produce a warning
on failure. To avoid flooding logs with warnings on kernels
without devmapper the level is reduced to a plain debug message.

Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonuma_conf: Properly check for caches in virDomainNumaDefValidate()
Michal Privoznik [Tue, 18 Aug 2020 10:46:38 +0000 (12:46 +0200)] 
numa_conf: Properly check for caches in virDomainNumaDefValidate()

When adding support for HMAT, in f0611fe8830 I've introduced a
check which aims to validate /domain/cpu/numa/interconnects. As a
part of that, there is a loop which checks whether all <latency/>
with @cache attribute refer to an existing cache level. For
instance:

  <cpu mode='host-model' check='partial'>
    <numa>
      <cell id='0' cpus='0-5' memory='512000' unit='KiB' discard='yes'>
        <cache level='1' associativity='direct' policy='writeback'>
          <size value='8' unit='KiB'/>
          <line value='5' unit='B'/>
        </cache>
      </cell>
      <interconnects>
        <latency initiator='0' target='0' cache='1' type='access' value='5'/>
        <bandwidth initiator='0' target='0' type='access' value='204800' unit='KiB'/>
      </interconnects>
    </numa>
  </cpu>

This XML defines that accessing L1 cache of node #0 from node #0
has latency of 5ns.

However, the loop was not written properly. Well, the check in
it, as it was always checking for the first cache in the target
node and not the rest. Therefore, the following example errors
out:

  <cpu mode='host-model' check='partial'>
    <numa>
      <cell id='0' cpus='0-5' memory='512000' unit='KiB' discard='yes'>
        <cache level='3' associativity='direct' policy='writeback'>
          <size value='10' unit='KiB'/>
          <line value='8' unit='B'/>
        </cache>
        <cache level='1' associativity='direct' policy='writeback'>
          <size value='8' unit='KiB'/>
          <line value='5' unit='B'/>
        </cache>
      </cell>
      <interconnects>
        <latency initiator='0' target='0' cache='1' type='access' value='5'/>
        <bandwidth initiator='0' target='0' type='access' value='204800' unit='KiB'/>
      </interconnects>
    </numa>
  </cpu>

This errors out even though it is a valid configuration. The L1
cache under node #0 is still present.

Fixes: f0611fe8830
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoqemu_domainjob: remove dependency on `qemuDomainDiskPrivatePtr`
Prathamesh Chavan [Mon, 17 Aug 2020 05:07:21 +0000 (10:37 +0530)] 
qemu_domainjob: remove dependency on `qemuDomainDiskPrivatePtr`

Both parsing and formatting of NBD migration jobs is QEMU specific and
since we're trying to create a hypervisor-agnostic module out of
qemu_domainjob.c, move the NBD XML handling bits to the qemu_domain
module instead. Additionally, move the respective NBD XML calls to
the 'parseJob'/'formatJob' callbacks of the
qemuDomainObjPrivateJobCallbacks structure.

Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu_domain: Move a couple of function declarations to the correct file
Prathamesh Chavan [Mon, 17 Aug 2020 05:07:19 +0000 (10:37 +0530)] 
qemu_domain: Move a couple of function declarations to the correct file

Functions `qemuDomainRemoveInactiveJob` and
`qemuDomainRemoveInactiveJobLocked` had their declaration misplaced in
`qemu_domainjob` and were moved to `qemu_domain` where their definitions
reside.

Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agomeson: Don't use spaces after parentheses
Andrea Bolognani [Tue, 18 Aug 2020 21:56:51 +0000 (23:56 +0200)] 
meson: Don't use spaces after parentheses

We don't do that anywhere else.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agomeson: Fix indentation
Andrea Bolognani [Tue, 18 Aug 2020 21:57:39 +0000 (23:57 +0200)] 
meson: Fix indentation

We use two spaces everywhere else.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agomeson: Fix typo supprt -> support
Andrea Bolognani [Tue, 18 Aug 2020 21:20:19 +0000 (23:20 +0200)] 
meson: Fix typo supprt -> support

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agomeson: Fix typo backand -> backend
Andrea Bolognani [Tue, 18 Aug 2020 19:01:15 +0000 (21:01 +0200)] 
meson: Fix typo backand -> backend

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agosrc/meson: add missing augeas tests
Pavel Hrdina [Tue, 18 Aug 2020 13:38:34 +0000 (15:38 +0200)] 
src/meson: add missing augeas tests

Most of our augeas files are generated during meson setup into build
directory and we were running augeas tests only for these files.

However, we have some other augeas and config files that are not
modified during meson setup and they are only in source directories.
In order to run tests for these files we need to provide different path
to both source and build directories.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc/meson: introduce srcdir and builddir into augeas_test_data dictionary
Pavel Hrdina [Tue, 18 Aug 2020 13:36:55 +0000 (15:36 +0200)] 
src/meson: introduce srcdir and builddir into augeas_test_data dictionary

This will be used later to specify different include directories for
augparse binary to run augeas tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: build: Fix links to 'edit this page' for kbase/manpages/internals
Peter Krempa [Mon, 17 Aug 2020 10:06:13 +0000 (12:06 +0200)] 
docs: build: Fix links to 'edit this page' for kbase/manpages/internals

Commit 862cf2ace4f04dadc175caacc74448e96c625ccb modified the generator
to base edit links in the root of the repository but forgot to add the
'docs/' prefix to the code generating kbase articles, manpages and the
internals documentation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: doCoreDump: Fix return value not expect as result
Hao Wang [Sat, 8 Aug 2020 08:19:58 +0000 (16:19 +0800)] 
qemu: doCoreDump: Fix return value not expect as result

In case qemuDumpToFd() returns zero followed by a VIR_CLOSE(fd) fail,
we'd jump to the "cleanup" label with "ret=0", potentially resulting in
an unexpected success return value.

Signed-off-by: Hao Wang <wanghao232@huawei.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoNEWS: Document recent virdevmapper fix
Michal Privoznik [Tue, 18 Aug 2020 11:14:16 +0000 (13:14 +0200)] 
NEWS: Document recent virdevmapper fix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovirdevmapper: Handle kernel without device-mapper support
Michal Privoznik [Tue, 18 Aug 2020 09:04:24 +0000 (11:04 +0200)] 
virdevmapper: Handle kernel without device-mapper support

In one of my latest patch (v6.6.0~30) I was trying to remove
libdevmapper use in favor of our own implementation. However, the
code did not take into account that device mapper can be not
compiled into the kernel (e.g. be a separate module that's not
loaded) in which case /proc/devices won't have the device-mapper
major number and thus virDevMapperGetTargets() and/or
virIsDevMapperDevice() fails.

However, such failure is safe to ignore, because if device mapper
is missing then there can't be any multipath devices and thus we
don't need to allow the deps in CGroups, nor create them in the
domain private namespace, etc.

Fixes: 22494556542c676d1b9e7f1c1f2ea13ac17e1e3e
Reported-by: Andrea Bolognani <abologna@redhat.com>
Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agovirdevmapper: Don't cache device-mapper major
Michal Privoznik [Tue, 18 Aug 2020 09:08:15 +0000 (11:08 +0200)] 
virdevmapper: Don't cache device-mapper major

The device mapper major is needed in virIsDevMapperDevice() which
determines whether given device is managed by device-mapper. This
number is obtained by parsing /proc/devices and then stored in a
global variable so that the file doesn't have to be parsed again.
However, as it turns out this logic is flawed - the major number
is not static and can change as it can be specified as a
parameter when loading the dm-mod module.

Unfortunately, I was not able to come up with a good solution and
thus the /proc/devices file is being parsed every time we need
the device mapper major.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agodocs: improve auth service listing
Pino Toscano [Mon, 17 Aug 2020 07:55:26 +0000 (09:55 +0200)] 
docs: improve auth service listing

Slightly improve the list of known authentication service types:
- reword 'ssh' to mention it is used for the ssh driver (for remote
  QEMU), and stop mentioning the removed Phyp driver
- add 'hyperv', used by the HyperV driver
- alphabetically sort the list
- use a bulletted list instead of a numbered one

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agobuild-aux: Get rid of 'make syntax-check' reference
Erik Skultety [Mon, 17 Aug 2020 06:47:42 +0000 (08:47 +0200)] 
build-aux: Get rid of 'make syntax-check' reference

Change the 'make syntax-check' reference after the switch to
meson/ninja.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agovbox_XPCOMCGlue.c: get rid of 'make check' reference
Daniel Henrique Barboza [Thu, 6 Aug 2020 13:34:54 +0000 (10:34 -0300)] 
vbox_XPCOMCGlue.c: get rid of 'make check' reference

Change the 'make check' reference after the switch to meson/ninja.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: get rid of 'make check' references
Daniel Henrique Barboza [Thu, 6 Aug 2020 13:34:53 +0000 (10:34 -0300)] 
tests: get rid of 'make check' references

Update the remaining 'make check' references after the
switch to meson/ninja.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoci/Makefile: get rid of 'make check' references
Daniel Henrique Barboza [Thu, 6 Aug 2020 13:34:52 +0000 (10:34 -0300)] 
ci/Makefile: get rid of 'make check' references

Update the remaining 'make check' references after the
switch to meson/ninja.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: get rid of 'make check' references
Daniel Henrique Barboza [Thu, 6 Aug 2020 13:34:51 +0000 (10:34 -0300)] 
docs: get rid of 'make check' references

Update the remaining 'make check' references after the
switch to meson/ninja.

The reference in testsuites.html.in was kept with a note that it is
the process for Libvirt 6.6.0 and older.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agostorage: avoid maybe-uninitialized warning by GCC 10
Boris Fiuczynski [Thu, 13 Aug 2020 14:03:46 +0000 (16:03 +0200)] 
storage: avoid maybe-uninitialized warning by GCC 10

GCC 10 complains about variables may be used uninitialized.
Even though it might be false positives, we can easily avoid them.

Avoiding
 ../src/storage/storage_backend_iscsi_direct.c:634:11: error: ‘nb_block’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   634 |     while (lba < nb_block) {
       |           ^
 ../src/storage/storage_backend_iscsi_direct.c:619:14: note: ‘nb_block’ was declared here
   619 |     uint64_t nb_block;
       |              ^~~~~~~~
 ../src/storage/storage_backend_iscsi_direct.c:637:16: error: ‘block_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   637 |         task = iscsi_write16_sync(iscsi, lun, lba, data,
       |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   638 |                                   block_size * to_write,
       |                                   ~~~~~~~~~~~~~~~~~~~~~~
   639 |                                   block_size, 0, 0, 0, 0, 0);
       |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~
 ../src/storage/storage_backend_iscsi_direct.c:618:14: note: ‘block_size’ was declared here
   618 |     uint32_t block_size;
       |              ^~~~~~~~~~
 ../src/storage/storage_backend_iscsi_direct.c: In function ‘virStorageBackendISCSIDirectRefreshPool’:
 ../src/storage/storage_backend_iscsi_direct.c:320:39: error: ‘nb_block’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   320 |     vol->target.capacity = block_size * nb_block;
       |                            ~~~~~~~~~~~^~~~~~~~~~
 ../src/storage/storage_backend_iscsi_direct.c:306:14: note: ‘nb_block’ was declared here
   306 |     uint64_t nb_block;
       |              ^~~~~~~~
 ../src/storage/storage_backend_iscsi_direct.c:320:39: error: ‘block_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   320 |     vol->target.capacity = block_size * nb_block;
       |                            ~~~~~~~~~~~^~~~~~~~~~
 ../src/storage/storage_backend_iscsi_direct.c:305:14: note: ‘block_size’ was declared here
   305 |     uint32_t block_size;
       |              ^~~~~~~~~~

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotools: avoid potential null pointer dereference by GCC 10
Boris Fiuczynski [Thu, 13 Aug 2020 14:03:45 +0000 (16:03 +0200)] 
tools: avoid potential null pointer dereference by GCC 10

GCC 10 complains about "arg" possibly being a NULL dereference.
Even though it might be a false positive, we can easily avoid it.

Avoiding
 ../tools/vsh.c: In function ‘vshCommandOptStringReq’:
 ../tools/vsh.c:1034:19: error: potential null pointer dereference [-Werror=null-dereference]
  1034 |     else if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
       |                ~~~^~~~~~

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: avoid maybe-uninitialized warning by GCC 10
Boris Fiuczynski [Thu, 13 Aug 2020 14:03:44 +0000 (16:03 +0200)] 
qemu: avoid maybe-uninitialized warning by GCC 10

GCC 10 complains about "well_formed_uri" may be used uninitialzed.
Even though it is a false positive, we can easily avoid it.

Avoiding
  ../src/qemu/qemu_migration.c: In function ‘qemuMigrationDstPrepareDirect’:
  ../src/qemu/qemu_migration.c:2920:16: error: ‘well_formed_uri’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    2920 |             if (well_formed_uri) {
         |                ^

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoapparmor: fix code style error in reduced if statement
Christian Ehrhardt [Thu, 13 Aug 2020 13:39:26 +0000 (15:39 +0200)] 
apparmor: fix code style error in reduced if statement

sc_spacing-check  FAIL reporting a case of "Curly brackets around
single-line body:" in a recent commit.

Fixes: d9c21f4b "apparmor: allow adding permanent per guest rules"
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agoapparmor: allow unmounting .dev entries
Christian Ehrhardt [Fri, 7 Aug 2020 07:05:04 +0000 (09:05 +0200)] 
apparmor: allow unmounting .dev entries

With qemu 5.0 and libvirt 6.6 there are new apparmor denials:
  apparmor="DENIED" operation="umount" profile="libvirtd"
  name="/run/libvirt/qemu/1-kvmguest-groovy-norm.dev/" comm="rpc-worker"

These are related to new issues around devmapper handling [1] and the
error path triggered by these issues now causes this new denial.

There are already related rules for mounting and it seems right to
allow also the related umount.

[1]: https://www.redhat.com/archives/libvir-list/2020-August/msg00236.html

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoapparmor: allow adding permanent per guest rules
Christian Ehrhardt [Thu, 6 Aug 2020 14:54:34 +0000 (16:54 +0200)] 
apparmor: allow adding permanent per guest rules

The design of apparmor in libvirt always had a way to define custom
per-guest rules as described in docs/drvqemu.html and [1].

A fix meant to clean the profiles after guest shutdown was a bit
overzealous and accidentially removed this important admin feature as
well.

Therefore reduce the --delete option of virt-aa-helper to only delete
the .files that would be re-generated in any case.

Users/Admins are always free to clean the profiles themselve if they
prefer a clean directory - they will be regenerated as needed. But
libvirt should never remove the base profile meant to allow per-guest
overrides and thereby break a documented feature.

[1]: https://gitlab.com/apparmor/apparmor/-/wikis/Libvirt#advanced-usage

Fixes: eba2225b "apparmor: delete profile on VM shutdown"
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: fix crash in qemuDomainSetBlkioParameters without cgroups
Pavel Hrdina [Tue, 11 Aug 2020 13:56:54 +0000 (15:56 +0200)] 
qemu: fix crash in qemuDomainSetBlkioParameters without cgroups

If we don't have cgroups available and user tries to update blkio
parameters for running VM it will crash.

It should have been protected by the virCgroupHasController() check but
it was never called if the API was executed without any flags.

We call virDomainObjGetDefs() which sets `def` and `persistentDef` based
on the flags and these two variables should be used to figure out if we
need to update LIVE, CONFIG or both states.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agokbase: sev: Provide more details on virtio-net configuration
Erik Skultety [Fri, 7 Aug 2020 11:13:39 +0000 (13:13 +0200)] 
kbase: sev: Provide more details on virtio-net configuration

With virtio-net we also need to disable the iPXE option ROM otherwise
a SEV-enabled guest would not boot. While at it, fix the full machine
XML examples accordingly.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
4 years agodocs: formatdomain: fix superscripts
Ján Tomko [Tue, 11 Aug 2020 22:18:23 +0000 (00:18 +0200)] 
docs: formatdomain: fix superscripts

There needs to be a space before the :sup: directive.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agobhyve: fix NULL pointer check position
Ján Tomko [Sun, 2 Aug 2020 20:50:37 +0000 (22:50 +0200)] 
bhyve: fix NULL pointer check position

src/bhyve/bhyve_parse_command.c:437:9: warning: Either the condition
'!config' is redundant or there is possible null pointer dereference:
config. [nullPointerRedundantCheck]

src/bhyve/bhyve_parse_command.c:280:23: warning: Either the condition
'!separator' is redundant or there is pointer arithmetic
with NULL pointer. [nullPointerArithmeticRedundantCheck]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
4 years agovircgroupv2devices: fix counting entries in BPF map
Pavel Hrdina [Tue, 11 Aug 2020 09:07:06 +0000 (11:07 +0200)] 
vircgroupv2devices: fix counting entries in BPF map

BPF syscall BPF_MAP_GET_NEXT_KEY returns -1 if something fails but it
will also return -1 if trying to get next key using the last key in the
map with errno set to ENOENT.

If there are VMs running and libvirtd is restarted and user tries to
call some cgroup devices operation on a VM we need to get the count of
entries in BPF map and it fails which will result in error when trying
to attach/detech devices.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agomeson: define IFCONFIG_PATH for virnetdevip
Roman Bogorodskiy [Sat, 8 Aug 2020 09:16:16 +0000 (13:16 +0400)] 
meson: define IFCONFIG_PATH for virnetdevip

When checking for ifconfig(8), set not only IFCONFIG value,
but also IFCONFIG_PATH as it's used in util/virnetdevip.c.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agomeson: fix BSD bridge management routines check
Roman Bogorodskiy [Sat, 8 Aug 2020 09:16:16 +0000 (13:16 +0400)] 
meson: fix BSD bridge management routines check

Add missing prerequisite headers for checking BRDGSFD, BRDGADD,
BRDGDEL in net/if_bridgevar.h.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agomeson: fix link_addr(3) check
Roman Bogorodskiy [Sat, 8 Aug 2020 09:16:16 +0000 (13:16 +0400)] 
meson: fix link_addr(3) check

Add missing prerequisite headers for checking link_addr(3)
in net/if_dl.h.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoapparmor: let qemu load old shared objects after upgrades
Christian Ehrhardt [Mon, 3 Aug 2020 12:03:19 +0000 (14:03 +0200)] 
apparmor: let qemu load old shared objects after upgrades

Since [1] qemu can after upgrade fall back to pre-upgrade modules
to still be able to dynamically load qemu-module based features.

The paths for these modules are pre-defined by the code and should
be allowed to be mapped and loaded from which will allow packagers
avoiding the inability of late feature load [2] after package upgrades.

[1]: https://github.com/qemu/qemu/commit/bd83c861
[2]: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1847361

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange redhat com>
4 years agoapparmor: qemu access to @{PROC}/*/auxv for hw_cap
Stefan Bader [Mon, 3 Aug 2020 11:44:27 +0000 (13:44 +0200)] 
apparmor: qemu access to @{PROC}/*/auxv for hw_cap

On some architectures (ppc, s390x, sparc, arm) qemu will read auxv
to detect hardware capabilities via qemu_getauxval.

Allow that access read-only for the entry owned by the current
qemu process.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
4 years agoapparmor: read only access to overcommit_memory
Jamie Strandboge [Mon, 3 Aug 2020 11:41:33 +0000 (13:41 +0200)] 
apparmor: read only access to overcommit_memory

Allow qemu to read @{PROC}/sys/vm/overcommit_memory.
This is read on guest start-up and (as read-only) not a
critical secret that has to stay hidden.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Jamie Strandboge <jamie@ubuntu.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoapparmor: allow libvirtd to call pygrub
Stefan Bader [Mon, 3 Aug 2020 10:21:23 +0000 (12:21 +0200)] 
apparmor: allow libvirtd to call pygrub

When using xen through libxl in Debian/Ubuntu it needs to be able to
call pygrub.

This is placed in a versioned path like /usr/lib/xen-4.11/bin.
In theory the rule could be more strict by rendering the libexec_dir
setting pkg-config can derive from libbxen-dev. But that would make
particular libvirt/xen packages version-depend on each other. It seems
more reasonable to avoid these versioned dependencies and use a wildcard
rule instead as it is already in place for libxl-save-helper.

Note: This change was in Debian [1] and Ubuntu [2] for quite some time
already.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931768
[2]: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1326003

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
4 years agoapparmor: allow default pki path
Sam Hartman [Mon, 3 Aug 2020 10:08:41 +0000 (12:08 +0200)] 
apparmor: allow default pki path

/etc/pki/qemu is a pki path recommended by qemu tls docs [1]
and one that can cause issues with spice connections when missing.

Add the path to the allowed list of pki paths to fix the issue.

Note: this is active in Debian/Ubuntu [1] for quite a while already.

[1]: https://www.qemu.org/docs/master/system/tls.html
[2]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930100

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
4 years agoqemu: consider available CPUs in iothread info output
Pavel Hrdina [Fri, 7 Aug 2020 14:04:41 +0000 (16:04 +0200)] 
qemu: consider available CPUs in iothread info output

Following the rationale from commit
<2020c6af8a8e4bb04acb629d089142be984484c8> we should do the same thing
for iothread info as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotest: fix emulator pin info in test driver
Pavel Hrdina [Fri, 7 Aug 2020 13:57:28 +0000 (15:57 +0200)] 
test: fix emulator pin info in test driver

Commit <6328da04285d9f65cb323d399f731c20caf63f5a> introduced
testDomainGetEmulatorPinInfo() into test driver but used
virHostCPUGetCount() function to get the number of host CPUs.

This would be correct for other drivers but in test driver we must not
depend on the host, we have to use hard-coded host representation that
we have in test driver.

Follows the logic of testDomainGetVcpuPinInfo().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: fix detection of available host CPUs for vcpupin
Pavel Hrdina [Fri, 7 Aug 2020 13:48:27 +0000 (15:48 +0200)] 
conf: fix detection of available host CPUs for vcpupin

Commit <2020c6af8a8e4bb04acb629d089142be984484c8> fixed an issue with
QEMU driver by reporting offline CPUs as well. However, doing so it
introduced a regression into libxl and test drivers by completely
ignoring the passed `hostcpus` variable.

Move the virHostCPUGetAvailableCPUsBitmap() out of the helper into QEMU
driver so it will not affect other drivers which gets the number of host
CPUs differently.

This was uncovered by running libvirt-dbus test suite which counts on
the fact that test driver has hard-coded host definition and must not
depend on the host at all.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: remove use of gettid() syscall
Daniel P. Berrangé [Fri, 7 Aug 2020 12:51:16 +0000 (13:51 +0100)] 
qemu: remove use of gettid() syscall

This is not expose in most historical versions of glibc, nor
non-glibc impls. We must use our wrapper API instead.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: fix race in signal interrupt during QEMU startup
Daniel P. Berrangé [Wed, 29 Jul 2020 18:00:25 +0000 (19:00 +0100)] 
qemu: fix race in signal interrupt during QEMU startup

If a Ctrl-C arrives while we are in the middle of executing the
virDomainCreateXML call, we will have no "virDomainPtr" object
available, but QEMU may none the less be running.

This means we'll never try to stop the QEMU process before we
honour the Ctrl-C and exit.

To deal with this race we need to postpone quit of the event
loop if it is requested while in the middle of domain startup.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: avoid race in releasing the GSource in event thread
Daniel P. Berrangé [Wed, 29 Jul 2020 16:51:53 +0000 (17:51 +0100)] 
util: avoid race in releasing the GSource in event thread

There is a race between  vir_event_thread_finalize and
virEventThreadWorker in releasing the last reference on
the GMainContext. If virEventThreadDataFree() runs after
vir_event_thread_finalize releases its reference, then
it will release the last reference on the GMainContext.
As a result g_autoptr cleanup on the GSource will access
free'd memory.

The race can be seen in non-deterministic crashes of the
virt-run-qemu program during its shutdown, but could
also likely affect the main libvirtd QEMU driver:

  Thread 2 (Thread 0x7f508ffff700 (LWP 222813)):
  #0  0x00007f509c8e26b0 in malloc_consolidate (av=av@entry=0x7f5088000020) at malloc.c:4488
  #1  0x00007f509c8e4b08 in _int_malloc (av=av@entry=0x7f5088000020, bytes=bytes@entry=2048) at malloc.c:3711
  #2  0x00007f509c8e6412 in __GI___libc_malloc (bytes=2048) at malloc.c:3073
  #3  0x00007f509d6e925e in g_realloc (mem=0x0, n_bytes=2048) at gmem.c:164
  #4  0x00007f509d705a57 in g_string_maybe_expand (string=string@entry=0x7f5088001f20, len=len@entry=1024) at gstring.c:102
  #5  0x00007f509d705ab6 in g_string_sized_new (dfl_size=dfl_size@entry=1024) at gstring.c:127
  #6  0x00007f509d708c5e in g_test_log_dump (len=<synthetic pointer>, msg=<synthetic pointer>) at gtestutils.c:3330
  #7  0x00007f509d708c5e in g_test_log
      (lbit=G_TEST_LOG_ERROR, string1=0x7f508800fcb0 "GLib:ERROR:ghash.c:377:g_hash_table_lookup_node: assertion failed: (hash_table->ref_count > 0)", string2=<optimized out>, n_args=0, largs=0x0) at gtestutils.c:975
  #8  0x00007f509d70af2a in g_assertion_message
      (domain=<optimized out>, file=0x7f509d7324a2 "ghash.c", line=<optimized out>, func=0x7f509d732750 <__func__.11348> "g_hash_table_lookup_node", message=<optimized out>)
      at gtestutils.c:2504
  #9  0x00007f509d70af8e in g_assertion_message_expr
      (domain=domain@entry=0x7f509d72d76e "GLib", file=file@entry=0x7f509d7324a2 "ghash.c", line=line@entry=377, func=func@entry=0x7f509d732750 <__func__.11348> "g_hash_table_lookup_node", expr=expr@entry=0x7f509d732488 "hash_table->ref_count > 0") at gtestutils.c:2555
  #10 0x00007f509d6d197e in g_hash_table_lookup_node (hash_table=0x55b70ace1760, key=<optimized out>, hash_return=<synthetic pointer>) at ghash.c:377
  #11 0x00007f509d6d197e in g_hash_table_lookup_node (hash_return=<synthetic pointer>, key=<optimized out>, hash_table=0x55b70ace1760) at ghash.c:361
  #12 0x00007f509d6d197e in g_hash_table_remove_internal (hash_table=0x55b70ace1760, key=<optimized out>, notify=1) at ghash.c:1371
  #13 0x00007f509d6e0664 in g_source_unref_internal (source=0x7f5088000b60, context=0x55b70ad87e00, have_lock=0) at gmain.c:2103
  #14 0x00007f509d6e1f64 in g_source_unref (source=<optimized out>) at gmain.c:2176
  #15 0x00007f50a08ff84c in glib_autoptr_cleanup_GSource (_ptr=<synthetic pointer>) at /usr/include/glib-2.0/glib/glib-autocleanups.h:58
  #16 0x00007f50a08ff84c in virEventThreadWorker (opaque=0x55b70ad87f80) at ../../src/util/vireventthread.c:114
  #17 0x00007f509d70bd4a in g_thread_proxy (data=0x55b70acf3850) at gthread.c:784
  #18 0x00007f509d04714a in start_thread (arg=<optimized out>) at pthread_create.c:479
  #19 0x00007f509c95cf23 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

  Thread 1 (Thread 0x7f50a1380c00 (LWP 222802)):
  #0  0x00007f509c8977ff in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x00007f509c881c35 in __GI_abort () at abort.c:79
  #2  0x00007f509d72a823 in g_mutex_clear (mutex=0x55b70ad87e00) at gthread-posix.c:1307
  #3  0x00007f509d72a823 in g_mutex_clear (mutex=mutex@entry=0x55b70ad87e00) at gthread-posix.c:1302
  #4  0x00007f509d6e1a84 in g_main_context_unref (context=0x55b70ad87e00) at gmain.c:582
  #5  0x00007f509d6e1a84 in g_main_context_unref (context=0x55b70ad87e00) at gmain.c:541
  #6  0x00007f50a08ffabb in vir_event_thread_finalize (object=0x55b70ad83180 [virEventThread]) at ../../src/util/vireventthread.c:50
  #7  0x00007f509d9c48a9 in g_object_unref (_object=<optimized out>) at gobject.c:3340
  #8  0x00007f509d9c48a9 in g_object_unref (_object=0x55b70ad83180) at gobject.c:3232

  #9  0x00007f509583d311 in qemuProcessQMPFree (proc=proc@entry=0x55b70ad87b90) at ../../src/qemu/qemu_process.c:8355
  #10 0x00007f5095790f58 in virQEMUCapsInitQMPSingle
      (qemuCaps=qemuCaps@entry=0x55b70ad88010, libDir=libDir@entry=0x55b70ad049e0 "/tmp/virt-qemu-run-VZC9N0/lib/qemu", runUid=runUid@entry=107, runGid=runGid@entry=107, onlyTCG=onlyTCG@entry=false) at ../../src/qemu/qemu_capabilities.c:5409
  #11 0x00007f509579108f in virQEMUCapsInitQMP (runGid=107, runUid=107, libDir=0x55b70ad049e0 "/tmp/virt-qemu-run-VZC9N0/lib/qemu", qemuCaps=0x55b70ad88010)
      at ../../src/qemu/qemu_capabilities.c:5420
  #12 0x00007f509579108f in virQEMUCapsNewForBinaryInternal
      (hostArch=VIR_ARCH_X86_64, binary=binary@entry=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", libDir=0x55b70ad049e0 "/tmp/virt-qemu-run-VZC9N0/lib/qemu", runUid=107, runGid=107, hostCPUSignature=0x55b70ad01320 "GenuineIntel, Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz, family: 6, model: 85, stepping: 7", microcodeVersion=83898113, kernelVersion=0x55b70ad00d60 "4.18.0-211.el8.x86_64 #1 SMP Thu Jun 4 08:08:16 UTC 2020") at ../../src/qemu/qemu_capabilities.c:5472
  #13 0x00007f5095791373 in virQEMUCapsNewData (binary=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", privData=0x55b70ad5b8f0) at ../../src/qemu/qemu_capabilities.c:5505
  #14 0x00007f50a09a32b1 in virFileCacheNewData (name=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", cache=<optimized out>) at ../../src/util/virfilecache.c:208
  #15 0x00007f50a09a32b1 in virFileCacheValidate (cache=cache@entry=0x55b70ad5c030, name=name@entry=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", data=data@entry=0x7ffca39ffd90)
      at ../../src/util/virfilecache.c:277
  #16 0x00007f50a09a37ea in virFileCacheLookup (cache=cache@entry=0x55b70ad5c030, name=name@entry=0x55b70ad7dc40 "/usr/libexec/qemu-kvm") at ../../src/util/virfilecache.c:310
  #17 0x00007f5095791627 in virQEMUCapsCacheLookup (cache=0x55b70ad5c030, binary=0x55b70ad7dc40 "/usr/libexec/qemu-kvm") at ../../src/qemu/qemu_capabilities.c:5647
  #18 0x00007f50957c34c3 in qemuDomainPostParseDataAlloc (def=<optimized out>, parseFlags=<optimized out>, opaque=<optimized out>, parseOpaque=0x7ffca39ffe18)
      at ../../src/qemu/qemu_domain.c:5470
  #19 0x00007f50a0a34051 in virDomainDefPostParse
      (def=def@entry=0x55b70ad7d200, parseFlags=parseFlags@entry=258, xmlopt=xmlopt@entry=0x55b70ad5d010, parseOpaque=parseOpaque@entry=0x0)
      at ../../src/conf/domain_conf.c:5970
  #20 0x00007f50a0a464bb in virDomainDefParseNode
      (xml=xml@entry=0x55b70aced140, root=root@entry=0x55b70ad5f020, xmlopt=xmlopt@entry=0x55b70ad5d010, parseOpaque=parseOpaque@entry=0x0, flags=flags@entry=258)
      at ../../src/conf/domain_conf.c:22520
  #21 0x00007f50a0a4669b in virDomainDefParse
      (xmlStr=xmlStr@entry=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., filename=filename@entry=0x0, xmlopt=0x55b70ad5d010, parseOpaque=parseOpaque@entry=0x0, flags=flags@entry=258) at ../../src/conf/domain_conf.c:22474
  #22 0x00007f50a0a467ae in virDomainDefParseString
      (xmlStr=xmlStr@entry=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., xmlopt=<optimized out>, parseOpaque=parseOpaque@entry=0x0, flags=flags@entry=258)
      at ../../src/conf/domain_conf.c:22488
  #23 0x00007f50958ce112 in qemuDomainCreateXML
      (conn=0x55b70acf9090, xml=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., flags=0) at ../../src/qemu/qemu_driver.c:1744
  #24 0x00007f50a0c268ac in virDomainCreateXML
      (conn=0x55b70acf9090, xmlDesc=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., flags=0) at ../../src/libvirt-domain.c:176
  #25 0x000055b709547e7b in main (argc=<optimized out>, argv=<optimized out>) at ../../src/qemu/qemu_shim.c:289

The solution is to explicitly unref the GSource at a safe time instead
of letting g_autoptr unref it when leaving scope.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: avoid crash due to race in glib event loop code
Daniel P. Berrangé [Tue, 28 Jul 2020 15:52:47 +0000 (16:52 +0100)] 
util: avoid crash due to race in glib event loop code

There is a fairly long standing race condition bug in glib which can hit
if you call g_source_destroy or g_source_unref from a non-main thread:

  https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1358

Unfortunately it is really common for libvirt to call g_source_destroy
from a non-main thread. This glib bug is the cause of non-determinstic
crashes in eventtest, and probably in libvirtd too.

To work around the problem we need to ensure that we never release
the last reference on a GSource from a non-main thread. The previous
patch replaced our use of g_source_destroy with a pair of
g_source_remove and g_source_unref. We can now delay the g_source_unref
call by using a idle callback to invoke it from the main thread which
avoids the race condition.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: keep track of full GSource object not source ID number
Daniel P. Berrangé [Tue, 28 Jul 2020 14:54:13 +0000 (15:54 +0100)] 
util: keep track of full GSource object not source ID number

The source ID number is an alternative way to identify a source that has
been added to a GMainContext. Internally when a source ID is given, glib
will lookup the corresponding GSource and use that. The use of a source
ID is racy in some cases though, because it is invalid to continue to
use an ID number after the GSource has been removed. It is thus safer
to use the GSource object directly and have full control over the ref
counting and thus cleanup.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agomeson: fix readline detection if there is no pkg-config file
Pavel Hrdina [Wed, 5 Aug 2020 10:39:24 +0000 (12:39 +0200)] 
meson: fix readline detection if there is no pkg-config file

Commit <74416b1d4849ef77ef31de5344dd75f03094434b> added check for
rl_completion_quote_character to make sure we have correct readline
library. Commit <a9443bc9a9ef451b46306e66ed3b706756fc1414> added
inaccurate comment that it's a function.

We need to check for generic symbol instead of checking for function.
In addition the readline/readline.h file requires stdio.h to by included
beforehand which was done in autotools but I dropped it in meson.

And lastly the final condition to print error or disable readline was
broken as well by replacing the readline_dep every time if readline was
not explicitly enabled.

Reported-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs/manpages/meson: fix sanlock detection
Pavel Hrdina [Wed, 5 Aug 2020 08:04:12 +0000 (10:04 +0200)] 
docs/manpages/meson: fix sanlock detection

In meson.build we define sanlock_dep only if it is available but in
addition we add 'WITH_SANLOCK' into conf. Use the presence of
'WITH_SANLOCK' in conf to figure out if we need to install
virt-sanlock-cleanup man page.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoscripts: Fix meson-install-symlink.py overwriting existing links
Erik Skultety [Tue, 4 Aug 2020 15:27:21 +0000 (17:27 +0200)] 
scripts: Fix meson-install-symlink.py overwriting existing links

By default, symlink re-creation fails if the link already exists, more
specifically in case of meson-install-symlink.py:

Traceback (most recent call last):
  File "/<path_to_libvirt_repo>/scripts/meson-install-symlink.py",
    line 15, in <module>
        os.symlink(target, link)
FileExistsError: File exists: '../default.xml' -> 'default.xml'

Unfortunately, Python can't mimic "ln -sf", so we have to fix this
differently - remove the existing link first and then try re-creating
it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoutil: Fix logic in virFileSetCOW
Jiri Denemark [Wed, 5 Aug 2020 08:01:45 +0000 (10:01 +0200)] 
util: Fix logic in virFileSetCOW

When COW is not explicitly requested to be disabled or enabled, the
function is supposed to do nothing on non-BTRFS file systems.

Fixes commit 7230bc95aa78379c9ee20cf59394c5fc4305b75b.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotreat all NULL returns from virXMLNodeContentString() as an error
Laine Stump [Tue, 14 Jul 2020 17:43:00 +0000 (13:43 -0400)] 
treat all NULL returns from virXMLNodeContentString() as an error

and stop erroneously equating NULL with "". The latter means that the
element has empty content, while the former means there was an error
during parsing (either internal with the parser, or the content of the
XML was bad).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: log an error if virXMLNodeContentString will return NULL
Laine Stump [Tue, 14 Jul 2020 04:21:28 +0000 (00:21 -0400)] 
util: log an error if virXMLNodeContentString will return NULL

Many of our calls to xmlNodeGetContent() (which are now all via
virXMLNodeContentString() are failing to check for a NULL return. We
need to remedy that, but in order to make the remedy simpler, let's
log an error in virXMLNodeContentString(), so that the callers don't
all individually need to (since it would be the same error message for
all of them anyway).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: replace all calls to xmlNodeGetContent with virXMLNodeContentString
Laine Stump [Tue, 14 Jul 2020 04:21:28 +0000 (00:21 -0400)] 
util: replace all calls to xmlNodeGetContent with virXMLNodeContentString

No functional change

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: refactor virDomainBlkioDeviceParseXML to reduce calls to xmlNodeGetContent
Laine Stump [Fri, 19 Jun 2020 01:52:38 +0000 (21:52 -0400)] 
conf: refactor virDomainBlkioDeviceParseXML to reduce calls to xmlNodeGetContent

virDomainBlkioDeviceParseXML() calls xmlNodeGetContent() multiple
times in a loop, but can easily be refactored to call it once for all
element nodes, and then use the result of that one call in each of the
(mutually exclusive) blocks that previously each had their own call to
xmlNodeGetContent.

This is being done in order to reduce the number of changes needed in
an upcoming patch that will eliminate the lack of checking for NULL on
return from xmlNodeGetContent().

As part of the simplification, the while() loop has been changed into
a for() so that we can use "continue" without bypassing the
"node = node->next".

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: formatdomain: fyx a tipo
Ján Tomko [Tue, 4 Aug 2020 17:36:42 +0000 (19:36 +0200)] 
docs: formatdomain: fyx a tipo

s/hystorical/historical/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: add G_GNUC_NO_INLINE annotations for mocked symbols
Daniel P. Berrangé [Tue, 4 Aug 2020 14:17:07 +0000 (15:17 +0100)] 
src: add G_GNUC_NO_INLINE annotations for mocked symbols

We should prevent inlining of symbols from the driver .so files that are
mocked, as well as those in the main libvirt.so

This isn't fixing any currently known problem, just trying to prevent
future issues.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotests: qemublocktest: fix crashing with SIGBUS
Roman Bogorodskiy [Tue, 4 Aug 2020 16:07:00 +0000 (20:07 +0400)] 
tests: qemublocktest: fix crashing with SIGBUS

Commit bcbb026993 converted qemublocktest to use
g_autoptr for virQEMUCaps. To prevent it from crashing,
don't explicitly call virObjectUnref() on this object.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>