]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agovirDomainDefParseNode: Pass only the XPath context as argument
Peter Krempa [Fri, 23 Sep 2022 12:38:39 +0000 (14:38 +0200)]
virDomainDefParseNode: Pass only the XPath context as argument

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Simplify validation in virDomainDefParse
Peter Krempa [Fri, 23 Sep 2022 11:42:44 +0000 (13:42 +0200)]
conf: domain: Simplify validation in virDomainDefParse

Use virXMLParse's features to validate the top level element and fetch
the XPath context.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: domain: Remove virDomainObjParseNode
Peter Krempa [Fri, 23 Sep 2022 11:34:36 +0000 (13:34 +0200)]
conf: domain: Remove virDomainObjParseNode

virDomainObjParseFile is the only caller of virDomainObjParseNode.
The code can be merged into it, simplified by using virXMLParse and
the function removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: network: Provide only virNetworkDefParse
Peter Krempa [Fri, 23 Sep 2022 11:28:44 +0000 (13:28 +0200)]
conf: network: Provide only virNetworkDefParse

Replace virNetworkDefParseString/File by direct calls to
virNetworkDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: network: Remove virNetworkDefParseNode
Peter Krempa [Fri, 23 Sep 2022 11:17:25 +0000 (13:17 +0200)]
conf: network: Remove virNetworkDefParseNode

Both callers can be easily converted to call virNetworkDefParseXML
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: interface: Remove virInterfaceDefParseFile
Peter Krempa [Fri, 23 Sep 2022 11:09:58 +0000 (13:09 +0200)]
conf: interface: Remove virInterfaceDefParseFile

The function was not used. Remove it and merge virInterfaceDefParse
into virInterfaceDefParseString.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: interface: Remove virInterfaceDefParseNode
Peter Krempa [Fri, 23 Sep 2022 11:07:36 +0000 (13:07 +0200)]
conf: interface: Remove virInterfaceDefParseNode

Both callers be easily made to call virInterfaceDefParseXML directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nodedev: Provide only virNodeDeviceDefParse
Peter Krempa [Fri, 23 Sep 2022 09:52:23 +0000 (11:52 +0200)]
conf: nodedev: Provide only virNodeDeviceDefParse

Replace the thin wrappers virNodeDeviceDefParseString/File by directly
calling the main parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: node_device: Remove virNodeDeviceDefParseNode
Peter Krempa [Fri, 23 Sep 2022 08:44:13 +0000 (10:44 +0200)]
conf: node_device: Remove virNodeDeviceDefParseNode

Both callers be easily made to call virNodeDeviceDefParseXML directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nwfilter: Provide only virNWFilterDefParse
Peter Krempa [Fri, 23 Sep 2022 08:36:36 +0000 (10:36 +0200)]
conf: nwfilter: Provide only virNWFilterDefParse

Replace virNWFilterDefParseString/File with the common function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nwfilter: Remove virNWFilterDefParseNode
Peter Krempa [Fri, 23 Sep 2022 08:32:52 +0000 (10:32 +0200)]
conf: nwfilter: Remove virNWFilterDefParseNode

Use virXMLParse to fetch the XML context and validate the top level XML
element name so that virNWFilterDefParseNode is no longer needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: backup: Remove virDomainBackupDefParseNode
Peter Krempa [Thu, 22 Sep 2022 16:02:50 +0000 (18:02 +0200)]
conf: backup: Remove virDomainBackupDefParseNode

Rename virDomainBackupDefParse to virDomainBackupDefParseXML and use
it in place of virDomainBackupDefParseNode. This is possible as
virXMLParse can be used to replace XPath context allocation and root
node checking.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: checkpoint: Remove virDomainCheckpointDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:56:53 +0000 (17:56 +0200)]
conf: checkpoint: Remove virDomainCheckpointDefParseNode

Replace all it does by properly using virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoprlsdkParseSnapshotTree: Simplify XML parsing code
Peter Krempa [Thu, 22 Sep 2022 15:53:04 +0000 (17:53 +0200)]
prlsdkParseSnapshotTree: Simplify XML parsing code

Use features of virXMLParse to validate root node and fetch XPath
context.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: secret: Provide only virSecretDefParse
Peter Krempa [Thu, 22 Sep 2022 15:42:00 +0000 (17:42 +0200)]
conf: secret: Provide only virSecretDefParse

Replace the virSecretDefParseFile/String shims by calls to
virSecretDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: secret: Refactor secretXMLParseNode
Peter Krempa [Thu, 22 Sep 2022 15:38:36 +0000 (17:38 +0200)]
conf: secret: Refactor secretXMLParseNode

Rename it to virSecretParseXML and move the root node validation and
context fetching into the caller (by properly calling virXMLParse).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: snapshot: Remove virDomainSnapshotDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:33:56 +0000 (17:33 +0200)]
conf: snapshot: Remove virDomainSnapshotDefParseNode

Check the root XML node name and fetch XPath context by properly
configuring virXMLParse. Callers can use virDomainSnapshotDefParse
instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Provide only virStorageVolDefParse
Peter Krempa [Thu, 22 Sep 2022 15:22:55 +0000 (17:22 +0200)]
conf: storage: Provide only virStorageVolDefParse

Remove the virStorageVolDefParseFile/String shim functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Remove virStorageVolDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:17:21 +0000 (17:17 +0200)]
conf: storage: Remove virStorageVolDefParseNode

Proper use of virXMLParse replaces everything the function provides.
Callers can use virStorageVolDefParseXML instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Provide only virStoragePoolDefParse
Peter Krempa [Thu, 22 Sep 2022 15:08:16 +0000 (17:08 +0200)]
conf: storage: Provide only virStoragePoolDefParse

Replace the virStoragePoolDefParseString/File thin wrappers by
virStoragePoolDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: storage: Remove virStoragePoolDefParseNode
Peter Krempa [Thu, 22 Sep 2022 15:00:25 +0000 (17:00 +0200)]
conf: storage: Remove virStoragePoolDefParseNode

Replace it by proper use of virXMLParse to validate the root node and
allocate the context. The use in the test driver can be directly
replaced by virStoragePoolDefParseXML as both are validated.

The change to the storage driver isn't trivial though as it requires
careful xpath context juggling to parse the nested volumes properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotestParseXMLDocFromFile: Validate that the replaced node is identical with parsed...
Peter Krempa [Thu, 22 Sep 2022 14:41:25 +0000 (16:41 +0200)]
testParseXMLDocFromFile: Validate that the replaced node is identical with parsed root

When replacing a definition node by contents of a file the root node in
the file must match the replaced node.

Enforce that by passing the original node name as the 'rootnode'
argument of virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotestParseXMLDocFromFile: Remove 'type' argument
Peter Krempa [Thu, 22 Sep 2022 14:38:42 +0000 (16:38 +0200)]
testParseXMLDocFromFile: Remove 'type' argument

virXMLParse ignores the 'url' argument which is what 'type' was passed
to it as when a filename is used as source for the XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotestParseXMLDocFromFile: Refactor control flow
Peter Krempa [Thu, 22 Sep 2022 14:22:53 +0000 (16:22 +0200)]
testParseXMLDocFromFile: Refactor control flow

Move few variables definitions closer to usage, add comments explaining
what's happening and simplify the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: networkportdef: Provide only virNetworkPortDefParse
Peter Krempa [Thu, 22 Sep 2022 14:09:27 +0000 (16:09 +0200)]
conf: networkportdef: Provide only virNetworkPortDefParse

Replace the two helpers virNetworkPortDefParseString/File with the
common helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: networkport: Remove virNetworkPortDefParseNode
Peter Krempa [Thu, 22 Sep 2022 14:04:10 +0000 (16:04 +0200)]
conf: networkport: Remove virNetworkPortDefParseNode

The function is exported but used only intenally, additionally
everything it did for the only caller can be replaced by properly using
virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: qemuxml2argv: Use virXMLParse properly
Peter Krempa [Thu, 22 Sep 2022 13:58:16 +0000 (15:58 +0200)]
tests: qemuxml2argv: Use virXMLParse properly

Don't validate the root node and don't allocate a private XPath context
when virXMLParse can do that internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nwfilterbinding: Provide only virNWFilterBindingDefParse
Peter Krempa [Thu, 22 Sep 2022 13:56:32 +0000 (15:56 +0200)]
conf: nwfilterbinding: Provide only virNWFilterBindingDefParse

Remove the virNWFilterBindingDefParseString/File thin wrappers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNWFilterBindingDefParse: Properly use virXMLParse
Peter Krempa [Thu, 22 Sep 2022 13:47:40 +0000 (15:47 +0200)]
virNWFilterBindingDefParse: Properly use virXMLParse

Fetch the XPath context and validate the node by using virXMLParse's
features.

This allows to completely remove virNWFilterBindingDefParseNode as
all callers now properly validate the root element name and have a XPath
context handy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirVBoxSnapshotConfGet(RW|RO)DisksPathsFromLibvirtXML: Refactor
Peter Krempa [Thu, 22 Sep 2022 13:26:13 +0000 (15:26 +0200)]
virVBoxSnapshotConfGet(RW|RO)DisksPathsFromLibvirtXML: Refactor

virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML and
virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML were doing the same
thing, except for one XPath query.

Factor out the common code into a helper and bring it up to modern
standard.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovbox: snapshot_conf: Don't allocate XPath context explicitly
Peter Krempa [Thu, 22 Sep 2022 13:12:20 +0000 (15:12 +0200)]
vbox: snapshot_conf: Don't allocate XPath context explicitly

Use the one provided via virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNWFilterBindingObjParse: Refactor XML parsing code
Peter Krempa [Thu, 22 Sep 2022 13:06:40 +0000 (15:06 +0200)]
virNWFilterBindingObjParse: Refactor XML parsing code

Remove the redundant root node checking and XPath context creation by
using virXMLParse properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: nwfilderbindigobj: Register automatic cleanup for virNWFilterBindingObj
Peter Krempa [Thu, 22 Sep 2022 12:59:23 +0000 (14:59 +0200)]
conf: nwfilderbindigobj: Register automatic cleanup for virNWFilterBindingObj

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Expose all arguments of virXMLParseHelper in virXMLParse macro
Peter Krempa [Thu, 22 Sep 2022 12:30:53 +0000 (14:30 +0200)]
util: xml: Expose all arguments of virXMLParseHelper in virXMLParse macro

The generic helper also has helper code to validate the root element and
create an XPath context. Many places in the code duplicate code for
doing these operations.

Extend the helper to provide all arguments and fix all callers.

In many cases this patch refactors the passing of the 'validate'
field into a separate variable to avoid quirky looking arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoci: integration: Update the perl CI job names
Erik Skultety [Thu, 6 Oct 2022 08:40:35 +0000 (10:40 +0200)]
ci: integration: Update the perl CI job names

libvirt-derived repos recently changed the way how and when CI
containers are built and for that a different naming scheme was adopted
to differentiate between the 2. Update the integration pipeline config
to reflect this change.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 5 Oct 2022 09:19:42 +0000 (11:19 +0200)]
Translated using Weblate (Swedish)

Currently translated at 48.1% (5022 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 agoqemu: tpm: Remove TPM state after successful migration
Stefan Berger [Tue, 4 Oct 2022 13:38:14 +0000 (09:38 -0400)]
qemu: tpm: Remove TPM state after successful migration

This patch 'fixes' the behavior of the persistent_state TPM domain XML
attribute that intends to preserve the state of the TPM but should not
keep the state around on all the hosts a VM has been migrated to. It
removes the TPM state directory structure from the source host upon
successful migration when non-shared storage is used. Similarly, it
removes it from the destination host upon migration failure when
non-shared storage is used.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Add UNDEFINE_TPM and UNDEFINE_KEEP_TPM flags
Stefan Berger [Tue, 4 Oct 2022 13:38:13 +0000 (09:38 -0400)]
qemu: Add UNDEFINE_TPM and UNDEFINE_KEEP_TPM flags

Add UNDEFINE_TPM and UNDEFINE_KEEP_TPM flags to qemuDomainUndefineFlags()
API and --tpm and --keep-tpm to 'virsh undefine'. Pass the
virDomainUndefineFlagsValues via qemuDomainRemoveInactive()
from qemuDomainUndefineFlags() all the way down to
qemuTPMEmulatorCleanupHost() and delete TPM storage there considering that
the UNDEFINE_TPM flag has priority over the persistent_state attribute
from the domain XML. Pass 0 in all other API call sites to
qemuDomainRemoveInactive() for now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoutil: xml: Use common formatting of 'Bitwise-OR' in function param description
Peter Krempa [Mon, 3 Oct 2022 13:35:12 +0000 (15:35 +0200)]
util: xml: Use common formatting of 'Bitwise-OR' in function param description

Our public API docs use the hyphenated version with capital OR. Fix the
virXMLProp* helpers to use the same syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Fix declararation of 'const char *' parameters in virXMLProp* helpers
Peter Krempa [Mon, 3 Oct 2022 13:32:59 +0000 (15:32 +0200)]
util: xml: Fix declararation of 'const char *' parameters in virXMLProp* helpers

We commonly use 'const char *name' instead of 'const char* name'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirpcivpd: reduce errors in log due to invalid VPD
Christian Ehrhardt [Tue, 27 Sep 2022 10:17:41 +0000 (12:17 +0200)]
virpcivpd: reduce errors in log due to invalid VPD

Sadly some devices provide invalid VPD data even with fully updated
firmware. Former hardning like 600f580d "PCI VPD: Skip fields with
invalid values" have already helped for those to some extent.
But if one happens to have such a device installed in the system,
despite all other things working properly the log potentially
flooded with messages like:
  internal error: The keyword is not comprised only of uppercase ASCII
  letters or digits
  internal error: A field data length violates the resource length boundary.

The user can't do anything about it to change that, they will be there on
any libvirt restart and potentially distract from other more important
issues.

Since the vpd decoding is implemented rather resilient (if parsing fails
all goes on fine, the respective device just has no VPD data populated
eventually) we can lower those from virReportError(VIR_ERR_INTERNAL_ERROR
to just VIR_INFO. If needed for debugging people can set the level
accordingly, but otherwise we would no more fill the logs with errors
without a strong reason.

Fixes: https://launchpad.net/bugs/1990949
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovirt-aa-helper: allow common riscv64 loader paths
Christian Ehrhardt [Tue, 27 Sep 2022 09:03:07 +0000 (11:03 +0200)]
virt-aa-helper: allow common riscv64 loader paths

Riscv64 usually uses u-boot as external -kernel and a loader from
the open implementation of RISC-V SBI. The paths for those binaries
as packaged in Debian and Ubuntu are in paths which are usually
forbidden to be added by the user under /usr/lib...

People used to start riscv64 guests only manually via qemu cmdline,
but trying to encapsulate that via libvirt now causes failures when
starting the guest due to the apparmor isolation not allowing that:
   virt-aa-helper: error: skipped restricted file
   virt-aa-helper: error: invalid VM definition

Explicitly allow the sub-paths used by u-boot-qemu and opensbi
under /usr/lib/ as readonly rules.

Fixes: https://launchpad.net/bugs/1990499
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: retire QEMU_CAPS_CCW
Ján Tomko [Fri, 30 Sep 2022 14:18:26 +0000 (16:18 +0200)]
qemu: retire QEMU_CAPS_CCW

Now that we no longer use the capability, stop probing for existence
of 'virtual-css-bridge' and its properties.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: retire QEMU_CAPS_CCW_CSSID_UNRESTRICTED
Ján Tomko [Fri, 30 Sep 2022 14:15:25 +0000 (16:15 +0200)]
qemu: retire QEMU_CAPS_CCW_CSSID_UNRESTRICTED

Now that it is no longer used, stop probing for it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Assume QEMU_CAPS_CCW
Ján Tomko [Fri, 30 Sep 2022 12:01:44 +0000 (14:01 +0200)]
qemu: Assume QEMU_CAPS_CCW

Introduced in libvirt by:
  commit f245a9791c23ba08858f7cf7b16b1c449967ab35
    qemu: introduce capability for virtual-css-bridge

Which mentions that its support was in QEMU 2.7.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Assume QEMU_CAPS_CCW_CSSID_UNRESTRICTED
Ján Tomko [Fri, 30 Sep 2022 11:37:34 +0000 (13:37 +0200)]
qemu: Assume QEMU_CAPS_CCW_CSSID_UNRESTRICTED

This capability was introduced by libvirt commit:
  commit 263e65fd204a27713db89064796c1d386bb541d8
      qemu: introduce vfio-ccw capability

It probes for the cssid-unrestricted property of
virtual-css-bridge, which was introduced in QEMU v2.12 by:
  commit 99577c492fb2916165ed9bc215f058877f0a4106
      s390x/css: unrestrict cssids

Since we bumped the minimum QEMU version to 4.2.0, assume
this property is always present.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: convert some s390x tests to use real capability data
Ján Tomko [Fri, 30 Sep 2022 13:45:08 +0000 (15:45 +0200)]
qemu: convert some s390x tests to use real capability data

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: qemuxml2argvdata: switch zpci address generation to real caps
Ján Tomko [Fri, 30 Sep 2022 14:02:23 +0000 (16:02 +0200)]
tests: qemuxml2argvdata: switch zpci address generation to real caps

Among the usual changes, this puts the virtio memballoon on the CCW bus.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agorpc: fix memory leak in virNetServerClientNew and virNetServerProgramDispatchCall
jiangjiacheng [Fri, 30 Sep 2022 07:02:47 +0000 (15:02 +0800)]
rpc: fix memory leak in virNetServerClientNew and virNetServerProgramDispatchCall

In virNetServerProgramDispatchCall, The arg is passed as a void*
and used to point to a certain struct depended on the dispatcher,
so I think it's the memory of the struct's member that leaks and
this memory shuld be freed by xdr_free.

In virNetServerClientNew, client->rx is assigned by invoking
virNetServerClientNew, but isn't freed if client->privateData's
initialization failed, which leads to a memory leak. Thanks to
Liang Peng's suggestion, put virNetMessageFree(client->rx) into
virNetServerClientDispose() to release the memory.

Signed-off-by: jiangjiacheng <jiangjiacheng@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
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>