]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agovirDomainNetDefParseXML: Drop prehistoric error workaround
Peter Krempa [Fri, 16 Sep 2022 16:25:19 +0000 (18:25 +0200)]
virDomainNetDefParseXML: Drop prehistoric error workaround

Apart from it being a long time ago the 'openvz' driver is also rarely
used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agovirDomainNetDefParseXML: Parse attributes of <mac> only when present
Peter Krempa [Fri, 16 Sep 2022 16:23:29 +0000 (18:23 +0200)]
virDomainNetDefParseXML: Parse attributes of <mac> only when present

Access the 'mac_node' variable only when it was filled.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Don't overload 'node' variable when parsing <coalesce>
Peter Krempa [Fri, 16 Sep 2022 16:18:47 +0000 (18:18 +0200)]
virDomainNetDefParseXML: Don't overload 'node' variable when parsing <coalesce>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of <filterref>
Peter Krempa [Fri, 16 Sep 2022 16:08:19 +0000 (18:08 +0200)]
virDomainNetDefParseXML: Refactor parsing of <filterref>

Parse the element only when the network type requires it and assign it
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of <target> subelement
Peter Krempa [Fri, 16 Sep 2022 16:03:24 +0000 (18:03 +0200)]
virDomainNetDefParseXML: Refactor parsing of <target> subelement

Specifically rework of parsing of the 'managed' attribute simplifies the
code greatly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDef: Use virTristateBool for 'managed_tap' instead of int
Peter Krempa [Fri, 16 Sep 2022 16:12:19 +0000 (18:12 +0200)]
virDomainNetDef: Use virTristateBool for 'managed_tap' instead of int

Convert the struct member to proper type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of <virtualport>
Peter Krempa [Fri, 16 Sep 2022 15:56:59 +0000 (17:56 +0200)]
virDomainNetDefParseXML: Refactor parsing of <virtualport>

Base whether virtualport is supported for a given interface on a new
variable named 'virtualport_flags' which also configures the parser for
the virtualports subelement and fill it in the appropriate interface
type branches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Move pure validation code from virDomainNetDefParseXML to virDomainNetD...
Peter Krempa [Fri, 16 Sep 2022 15:47:56 +0000 (17:47 +0200)]
conf: domain: Move pure validation code from virDomainNetDefParseXML to virDomainNetDefValidate

The moved code is pure validation of semantics of the definition and not
actual parsed values. Move it to the validation code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_HOSTDEV
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_HOSTDEV

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_UDP/MCAST...
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_UDP/MCAST/SERVER/CLIENT

This also removes the confusing use of variables named 'tmpNode' and
'tmp_node' right next to each other.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Introduce VIR_XPATH_NODE_AUTORESTORE_NAME
Peter Krempa [Fri, 16 Sep 2022 15:19:44 +0000 (17:19 +0200)]
util: xml: Introduce VIR_XPATH_NODE_AUTORESTORE_NAME

VIR_XPATH_NODE_AUTORESTORE_NAME is a more generic version of the
VIR_XPATH_NODE_AUTORESTORE macro used to save the 'node' inside a XPath
context struct. The new macro allows specifying the name of the variable
used to save the context so that it can be used multiple times inside a
function's nested scopes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDPA
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDPA

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VHOSTUSER
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VHOSTUSER

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Move 'virDomainChrSourceReconnectDefParseXML'
Peter Krempa [Fri, 16 Sep 2022 14:51:36 +0000 (16:51 +0200)]
conf: domain: Move 'virDomainChrSourceReconnectDefParseXML'

Move the function in place of its forward declaration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Extract network device model earlier
Peter Krempa [Fri, 16 Sep 2022 13:50:54 +0000 (15:50 +0200)]
virDomainNetDefParseXML: Extract network device model earlier

Move the code fetching the model of the net device before the main code
parsing individual device types so that the data is available before the
upcoming refactor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_DIRECT
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_DIRECT

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Convert 'mode' field of the 'direct' type of virDomainNetDef to proper...
Peter Krempa [Fri, 16 Sep 2022 13:38:14 +0000 (15:38 +0200)]
conf: domain: Convert 'mode' field of the 'direct' type of virDomainNetDef to proper type

Use 'virNetDevMacVLanMode'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_BRIDGE
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_BRIDGE

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_INTERNAL
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_INTERNAL

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDS
Peter Krempa [Fri, 16 Sep 2022 12:53:32 +0000 (14:53 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDS

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Introduce virXMLPropLongLong
Peter Krempa [Fri, 16 Sep 2022 12:40:46 +0000 (14:40 +0200)]
util: xml: Introduce virXMLPropLongLong

Add a helper for parsing long long values from XML properties with
semantics like virXMLPropInt.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_NETWORK
Peter Krempa [Fri, 16 Sep 2022 11:05:29 +0000 (13:05 +0200)]
virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_NETWORK

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Convert parsing of 'source_node' to a switch() statement
Peter Krempa [Thu, 15 Sep 2022 16:13:30 +0000 (18:13 +0200)]
virDomainNetDefParseXML: Convert parsing of 'source_node' to a switch() statement

Convert the individual 'if' clauses to a switch statement.

By moving the check that 'source_node' is non-null inside of each case
rather we will be able to move more type specific code into the switch
statement when it will be refactored in subsequent patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Introduce virXMLPropStringRequired
Peter Krempa [Fri, 16 Sep 2022 07:32:48 +0000 (09:32 +0200)]
util: xml: Introduce virXMLPropStringRequired

Similarly to virXMLPropString it extracts a string but reports an error
similar to the newer virXMLProp helpers if the attribute is not present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Adjust documentation of virXMLPropString
Peter Krempa [Fri, 16 Sep 2022 07:14:42 +0000 (09:14 +0200)]
util: xml: Adjust documentation of virXMLPropString

All callers treat NULL as if the string is not present in the XML.
Adjust the description so that it's implied that it's not an error and
thus also no error reporting is expected.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Introduce virXMLPropUUID
Peter Krempa [Fri, 16 Sep 2022 06:19:31 +0000 (08:19 +0200)]
util: xml: Introduce virXMLPropUUID

The helper function extracts a UUID with semantics similar to other
helpers we have.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetIPInfoParseXML: Don't force callers to set proper 'ctxt->node'
Peter Krempa [Thu, 15 Sep 2022 16:04:12 +0000 (18:04 +0200)]
virDomainNetIPInfoParseXML: Don't force callers to set proper 'ctxt->node'

In certain cases it's inconvenient to move the XPath's context current
node in the caller. Add a 'node' argument and override it inside the
function. VIR_XPATH_NODE_AUTORESTORE handles the cleanup.

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

Do the XPath fetches first as they don't require cleanup and rename
'cleanup' to 'error' and take it only on failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetIPInfoParseXML: Don't VIR_FREE and overwrite autofreed 'nodes'
Peter Krempa [Thu, 15 Sep 2022 15:58:32 +0000 (17:58 +0200)]
virDomainNetIPInfoParseXML: Don't VIR_FREE and overwrite autofreed 'nodes'

Use two separate variables for the nodes and count instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetIPInfoParseXML: Remove pointless automatic clearing of 'route' and 'ip'
Peter Krempa [Thu, 15 Sep 2022 15:47:49 +0000 (17:47 +0200)]
virDomainNetIPInfoParseXML: Remove pointless automatic clearing of 'route' and 'ip'

The variables are only used in code paths which can't fail after they
are allocated.

Additionally decrease scope of the variables.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Use virXMLPropEnumDefault for parsing 'def->type'
Peter Krempa [Thu, 15 Sep 2022 15:23:23 +0000 (17:23 +0200)]
virDomainNetDefParseXML: Use virXMLPropEnumDefault for parsing 'def->type'

Replace ad-hoc logic that fills the default by use of the proper helper
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Split out parsing of 'driver' subelement
Peter Krempa [Thu, 15 Sep 2022 15:21:56 +0000 (17:21 +0200)]
virDomainNetDefParseXML: Split out parsing of 'driver' subelement

Separate the code into virDomainNetDefParseXMLDriver. Some local
variables were renamed and the scope decreased.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Separate and localize parsing of 'backend/@vhost'
Peter Krempa [Thu, 15 Sep 2022 14:54:46 +0000 (16:54 +0200)]
virDomainNetDefParseXML: Separate and localize parsing of 'backend/@vhost'

Move it into an independent block and move temporary variables locally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirDomainNetDefParseXML: Remove unnecessary temporary variables
Peter Krempa [Thu, 15 Sep 2022 14:01:20 +0000 (16:01 +0200)]
virDomainNetDefParseXML: Remove unnecessary temporary variables

Some values were extracted into a temporary variable and then assigned
to the definition later without a modification.

Directly assign them instead.

One slight modification was done to 'ifname' which was cleared in
certain cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Remove 'error' label in virDomainNetDefParseXML
Peter Krempa [Thu, 15 Sep 2022 13:54:16 +0000 (15:54 +0200)]
conf: domain: Remove 'error' label in virDomainNetDefParseXML

The 'error' label was an alias to 'return NULL;'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML
Peter Krempa [Thu, 15 Sep 2022 13:52:21 +0000 (15:52 +0200)]
conf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML

Convert the last two variables having inline cleanup to automatic
cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Register automatic pointer freeing for virDomainActualNetDef
Peter Krempa [Thu, 15 Sep 2022 13:49:59 +0000 (15:49 +0200)]
conf: domain: Register automatic pointer freeing for virDomainActualNetDef

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoci: refresh generated files
Pavel Hrdina [Mon, 26 Sep 2022 16:37:22 +0000 (18:37 +0200)]
ci: refresh generated files

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agospec: add systemd-rpm-macros build dependency
Pavel Hrdina [Mon, 26 Sep 2022 16:33:20 +0000 (18:33 +0200)]
spec: add systemd-rpm-macros build dependency

We should explicitly depend on this package as we use some macros
defined by files that are installed from systemd-rpm-macros.

Currently the build works only because some of our other build
dependencies pull in systemd which will install systemd-rpm-macros if
rpm-build is installed as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoPost-release version bump to 8.9.0
Jiri Denemark [Mon, 3 Oct 2022 08:03:44 +0000 (10:03 +0200)]
Post-release version bump to 8.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoRelease of libvirt-8.8.0
Jiri Denemark [Mon, 3 Oct 2022 07:57:00 +0000 (09:57 +0200)]
Release of libvirt-8.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Sun, 2 Oct 2022 12:19:52 +0000 (14:19 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10432 of 10432 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 agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 2 Oct 2022 12:19:51 +0000 (14:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 47.9% (5002 of 10432 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoTranslated using Weblate (Russian)
Sergey A [Sun, 2 Oct 2022 12:19:50 +0000 (14:19 +0200)]
Translated using Weblate (Russian)

Currently translated at 91.1% (9505 of 10432 strings)

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

Co-authored-by: Sergey A <sw@atrus.ru>
Signed-off-by: Sergey A. <sw@atrus.ru>
2 years agoTranslated using Weblate (Korean)
김인수 [Sun, 2 Oct 2022 12:19:49 +0000 (14:19 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10432 of 10432 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 agodocs: compiling: Add link to latest openSUSE libvirt package
Jim Fehlig [Thu, 29 Sep 2022 20:05:41 +0000 (14:05 -0600)]
docs: compiling: Add link to latest openSUSE libvirt package

This is a follow-up to fbd6b2480a, adding a link to the latest libvirt
package for openSUSE.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Fri, 30 Sep 2022 10:39:29 +0000 (12:39 +0200)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agovirgdbusmock: Mock g_dbus_connection_call_with_unix_fd_list_sync() only on UNIX-like...
Michal Privoznik [Wed, 28 Sep 2022 09:05:47 +0000 (11:05 +0200)]
virgdbusmock: Mock g_dbus_connection_call_with_unix_fd_list_sync() only on UNIX-like systems

As of GLib commit c9874f817be51d3b652457daef3b10766b59db9a,
relesed in GLib 2.73, the g_dbus_connection_call_with_unix_fd_list_sync()
function is not defined always, only when G_OS_UNIX condition is
set. This is also the reason why our virGDBusCallMethodWithFD()
function is guarded with that macro. But virgdbusmock is compiled
always, even on !UNIX systems, e.g. mingw. Therefore, we need to
use the same macro to condition compile its mock.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirdomainjob: check if cb is not NULL before dereferencing
Kristina Hanicova [Fri, 30 Sep 2022 11:51:28 +0000 (13:51 +0200)]
virdomainjob: check if cb is not NULL before dereferencing

The callback struct does not always have to be set which could
cause a dereferencing of a NULL pointer. This patch adds check
against NULL in missing places before dereferencing.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuProcessReconnect: Don't build memory paths
Michal Privoznik [Wed, 28 Sep 2022 08:12:36 +0000 (10:12 +0200)]
qemuProcessReconnect: Don't build memory paths

Let me take you on a short trip to history. A long time ago,
libvirt would configure all QEMUs to use $hugetlbfs/libvirt/qemu
for their hugepages setup. This was problematic, because it did
not allow enough separation between guests. Therefore in
v3.0.0-rc1~367 the path changed to a per-domain basis:

  $hugetlbfs/libvirt/qemu/$domainShortName

And to help with migration on daemon restart a call to
qemuProcessBuildDestroyMemoryPaths() was added to
qemuProcessReconnect() (well, it was named
qemuProcessBuildDestroyHugepagesPath() back then, see
v3.10.0-rc1~174). This was desirable then, because the memory
hotplug code did not call the function, it simply assumes
per-domain paths to exist. But this changed in v3.5.0-rc1~92
after which the per-domain paths are created on memory hotplug
too.

Therefore, it's no longer necessary to create these paths in
qemuProcessReconnect(). They are created exactly when needed
(domain startup and memory hotplug).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuNamespaceMknodOne: Call g_file_read_link() in async-signal-safe fashion
Michal Privoznik [Wed, 28 Sep 2022 07:53:47 +0000 (09:53 +0200)]
qemuNamespaceMknodOne: Call g_file_read_link() in async-signal-safe fashion

When creating a node in QEMU's namespace the whole link chain is
created with it. Here, we use g_file_read_link() from the child
(running inside the namespace) to learn whether a link exists and
points to expected target. Now, when building the namespace there
can't be any symlinks and this g_file_read_link() returns NULL
always. And because we pass a local GError variable to it, glib
tries to set it to a localized error message. This comes with
creating a (static) hash table inside of g_strerror() and is
guarded with a mutex. The hash table is also allocated using
GSlice allocator instead of g_malloc, and since the latter is
safe to use after fork (because it's documented to use plain
malloc), glib went with the former, naturally. Now, GSlice
allocator has plenty of internal mutexes and thus hitting a
locked mutex is not that hard.

Fortunately, we don't care about any error from
g_file_read_link() and thus we can pass NULL which avoids calling
g_strerror().

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2120965
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemuNamespaceMknodPaths: Don't fork needlessly
Michal Privoznik [Wed, 28 Sep 2022 07:47:37 +0000 (09:47 +0200)]
qemuNamespaceMknodPaths: Don't fork needlessly

The qemuNamespaceMknodPaths() function is responsible for
creating files/directories in QEMU's mount namespace. When
called, it is given list of paths that have to be created in the
namespace. It processes this list and removes items that are not
directly under /dev, but on a 'shared' filesystem (note that all
other mount points are preserved). And it may so happen that
after this pre-process no files/directories need to be created in
the namespace. If that's the case, exit early and avoid
fork()-ing only to find out the same.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Remove host-passthrough validation check for host-phys-bits=on
Lin Ma [Thu, 8 Sep 2022 07:07:22 +0000 (15:07 +0800)]
qemu: Remove host-passthrough validation check for host-phys-bits=on

Besides the -cpu host, The host-phys-bits=on applies to custom or max
cpu model, So the host-passthrough validation check is unnecessary for
maxphysaddr with mode='passthrough'.

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2 years agovirdomainjob: preserveJob: memdup the cb structure instead of copying it
Kristina Hanicova [Thu, 29 Sep 2022 11:56:30 +0000 (13:56 +0200)]
virdomainjob: preserveJob: memdup the cb structure instead of copying it

In case of variable 'oldjob' (job structure) in
qemuProcessReconnect() the cb pointer was just copied from the
existing job structure in virDomainObjPreserveJob(). This caused
the job and oldjob sharing the same pointer, which was later
freed at the end of the qemuProcessReconnect() function by
automatic call to virDomainObjClearJob(). This caused an invalid
read in and subsequent daemon crash as the job structure was
trying to read cb which had been already freed.

This patch changes the copying to g_memdup that allocates
different pointer, which can be later safely freed.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoUpdate translation files
Weblate [Tue, 27 Sep 2022 09:08:35 +0000 (11:08 +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>
2 years agospec: Use consistent versioning for Obsoletes
Jiri Denemark [Tue, 27 Sep 2022 09:11:24 +0000 (11:11 +0200)]
spec: Use consistent versioning for Obsoletes

rpmbuild is complaining it's not recommended to have unversioned
Obsoletes. On the other hand using dynamic version/release is a bit too
much as we know in which release a particular subpackage was removed.
Let's just use the corresponding version in both cases to be consistent
with all other Obsoletes in our spec file.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agopo: Refresh potfile for v8.8.0
Jiri Denemark [Tue, 27 Sep 2022 09:01:35 +0000 (11:01 +0200)]
po: Refresh potfile for v8.8.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu: fix memory leak about virDomainEventTunableNew
lu zhipeng [Mon, 26 Sep 2022 11:55:52 +0000 (19:55 +0800)]
qemu: fix memory leak about virDomainEventTunableNew

For prevent memory leak and easier to use, So change
virDomainEventTunableNew to get virTypedParameterPtr *params
and set it = NULL.

Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu_monitor_json: remove unnecessary variable 'rc'
Kristina Hanicova [Wed, 7 Sep 2022 13:13:57 +0000 (15:13 +0200)]
qemu_monitor_json: remove unnecessary variable 'rc'

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agolibvirt-guests: Fix dependency ordering in service file
Martin Kletzander [Tue, 30 Aug 2022 06:29:53 +0000 (08:29 +0200)]
libvirt-guests: Fix dependency ordering in service file

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

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

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

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

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

Currently translated at 99.8% (10420 of 10440 strings)

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

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

Currently translated at 47.2% (4932 of 10440 strings)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Updated example covers:

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

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

Currently translated at 45.9% (4794 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 45.5% (4754 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 45.3% (4734 of 10440 strings)

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

Translated using Weblate (Swedish)

Currently translated at 44.9% (4694 of 10440 strings)

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

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

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

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

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

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

According to repology.org:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The function is used only after the definition.

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

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

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

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

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

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

Jumping to the label would just return NULL.

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

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

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

Configuring an URI alias such as

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

Results in a double free when the alias is used:

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

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

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

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

There are two points I've taken for granted:

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

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

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

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

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

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

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

This reverts commit 46302172d47709b169c4b9b4cd6a4847fc2f0b4c

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

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

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

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

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

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

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

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

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

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

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

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

Switch to 'VIR_AUTOCLOSE' to simplify cleanup.

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

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

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

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

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

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

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

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

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

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

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

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

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