]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agovbox: Drop UIUSBCommon::GetEnabled()
Michal Privoznik [Sun, 22 Jan 2023 12:06:31 +0000 (13:06 +0100)]
vbox: Drop UIUSBCommon::GetEnabled()

The UIUSBCommon::GetEnabled() function is not needed really, as
it sets a boolean to true and always succeeds. We can live
without the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop UIUSBCommon::Enable()
Michal Privoznik [Sun, 22 Jan 2023 12:04:52 +0000 (13:04 +0100)]
vbox: Drop UIUSBCommon::Enable()

The UIUSBCommon::Enable() function is no longer needed as it is a
NOP. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop @data and @name from UIHost::CreateHostOnlyNetworkInterface()
Michal Privoznik [Sun, 22 Jan 2023 12:01:41 +0000 (13:01 +0100)]
vbox: Drop @data and @name from UIHost::CreateHostOnlyNetworkInterface()

The @data and @name arguments of
UIHost::CreateHostOnlyNetworkInterface() callback are unused.
Drop them and also their propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop @iid from UISession::OpenExisting()
Michal Privoznik [Sun, 22 Jan 2023 11:49:29 +0000 (12:49 +0100)]
vbox: Drop @iid from UISession::OpenExisting()

The @iid argument of UISession::OpenExisting() callback is
unused. Drop it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop @iid from UISession::Open()
Michal Privoznik [Sun, 22 Jan 2023 11:51:37 +0000 (12:51 +0100)]
vbox: Drop @iid from UISession::Open()

The @iid argument of UISession::Open() callback is unused. Drop
it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop @iid from UIMachine::LaunchVMProcess()
Michal Privoznik [Sun, 22 Jan 2023 11:30:02 +0000 (12:30 +0100)]
vbox: Drop @iid from UIMachine::LaunchVMProcess()

The @iid argument of UIMachine::LaunchVMProcess() callback is
unused. Drop it and also its propagation from parent functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop @mediaChangeOnly from vboxDomainAttachDeviceImpl()
Michal Privoznik [Sun, 22 Jan 2023 12:23:32 +0000 (13:23 +0100)]
vbox: Drop @mediaChangeOnly from vboxDomainAttachDeviceImpl()

The @mediaChangeOnly argument of vboxDomainAttachDeviceImpl()
function is unused. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Drop misleading G_GNUC_UNUSED annotation
Michal Privoznik [Sun, 22 Jan 2023 11:26:26 +0000 (12:26 +0100)]
vbox: Drop misleading G_GNUC_UNUSED annotation

There are few cases where a function argument is marked as
unused, but it's used later in the function. The majority of such
occurrences are in vbox_tmpl.c as a residue of older vbox
versions, but a pair was found in vbox_common.c too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agonetwork: Increase max route size when checking IPv6 forwarding
Brooks Swinnerton [Sat, 21 Jan 2023 00:58:05 +0000 (19:58 -0500)]
network: Increase max route size when checking IPv6 forwarding

In d9ee51e, virNetDevIPCheckIPv6Forwarding was updated to walk the
contents of /proc/net/ipv6_route so that it could check to see if the
RTF_ADDRCONF was set on any IPv6 routes to ultimately determine if
enabling forwarding would result in an error due to accept_ra=1 being
set on the interface.

The implementation added in that commit limited the number of routes
that could be read from /proc/net/ipv6_route to 100_000, each with 150
characters. This is problematic for machines that have a full IPv6
routing table, as the IPv6 routing table has now grown to over 160_000
(it was closer to 100_000 at the time of that commit).

This patch increases the maximum route size from 100_000 to 1_000_000.
While a million routes is somewhat arbitrary, it's meant to be a value
that can be supported for the forseeable future. APNIC, one of the five
regional internet registries, recently published a forecast of IPv6
table growth which anticipates a worst-case growth to 1_000_000 in
January of 2029.

Signed-off-by: Brooks Swinnerton <bswinnerton@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuProcessEventSubmit : Unref event->vm instead of vm
Shaleen Bathla [Tue, 17 Jan 2023 09:22:13 +0000 (14:52 +0530)]
qemuProcessEventSubmit : Unref event->vm instead of vm

In error case, unref event->vm instead of vm. This makes it
easier for the reader to understand as it is the event struct
that's holding the reference.

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodocs: fix passt example
Laine Stump [Wed, 18 Jan 2023 14:07:53 +0000 (09:07 -0500)]
docs: fix passt example

Somehow the example I neglected to fully update the example for the
interface passt backend when the design changed during
development. This fixes the example to reflect what is in the code.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirAuthGetPasswordPath: Use virAuthAskCredential for callback interaction
Peter Krempa [Thu, 8 Dec 2022 15:28:15 +0000 (16:28 +0100)]
virAuthGetPasswordPath: Use virAuthAskCredential for callback interaction

Replace the open-coded variant by the new helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetLibsshAuthenticatePassword: Use virAuthAskPassword instead of virAuthGetPasswor...
Peter Krempa [Thu, 8 Dec 2022 15:24:19 +0000 (16:24 +0100)]
virNetLibsshAuthenticatePassword: Use virAuthAskPassword instead of virAuthGetPasswordPath

virAuthGetPasswordPath can return the same password over and over if
it's configured in the config. We rather want to try that only the first
time and then ask the user instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetLibsshCheckHostKey: Use virAuthAskCredential
Peter Krempa [Thu, 8 Dec 2022 15:13:16 +0000 (16:13 +0100)]
virNetLibsshCheckHostKey: Use virAuthAskCredential

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoutil: virauth: Export virAuthGetCredential
Peter Krempa [Thu, 8 Dec 2022 16:03:42 +0000 (17:03 +0100)]
util: virauth: Export virAuthGetCredential

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetLibsshAuthenticatePrivkeyCb: Use virAuthAskCredential
Peter Krempa [Thu, 8 Dec 2022 15:07:43 +0000 (16:07 +0100)]
virNetLibsshAuthenticatePrivkeyCb: Use virAuthAskCredential

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetLibsshAuthenticateKeyboardInteractive: Use virAuthAskCredential
Peter Krempa [Thu, 8 Dec 2022 15:04:13 +0000 (16:04 +0100)]
virNetLibsshAuthenticateKeyboardInteractive: Use virAuthAskCredential

Rework the code to use the new helper instead of open coding the auth
callback interaction.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoutil: auth: Introduce virAuthAskCredential
Peter Krempa [Thu, 8 Dec 2022 14:55:53 +0000 (15:55 +0100)]
util: auth: Introduce virAuthAskCredential

The helper uses the user-provided auth callbacks to ask the user. The
helper encapsulates the steps we do to query the user in few places into
a common helper which can be then used further.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirnetsshsession: Pass in username via virNetSSHSessionNew rather than auth functions
Peter Krempa [Thu, 8 Dec 2022 14:18:54 +0000 (15:18 +0100)]
virnetsshsession: Pass in username via virNetSSHSessionNew rather than auth functions

We only ever allow one username so there's no point passing it to each
authentication registration function. Additionally the only caller
(virNetClientNewLibSSH2) always passes a username so all the checks were
pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetSSHAuthMethod: Remove unused 'password' field
Peter Krempa [Thu, 8 Dec 2022 13:20:44 +0000 (14:20 +0100)]
virNetSSHAuthMethod: Remove unused 'password' field

None of the callers actually set it. Remove the field and corresponding
logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetSSHSessionAuthAddPrivKeyAuth: Refactor cleanup
Peter Krempa [Thu, 8 Dec 2022 13:18:16 +0000 (14:18 +0100)]
virNetSSHSessionAuthAddPrivKeyAuth: Refactor cleanup

With g_strdup not failing we can remove all of the 'error' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetSSHSessionAuthAddPrivKeyAuth: Remove unused 'password' argument
Peter Krempa [Thu, 8 Dec 2022 13:16:50 +0000 (14:16 +0100)]
virNetSSHSessionAuthAddPrivKeyAuth: Remove unused 'password' argument

The only caller doesn't pass the password. Remove the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoutil: authconfig: Use conteporary and consistent header style
Peter Krempa [Thu, 8 Dec 2022 13:08:28 +0000 (14:08 +0100)]
util: authconfig: Use conteporary and consistent header style

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoutil: authconfig: Use automatic pointer clearing for virAuthConfig
Peter Krempa [Thu, 8 Dec 2022 13:07:19 +0000 (14:07 +0100)]
util: authconfig: Use automatic pointer clearing for virAuthConfig

Fix and clean up the error paths in virAuthConfigNew*.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetLibsshAuthMethod: Drop 'password' field
Peter Krempa [Thu, 8 Dec 2022 12:53:17 +0000 (13:53 +0100)]
virNetLibsshAuthMethod: Drop 'password' field

The field was never populated so we can remove it and all the associated
logic.

Both for password authentication and fetching the password for the
public key we still can use the authentication callbacks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirNetLibsshSessionAuthAddPrivKeyAuth: Drop 'password' argument
Peter Krempa [Thu, 8 Dec 2022 12:50:16 +0000 (13:50 +0100)]
virNetLibsshSessionAuthAddPrivKeyAuth: Drop 'password' argument

The only caller doesn't actually populate it. Remove it to simplify
internals.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovbox: Fix starting domains
Michal Privoznik [Sat, 21 Jan 2023 11:46:05 +0000 (12:46 +0100)]
vbox: Fix starting domains

When starting a VirtualBox domain, we try to guess which frontend
to use. While the whole algorithm looks a bit outdated, it may
happen that we tell VirtualBox to use "gui" frontend, but not
which DISPLAY= to use.

I haven't found any documentation on the algorithm we use, but if
I make us fallback onto DISPLAY=:0 when no other configuration is
found then I'm able to start my guests just fine.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovbox: Fix memleak in _virtualboxCreateMachine()
Michal Privoznik [Sat, 21 Jan 2023 09:25:42 +0000 (10:25 +0100)]
vbox: Fix memleak in _virtualboxCreateMachine()

The _virtualboxCreateMachine() function allocates
@createFlagsUtf16 but never frees it.

==12481== 236 bytes in 2 blocks are definitely lost in loss record 2,060 of 2,216
==12481==    at 0x48407E5: malloc (vg_replace_malloc.c:393)
==12481==    by 0xB6C6D1B: RTStrToUtf16Tag (utf-8.cpp:1033)
==12481==    by 0xB4DB500: _virtualboxCreateMachine (vbox_tmpl.c:634)
==12481==    by 0xB4E68A3: vboxDomainDefineXMLFlags (vbox_common.c:1976)
==12481==    by 0x4C7DF83: virDomainDefineXMLFlags (libvirt-domain.c:6666)
==12481==    by 0x13C2DA: remoteDispatchDomainDefineXMLFlags (remote_daemon_dispatch_stubs.h:5271)
==12481==    by 0x13C265: remoteDispatchDomainDefineXMLFlagsHelper (remote_daemon_dispatch_stubs.h:5252)
==12481==    by 0x4AD9DF7: virNetServerProgramDispatchCall (virnetserverprogram.c:428)
==12481==    by 0x4AD9931: virNetServerProgramDispatch (virnetserverprogram.c:302)
==12481==    by 0x4AE28AC: virNetServerProcessMsg (virnetserver.c:135)
==12481==    by 0x4AE2972: virNetServerHandleJob (virnetserver.c:155)
==12481==    by 0x49BC275: virThreadPoolWorker (virthreadpool.c:164)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: Provide virDomainGetCPUStats() implementation for session connection
Michal Privoznik [Mon, 16 Jan 2023 11:46:09 +0000 (12:46 +0100)]
qemu: Provide virDomainGetCPUStats() implementation for session connection

We have virDomainGetCPUStats() API which offers querying
statistics on host CPU usage by given guest. And it works in two
modes: getting overall stats (@start_cpu == -1, @ncpus == 1) or
getting per host CPU usage.

For the QEMU driver it is implemented by looking into values
stored in corresponding cpuacct CGroup controller. Well, this
works for system instances, where libvirt has permissions to
create CGroups and place QEMU process into them. But it does not
fly for session connection, where no CGroups are set up.

Fortunately, we can do something similar to v8.8.0-rc1~95 and use
virProcessGetStatInfo() to fill the overall stats. Unfortunately,
I haven't found any source of per host CPU usage, so we just
continue throwing an error in that case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agosrc: Don't use virReportSystemError() on virProcessGetStatInfo() failure
Michal Privoznik [Wed, 18 Jan 2023 08:03:29 +0000 (09:03 +0100)]
src: Don't use virReportSystemError() on virProcessGetStatInfo() failure

Firstly, the virProcessGetStatInfo() does not fail really. But
even if it did, it sets correct errno only sometimes (and even
that is done in a helper it's calling - virProcessGetStat() and
even there it's the case only in very few error paths).

Therefore, using virReportSystemError() to report errors is very
misleading. Use plain virReportError() instead. Luckily, there
are only two places where the former was used:
chDomainHelperGetVcpus() and qemuDomainHelperGetVcpus() (not a
big surprise since CH driver is heavily inspired by QEMU driver).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoconf: clarify some external TPM error messages
Ján Tomko [Fri, 20 Jan 2023 11:56:48 +0000 (12:56 +0100)]
conf: clarify some external TPM error messages

Two of the messages referred to 'backend type' when dealing
with the source type and one mentioned the 'client' attribute
from an earlier iteration of the patches, even though the attribute
was later changed to 'connect'.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_interface: Fix managed='no' case when creating an ethernet interface
Michal Privoznik [Mon, 23 Jan 2023 10:42:18 +0000 (11:42 +0100)]
qemu_interface: Fix managed='no' case when creating an ethernet interface

In a recent commit of v9.0.0-rc1~192 I've tried to forbid case
where a TAP device already exists, but at the same time it's
managed by Libvirt (<interface type='ethernet'> <target
dev='tap0' managed='yes'/> </interface>). NB, if @managed
attribute is missing then it's assumed to be managed by Libvirt.

Anyway, I've mistakenly put setting of
VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING flag into managed='yes'
branch instead of managed='no' branch in
qemuInterfaceEthernetConnect().

Move the setting of the flag into the correct branch.

Fixes: a2ae3d299cf9c5ada8aa42ec4271748eb479dc27
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovirnetdevtap: Clarify virNetDevTapCreate() behavior wrt VIR_NETDEV_TAP_CREATE_ALLOW_E...
Michal Privoznik [Mon, 23 Jan 2023 10:38:03 +0000 (11:38 +0100)]
virnetdevtap: Clarify virNetDevTapCreate() behavior wrt VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING

The VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING flag is documented as:

  /* The device is allowed to exist before creation */
  VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING     = 1 << 4,

and yet, the documentation to virNetDevTapCreate() documents its
behavior when the flag is passed as:

  *   VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING
  *     - The device creation fails if @ifname already exists

Fortunately, the function is implemented so that it follows the
expected behavior (i.e. the former flag documentation). Fix the
function documentation then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodocs: submitting-patches: remove note about --patience
Ján Tomko [Mon, 9 Jan 2023 17:24:47 +0000 (18:24 +0100)]
docs: submitting-patches: remove note about --patience

Since we don't really say how to send patches using this diff algorithm,
it only clutters the document about *submitting* patches.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agodocs: submitting-patches: Remove emphasis on not cc'ing developers
Ján Tomko [Mon, 9 Jan 2023 17:21:16 +0000 (18:21 +0100)]
docs: submitting-patches: Remove emphasis on not cc'ing developers

While some developers prefer to receive patches only on the mailing
list, cc'ing is a common practice in other projects.

Since it's easy enough to set up a mail filter for this, remove
the paragraph for simplicity.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agosrc/tests: use g_autoptr for virNWFilterDef and virNWFilterRuleDef
Jiang Jiacheng [Tue, 10 Jan 2023 11:29:26 +0000 (19:29 +0800)]
src/tests: use g_autoptr for virNWFilterDef and virNWFilterRuleDef

Use g_autoptr() for virNWFilterDef and virNWFilterRuleDef and remove
unnecessary label.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: define g_autoptr for virNWFilterDef and virNWFilterRuleDef
Jiang Jiacheng [Tue, 10 Jan 2023 11:29:25 +0000 (19:29 +0800)]
conf: define g_autoptr for virNWFilterDef and virNWFilterRuleDef

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: Mention split of libvirt-daemon subpackage
Jim Fehlig [Thu, 5 Jan 2023 17:59:28 +0000 (10:59 -0700)]
NEWS: Mention split of libvirt-daemon subpackage

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agokbase: Update rpm-deployment.rst with new subpackages
Jim Fehlig [Wed, 14 Dec 2022 00:18:10 +0000 (17:18 -0700)]
kbase: Update rpm-deployment.rst with new subpackages

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Remove libvirt-daemon dependency from hypervisor subpackages
Jim Fehlig [Wed, 14 Dec 2022 00:31:01 +0000 (17:31 -0700)]
spec: Remove libvirt-daemon dependency from hypervisor subpackages

Remove the libvirt-daemon dependency from the various
libvirt-daemon-<hypervisor> subpackages, replacing it with a set of the
new sub subpackages providing similar functionality. When libvirt is build
with modular daemons, the hypervisor subpackages no longer include the
traditional, monolithic libvirt daemon.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agospec: Remove libvirt-daemon dependency from primary drivers
Jim Fehlig [Wed, 11 Jan 2023 21:17:32 +0000 (14:17 -0700)]
spec: Remove libvirt-daemon dependency from primary drivers

To avoid needlessly installing the monolithic daemon, replace the
libvirt-daemon dependency with libvirt-daemon-common in the primary
drivers.

The qemu driver also needs a dependency on libvirt-daemon-log since
the virtqemud systemd service file has a hard dependency on
virtlogd.socket.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoservices: Weaken systemd dependency on virtlockd
Jim Fehlig [Fri, 13 Jan 2023 19:04:28 +0000 (12:04 -0700)]
services: Weaken systemd dependency on virtlockd

The systemd service files of the qemu and libxl driver currently have a
'Requires' dependency on virtlockd, which is too strong since virtlockd
is not enabled by default in either driver. Change the dependency to a
'Wants' to avoid a package dependency between the driver subpackages and
the new libvirt-daemon-lock subpackage.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agospec: Remove libvirt-daemon dependency from secondary drivers
Jim Fehlig [Wed, 14 Dec 2022 00:31:00 +0000 (17:31 -0700)]
spec: Remove libvirt-daemon dependency from secondary drivers

To avoid needlessly installing the monolithic daemon, replace the
libvirt-daemon dependency with libvirt-daemon-common in the secondary
drivers. The common subpackage contains all the utilities and files
needed by the secondary drivers.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Add numad dependency to qemu and lxc drivers
Jim Fehlig [Tue, 20 Dec 2022 04:18:26 +0000 (21:18 -0700)]
spec: Add numad dependency to qemu and lxc drivers

Both drivers use numad via virNumaGetAutoPlacementAdvice. Drop the numad
dependency from libvirt-daemon-common to avoid enforcing it all users of
the subpackage.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Add module-init-tools dependency to nodedev and lxc drivers
Jim Fehlig [Tue, 20 Dec 2022 00:38:31 +0000 (17:38 -0700)]
spec: Add module-init-tools dependency to nodedev and lxc drivers

Only the nodedev and lxc drivers require module-init-tools. Remove the
dependency from libvirt-daemon-common and add it to the nodedev and lxc
drivers. This avoids enforcing the dependency on all users of
libvirt-daemon-common.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Move common files and dependencies to libvirt-daemon-common
Jim Fehlig [Wed, 14 Dec 2022 00:30:59 +0000 (17:30 -0700)]
spec: Move common files and dependencies to libvirt-daemon-common

Introduce a new subpackage libvirt-daemon-common and move virt-admin,
virt-host-validate, virt-ssh-helper, libvirt-guests and miscellaneous
files/directories to it. Also move common dependencies to the new
subpackage. These files, utilities, and dependecies are used by other
core libvirt daemons

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agospec: Rename the libvirt-lock-sanlock subpackage
Jim Fehlig [Wed, 14 Dec 2022 00:30:58 +0000 (17:30 -0700)]
spec: Rename the libvirt-lock-sanlock subpackage

The new name "libvirt-daemon-plugin-sanlock" provides consistency with the
newly introduced "libvirt-daemon-plugin-lockd" subpackage.

It's also a good opportunity to taking ownership of
%{_libdir}/libvirt/lock-driver/, removing the need for a dependency on the
libvirt-daemon package.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agospec: Move lockd plugin to a new subpackage
Jim Fehlig [Fri, 2 Dec 2022 18:24:27 +0000 (11:24 -0700)]
spec: Move lockd plugin to a new subpackage

Introduce the libvirt-daemon-plugin-lockd subpackage to provide the
client-side lockd plugin for virtlockd.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Move virtproxyd to a new subpackage libvirt-daemon-proxy
Jim Fehlig [Thu, 1 Dec 2022 23:24:18 +0000 (16:24 -0700)]
spec: Move virtproxyd to a new subpackage libvirt-daemon-proxy

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Move virtlogd to a new subpackage libvirt-daemon-log
Jim Fehlig [Thu, 1 Dec 2022 23:08:22 +0000 (16:08 -0700)]
spec: Move virtlogd to a new subpackage libvirt-daemon-log

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Move virtlockd to a new subpackage libvirt-daemon-lock
Jim Fehlig [Thu, 1 Dec 2022 22:22:32 +0000 (15:22 -0700)]
spec: Move virtlockd to a new subpackage libvirt-daemon-lock

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoapparmor: Allow umount(/dev)
Andrea Bolognani [Wed, 18 Jan 2023 09:28:04 +0000 (10:28 +0100)]
apparmor: Allow umount(/dev)

Commit 379c0ce4bfed introduced a call to umount(/dev) performed
inside the namespace that we run QEMU in.

As a result of this, on machines using AppArmor, VM startup now
fails with

  internal error: Process exited prior to exec: libvirt:
  QEMU Driver error: failed to umount devfs on /dev: Permission denied

The corresponding denial is

  AVC apparmor="DENIED" operation="umount" profile="libvirtd"
      name="/dev/" pid=70036 comm="rpc-libvirtd"

Extend the AppArmor configuration for virtqemud and libvirtd so
that this operation is allowed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2 years agoch: use CURLOPT_UPLOAD instead of CURLOPT_PUT
Daniel P. Berrangé [Wed, 18 Jan 2023 09:45:52 +0000 (09:45 +0000)]
ch: use CURLOPT_UPLOAD instead of CURLOPT_PUT

The CURLOPT_PUT constant causes a deprecation warning when compiling on
Alpine Edge.  The docs indicate it is deprecated since 7.2.1

  https://curl.se/libcurl/c/CURLOPT_PUT.html

Since 7.87 the deprecation is now exposed at build time via a compiler
warning.

We already use CURLOPT_UPLOAD in the ESX driver, so this brings the CH
driver into line.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoremote: add missing lock guard for secret value API
Daniel P. Berrangé [Wed, 18 Jan 2023 12:53:53 +0000 (12:53 +0000)]
remote: add missing lock guard for secret value API

This fixes a bug in

  commit fda53ab3a536647192dd088672dcb6f4a6820e51
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Dec 22 10:29:32 2022 -0500

    remote: use VIR_LOCK_GUARD in client code

Reviewed-by: Erik Skultety <eskultet@redhat>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoremote: remoteDomainCreate: Add missing struct initializer for 'ret2'
Erik Skultety [Wed, 18 Jan 2023 11:33:57 +0000 (12:33 +0100)]
remote: remoteDomainCreate: Add missing struct initializer for 'ret2'

Fixes: 62448c1a4927682f999fecf55e896de4625e46f6
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoadmin: use struct zero initializer instead of memset
Daniel P. Berrangé [Thu, 22 Dec 2022 15:42:20 +0000 (10:42 -0500)]
admin: use struct zero initializer instead of memset

This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoremote: use struct zero initializer instead of memset
Daniel P. Berrangé [Thu, 22 Dec 2022 15:42:20 +0000 (10:42 -0500)]
remote: use struct zero initializer instead of memset

This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agorpc: use struct zero initializer instead of memset
Daniel P. Berrangé [Thu, 22 Dec 2022 15:42:20 +0000 (10:42 -0500)]
rpc: use struct zero initializer instead of memset

This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoadmin: use VIR_LOCK_GUARD in client code
Daniel P. Berrangé [Thu, 22 Dec 2022 15:29:32 +0000 (10:29 -0500)]
admin: use VIR_LOCK_GUARD in client code

Using VIR_LOCK_GUARD enables the 'done' goto label to be
eliminated.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoremote: use VIR_LOCK_GUARD in client code
Daniel P. Berrangé [Thu, 22 Dec 2022 15:29:32 +0000 (10:29 -0500)]
remote: use VIR_LOCK_GUARD in client code

Using VIR_LOCK_GUARD enables the 'done' goto label to be
eliminated.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agorpc: use VIR_LOCK_GUARD in remote client code
Daniel P. Berrangé [Thu, 22 Dec 2022 15:28:50 +0000 (10:28 -0500)]
rpc: use VIR_LOCK_GUARD in remote client code

Using VIR_LOCK_GUARD helps to simplify the control flow
logic.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agologging: remove redundant XDR typedef
Daniel P. Berrangé [Mon, 19 Dec 2022 19:14:36 +0000 (14:14 -0500)]
logging: remove redundant XDR typedef

Every enum/struct/union implicitly includes a typedef in the
emitted C code. Furthermore, the syntax used to declare the
redundant typedef is not compliant with the XDR spec.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agolxc: fix XDR protocol compliance
Daniel P. Berrangé [Mon, 19 Dec 2022 19:13:16 +0000 (14:13 -0500)]
lxc: fix XDR protocol compliance

The RFC spec for XDR does not allow enums to omit their
values, they must be explicitly given. Don't rely on this
rpcgen language extension.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoremote: remove redundant initialization of args variable
Daniel P. Berrangé [Thu, 22 Dec 2022 17:20:32 +0000 (12:20 -0500)]
remote: remove redundant initialization of args variable

Every member of the args variable will be initialized
explicitly. A few methods had a redundant call to memset
the args which can be removed.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agodocs: Fix typo
Andrea Bolognani [Tue, 17 Jan 2023 15:49:44 +0000 (16:49 +0100)]
docs: Fix typo

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: document correct cpu shares limits with both cgroups v1 and v2
Pavel Hrdina [Tue, 17 Jan 2023 09:33:22 +0000 (10:33 +0100)]
docs: document correct cpu shares limits with both cgroups v1 and v2

The limits are different with cgroups v1 and v2 but our XML
documentation and virsh manpage mentioned only cgroups v1 limits without
explicitly saying it only applies to cgroups v1.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agodomain_validate: drop cpu.shares cgroup check
Pavel Hrdina [Tue, 17 Jan 2023 09:08:08 +0000 (10:08 +0100)]
domain_validate: drop cpu.shares cgroup check

This check is done when VM is defined but doesn't take into account what
cgroups version is currently used on the host system so it doesn't work
correctly.

To make proper check at this point we would have to figure out cgroups
version while defining a VM but that will still not guarantee that the
VM will start correctly in the future as the host may be rebooted with
different cgroups version.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agovircgroupv2: fix cpu.weight limits check
Pavel Hrdina [Tue, 17 Jan 2023 09:02:07 +0000 (10:02 +0100)]
vircgroupv2: fix cpu.weight limits check

The cgroup v2 cpu.weight limits are different than cgroup v1 cpu.shares
limits.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agorpm: convert license to SPDX format
Daniel P. Berrangé [Mon, 16 Jan 2023 13:16:57 +0000 (08:16 -0500)]
rpm: convert license to SPDX format

Note that with the introduction of SPDX, Fedora no longer wants
maintainers to do effective license analysis, hence we now list
all the licenses that are applicable to the binary package
contents

  https://docs.fedoraproject.org/en-US/legal/license-field/#_no_effective_license_analysis

Note, we can still omit licenses that are only applicable to
the build system.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoPost-release version bump to 9.1.0
Jiri Denemark [Mon, 16 Jan 2023 10:59:42 +0000 (11:59 +0100)]
Post-release version bump to 9.1.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoRelease of libvirt-9.0.0
Jiri Denemark [Mon, 16 Jan 2023 10:57:28 +0000 (11:57 +0100)]
Release of libvirt-9.0.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Mon, 16 Jan 2023 08:30:07 +0000 (09:30 +0100)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoTranslated using Weblate (Korean)
김인수 [Sun, 15 Jan 2023 04:20:13 +0000 (05:20 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10405 of 10405 strings)

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

Translated using Weblate (Korean)

Currently translated at 99.5% (10363 of 10405 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>
2 years agoNEWS: Document virDomainFDAssociate and NULL dereference in virXMLPropStringRequired
Peter Krempa [Fri, 13 Jan 2023 09:24:38 +0000 (10:24 +0100)]
NEWS: Document virDomainFDAssociate and NULL dereference in virXMLPropStringRequired

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: remove unused qemu .args file
Laine Stump [Fri, 13 Jan 2023 04:42:18 +0000 (23:42 -0500)]
tests: remove unused qemu .args file

net-user-passt.args was generated early during testing of the passt
qemu commandline, when qemuxml2argvtest was using
DO_TEST("net-user-passt"). This was later changed to
DO_TEST_CAPS_LATEST(), so the file net-user-passt.x86_64-latest.args
is used instead, but the original (now unused) test file was
accidentally added to the original patch. This patch removes it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu: remove commented-out option in passt qemu commandline setup
Laine Stump [Fri, 13 Jan 2023 04:42:17 +0000 (23:42 -0500)]
qemu: remove commented-out option in passt qemu commandline setup

This commented-out option was pointed out by jtomko during review, but
I missed taking it out when addressing his comments.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoconf: remove <backend upstream='xxx'/> attribute
Laine Stump [Fri, 13 Jan 2023 04:42:16 +0000 (23:42 -0500)]
conf: remove <backend upstream='xxx'/> attribute

This attribute was added to support setting the --interface option for
passt, but in a post-push/pre-9.0-release review, danpb pointed out
that it would be better to use the existing <source dev='xxx'/>
attribute to set --interface rather than creating a new attribute (in
the wrong place). So we remove backend/upstream, and change the passt
commandline creation to grab the name for --interface from source/dev.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemuBuildThreadContextProps: Generate ThreadContext less frequently
Michal Privoznik [Thu, 5 Jan 2023 08:51:07 +0000 (09:51 +0100)]
qemuBuildThreadContextProps: Generate ThreadContext less frequently

Currently, the ThreadContext object is generated whenever we see
.host-nodes attribute for a memory-backend-* object. The idea was
that when the backend is pinned to a specific set of host NUMA
nodes, then the allocation could be happening on CPUs from those
nodes too. But this may not be always possible.

Users might configure their guests in such way that vCPUs and
corresponding guest NUMA nodes are on different host NUMA nodes
than emulator thread. In this case, ThreadContext won't work,
because ThreadContext objects live in context of the emulator
thread (vCPU threads are moved around by us later, when emulator
thread finished its setup and spawned vCPU threads - see
qemuProcessSetupVcpus()). Therefore, memory allocation is done by
emulator thread which is pinned to a subset of host NUMA nodes,
but tries to create a ThreadContext object with a disjoint subset
of host NUMA nodes, which fails.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2154750
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agosecurity_selinux: Set and restore /dev/sgx_* labels
Michal Privoznik [Tue, 3 Jan 2023 09:29:01 +0000 (10:29 +0100)]
security_selinux: Set and restore /dev/sgx_* labels

For SGX type of memory, QEMU needs to open and talk to
/dev/sgx_vepc and /dev/sgx_provision files. But we do not set nor
restore SELinux labels on these files when starting a guest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: document external swtpm backend addition
Ján Tomko [Wed, 11 Jan 2023 15:04:23 +0000 (16:04 +0100)]
NEWS: document external swtpm backend addition

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoTranslated using Weblate (Korean)
김인수 [Thu, 12 Jan 2023 08:59:36 +0000 (09:59 +0100)]
Translated using Weblate (Korean)

Currently translated at 99.5% (10362 of 10405 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>
2 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 12 Jan 2023 08:59:36 +0000 (09:59 +0100)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10405 of 10405 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>
2 years agosrc/util/vircgroupv2.c: interpret neg quota as "max"
antonios-f [Thu, 17 Nov 2022 09:53:23 +0000 (09:53 +0000)]
src/util/vircgroupv2.c: interpret neg quota as "max"

Because of kernel doesn't allow passing negative values to
cpu.max as quota, it's needing to convert negative values to "max" token.

Signed-off-by: Anton Fadeev <anton.fadeev@red-soft.ru>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agodocs: drvqemu: Fix a typo
Han Han [Thu, 12 Jan 2023 04:10:21 +0000 (12:10 +0800)]
docs: drvqemu: Fix a typo

Fixes: a677ea928a65fceb1463e14044b23d7fba6acd3d
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoci: integration: Set an expiration on logs artifacts
Erik Skultety [Thu, 12 Jan 2023 06:57:58 +0000 (07:57 +0100)]
ci: integration: Set an expiration on logs artifacts

The default expiry time is 30 days. Since the RPM artifacts coming from
the previous pipeline stages are set to expire in 1 day we can set the
failed integration job log artifacts to the same value. The sentiment
here is that if an integration job legitimately failed (i.e. not with
an infrastructure failure) unless it was fixed in the meantime it will
fail the next day with the scheduled pipeline again, meaning, that even
if the older log artifacts are removed, they'll be immediately
replaced with fresh ones.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: Change some gotos in qemuPasstStart to direct return
Jiri Denemark [Wed, 11 Jan 2023 09:40:10 +0000 (10:40 +0100)]
qemu: Change some gotos in qemuPasstStart to direct return

Jumping to the error label and reading the pidfile does not make sense
until we reached qemuSecurityCommandRun which creates the pidfile.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: Don't check pidfile in qemuPasstStart
Jiri Denemark [Wed, 11 Jan 2023 08:54:59 +0000 (09:54 +0100)]
qemu: Don't check pidfile in qemuPasstStart

The pidfile is guaranteed to be non-NULL (thanks to glib allocation
functions) and it's dereferenced two lines above anyway.

Reported by coverity:

    /src/qemu/qemu_passt.c: 278 in qemuPasstStart()
    272         return 0;
    273
    274      error:
    275         ignore_value(virPidFileReadPathIfLocked(pidfile, &pid));
    276         if (pid != -1)
    277             virProcessKillPainfully(pid, true);
    >>>     CID 404360:  Null pointer dereferences  (REVERSE_INULL)
    >>>     Null-checking "pidfile" suggests that it may be null, but it
    >>>     has already been dereferenced on all paths leading to the check.
    278         if (pidfile)
    279             unlink(pidfile);
    280
    281         return -1;

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoconf: Avoid NULL dereference in virDomainNetPortForwardFree
Jiri Denemark [Wed, 11 Jan 2023 08:25:58 +0000 (09:25 +0100)]
conf: Avoid NULL dereference in virDomainNetPortForwardFree

In our current code the function is not called with NULL argument, but
we should follow our common practice and make it safe anyway.

Reported by coverity:

    /src/conf/domain_conf.c: 2635 in virDomainNetPortForwardFree()
    2629     {
    2630         size_t i;
    2631
    2632         if (pf)
    2633             g_free(pf->dev);
    2634
    >>>     CID 404359:  Null pointer dereferences  (FORWARD_NULL)
    >>>     Dereferencing null pointer "pf".
    2635         for (i = 0; i < pf->nRanges; i++)
    2636             g_free(pf->ranges[i]);
    2637
    2638         g_free(pf->ranges);
    2639         g_free(pf);
    2640     }

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoUpdate translation files
Weblate [Tue, 10 Jan 2023 08:28:43 +0000 (09:28 +0100)]
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>
2 years agoNEWS: document addition of passt support
Laine Stump [Tue, 10 Jan 2023 06:36:59 +0000 (01:36 -0500)]
NEWS: document addition of passt support

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: Fix handling of passed FDs in remoteDispatchDomainFdAssociate
Peter Krempa [Tue, 10 Jan 2023 13:31:27 +0000 (14:31 +0100)]
qemu: Fix handling of passed FDs in remoteDispatchDomainFdAssociate

To ensure same behaviour when remote driver is or is not used we must
not steal the FDs and array holding them passed to qemuDomainFDAssociate
but rather duplicate them. At the same time the remote driver must close
and free them to prevent leak.

Pointed out by Coverity as FD leak on error path:

 *** CID 404348:  Resource leaks  (RESOURCE_LEAK)
 /src/remote/remote_daemon_dispatch.c: 7484 in remoteDispatchDomainFdAssociate()
 7478         rv = 0;
 7479
 7480      cleanup:
 7481         if (rv < 0)
 7482             virNetMessageSaveError(rerr);
 7483         virObjectUnref(dom);
 >>>     CID 404348:  Resource leaks  (RESOURCE_LEAK)
 >>>     Variable "fds" going out of scope leaks the storage it points to.
 7484         return rv;

Fixes: abd9025c2fd
Fixes: f762f87534e
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agospec: Restart libvirtd on upgrade without socket activation
Martin Kletzander [Tue, 10 Jan 2023 11:21:56 +0000 (12:21 +0100)]
spec: Restart libvirtd on upgrade without socket activation

The %posttrans phase has a special case for upgrading libvirt daemon
with --listen, but it forgot to also restart the daemon in order to
run the new installed version.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoremote: fix double free of migration params on error
Daniel P. Berrangé [Thu, 22 Dec 2022 17:17:15 +0000 (12:17 -0500)]
remote: fix double free of migration params on error

The remote_*_args methods will generally borrow pointers
passed in the caller, so should not be freed.

On failure of the virTypedParamsSerialize method, however,
xdr_free was being called. This is presumably because it
was thought that the params may have been partially
serialized and need cleaning up. This is incorrect, as
virTypedParamsSerialize takes care to cleanup partially
serialized data. This xdr_free call would lead to free'ing
the borrowed cookie pointers, which would be a double free.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoadmin: fix leak of typed parameters on error
Daniel P. Berrangé [Thu, 22 Dec 2022 16:15:27 +0000 (11:15 -0500)]
admin: fix leak of typed parameters on error

A few admin client methods had the xdr_free call the wrong
side of the cleanup label, so typed parameters would not
be freed on error.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agopo: Refresh potfile for v9.0.0
Jiri Denemark [Tue, 10 Jan 2023 08:25:28 +0000 (09:25 +0100)]
po: Refresh potfile for v9.0.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agospecfile: require passt for the build if fedora >= 36 or rhel >= 9
Laine Stump [Fri, 6 Jan 2023 23:36:44 +0000 (18:36 -0500)]
specfile: require passt for the build if fedora >= 36 or rhel >= 9

The only reason we need it at build time is to find its location in
$PATH so it can be hardcoded into the libvirt binary (and avoid the
possibility of someone adding in a malicious binary somewhere earlier
in the path, I guess).

Only 'recommend' passt during installation though, since it is not
needed unless someone is actually using it.

There is no need to add in a build-time "WITH_PASST" option (IMO),
since it adds very little to the size of the code - "PASST" (the path
to the binary) will just be set to "passt", so if someone does manage
to build and install passt on an older version of Fedora or RHEL, it
will still work (as long as it's installed somewhere in the path).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: hook up passt config to qemu domains
Laine Stump [Thu, 15 Dec 2022 19:19:16 +0000 (14:19 -0500)]
qemu: hook up passt config to qemu domains

This consists of (1) adding the necessary args to the qemu commandline
netdev option, and (2) starting a passt process prior to starting
qemu, and making sure that it is terminated when it's no longer
needed. Under normal circumstances, passt will terminate itself as
soon as qemu closes its socket, but in case of some error where qemu
is never started, or fails to startup completely, we need to terminate
passt manually.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: add passtStateDir to qemu driver config
Laine Stump [Fri, 2 Dec 2022 18:38:01 +0000 (13:38 -0500)]
qemu: add passtStateDir to qemu driver config

...following in the patter of slirpStateDir.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: new capability QEMU_CAPS_NETDEV_STREAM
Laine Stump [Thu, 5 Jan 2023 03:10:09 +0000 (22:10 -0500)]
qemu: new capability QEMU_CAPS_NETDEV_STREAM

passt support requires "-netdev stream", which was added to QEMU in
qemu-7.2.0.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: parse/format passt-related XML additions
Laine Stump [Fri, 11 Nov 2022 19:43:45 +0000 (14:43 -0500)]
conf: parse/format passt-related XML additions

This implements XML config to represent a subset of the features
supported by 'passt' (https://passt.top), which is an alternative
backend for emulated network devices that requires no elevated
privileges (similar to slirp, but "better").

Along with setting the backend to use passt (via <backend
type='passt'/> when the interface type='user'), we also support
passt's --log-file and --interface options (via the <backend>
subelement logFile and upstream attributes) and its --tcp-ports and
--udp-ports options (which selectively forward incoming connections to
the host on to the guest) via the new <portForward> subelement of
<interface>. Here is an example of the config for a network interface
that uses passt to connect:

    <interface type='user'>
      <mac address='52:54:00:a8:33:fc'/>
      <ip address='192.168.221.122' family='ipv4'/>
      <model type='virtio'/>
      <backend type='passt' logFile='/tmp/xyzzy.log' upstream='eth0'/>
      <portForward address='10.0.0.1' proto='tcp' dev='eth0'>
        <range start='2022' to='22'/>
        <range start='5000' end='5099' to='1000'/>
        <range start='5010' end='5029' exclude='yes'/>
      </portForward>
      <portForward proto='udp'>
        <range start='10101'/>
      </portForward>
    </interface>

In this case:

* the guest will be offered address 192.168.221.122 for its interface
  via DHCP

* the passt process will write all log messages to /tmp/xyzzy.log

* routes to the outside for the guest will be derived from the
  addresses and routes associated with the host interface "eth0".

* incoming tcp port 2022 to the host will be forwarded to port 22
  on the guest.

* incoming tcp ports 5000-5099 (with the exception of ports 5010-5029)
  to the host will be forwarded to port 1000-1099 on the guest.

* incoming udp packets on port 10101 will be forwarded (unchanged) to
  the guest.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>