Commit Graph

37105 Commits

Author SHA1 Message Date
Michal Privoznik
1d3a9ee9da qemu: Make memory path generation embed driver aware
So far, libvirt generates the following path for memory:

  $memoryBackingDir/$id-$shortName/ram-nodeN

where $memoryBackingDir is the path where QEMU mmaps() memory for
the guest (e.g. /var/lib/libvirt/qemu/ram), $id is domain ID
and $shortName is shortened version of domain name. So for
instance, the generated path may look something like this:

  /var/lib/libvirt/qemu/ram/1-QEMUGuest/ram-node0

While in case of embed driver the following path would be
generated by default:

  $root/lib/qemu/ram/1-QEMUGuest/ram-node0

which is not clashing with other embed drivers, we allow users to
override the default and have all embed drivers use the same
prefix. This can create clashing paths. Fortunately, we can reuse
the approach for machined name generation
(v6.1.0-178-gc9bd08ee35) and include part of hash of the root in
the generated path.

Note, the important change is in qemuGetMemoryBackingBasePath().
The rest is needed to pass driver around.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:32 +02:00
Michal Privoznik
bf54784cb1 qemu: Make hugepages path generation embed driver aware
So far, libvirt generates the following path for hugepages:

  $mnt/libvirt/qemu/$id-$shortName

where $mnt is the mount point of hugetlbfs corresponding to
hugepages of desired size (e.g. /dev/hugepages), $id is domain ID
and $shortName is shortened version of domain name. So for
instance, the generated path may look something like this:

  /dev/hugepages/libvirt/qemu/1-QEMUGuest

But this won't work with embed driver really, because if there
are two instances of embed driver, and they both want to start a
domain with the same name and with hugepages, both drivers will
generate the same path which is not desired. Fortunately, we can
reuse the approach for machined name generation
(v6.1.0-178-gc9bd08ee35) and include part of hash of the root in
the generated path.

Note, the important change is in qemuGetBaseHugepagePath(). The
rest is needed to pass driver around.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:26 +02:00
Michal Privoznik
6297560761 Revert "qemu_conf: Track embed root dir"
This reverts commit 06a19921b6.

What I haven't realized when writing this ^^ commit is that the
virQEMUDriver structure already stores the root directory path.
And since the pointer is immutable it can be accessed right from
the structure and thus there is no need to duplicate it in the
driver config.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:25 +02:00
Michal Privoznik
be0e311572 qemuDomainGetMachineName: Access embeddedRoot from driver rather than cfg
The cfg->root is going away, therefore get the info right from
the driver structure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:23 +02:00
Michal Privoznik
5bc3299447 virDomainDriverGenerateMachineName: Factor out embed path hashing
The code that generates "qemu-embed-$hash" is going to be useful
in more places. Separate it out into a function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:22 +02:00
Michal Privoznik
8b9488d929 conf: Move virDomainGenerateMachineName to hypervisor/
The virDomainGenerateMachineName() function doesn't belong in
src/conf/ really, because it has nothing to do with domain XML
parsing. It landed there because of lack of better place in the
past. But now that we have src/hypervisor/ the function should
live there. At the same time, the function name is changed to
match new location.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:19 +02:00
Michal Privoznik
34a59fb570 qemu: Drop two layers of nesting of memoryBackingDir
Initially introduced in v3.10.0-rc1~172.

When generating a path for memory-backend-file or -mem-path, qemu
driver will use the following pattern:

  $memoryBackingDir/libvirt/qemu/$id-$shortName

where $memoryBackingDir defaults to /var/lib/libvirt/qemu/ram but
can be overridden in qemu.conf. Anyway, the "/libvirt/qemu/" part
looks redundant, because it's already contained in the default,
or creates unnecessary nesting if overridden in qemu.conf.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-04-07 15:26:17 +02:00
Michal Privoznik
0e4ec86978 qemu: Drop virQEMUDriverIsPrivileged()
Introduced in v1.2.17-rc1~121, the assumption was that the
driver->privileged is immutable at the time but it might change
in the future. Well, it did not ever since. It is still immutable
variable. Drop the needless accessor then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-04-07 15:26:15 +02:00
Michal Privoznik
f00f4ea7b1 tests: Fix virQEMUDriverConfigNew() calling with respect to @root
The virQEMUDriverConfigNew() accepts path to root directory for
embed mode as an argument. If the argument is not NULL it uses
the passed value as prefix for some internal paths (e.g.
cfg->libDir). If it is NULL though, it looks if the other
argument, @privileged is true or false and generates internal
paths accordingly. But when calling the function from the test
suite, instead of passing NULL for @root, an empty string is
passed. Fortunately, this doesn't create a problem because in
both problematic cases the generated paths are "fixed" to point
somewhere into build dir or the code which is tested doesn't
access them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-07 15:26:10 +02:00
Seeteena Thoufeek
f3d1582e3c cpu: Use g_autoptr and g_autofree in cpu.c
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-07 12:58:07 +02:00
Jim Fehlig
88011ed280 libxl: fix crash when initializing driver
Commit 54a401af47 split out DriverConfigInit from DriverConfigNew, but
then called it a bit late from libxlStateInitialize. The cfg is used in
libxlDriverConfigLoadFile and when uninitialized results in a crash.
Calling DriverConfigInit immediately after DriverConfigNew fixes the
crash.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-06 08:23:01 -06:00
Daniel Henrique Barboza
0895a0e75d formatdomain.html.in: fix 'sockets' info in topology element
In the 'topology' element it is mentioned, regarding the sockets
value, "They refer to the total number of CPU sockets".

This is not accurate. What we're doing is calculating the number
of sockets per NUMA node, which can be checked in the current
implementation of virHostCPUGetInfoPopulateLinux(). Calculating
the total number of sockets would break the topology sanity
check nodes*sockets*cores*threads=online_cpus.

This documentation fix is important to avoid user confusion when
seeing the output of 'virsh capabilities' and expecting it to be
equal to the output of 'lscpu'. E.g in a Power 9 host this 'lscpu'
output:

Architecture:        ppc64le
Byte Order:          Little Endian
CPU(s):              160
On-line CPU(s) list: 0-159
Thread(s) per core:  4
Core(s) per socket:  20
Socket(s):           2
NUMA node(s):        2
Model:               2.2 (pvr 004e 1202)
Model name:          POWER9, altivec supported

And this XML output from virsh capabilities:

    <cpu>
      <arch>ppc64le</arch>
      <model>POWER9</model>
      <vendor>IBM</vendor>
      <topology sockets='1' dies='1' cores='20' threads='4'/>
      (...)
    </cpu>

Both are correct, as long as we mention in the Libvirt documentation
that 'sockets' in the topology element represents the number of sockets
per NUMA node.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-06 15:56:14 +02:00
Prathamesh Chavan
08071ec0f1 tools: variables clean-up in libvirt-guests script
Redeclared variables in script functions marked as local.
Variables `guest_running` and `guests_shutting_down` in the
functions 'guest_is_on` and `check_guests_shutdown` were
untouched, as the functions returned values in these
variables.

Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-06 15:00:00 +02:00
Seeteena Thoufeek
333fd2bdb0 qemu_cgroup.c: use VIR_AUTOSTRINGLIST, g_autofree and g_autoptr
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-04-06 14:06:14 +02:00
Christian Schoenebeck
89bbe9bb1e qemu: add support for 'multidevs' option
This option prevents misbehaviours on guest if a qemu 9pfs export
contains multiple devices, due to the potential file ID collisions
this otherwise may cause.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-06 13:55:27 +02:00
Christian Schoenebeck
c3a1856890 conf: add 'multidevs' option
Introduce new 'multidevs' option for filesystem.

  <filesystem type='mount' accessmode='mapped' multidevs='remap'>
    <source dir='/path'/>
    <target dir='mount_tag'>
  </filesystem>

This option prevents misbehaviours on guest if a qemu 9pfs export
contains multiple devices, due to the potential file ID collisions
this otherwise may cause.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-06 13:55:27 +02:00
Christian Schoenebeck
8fe6e82d1c qemu: capabilities: add QEMU_CAPS_FSDEV_MULTIDEVS
The QEMU 9pfs 'multidevs' option exists since QEMU 4.2. Probe QEMU's
command line set though to check whether this option is really
available, and if yes enable this new QEMU_CAPS_FSDEV_MULTIDEVS
capability on libvirt side.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-06 13:55:12 +02:00
Daniel Henrique Barboza
bc210e7ab2 qemu: move qemuValidateDomainDeviceDef() to qemu_validate.c
Now that all its helper functions are in qemu_validate.c, we can
move the function itself. The helpers can become static again since
they're all in the same file.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
a5f488d3d4 qemu: move remaining qemuDomainDeviceDefValidate() helpers
This will allow to move qemuDomainDeviceDefValidate() itself in
the next patch in a cleaner way.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
78f605e0b3 qemu: move qemuDomainDeviceDefValidateSound() to qemu_validate.c
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
48e2aadce0 qemu: move qemuDomainDeviceDefValidateFS() to qemu_validate.c
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
3b4e054c3d qemu: move qemuDomainDeviceDefValidateGraphics() to qemu_validate.c
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
4d3d025ecb qemu: move qemuDomainDeviceDefValidateController() to qemu_validate.c
Move the function and all its static helper functions.

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>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
b8f1f037ed qemu: move qemuDomainDeviceDefValidateDisk() to qemu_validate.c
This function will remain public due to its usage in qemublocktest.c
even after moving qemuDomainDeviceDefValidate(). The position of its
header in qemu_validate.h is no accident.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
5d80af2cf3 qemu: move qemuDomainDeviceDefValidateVideo() to qemu_validate.c
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
94410ded3d qemu: move qemuDomainDeviceDefValidateHostdev() to qemu_validate.c
This function alone requires other 3 static functions to be
moved as well, thus let's move it in its own patch.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
f38cfe7225 qemu: move qemuDomainChrDefValidate() to qemu_validate.c
qemuDomainChrDefValidate() has a lot of static helpers functions
that needed to be moved as well.

Other functions from qemuDomainDeviceDefValidate() that were
also moved:
- qemuValidateDomainSmartcardDef
- qemuValidateDomainRNGDef
- qemuValidateDomainRedirdevDef
- qemuValidateDomainWatchdogDef

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
a03738cee4 qemu: move qemuDomainDeviceDefValidateNetwork() to qemu_validate.c
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>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
2a8168c99b qemu: move qemuDomainDeviceDefValidateAddress() to qemu_validate.c
The next big task is to move qemuDomainDeviceDefValidate() to
qemu_validation.c, which is a function that calls a lot of
other static helper functions. This patch starts it by moving
qemuDomainDeviceDefValidateAddress().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
07cfccc53a qemu: move qemuDomainValidateDef() to qemu_validate.c
Move the static functions qemuDomainValidateDef() uses, as well as
qemuDomainValidateDef() itself to qemu_validate.

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>
2020-04-03 16:25:30 +02:00
Daniel Henrique Barboza
906fddf733 qemu: move qemuDomainDefValidateFeatures to qemu_validate.c
This patch introduces a new file to host domain validations from
the QEMU driver. And to get things started, let's move
qemuDomainDefValidateFeatures() to this new file.

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>
2020-04-03 16:25:30 +02:00
Han Han
cf2f92f373 schemas: rng: Add encryption and slices elements to domainsnapshot schema
Both <encryption> and <diskSourceCommon> were absent from the <source>
element defined in domainsnapshot.rng

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-04-03 15:53:43 +02:00
Seeteena Thoufeek
a1a6763663 qemu_checkpoint.c: Use g_autofree in qemuCheckpointPrepare()
This is the only instance of g_autofree change applicable for
qemu_checkpoint.c

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 14:16:49 +02:00
Andrea Bolognani
68d08cf2f2 remote: Drop KRB5_KTNAME override
When the comment in libvirtd.sasl was last updated with

  commit fe772f24a6
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Sat Oct 20 14:10:03 2012 -0400

    daemon: Avoid 'Could not find keytab file' in syslog

it was noted that only old versions of kerberos would need the
environment variable to be set: that was more than seven years
ago, so it's safe to assume that none of our current target
platforms still requires that hack and setting the appropriate
key in the configuration file will be enough.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-03 11:51:00 +02:00
Andrea Bolognani
deb73277ca qemu: Allow audio driver override in virtqemud
libvirtd supports this feature, and virtqemud ultimately calls to
the same code so it does as well: advertise it in the sysconf file
for the latter, as is already the case for the former.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-03 11:50:57 +02:00
Andrea Bolognani
ef0fa8395f systemd: Move timeout from service files to sysconf files
This follows the example set by libvirtd, and makes it easier for
the admin to tweak the timeout or disable it altogether.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-03 11:50:50 +02:00
Andrea Bolognani
93c13f0d93 systemd: Add sysconf files for all daemons
While not terribly useful in general, tweaking each daemon's
timeout (or disabling it off altogether) is a valid use case which
we can very easily support while being consistent with what already
happens for libvirtd. This is a first step in that direction.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-03 11:50:47 +02:00
Andrea Bolognani
9884ae3479 systemd: Tweak existing sysconf files
We're going to add many more later, so start by adjusting the
existing ones to more closely follow the example set by libvirtd.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-03 11:50:35 +02:00
Andrea Bolognani
a1c793ec57 daemons: Support --timeout 0
When using systemd we want to take advantage of socket activation
instead of keeping daemons running all the time, so we default to
shutting them down after two minutes of inactivity.

At the same time, we want it to be possible for the admin to opt
out of this behavior and disable timeouts entirely. A very natural
way to do so would be to specify a zero-length timeout, but that's
currently not accepted by the command line parser. Address that.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-03 11:50:27 +02:00
Peter Krempa
9428c4609c virDomainCheckpointRedefinePrep: Set 'current' checkpoint if there isn't any
When redefining checkpoints from scratch we'd not set the 'current'
checkpoint if there wasn't any. This meant that the code wasn't ever
able to set a 'current' checkpoint as any other one looks up if the
parent of the redefined checkpoint is current.

Since the backup code then requires the current checkpoint to start the
lookup we'd not be able to perform a backup after restoring the
checkpoint hierarchy.

Reported-by: Eyal Shenitzky <eshenitz@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-03 09:56:57 +02:00
Peter Krempa
135a0b3f71 qemu: checkpoint: Allow checkpoint redefine for offline VMs
Skip the liveness and capability checks when redefining checkpoints as
we don't need qemu interactions to update the metadata.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-03 09:55:59 +02:00
Peter Krempa
a743583e4f qemu: capabilities: Update qemu-5.0.0 capabilities for x86_64 to rc1
Now that v5.0.0-rc1 was tagged, update the capabilities to make sure
that everything works as expected.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 09:53:49 +02:00
Peter Krempa
b659b5f93a syntax-check: Exempt tests/qemucapabilitiesdata from 'sc_prohibit_devname'
QEMU uses the 'devname' string in the QAPI schema so a bump would
trigger this check. Exempt all of the capabilities data from the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 09:36:20 +02:00
Peter Krempa
958ac278cd qemumonitorjsontest: AddNetdev: Use real variant
QEMU now formalized the arguments of netdev-add in the schema, so we
must use a real type to pass the schema validation once the schema is
updated.

The 'user' variant doesn't have any other mandatory fields.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 09:36:20 +02:00
Peter Krempa
5a13eb1655 qemuMonitorTestProcessCommandDefaultValidate: Output validator output to stderr
Trying to squeeze the validator output into the monitor reply message
doesn't make sense and doesn't work well as it's not well formed JSON:

54) qemuMonitorJSONAddNetdev                                          ... libvirt:  error : internal error: cannot parse json { "error":  { "desc": "failed to validate arguments of 'netdev_add' against QAPI schema: {
   ERROR: variant 'test' for discriminator 'type' not found
",    "class": "UnexpectedCommand" } }: lexical error: invalid character inside string.
          ev_add' against QAPI schema: {    ERROR: variant 'test' for
                     (right here) ------^
FAILED

Output it to stderr if requested and just note that schema validation
failed in the error message:

54) qemuMonitorJSONAddNetdev                                          ...
failed to validate arguments of 'netdev_add' against QAPI schema
args:
{
  "id": "net0",
  "type": "test"
}

validator output:
 {
   ERROR: variant 'test' for discriminator 'type' not found

libvirt: QEMU Driver error : internal error: unable to execute QEMU command 'netdev_add': failed to validate arguments of 'netdev_add' against QAPI schema (to see debug output use VIR_TEST_DEBUG=2)
FAILED

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 09:36:20 +02:00
Peter Krempa
203e802d88 qemumonitorjsontest: Space out test name concatenation
The test name is concatenated from a prefix with the test name, but no
space was added so the output looked wrong.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-03 09:36:20 +02:00
Peter Krempa
6746136a27 qemuBlockJobRefreshJobs: Warn readers that 'job' may be invalid after update
Add a comment noting that job update can cause the pointer to be invalid
and thus should not be accessed after.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-03 09:34:49 +02:00
Peter Krempa
ddce75fac0 qemuBlockJobUpdate: Remove return value
No callers use it any more. Additionally if qemuBlockJobUpdate was
called with the last reference of the job e.g. in
qemuBlockJobRefreshJobs, the reading of the job state would happen from
freed memory.

Reported-by: Pavel Mores <pmores@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-03 09:34:49 +02:00
Peter Krempa
028cc19c65 qemu: migration: Don't use return value of qemuBlockJobUpdate
Upcoming patch will remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-03 09:34:49 +02:00
Peter Krempa
496a44a7eb qemuSecurityChownCallback: Don't initialize storage file subsystem for local file
virStorageFileSupportsSecurityDriver ends up initializing the storage
file backend which after the recent changes to the daemon architecture
may end up dlopening of the backend modules.

Since this is required only for remote storage we can optimize the call
by moving the check whether the backend is supported to the branch which
deals with remote storage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
2020-04-03 09:32:51 +02:00