]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agogitlab: create an explicit stage for cross build jobs
Daniel P. Berrangé [Fri, 6 Mar 2020 15:38:36 +0000 (15:38 +0000)]
gitlab: create an explicit stage for cross build jobs

As we introduce more build jobs, it will be useful to have a grouping of
jobs to more easily visualize the results and potentially control build
ordering.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitlab: restrict git history to 100 commits
Daniel P. Berrangé [Tue, 24 Mar 2020 12:04:08 +0000 (12:04 +0000)]
gitlab: restrict git history to 100 commits

We don't need the full git history when running CI jobs. From a code POV
we only need the most recent commit, but we want to be able to run
checks on the commits too. In particular to validate the DCO signoff for
each commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitlab: add variable for make command name
Daniel P. Berrangé [Tue, 24 Mar 2020 11:01:12 +0000 (11:01 +0000)]
gitlab: add variable for make command name

To facilitate future jobs that will use FreeBSD

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_domain.c: remove unneeded size check in NVDIMM alignment
Daniel Henrique Barboza [Wed, 25 Mar 2020 14:15:14 +0000 (11:15 -0300)]
qemu_domain.c: remove unneeded size check in NVDIMM alignment

Commit 5540acb9a2b added a minimum size verification for the target
size of ppc64 NVDIMMs but forgot to remove a MAX() size check that
was being used in earlier reviews of that commit. The size
verification makes this check unneeded since we're making sure
that guestArea will always be at least equal to ppc64AlignSize.

Fixes: 5540acb9a2bd33fb97a7446a610b602c9e8629a3
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_agent.c: Use g_autofree in qemu_agent.c
Seeteena Thoufeek [Fri, 27 Mar 2020 05:25:55 +0000 (10:55 +0530)]
qemu_agent.c: Use g_autofree in qemu_agent.c

This is the only instance of g_autofree change applicable for
qemu_agent.c

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobhyve: fix typo in struct field accessor
Daniel P. Berrangé [Thu, 26 Mar 2020 17:29:16 +0000 (17:29 +0000)]
bhyve: fix typo in struct field accessor

This fixes a FreeBSD build error from

  commit a11a0e6e8473fec6127b263a33f892135097648f
  Author: Rafael Fonseca <r4f4rfs@gmail.com>
  Date:   Tue Mar 24 17:14:30 2020 +0100

    bhyve: move video default logic to driver

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemuCheckpointCreateXML: Check VM liveness first
Peter Krempa [Thu, 26 Mar 2020 14:20:44 +0000 (15:20 +0100)]
qemuCheckpointCreateXML: Check VM liveness first

Move the liveness check prior to the capability check. If the VM is
offline the capabilities are not initialized and thus we'd report the
wrong error.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuBackupBegin: Fix monitor access when rolling back due to failure
Peter Krempa [Thu, 26 Mar 2020 14:37:44 +0000 (15:37 +0100)]
qemuBackupBegin: Fix monitor access when rolling back due to failure

The code attempting to clean up after a failed pull mode backup job
wrongly entered monitor but didn't clean up nor exit monitor due to a
logic bug. Fix the condition.

Introduced in a1521f84a53

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemuCheckpointDelete: Check VM liveness first
Peter Krempa [Thu, 26 Mar 2020 14:20:44 +0000 (15:20 +0100)]
qemuCheckpointDelete: Check VM liveness first

Move the liveness check prior to the capability check. If the VM is
offline the capabilities are not initialized and thus we'd report the
wrong error.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoschemas: rng: Use interleave in the disk source element
Han Han [Thu, 26 Mar 2020 02:44:23 +0000 (10:44 +0800)]
schemas: rng: Use interleave in the disk source element

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agocpu_map: Don't use new noTSX models for host-model CPUs
Jiri Denemark [Tue, 17 Mar 2020 21:32:16 +0000 (22:32 +0100)]
cpu_map: Don't use new noTSX models for host-model CPUs

Host-model CPU definitions (and domain capabilities) will use the
original CPU models (without noTSX in their name) and explicitly disable
hle and rtm features. This way domains with host-model CPUs will be
migratable even to older versions of libvirt which do not support the
noTSX model variants.

The new models will be advertised in host capabilities and they may
be used explicitly with custom CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agocpu_x86: Honor CPU models' <decode> element
Jiri Denemark [Tue, 17 Mar 2020 21:27:49 +0000 (22:27 +0100)]
cpu_x86: Honor CPU models' <decode> element

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agocpu_map: Add <decode> element to x86 CPU model definitions
Jiri Denemark [Thu, 12 Mar 2020 16:39:37 +0000 (17:39 +0100)]
cpu_map: Add <decode> element to x86 CPU model definitions

The element specifies whether a particular CPU model can be used when
creating a CPU definition from raw CPUID/MSR data. The @host attribute
determines whether the CPU model can be used (host='on') for creating
CPU definition for host capabilities. Usability of the model for domain
capabilities and host-model CPU definitions is controlled by the @guest
attribute.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agocpu_map: Add more -noTSX x86 CPU models
Christian Ehrhardt [Tue, 10 Mar 2020 10:48:06 +0000 (11:48 +0100)]
cpu_map: Add more -noTSX x86 CPU models

One of the mitigation methods for TAA[1] is to disable TSX
support on the host system.  Linux added a mechanism to disable
TSX globally through the kernel command line, and many Linux
distributions now default to tsx=off.  This makes existing CPU
models that have HLE and RTM enabled not usable anymore.

Add new versions of all CPU models that have the HLE and RTM
features enabled, that can be used when TSX is disabled in the
host system.

On systems disabling the features without those types defined
in cpu-maps users end up without modern CPU types in the list
of usable CPUs to use in the likes of virsh domcapabilities
or tools higher in the stack like virt-manager.

This adds:
-Cascadelake-Server-noTSX
-Icelake-Client-noTSX
-Icelake-Server-noTSX
-Skylake-Server-noTSX-IBRS
-Skylake-Client-noTSX-IBRS

Introduced in QEMU by commit v4.2.0-rc2-3-g9ab2237f19 (function)
                  and commit v4.2.0-rc2-4-g02fa60d101 (names)

References:

    [1] TAA, TSX asynchronous Abort:
        https://software.intel.com/security-software-guidance/insights/deep-dive-intel-transactional-synchronization-extensions-intel-tsx-asynchronous-abort
        https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1853200
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Message-Id: <20200310104806.2723-2-christian.ehrhardt@canonical.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: allow PMU feature to be enabled for ppc64 guests
Daniel Henrique Barboza [Tue, 24 Mar 2020 17:33:24 +0000 (14:33 -0300)]
qemu: allow PMU feature to be enabled for ppc64 guests

The PMU feature is enabled by default in ppc64 guests and can't
be disabled via Libvirt or QEMU [1]. The current PMU feature
implementation does not allow PMU to enabled or disabled in the
ppc64 guest. Declaring the PMU feature will make the 'pmu'
property to be passed on to QEMU, but this property isn't
available for ppc64:

qemu-kvm: can't apply global host-powerpc64-cpu.pmu=on: Property '.pmu' not found

A similar error is thrown when trying to disable the PMU.

This patch standardizes the PMU handling for ppc64 guests by:

- throwing an error if the user attempts to set the feature to
'off', given that this feature can't be turned off at all;

- allowing the feature to be declared as 'on' in the domain XML.
This is done by skipping ppc64 guests when creating the command
line for this feature.

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

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: make Hyperv settings exclusive to x86 and aarch64
Daniel Henrique Barboza [Tue, 24 Mar 2020 17:33:23 +0000 (14:33 -0300)]
qemu: make Hyperv settings exclusive to x86 and aarch64

Hyperv features are supported by both x86 and aarch64. The <hyperv/>
declaration in the XML by itself is benign to other architectures,
but any of its 14 current features will break QEMU with an error
like this (from ppc64):

qemu-kvm: Expected key=value format, found hv_relaxed

This is a more extreme case than the one for apic eoi because we
would need an extra 'switch' statement, with all current Hyperv
features in the body of qemuDomainDefValidateFeatures(), to
check if the user attempted to activate any of them. It's easier to
simply fail to launch with any 'hyperv' declaration in the XML for
every arch which is not x86 and aarch64.

A fair disclaimer about Windows and PowerPC: the last Windows version
that ran in the architecture is the hall of famer Windows NT 4.0,
launched in 1996 and with end of extended support for the Server
version in 2004 [1]. I am acknowledging that there might be Windows
NT 4.0 users running in PowerPC, but not enough people running it
under KVM/QEMU to justify Libvirt allowing 'hyperv' to exist in the
domain XML of ppc64 domains.

[1] https://en.wikipedia.org/wiki/Windows_NT_4.0

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: avoid launching non-x86 guests with 'pvspinlock' setting
Daniel Henrique Barboza [Tue, 24 Mar 2020 17:33:22 +0000 (14:33 -0300)]
qemu: avoid launching non-x86 guests with 'pvspinlock' setting

The 'pvspinlock' feature is x86 only. The "<pvspinlock/>" declaration
will always have a value 'on' or 'off', and both will break QEMU when
launching non-x86 guests. This is the error message for
"<pvspinlock state='on'/>" when running a ppc64 guest:

qemu-kvm: Expected key=value format, found +kvm_pv_unhalt

A similar error message is thrown for "<pvspinlock state='off'/>".

This patch prevents non-x86 guests from launching with any
pvspinlock setting with a more informative error message:

error: unsupported configuration: The 'pvspinlock' feature is not
supported for architecture 'ppc64' or machine type 'pseries'

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: avoid launching non-x86 guests with APIC-EOI setting
Daniel Henrique Barboza [Tue, 24 Mar 2020 17:33:21 +0000 (14:33 -0300)]
qemu: avoid launching non-x86 guests with APIC-EOI setting

The "<apic/>" feature, although it's available only for x86 guests,
can be declared in the domain XML of other archs without errors.
But setting its 'eoi' attribute will break QEMU. For "<apic eoi='on'/>",
in a ppc64 guest:

qemu-kvm: Expected key=value format, found +kvm_pv_eoi

A similar error happens with eoi='off'.

One can argue that it's better to simply forbid launching non-x86
guests with "<apic/>" declared in the XML - it is a feature that
the architecture doesn't support and this would make it clearer
about it. This is sensible, but there are non-x86 guests that are
running with "<apic/>" declared in the domain (and A LOT of guests
running with "<acpi/>" for that matter, probably reminiscent of x86
templates that were reused for other archs) that will stop working if we
go this route.

A more subtle approach is to detect if the 'eoi' element is being set
for non-x86 guests and warn the user about it with a better error
message than the one QEMU provides. This is the new error message
when any value is set for the 'eoi' element in a ppc64 XML:

error: unsupported configuration: The 'eoi' attribute of the 'apic'
feature is not supported for architecture 'ppc64' or machine type
'pseries'.

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

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemuDomainGetGuestInfo: Suppress non-fatal errors
Peter Krempa [Mon, 16 Mar 2020 08:04:53 +0000 (09:04 +0100)]
qemuDomainGetGuestInfo: Suppress non-fatal errors

Don't report cases when the guest information is not requested
explicitly and not present either.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetFSInfo: expose 'report_unsupported' argument
Peter Krempa [Mon, 16 Mar 2020 07:37:13 +0000 (08:37 +0100)]
qemuAgentGetFSInfo: expose 'report_unsupported' argument

Use qemuAgentCommandFull so that callers of qemuAgentGetFSInfo can
suppress error reports if the function is not supported by the guest
agent.

Since this patch removes the last use of
qemuAgentErrorCommandUnsupported the whole function is deleted as well.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetTimezone: expose 'report_unsupported' argument
Peter Krempa [Mon, 16 Mar 2020 07:37:13 +0000 (08:37 +0100)]
qemuAgentGetTimezone: expose 'report_unsupported' argument

Use qemuAgentCommandFull so that callers of qemuAgentGetTimezone can
suppress error reports if the function is not supported by the guest
agent.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetOSInfo: expose 'report_unsupported' argument
Peter Krempa [Mon, 16 Mar 2020 07:37:13 +0000 (08:37 +0100)]
qemuAgentGetOSInfo: expose 'report_unsupported' argument

Use qemuAgentCommandFull so that callers of qemuAgentGetOSInfo can
suppress error reports if the function is not supported by the guest
agent.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetUsers: expose 'report_unsupported' argument
Peter Krempa [Mon, 16 Mar 2020 07:37:13 +0000 (08:37 +0100)]
qemuAgentGetUsers: expose 'report_unsupported' argument

Use qemuAgentCommandFull so that callers of qemuAgentGetUsers can
suppress error reports if the function is not supported by the guest
agent.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetHostname: expose 'report_unsupported' argument
Peter Krempa [Mon, 16 Mar 2020 07:26:34 +0000 (08:26 +0100)]
qemuAgentGetHostname: expose 'report_unsupported' argument

Use qemuAgentCommandFull in qemuAgentGetHostname so that we can suppress
error reports if the caller will not require them. Callers for now
always require error reporting but will be fixed later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetHostname: Refactor to remove cleanup section
Peter Krempa [Fri, 13 Mar 2020 09:55:22 +0000 (10:55 +0100)]
qemuAgentGetHostname: Refactor to remove cleanup section

Use g_autoptr instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentGetUsers: Fix return value on success
Peter Krempa [Fri, 13 Mar 2020 09:02:48 +0000 (10:02 +0100)]
qemuAgentGetUsers: Fix return value on success

Return 0 on success to match the documentation. The callers only check
for negative values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentCommand: Wire up suppressing of error reporting for unsupported commands
Peter Krempa [Fri, 13 Mar 2020 08:49:35 +0000 (09:49 +0100)]
qemuAgentCommand: Wire up suppressing of error reporting for unsupported commands

In some cases we don't want to log errors if an agent command is
unsupported. Wire it up into qemuAgentCheckError via qemuAgentCommandFull
and provide a thin wrapper (qemuAgentCommand) to prevent having to fix
all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuAgentCheckError: use g_autofree
Peter Krempa [Fri, 13 Mar 2020 08:43:10 +0000 (09:43 +0100)]
qemuAgentCheckError: use g_autofree

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuDomainGetGuestInfo: Validate supported information types
Peter Krempa [Fri, 13 Mar 2020 08:05:48 +0000 (09:05 +0100)]
qemuDomainGetGuestInfo: Validate supported information types

'qemuDomainGetGuestInfoCheckSupport' despite its name was not checking
whether the info types are supported. Convert the function to return
integers and include the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: domain_conf: remove virDomainVideoDefaultType
Rafael Fonseca [Tue, 24 Mar 2020 16:14:36 +0000 (17:14 +0100)]
conf: domain_conf: remove virDomainVideoDefaultType

The logic has been moved to the individual drivers.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovbox: move video default logic to driver
Rafael Fonseca [Tue, 24 Mar 2020 16:14:35 +0000 (17:14 +0100)]
vbox: move video default logic to driver

The logic setting a device default should be in the post parse function
of individual driver code.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotest: move video default logic to driver
Rafael Fonseca [Tue, 24 Mar 2020 16:14:34 +0000 (17:14 +0100)]
test: move video default logic to driver

The logic setting a device default should be in the post parse function
of individual driver code.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovmx: vmware: move video default logic to driver
Rafael Fonseca [Tue, 24 Mar 2020 16:14:33 +0000 (17:14 +0100)]
vmx: vmware: move video default logic to driver

The logic setting a device default should be in the post parse function
of individual driver code.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovz: openvz: move video default logic to driver
Rafael Fonseca [Tue, 24 Mar 2020 16:14:32 +0000 (17:14 +0100)]
vz: openvz: move video default logic to driver

The logic setting a device default should be in the post parse function
of individual driver code.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: move video default logic to driver
Rafael Fonseca [Tue, 24 Mar 2020 16:14:31 +0000 (17:14 +0100)]
libxl: move video default logic to driver

The logic setting a device default should be in the post parse function
of individual driver code.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobhyve: move video default logic to driver
Rafael Fonseca [Tue, 24 Mar 2020 16:14:30 +0000 (17:14 +0100)]
bhyve: move video default logic to driver

The logic setting a device default should be in the post parse function
of individual driver code.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: keep the pidfile locked
Marc-André Lureau [Tue, 24 Mar 2020 23:58:00 +0000 (00:58 +0100)]
util: keep the pidfile locked

Unfortunately, advisory record locking lose the lock if any fd refering
to the file is closed. There doesn't seem to be a way to preserve the
lock atomically. We could eventually retake the lock if low pidfilefd
is required.

This fixes processes being leaked, as they are not killed in
virPidFileForceCleanupPath() if the lock can be taken. Here also, we may
consider this is not good enough, as a process may leak by simply
closing the pidfilefd.

Fixes commit d146105f1e4a9e0ab179f0b78c070ea38b9d5334 ("virCommand:
Actually acquire pidfile instead of just writing it")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: news: fix typo
Ján Tomko [Tue, 24 Mar 2020 17:22:11 +0000 (18:22 +0100)]
docs: news: fix typo

s/ommited/omitted/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoWIP: qemu-slirp: update to follow current spec
Marc-André Lureau [Tue, 25 Feb 2020 09:55:13 +0000 (10:55 +0100)]
WIP: qemu-slirp: update to follow current spec

The WIP specification is hosted on slirp wiki at this point:
https://gitlab.freedesktop.org/slirp/libslirp/-/wikis/Slirp-Helper

We would need more feedback from various parties (including libvirt,
podman, and other developpers) before declaring a frozen version.

So for now, follow it, and feedback welcome!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-slirp: register helper for migration
Marc-André Lureau [Tue, 25 Feb 2020 09:55:12 +0000 (10:55 +0100)]
qemu-slirp: register helper for migration

When the helper supports DBus, connect it to the bus and set its ID.

If the helper supports migration, register its ID to the list of
dbus-vmstate ID to migrate, and specify --dbus-incoming when
restoring the VM.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: add dbus-vmstate helper migration support
Marc-André Lureau [Tue, 25 Feb 2020 09:55:11 +0000 (10:55 +0100)]
qemu: add dbus-vmstate helper migration support

Helper processes may have their state migrated with QEMU data stream
thanks to the QEMU "dbus-vmstate".

libvirt maintains the list of helpers to be migrated. The
"dbus-vmstate" is added when required, and given the list of helper
Ids that must be migrated, on save & load sides.

See also:
https://git.qemu.org/?p=qemu.git;a=blob;f=docs/interop/dbus-vmstate.rst

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: prepare and stop the dbus daemon
Marc-André Lureau [Tue, 25 Feb 2020 09:55:10 +0000 (10:55 +0100)]
qemu: prepare and stop the dbus daemon

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodomain: save/restore the state of dbus-daemon running
Marc-André Lureau [Tue, 25 Feb 2020 09:55:09 +0000 (10:55 +0100)]
domain: save/restore the state of dbus-daemon running

This avoids trying to start a dbus-daemon when its already running.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: add a DBus daemon helper unit
Marc-André Lureau [Tue, 25 Feb 2020 09:55:08 +0000 (10:55 +0100)]
qemu: add a DBus daemon helper unit

Add a unit to start & stop a private dbus-daemon.

The daemon is meant to be started on demand, and associated with a
QEMU process. It should be stopped when the QEMU process is stopped.

The current policy is permissive like a session bus. Stricter
policies can be added later, following recommendations from:
https://git.qemu.org/?p=qemu.git;a=blob;f=docs/interop/dbus.rst

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-conf: add dbusStateDir
Marc-André Lureau [Tue, 25 Feb 2020 09:55:07 +0000 (10:55 +0100)]
qemu-conf: add dbusStateDir

Location of DBus daemon state configuration, socket, pid...

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-conf: add configurable dbus-daemon location
Marc-André Lureau [Tue, 25 Feb 2020 09:55:06 +0000 (10:55 +0100)]
qemu-conf: add configurable dbus-daemon location

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: remove dbus-vmstate code
Marc-André Lureau [Tue, 25 Feb 2020 09:55:05 +0000 (10:55 +0100)]
qemu: remove dbus-vmstate code

This code was based on a per-helper instance and peer-to-peer
connections. The code that landed in qemu master for v5.0 is relying
on a single instance and DBus bus.

Instead of trying to adapt the existing dbus-vmstate code, let's
remove it and resubmit. That should make reviewing easier.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobridge_driver: Replace and drop networkKillDaemon
Michal Privoznik [Fri, 13 Mar 2020 16:06:19 +0000 (17:06 +0100)]
bridge_driver: Replace and drop networkKillDaemon

In the network driver code there's networkKillDaemon() which is
the same as virProcessKillPainfully(). Replace the former with
the later and drop what becomes unused function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agoqemuVirtioFSStop: Simplify daemon kill
Michal Privoznik [Fri, 13 Mar 2020 16:03:10 +0000 (17:03 +0100)]
qemuVirtioFSStop: Simplify daemon kill

Now, that we know that the virtiofsd will have the pidfile open
and locked we can use virPidFileForceCleanupPath() to kill it and
unlink the pidfile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agoqemuSlirpStop: Simplify helper kill
Michal Privoznik [Fri, 13 Mar 2020 15:12:59 +0000 (16:12 +0100)]
qemuSlirpStop: Simplify helper kill

Now, that we know that the slirp helper will have the pidfile
open and locked we can use virPidFileForceCleanupPath() to kill
it and unlink the pidfile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agoqemuProcessStartManagedPRDaemon: Don't pass -f pidfile to the daemon
Michal Privoznik [Fri, 13 Mar 2020 14:57:24 +0000 (15:57 +0100)]
qemuProcessStartManagedPRDaemon: Don't pass -f pidfile to the daemon

Now, that our virCommandSetPidFile() is more intelligent we don't
need to rely on the daemon to create and lock the pidfile and use
virCommandSetPidFile() at the same time.

NOTE that as advertised in the previous commit, this was
temporarily broken, because both virCommand and
qemuProcessStartManagedPRDaemon() would try to lock the pidfile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agovirCommand: Actually acquire pidfile instead of just writing it
Michal Privoznik [Fri, 13 Mar 2020 12:12:49 +0000 (13:12 +0100)]
virCommand: Actually acquire pidfile instead of just writing it

Our virCommand module allows us to set a pidfile for commands we
want to spawn. The caller constructs the string of pidfile path
and then uses virCommandSetPidFile() to tell the module to write
the pidfile once the command is ran. This usually works, but has
two flaws:

1) the child process does not hold the pidfile open & locked.
Therefore, the caller (or anybody else) can't use our fancy
virPidFileForceCleanupPath() function to kill the command
afterwards. Also, for everybody else on the system it's
needlessly harder to check if the pid from the pidfile is still
alive or not.

2) if the caller ever makes a mistake and passes the same pidfile
path for two different commands, the start of the second command
will overwrite the pidfile even though the first command might
still be running.

NOTE that this temporarily renders some command spawning
unusable, specifically those code patterns where both
virCommandSetPidFile() is used together with instructing spawned
command to acquire pidfile itself. Fortunately, there is only one
occurrence of such pattern and it is in
qemuProcessStartManagedPRDaemon(). This is fixed in next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agoqemu_monitor_text.c: Use g_autofree
Seeteena Thoufeek [Tue, 24 Mar 2020 12:44:46 +0000 (18:14 +0530)]
qemu_monitor_text.c: Use g_autofree

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agocommandtest: Fix test28 error detection
Michal Privoznik [Tue, 24 Mar 2020 12:48:58 +0000 (13:48 +0100)]
commandtest: Fix test28 error detection

As a part of c799d150d5e9dae I've introduced a test case that
tests whether passing error object between processes works. The
test spawns a child which reports a system error, parent process
then reads the error and compares with expected output. Problem
with this approach is that error message contains stringified
errno which is not portable. FreeBSD has generally different
messages than Linux. Therefore, use g_strerror() to do the errno
to string translation for us.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agostorage: Parse 'nvme' disk source properties from json:{} pseudo-uri
Peter Krempa [Mon, 23 Mar 2020 17:06:56 +0000 (18:06 +0100)]
storage: Parse 'nvme' disk source properties from json:{} pseudo-uri

Our code allows snapshots of NVMe based disks which means we create
overlay file with a 'json:{}' pseudo-uri refering to the NVME device.
Our parser code doesn't handle them though. Add the parser and test it
via the XML->json->XML round-trip and reference data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBlockGetBackingStoreString: Properly handle 'http/s' with cookies and others
Peter Krempa [Mon, 23 Mar 2020 15:36:22 +0000 (16:36 +0100)]
qemuBlockGetBackingStoreString: Properly handle 'http/s' with cookies and others

Format cookies into the backing store string without encryption as they
will not be visible on the command line when formatting a 'target' only
string. In cases when cookies or other options are used we must use the
JSON format rather than pure URI.

Add tests to validate the scenario.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: block: Extract formatting of cookie string
Peter Krempa [Mon, 23 Mar 2020 15:31:19 +0000 (16:31 +0100)]
qemu: block: Extract formatting of cookie string

Introduce qemuBlockStorageSourceGetCookieString which does the
concatenation so that we can reuse it later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBlockGetBackingStoreString: Add extra wrapping object to JSON strings
Peter Krempa [Mon, 23 Mar 2020 15:09:31 +0000 (16:09 +0100)]
qemuBlockGetBackingStoreString: Add extra wrapping object to JSON strings

QEMU requires an extra wrapper object where only the "file" member is
populated. This is basically a placeholder for establishing the format
layer. We did the same in qemuDiskSourceGetProps for the old-school
JSON usage with -drive but forgot to adopt this for -blockdev.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agostorage: Implement backing store support for "fat:" prefix
Peter Krempa [Mon, 23 Mar 2020 15:04:19 +0000 (16:04 +0100)]
storage: Implement backing store support for "fat:" prefix

qemublocktest showed that we don't add the "fat:" prefix for directory
storage when formatting the backing store string. While it's unlikely to
be used it's simple enough to actually implement the support rather than
trying to forbid it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBlockGetBackingStoreString: Remove 'ret' variable
Peter Krempa [Mon, 23 Mar 2020 14:29:56 +0000 (15:29 +0100)]
qemuBlockGetBackingStoreString: Remove 'ret' variable

We can return the appropriate string directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemublocktest: Test backing store strings
Peter Krempa [Mon, 23 Mar 2020 11:35:32 +0000 (12:35 +0100)]
qemublocktest: Test backing store strings

With -blockdev libvirt provides the string which is recorded  as
'backing store' property of an image to qemu. Add testing for
qemuBlockGetBackingStoreString which generates these strings as there's
logic which determines which format to use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotestQemuDiskXMLToProps: Store all per-image data in one structure
Peter Krempa [Mon, 23 Mar 2020 11:10:38 +0000 (12:10 +0100)]
testQemuDiskXMLToProps: Store all per-image data in one structure

We had two non-syncrhonized arrays holding the individual data. This was
a lazy way to do it when I was adding new tests recently. Since it's
hard to extend with new data to test refactor the storage of test data
to use a new struct where all per-image data are kept and can be
extended easily.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBlockGetBackingStoreString: Add 'pretty' argument
Peter Krempa [Mon, 23 Mar 2020 10:48:10 +0000 (11:48 +0100)]
qemuBlockGetBackingStoreString: Add 'pretty' argument

Add support for pretty-printing of the JSON variant of the output for
consumption in tests. All current callers pass 'false'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotestQemuDiskXMLToPropsValidateFileSrcOnly: Move together with rest of xml->json code
Peter Krempa [Mon, 23 Mar 2020 10:50:57 +0000 (11:50 +0100)]
testQemuDiskXMLToPropsValidateFileSrcOnly: Move together with rest of xml->json code

The function was misplaced. Group it together with other helper
functions for testing disk XML to qemu JSON props conversion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemublocktest: xml->json: Refactor cleanup in test case functions
Peter Krempa [Mon, 23 Mar 2020 10:24:39 +0000 (11:24 +0100)]
qemublocktest: xml->json: Refactor cleanup in test case functions

Use automatic variable clearing and remove the cleanup sections of
testQemuDiskXMLToProps, testQemuDiskXMLToPropsValidateSchema and
testQemuDiskXMLToPropsValidateFile.

testQemuDiskXMLToPropsValidateFileSrcOnly already uses new helpers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirDomainDiskSourceNVMeFormat: Format only valid 'managed' values
Peter Krempa [Mon, 23 Mar 2020 17:26:52 +0000 (18:26 +0100)]
virDomainDiskSourceNVMeFormat: Format only valid 'managed' values

VIR_TRISTATE_BOOL_ABSENT which maps to the 'default' string would not be
parsed back, so we shouldn't format it either.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemublocktest: xml->json: Add test for NVMe
Peter Krempa [Wed, 18 Mar 2020 17:49:10 +0000 (18:49 +0100)]
qemublocktest: xml->json: Add test for NVMe

Based on the configuration from the only qemuxml2argv test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: rename 'namespace' property of struct _virStorageSourceNVMeDef
Peter Krempa [Mon, 23 Mar 2020 09:57:49 +0000 (10:57 +0100)]
conf: rename 'namespace' property of struct _virStorageSourceNVMeDef

While 'namespace' is not a reserved word in C, it is in C++. Our
compilers are happy with it but syntax-hilighting in some editors
hilights is as a keyword. Rename it to prevent confusion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: virhostcpu: Fail when fetching CPU Stats for invalid cpu
Mauro S. M. Rodrigues [Fri, 21 Feb 2020 18:10:45 +0000 (15:10 -0300)]
util: virhostcpu: Fail when fetching CPU Stats for invalid cpu

virHostCPUGetStatsLinux walks through every cpu in /proc/stat until it
finds cpu%cpuNum that matches with the requested cpu.
If none is found it logs the error but it should return -1, instead of 0.
Otherwise virsh nodecpustats --cpu <invalid cpu number> and API bindings
don't fail properly, printing a blank line instead of an error message.

This patch also includes an additional test for virhostcputest to avoid
this regression to happen again in the future.

Fixes: 93af79fba3fd75a8df6b7ca608719dd97f9511a0
Reported-by: Satheesh Rajendran <satheera@in.ibm.com>
Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoqemu: virtiofs: shorten socket filename
Ján Tomko [Mon, 23 Mar 2020 15:48:57 +0000 (16:48 +0100)]
qemu: virtiofs: shorten socket filename

Use just 'fs' instead of 'virtiofsd'.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: virtiofs: shorten pid filename
Ján Tomko [Mon, 23 Mar 2020 15:46:03 +0000 (16:46 +0100)]
qemu: virtiofs: shorten pid filename

There is no need to repeat the shortName, since it's
already present in the directory path.

Also use just 'fs' instead of 'virtiofsd'.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Suggested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews.xml: document the new NVDIMM support for Pseries guests
Daniel Henrique Barboza [Mon, 23 Mar 2020 19:40:51 +0000 (16:40 -0300)]
news.xml: document the new NVDIMM support for Pseries guests

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoformatdomain.html.in: document NVDIMM 'label' requirement for pSeries
Daniel Henrique Barboza [Mon, 23 Mar 2020 19:40:50 +0000 (16:40 -0300)]
formatdomain.html.in: document NVDIMM 'label' requirement for pSeries

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf, qemu: enable NVDIMM support for ppc64
Daniel Henrique Barboza [Mon, 23 Mar 2020 19:40:49 +0000 (16:40 -0300)]
conf, qemu: enable NVDIMM support for ppc64

Using the 'uuid' element for ppc64 NVDIMM memory added in the
previous patch, use it in qemuBuildMemoryDeviceStr() to pass
it over to QEMU.

Another ppc64 restriction is the necessity of a mem->labelsize,
given than ppc64 only support label-area backed NVDIMMs.

Finally, we don't want ppc64 NVDIMMs to align up due to the
high risk of going beyond the end of file with a 256MiB
increment that the user didn't predict. Align it down
instead. If target size is less than the minimum of
256MiB + labelsize, error out since QEMU will error out
if we attempt to round it up to the minimum.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoformatdomain.html.in: document the new 'uuid' NVDIMM element
Daniel Henrique Barboza [Mon, 23 Mar 2020 19:40:48 +0000 (16:40 -0300)]
formatdomain.html.in: document the new 'uuid' NVDIMM element

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Introduce optional 'uuid' element for NVDIMM memory
Daniel Henrique Barboza [Mon, 23 Mar 2020 19:40:47 +0000 (16:40 -0300)]
conf: Introduce optional 'uuid' element for NVDIMM memory

ppc64 NVDIMM support was implemented in QEMU by commit [1].
The support is similar to what x86 already does, aside from
an extra 'uuid' element.

This patch introduces a new optional 'uuid' element for the
NVDIMM memory model. This element behaves like the 'uuid'
element of the domain definition - if absent, we'll create
a new one, otherwise use the one provided by the XML.
The 'uuid' element is exclusive to pseries guests and are
unavailable for other architectures.

Next patch will use this new element to add NVDIMM support
for ppc64.

[1] https://github.com/qemu/qemu/commit/ee3a71e36654317b14ede0290e87628f8b79f850

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: capabilities: update qemu-5.0.0 capabilities for ppc64
Daniel Henrique Barboza [Mon, 23 Mar 2020 19:40:46 +0000 (16:40 -0300)]
qemu: capabilities: update qemu-5.0.0 capabilities for ppc64

Update ppc64 capabilities to pick up the new NVDIMM capability
support for ppc64.

Since the ppc64 capabilities weren't updated for some time, the
bulk of the changes here are related to the blockdev support
(see commit c6a9e54ce3 for info) that we are picking up just
now.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Document removal of support for .ini style of comments
Michal Privoznik [Mon, 23 Mar 2020 14:49:59 +0000 (15:49 +0100)]
news: Document removal of support for .ini style of comments

In previous patches virKeyFile was replaced with its GLib
counterpart which created an incompatible change: comments can
now begin only with a number sign (#). While this won't probably
affect anyone, mention it in the release notes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: remove virKeyFile
Rafael Fonseca [Mon, 23 Mar 2020 13:19:13 +0000 (14:19 +0100)]
util: remove virKeyFile

The functionality is now provided by glib's GKeyFile.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: authconfig: use g_key_file_*
Rafael Fonseca [Mon, 23 Mar 2020 13:19:12 +0000 (14:19 +0100)]
util: authconfig: use g_key_file_*

Replace libvirt's virKeyFile by glib's GKeyFile.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoapi: disallow virDomainAgentSetResponseTimeout() on read-only connections
Jonathon Jongsma [Fri, 20 Mar 2020 14:43:13 +0000 (09:43 -0500)]
api: disallow virDomainAgentSetResponseTimeout() on read-only connections

This function changes the amount of time that libvirt waits for a
response from the guest agent for all guest agent commands. Since this
is a configuration change, it should not be allowed on read-only
connections.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fix response timeout for agent guest-sync
Jonathon Jongsma [Fri, 20 Mar 2020 22:28:10 +0000 (17:28 -0500)]
qemu: fix response timeout for agent guest-sync

The agent 'guest-sync' command historically had a 5s response timeout
which was different from other agent commands, which waited forever.
When we added the ability to customize the response timeout for guest
agent commands, we intended to continue to use 5s for 'guest-sync' when
the user specified a response timeout greater than 5s, and use the
user-specified timeout if it was below 5s. Unfortunately, when
attempting to determine whether the user-specified timeout was less than
5s, we were comparing against an enum value of
VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT (which is -1) rather than against
the actual time value that it represented (5).

This change makes it so that 'guest-sync' now uses the user-specified
tiemout if it is less than 5s.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Use g_autofree and g_autoptr in qemuAgentSetUserPassword
Seeteena Thoufeek [Mon, 23 Mar 2020 11:13:59 +0000 (16:43 +0530)]
qemu: Use g_autofree and g_autoptr in qemuAgentSetUserPassword

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: use virStringParseYesNo
Rafael Fonseca [Sun, 22 Mar 2020 16:39:50 +0000 (17:39 +0100)]
conf: use virStringParseYesNo

Use existing function built for this exact purpose.

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosecurity: Try harder to run transactions
Michal Privoznik [Wed, 18 Mar 2020 09:18:46 +0000 (10:18 +0100)]
security: Try harder to run transactions

When a QEMU process dies in the middle of a hotplug, then we fail
to restore the seclabels on the device. The problem is that if
the thread doing hotplug locks the domain object first and thus
blocks the thread that wants to do qemuProcessStop(), the
seclabel cleanup code will see vm->pid still set and mount
namespace used and therefore try to enter the namespace
represented by the PID. But the PID is gone really and thus
entering will fail and no restore is done. What we can do is to
try enter the namespace (if requested to do so) but if entering
fails, fall back to no NS mode.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agovirprocess: Passthru error from virProcessRunInForkHelper
Michal Privoznik [Wed, 18 Mar 2020 11:59:08 +0000 (12:59 +0100)]
virprocess: Passthru error from virProcessRunInForkHelper

When running a function in a forked child, so far the only thing
we could report is exit status of the child and the error
message. However, it may be beneficial to the caller to know the
actual error that happened in the child.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agovirfile: Handle directories in virFileBindMountDevice()
Michal Privoznik [Fri, 4 Oct 2019 19:01:49 +0000 (21:01 +0200)]
virfile: Handle directories in virFileBindMountDevice()

The @src is not always a file. It may also be a directory (for
instance qemuDomainCreateDeviceRecursive() assumes that) - even
though it doesn't happen usually. Anyway, mount() can mount only
a dir onto a dir and a file onto a file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agoqemuDomainBuildNamespace: Make @devPath const
Michal Privoznik [Fri, 4 Oct 2019 19:56:25 +0000 (21:56 +0200)]
qemuDomainBuildNamespace: Make @devPath const

The @devPath variable is not modifiable. It merely just points to
string containing path where private devtmpfs is being
constructed. Make it const so it doesn't look weird that it's not
freed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agoqemuDomainBuildNamespace: Try harder to remove temp directories
Michal Privoznik [Fri, 4 Oct 2019 19:01:29 +0000 (21:01 +0200)]
qemuDomainBuildNamespace: Try harder to remove temp directories

If building namespace fails somewhere in the middle (that is some
files exists under devMountsSavePath[i]), then plain rmdir() is
not enough to remove dir. Umount the temp location and use
virFileDeleteTree() to remove the directory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agoqemuDomainCreateDeviceRecursive: Report error if mkdir() fails
Michal Privoznik [Fri, 4 Oct 2019 18:59:10 +0000 (20:59 +0200)]
qemuDomainCreateDeviceRecursive: Report error if mkdir() fails

The virFileMakePathWithMode() which is our recursive version of
mkdir() fails, it simply just returns a negative value with errno
set. No error is reported (as compared to virFileTouch() for
instance).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agotests: virstoragetest: validate that array deflattening works for gluster
Peter Krempa [Thu, 14 Dec 2017 17:01:05 +0000 (18:01 +0100)]
tests: virstoragetest: validate that array deflattening works for gluster

Validate that we are able to parse back the dotted syntax arrays we were
generating in the pre-blockdev era.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agojsontest: Add test cases for deflattening of arrays
Peter Krempa [Wed, 18 Mar 2020 16:02:42 +0000 (17:02 +0100)]
jsontest: Add test cases for deflattening of arrays

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirjson: Deflatten arrays generated by the json->commandline generator
Peter Krempa [Thu, 14 Dec 2017 17:03:04 +0000 (18:03 +0100)]
virjson: Deflatten arrays generated by the json->commandline generator

For the few instances where we'd generate an array in dotted syntax we
should be able to parse it back. Add another step in deflattening of the
dotted syntax which reconstructs the arrays so that the backing store
parser can parse it.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: json: Extract deflattening of keys into a separate function
Peter Krempa [Thu, 19 Mar 2020 17:11:48 +0000 (18:11 +0100)]
util: json: Extract deflattening of keys into a separate function

Extract the code so that there's a clean separation once we'll want do
do other steps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirJSONValueObjectDeflattenWorker: Refactor cleanup
Peter Krempa [Wed, 18 Mar 2020 15:38:16 +0000 (16:38 +0100)]
virJSONValueObjectDeflattenWorker: Refactor cleanup

Use automatic memory handling to remove the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirBitmapNewEmpty: Use g_new0 to allocate and remove error checking
Peter Krempa [Wed, 18 Mar 2020 14:51:14 +0000 (15:51 +0100)]
virBitmapNewEmpty: Use g_new0 to allocate and remove error checking

virBitmapNewEmpty can't fail now so we can make it obvious and fix all
callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirStorageEncryptionSecretCopy: Properly copy internals
Peter Krempa [Thu, 19 Mar 2020 14:38:06 +0000 (15:38 +0100)]
virStorageEncryptionSecretCopy: Properly copy internals

virStorageEncryptionSecretPtr may have a string inside it, thus we must
copy the string too. Use virSecretLookupDefCopy to do that.

Caused by non-obvious code introduced in 756b46ddd24 and later 47e88b33b
which added a string that needed to be copied.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirSecretLookupDefCopy: Remove return value
Peter Krempa [Thu, 19 Mar 2020 14:27:40 +0000 (15:27 +0100)]
virSecretLookupDefCopy: Remove return value

The function always returns succes so there's no need for a return
value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: block: Split up formatting of JSON props for 'raw' and 'luks' drivers
Peter Krempa [Thu, 19 Mar 2020 16:23:33 +0000 (17:23 +0100)]
qemu: block: Split up formatting of JSON props for 'raw' and 'luks' drivers

qemuBlockStorageSourceGetFormatRawProps aggregated both formats but
since we now have props specific for either of those formats it's
unwanted to aggregate the code such way. Split out the 'luks' props
formatter into qemuBlockStorageSourceGetFormatLUKSProps.

The wrong separation demonstrates istself on formatting of the 'size'
and 'offset' attributes for the 'luks' driver which does not conform
to the qapi schema.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuBlockStorageSourceNeedsStorageSliceLayer: Deal with 'luks' files
Peter Krempa [Thu, 19 Mar 2020 15:54:52 +0000 (16:54 +0100)]
qemuBlockStorageSourceNeedsStorageSliceLayer: Deal with 'luks' files

The 'luks' driver in qemu is as any other non-raw format driver and thus
doesn't support the properties for 'slice'. Since libvirt considers
luks files to be raw+encryption we need to special case them when
dealing with the slice.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>