]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoscripts: check-aclrules: use regular expressions less often
Ján Tomko [Wed, 20 Nov 2019 18:13:29 +0000 (19:13 +0100)]
scripts: check-aclrules: use regular expressions less often

Use a simple
  if "substr" in line
before running a regular expression, which saves time,
especially if the regex has a capture group.

This reduces runtime of the check by almost 78 % for me.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoscripts: check-aclrules: use in instead of find
Ján Tomko [Wed, 20 Nov 2019 18:05:13 +0000 (19:05 +0100)]
scripts: check-aclrules: use in instead of find

For checking whether a substring is present in a string,
using the pattern:
    "str" in string
is slightly faster than:
    string.find("str") != -1

Use it to shave off 4 % of the runtime of this script that
processes quite a few long source files.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoscripts: speedup prohibit-duplicate-header
Ján Tomko [Wed, 9 Oct 2019 19:02:38 +0000 (21:02 +0200)]
scripts: speedup prohibit-duplicate-header

Running regular expressions with capture groups is expensive.
Bail out early if the line does not start with a '#'.

This reduces the runtime of the check by two thirds.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirsh: limit completion of 'domhostname' to active domains
Pino Toscano [Wed, 20 Nov 2019 13:24:33 +0000 (14:24 +0100)]
virsh: limit completion of 'domhostname' to active domains

Getting the hostname of a guest usually requires a in-guest agent,
or generally can be determined only on active domains.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuProcessStop: Remove image metadata for running mirror jobs
Michal Privoznik [Mon, 18 Nov 2019 16:40:01 +0000 (17:40 +0100)]
qemuProcessStop: Remove image metadata for running mirror jobs

If user starts a blockcommit or a blockcopy then we modify access
for qemu on both images and leave it like that until the job
terminates.  So far so good. Problem is, if user instead of
terminating the job (where we would modify the access again so
that the state before the job is restored) calls destroy on the
domain or if qemu dies whilst executing the block job.  In this
case we don't ever clear the access we granted at the beginning.
To fix this, maybe a bit harsh approach is used, but it works:
after all labels were restored (that is after
qemuSecurityRestoreAllLabel() was called), we iterate over each
disk in the domain and remove XATTRs from the whole backing chain
and also from any file the disk is being mirrored to.

This would have been done at the time of pivot, but it isn't
because user decided to kill the domain instead. If we don't do
this and leave some XATTRs behind the domain might be unable to
start.

Also, secdriver can't do this because it doesn't know if there is
any job running. It's outside of its scope - the hypervisor
driver is responsible for calling secdriver's APIs.

Moreover, this is safe to call because we don't remember labels
for any member of a backing chain except of the top layer. But
that one was restored in qemuSecurityRestoreAllLabel() call done
earlier. Therefore, not only we don't remember labels (and thus
this is basically a NOP for other images in the backing chain) it
is also safe to call this when no blockjob was started in the
first place, or if some parts of the backing chain are shared
with some other domains - this is NOP, unless a block job is
active at the time of domain destroy.

https://bugzilla.redhat.com/show_bug.cgi?id=1741456#c19

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Separate image metadata removal into a function
Michal Privoznik [Tue, 19 Nov 2019 07:43:58 +0000 (08:43 +0100)]
qemu: Separate image metadata removal into a function

There are four places where we remove image XATTRs and in all of
them we have the same for() loop with the same body. Move it into
a separate function because I'm about to introduce fifth place
where the same needs to be done.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Instantiate pflash via -machine when using blockdev
Peter Krempa [Fri, 15 Nov 2019 11:27:42 +0000 (12:27 +0100)]
qemu: Instantiate pflash via -machine when using blockdev

Install the convertor function which enables the internals that will use
-blockdev to make qemu open the firmware image and stop using -drive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: command: Build the 'pflash' drives via -machine
Peter Krempa [Fri, 15 Nov 2019 12:36:53 +0000 (13:36 +0100)]
qemu: command: Build the 'pflash' drives via -machine

The old way to instantiate a pflash device via -drive was a hack since
it's a platform device.

The modern approach calls for configuring it via -machine and takes the
node name as an argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: command: Build -blockdev-s for backing of pflash
Peter Krempa [Fri, 15 Nov 2019 13:41:56 +0000 (14:41 +0100)]
qemu: command: Build  -blockdev-s for backing of pflash

As a first step we will build the blockdevs which will be supposed to
back the pflash drives when moving away from -drive.

This code is similar to the way we build the blockdevs for the disk, but
skips the copy-on-read layer and doesn't implement any legacy approach.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: domain: Introduce helper to convert <loader> into virStorageSource
Peter Krempa [Fri, 15 Nov 2019 15:25:26 +0000 (16:25 +0100)]
qemu: domain: Introduce helper to convert <loader> into virStorageSource

Add a helper which will covert the PFLASH code file and variable file
into the virStorageSource objects stored in private data so that we can
use them with -blockdev while keeping the infrastructure to determine
the path to the loaders intact.

This is a temporary solution until we will want to do snapshots of the
pflash where we will be forced do track the full backing chain in the
XML.

In the meanwhile just convert it partially so that we can stop using
-drive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: domain: Store virStorageSources representing pflash backing
Peter Krempa [Fri, 15 Nov 2019 15:23:44 +0000 (16:23 +0100)]
qemu: domain: Store virStorageSources representing pflash backing

To allow converting the pflash drives to blockdev we will need a
virStorageSource to allow using our helpers. Temporarily prior to
coverting loader data to a virStorageSoruce add private data which will
house this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: command: Extract formatting of -drive for pflash
Peter Krempa [Fri, 1 Nov 2019 11:14:43 +0000 (12:14 +0100)]
qemu: command: Extract formatting of -drive for pflash

Extract the old way to instantiate pflash devices to hold the firmware
via -drive to a separate function so that it can later be conditionally
disabled when -blockdev will be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodomcaps: Remove function initializing domain caps as unsupported
Peter Krempa [Thu, 21 Nov 2019 08:52:24 +0000 (09:52 +0100)]
domcaps: Remove function initializing domain caps as unsupported

Commit 5751a0b6b1968bb2354b2ac21cc5938b93009590 added a helper function
called virDomainCapsFeaturesInitUnsupported which initialized all domain
capability features as unsupported.

When adding a new feature this would initialize it as unsupported also
for hypervisor drivers which the original author possibly didn't intend
to modify. To prevent accidental wrong value being reported in such case
revert back to initializing individual features in the hypervisor
drivers themselves.

This is not a straight revert as additonal patches modified how we store
the capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibvirt-<module>: Check caller-provided buffers to be NULL with size > 0
Erik Skultety [Mon, 18 Nov 2019 11:04:16 +0000 (12:04 +0100)]
libvirt-<module>: Check caller-provided buffers to be NULL with size > 0

Pre-Glib era which used malloc allowed the size of the client-side
buffers to be declared as 0, because malloc documents that it can either
return 0 or a unique pointer on 0 size allocations.
With glib this doesn't work anymore, because glib documents that for
such allocation requests NULL is always returned which results in an
error in our public API checks server-side.
This patch complements the fix in the RPC layer by explicitly erroring
out on the following combination of args used by our legacy APIs (their
moder equivalents don't suffer from this):

function(caller-allocated-array, size, ...) {
    if (!caller-allocated-array && size > 0)
        return error;
}

treating everything else as a valid input and potentially let that fail
on the server-side rather than client-side.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: gendispatch: Fix a couple of places adding trailing spaces
Erik Skultety [Mon, 18 Nov 2019 09:30:20 +0000 (10:30 +0100)]
rpc: gendispatch: Fix a couple of places adding trailing spaces

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: remove NULL check from virDomainQemuMonitorEventNew
Ján Tomko [Mon, 11 Nov 2019 09:21:03 +0000 (10:21 +0100)]
conf: remove NULL check from virDomainQemuMonitorEventNew

The qemu_domain_monitor_event_msg struct in qemu_protocol.x
defines event as a nonnull_string and qemuMonitorJSONIOProcessEvent
also errors out on a non-NULL event.

Drop the check to fix the build with static analysis.

This essentially reverts commit d343e8203d248635f5e7a0d86dd077f74d49e3af

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirt-aa-helper: testcase for shmem devices
Christian Ehrhardt [Tue, 22 Oct 2019 10:13:41 +0000 (12:13 +0200)]
virt-aa-helper: testcase for shmem devices

Adding build time self tests for basic (deprecated), doorbell and plain mode.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agovirt-aa-helper: add rules for shmem devices
Christian Ehrhardt [Thu, 17 Oct 2019 10:48:10 +0000 (12:48 +0200)]
virt-aa-helper: add rules for shmem devices

Shared memory devices need qemu to be able to access certain paths
either for the shared memory directly (mostly ivshmem-plain) or for a
socket (mostly ivshmem-doorbell).

Add logic to virt-aa-helper to render those apparmor rules based
on the domain configuration.

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

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: let AppArmorSetSecurityImageLabel append rules
Christian Ehrhardt [Wed, 16 Oct 2019 07:35:27 +0000 (09:35 +0200)]
apparmor: let AppArmorSetSecurityImageLabel append rules

There are currently broken use cases, e.g. snapshotting more than one disk at
once like:
 $ virsh snapshot-create-as --domain eoan --disk-only --atomic
   --diskspec vda,snapshot=no  --diskspec vdb,snapshot=no
   --diskspec vdc,file=/test/disk1.snapshot1.qcow,snapshot=external
   --diskspec vdd,file=/test/disk2.snapshot1.qcow,snapshot=external
The command above will iterate from qemuDomainSnapshotCreateDiskActive and
eventually add /test/disk1.snapshot1.qcow first (appears in the rules)
to then later add /test/disk2.snapshot1.qcow and while doing so throwing
away the former rule causing it to fail.

All other calls to (re)load_profile already use append=true when adding
rules append=false is only used when restoring rules [1].

Fix this by letting AppArmorSetSecurityImageLabel use append=true as well.

Since this is removing a (unintentional) trigger to revoke all rules
appended so far we agreed on review to do some tests, but in the tests
no rules came back on:
- hot-plug
- hot-unplug
- snapshotting

Bugs:
https://bugs.launchpad.net/libvirt/+bug/1845506
https://bugzilla.redhat.com/show_bug.cgi?id=1746684

[1]: https://bugs.launchpad.net/libvirt/+bug/1845506/comments/13

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: refactor AppArmorSetSecurityImageLabel
Christian Ehrhardt [Wed, 16 Oct 2019 07:32:52 +0000 (09:32 +0200)]
apparmor: refactor AppArmorSetSecurityImageLabel

A lot of the code in AppArmorSetSecurityImageLabel is a duplicate of
what is in reload_profile, this refactors AppArmorSetSecurityImageLabel
to use reload_profile instead.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoapparmor: drop useless call to get_profile_name
Christian Ehrhardt [Wed, 16 Oct 2019 07:15:14 +0000 (09:15 +0200)]
apparmor: drop useless call to get_profile_name

reload_profile calls get_profile_name for no particular gain, lets
remove that call. The string isn't used in that function later on
and not registered/passed anywhere.

It can only fail if it either can't allocate or if the
virDomainDefPtr would have no uuid set (which isn't allowed).

Thereby the only "check" it really provides is if it can allocate the
string to then free it again.

This was initially added in [1] when the code was still in
AppArmorRestoreSecurityImageLabel (later moved) and even back then had
no further effect than described above.

[1]: https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/security/security_apparmor.c;h=16de0f26f41689e0c50481120d9f8a59ba1f4073;hb=bbaecd6a8f15345bc822ab4b79eb0955986bb2fd#l487

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agovirt-aa-helper: clarify command line options
Christian Ehrhardt [Wed, 16 Oct 2019 06:47:36 +0000 (08:47 +0200)]
virt-aa-helper: clarify command line options

While only used internally from libvirt the options still are misleading
enough to cause issues every now and then.
Group modes, options and an adding extra file and extend the wording of
the latter which had the biggest lack of clarity.
Both add a file to the end of the rules, but one re-generates the
rules from XML and the other keeps the existing rules as-is not
considering the XML content.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoqemu: Store default CPU in domain XML
Jiri Denemark [Thu, 26 Sep 2019 16:42:02 +0000 (18:42 +0200)]
qemu: Store default CPU in domain XML

When starting a domain without a CPU model specified in the domain XML,
QEMU will choose a default one. Which is fine unless the domain gets
migrated to another host because libvirt doesn't perform any CPU ABI
checks and the virtual CPU provided by QEMU on the destination host can
differ from the one on the source host.

With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
a particular machine type and store it in the domain XML. This way the
chosen CPU model is more visible to users and libvirt will make sure
the guest will see the exact same CPU after migration.

Architecture specific notes
- aarch64: We only set the default CPU for TCG domains as KVM requires
  explicit "-cpu host" to work.

- ppc64: The default CPU for KVM is "host" thanks to some hacks in QEMU,
  we will translate the default model to the model corresponding to the
  host CPU ("POWER8" on a Power8 host, "POWER9" on Power9 host, etc.).
  This is not a problem as the corresponding CPU model is in fact an
  alias for "host". This is probably not ideal, but it's not wrong and
  the default virtual CPU configured by libvirt is the same QEMU would
  use. TCG uses various CPU models depending on machine type and its
  version.

- s390x: The default CPU for KVM is "host" while TCG defaults to "qemu".

- x86_64: The default CPU model (qemu64) is not runnable on any host
  with KVM, but QEMU just disables unavailable features and starts
  happily.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2*test: Add test cases for default CPU models on x86_64
Jiri Denemark [Fri, 11 Oct 2019 18:15:03 +0000 (20:15 +0200)]
qemuxml2*test: Add test cases for default CPU models on x86_64

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2*test: Add test cases for default CPU models on s390x
Jiri Denemark [Fri, 11 Oct 2019 18:15:03 +0000 (20:15 +0200)]
qemuxml2*test: Add test cases for default CPU models on s390x

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2*test: Add test cases for default CPU models on ppc64
Jiri Denemark [Fri, 11 Oct 2019 18:15:03 +0000 (20:15 +0200)]
qemuxml2*test: Add test cases for default CPU models on ppc64

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2*test: Add test cases for default CPU models on aarch64
Jiri Denemark [Fri, 11 Oct 2019 18:15:03 +0000 (20:15 +0200)]
qemuxml2*test: Add test cases for default CPU models on aarch64

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuxml2argvtest: Update host arch for DO_TEST*ARCH* tests
Jiri Denemark [Thu, 24 Oct 2019 15:51:42 +0000 (17:51 +0200)]
qemuxml2argvtest: Update host arch for DO_TEST*ARCH* tests

To avoid mismatch between host and QEMU capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Define g_autoptr cleanup function for virCPUDef
Jiri Denemark [Thu, 26 Sep 2019 16:41:42 +0000 (18:41 +0200)]
conf: Define g_autoptr cleanup function for virCPUDef

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use g_autoptr in qemuDomainDefPostParse
Jiri Denemark [Thu, 26 Sep 2019 15:47:53 +0000 (17:47 +0200)]
qemu: Use g_autoptr in qemuDomainDefPostParse

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsGetMachineDefaultCPU
Jiri Denemark [Thu, 26 Sep 2019 13:22:38 +0000 (15:22 +0200)]
qemu: Introduce virQEMUCapsGetMachineDefaultCPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Probe for default CPU types
Jiri Denemark [Thu, 18 Jul 2019 17:21:55 +0000 (19:21 +0200)]
qemu: Probe for default CPU types

QEMU 4.2.0 will report default CPU types used by each machine type and
we will want to start using it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Probe machine types for both KVM and TCG
Jiri Denemark [Thu, 24 Oct 2019 12:21:46 +0000 (14:21 +0200)]
qemu: Probe machine types for both KVM and TCG

Almost all TCG query-machines replies match KVM. The only exceptions are
4.2.0 replies on s390x which differ in the reported default CPU type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make probed machine types depend on accelerator
Jiri Denemark [Thu, 24 Oct 2019 12:19:38 +0000 (14:19 +0200)]
qemu: Make probed machine types depend on accelerator

Some specifics of machine types may depend on the accelerator and thus
the data should be moved to virQEMUCapsAccel. The TCG machine types are
just copied from the ones probed for KVM to simplify the changes to
qemucapabilitiestest data files.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsCopyMachineTypes
Jiri Denemark [Thu, 24 Oct 2019 09:35:10 +0000 (11:35 +0200)]
qemu: Introduce virQEMUCapsCopyMachineTypes

The function copies machine type data from one QEMU caps structure to
another.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use typedef for virQEMUCapsMachineType
Jiri Denemark [Wed, 30 Oct 2019 00:04:06 +0000 (01:04 +0100)]
qemu: Use typedef for virQEMUCapsMachineType

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move machine type data in capabilities cache
Jiri Denemark [Thu, 24 Oct 2019 07:04:58 +0000 (09:04 +0200)]
qemu: Move machine type data in capabilities cache

In preparation for making machine types dependent on the accelerator,
the <machine> elements are formatted between <cpu type='kvm'> and
<cpu type='tcg'>.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Pass virDomainVirtType to APIs dealing with machine types
Jiri Denemark [Thu, 24 Oct 2019 06:52:21 +0000 (08:52 +0200)]
qemu: Pass virDomainVirtType to APIs dealing with machine types

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split out virQEMUCapsFormatCache
Jiri Denemark [Wed, 23 Oct 2019 16:29:39 +0000 (18:29 +0200)]
qemu: Split out virQEMUCapsFormatCache

All the code for formatting machine type data was moved to a standalone
virQEMUCapsFormatMachines function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split out virQEMUCapsLoadCache
Jiri Denemark [Wed, 23 Oct 2019 16:05:45 +0000 (18:05 +0200)]
qemu: Split out virQEMUCapsLoadCache

All the code for loading machine type data was moved to a standalone
virQEMUCapsLoadMachines function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make virQEMUCapsIsMachineSupported static
Jiri Denemark [Wed, 23 Oct 2019 15:51:50 +0000 (17:51 +0200)]
qemu: Make virQEMUCapsIsMachineSupported static

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Make virQEMUCapsGetMachineTypesCaps static
Jiri Denemark [Wed, 23 Oct 2019 15:08:57 +0000 (17:08 +0200)]
qemu: Make virQEMUCapsGetMachineTypesCaps static

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor probing of accelerator dependent data
Jiri Denemark [Wed, 23 Oct 2019 14:48:17 +0000 (16:48 +0200)]
qemu: Refactor probing of accelerator dependent data

To avoid duplicating code which selects the right virQEMUCapsAccel data
to be filled during probing.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsProbeCPUDefinitionsTest
Jiri Denemark [Wed, 23 Oct 2019 12:08:16 +0000 (14:08 +0200)]
qemu: Introduce virQEMUCapsProbeCPUDefinitionsTest

It is a tiny wrapper around virQEMUCapsProbeQMPCPUDefinitions which will
soon get private parameters and thus it cannot be exposed outside
qemu_capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor virQEMUCapsFormatAccel
Jiri Denemark [Wed, 23 Oct 2019 11:00:31 +0000 (13:00 +0200)]
qemu: Refactor virQEMUCapsFormatAccel

And make it use virQEMUCapsGetAccel once rather than repeating the same
code in all functions called from virQEMUCapsFormatAccel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Refactor virQEMUCapsLoadAccel
Jiri Denemark [Wed, 23 Oct 2019 10:59:43 +0000 (12:59 +0200)]
qemu: Refactor virQEMUCapsLoadAccel

And make it use virQEMUCapsGetAccel once rather than repeating the same
code in all functions called from virQEMUCapsLoadAccel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Drop virQEMUCapsGetHostCPUData
Jiri Denemark [Wed, 23 Oct 2019 10:57:20 +0000 (12:57 +0200)]
qemu: Drop virQEMUCapsGetHostCPUData

It was very similar to virQEMUCapsGetAccel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce and use virQEMUCapsGetAccel
Jiri Denemark [Wed, 23 Oct 2019 10:46:28 +0000 (12:46 +0200)]
qemu: Introduce and use virQEMUCapsGetAccel

The function can be used to get the pointer to all data which depend on
the accelerator.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsAccelClear
Jiri Denemark [Wed, 23 Oct 2019 10:42:54 +0000 (12:42 +0200)]
qemu: Introduce virQEMUCapsAccelClear

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsAccelCopy
Jiri Denemark [Wed, 23 Oct 2019 10:41:31 +0000 (12:41 +0200)]
qemu: Introduce virQEMUCapsAccelCopy

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsAccel structure
Jiri Denemark [Wed, 23 Oct 2019 10:29:52 +0000 (12:29 +0200)]
qemu: Introduce virQEMUCapsAccel structure

This is container for capabilities data that depend on the accelerator.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add virQEMUCaps{Load,Format}Accel
Jiri Denemark [Wed, 23 Oct 2019 08:24:46 +0000 (10:24 +0200)]
qemu: Add virQEMUCaps{Load,Format}Accel

The new functions are designed to load and format capabilities which
depend on the accelerator (host CPU expansion and CPU models).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Drop unused virQEMUCapsGetDefaultMachine
Jiri Denemark [Thu, 26 Sep 2019 13:26:45 +0000 (15:26 +0200)]
qemu: Drop unused virQEMUCapsGetDefaultMachine

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Store typename from query-cpu-definitions in qemuCaps
Jiri Denemark [Thu, 19 Sep 2019 18:47:37 +0000 (20:47 +0200)]
qemu: Store typename from query-cpu-definitions in qemuCaps

We need to create a mapping between CPU model names and their
corresponding QOM types.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Drop virDomainCapsCPUModelsAddSteal
Jiri Denemark [Fri, 20 Sep 2019 21:08:55 +0000 (23:08 +0200)]
conf: Drop virDomainCapsCPUModelsAddSteal

Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so
simple we can just squash the code in a single function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Drop unused virDomainCapsCPUModelsFilter
Jiri Denemark [Fri, 20 Sep 2019 21:00:14 +0000 (23:00 +0200)]
conf: Drop unused virDomainCapsCPUModelsFilter

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Switch qemuCaps to use qemuMonitorCPUDefs
Jiri Denemark [Tue, 24 Sep 2019 14:38:05 +0000 (16:38 +0200)]
qemu: Switch qemuCaps to use qemuMonitorCPUDefs

We will need to keep some QEMU-specific data for each CPU model
supported by a QEMU binary. Instead of complicating the generic
virDomainCapsCPUModelsPtr, we can just directly store
qemuMonitorCPUDefsPtr returned by the capabilities probing code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Split virQEMUCapsFetchCPUModels
Jiri Denemark [Wed, 9 Oct 2019 08:16:17 +0000 (10:16 +0200)]
qemu: Split virQEMUCapsFetchCPUModels

Most of the code moved to a new virQEMUCapsFetchCPUDefinitions function
and the existing virQEMUCapsFetchCPUModels just becomes a small wrapper
around virQEMUCapsFetchCPUDefinitions and virQEMUCapsCPUDefsToModels.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Rename virQEMUCaps{Get,Fetch}CPUDefinitions
Jiri Denemark [Wed, 9 Oct 2019 08:14:59 +0000 (10:14 +0200)]
qemu: Rename virQEMUCaps{Get,Fetch}CPUDefinitions

The functions return virDomainCapsCPUModelsPtr and thus they should be
called *CPUModels for consistency. Functions called *CPUDefinitions will
work on qemuMonitorCPUDefsPtr.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce virQEMUCapsCPUDefsToModels
Jiri Denemark [Tue, 24 Sep 2019 13:59:34 +0000 (15:59 +0200)]
qemu: Introduce virQEMUCapsCPUDefsToModels

The function translates qemuMonitorCPUDefsPtr (used by QEMU caps probing
code) into virDomainCapsCPUModelsPtr used by domain capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo
Jiri Denemark [Tue, 29 Oct 2019 13:36:11 +0000 (14:36 +0100)]
qemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo

While virDomainCapsCPUModel structure contains 'usable' field with
virDomainCapsCPUUsable type, the lower level structure specific to QEMU
driver used virTriStateBool for the same thing and we had to translate
between them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use g_autofree in virQEMUCapsLoadCPUModels
Jiri Denemark [Tue, 24 Sep 2019 12:55:26 +0000 (14:55 +0200)]
qemu: Use g_autofree in virQEMUCapsLoadCPUModels

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add qemuMonitorCPUDefsCopy
Jiri Denemark [Tue, 24 Sep 2019 15:12:34 +0000 (17:12 +0200)]
qemu: Add qemuMonitorCPUDefsCopy

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Flatten qemuMonitorCPUDefs.cpus
Jiri Denemark [Tue, 24 Sep 2019 11:45:37 +0000 (13:45 +0200)]
qemu: Flatten qemuMonitorCPUDefs.cpus

Let's store qemuMonitorCPUDefInfo directly in the array of CPUs in
qemuMonitorCPUDefs rather then using an array of pointers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Introduce qemuMonitorCPUDefs struct
Jiri Denemark [Tue, 24 Sep 2019 11:42:00 +0000 (13:42 +0200)]
qemu: Introduce qemuMonitorCPUDefs struct

It is a container for a CPU models list (qemuMonitorCPUDefInfo) and a
number of elements in this list.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Change return type of virQEMUCapsFetchCPUDefinitions
Jiri Denemark [Thu, 10 Oct 2019 14:44:40 +0000 (16:44 +0200)]
qemu: Change return type of virQEMUCapsFetchCPUDefinitions

The function would return a valid virDomainCapsCPUModelsPtr with empty
CPU models list if query-cpu-definitions exists in QEMU, but returns
GenericError meaning it's not in fact implemented. This behaviour is a
bit strange especially after such virDomainCapsCPUModels structure is
stored in capabilities XML and parsed back, which will result in NULL
virDomainCapsCPUModelsPtr rather than a structure containing nothing.

Let's just keep virDomainCapsCPUModelsPtr NULL if the QMP command is not
implemented and change the return value to int so that callers can
easily check for failure or success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use g_autoptr in qemuMonitorJSONGetCPUDefinitions
Jiri Denemark [Tue, 24 Sep 2019 11:20:49 +0000 (13:20 +0200)]
qemu: Use g_autoptr in qemuMonitorJSONGetCPUDefinitions

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use virQEMUCapsGetCPUDefinitions more
Jiri Denemark [Fri, 20 Sep 2019 20:54:13 +0000 (22:54 +0200)]
qemu: Use virQEMUCapsGetCPUDefinitions more

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Filter models in virQEMUCapsGetCPUDefinitions
Jiri Denemark [Fri, 20 Sep 2019 20:48:13 +0000 (22:48 +0200)]
qemu: Filter models in virQEMUCapsGetCPUDefinitions

Some callers of virQEMUCapsGetCPUDefinitions will need to filter the
returned list of CPU models. Let's add the filtering parameters directly
to virQEMUCapsGetCPUDefinitions to avoid copying the CPU models list
twice.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Copy CPU models in virQEMUCapsGetCPUDefinitions
Jiri Denemark [Fri, 20 Sep 2019 20:41:34 +0000 (22:41 +0200)]
qemu: Copy CPU models in virQEMUCapsGetCPUDefinitions

Rather than returning a direct pointer the list stored in qemuCaps the
function now creates a new copy of the CPU models list.

The main purpose of this seemingly useless change is to update callers
to free the result returned by virQEMUCapsGetCPUDefinitions because the
internals of this function will change significantly in the following
patches.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Update 4.2.0 capabilities data on ppc64
Jiri Denemark [Thu, 31 Oct 2019 14:47:09 +0000 (15:47 +0100)]
tests: Update 4.2.0 capabilities data on ppc64

Generated with "spapr/kvm: Set default cpu model for all machine
classes" fix for QEMU applied.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: Add capabilities for QEMU 4.2.0 on s390x
Jiri Denemark [Tue, 15 Oct 2019 11:48:34 +0000 (13:48 +0200)]
tests: Add capabilities for QEMU 4.2.0 on s390x

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: rewrite polkit ACL generator in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite polkit ACL generator in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the genpolkit.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite ACL rule checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite ACL rule checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-aclrules.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite driver impl checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite driver impl checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-driverimpls.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite driver name checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite driver name checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-drivername.pl tool in Python.

This was mostly a straight conversion, manually going line-by-line
to change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

In testing though it was discovered the existing code was broken
since it hadn't been updated after driver.h was split into many
files. Since the old code is being thrown away, the fix was done
as part of the rewrite rather than split into a separate commit.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite systemtap function generator in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite systemtap function generator in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the gensystemtap.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite systemtap probe generator in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite systemtap probe generator in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the dtrace2systemtap.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

The "--with-modules" flag was dropped because this functionality
is not implicitly always enabled.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite symfile library checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite symfile library checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-symfile.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite symfile sorting checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite symfile sorting checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-symsorting.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: rewrite ACL permissions checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
src: rewrite ACL permissions checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the check-aclperms.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild-aux: rewrite header ifdef checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
build-aux: rewrite header ifdef checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the header-ifdef.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild-aux: rewrite mock inline checker in Python
Daniel P. Berrangé [Fri, 30 Aug 2019 12:22:54 +0000 (13:22 +0100)]
build-aux: rewrite mock inline checker in Python

As part of a goal to eliminate Perl from libvirt build tools,
rewrite the mock-noinline.pl tool in Python.

This was a straight conversion, manually going line-by-line to
change the syntax from Perl to Python. Thus the overall structure
of the file and approach is the same.

Tested-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: checkpoint: Use qemuMonitorTransactionBitmapMergeSourceAddBitmap
Peter Krempa [Mon, 7 Oct 2019 14:33:49 +0000 (16:33 +0200)]
qemu: checkpoint: Use qemuMonitorTransactionBitmapMergeSourceAddBitmap

Use the new helper in qemuCheckpointDiscard rather than constructing the
array manually.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Forcibly mknod() even if it exists
Michal Privoznik [Fri, 8 Nov 2019 08:41:35 +0000 (09:41 +0100)]
qemu: Forcibly mknod() even if it exists

Another weird bug appeared concerning qemu namespaces. Basically
the problem is as follows:

1) Issue an API that causes libvirt to create a node in domain's
   namespace, say /dev/nvme0n1 with 8:0 as major:minor (the API can
   be attach-disk for instance). Or simply create the node from a
   console by hand.

2) Detach the disk from qemu.

3) Do something that makes /dev/nvme0n1 change it's minor number.

4) Try to attach the disk again.

The problem is, in a few cases - like disk-detach - we don't
remove the corresponding /dev node from the mount namespace
(because it may be used by some other disk's backing chain). But
this creates a problem, because if the node changes its MAJ:MIN
numbers we don't propagate the change into the domain's
namespace. We do plain mknod() and ignore EEXIST which obviously
is not enough because it doesn't guarantee that the node has
updated MAJ:MIN pair.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agognulib: remove mk*temp modules
Ján Tomko [Wed, 20 Nov 2019 12:07:18 +0000 (13:07 +0100)]
gnulib: remove mk*temp modules

After commits 4ac47730408eaf91683f6502ec10541f4f711a5c and
ef88698668e4a87c794d70879eeffefb52aa0017, we use the GLib versions
of these functions.

Remove the corresponding gnulib modules.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agobootstrap.conf: drop c-strcasestr gnulib module
Pavel Hrdina [Tue, 19 Nov 2019 14:22:58 +0000 (15:22 +0100)]
bootstrap.conf: drop c-strcasestr gnulib module

Last usage was removed by commit
<41f88886198e231285cc813f8c0687c8ec5c9488> and commit
<0f4d31720430b4e3735064cc0d8f88a1a438e154> forgot to drop include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agognulib: Remove use of 'strsep' module
Peter Krempa [Thu, 14 Nov 2019 09:31:53 +0000 (10:31 +0100)]
gnulib: Remove use of 'strsep' module

We don't use strsep any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agobootstrap: remove regex module
Ján Tomko [Wed, 13 Nov 2019 15:57:53 +0000 (16:57 +0100)]
bootstrap: remove regex module

Now that we use GRegex everywhere, there is no need for this module.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agosyntax-check: forbid usage of snprintf
Pavel Hrdina [Wed, 13 Nov 2019 16:33:27 +0000 (17:33 +0100)]
syntax-check: forbid usage of snprintf

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosyntax-check: update of sprintf rule to mention g_snprintf
Pavel Hrdina [Wed, 13 Nov 2019 16:33:26 +0000 (17:33 +0100)]
syntax-check: update of sprintf rule to mention g_snprintf

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobootstrap.conf: remove usage of snprintf gnulib module
Pavel Hrdina [Wed, 13 Nov 2019 16:33:25 +0000 (17:33 +0100)]
bootstrap.conf: remove usage of snprintf gnulib module

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agognulib: remove use of 'vsnprintf' module
Ján Tomko [Wed, 13 Nov 2019 13:18:18 +0000 (14:18 +0100)]
gnulib: remove use of 'vsnprintf' module

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agognulib: remove use of 'byteswap' module
Ján Tomko [Wed, 13 Nov 2019 13:17:31 +0000 (14:17 +0100)]
gnulib: remove use of 'byteswap' module

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agognulib: remove 'areadlink' module
Peter Krempa [Wed, 13 Nov 2019 13:16:42 +0000 (14:16 +0100)]
gnulib: remove 'areadlink' module

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Remove non-transaction based dirty bitmap APIs
Peter Krempa [Thu, 26 Sep 2019 15:00:44 +0000 (17:00 +0200)]
qemu: monitor: Remove non-transaction based dirty bitmap APIs

We replaced them by use of transaction to simplify possible failure
scenarios.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: checkpoint: Fix rollback and access to unlocked 'vm' when deleting checkpoints
Peter Krempa [Thu, 26 Sep 2019 14:56:16 +0000 (16:56 +0200)]
qemu: checkpoint: Fix rollback and access to unlocked 'vm' when deleting checkpoints

Delete/merge bitmaps when deleting checkpoints using a 'transaction' so
that we don't have to deal with halfway-failed scenarios and also fix
access to 'vm' while in the monitor lock.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: virschema: Propagate errors from directory traversal in testSchemaDir
Peter Krempa [Tue, 19 Nov 2019 10:55:05 +0000 (11:55 +0100)]
tests: virschema: Propagate errors from directory traversal in testSchemaDir

testSchemaDir is a helper which invokes the schema test using virTestRun
on all schema files. Since the function itself is not called inside
virTestRun any helper function call is not dispatched to the user and
thus it's hard to debug the test. Propagate errors from the directory
traversal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: utils: Introduce helper for dispatching libvirt errors
Peter Krempa [Tue, 19 Nov 2019 10:52:40 +0000 (11:52 +0100)]
tests: utils: Introduce helper for dispatching libvirt errors

In cases when we call a libvirt helper which reports an error the error
would be hidden unless libvirt library debug is on. This produces a lot
of output and is hard to debug.

The helper provides a way to dispatch the libvirt error in specific
cases sice we do already dispatch it in case when virTestRun is used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: schema: Simplify memory handling using g_autofree
Peter Krempa [Tue, 19 Nov 2019 10:16:34 +0000 (11:16 +0100)]
tests: schema: Simplify memory handling using g_autofree

Refactor various functions to avoid multiple freeing function calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>