]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
19 months agosystemd: Set @name@ for virtlogd/virtlockd
Andrea Bolognani [Tue, 19 Sep 2023 14:24:44 +0000 (16:24 +0200)]
systemd: Set @name@ for virtlogd/virtlockd

The information is not used anywhere right now, but the
documentation for virt_daemon_units claims it's mandatory.
We also intend to actually start using it later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Set Type=notify for virtlogd/virtlockd
Andrea Bolognani [Tue, 19 Sep 2023 18:09:26 +0000 (20:09 +0200)]
systemd: Set Type=notify for virtlogd/virtlockd

This tells systemd that the services in question support the
native socket activation protocol.

virtlogd and virtlockd, just like all the other daemons, implement
the necessary handshake.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Add missing Service for virtlogd/virtlockd
Andrea Bolognani [Tue, 19 Sep 2023 13:20:16 +0000 (15:20 +0200)]
systemd: Add missing Service for virtlogd/virtlockd

While systemd will automatically match foo.socket with foo.service
based on their names, it's nicer to connect the two explicitly.

This is what we do for all services, with virtlogd and virtlockd
being the only exceptions.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Add missing WantedBy for virtlogd/virtlockd
Andrea Bolognani [Mon, 18 Sep 2023 13:25:28 +0000 (15:25 +0200)]
systemd: Add missing WantedBy for virtlogd/virtlockd

This annotation being missing resulted in virtlogd and virtlockd
being marked as "indirect" services, i.e. services that cannot
be started directly but have to be socket activated instead.

While this is our preferred configuration, we shouldn't prevent
the admin to start them at boot if they want to.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Add missing Also for admin socket
Andrea Bolognani [Sun, 12 Mar 2023 16:08:50 +0000 (17:08 +0100)]
systemd: Add missing Also for admin socket

When libvirtd, virtlog and virtlockd are enabled, we want their
admin sockets to be enabled for socket activation as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoUpdate translation files
Weblate [Tue, 26 Sep 2023 09:46:35 +0000 (11:46 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
19 months agopo: Refresh potfile for v9.8.0
Jiri Denemark [Tue, 26 Sep 2023 09:26:58 +0000 (11:26 +0200)]
po: Refresh potfile for v9.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
19 months agoutil: Fix error return for virProcessKillPainfullyDelay()
Jonathon Jongsma [Fri, 22 Sep 2023 19:23:10 +0000 (14:23 -0500)]
util: Fix error return for virProcessKillPainfullyDelay()

Commit 93af79fb removed a cleanup label in favor of returning error
values directly in certain cases. But the final return value was changed
from -1 to 0. If we get to the end of the function, that means that
we've waited for the process to exit but it still exists. So we should
return -1. The error message was still being set correctly, but we were
returning a success status (0).

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agolibxl: Fix connection to modular network daemon
Jim Fehlig [Fri, 22 Sep 2023 18:20:35 +0000 (12:20 -0600)]
libxl: Fix connection to modular network daemon

In a modular daemon configuration, virtxend does not support the
virNetwork* APIs. It should open a connection to virtnetworkd when
using those APIs, but currently always opens a connection to
"xen:///system". Switch to using virGetConnectNetwork to obtain a
valid connection instead of using the hardcoded URI.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agointerface: fix udev_device_get_sysattr_value return value check
Dmitry Frolov [Tue, 12 Sep 2023 12:56:47 +0000 (15:56 +0300)]
interface: fix udev_device_get_sysattr_value return value check

Reviewing the code I found that return value of function
udev_device_get_sysattr_value() is dereferenced without a check.
udev_device_get_sysattr_value() may return NULL by number of reasons.

v2: VIR_DEBUG added, replaced STREQ(NULLSTR()) with STREQ_NULLABLE()
v3: More checks added, to skip earlier. More verbose VIR_DEBUG.

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
19 months agodocs: formatdomain: clarify support of some filesystem options
Ján Tomko [Wed, 20 Sep 2023 15:21:39 +0000 (17:21 +0200)]
docs: formatdomain: clarify support of some filesystem options

Not all are supported by all hypervisors.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
19 months agoqemu: extend filesystem XML validation
Ján Tomko [Wed, 20 Sep 2023 15:17:08 +0000 (17:17 +0200)]
qemu: extend filesystem XML validation

Reject readonly argument for virtiofs and quotas for all filesystems.

https://issues.redhat.com/browse/RHEL-4994
https://issues.redhat.com/browse/RHEL-4432

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
19 months agoqemu: fix indentation in qemuValidateDomainDeviceDefFS
Ján Tomko [Fri, 1 Sep 2023 14:28:01 +0000 (16:28 +0200)]
qemu: fix indentation in qemuValidateDomainDeviceDefFS

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
19 months agovirDomainMemoryDefValidate: Check for overlapping memory devices
Michal Privoznik [Fri, 22 Sep 2023 09:01:40 +0000 (11:01 +0200)]
virDomainMemoryDefValidate: Check for overlapping memory devices

As of v9.4.0-rc2~5 it is possible to specify guest address where
a virtio-mem/virtio-pmem memory device is mapped to. What that
commit forgot to introduce was a check for overlaps.

And yes, this is technically an O(n^2) algorithm, as
virDomainMemoryDefValidate() is called over each memory device
and after this, virDomainMemoryDefValidate() also iterates over
each memory device. But given there's usually only a handful of
such devices, and this runs only when parsing domain XML I guess
code readability wins over some less obvious solution.

Resolves: https://issues.redhat.com/browse/RHEL-4452
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainMemoryDefValidate: Fix VIRTIO_MEM alignment check
Michal Privoznik [Fri, 22 Sep 2023 08:45:50 +0000 (10:45 +0200)]
virDomainMemoryDefValidate: Fix VIRTIO_MEM alignment check

Inside of virDomainMemoryDefValidate() there's a check that
address where a virtio-mem memory device is mapped to is a
multiple of its block size. But this check is off by a couple of
bits, because the memory address is in bytes while the block size
is in kibibytes. Therefore, when checking whether address is a
multiple of the block size, the latter has to be multiplied by a
factor of 1024.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agodomain_validate: Validate VIRTIO_PMEM address alignment
Michal Privoznik [Fri, 22 Sep 2023 08:07:28 +0000 (10:07 +0200)]
domain_validate: Validate VIRTIO_PMEM address alignment

QEMU mandates the VIRTIO_PMEM address is aligned to a pagesize.
This is a very reasonable requirement. So much so, that it
deserves to be in hypervisor agnostic validation code
(virDomainMemoryDefValidate()). Not that any other hypervisor
would support VIRTIO_PMEM yet. But even if they did, this would
surely be still valid.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoqemu: Improve error message for failed firmware autoselection
Andrea Bolognani [Fri, 22 Sep 2023 13:19:46 +0000 (15:19 +0200)]
qemu: Improve error message for failed firmware autoselection

The current message can be misleading, because it seems to suggest
that no firmware of the requested type is available on the system.

What actually happens most of the time, however, is that despite
having multiple firmwares of the right type to choose from, none
of them is suitable because of lacking some specific feature or
being incompatible with some setting that the user has explicitly
enabled.

Providing an error message that describes exactly the problem is
not feasible, since we would have to list each candidate along
with the reason why we rejected it, which would get out of hand
quickly.

As a small but hopefully helpful improvement over the current
situation, reword the error message to make it clearer that the
culprit is not necessarily the firmware type, but rather the
overall domain configuration.

Suggested-by: Michael Kjörling <7d1340278307@ewoof.net>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agotest_driver: Implement virConnectGetDomainCapabilities()
Michal Privoznik [Wed, 20 Sep 2023 16:01:14 +0000 (18:01 +0200)]
test_driver: Implement virConnectGetDomainCapabilities()

Our test driver lacks implementation for
virConnectGetDomainCapabilities(). Provide one, though a trivial
one. Mostly so that something else than VIR_ERR_NO_SUPPORT error
is returned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirerror: Make virReportEnumRangeError() check for type mismatch
Michal Privoznik [Mon, 18 Sep 2023 14:15:33 +0000 (16:15 +0200)]
virerror: Make virReportEnumRangeError() check for type mismatch

As can be seen from previous commits, it's fairly easy to pass a
different type to virReportEnumRangeError() than the actual
variable is of. So far, we have a sizeof() hack to check if some
nonsensical types are not passed, e.g. it catches cases where a
function name is passed instead of an enum. Extend the hack to
check whether proper enum was passed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainVideoDefValidate: Use proper type in virReportEnumRangeError()
Michal Privoznik [Mon, 18 Sep 2023 13:46:21 +0000 (15:46 +0200)]
virDomainVideoDefValidate: Use proper type in virReportEnumRangeError()

The @backend member of _virDomainVideoDef struct is of type
virDomainVideoBackendType. Pass the proper type to
virReportEnumRangeError().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirNetDevVPortProfileOp8021Qbh: Use proper type in virReportEnumRangeError()
Michal Privoznik [Mon, 18 Sep 2023 13:45:52 +0000 (15:45 +0200)]
virNetDevVPortProfileOp8021Qbh: Use proper type in virReportEnumRangeError()

The @virtPortOp variable inside of virNetDevVPortProfileOp8021Qbh
is of type virNetDevVPortProfileLinkOp. Pass the proper type to
virReportEnumRangeError().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirnetdevvportprofile: Turn virNetDevVPortProfileLinkOp enum into a proper typedef
Michal Privoznik [Mon, 18 Sep 2023 13:45:12 +0000 (15:45 +0200)]
virnetdevvportprofile: Turn virNetDevVPortProfileLinkOp enum into a proper typedef

This allows us to declare variables without using 'enum
virNetDev....' and will become more useful in the near future
(when virReportEnumRangeError() is fixed).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoqemu_nbdkit: fix possible null dereference
Pavel Hrdina [Wed, 20 Sep 2023 11:45:59 +0000 (13:45 +0200)]
qemu_nbdkit: fix possible null dereference

Function virGetConnectSecret() can return NULL so we need to check it
since in virSecretGetSecretString() it gets dereferenced.

Reported-by: coverity
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoci: add libnbd to build
Jonathon Jongsma [Tue, 29 Aug 2023 15:13:20 +0000 (10:13 -0500)]
ci: add libnbd to build

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
19 months agorpm: update spec file for for nbdkit support
Jonathon Jongsma [Thu, 20 Jul 2023 17:21:26 +0000 (12:21 -0500)]
rpm: update spec file for for nbdkit support

Require libnbd-devel when building the qemu driver, recommend nbdkit
packages.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: implement ssh-agent auth for ssh disks with nbdkit
Jonathon Jongsma [Fri, 14 Jul 2023 20:54:03 +0000 (15:54 -0500)]
qemu: implement ssh-agent auth for ssh disks with nbdkit

It's not possible to use password-protected ssh keys directly with
libvirt because libvirt doesn't have any way to prompt a user for the
password. To accomodate password-protected key files, an administrator
can add these keys to an ssh agent and then configure the domain with
the path to the ssh-agent socket.

Note that this requires an administrator or management app to
configure the ssh-agent with an appropriate socket path and add the
necessary keys to it. In addition, it does not currently work with
selinux enabled. The ssh-agent socket would need a label that libvirt
would be allowed to access rather than unconfined_t.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoschema: add ssh-agent configuration for ssh disks
Jonathon Jongsma [Fri, 14 Jul 2023 20:14:25 +0000 (15:14 -0500)]
schema: add ssh-agent configuration for ssh disks

Add the ability to specify a path to a ssh-agent socket in order to use
the ssh-agent to authenticate to remote ssh disks. Example
configuration:

    <disk type='network'>
        </source protocol='ssh' ...>
            <identity username='myusername' agentsock='/path/to/socket'/>
            ...
        </source>
        ...
    </disk>

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: implement keyfile auth for ssh disks with nbdkit
Jonathon Jongsma [Thu, 22 Dec 2022 22:56:47 +0000 (16:56 -0600)]
qemu: implement keyfile auth for ssh disks with nbdkit

For ssh disks that are served by nbdkit, we can support logging in with
an ssh key file. Pass the path to the configured key file and the
username to the nbdkit process.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoschema: add keyfile configuration for ssh disks
Jonathon Jongsma [Thu, 19 Jan 2023 21:52:20 +0000 (15:52 -0600)]
schema: add keyfile configuration for ssh disks

Authenticating via key file to an ssh server is often preferable to
logging in via password. In order to support this functionality add a
new <identity> xml element for ssh disks that allows the user to specify
a keyfile and username. Example configuration:

    <disk type='network'>
      <source protocol='ssh' ...>
        <identity keyfile='/path/to/id_rsa' username='myusername'/>
        ...
      </source>
    ...
    </disk>

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: implement knownHosts for ssh disks with nbdkit
Jonathon Jongsma [Thu, 22 Dec 2022 19:04:51 +0000 (13:04 -0600)]
qemu: implement knownHosts for ssh disks with nbdkit

For ssh disks that are served by nbdkit, use the configured value for
knownHosts and pass it to the nbdkit process.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoschema: add configuration for host verification of ssh disks
Jonathon Jongsma [Thu, 19 Jan 2023 21:46:22 +0000 (15:46 -0600)]
schema: add configuration for host verification of ssh disks

In order to make ssh disks usable, we need to be able to validate a
remote host. To do this, add a <knownHosts> xml element for ssh disks to
allow the user to specify a location for a file that contains known host
keys. Implementation to follow.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: implement password auth for ssh disks with nbdkit
Jonathon Jongsma [Wed, 21 Dec 2022 21:42:02 +0000 (15:42 -0600)]
qemu: implement password auth for ssh disks with nbdkit

For ssh disks that are served by nbdkit, lookup the password from the
configured secret and securely pass it to the nbdkit process using fd
passing.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoschema: add password configuration for ssh disk
Jonathon Jongsma [Wed, 21 Dec 2022 20:27:08 +0000 (14:27 -0600)]
schema: add password configuration for ssh disk

Right now, ssh network disks are not usable. There is some basic support
in libvirt that is meant to support disk chains that have backing disks
located at ssh urls, but there is no real way for a user to configure a
ssh-based disk.  This commit allows users to configure an ssh disk with
password authentication. Implementation will follow.

<disk type='network'>
  <source  protocol='ssh' ...>
    <auth username='myusername'>
      <secret type='iscsi' usage='secretname'/>
    </auth>
</disk>

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: try to connect to nbdkit early to detect errors
Jonathon Jongsma [Fri, 16 Dec 2022 23:10:49 +0000 (17:10 -0600)]
qemu: try to connect to nbdkit early to detect errors

When using nbdkit to serve a network disk source, the nbdkit process
will start and wait for an nbd connection before actually attempting to
connect to the (remote) disk location. Because of this, nbdkit will not
report an error until after qemu is launched and tries to read from the
disk. This results in a fairly user-unfriendly error saying that qemu
was unable to start because "Requested export not available".

Ideally we'd like to be able to tell the user *why* the export is not
available, but this sort of information is only available to nbdkit, not
qemu. It could be because the url was incorrect, or because of an
authentication failure, or one of many other possibilities.

To make this friendlier for users and easier to detect
misconfigurations, try to connect to nbdkit immediately after starting
nbdkit and before we try to start qemu. This requires adding a
dependency on libnbd. If an error occurs when connecting to nbdkit, read
back from the nbdkit error log and provide that information in the error
report from qemuNbdkitProcessStart().

User-visible change demonstrated below:
Previous error:

    $ virsh start nbdkit-test
    2023-01-18 19:47:45.778+0000: 30895: error : virNetClientProgramDispatchError:172 : internal
    error: process exited while connecting to monitor: 2023-01-18T19:47:45.704658Z
    qemu-system-x86_64: -blockdev {"driver":"nbd","server":{"type":"unix",
    "path":"/var/lib/libvirt/qemu/domain-1-nbdkit-test/nbdkit-libvirt-1-storage.socket"},
    "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}: Requested export not
    available
    error: Failed to start domain 'nbdkit-test'
    error: internal error: process exited while connecting to monitor: 2023-01-18T19:47:45.704658Z
    qemu-system-x86_64: -blockdev {"driver":"nbd","server":{"type":"unix",
    "path":"/var/lib/libvirt/qemu/domain-1-nbdkit-test/nbdkit-libvirt-1-storage.socket"},
    "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}: Requested export not
    available

After this change:

    $ virsh start nbdkit-test
    2023-01-18 19:44:36.242+0000: 30895: error : virNetClientProgramDispatchError:172 : internal
    error: Failed to connect to nbdkit for 'http://localhost:8888/nonexistent.iso': nbdkit: curl[1]:
    error: problem doing HEAD request to fetch size of URL [http://localhost:8888/nonexistent.iso]:
    HTTP response code said error: The requested URL returned error: 404
    error: Failed to start domain 'nbdkit-test'
    error: internal error: Failed to connect to nbdkit for 'http://localhost:8888/nonexistent.iso]:
    error: problem doing HEAD request to fetch size of URL [http://localhost:8888/nonexistent.iso]:
    HTTP response code said error: The requested URL returned error: 404

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: Monitor nbdkit process for exit
Jonathon Jongsma [Wed, 5 Oct 2022 17:03:33 +0000 (12:03 -0500)]
qemu: Monitor nbdkit process for exit

Adds the ability to monitor the nbdkit process so that we can take
action in case the child exits unexpectedly.

When the nbdkit process exits, we pause the vm, restart nbdkit, and then
resume the vm. This allows the vm to continue working in the event of a
nbdkit failure.

Eventually we may want to generalize this functionality since we may
need something similar for e.g. qemu-storage-daemon, etc.

The process is monitored with the pidfd_open() syscall if it exists
(since linux 5.3). Otherwise it resorts to checking whether the process
is alive once a second. The one-second time period was chosen somewhat
arbitrarily.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: Add Taint for nbdkit restart failure
Jonathon Jongsma [Mon, 21 Aug 2023 21:04:35 +0000 (16:04 -0500)]
qemu: Add Taint for nbdkit restart failure

Since the restart handler will trigger at an arbitrary time (when the
nbdkit process crashes, for instance), it's difficult to provide
feedback to the user if the restart is unsuccessful. Rather than just
relying on a warning in the log, taint the domain so that there will be
a slightly more user-visible notification.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: add test for authenticating a https network disk
Jonathon Jongsma [Thu, 11 Aug 2022 20:08:13 +0000 (15:08 -0500)]
qemu: add test for authenticating a https network disk

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agotests: add tests for nbdkit invocation
Jonathon Jongsma [Fri, 19 Aug 2022 22:21:52 +0000 (17:21 -0500)]
tests: add tests for nbdkit invocation

We were testing the arguments that were being passed to qemu when a disk
was being served by nbdkit, but the arguments used to start nbdkit
itself were not testable. This adds a test to ensure that we're invoking
nbdkit correctly for various disk source definitions.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoutil: make virCommandSetSendBuffer testable
Jonathon Jongsma [Thu, 29 Sep 2022 21:12:55 +0000 (16:12 -0500)]
util: make virCommandSetSendBuffer testable

Add a private function to peek at the list of send buffers in virCommand
so that it is testable

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: use nbdkit to serve network disks if available
Jonathon Jongsma [Fri, 8 Jul 2022 22:13:34 +0000 (17:13 -0500)]
qemu: use nbdkit to serve network disks if available

For virStorageSource objects that contain an nbdkitProcess, start that
nbdkit process to serve that network drive and then pass the nbdkit
socket to qemu rather than sending the network url to qemu directly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: pass sensitive data to nbdkit via pipe
Jonathon Jongsma [Thu, 18 Aug 2022 21:27:46 +0000 (16:27 -0500)]
qemu: pass sensitive data to nbdkit via pipe

Rather than passing passwords and cookies (which could contain
passwords) to nbdkit via commandline arguments, use the alternate format
that nbdkit supports where we can specify a file descriptor which nbdkit
will read to get the password or cookies.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoutil: secure erase virCommand send buffers
Jonathon Jongsma [Tue, 7 Feb 2023 20:05:22 +0000 (14:05 -0600)]
util: secure erase virCommand send buffers

All users of virCommandSetSendBuffer() are using it to send sensitive
data to a child process. So, since these buffers contain sensitive
information, clear it with virSecureErase().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: include nbdkit state in private xml
Jonathon Jongsma [Fri, 8 Jul 2022 15:40:06 +0000 (10:40 -0500)]
qemu: include nbdkit state in private xml

Add xml to the private data for a disk source to represent the nbdkit
process so that the state can be re-created if the libvirt daemon is
restarted. Format:

   <nbdkit>
     <pidfile>/path/to/nbdkit.pid</pidfile>
     <socketfile>/path/to/nbdkit.socket</socketfile>
   </nbdkit>

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: split qemuDomainSecretStorageSourcePrepare
Jonathon Jongsma [Tue, 5 Jul 2022 21:24:55 +0000 (16:24 -0500)]
qemu: split qemuDomainSecretStorageSourcePrepare

This prepares encryption secrets and authentication secrets. When we add
nbdkit-backed network storage sources, we will not need to send
authentication secrets to qemu, since they will be sent to nbdkit
instead. So split this into two different functions.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agotests: add ability to test various nbdkit capabilities
Jonathon Jongsma [Fri, 8 Jul 2022 19:30:30 +0000 (14:30 -0500)]
tests: add ability to test various nbdkit capabilities

Add new DO_TEST_CAPS_LATEST_NBDKIT macro to test xml2argv for various
nbdkit capability scenarios.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: log error output from nbdkit
Jonathon Jongsma [Mon, 12 Dec 2022 21:12:33 +0000 (15:12 -0600)]
qemu: log error output from nbdkit

log stderr and stdout from nbdkit into its own log so that
nbdkit-related issues can be debugged more easily.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: move qemuProcessReadLog() to qemuLogContext
Jonathon Jongsma [Thu, 19 Jan 2023 19:16:01 +0000 (13:16 -0600)]
qemu: move qemuProcessReadLog() to qemuLogContext

This code can be used by the nbdkit implementation for reading back
filtered log data for error reporting. Move it to qemuLogContext so that
it can be shared. Renamed to qemuLogContextReadFiltered().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: Extract qemuDomainLogContext into a new file
Jonathon Jongsma [Thu, 12 Jan 2023 15:51:43 +0000 (09:51 -0600)]
qemu: Extract qemuDomainLogContext into a new file

This will allow us to use it for nbdkit logging in upcoming commits.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoGeneralize qemuDomainLogContextNew()
Jonathon Jongsma [Wed, 11 Jan 2023 19:54:06 +0000 (13:54 -0600)]
Generalize qemuDomainLogContextNew()

Allow to specify a basename for the log file so that
qemuDomainLogContextNew() can be used to create log contexts for
secondary loggers.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: add functions to start and stop nbdkit
Jonathon Jongsma [Fri, 8 Jul 2022 19:20:20 +0000 (14:20 -0500)]
qemu: add functions to start and stop nbdkit

Add some helper functions to build a virCommand object and run the
nbdkit process for a given virStorageSource.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: query nbdkit module dir from binary
Jonathon Jongsma [Fri, 9 Dec 2022 16:29:25 +0000 (10:29 -0600)]
qemu: query nbdkit module dir from binary

Rather than hard-coding the nbdkit module directory, query the nbdkit
binary for the location to these directories. nbdkit provides a
--dump-config optiont that outputs this information and can be easily
parsed. We can also get the version from this output rather than
executing `nbdkit --version` separately.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: Add qemuNbdkitProcess
Jonathon Jongsma [Tue, 5 Jul 2022 22:00:11 +0000 (17:00 -0500)]
qemu: Add qemuNbdkitProcess

An object for storing information about a nbdkit process that is serving
a specific virStorageSource. At the moment, this information is just
stored in the private data of virStorageSource and not used at all.
Future commits will use this data to actually start a nbdkit process.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: use file cache for nbdkit caps
Jonathon Jongsma [Thu, 21 Jul 2022 22:34:49 +0000 (17:34 -0500)]
qemu: use file cache for nbdkit caps

Add the virFileCache implementation for nbdkit capabilities to the qemu
driver. This allows us to determine whether nbdkit is installed and
which plugins are supported. it also has persistent caching and the
capabilities are re-queried whenever something changes.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: implement persistent file cache for nbdkit caps
Jonathon Jongsma [Fri, 5 Aug 2022 20:24:08 +0000 (15:24 -0500)]
qemu: implement persistent file cache for nbdkit caps

Implement the loadFile and saveFile virFileCacheHandlers callbacks so
that nbdkit capabilities are cached perstistently across daemon
restarts. The format and implementation is modeled on the qemu
capabilities, but simplified slightly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: implement basic virFileCache for nbdkit caps
Jonathon Jongsma [Thu, 21 Jul 2022 22:25:16 +0000 (17:25 -0500)]
qemu: implement basic virFileCache for nbdkit caps

Preparatory step for caching nbdkit capabilities. This patch implements
the newData and isValid virFileCacheHandlers callback functions.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoutil: Allow virFileCache data to be any GObject
Jonathon Jongsma [Wed, 13 Jul 2022 19:55:55 +0000 (14:55 -0500)]
util: Allow virFileCache data to be any GObject

Since the libvirt documentation suggests to prefer GObject over
virObject, and since virObject is a GObject, change virFileCache to
allow GObjects as data.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: expand nbdkit capabilities
Jonathon Jongsma [Thu, 21 Jul 2022 22:16:40 +0000 (17:16 -0500)]
qemu: expand nbdkit capabilities

In order to add caching of the nbdkit capabilities, we will need to
compare against file modification times, etc. So look up this
information when creating the nbdkit caps.

Add a nbdkit_moddir build option to allow the builder to specify the
location to look for nbdkit plugins and filters.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: Add functions for determining nbdkit availability
Jonathon Jongsma [Tue, 5 Jul 2022 20:40:16 +0000 (15:40 -0500)]
qemu: Add functions for determining nbdkit availability

In future commits, we will optionally use nbdkit to serve some remote
disk sources. This patch queries to see whether nbdkit is installed on
the host and queries it for capabilities. The data will be used in later
commits.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoschema: allow 'ssh' as a protocol for network disks
Jonathon Jongsma [Tue, 5 Jul 2022 20:53:57 +0000 (15:53 -0500)]
schema: allow 'ssh' as a protocol for network disks

There was support in the code for parsing protocol='ssh' on network disk
sources, but it was not present in the xml schema. Add this to the
schema.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agolibxl: Fix Domain-0 ballooning logic
Jim Fehlig [Mon, 18 Sep 2023 15:59:39 +0000 (09:59 -0600)]
libxl: Fix Domain-0 ballooning logic

When Domain-0 autoballooning is enabled, it's possible that memory may
need to be ballooned down in Domain-0 to accommodate the needs of another
virtual machine. libxlDomainFreeMemory handles this task, but due to a
logic bug is underflowing the variable containing Domain-0 new
target memory. The resulting huge numbers are filtered by
libxlSetMemoryTargetWrapper and memory is not changed.

Under the covers, libxlDomainFreeMemory uses Xen's libxl_set_memory_target
API, which includes a 'relative' parameter for specifying how to set the
target. If true, the target is an increment/decrement value over the
current memory, otherwise target is taken as an absolute value.
libxlDomainFreeMemory sets 'relative' to true, but never allows for
negative values by declaring the target memory variable as an unsigned.
Fix by declaring the variable as signed, which also requried adjusting
libxlSetMemoryTargetWrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoci: jobs.sh: Define and create SCRATCH_DIR for local executions
Erik Skultety [Wed, 13 Sep 2023 09:49:09 +0000 (11:49 +0200)]
ci: jobs.sh: Define and create SCRATCH_DIR for local executions

Running outside of GitLab will likely not have the variable set and
hence the execution would fail. To make sure we always start with a
clean scratch dir (which may or may not be the best thing), create it
with 'mktemp'. The main reason for a temporary directory is to ensure a
clean environment for the job every time run_integration function is
run. For repeated interactive use case, it is imperative that the
developer takes care of their environment.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: run_integration: Print DAEMONS variable for debugging
Erik Skultety [Wed, 13 Sep 2023 09:21:08 +0000 (11:21 +0200)]
ci: jobs.sh: run_integration: Print DAEMONS variable for debugging

One advantage that GitLab's YAML has with Shell commands is that every
single line is printed out as is, including control structures. In
order to see whether the logic did the same thing and the tests are
going to operate on the right set of daemons (monolithic vs modular),
lets print the DAEMONS variable that we set depending on the distro we
execute the tests on.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: integration: Execute commands via 'run_cmd[_quiet]' helpers
Erik Skultety [Tue, 12 Sep 2023 14:30:19 +0000 (16:30 +0200)]
ci: jobs.sh: integration: Execute commands via 'run_cmd[_quiet]' helpers

Unfortunately, once we go down the line of running our own scripts as
part of GitLab CI jobs rather than open coding Shell in YAML, we lose
the benefit of seeing each line the script executes. The downside of
the default YAML however is that we have to maintain the same piece of
code on 2 places in that case. Let's adopt what we use with other
container jobs and prefix each shell command with 'run_cmd' or
'run_cmd_quiet' which will dump it in the logs before executing.
Flow control expressions and structures are a problem though in this
regard, so let's just print some important values for debugging
purposes.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: Introduce a quiet version of run_cmd
Erik Skultety [Tue, 19 Sep 2023 08:46:08 +0000 (10:46 +0200)]
ci: jobs.sh: Introduce a quiet version of run_cmd

We've started using the run_cmd helper function to log what kind of
command is being executed as well as actually executing the command.
The problem however is doing I/O redirections for commands which we
don't wish to see any output for whatever reason. Now, if the
redirection is applied at parameter passing to run_cmd it's going to be
applied to the debug print as well. Let's introduce another helper,
run_cmd_quiet which takes care of the I/O redirection and executes the
command completely silently.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: run_integration: Make POSIX-compliant
Erik Skultety [Tue, 12 Sep 2023 14:14:47 +0000 (16:14 +0200)]
ci: jobs.sh: run_integration: Make POSIX-compliant

Neither '&>' nor 'source' are defined in POSIX.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: run_integration: Add/Rewrite/Reformat commentaries
Erik Skultety [Fri, 20 Jan 2023 09:10:40 +0000 (10:10 +0100)]
ci: jobs.sh: run_integration: Add/Rewrite/Reformat commentaries

Because of the nature of writing inline shell commands to YAML, most of
the commentaries where inlined with the command not to hinder YAML
readability any further. Since we moved the logic to a standalone
script, we can now do whatever formatting & readability adjustments we
want.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: integration: Use --quiet with virsh
Erik Skultety [Fri, 15 Sep 2023 12:46:39 +0000 (14:46 +0200)]
ci: jobs.sh: integration: Use --quiet with virsh

We've not been interested in any extra output from the command at all
since we always redirected both stdout and stderr to /dev/null. Future
patch will change that slightly, so --quiet will start making sense.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: jobs.sh: Drop comment about the need for Avocado 98.0
Erik Skultety [Fri, 15 Sep 2023 12:41:57 +0000 (14:41 +0200)]
ci: jobs.sh: Drop comment about the need for Avocado 98.0

We needed v98.0 in commit c9a65eb8 due to a bug in Avocado in the past
and have been installing the latest Avocado for a while since commit
91774931, yet we kept the comment by a mistake.

Besides, looks like v98.0 ignores the avocado.config file in the TCK
repo instructing it to run the test suite sequentially leading to test
stability issues, so abandoning the v98.0 in commit 91774931 was a good
thing in the end.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: integration: Drop the 'install-deps' hidden job and reference
Erik Skultety [Fri, 20 Jan 2023 09:19:52 +0000 (10:19 +0100)]
ci: integration: Drop the 'install-deps' hidden job and reference

Since the section now only consists of a single command, we can happily
move the command to the main integration template job body.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: integration: Adjust the check for CentOS Stream version
Erik Skultety [Wed, 13 Sep 2023 15:05:02 +0000 (17:05 +0200)]
ci: integration: Adjust the check for CentOS Stream version

All supported versions of Fedora and CentOS Stream 9 default to modular
setup, it's probably better if we cosmetically adjust the CentOS Stream
version check to make it explicit that monolithic daemon services ought
to be started only on Stream 8.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoci: integration: Extract the integration CI main recipe to jobs.sh
Erik Skultety [Fri, 15 Sep 2023 12:23:21 +0000 (14:23 +0200)]
ci: integration: Extract the integration CI main recipe to jobs.sh

Follow what's been done to other jobs in .gitlab-ci.yml and extract the
shell logic from YAML to a function in ci/jobs.sh

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosyntax-check: Drop the shell's 'check for minus' rule
Erik Skultety [Fri, 27 Jan 2023 07:52:17 +0000 (08:52 +0100)]
syntax-check: Drop the shell's 'check for minus' rule

Apparently we've only had it because the -[ao] options weren't portable
at the time, but according to
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

both are defined in POSIX.1-2017 revision which is old enough for all
our supported platforms to have adopted it already, so we can drop the
check. However, the above has also marked -[ao] as obsolescent stating
that:
   "[OB] Obsolescent

   The functionality described may be removed in a future version of
   this volume of POSIX.1-2017. Strictly Conforming POSIX Applications
   and Strictly Conforming XSI Applications shall not use obsolescent
   features."

It is however unlikely that the shell implementations would drop
support for -[ao] despite POSIX potentially removing them.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosrc: Avoid needless checks before calling g_strdup()
Michal Privoznik [Mon, 18 Sep 2023 09:28:31 +0000 (11:28 +0200)]
src: Avoid needless checks before calling g_strdup()

There are few places where the following pattern occurs:

  if (var)
      other = g_strdup(var);

where @other wasn't initialized before g_strdup(). Checking for
var != NULL is useless in this case, as that's exactly what
g_strdup() does (in which case it returns NULL).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoNEWS: Documnet network metadata change event
K Shiva Kiran [Sun, 3 Sep 2023 16:00:50 +0000 (21:30 +0530)]
NEWS: Documnet network metadata change event

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoexamples: Report network metadata change event
K Shiva Kiran [Sun, 3 Sep 2023 14:58:40 +0000 (20:28 +0530)]
examples: Report network metadata change event

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agonetwork: Emit Emit network metadata change event
K Shiva Kiran [Sun, 3 Sep 2023 14:58:39 +0000 (20:28 +0530)]
network: Emit Emit network metadata change event

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agotest_driver: Emit network metadata change event
K Shiva Kiran [Sun, 3 Sep 2023 14:58:38 +0000 (20:28 +0530)]
test_driver: Emit network metadata change event

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoremote: Implement client side of network netadata change event
K Shiva Kiran [Sun, 3 Sep 2023 14:58:37 +0000 (20:28 +0530)]
remote: Implement client side of network netadata change event

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoconf: Add methods to create Metadata change events
K Shiva Kiran [Sun, 3 Sep 2023 14:58:36 +0000 (20:28 +0530)]
conf: Add methods to create Metadata change events

Adds two new private methods to create metadata change events:
- virNetworkEventMetadataChangeNewFromNet()
- virNetworkEventMetadataChangeNewFromObj()

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoDefine Network Metadata change event
K Shiva Kiran [Sun, 3 Sep 2023 14:58:33 +0000 (20:28 +0530)]
Define Network Metadata change event

When changing the metadata via virNetworkSetMetadata(), we can
now emit an event to notify the app of changes. This is useful
when co-ordinating different applications read/write of custom
metadata.

Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agobhyveBuildControllerArgStr: Fill in missing cases to switch() statement
Michal Privoznik [Fri, 15 Sep 2023 11:26:40 +0000 (13:26 +0200)]
bhyveBuildControllerArgStr: Fill in missing cases to switch() statement

When making 'type' member of virDomainControllerDef to be of
virDomainControllerType rather than an int I forgot to update
bhyve_command.c.

Fixes: 27a653b8931051991d44b8776a8cdc08c666b729
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
19 months agovirDomainDiskSourceNVMeParse: Use virXMLPropULongLong()
Michal Privoznik [Thu, 14 Sep 2023 13:53:12 +0000 (15:53 +0200)]
virDomainDiskSourceNVMeParse: Use virXMLPropULongLong()

Inside of virDomainDiskSourceNVMeParse() we have
virXMLPropString() + virStrToLong_ull() combo. Switch to
virXMLPropULongLong() which does the same thing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirStorageNetHostDef: Convert 'transport' field to proper enum type
Michal Privoznik [Wed, 13 Sep 2023 16:21:21 +0000 (18:21 +0200)]
virStorageNetHostDef: Convert 'transport' field to proper enum type

Convert the field and adjust the XML parsers to use
virXMLPropEnumDefault().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainDeviceInfo: Convert 'type' field to proper enum type
Michal Privoznik [Wed, 13 Sep 2023 16:10:54 +0000 (18:10 +0200)]
virDomainDeviceInfo: Convert 'type' field to proper enum type

Convert the field, adjust the XML parsers to use virXMLPropEnum()
and fill in missing cases to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainWatchdogDef: Convert 'action' field to proper enum type
Michal Privoznik [Tue, 2 May 2023 11:45:44 +0000 (13:45 +0200)]
virDomainWatchdogDef: Convert 'action' field to proper enum type

Convert the field and adjust the XML parser to use
virXMLPropEnumDefault().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainWatchdogDef: Convert 'model' field to proper enum type
Michal Privoznik [Tue, 2 May 2023 11:43:38 +0000 (13:43 +0200)]
virDomainWatchdogDef: Convert 'model' field to proper enum type

Convert the field and adjust the XML parsers to use
virXMLPropEnum().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainRNGDef: Convert 'backend' field to proper enum type
Michal Privoznik [Tue, 2 May 2023 10:29:18 +0000 (12:29 +0200)]
virDomainRNGDef: Convert 'backend' field to proper enum type

Convert the field and adjust the XML parser to use
virXMLPropEnum().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainRNGDef: Convert 'model' field to proper enum type
Michal Privoznik [Tue, 2 May 2023 10:23:45 +0000 (12:23 +0200)]
virDomainRNGDef: Convert 'model' field to proper enum type

Convert the field and adjust the XML parser to use
virXMLPropEnum().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainControllerDef: Convert 'type' field to proper enum type
Michal Privoznik [Tue, 2 May 2023 10:06:42 +0000 (12:06 +0200)]
virDomainControllerDef: Convert 'type' field to proper enum type

Convert the field and fill in missing cases to switch()
statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainHostdevSubsys: Convert 'type' field to proper enum type
Michal Privoznik [Mon, 24 Apr 2023 12:13:53 +0000 (14:13 +0200)]
virDomainHostdevSubsys: Convert 'type' field to proper enum type

Convert the field, and fill in missing cases to switch()
statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainHostdevCaps: Convert 'type' field to proper enum type
Michal Privoznik [Mon, 24 Apr 2023 12:13:32 +0000 (14:13 +0200)]
virDomainHostdevCaps: Convert 'type' field to proper enum type

Convert the field, adjust the XML parsers to use virXMLPropEnum()
and fill in missing cases to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainHostdevDef: Convert 'mode' field to proper enum type
Michal Privoznik [Mon, 24 Apr 2023 11:15:27 +0000 (13:15 +0200)]
virDomainHostdevDef: Convert 'mode' field to proper enum type

Convert the field, adjust the XML parser to use
virXMLPropEnumDefault() and fill in missing cases to switch()
statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainHostdevSubsysSCSIVHost: Convert 'protocol' field to proper enum type
Michal Privoznik [Wed, 13 Sep 2023 12:23:15 +0000 (14:23 +0200)]
virDomainHostdevSubsysSCSIVHost: Convert 'protocol' field to proper enum type

Convert the field and adjust the XML parser to use
virXMLPropEnum().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirDomainHostdevSubsysSCSI: Convert 'protocol' field to proper enum type
Michal Privoznik [Wed, 13 Sep 2023 12:39:00 +0000 (14:39 +0200)]
virDomainHostdevSubsysSCSI: Convert 'protocol' field to proper enum type

Convert the field and adjust the XML parser to use
virXMLPropEnum().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agosrc: Drop needless typecast to virDomainDiskBus
Michal Privoznik [Wed, 13 Sep 2023 15:30:45 +0000 (17:30 +0200)]
src: Drop needless typecast to virDomainDiskBus

The 'bus' member of _virDomainDiskDef is already declared of
virDomainDiskModel type. Hence, there is no need to typecast the
variable when passing to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoqemu_domain_address: Drop needless typecast to virDomainDiskModel
Michal Privoznik [Tue, 2 May 2023 10:19:36 +0000 (12:19 +0200)]
qemu_domain_address: Drop needless typecast to virDomainDiskModel

The 'mode' member of _virDomainDiskDef is already declared of
virDomainDiskModel type. Hence, there is no need to typecast the
variable when passing to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agosrc: Drop needless typecast to virDomainDeviceType
Michal Privoznik [Wed, 13 Sep 2023 15:11:12 +0000 (17:11 +0200)]
src: Drop needless typecast to virDomainDeviceType

The 'type' member of _virDomainDeviceDef is already declared of
virDomainDeviceType type. Hence, there is no need to typecast the
variable when passing to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoqemu: Drop needless typecast to virDomainFSDriverType
Michal Privoznik [Tue, 2 May 2023 10:10:30 +0000 (12:10 +0200)]
qemu: Drop needless typecast to virDomainFSDriverType

The 'fsdriver' member of _virDomainFSDef is already declared of
virDomainFSDriverType type. Hence, there is no need to typecast
the variable when passing to switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoqemu_domain_address: Drop needless typecast in qemuDomainDeviceCalculatePCIConnectFlags()
Michal Privoznik [Tue, 2 May 2023 10:06:30 +0000 (12:06 +0200)]
qemu_domain_address: Drop needless typecast in qemuDomainDeviceCalculatePCIConnectFlags()

Inside of qemuDomainDeviceCalculatePCIConnectFlags() there's a
switch() which typecasts a variable of
virDomainHostdevSubsysSCSIVHostModelType type to the very same
type. This is useless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agosrc: Access hostdev->source.subsys iff VIR_DOMAIN_HOSTDEV_MODE_SUBSYS
Michal Privoznik [Tue, 2 May 2023 08:54:26 +0000 (10:54 +0200)]
src: Access hostdev->source.subsys iff VIR_DOMAIN_HOSTDEV_MODE_SUBSYS

There are few places where a virDomainHostdevDef->source.subsys
is accessed without ->mode being checked. Mind you,
virDomainHostdevDef can be also in
VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES mode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>