]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agolibvirt-guests: Fix dependency ordering in service file
Martin Kletzander [Tue, 30 Aug 2022 06:29:53 +0000 (08:29 +0200)]
libvirt-guests: Fix dependency ordering in service file

After some debugging and discussion with systemd team it turns out we
are misusing the ordering in libvirt-guests.service.  That happened
because we want to support both monolithic and modular daemon setups and
on top of that we also want to support socket activation and services
without socket activation.  Unfortunately this is impossible to express
in the unit file because of how transactions are handled in systemd when
dependencies are resolved and multiple actions (jobs) are queued.  For
explanation from Michal Sekletar see comment #7 in the BZ this patch is
fixing:

https://bugzilla.redhat.com/show_bug.cgi?id=1964855#c7

In order to support all the scenarios this patch also amends the
manpages so that users that are changing the default can also read how
to correct the dependency ordering in libvirt-guests unit file.

Ideally we would also keep the existing configuration during upgrade,
but due to our huge support matrix this seems hardly feasible as it
could introduce even more problems.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoTranslated using Weblate (Chinese (Simplified) (zh_CN))
zhanchun li [Sun, 25 Sep 2022 12:19:43 +0000 (14:19 +0200)]
Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 99.8% (10420 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/zh_CN/

Co-authored-by: zhanchun li <lzc777@126.com>
Signed-off-by: zhanchun li <lzc777@126.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 25 Sep 2022 12:19:43 +0000 (14:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 47.2% (4932 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoqemu_process.c: Propagate hugetlbfs mounts on reconnect
Michal Privoznik [Tue, 6 Sep 2022 11:45:51 +0000 (13:45 +0200)]
qemu_process.c: Propagate hugetlbfs mounts on reconnect

When reconnecting to a running QEMU process, we construct the
per-domain path in all hugetlbfs mounts. This is a relict from
the past (v3.4.0-100-g5b24d25062) where we switched to a
per-domain path and we want to create those paths when libvirtd
restarts on upgrade.

And with namespaces enabled there is one corner case where the
path is not created. In fact an error is reported and the
reconnect fails. Ideally, all mount events are propagated into
the QEMU's namespace. And they probably are, except when the
target path does not exist inside the namespace. Now, it's pretty
common for users to mount hugetlbfs under /dev (e.g.
/dev/hugepages), but if domain is started without hugepages (or
more specifically - private hugetlbfs path wasn't created on
domain startup), then the reconnect code tries to create it.
But it fails to do so, well, it fails to set seclabels on the
path because, because the path does not exist in the private
namespace. And it doesn't exist because we specifically create
only a subset of all possible /dev nodes. Therefore, the mount
event, whilst propagated, is not successful and hence the
filesystem is not mounted. We have to do it ourselves.

If hugetlbfs is mount anywhere else there's no problem and this
is effectively a dead code.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2123196
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_namespace: Introduce qemuDomainNamespaceSetupPath()
Michal Privoznik [Tue, 6 Sep 2022 11:43:58 +0000 (13:43 +0200)]
qemu_namespace: Introduce qemuDomainNamespaceSetupPath()

Sometimes it may come handy to just bind mount a directory/file
into domain's namespace. Implement a thin wrapper over
qemuNamespaceMknodPaths() which has all the logic we need.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_namespace: Fix a corner case in qemuDomainGetPreservedMounts()
Michal Privoznik [Tue, 6 Sep 2022 11:43:22 +0000 (13:43 +0200)]
qemu_namespace: Fix a corner case in qemuDomainGetPreservedMounts()

When setting up namespace for QEMU we look at mount points under
/dev (like /dev/pts, /dev/mqueue/, etc.) because we want to
preserve those (which is done by moving them to a temp location,
unshare(), and then moving them back). We have a convenience
helper - qemuDomainGetPreservedMounts() - that processes the
mount table and (optionally) moves the other filesystems too.
This helper is also used when attempting to create a path in NS,
because the path, while starting with "/dev/" prefix, may
actually lead to one of those filesystems that we preserved.

And here comes the corner case: while we require the parent mount
table to be in shared mode (equivalent of `mount --make-rshared /'),
these mount events propagate iff the target path exist inside the
slave mount table (= QEMU's private namespace). And since we
create only a subset of /dev nodes, well, that assumption is not
always the case.

For instance, assume that a domain is already running, no
hugepages were configured for it nor any hugetlbfs is mounted.
Now, when a hugetlbfs is mounted into '/dev/hugepages', this is
propagated into the QEMU's namespace, but since the target dir
does not exist in the private /dev, the FS is not mounted in the
namespace.

Fortunately, this difference between namespaces is visible when
comparing /proc/mounts and /proc/$PID/mounts (where PID is the
QEMU's PID). Therefore, if possible we should look at the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_namespace: Tolerate missing ACLs when creating a path in namespace
Michal Privoznik [Tue, 6 Sep 2022 11:37:23 +0000 (13:37 +0200)]
qemu_namespace: Tolerate missing ACLs when creating a path in namespace

When creating a path in a domain's mount namespace we try to set
ACLs on it, so that it's a verbatim copy of the path in parent's
namespace. The ACLs are queried upfront (by
qemuNamespaceMknodItemInit()) but this is fault tolerant so the
pointer to ACLs might be NULL (meaning no ACLs were queried, for
instance because the underlying filesystem does not support
them). But then we take this NULL and pass it to virFileSetACLs()
which immediately returns an error because NULL is invalid value.

Mimic what we do with SELinux label - only set ACLs if they are
non-NULL which includes symlinks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_domain: Ignore all but SCSI hostdevs in qemuDomainDeviceHostdevDefPostParseResto...
Michal Privoznik [Fri, 23 Sep 2022 13:06:19 +0000 (15:06 +0200)]
qemu_domain: Ignore all but SCSI hostdevs in qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias()

When retiring QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI capability the
commit removed a bit too much. Previously, all other devices than
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI were ignored in
qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(). But the
commit in question removed not only the capability check but also
this return early statement. Restore it back.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2129239
Fixes: dc8dbb27d40968c9d9bfad2c6181bccc20c0e44e
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agosecurity_selinux: Don't ignore NVMe disks when setting image label
Michal Privoznik [Wed, 21 Sep 2022 13:56:13 +0000 (15:56 +0200)]
security_selinux: Don't ignore NVMe disks when setting image label

For NVMe disks we skip setting SELinux label on corresponding
VFIO group (/dev/vfio/X). This bug is only visible with
namespaces and goes as follows:

1) libvirt assigns NVMe disk to vfio-pci driver,
2) kernel creates /dev/vfio/X node with generic device_t SELinux
   label,
3) our namespace code creates the exact copy of the node in
   domain's private /dev,
4) SELinux policy kicks in an changes the label on the node to
   vfio_device_t (in the top most namespace),
5) libvirt tells QEMU to attach the NVMe disk, which is denied by
   SELinux policy.

While one can argue that kernel should have created the
/dev/vfio/X node with the correct SELinux label from the
beginning (step 2), libvirt can't rely on that and needs to set
label on its own.

Surprisingly, I already wrote the code that aims on this specific
case (v6.0.0-rc1~241), but because of a shortcut we take earlier
it is never ran. The reason is that
virStorageSourceIsLocalStorage() considers NVMe disks as
non-local because their source is not accessible via src->path
(or even if it is, it's not a local path).

Therefore, do not exit early for NVMe disks and let the function
continue.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2121441
Fixes: 284a12bae0e4cf93ea72797965d6c12e3a103f40
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agotests: add better QEMU capabilities example
Daniel P. Berrangé [Tue, 30 Aug 2022 11:27:59 +0000 (12:27 +0100)]
tests: add better QEMU capabilities example

Updated example covers:

  * UUID
  * CPU model, vendor, microcode, signature, counters,
    topology, maxphysaddr, features,
  * Power management
  * NUMA page size info, multiple nodes, CPU topology IDs, distances
  * CPU cache bank info
  * Multiple secmodels

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Fri, 16 Sep 2022 21:19:24 +0000 (23:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 45.9% (4794 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 45.5% (4754 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 45.3% (4734 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 44.9% (4694 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agovirdomainjob: virDomainObjInitJob: Avoid borrowing memory from 'virDomainXMLOption'
Peter Krempa [Mon, 19 Sep 2022 08:18:14 +0000 (10:18 +0200)]
virdomainjob: virDomainObjInitJob: Avoid borrowing memory from 'virDomainXMLOption'

The 'cb' and 'jobDataPrivateCb' pointers are stored in the job object
but made point to the memory owned by the virDomainXMLOption struct in
the callers.

Since the 'virdomainjob' module isn't in control the lifetime of the
virDomainXMLOption, which in some cases is freed before the domain job
data, freed memory would be dereferenced in some cases.

Copy the structs from virDomainXMLOption to ensure the lifetime. This is
possible since the callback functions are immutable.

Fixes: 84e9fd068ccad6e19e037cd6680df437617e2de5
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agomeson: Require libssh-0.8.1 or newer
Michal Privoznik [Wed, 7 Sep 2022 13:08:20 +0000 (15:08 +0200)]
meson: Require libssh-0.8.1 or newer

According to repology.org:

              RHEL-8: 0.9.4
              RHEL-9: 0.9.6
           Debian 11: 0.9.5
  openSUSE Leap 15.3: 0.8.7
        Ubuntu 20.04: 0.9.3

And the rest of distros has something newer anyways. Requiring
0.8.1 or newer allows us to drop the terrible hack where we
rename functions at meson level using #define. Note, 0.8.0 is
the version of libssh where the rename happened. It also allows
us to stick with SHA-256 hash algorithm for public keys.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoci: refresh with latest lcitool manifest
Daniel P. Berrangé [Wed, 14 Sep 2022 14:54:15 +0000 (10:54 -0400)]
ci: refresh with latest lcitool manifest

This updates the FreeBSD 13 image to 13.1 which should fix the
symbol lookup errors seen in CI recently.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agodocs: compiling: Add notes on starting compiled libvirt daemons
Peter Krempa [Fri, 9 Sep 2022 13:57:40 +0000 (15:57 +0200)]
docs: compiling: Add notes on starting compiled libvirt daemons

In the basic configuration with monolithic libvirtd users are required
to also start virtlogd. Add a general note with a specific example
hinting that this is needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: compiling: Encourage force-enabling required functionality
Peter Krempa [Fri, 9 Sep 2022 13:45:47 +0000 (15:45 +0200)]
docs: compiling: Encourage force-enabling required functionality

To prevent surprises when a build doesn't in fact contain the required
functionality suggest that users force-enable required modules.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: compiling: Separate 'prepare', 'configure', and 'build' steps
Peter Krempa [Fri, 9 Sep 2022 13:33:25 +0000 (15:33 +0200)]
docs: compiling: Separate 'prepare', 'configure', and 'build' steps

Only the preparation of sources differs between a build from a git
checkout vs a build from tarball. Restructure the docs to outline the
difference and combine information on how to configure libvirt.

Most notably the suggestion to use '-Dsystem=true' was present only for
the steps to build a git checkout.

Suggest also running the testsuite as part of the build step.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: compiling: Separate information on how to install libvirt and add disclaimer
Peter Krempa [Fri, 9 Sep 2022 08:44:13 +0000 (10:44 +0200)]
docs: compiling: Separate information on how to install libvirt and add disclaimer

Create a section for instructions on how to install the built binaries
rather than mentioning it multiple times.

Add a note that installing over your distro-provided packages will most
likely break your instalation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: compiling: Section off block on how to run from build directory
Peter Krempa [Fri, 9 Sep 2022 12:20:15 +0000 (14:20 +0200)]
docs: compiling: Section off block on how to run from build directory

Running from build directory isn't strictly tied to the git-checkout
build so make a new section for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: compiling: Add a paragraph suggesting installation from repository
Peter Krempa [Fri, 9 Sep 2022 08:19:43 +0000 (10:19 +0200)]
docs: compiling: Add a paragraph suggesting installation from repository

Users should be encouraged to install libvirt from the distro's repos in
the first place.

Also encourage distro-specific ways to get newer versions, rather than
building from source manually.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoremote: Don't attempt remote connection from libvirtd
Peter Krempa [Thu, 8 Sep 2022 15:04:01 +0000 (17:04 +0200)]
remote: Don't attempt remote connection from libvirtd

When a hypervisor driver is not compiled in and a user enables the
monolithic libvirtd, they get the following misleading error:

  $ virsh -c qemu:///system
  error: failed to connect to the hypervisor
  error: Failed to connect socket to '/var/run/libvirt/virtqemud-sock': No such file or directory

The issue is that the daemon side of the remote driver can't find the
appropriate driver, but the remote driver always accepts everything and
thus attempts to delegate further, which in case of libvirtd makes no
sense.

Refuse opening a connection for local URIS even when the requested
driver is not registered in case when we are inside 'libvirtd' as
libvirtd doesn't have anything to delegate to.

  $ virsh -c qemu:///system
  error: failed to connect to the hypervisor
  error: no connection driver available for qemu:///system

Discovered when investigating https://gitlab.com/libvirt/libvirt/-/issues/370

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirStateInitialize: Propagate whether running in monolithic daemon mode to stateful...
Peter Krempa [Fri, 9 Sep 2022 11:16:42 +0000 (13:16 +0200)]
virStateInitialize: Propagate whether running in monolithic daemon mode to stateful driver init

Upcoming patch which is fixing the opening of drivers in monolithic mode
needs to know whether we are inside 'libvirtd' but the code where the
decision needs to happen is not re-compiled per daemon. Thus we need to
pass this information to the stateful driver init function so that it
can be remebered.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agolxc: Remove unneeded forward declaration of 'lxcStateInitialize'
Peter Krempa [Fri, 9 Sep 2022 11:05:14 +0000 (13:05 +0200)]
lxc: Remove unneeded forward declaration of 'lxcStateInitialize'

The function is used only after the definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoremote: doRemoteOpen: Automatically clean up 'priv'
Peter Krempa [Fri, 9 Sep 2022 08:56:40 +0000 (10:56 +0200)]
remote: doRemoteOpen: Automatically clean up 'priv'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoremoteConnectOpen: Refactor cleanup
Peter Krempa [Thu, 8 Sep 2022 16:00:12 +0000 (18:00 +0200)]
remoteConnectOpen: Refactor cleanup

Use automatic memory freeing for 'driver' and return error right away to
avoid the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoremote: remoteOpenConn: Use virConnectOpenAuth instead of virConnectOpen(ReadOnly)
Peter Krempa [Thu, 8 Sep 2022 13:49:38 +0000 (15:49 +0200)]
remote: remoteOpenConn: Use virConnectOpenAuth instead of virConnectOpen(ReadOnly)

virConnectOpenAuth provides an unified interface with using 'flags' to
select the proper mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirConnectOpenInternal: Remove 'failed' label
Peter Krempa [Thu, 8 Sep 2022 14:37:26 +0000 (16:37 +0200)]
virConnectOpenInternal: Remove 'failed' label

Jumping to the label would just return NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirConnectOpenInternal: Switch to automatic memory cleanup
Peter Krempa [Thu, 8 Sep 2022 14:36:28 +0000 (16:36 +0200)]
virConnectOpenInternal: Switch to automatic memory cleanup

Use automatic cleanup for 'ret' and 'uristr'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirConnectOpenInternal: Avoid double free() when alias is an invalid URI
Peter Krempa [Thu, 8 Sep 2022 14:31:58 +0000 (16:31 +0200)]
virConnectOpenInternal: Avoid double free() when alias is an invalid URI

Configuring an URI alias such as

  uri_aliases = [
      "blah=qemu://invaliduri@@@",
  ]

Results in a double free when the alias is used:

  $ virsh -c blah
  free(): double free detected in tcache 2
  Aborted (core dumped)

This happens as the 'alias' variable is first assigned to 'uristr' which
is cleared in the 'failed' label and then is explicitly freed again.

Fix this by stealing the alias into 'uristr' and removing the
unnecessary freeing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agokbase: Document QEMU private mount NS limitations
Michal Privoznik [Mon, 5 Sep 2022 10:37:16 +0000 (12:37 +0200)]
kbase: Document QEMU private mount NS limitations

There are two points I've taken for granted:

  1) the mount points are set before starting a guest,
  2) the / and its submounts are marked as shared, so that mount
     events propagate into child namespaces when assumption 1) is
     not held.

But what's obvious to me might not be obvious to our users.
Document these known limitations.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2123196
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_process: Don't require a hugetlbfs mount for memfd
Michal Privoznik [Mon, 5 Sep 2022 08:34:44 +0000 (10:34 +0200)]
qemu_process: Don't require a hugetlbfs mount for memfd

The aim of qemuProcessNeedHugepagesPath() is to determine whether
a hugetlbfs mount point is required for given domain (as in
whether qemuBuildMemoryBackendProps() picks up
memory-backend-file pointing to a hugetlbfs mount point). Well,
when domain is configured to use memfd backend then that
condition can never be true. Therefore, skip creating domain's
private path under hugetlbfs mount points.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoRevert "build: Decrease maximum stack frame size to 2048"
Peter Krempa [Fri, 9 Sep 2022 14:49:14 +0000 (16:49 +0200)]
Revert "build: Decrease maximum stack frame size to 2048"

The bhyve driver still has some frames larger than 2048 bytes, so we
need to keep the limit as is.

The CI failure was masked by the Freebsd-13 failing for unrelated
reasons.

This reverts commit 46302172d47709b169c4b9b4cd6a4847fc2f0b4c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agobuild: Decrease maximum stack frame size to 2048
Peter Krempa [Mon, 5 Sep 2022 12:38:09 +0000 (14:38 +0200)]
build: Decrease maximum stack frame size to 2048

After recent cleanups we can now restrict the maximum stack frame size
to 2k.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoremote: dispatch: Allocate 'virDomainDef' in ACL helpers dynamically
Peter Krempa [Mon, 5 Sep 2022 14:22:34 +0000 (16:22 +0200)]
remote: dispatch: Allocate 'virDomainDef' in ACL helpers dynamically

At time of this patch struct 'virDomainDef' has 1736 bytes. Allocate it
dynamically to keep the stack frame size in reasonable values.

This patch also fixes remoteRelayDomainQemuMonitorEventCheckACL, where
we didn't clear the stack'd variable prior to use. Fortunately for now
the code didn't look at anything else than what the code overwrote.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: netdev: Dynamically allocate 'struct nlattr' in virNetDevSwitchdevFeature
Peter Krempa [Mon, 5 Sep 2022 14:22:47 +0000 (16:22 +0200)]
util: netdev: Dynamically allocate 'struct nlattr' in virNetDevSwitchdevFeature

At time of writing DEVLINK_ATTR_MAX equals to 176, thus the stack'd size
of the pointer array is almost 1.4kiB. Allocate it dynamically.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agolxc: process: Rework reading errors from the log file
Peter Krempa [Mon, 5 Sep 2022 13:28:57 +0000 (15:28 +0200)]
lxc: process: Rework reading errors from the log file

Introduce 'virLXCProcessReportStartupLogError' which simplifies the
error handling on startup of the LXC process when reading of the error
log is needed.

This function has unusual return value semantics but it helps to make
the callers simpler.

This patch also removes 2 1k stack'd buffers from virLXCProcessStart.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agolxc: virLXCProcessReadLogOutput: Automatically close FD
Peter Krempa [Mon, 5 Sep 2022 12:49:49 +0000 (14:49 +0200)]
lxc: virLXCProcessReadLogOutput: Automatically close FD

Switch to 'VIR_AUTOCLOSE' to simplify cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: monitor: Renumber QEMU_MONITOR_MIGRATE_RESUME
Peter Krempa [Thu, 8 Sep 2022 11:17:01 +0000 (13:17 +0200)]
qemu: monitor: Renumber QEMU_MONITOR_MIGRATE_RESUME

Now that all preceding flags were deleted we can fix the enum value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: migration: Remove QEMU_MONITOR_MIGRATE_BACKGROUND
Peter Krempa [Thu, 8 Sep 2022 11:04:54 +0000 (13:04 +0200)]
qemu: migration: Remove QEMU_MONITOR_MIGRATE_BACKGROUND

'qemuMonitorJSONMigrate' is called from:
 - qemuMonitorMigrateToHost
 - qemuMonitorMigrateToSocket
   Both of the above function are called only from
   qemuMigrationSrcStart.

 - qemuMonitorMigrateToFd
   - called from:
     - qemuMigrationSrcToFile
       Both instances here pass QEMU_MONITOR_MIGRATE_BACKGROUND
       directly.
     - qemuMigrationSrcStart

qemuMigrationSrcStart is then called from qemuMigrationSrcRun and
qemuMigrationSrcResume, both of which always add QEMU_MONITOR_MIGRATE_BACKGROUND
to the flags.

Thus any caller always passes the flag so that we can remove the flag
altogether.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: monitor: Drop support for old-style non-shared storage migration
Peter Krempa [Thu, 8 Sep 2022 10:54:57 +0000 (12:54 +0200)]
qemu: monitor: Drop support for old-style non-shared storage migration

Remove the support for enabling the 'blk' and 'inc' parameters of the
'migrate' command as there are no users any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: migration: Don't attempt to fall back to old-style storage migration
Peter Krempa [Thu, 8 Sep 2022 10:48:47 +0000 (12:48 +0200)]
qemu: migration: Don't attempt to fall back to old-style storage migration

QEMU supported the NBD server required for the new-style migration for a
long time already and when coupled with -blockdev the old style
migration doesn't even work, thus remove support for it.

This patch modifies the code to check that the destination returned data
for the NBD migration and returns an error if it did not and deletes the
fallback code paths which would not work.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: capabilities: Retire QEMU_CAPS_NBD_SERVER
Peter Krempa [Thu, 8 Sep 2022 10:44:01 +0000 (12:44 +0200)]
qemu: capabilities: Retire QEMU_CAPS_NBD_SERVER

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: migration: Always assume support for QEMU_CAPS_NBD_SERVER
Peter Krempa [Thu, 8 Sep 2022 10:41:49 +0000 (12:41 +0200)]
qemu: migration: Always assume support for QEMU_CAPS_NBD_SERVER

The NBD server (detected via 'nbd-server-start' qmp command) was added
to qemu in v1.3 and can't be compiled out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: Mention that non-shared storage migration was broken in libvirt-8.7
Peter Krempa [Thu, 8 Sep 2022 10:38:28 +0000 (12:38 +0200)]
NEWS: Mention that non-shared storage migration was broken in libvirt-8.7

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: migration: Fix setup of non-shared storage migration in qemuMigrationSrcBeginPhase
Peter Krempa [Thu, 8 Sep 2022 09:55:08 +0000 (11:55 +0200)]
qemu: migration: Fix setup of non-shared storage migration in qemuMigrationSrcBeginPhase

In commit 6111b2352242e9 removing pre-blockdev code paths I've
improperly refactored the setup of non-shared storage migration.

Specifically the code checking that there are disks and setting up the
NBD data in the migration cookie was originally outside of the loop
checking the user provided list of specific disks to migrate, but became
part of the block as it was not un-indented when a higher level block
was being removed.

The above caused that if non-shared storage migration is requested, but
the user doesn't provide the list of disks to migrate (thus implying to
migrate every appropriate disk) the code doesn't actually setup the
migration and then later on falls back to the old-style migration which
no longer works with blockdev.

Move the check that there's anything to migrate out of the
'nmigrate_disks' block.

Fixes: 6111b2352242e93c6d2c29f9549d596ed1056ce5
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2125111
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/373
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 6 Sep 2022 19:19:31 +0000 (21:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 44.5% (4654 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoRevert "conf: clean up memory containing secrets before freeing"
Peter Krempa [Wed, 7 Sep 2022 11:09:13 +0000 (13:09 +0200)]
Revert "conf: clean up memory containing secrets before freeing"

Adding supposedly secure cleanup for secrets in anything related to the
XML parser is pointless because there are multiple other un-sanitized
copies of the full XML and the XML parser state at the very least.

Similarly in case RPC was used to transport the XML the RPC buffers are
not sanitized.

Additionally this patch was incomplete as it didn't sanitize the
password in the cleanup function for virDomainGraphicsAuthDef.

This reverts commit 51f8130d78fde3201b49c02b7095ff918b6e658a

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu & conf: move BeginNestedJob & BeginJobNowait into src/conf
Kristina Hanicova [Mon, 5 Sep 2022 13:57:15 +0000 (15:57 +0200)]
qemu & conf: move BeginNestedJob & BeginJobNowait into src/conf

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu & conf: move BeginAsyncJob & EndAsyncJob into src/conf
Kristina Hanicova [Mon, 5 Sep 2022 13:57:14 +0000 (15:57 +0200)]
qemu & conf: move BeginAsyncJob & EndAsyncJob into src/conf

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu & conf: move BeginAgentJob & EndAgentJob into src/conf/virdomainjob
Kristina Hanicova [Mon, 5 Sep 2022 13:57:13 +0000 (15:57 +0200)]
qemu & conf: move BeginAgentJob & EndAgentJob into src/conf/virdomainjob

Although these and functions in the following two patches are for
now just being used by the qemu driver, it makes sense to have all
begin job functions in the same file.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoCH: use virDomainObjEndJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:12 +0000 (15:57 +0200)]
CH: use virDomainObjEndJob()

This patch removes virCHDomainObjEndJob() and replaces it with
call to the generalized virDomainObjEndJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoLXC: use virDomainObjEndJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:11 +0000 (15:57 +0200)]
LXC: use virDomainObjEndJob()

This patch removes virLXCDomainObjEndJob() and replaces it with
call to the generalized virDomainObjEndJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agolibxl: use virDomainObjEndJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:10 +0000 (15:57 +0200)]
libxl: use virDomainObjEndJob()

This patch removes libxlDomainObjEndJob() and replaces it with
call to the generalized virDomainObjEndJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: use virDomainObjEndJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:09 +0000 (15:57 +0200)]
qemu: use virDomainObjEndJob()

This patch moves qemuDomainObjEndJob() into
src/conf/virdomainjob as universal virDomainObjEndJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoCH: use virDomainObjBeginJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:08 +0000 (15:57 +0200)]
CH: use virDomainObjBeginJob()

This patch removes virCHDomainObjBeginJob() and replaces it with
call to the generalized virDomainObjBeginJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoLXC: use virDomainObjBeginJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:07 +0000 (15:57 +0200)]
LXC: use virDomainObjBeginJob()

This patch removes virLXCDomainObjBeginJob() and replaces it with
call to the generalized virDomainObjBeginJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agolibxl: use virDomainObjBeginJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:06 +0000 (15:57 +0200)]
libxl: use virDomainObjBeginJob()

This patch removes libxlDomainObjBeginJob() and replaces it with
generalized virDomainObjBeginJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: use virDomainObjBeginJob()
Kristina Hanicova [Mon, 5 Sep 2022 13:57:05 +0000 (15:57 +0200)]
qemu: use virDomainObjBeginJob()

This patch moves qemuDomainObjBeginJob() into
src/conf/virdomainjob as universal virDomainObjBeginJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agovirdomainjob: make drivers use job object in the domain object
Kristina Hanicova [Mon, 5 Sep 2022 13:57:04 +0000 (15:57 +0200)]
virdomainjob: make drivers use job object in the domain object

This patch uses the job object directly in the domain object and
removes the job object from private data of all drivers that use
it as well as other relevant code (initializing and freeing the
structure).

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: extend xmlopt with job config & add job object into domain object
Kristina Hanicova [Mon, 5 Sep 2022 13:57:03 +0000 (15:57 +0200)]
conf: extend xmlopt with job config & add job object into domain object

This patch adds the generalized job object into the domain object
so that it can be used by all drivers without the need to extract
it from the private data.

Because of this, the job object needs to be created and set
during the creation of the domain object. This patch also extends
xmlopt with possible job config containing virDomainJobObj
callbacks, its private data callbacks and one variable
(maxQueuedJobs).

This patch includes:
* addition of virDomainJobObj into virDomainObj (used in the
  following patches)
* extending xmlopt with job config structure
* new function for freeing the virDomainJobObj

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agovirdomainjob: add check for callbacks
Kristina Hanicova [Mon, 5 Sep 2022 13:57:02 +0000 (15:57 +0200)]
virdomainjob: add check for callbacks

There may be a case that the callback structure will exist with
no callbacks (following patches). This patch adds check for
specific callbacks before using them.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agomove files: hypervisor/domain_job -> conf/virdomainjob
Kristina Hanicova [Mon, 5 Sep 2022 13:57:01 +0000 (15:57 +0200)]
move files: hypervisor/domain_job -> conf/virdomainjob

The following patches move job object as a member into the domain
object.  Because of this, domain_conf (where the domain object is
defined) needs to import the file with the job object.

It makes sense to move jobs to the same level as the domain_conf:
into src/conf/

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agolibxl: remove usage of virDomainJobData
Kristina Hanicova [Mon, 5 Sep 2022 13:57:00 +0000 (15:57 +0200)]
libxl: remove usage of virDomainJobData

Struct virDomainJobData is meant for statistics for async jobs.
It was used to keep track of only two attributes, one of which is
also in the generalized virDomainJobObj ("started") and one which
is always set to the same value, if any job is active
("jobType").

This patch removes usage & allocation of virDomainJobData
structure and rewrites libxlDomainJobUpdateTime() into more
suitable libxlDomainJobGetTimeElapsed().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjBeginJobInternal() into hypervisor
Kristina Hanicova [Mon, 5 Sep 2022 13:56:59 +0000 (15:56 +0200)]
qemu & hypervisor: move qemuDomainObjBeginJobInternal() into hypervisor

This patch moves qemuDomainObjBeginJobInternal() as
virDomainObjBeginJobInternal() into hypervisor in order to be
used by other hypervisors in the following patches.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: do not probe for properties of nec-usb-xhci
Ján Tomko [Thu, 25 Aug 2022 15:56:27 +0000 (17:56 +0200)]
qemu: do not probe for properties of nec-usb-xhci

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: remove qemuValidateDomainVirtioOptions
Ján Tomko [Thu, 25 Aug 2022 15:48:20 +0000 (17:48 +0200)]
qemu: remove qemuValidateDomainVirtioOptions

Now that we assume all the virtio capabilities, this function does not
check anything.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: retire QEMU_CAPS_VIRTIO_PACKED_QUEUES
Ján Tomko [Thu, 25 Aug 2022 15:47:11 +0000 (17:47 +0200)]
qemu: retire QEMU_CAPS_VIRTIO_PACKED_QUEUES

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: assume QEMU_CAPS_VIRTIO_PACKED_QUEUES
Ján Tomko [Thu, 25 Aug 2022 15:40:44 +0000 (17:40 +0200)]
qemu: assume QEMU_CAPS_VIRTIO_PACKED_QUEUES

Added by QEMU commit:

commit 74b3e46630446568aecb0be1c77c4875d7a52f6d
Author:     Jason Wang <jasowang@redhat.com>
CommitDate: 2019-10-25 07:46:22 -0400

    virtio: add property to enable packed virtqueue

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
    Message-Id: <20191025083527.30803-9-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
git describe: v4.1.0-1780-g74b3e46630 contains: v4.2.0-rc0~32^2~17

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: retire QEMU_CAPS_VIRTIO_SCSI_IOTHREAD
Ján Tomko [Thu, 25 Aug 2022 15:32:19 +0000 (17:32 +0200)]
qemu: retire QEMU_CAPS_VIRTIO_SCSI_IOTHREAD

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: assume QEMU_CAPS_VIRTIO_SCSI_IOTHREAD
Ján Tomko [Thu, 25 Aug 2022 15:29:48 +0000 (17:29 +0200)]
qemu: assume QEMU_CAPS_VIRTIO_SCSI_IOTHREAD

All the supported QEMU versions should have iothread support
on the virtio-scsi controllers if they are compiled in.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: retire QEMU_CAPS_NEC_USB_XHCI_PORTS
Ján Tomko [Mon, 22 Aug 2022 14:50:27 +0000 (16:50 +0200)]
qemu: retire QEMU_CAPS_NEC_USB_XHCI_PORTS

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: assume QEMU_CAPS_NEC_USB_XHCI_PORTS
Ján Tomko [Mon, 22 Aug 2022 14:49:17 +0000 (16:49 +0200)]
qemu: assume QEMU_CAPS_NEC_USB_XHCI_PORTS

Introduced by QEMU commit 0846e6359c407e372f446723b8b7b09ac20d0f03
released in QEMU 1.3.0

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: retire QEMU_CAPS_CHARDEV_LOGFILE
Ján Tomko [Mon, 22 Aug 2022 14:36:08 +0000 (16:36 +0200)]
qemu: retire QEMU_CAPS_CHARDEV_LOGFILE

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: assume QEMU_CAPS_CHARDEV_LOGFILE
Ján Tomko [Mon, 22 Aug 2022 14:34:44 +0000 (16:34 +0200)]
qemu: assume QEMU_CAPS_CHARDEV_LOGFILE

Introduced in QEMU 2.6

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: retire QEMU_CAPS_CHARDEV_FILE_APPEND
Ján Tomko [Mon, 22 Aug 2022 14:32:45 +0000 (16:32 +0200)]
qemu: retire QEMU_CAPS_CHARDEV_FILE_APPEND

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: assume QEMU_CAPS_CHARDEV_FILE_APPEND
Ján Tomko [Mon, 22 Aug 2022 14:30:41 +0000 (16:30 +0200)]
qemu: assume QEMU_CAPS_CHARDEV_FILE_APPEND

Introduced in QEMU 2.6

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoFix some coding style issues
jiangjiacheng [Tue, 6 Sep 2022 13:48:31 +0000 (21:48 +0800)]
Fix some coding style issues

Fix some coding style issues with alignment and spaces.

Signed-off-by: jiangjiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoremote: remove unnecessary return value and if branch
jiangjiacheng [Tue, 6 Sep 2022 13:48:30 +0000 (21:48 +0800)]
remote: remove unnecessary return value and if branch

Function daemonConfigFilePath() will assign a path to
remote_config_file definitely and the path will be validated
in following codes. So, it's unnecessary to return value
from daemonConfigFilePath() and check the returned value.

Signed-off-by: jiangjiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoconf: clean up memory containing secrets before freeing
jiangjiacheng [Tue, 6 Sep 2022 13:48:29 +0000 (21:48 +0800)]
conf: clean up memory containing secrets before freeing

The password may not be valid in the error branch, but for
higher security, it's better to clean up the memory before
freeing it.

Signed-off-by: jiangjiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agocpu_map: Introduce Fujitsu a64fx
Liu Yiding [Fri, 2 Sep 2022 03:02:37 +0000 (03:02 +0000)]
cpu_map: Introduce Fujitsu a64fx

Add Fujitsu a64fx as a supported cpu model.

Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu: Make qemuMigrationSrcCancel optionally synchronous
Jiri Denemark [Tue, 6 Sep 2022 16:21:31 +0000 (18:21 +0200)]
qemu: Make qemuMigrationSrcCancel optionally synchronous

We have always considered "migrate_cancel" QMP command to return after
successfully cancelling the migration. But this is no longer true (to be
honest I'm not sure it ever was) as it just changes the migration state
to "cancelling". In most cases the migration is canceled pretty quickly
and we don't really notice anything, but sometimes it takes so long we
even get to clearing migration capabilities before the migration is
actually canceled, which fails as capabilities can only be changed when
no migration is running. So to avoid this issue, we can wait for the
migration to be really canceled after sending migrate_cancel. The only
place where we don't need synchronous behavior is when we're cancelling
migration on user's request while it is actively watched by another
thread.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Create wrapper for qemuMonitorMigrateCancel
Jiri Denemark [Tue, 30 Aug 2022 10:29:02 +0000 (12:29 +0200)]
qemu: Create wrapper for qemuMonitorMigrateCancel

We will need a little bit more code around qemuMonitorMigrateCancel to
make sure it works as expected. The new qemuMigrationSrcCancel helper
will avoid repeating the code in several places.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Rename qemuMigrationSrcCancel
Jiri Denemark [Tue, 30 Aug 2022 09:18:06 +0000 (11:18 +0200)]
qemu: Rename qemuMigrationSrcCancel

Let's call this qemuMigrationSrcCancelUnattended as the function is
supposed to be used when no other thread is watching the migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_driver: Fix order of arguments in qemuDomainGetStatsCpuProc()
Michal Privoznik [Tue, 6 Sep 2022 15:24:38 +0000 (17:24 +0200)]
qemu_driver: Fix order of arguments in qemuDomainGetStatsCpuProc()

Just before pushing my earlier commit I've switch order of two
arguments of virProcessGetStatInfo() (as suggested in review).
However, I forgot to swap the arguments in
qemuDomainGetStatsCpuProc() which leads to userTime and sysTime
being swapped.

Fixes: 044b8744d65f8571038f85685b3c4b241162977b
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoutil: virFileIsSharedFSType: Simplify shared fs type declarations
Peter Krempa [Mon, 5 Sep 2022 12:28:29 +0000 (14:28 +0200)]
util: virFileIsSharedFSType: Simplify shared fs type declarations

Use approach similar to virFileIsSharedFsFUSE to declaratively handle
the filesystem magic numbers mapping to libvirt's fstypes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: virfile: Drop QB_MAGIC constant
Peter Krempa [Mon, 5 Sep 2022 12:13:34 +0000 (14:13 +0200)]
util: virfile: Drop QB_MAGIC constant

The filesystem type magic constant was added for the 'quobyte' shared
filesystem in commit 451094bd153 but is present neither in the kernel
sources nor in coreutils which we've historically used as source of
information.

Since the code dealing with FUSE-based filesystems doesn't need the
constant we can remove it and the now-dead check for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: virfile: Don't use VIR_FILE_SHFS_GFS2 for glusterfs
Peter Krempa [Mon, 5 Sep 2022 12:10:50 +0000 (14:10 +0200)]
util: virfile: Don't use VIR_FILE_SHFS_GFS2 for glusterfs

While the code works properly as no code path is specifically wanting to
check for glusterfs, we should properly declare glusterfs as a separate
from GFS2.

Fixes: 478da65fb46
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: virfile: Rewrite matching of FUSE-based shared filesystems
Peter Krempa [Mon, 5 Sep 2022 12:05:55 +0000 (14:05 +0200)]
util: virfile: Rewrite matching of FUSE-based shared filesystems

'virFileIsSharedFixFUSE' was used to update the 'f_type' field for
certain shared filesystem types.

This patch renames it to 'virFileIsSharedFsFUSE' and makes it directly
return whether the FUSE filesystem is shared or not and simplifies
additions to the list of shared FUSE filesystems.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: virFileIsSharedFixFUSE: Refactor cleanup
Peter Krempa [Mon, 5 Sep 2022 11:57:18 +0000 (13:57 +0200)]
util: virFileIsSharedFixFUSE: Refactor cleanup

Automatically free memory of 'canonPath' so that the failure of
'setmntent' doesn't have to go to 'cleanup'. This allows us to remove
the cleanup section and the 'ret' variable as the rest of the function
can't fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: virFileIsSharedFSType: Annotate (some) shared filesystem names
Peter Krempa [Mon, 5 Sep 2022 10:39:10 +0000 (12:39 +0200)]
util: virFileIsSharedFSType: Annotate (some) shared filesystem names

Expand some of the uncommon or unobvious filesystem names in a comment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: virFileIsSharedFSType: Pass bitmap of checked fs types as unsigned
Peter Krempa [Mon, 5 Sep 2022 09:34:32 +0000 (11:34 +0200)]
util: virFileIsSharedFSType: Pass bitmap of checked fs types as unsigned

We populate the bits individually so unsigned is the proper type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: qemuxml2argvdata: Remove two unused output files
Peter Krempa [Mon, 5 Sep 2022 15:22:28 +0000 (17:22 +0200)]
tests: qemuxml2argvdata: Remove two unused output files

Commit d7ae7ce363aa51ab46 forgot to clean up unused error output files
'boot-dev+order.err' and 'boot-menu-enable-with-timeout-invalid'
after converting tests to DO_TEST_CAPS_LATEST.

Fixes: d7ae7ce363aa51ab4600261b5934075388843142
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Implement qemuDomainGetStatsCpu fallback for qemu:///session
Michal Privoznik [Tue, 9 Aug 2022 14:16:09 +0000 (16:16 +0200)]
qemu: Implement qemuDomainGetStatsCpu fallback for qemu:///session

For domains started under session URI, we don't set up CGroups
(well, how could we since we're not running as root anyways).
Nevertheless, fetching CPU statistics exits early because of
lacking cpuacct controller. But with recent extension to
virProcessGetStatInfo() we can get the values we need from the
proc filesystem. Implement the fallback for the session URI as
some of virt tools rely on cpu.* stats to be reported (virt-top,
virt-manager).

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/353
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1693707
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: Extend virProcessGetStatInfo() for sysTime and userTime
Michal Privoznik [Tue, 9 Aug 2022 14:15:55 +0000 (16:15 +0200)]
util: Extend virProcessGetStatInfo() for sysTime and userTime

The virProcessGetStatInfo() helper parses /proc stat file for
given PID and/or TID and reports cumulative cpuTime which is just
a sum of user and sys times. But in near future, we'll need those
times separately, so make the function return them too (if caller
desires).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 4 Sep 2022 19:19:31 +0000 (21:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 44.3% (4634 of 10440 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoNEWS: Mention removal of the sheepdog storage driver backend
Peter Krempa [Thu, 1 Sep 2022 11:53:15 +0000 (13:53 +0200)]
NEWS: Mention removal of the sheepdog storage driver backend

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoci: Regenerate dockerfiles after 'sheepdog' removal
Peter Krempa [Thu, 1 Sep 2022 11:37:50 +0000 (13:37 +0200)]
ci: Regenerate dockerfiles after 'sheepdog' removal

After support for the sheepdog storage driver backend was removed we
don't need to install it any longer in the containers.

Regenerate the dockerfiles after:
https://gitlab.com/libvirt/libvirt-ci/-/merge_requests/314

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemucapabilitiestest: Update qemu capabilities for qemu-7.1 release
Peter Krempa [Wed, 27 Jul 2022 08:28:53 +0000 (10:28 +0200)]
qemucapabilitiestest: Update qemu capabilities for qemu-7.1 release

qemu-7.1 is released now. Update the capabilities for the final time.

Notable change since last update:
 - 'exit-failure' action for 'panic' lifecycle action added

The 'min-xlevel' change is related to upgrade of the host kernel.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemuValidateDomainDef: Clarify error message when S390 PV launch security is unsuppor...
Peter Krempa [Tue, 30 Aug 2022 11:46:06 +0000 (13:46 +0200)]
qemuValidateDomainDef: Clarify error message when S390 PV launch security is unsupported by the kernel

Split up the condition and report a different error message when the
host or host config results in S390 PV launch security being
unavailable.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2122534
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
2 years agoqemu: command: Don't use deprecated chardev backend drivers 'tty' and 'parport'
Peter Krempa [Mon, 29 Aug 2022 13:34:56 +0000 (15:34 +0200)]
qemu: command: Don't use deprecated chardev backend drivers 'tty' and 'parport'

The replacement is 'serial' and 'parallel' respectively introduced at
least in qemu-2.9 and the old versions are deprecated since qemu-6.0
(qemu commit 5965243641d797b22 ).

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