]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
18 months agodocs: Fix typos
Han Han [Mon, 9 Oct 2023 01:18:26 +0000 (09:18 +0800)]
docs: Fix typos

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
18 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 7 Oct 2023 20:36:00 +0000 (22:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 51.9% (5407 of 10413 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>
19 months agomeson: Improve nbdkit configurability
Andrea Bolognani [Wed, 4 Oct 2023 22:37:09 +0000 (00:37 +0200)]
meson: Improve nbdkit configurability

Currently, nbdkit support will automatically be enabled as long as
the pidfd_open(2) syscall is available. Optionally, libnbd is used
to generate more user-friendly error messages.

In theory this is all good, since use of nbdkit is supposed to be
transparent to the user. In practice, however, there is a problem:
if support for it is enabled at build time and the necessary
runtime components are installed, nbdkit will always be preferred,
with no way for the user to opt out.

This will arguably be fine in the long run, but right now none of
the platforms that we target ships with a SELinux policy that
allows libvirt to launch nbdkit, and the AppArmor policy that we
maintain ourselves hasn't been updated either.

So, in practice, as of today having nbdkit installed on the host
makes network disks completely unusable unless you're willing to
compromise the overall security of the system by disabling
SELinux/AppArmor.

In order to make the transition smoother, provide a convenient
way for users and distro packagers to disable nbdkit support at
compile time until SELinux and AppArmor are ready.

In the process, detection is completely overhauled. libnbd is
made mandatory when nbdkit support is enabled, since availability
across operating systems is comparable and offering users the
option to make error messages worse doesn't make a lot of sense;
we also make sure that an explicit request from the user to
enable/disable nbdkit support is either complied with, or results
in a build failure when that's not possible. Last but not least,
we avoid linking against libnbd when nbdkit support is disabled.

At the RPM level, we disable the feature when building against
anything older than Fedora 40, which still doesn't have the
necessary SELinux bits but will hopefully gain them by the time
it's released. We also allow nbdkit support to be disabled at
build time the same way as other optional features, that is, by
passing "--define '_without_nbdkit 1'" to rpmbuild. Finally, if
nbdkit support has been disabled, installing libvirt will no
longer drag it in as a (weak) dependency.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
19 months agoqemu: DomainGetGuestVcpusParams: reduce scope of tmp
Ján Tomko [Fri, 29 Sep 2023 12:37:47 +0000 (14:37 +0200)]
qemu: DomainGetGuestVcpusParams: reduce scope of tmp

Wrap the macro body in a new block and move the declaration of 'tmp'
into it, to avoid the need to mix g_autofree with manual freeing.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
19 months agovirsh: Account for return values in virNodeGetFreePages
Martin Kletzander [Tue, 26 Sep 2023 13:20:42 +0000 (15:20 +0200)]
virsh: Account for return values in virNodeGetFreePages

The function returns how many array items were filled in, but virsh
never checked for anything other than errors.  Just to make sure this
does not report invalid data, even though the only possibility would be
reporting 0 free pages, check the returned data so that possible errors
are detected.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit c35ba64d18235bfe35617cb3d6d6cc778f6d166d)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agotest: Fix testNodeGetFreePages
Martin Kletzander [Tue, 26 Sep 2023 12:18:53 +0000 (14:18 +0200)]
test: Fix testNodeGetFreePages

The function is supposed to return the number of items filled into the
array and not zero.  Also change the initialization of the "randomness"
to be based on the startCell so that the values are different for each
cell even for separate calls.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 208569b07b6479e0acd05c5a7e1978b0b641e188)
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoutil: fix success return for virProcessKillPainfullyDelay()
Jonathon Jongsma [Fri, 22 Sep 2023 19:42:42 +0000 (14:42 -0500)]
util: fix success return for virProcessKillPainfullyDelay()

virProcessKillPainfullyDelay() currently almost always returns 1 or -1,
even though the documentation indicates that it should return 0 if the
process was terminated gracefully. But the computation of the return
code is faulty and the only case where it currently returns 0 is when it
is called with the pid of a process that does not exist.

Since no callers ever even distinguish between the 0 and 1 response
codes, simply get rid of the distinction and return 0 for both cases.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agosystemd: Move Documentation lines
Andrea Bolognani [Mon, 25 Sep 2023 14:43:52 +0000 (16:43 +0200)]
systemd: Move Documentation lines

Like the Description, these are intended to be displayed to the
user, so it makes sense to have them towards the top of the file
before all the information that systemd will parse to calculate
dependencies.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Improve and unify unit descriptions
Andrea Bolognani [Mon, 25 Sep 2023 14:06:09 +0000 (16:06 +0200)]
systemd: Improve and unify unit descriptions

Hypervisors are referred to by their user-facing name rather
than the name of their libvirt driver, the monolithic daemon is
explicitly referred to as legacy, and a consistent format is
used throughout.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Add RemoveOnStop=yes to all sockets
Andrea Bolognani [Wed, 27 Sep 2023 15:13:32 +0000 (17:13 +0200)]
systemd: Add RemoveOnStop=yes to all sockets

Currently we only set this for the main sockets, which means
that

  $ systemctl stop virtqemud.socket

will make the socket disappear from the filesystem while

  $ systemctl stop virtqemud-ro.socket

won't. Get rid of this inconsistency.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Add Also between sockets
Andrea Bolognani [Mon, 25 Sep 2023 15:24:34 +0000 (17:24 +0200)]
systemd: Add Also between sockets

This results in all sockets for a service being enabled when a
single one of them is.

The -tcp and -tls sockets are intentionally excluded, because
enabling them should require explicit action on the
administrator's part; moreover, disabling them should not result
in the local sockets being disabled too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop Before=foo.service from sockets
Andrea Bolognani [Mon, 25 Sep 2023 15:18:30 +0000 (17:18 +0200)]
systemd: Drop Before=foo.service from sockets

systemd will automatically infer this dependency based on the
socket's Service=foo.service setting.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop Before=libvirtd from virtlogd/virtlockd
Andrea Bolognani [Mon, 25 Sep 2023 15:15:38 +0000 (17:15 +0200)]
systemd: Drop Before=libvirtd from virtlogd/virtlockd

We have already declared the mirror relationship, so this one
is now redundant.

Moreover, this version was incomplete: it only ever worked for
the monolithic daemon, but the modular daemons for QEMU and Xen
also want the sockets to be active.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Augment Requires/Wants with After
Andrea Bolognani [Mon, 25 Sep 2023 15:16:20 +0000 (17:16 +0200)]
systemd: Augment Requires/Wants with After

Requires/Wants only tells systemd that the corresponding unit
should be started when the current one is, but that could very
well happen in parallel. For virtlogd/virtlockd, we want the
socket to be already active when the hypervisor driver is
started.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Downgrade read-only/admin sockets to Wants
Andrea Bolognani [Wed, 27 Sep 2023 13:44:34 +0000 (15:44 +0200)]
systemd: Downgrade read-only/admin sockets to Wants

Only the main socket is actually necessary for the service to be
usable.

In the past, we've had security issues that could be exploited via
access to the read-only socket, so a security-minded administrator
might consider disabling all optional sockets. This change makes
such a setup possible.

Note that the services will still try to activate all their
sockets on startup, even if they have been disabled. To make sure
that the optional sockets are never started, they will have to be
masked.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Replace Requires with BindTo+After for main socket
Andrea Bolognani [Mon, 25 Sep 2023 15:09:37 +0000 (17:09 +0200)]
systemd: Replace Requires with BindTo+After for main socket

This is the strongest relationship that can be declared between
two units, and causes the service to be terminated immediately
if its main socket disappears. This is the behavior we want.

Note that we don't do the same for the read-only/admin sockets,
because those are not as critical for the core functionality of
services as the main socket it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Make modular daemons conflict with libvirtd
Andrea Bolognani [Mon, 25 Sep 2023 15:24:10 +0000 (17:24 +0200)]
systemd: Make modular daemons conflict with libvirtd

We want to make sure that, at any given time, we have either the
modular daemons or the monolithic one running, never both. In
order to achieve that, make every single modular unit conflict
with the corresponding libvirtd unit.

We set both Conflicts=libvirtd.unit and After=libvirtd.unit: this
tells systemd that, whenever virtfood.unit and libvirtd.unit are
part of the same transaction, the former should win out.

Thanks to this, if both the modular daemons and the monolithic
one have been enabled because of outdated automation or a simple
mistake of the administrator, the request to start libvirtd at
boot will be ignored and the result will be a regular modular
deployment.

If the request to start libvirtd is made when the modular daemons
are already running, we have no way to prevent systemd from
complying with that request; however, thanks to the way the
conflict relationship has been declared, they will be shut down
cleanly before libvirtd is started. From the user's point of
view, the transition from modular to monolithic will be
completely transparent: it's basically the same scenario as a
regular package upgrade, just with an extra twist.

Note that, while switching from modular to monolithic at runtime
happens automatically, going back requires manual intervention,
i.e. starting all the necessary sockets one by one. That's okay:
the goal here is to prevent misconfiguration and force of habit
to accidentally disrupt a working setup, not to encourage the
scenario. In a correctly configured and managed host, it should
never occur.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop parametrization from libvirtd sockets
Andrea Bolognani [Mon, 25 Sep 2023 14:14:43 +0000 (16:14 +0200)]
systemd: Drop parametrization from libvirtd sockets

Up until now the files have been used as template for most
services, but now that those have been converted to common
templates we can drop parametrization and make it clear that
these files are for libvirtd only.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop @deps@
Andrea Bolognani [Tue, 19 Sep 2023 18:49:42 +0000 (20:49 +0200)]
systemd: Drop @deps@

It's no longer used anywhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop libvirtd_socket*_in values
Andrea Bolognani [Thu, 21 Sep 2023 15:39:43 +0000 (17:39 +0200)]
systemd: Drop libvirtd_socket*_in values

Now that the migration to common templates has been completed,
we no longer need these.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtproxyd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:01:03 +0000 (20:01 +0200)]
systemd: Switch virtproxyd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtqemud to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:41:06 +0000 (20:41 +0200)]
systemd: Switch virtqemud to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtlxcd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:35:54 +0000 (20:35 +0200)]
systemd: Switch virtlxcd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtxend to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:32:50 +0000 (20:32 +0200)]
systemd: Switch virtxend to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtchd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:24:01 +0000 (20:24 +0200)]
systemd: Switch virtchd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtvzd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:26:22 +0000 (20:26 +0200)]
systemd: Switch virtvzd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtvboxd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:19:18 +0000 (20:19 +0200)]
systemd: Switch virtvboxd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtstoraged to common templates
Andrea Bolognani [Tue, 19 Sep 2023 17:54:52 +0000 (19:54 +0200)]
systemd: Switch virtstoraged to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtnetworkd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 17:49:05 +0000 (19:49 +0200)]
systemd: Switch virtnetworkd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtsecretd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:15:56 +0000 (20:15 +0200)]
systemd: Switch virtsecretd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtnwfilterd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 18:14:04 +0000 (20:14 +0200)]
systemd: Switch virtnwfilterd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtinterfaced to common templates
Andrea Bolognani [Tue, 19 Sep 2023 17:57:40 +0000 (19:57 +0200)]
systemd: Switch virtinterfaced to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Switch virtnodedevd to common templates
Andrea Bolognani [Tue, 19 Sep 2023 17:33:45 +0000 (19:33 +0200)]
systemd: Switch virtnodedevd to common templates

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Use common templates by default
Andrea Bolognani [Thu, 21 Sep 2023 15:10:56 +0000 (17:10 +0200)]
systemd: Use common templates by default

All services are still listing their input files explicitly, so
no changes to the output files will occur yet.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Introduce common templates
Andrea Bolognani [Tue, 19 Sep 2023 17:28:55 +0000 (19:28 +0200)]
systemd: Introduce common templates

We already use templating to generate sockets, which are all
based off libvirtd's. Push the idea further, and extend it to
cover services as well.

This is more challenging, as the various modular daemons each have
their own needs in terms of what system services needs to be
available before they can be started, which other components of
libvirt they depend on, and so on.

In order to make this sort of per-service tweaks possible, we
introduce a Python script that can merge two systemd units
together. The script is aware of the semantics of systemd's unit
definition format, so it can intelligently merge sections
together.

This generic systemd unit merging mechanism will also supersede
the extremely ad-hoc @deps@ variable, which is currently used in
a single scenario.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Provide all input files explicitly
Andrea Bolognani [Thu, 21 Sep 2023 15:03:19 +0000 (17:03 +0200)]
systemd: Provide all input files explicitly

We're about to change the defaults and start migrating to common
templates: in order to be able to switch units over one at a
time, make the input files that are currently used explicit
rather than implicit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Introduce temporary libvirtd_socket*_in values
Andrea Bolognani [Thu, 21 Sep 2023 14:15:33 +0000 (16:15 +0200)]
systemd: Introduce temporary libvirtd_socket*_in values

These will be useful during the upcoming migration to common
templates for systemd units and will be dropped as soon as all
services have been converted.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Make @service_in@ optional
Andrea Bolognani [Thu, 21 Sep 2023 15:08:28 +0000 (17:08 +0200)]
systemd: Make @service_in@ optional

It is currently considered required, but we're soon going to
provide a default that will be suitable for most services.

Since all services currently provide a value explicitly, we
can implement a default without breaking anything.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Introduce service_in/service_out variables
Andrea Bolognani [Tue, 26 Sep 2023 17:58:00 +0000 (19:58 +0200)]
systemd: Introduce service_in/service_out variables

They're similar to the existing socket_in/socket_out variables
and will make future changes nicer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop Conflicts from virtproxyd sockets
Andrea Bolognani [Tue, 19 Sep 2023 19:07:28 +0000 (21:07 +0200)]
systemd: Drop Conflicts from virtproxyd sockets

The idea behind these is to prevent running both modular daemons
and monolithic daemon at the same time. We will implement a more
effective solution for that shortly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agogitpublish: Add suppresscc option
Erik Skultety [Tue, 19 Sep 2023 09:26:01 +0000 (11:26 +0200)]
gitpublish: Add suppresscc option

send-email scans the commit messages to figure out the default set of
addresses to put into CC, Acked-by/Reviewed-by, etc-by being among
them. We're quite strict about CC-ing people on libvirt-list, since
most developers are subscribed to the list anyway. Respect the rule by
avoiding CCing people solely based on the fact that they've done review
of any of previous revisions.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoPost-release version bump to 9.9.0
Jiri Denemark [Mon, 2 Oct 2023 07:33:28 +0000 (09:33 +0200)]
Post-release version bump to 9.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
19 months agoRelease of libvirt-9.8.0
Jiri Denemark [Mon, 2 Oct 2023 07:31:09 +0000 (09:31 +0200)]
Release of libvirt-9.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
19 months agoTranslated using Weblate (Korean)
김인수 [Sun, 1 Oct 2023 02:35:53 +0000 (04:35 +0200)]
Translated using Weblate (Korean)

Currently translated at 99.7% (10389 of 10413 strings)

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

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
19 months agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Thu, 28 Sep 2023 06:27:27 +0000 (08:27 +0200)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoNEWS: Fix placement of network metadata entry
Michal Privoznik [Fri, 29 Sep 2023 07:21:35 +0000 (09:21 +0200)]
NEWS: Fix placement of network metadata entry

The network metadata support is a new feature in the upcoming
release, not a removed one. Place it accordingly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agoqemu: Add VIR_FREE in ADD_BITMAP
Anastasia Belova [Thu, 28 Sep 2023 11:55:11 +0000 (14:55 +0300)]
qemu: Add VIR_FREE in ADD_BITMAP

virBitmapFormat returns the string that should be freed.

All strings in three ADD_BITMAP calls in qemuDomainGetGuestVcpusParams
are contained in tmp. So memory leak is possible here without VIR_FREE.

Fixes: 0108deb944af5ca6f1da350c9d0352c8ed18738b
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 28 Sep 2023 05:14:11 +0000 (07:14 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10413 of 10413 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
19 months agoTranslated using Weblate (Korean)
김인수 [Thu, 28 Sep 2023 05:14:10 +0000 (07:14 +0200)]
Translated using Weblate (Korean)

Currently translated at 99.7% (10383 of 10413 strings)

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

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
19 months agorpm: Drop with_vz define
Andrea Bolognani [Thu, 28 Sep 2023 13:30:31 +0000 (15:30 +0200)]
rpm: Drop with_vz define

Commit 56edf2fefe30 removed the last use.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agodocs: Go bindings release at the same time as the C library
Andrea Bolognani [Wed, 27 Sep 2023 17:39:47 +0000 (19:39 +0200)]
docs: Go bindings release at the same time as the C library

The actual versioning policy[1] is a bit more nuanced, and in
particular there are scenarios in which the monthly release
is intentionally skipped, but overall it's not inaccurate to
claim that the release cadence of the Go bindings follows the
one of the C library.

[1] https://gitlab.com/libvirt/libvirt-go-module/-/blob/master/VERSIONING.rst

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agonews: document nbdkit support for network disks
Jonathon Jongsma [Tue, 12 Sep 2023 19:55:44 +0000 (14:55 -0500)]
news: document nbdkit support for network disks

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agonews: document support for vdpa block devices
Jonathon Jongsma [Tue, 12 Sep 2023 16:35:48 +0000 (11:35 -0500)]
news: document support for vdpa block devices

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agosystemd: Drop unnecessary uses of @sockprefix@
Andrea Bolognani [Tue, 19 Sep 2023 15:28:30 +0000 (17:28 +0200)]
systemd: Drop unnecessary uses of @sockprefix@

Now that providing the value is optional, we can remove almost
all uses.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Make @sockprefix@ optional
Andrea Bolognani [Tue, 19 Sep 2023 15:25:27 +0000 (17:25 +0200)]
systemd: Make @sockprefix@ optional

For most services, the socket paths can be derived trivially from
the name of the daemon: for virtqemud, for example, they will be

  /run/libvirt/virtqemud-sock
  /run/libvirt/virtqemud-sock-ro
  /run/libvirt/virtqemud-admin-sock

libvirtd and virtproxyd are the exceptions, since their socket
paths will be

  /run/libvirt/libvirt-sock
  /run/libvirt/libvirt-sock-ro
  /run/libvirt/libvirt-admin-sock

So we still need to be able to provide a custom @sockprefix@ in
those cases, but in the most common scenario we can do away with
the requirement by introducing a sensible default.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Drop unnecessary uses of @sockets@
Andrea Bolognani [Tue, 19 Sep 2023 15:34:40 +0000 (17:34 +0200)]
systemd: Drop unnecessary uses of @sockets@

For most services, the value provided explicitly matches the
documented default.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Only set @sockmode@ once
Andrea Bolognani [Tue, 19 Sep 2023 13:36:18 +0000 (15:36 +0200)]
systemd: Only set @sockmode@ once

The decision is based only on whether Polkit support is enabled,
so there's no need to go through it again for every single
service.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Rename @mode@ -> @sockmode@
Andrea Bolognani [Mon, 25 Sep 2023 14:54:37 +0000 (16:54 +0200)]
systemd: Rename @mode@ -> @sockmode@

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agosystemd: Rename socket_in_def -> socket_in_default
Andrea Bolognani [Mon, 25 Sep 2023 14:57:25 +0000 (16:57 +0200)]
systemd: Rename socket_in_def -> socket_in_default

The meaning of the _def suffix might not be immediately obvious,
especially since it's also used to refer to the output of the
meson-gen-def.py script elsewhere in the same file.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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>