]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agoutil: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE
Ján Tomko [Tue, 28 Jul 2020 19:47:29 +0000 (21:47 +0200)] 
util: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE

The VIR_XPATH_NODE_AUTORESTORE contains an ignore_value
statement to silence an unused variable warning on clang.

Use a pragma instead, which is not a statement.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: iscsitest: split out testISCSIScanTargetsTests
Ján Tomko [Tue, 28 Jul 2020 18:11:09 +0000 (20:11 +0200)] 
tests: iscsitest: split out testISCSIScanTargetsTests

The ScanTargets testing code declares some variables
in the middle of main.

Split it out into a separate function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: cgroup: wrap BACKEND_CALL macro in a block
Ján Tomko [Tue, 28 Jul 2020 18:08:07 +0000 (20:08 +0200)] 
util: cgroup: wrap BACKEND_CALL macro in a block

VIR_CGROUP_BACKEND_CALL is exclusively used at the end
of a function, but it declares a variable.

Wrap it in a do..while block.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: authconfigtest: move declarations
Ján Tomko [Tue, 28 Jul 2020 18:11:01 +0000 (20:11 +0200)] 
tests: authconfigtest: move declarations

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: sockettest: move declarations
Ján Tomko [Tue, 28 Jul 2020 18:10:53 +0000 (20:10 +0200)] 
tests: sockettest: move declarations

Declare the structs: at the beginning of the block.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: virNetDevBridgeSet: split declarations
Ján Tomko [Tue, 28 Jul 2020 18:09:22 +0000 (20:09 +0200)] 
util: virNetDevBridgeSet: split declarations

Declare the variables at the beginning of the function,
then fill them up.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosecurity: move chardevData declaration
Ján Tomko [Tue, 28 Jul 2020 17:59:54 +0000 (19:59 +0200)] 
security: move chardevData declaration

Declare it at the beginning of the function
instead of right before use.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agorpc: move lock after declaration
Ján Tomko [Tue, 28 Jul 2020 18:00:03 +0000 (20:00 +0200)] 
rpc: move lock after declaration

virNetClientRemoveStream starts by calling a lock.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoMove debug statements after declarations
Ján Tomko [Mon, 3 Aug 2020 15:28:06 +0000 (17:28 +0200)] 
Move debug statements after declarations

Many of our functions start with a DEBUG statement.
Move the statements after declarations to appease
our coding style.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoSplit declarations from initializations
Ján Tomko [Tue, 28 Jul 2020 17:50:28 +0000 (19:50 +0200)] 
Split declarations from initializations

Split those initializations that depend on a statement
above them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoMove declarations before statements
Ján Tomko [Mon, 3 Aug 2020 15:27:58 +0000 (17:27 +0200)] 
Move declarations before statements

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: move declarations in virStorageFileChainLookup
Ján Tomko [Tue, 28 Jul 2020 18:09:40 +0000 (20:09 +0200)] 
util: move declarations in virStorageFileChainLookup

Use g_autofree and move the declarations to the beginning
of the block.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: virHostMem*Parameters: split out non-Linux stubs
Ján Tomko [Mon, 3 Aug 2020 15:58:03 +0000 (17:58 +0200)] 
util: virHostMem*Parameters: split out non-Linux stubs

Repeat the whole function header instead of mixing #ifdefs
in the code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: virHostMemSetParameters: remove pointless variable
Ján Tomko [Mon, 3 Aug 2020 15:56:25 +0000 (17:56 +0200)] 
util: virHostMemSetParameters: remove pointless variable

It is only used inside the condition.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: virRandomInt: remove temporary variable
Ján Tomko [Tue, 28 Jul 2020 18:09:31 +0000 (20:09 +0200)] 
util: virRandomInt: remove temporary variable

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: Mention support for device model commandline passthrough in Xen
Jim Fehlig [Fri, 31 Jul 2020 15:53:01 +0000 (09:53 -0600)] 
news: Mention support for device model commandline passthrough in Xen

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoXen: Add support for qemu commandline passthrough to config converter
Jim Fehlig [Fri, 31 Jul 2020 15:39:25 +0000 (09:39 -0600)] 
Xen: Add support for qemu commandline passthrough to config converter

Support qemu commandline passthrough in the domXML to native config
converter. Add tests to check the conversion.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoXen: Add support for qemu command-line passthrough
Jim Fehlig [Thu, 30 Jul 2020 19:25:20 +0000 (13:25 -0600)] 
Xen: Add support for qemu command-line passthrough

Xen supports passing arbitrary arguments to the QEMU device model via
the 'extra' member of the public libxl_domain_build_info structure.
This patch adds a 'xen' namespace extension, similar to the QEMU and
bhyve drivers, to map arbitrary arguments to the 'extra' member. Only
passthrough of arguments is supported. Passthrough of environment
variables or capabilities adjustments is not supported.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoNEWS.rst: update with NVDIMM auto-alignment removal for pSeries
Daniel Henrique Barboza [Mon, 24 Aug 2020 17:57:37 +0000 (14:57 -0300)] 
NEWS.rst: update with NVDIMM auto-alignment removal for pSeries

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agostorage_util: fix qemu-img sparse allocation
Pavel Hrdina [Tue, 25 Aug 2020 13:09:53 +0000 (15:09 +0200)] 
storage_util: fix qemu-img sparse allocation

Commit <c9ec7088c7a3f4cd26bb471f1f243931fff6f4f9> introduced a support
to fully allocate qcow2 images when <allocation> matches <capacity> but
it doesn't work as expected.

The issue is that info.size_arg is in KB but the info.allocation
introduced by the mentioned commit is in B. This results in using
"preallocation=falloc," in cases where "preallocation=metadata," should
be used.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirnetserver: fix some memory leaks in virNetTLSContextReloadForServer
Jin Yan [Thu, 13 Aug 2020 03:37:56 +0000 (11:37 +0800)] 
virnetserver: fix some memory leaks in virNetTLSContextReloadForServer

These leaks were introduced in commit 15d280fa97b0, use g_autofree for all
cert_path pointers.

Signed-off-by: Jin Yan <jinyan12@huawei.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoNEWS: Mention IQN setting for iSCSI hostdevs
Peter Krempa [Mon, 24 Aug 2020 15:11:05 +0000 (17:11 +0200)] 
NEWS: Mention IQN setting for iSCSI hostdevs

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh: Add source-initiator opt to build the initiator of pool XML
Han Han [Tue, 25 Aug 2020 03:50:33 +0000 (11:50 +0800)] 
virsh: Add source-initiator opt to build the initiator of pool XML

For iscsi-direct pool, the initiator is necessary for pool defining:
<pool type="iscsi-direct">
 ...
    <initiator>
      <iqn name="iqn.2013-06.com.example:iscsi-initiator"/>
    </initiator>
...
</pool>

Add --source-initiator to fill the initiator iqn for
pool-create-as/pool-define-as subcommands.

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

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationCapsToJSON: Refactor capability object formatting
Peter Krempa [Mon, 24 Aug 2020 15:00:59 +0000 (17:00 +0200)] 
qemuMigrationCapsToJSON: Refactor capability object formatting

Use virJSONValueObjectCreate rather than creating the object
piece-by-piece and use new accessors for bitmap to simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agogitdm: add missing aliases
Pino Toscano [Mon, 24 Aug 2020 10:44:14 +0000 (12:44 +0200)] 
gitdm: add missing aliases

Consider a couple of misspelt emails in B-y tags.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agogitdm: move pld-linux.org to opensource
Pino Toscano [Mon, 24 Aug 2020 10:19:59 +0000 (12:19 +0200)] 
gitdm: move pld-linux.org to opensource

PLD Linux is a Linux distribution, so @pld-linux.org fits in the
opensource group with similar projects.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agodocs: formatdomain: document <audio> element
Roman Bogorodskiy [Fri, 7 Aug 2020 15:00:38 +0000 (19:00 +0400)] 
docs: formatdomain: document <audio> element

Document the new <audio> element which allows to specify
host audio backend for a guest <sound> device, and update
the <sound> element description with the new <audio>
sub-element which specifies the other end of the mapping.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: allow to specify host sound device
Roman Bogorodskiy [Sat, 18 Jul 2020 11:23:28 +0000 (15:23 +0400)] 
bhyve: allow to specify host sound device

Allow to map sound playback and recording devices to host devices
using "<audio type='oss'/>" OSS audio backend.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: allow to map sound device to host device
Roman Bogorodskiy [Sat, 18 Jul 2020 06:23:57 +0000 (10:23 +0400)] 
conf: allow to map sound device to host device

Introduce a new device element "<audio>" which allows
to map guest sound device specified using the "<sound>"
element to specific audio backend.

Example:

  <sound model='ich7'>
     <audio id='1'/>
  </sound>
  <audio id='1' type='oss'>
     <input dev='/dev/dsp0'/>
     <output dev='/dev/dsp0'/>
  </audio>

This block maps to OSS audio backend on the host using
/dev/dsp0 device for both input (recording)
and output (playback).

OSS is the only backend supported so far.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agobhyve: implement sound device support
Roman Bogorodskiy [Tue, 14 Jul 2020 14:44:13 +0000 (18:44 +0400)] 
bhyve: implement sound device support

bhyve supports intel hda sound devices that could be specified
on the command like using "-1:0,hda,play=$play_dev,rec=$rec_dev",
where "1:0" is a PCI address, and "$play_dev" and "$rec_dev"
point to the playback and recording device on the host respectively.
Currently, schema of the 'sound' element doesn't allow specifying
neither playback nor recording devices, so for now hardcode
/dev/dsp0, which is the first audio device on the host.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add 'ich7' sound model
Roman Bogorodskiy [Thu, 6 Aug 2020 14:40:37 +0000 (18:40 +0400)] 
conf: add 'ich7' sound model

Add 'ich7' sound model. This is a preparation for sound support in
bhyve, as 'ich7' is the only model it supports.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: properly clear out autogenerated macvtap names when formatting/parsing
Laine Stump [Sun, 23 Aug 2020 03:42:52 +0000 (23:42 -0400)] 
conf: properly clear out autogenerated macvtap names when formatting/parsing

Back when macvtap support was added in commit 315baab9443 in Feb. 2010
(libvirt-0.7.7), it was setup to autogenerate a name for the device if
one wasn't supplied, in the pattern "macvtap%d" (or "macvlan%d"),
similar to the way an unspecified standard tap device name will lead
to an autogenerated "vnet%d".

As a matter of fact, in commit ca1b7cc8e45 added in May 2010, the code
was changed to *always* ignore a supplied device name for macvtap
interfaces by deleting *any* name immediately during the <interface>
parsing (this was intended to prevent one domain which had failed to
completely start from deleting the macvtap device of another domain
which had subsequently been provided the same device name (this will
seem mildly ironic later). This was later fixed to only clear the
device name when inactive XML was being parsed. HOWEVER - this was
only done if the xml was <interface type='direct'> - autogenerated
names were not cleared for <interface type='network'> (which could
also result in a macvtap device).

Although the names of "vnetX" tap devices had always been
automatically cleared when parsing <interface> (see commit d1304583d
from July 2008 (!)), at the time macvtap support was added, both vnetX
and macvtapX device names were always included when formatting the
XML.

Then in commit a8be259d0cc (July 2011, libvirt-0.9.4), <interface>
formatting was changed to also clear out "vnetX" device names during
XML formatting as well. However the same treatment wasn't given to
"macvtapX".

Now in 2020, there has been a report that a failed migration leads to
the macvtap device of some other unrelated guest on the destination
host losing its network connectivity. It was determined that this was
due to the domain XML in the migration containing a macvtap device
name, e.g. "macvtap0", that was already in use by the other guest on
the destination. Normally this wouldn't be a problem, because libvirt
would see that the device was already in use, and then find a
different unused name. But in this case, other external problems were
causing the migration to fail prior to selecting a macvtap device and
successfully opening it, and during error recovery, qemuProcessStop()
was called, which went through all def->nets objects and (if they were
macvtap) deleted the device specified in net->ifname; since libvirt
hadn't gotten to the point of replacing the incoming "macvtap0" with
the name of a device it actually created for this guest, that meant
that "macvtap0" was deleted, *even though it was currently in use by a
different guest*!

Whew!

So, it turns out that when formatting "migratable" XML, "vnetX"
devices are omitted, just as when formatting "inactive" XML. By making
the code in both interface parsing and formatting consistent for
"vnetX", "macvtapX", and "macvlanX", we can thus make sure that the
autogenerated (and unneeded / completely *not* wanted) macvtap device
name will not be sent with the migration XML. This way when a
migration fails, net->ifname will be NULL, and libvirt won't have any
device to try and (erroneously) delete.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: remove unreachable code in qemuProcessStart()
Laine Stump [Sat, 22 Aug 2020 21:43:24 +0000 (17:43 -0400)] 
qemu: remove unreachable code in qemuProcessStart()

Back when the original version of this chunk of code was added (commit
41b087198 in libvirt-0.8.1 in April 2010), we used virExecDaemonize()
to start the qemu process, and would continue on in the function
(which at that time was called qemudStartVMDaemon()) even if a -1 was
returned. So it was possible to get to this code with rv == -1 (it was
called "ret" in that version of the code).

In modern libvirt code, qemu is started with virCommandRun(); then we
call virPidFileReadPath(); those are the only two ways of setting "rv"
prior to this code being removed, and in either case if the new value
of rv < 0, then we immediately skip over the rest of the code to the
cleanup: label.

This means that the code being removed by this patch is
unreachable.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu_namespace: Don't build namespace if domain doesn't have it enabled
Michal Privoznik [Fri, 21 Aug 2020 13:49:29 +0000 (15:49 +0200)] 
qemu_namespace: Don't build namespace if domain doesn't have it enabled

Even if namespaces are disabled, then due to a missing check at the
beginning of qemuDomainBuildNamespace(), the domain startup code
still tries to populate (nonexistent) domain's namespace.

Fixes: 8da362fe62766b4eee209cd3ce591ceb62299d13
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoRevert "formatdomain.html.in: mention pSeries NVDIMM 'align down' mechanic"
Daniel Henrique Barboza [Mon, 24 Aug 2020 16:41:05 +0000 (18:41 +0200)] 
Revert "formatdomain.html.in: mention pSeries NVDIMM 'align down' mechanic"

We do not auto-align down pSeries NVDIMMs anymore.

This reverts commit 8f474ceea05aec349be19726e394a62e300efe77.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_domain.c: change qemuDomainMemoryDeviceAlignSize() return type
Daniel Henrique Barboza [Thu, 30 Jul 2020 19:48:03 +0000 (16:48 -0300)] 
qemu_domain.c: change qemuDomainMemoryDeviceAlignSize() return type

After the recent changes, this function is now always returning
zero. Turn it to 'void' to relieve callers from checking it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_domain.c: do not auto-align ppc64 NVDIMMs
Daniel Henrique Barboza [Thu, 30 Jul 2020 19:48:02 +0000 (16:48 -0300)] 
qemu_domain.c: do not auto-align ppc64 NVDIMMs

We don't need the auto-alignment now that the user is handling
it by hand.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_validate.c: add pSeries NVDIMM size alignment validation
Daniel Henrique Barboza [Thu, 30 Jul 2020 19:48:01 +0000 (16:48 -0300)] 
qemu_validate.c: add pSeries NVDIMM size alignment validation

The existing auto-align behavior for pSeries has the idea to
alleviate user configuration of the NVDIMM size, given that the
alignment calculation is not trivial to do (256MiB alignment
of mem->size - mem->label_size value, a.k.a guest area). We
align mem->size down to avoid end of file problems.

The end result is not ideal though. We do not touch the domain
XML, meaning that the XML can report a NVDIMM size 255MiB smaller
than the actual size the guest is seeing. It also adds one more
thing to consider in case the guest is reporting less memory
than declared, since the auto-align is transparent to the
user.

Following Andrea's suggestion in [1], let's instead do an
size alignment validation. If the NVDIMM is unaligned, error out
and suggest a rounded up value. This can be bothersome to users,
but will bring consistency of NVDIMM size between the domain XML
and the guest.

This approach will force existing non-running pSeries guests to
readjust the NVDIMM value in their XMLs, if necessary. No changes
were made for x86 NVDIMM support.

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

Suggested-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_domain.c: make qemuDomainGetMemorySizeAlignment() public
Daniel Henrique Barboza [Thu, 30 Jul 2020 19:48:00 +0000 (16:48 -0300)] 
qemu_domain.c: make qemuDomainGetMemorySizeAlignment() public

Next patch will use it outside of qemu_domain.c.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuDomainGetMemorySizeAlignment: Mark domain @def const
Michal Privoznik [Mon, 24 Aug 2020 16:29:44 +0000 (18:29 +0200)] 
qemuDomainGetMemorySizeAlignment: Mark domain @def const

This function is not changing the domain definition, it's only
reading from it. The function is going to be used from another
function which already takes const virDomainDef. Make the @def
const to avoid typecasting it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agomanpages/virsh: A couple of small clarifications
Kashyap Chamarthy [Tue, 4 Aug 2020 14:04:03 +0000 (16:04 +0200)] 
manpages/virsh: A couple of small clarifications

Changes:

  - Update the descriptions of --current & --config flags.

    For --config, the reason to rephrase "next boot" to "next start"
    is: "Next boot may still imply somebody selecting "reboot" in the
    guest OS and fully expecting the changes to be applied."  (per Peter
    Krempa)

    For --current, existing documentation says:

      "If *--current* is specified, affect the current guest state."

    It's not entirely clear what states can "current" mean or imply.  So
    rephrase it in context of the other two related flags --live and
    --config.

  - While at it, I also took the liberty to replace the few occurrences
    of "peristent domain[s]" with "persistent guest[s]"

Fix all occurrences (i.e. as many as I could spot) of this.

(Thanks: Dan Berrangé on IRC.)

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Move virQEMUFileOpenAs to qemu_domain.c
Peter Krempa [Mon, 24 Aug 2020 15:38:05 +0000 (17:38 +0200)] 
qemu: Move virQEMUFileOpenAs to qemu_domain.c

Commit 43620689794507308fbd3def6992a68ee2f8fa97 moved the function to
util/virqemu.c which is compiled also on win32 and geteuid()/getegid()
doesn't exist there.

Move it to qemu_domain.c which is compiled only when the qemu driver is
enabled. Originally I didn't want to put it here as qemu_domain.c is a
code dump for helper functions but this is the least invasive fix.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemucapabilitiesdata: Add test data for x86_64 for the qemu-5.2 dev cycle
Peter Krempa [Mon, 24 Aug 2020 12:22:20 +0000 (14:22 +0200)] 
qemucapabilitiesdata: Add test data for x86_64 for the qemu-5.2 dev cycle

The machine types for this cycle were already added and qemu also added
a property for the machine type object called "default-ram-id".

Also "block-bitmap-mapping" is supported as a migration parameter.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemucapabilities: Update data for qemu-v5.1.0 release
Peter Krempa [Mon, 24 Aug 2020 12:14:48 +0000 (14:14 +0200)] 
tests: qemucapabilities: Update data for qemu-v5.1.0 release

qemu-v5.1.0 is released now. There weren't any noticable changes since
our last update to 'rc2'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemumigparamstest: Validate output parameters against QMP schema
Peter Krempa [Fri, 7 Aug 2020 14:02:03 +0000 (16:02 +0200)] 
qemumigparamstest: Validate output parameters against QMP schema

Ensure that the migration parameters are formatted properly according to
the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Extract snapshot related code to a separate file
Peter Krempa [Wed, 15 Jul 2020 13:50:14 +0000 (15:50 +0200)] 
qemu: Extract snapshot related code to a separate file

We've dumped all the snapshot helpers and related code into
qemu_driver.c. It accounted for ~10% of overal size of qemu_driver.c.

Separate the code to qemu_snapshot.c/h.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Split of code related to handling of the save image file
Peter Krempa [Thu, 16 Jul 2020 07:54:56 +0000 (09:54 +0200)] 
qemu: Split of code related to handling of the save image file

There's a lot of helper code related to the save image handling. Extract
it to qemu_saveimage.c/h.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuFileWrapperFDClose: move to qemu_domain.c
Peter Krempa [Thu, 16 Jul 2020 09:40:34 +0000 (11:40 +0200)] 
qemuFileWrapperFDClose: 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 we check the domain
state after closing the wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
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>