]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoDocument specifics of virConnectBaselineHypervisorCPU
Jiri Denemark [Fri, 7 Oct 2022 16:36:50 +0000 (18:36 +0200)]
Document specifics of virConnectBaselineHypervisorCPU

The API can be used to get usability blockers for an unusable CPU model,
which is not obvious. Let's explicitly document this behavior as it is
now mentioned in the documentation of domain capabilities XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodocs: Enhance documentation of CPU models in domain caps
Jiri Denemark [Fri, 7 Oct 2022 16:16:09 +0000 (18:16 +0200)]
docs: Enhance documentation of CPU models in domain caps

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_arm: Don't implement virCPUGetVendorForModel
Jiri Denemark [Thu, 29 Sep 2022 19:54:34 +0000 (21:54 +0200)]
cpu_arm: Don't implement virCPUGetVendorForModel

This patch is effectively a no-op, but I wanted to initialize
.getVendorForModel explicitly as implementing this function does not
even make sense on ARM. The CPU models in our CPU map are only used for
describing host CPU in capabilities XML and cannot be used for guest CPU
definition in domain XML anyway. The CPU models listed as supported in
domain capabilities XML are just passed through from QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_ppc64: Implement virCPUGetVendorForModel
Jiri Denemark [Thu, 29 Sep 2022 19:51:22 +0000 (21:51 +0200)]
cpu_ppc64: Implement virCPUGetVendorForModel

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_x86: Implement virCPUGetVendorForModel
Jiri Denemark [Thu, 29 Sep 2022 19:40:40 +0000 (21:40 +0200)]
cpu_x86: Implement virCPUGetVendorForModel

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoIntroduce virCPUGetVendorForModel and use it in QEMU driver
Jiri Denemark [Thu, 29 Sep 2022 14:32:27 +0000 (16:32 +0200)]
Introduce virCPUGetVendorForModel and use it in QEMU driver

So far QEMU driver does not get CPU model vendor from QEMU directly and
it has to ask the CPU driver for the info stored in CPU map.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agodomain_capabilities: Add vendor attribute for CPU models
Jiri Denemark [Fri, 30 Sep 2022 09:46:29 +0000 (11:46 +0200)]
domain_capabilities: Add vendor attribute for CPU models

Even though several CPU models from various vendors are reported as
usable on a given host, user may still want to use only those that match
the host vendor. Currently the only place where users can check the
vendor of each CPU model is our CPU map, which is considered internal
and users should not really be using it directly. So to allow for such
filtering we now advertise the vendor of each CPU model in domain
capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Do not pass qemuCaps to virQEMUCapsCPUFeature{To,From}QEMU
Jiri Denemark [Fri, 30 Sep 2022 16:34:05 +0000 (18:34 +0200)]
qemu: Do not pass qemuCaps to virQEMUCapsCPUFeature{To,From}QEMU

The only part of qemuCaps both functions are interested in is the CPU
architecture. Changing them to expect just virArch makes the functions
more reusable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu_ppc64: Avoid repeated loading of CPU map
Jiri Denemark [Fri, 30 Sep 2022 09:03:15 +0000 (11:03 +0200)]
cpu_ppc64: Avoid repeated loading of CPU map

The ppc64 CPU code still has to load and parse the CPU map everytime it
needs to look at it, which can make some operations pretty slow. Other
archs already switched to loading the CPU map once and keeping the
parsed structure in memory. Let's switch ppc64 as well.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: virDomainCapsCPUModelsAdd never fails
Jiri Denemark [Thu, 29 Sep 2022 14:30:19 +0000 (16:30 +0200)]
conf: virDomainCapsCPUModelsAdd never fails

Since the function always returns 0, we can just return void and make
callers simpler.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNetServerProgramDispatchCall: Avoid calling xdr_free(_, NULL)
Michal Privoznik [Fri, 7 Oct 2022 11:05:03 +0000 (13:05 +0200)]
virNetServerProgramDispatchCall: Avoid calling xdr_free(_, NULL)

In recent commit of v8.8.0-41-g41eb0f446c I've suggested during
review to put both xdr_free() calls under error label, assuming
that xdr_free() accepts NULL and thus is a NOP when the control
jumps onto the label even before either of @arg or @ret was
allocated. Well, turns out, xdr_free() does no accept NULL and
thus we have to guard its call. But since @dispatcher is already
set by the time either of the variables is allocated, we can
replace the condition from 'if (dispatcher)' to 'if (arg)' and
'if (ret)'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agosrc: warn if client hits the max requests limit
Daniel P. Berrangé [Wed, 24 Aug 2022 15:15:24 +0000 (16:15 +0100)]
src: warn if client hits the max requests limit

Since they are simply normal RPC messages, the keep alive packets are
subject to the "max_client_requests" limit just like any API calls.

Thus, if a client hits the 'max_client_requests' limit and all the
pending API calls take a long time to complete, it may result in
keep-alives firing and dropping the client connection.

This has been seen by a number of users with the default value of
max_client_requests=5, by issuing 5 concurrent live migration
operations.

By printing a warning message when this happens, admins will be alerted
to the fact that their active clients are exceeding the default client
requests limit.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: add virt-qemu-qmp-proxy for proxying QMP via libvirt QEMU guests
Daniel P. Berrangé [Fri, 27 May 2022 09:34:47 +0000 (10:34 +0100)]
tools: add virt-qemu-qmp-proxy for proxying QMP via libvirt QEMU guests

Libvirt provides QMP passthrough APIs for the QEMU driver and these are
exposed in virsh. It is not especially pleasant, however, using the raw
QMP JSON syntax. QEMU has a tool 'qmp-shell' which can speak QMP and
exposes a human friendly interactive shell. It is not possible to use
this with libvirt managed guest, however, since only one client can
attach to the QMP socket at any point in time. While it would be
possible to configure a second QMP socket for a VM, it may not be
an known requirement at the time the guest is provisioned.

The virt-qmp-proxy tool aims to solve this problem. It opens a UNIX
socket and listens for incoming client connections, speaking QMP on
the connected socket. It will forward any QMP commands received onto
the running libvirt QEMU guest, and forward any replies back to the
QMP client. It will also forward back events.

  $ virsh start demo
  $ virt-qmp-proxy demo demo.qmp &
  $ qmp-shell demo.qmp
  Welcome to the QMP low-level shell!
  Connected to QEMU 6.2.0

  (QEMU) query-kvm
  {
      "return": {
          "enabled": true,
          "present": true
      }
  }

Note this tool of course has the same risks as the raw libvirt
QMP passthrough. It is safe to run query commands to fetch information
but commands which change the QEMU state risk disrupting libvirt's
management of QEMU, potentially resulting in data loss/corruption in
the worst case. Any use of this tool will cause the guest to be marked
as tainted as an warning that it could be in an unexpected state.

Since this tool introduces a python dependency it is not desirable
to include it in any of the existing RPMs in libvirt. This tool is
also QEMU specific, so isn't appropriate to bundle with the generic
tools. Thus a new RPM is introduced 'libvirt-clients-qemu', to
contain additional QEMU specific tools, with extra external deps.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoci: refresh with latest lcitool manifest
Daniel P. Berrangé [Fri, 30 Sep 2022 08:50:04 +0000 (04:50 -0400)]
ci: refresh with latest lcitool manifest

This refresh switches the CI for contributors to be triggered by merge
requests. Pushing to a branch in a fork will no longer run CI pipelines,
in order to avoid consuming CI minutes. To regain the original behaviour
contributors can opt-in to a pipeline on push

   git push <remote> -o ci.variable=RUN_PIPELINE=1

This variable can also be set globally on the repository, through the
web UI options Settings -> CI/CD -> Variables, though this is not
recommended. Upstream repo pushes to branches will run CI.

The use of containers has changed in this update, with only the upstream
repo creating containers, in order to avoid consuming contributors'
limited storage quotas. A fork with existing container images may delete
them. Containers will be rebuilt upstream when pushing commits with CI
changes to the default branch. Any other scenario with CI changes will
simply install build pre-requisite packages in a throaway environment,
using the ci/buildenv/ scripts. These scripts may also be used on a
contributor's local machines.

With pipelines triggered by merge requests, it is also now possible to
workaround the inability of contributors to run pipelines if they have
run out of CI quota. A project member can trigger a pipeline from the
merge request, which will run in context of upstream, however, note
this should only be done after reviewing the code for any malicious
CI changes.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoutil: xml: Remove virXMLParseStringCtxtRoot
Peter Krempa [Fri, 23 Sep 2022 13:38:49 +0000 (15:38 +0200)]
util: xml: Remove virXMLParseStringCtxtRoot

Remove the seldom used helper in favor of full virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotest_driver: Make callers of testOpenParse ensure the root element name
Peter Krempa [Fri, 23 Sep 2022 13:16:22 +0000 (15:16 +0200)]
test_driver: Make callers of testOpenParse ensure the root element name

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agosecurity: aa-helper: Use virXMLParse instead of virXMLParseString
Peter Krempa [Fri, 23 Sep 2022 13:11:59 +0000 (15:11 +0200)]
security: aa-helper: Use virXMLParse instead of virXMLParseString

Use the helper with more features to validate the root XML element name
instead of open-coding it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: savecookie: Remove virSaveCookieParseNode
Peter Krempa [Fri, 23 Sep 2022 13:03:19 +0000 (15:03 +0200)]
conf: savecookie: Remove virSaveCookieParseNode

The function provided just checking of the root XML node name which can
be easily moved into the caller wich doesn't do that already and
checking of the pointers which is trivial. Remove the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove virXMLParseCtxt
Peter Krempa [Fri, 23 Sep 2022 12:53:21 +0000 (14:53 +0200)]
util: xml: Remove virXMLParseCtxt

Convert the two outstanding uses to virXMLParseFileCtxt as they always
pass a filename and remove the helper macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove virXMLParseFile
Peter Krempa [Fri, 23 Sep 2022 12:49:01 +0000 (14:49 +0200)]
util: xml: Remove virXMLParseFile

Most callers prefer using the XPath context. Convert the last user to
use virXMLParseFileCtxt and remove the helper macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse
Peter Krempa [Fri, 23 Sep 2022 12:47:12 +0000 (14:47 +0200)]
qemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse

Use virXMLParse so that the code doesn't have to explicitly allocate
an XPath context and validate the root element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoutil: xml: Remove virXMLParseString
Peter Krempa [Fri, 23 Sep 2022 12:44:25 +0000 (14:44 +0200)]
util: xml: Remove virXMLParseString

Most callers use virXMLParseStringCtxt. Convert the last use case
and remove the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirsh: Use proper helper for parsing XML in virshDumpXML
Peter Krempa [Fri, 23 Sep 2022 12:42:18 +0000 (14:42 +0200)]
virsh: Use proper helper for parsing XML in virshDumpXML

Use virXMLParseStringCtxt instead of virXMLParseString since the code
requires a XPath context anyways.

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