]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agovirDomainIOThreadIDDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 16 Apr 2021 09:41:51 +0000 (11:41 +0200)]
virDomainIOThreadIDDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNetworkForwardNatDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 16 Apr 2021 09:41:50 +0000 (11:41 +0200)]
virNetworkForwardNatDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirxml: Add virXMLPropEnum
Tim Wiederhake [Fri, 16 Apr 2021 09:41:49 +0000 (11:41 +0200)]
virxml: Add virXMLPropEnum

Convenience function to return the value of an enum XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirxml: Add virXMLPropUInt
Tim Wiederhake [Fri, 16 Apr 2021 09:41:48 +0000 (11:41 +0200)]
virxml: Add virXMLPropUInt

Convenience function to return the value of an unsigned integer XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirxml: Add virXMLPropInt
Tim Wiederhake [Fri, 16 Apr 2021 09:41:47 +0000 (11:41 +0200)]
virxml: Add virXMLPropInt

Convenience function to return the value of an integer XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirxml: Add virXMLPropTristateSwitch
Tim Wiederhake [Fri, 16 Apr 2021 09:41:46 +0000 (11:41 +0200)]
virxml: Add virXMLPropTristateSwitch

Convenience function to return the value of an on / off XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirxml: Add virXMLPropTristateBool
Tim Wiederhake [Fri, 16 Apr 2021 09:41:45 +0000 (11:41 +0200)]
virxml: Add virXMLPropTristateBool

Convenience function to return the value of a yes / no XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirXMLParseHelper: Refactor cleanup
Peter Krempa [Wed, 14 Apr 2021 11:06:51 +0000 (13:06 +0200)]
virXMLParseHelper: Refactor cleanup

Switch @xml and @pctxt to g_autofree and get rid of the "error" and
"cleanup" labels.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agovirXMLParseHelper: Rework error reporting
Peter Krempa [Wed, 14 Apr 2021 11:03:58 +0000 (13:03 +0200)]
virXMLParseHelper: Rework error reporting

Move the reporting of parsing error on the error path of the parser as
other code paths report their own errors already.

Additionally prefer printing the 'url' as document name if provided
instead of "[inline data]" as that usually gives a better hint at least
which kind of XML is being parsed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoutil: xml: Register autoptr cleanup function for 'xmlParserCtxt'
Peter Krempa [Wed, 14 Apr 2021 10:54:41 +0000 (12:54 +0200)]
util: xml: Register autoptr cleanup function for 'xmlParserCtxt'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agovirXMLParseHelper: Sync argument names between declaration and definition
Peter Krempa [Wed, 14 Apr 2021 10:52:35 +0000 (12:52 +0200)]
virXMLParseHelper: Sync argument names between declaration and definition

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoutil: virxml: Fix formatting of virxml.h
Peter Krempa [Wed, 14 Apr 2021 11:32:12 +0000 (13:32 +0200)]
util: virxml: Fix formatting of virxml.h

Remove the "block" formatting of function declarations and use uniform
spacing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoconf: Use virTristateXXX in virPCIDeviceAddress
Tim Wiederhake [Wed, 7 Apr 2021 11:48:41 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virPCIDeviceAddress

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStoragePoolSourceDevice
Tim Wiederhake [Wed, 7 Apr 2021 11:48:40 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virStoragePoolSourceDevice

Note that the comment for virStoragePoolSourceDevice::part_separator was wrong.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStorageAdapterFCHost
Tim Wiederhake [Wed, 7 Apr 2021 11:48:39 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virStorageAdapterFCHost

Note that the comment for virStorageAdapterFCHost::managed was wrong.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:38 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainLoaderDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:37 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainLoaderDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainMemballoonDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:36 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainMemballoonDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainGraphicsDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:35 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainGraphicsDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainChrSourceDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:34 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainChrSourceDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainNetDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:33 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainNetDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainActualNetDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:32 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainActualNetDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainDiskDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:31 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainDiskDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainDeviceInfo
Tim Wiederhake [Wed, 7 Apr 2021 11:48:30 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainDeviceInfo

Note that the wrong "VIR_TRISTATE_*_ABSENT" was used in qemuDomainChangeNet.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStorageSourceNVMeDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:29 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virStorageSourceNVMeDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStorageSource
Tim Wiederhake [Wed, 7 Apr 2021 11:48:28 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virStorageSource

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoci: Refresh contents
Andrea Bolognani [Thu, 15 Apr 2021 17:07:16 +0000 (19:07 +0200)]
ci: Refresh contents

Notable changes:

  * cross-building container images are smaller because they
    no longer include the native compilers;

  * ccache is enabled for clang builds.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agonodedev: handle null return from GetIOMMUGroupDev()
Jonathon Jongsma [Tue, 13 Apr 2021 19:27:04 +0000 (14:27 -0500)]
nodedev: handle null return from GetIOMMUGroupDev()

Coverity reported that this function can return NULL, so it should be
handled properly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: refactor virMediatedDeviceGetIOMMUGroupNum()
Jonathon Jongsma [Tue, 13 Apr 2021 19:09:19 +0000 (14:09 -0500)]
nodedev: refactor virMediatedDeviceGetIOMMUGroupNum()

Currently virMediatedDeviceGetIOMMUGroupDev() looks up the iommu group
number and uses that to construct a path to the iommu group device.
virMediatedDeviceGetIOMMUGroupNum() then uses that device path and takes
the basename to get the group number. That's unnecessary extra string
manipulation for *GroupNum(). Reverse the implementations and make
*GroupDev() call *GroupNum().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: remove unnecessary null check
Jonathon Jongsma [Tue, 13 Apr 2021 16:19:00 +0000 (11:19 -0500)]
qemu: remove unnecessary null check

virMediatedDeviceGetSysfsPath() (via g_strdup_printf()) is guaranteed to
return a non-NULL value, so remove the unnecessary checks for NULL.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirlog: Remove stray "todo" in comment
Tim Wiederhake [Thu, 15 Apr 2021 08:12:13 +0000 (10:12 +0200)]
virlog: Remove stray "todo" in comment

Fixes: 8fe30b2167b5b56461b11dbf02aca83030070caf
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoFix spelling
Tim Wiederhake [Thu, 15 Apr 2021 08:12:12 +0000 (10:12 +0200)]
Fix spelling

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agolibxl: Add debug statements
Jim Fehlig [Tue, 13 Apr 2021 23:29:19 +0000 (17:29 -0600)]
libxl: Add debug statements

Over several years of debugging reports related to VM shutdown, destruction,
and cleanup, I've found that logging of all events received from libxl and
logging the entry of libxlDomainCleanup has proven useful. Add the these
debug messages upstream to aid in future debugging.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Expose disk serial in virDomainGetGuestInfo()
Michal Privoznik [Wed, 14 Apr 2021 08:09:35 +0000 (10:09 +0200)]
qemu: Expose disk serial in virDomainGetGuestInfo()

When querying guest info via virDomainGetGuestInfo() the
'guest-get-disks' agent command is called. It may report disk
serial number which we parse, but never report nor use for
anything else.

As it turns out, it may help management application find matching
disk in their internals.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-By: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovircgroupv2devices: refactor virCgroupV2DevicesRemoveProg
Pavel Hrdina [Wed, 14 Apr 2021 10:01:23 +0000 (12:01 +0200)]
vircgroupv2devices: refactor virCgroupV2DevicesRemoveProg

When running on systemd host the cgroup itself is removed by machined
so when we reach this code the directory no longer exist. If libvirtd
was running the whole time between starting and destroying VM the
detection is skipped because we still have both FD in memory. But if
libvirtd was restarted and no operation requiring cgroup devices
executed the FDs would be 0 and libvirt would try to detect them using
the cgroup directory. This results in reporting following errors:

    libvirtd[955]: unable to open '/sys/fs/cgroup/machine.slice/machine-qemu\x2d1\x2dguest.scope/': No such file or directory
    libvirtd[955]: Failed to remove cgroup for guest

When running on non-systemd host where we handle cgroups manually this
would not happen.

When destroying VM it is not necessary to detect the BPF prog and map
because the following code only closes the FDs without doing anything
else. We could run code that would try to detach the BPF prog from the
cgroup but that is not necessary as well. If the cgroup is removed and
there is no other FD open to the prog kernel will cleanup the prog and
map eventually.

Reported-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: properly free BPF prog and map FDs
Pavel Hrdina [Fri, 9 Apr 2021 16:28:09 +0000 (18:28 +0200)]
vircgroupv2: properly free BPF prog and map FDs

When nested cgroup was introduced it did not properly free file
descriptors for BPF prog and map. With nested cgroups we create the BPF
bits in the nested cgroup instead of the VM root cgroup.

This would leak the FDs which would be the last reference to the prog
and map so kernel would not remove the resources as well. It would only
happen once libvirtd process exits.

Fixes: 184245f53b94fc84f727eb6e8a2aa52df02d69c0
Reported-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: Don't fail device enumeration if MDEVCTL is missing
Michal Privoznik [Tue, 13 Apr 2021 09:50:11 +0000 (11:50 +0200)]
nodedev: Don't fail device enumeration if MDEVCTL is missing

After all devices were enumerated, the enumeration thread call
nodeDeviceUpdateMediatedDevices() to refresh the state of
mediated devices. This means that 'mdevctl' will be executed. But
it may be missing on some systems (e.g. mine) in which case we
should just skip the update of mdevs instead of failing whole
device enumeration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Mark device initialization complete even in case of an error
Michal Privoznik [Tue, 13 Apr 2021 08:45:24 +0000 (10:45 +0200)]
nodedev: Mark device initialization complete even in case of an error

To speed up nodedev driver initialization, the device enumeration
is done in a separate thread. Once finished, the thread sets a
boolean variable that allows public APIs to be called (instead of
waiting for the thread to finish).

However, if there's an error in the device enumeration thread
then the control jumps over at the 'error' label and the boolean
is never set. This means, that any virNodeDev*() API is stuck
forever. Mark the initialization as complete (the thread is
quitting anyway) and let the APIs proceed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Wait for device initialization in all public API callbacks
Michal Privoznik [Tue, 13 Apr 2021 09:18:23 +0000 (11:18 +0200)]
nodedev: Wait for device initialization in all public API callbacks

Although I have not experienced this in real life, there is a
possible race condition when creating new device, getting its XML
or parent or listing its capabilities.  If the nodedev driver is
still enumerating devices (in a separate thread) and one of
virNodeDeviceGetXMLDesc(), virNodeDeviceGetParent(),
virNodeDeviceNumOfCaps(), virNodeDeviceListCaps() or
virNodeDeviceCreate() is called then it can lead to spurious
results because the device enumeration thread is removing devices
from or adding them to the internal list of devices (among with
their states).

Therefore, wait for things to settle down before proceeding with
any of the APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Signal initCond with driver locked
Michal Privoznik [Tue, 13 Apr 2021 08:52:07 +0000 (10:52 +0200)]
nodedev: Signal initCond with driver locked

This is more academic dispute than a real bug, but this is taken
from pthread_cond_broadcast(3p) man:

  The pthread_cond_broadcast() or pthread_cond_signal() functions
  may be called by a thread whether or not it currently owns the
  mutex that threads calling pthread_cond_wait() or
  pthread_cond_timedwait() have associated with the condition
  variable during their waits; however, if predictable scheduling
  behavior is required, then that mutex shall be locked by the
  thread calling pthread_cond_broadcast() or
  pthread_cond_signal().

Therefore, broadcast the initCond while the nodedev driver is
still locked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Rename nodeDeviceWaitInit()
Michal Privoznik [Tue, 13 Apr 2021 09:14:15 +0000 (11:14 +0200)]
nodedev: Rename nodeDeviceWaitInit()

The consensus is to put the verb last. Therefore, the new name is
nodeDeviceInitWait(). This allows us to introduce new function
(done later in a separate commit) that will "complete" the device
initialization.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agolib: Drop internal virXXXPtr typedefs
Michal Privoznik [Thu, 11 Mar 2021 07:16:13 +0000 (08:16 +0100)]
lib: Drop internal virXXXPtr typedefs

Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_conf: properly set 'deprecation_behavior' default value
Pavel Hrdina [Mon, 12 Apr 2021 20:55:02 +0000 (22:55 +0200)]
qemu_conf: properly set 'deprecation_behavior' default value

The comment for that option states that the default value is 'none' but
it was not set by the code. By default the value is NULL which results
into the following warning:

warning : qemuBuildCompatDeprecatedCommandLine:10393 : Unsupported deprecation behavior '(null)' for VM 'test'

Fixes: 700450449377be4bf923e91d00f8fe8cf0975f66
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirfile: Replace AbsPath judgement method with g_path_is_absolute()
Luke Yue [Mon, 12 Apr 2021 14:04:27 +0000 (22:04 +0800)]
virfile: Replace AbsPath judgement method with g_path_is_absolute()

The g_path_is_absolute() considers more situations
than just a simply "path[0] == '/'".

Related issue: https://gitlab.com/libvirt/libvirt/-/issues/12
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoRemove references to deleted Makefile.am
Tim Wiederhake [Tue, 13 Apr 2021 07:28:31 +0000 (09:28 +0200)]
Remove references to deleted Makefile.am

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuBlockJobProcessEventCompletedPull: Add backingStore terminators if base is NULL
Peter Krempa [Mon, 12 Apr 2021 15:42:23 +0000 (17:42 +0200)]
qemuBlockJobProcessEventCompletedPull: Add backingStore terminators if base is NULL

When doing a blockpull with NULL base the full contents of the disk are
pulled into the topmost image which then becomes fully self-contained.

qemuBlockJobProcessEventCompletedPull doesn't install the backing chain
terminators though, although it's guaranteed that there will be no
backing chain behind disk->src.

Add the terminators for completness and for disabling backing chain
detection on further boots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuBlockJobProcessEventCompletedPull: Avoid dangling pointer after blockpull
Peter Krempa [Mon, 12 Apr 2021 15:24:22 +0000 (17:24 +0200)]
qemuBlockJobProcessEventCompletedPull: Avoid dangling pointer after blockpull

When doing a full block pull job (base == NULL) and the config XML
contains a compatible disk, the completer function would leave a
dangling pointer in 'cfgdisk->src->backingStore' as cfgdisk->src would
be set to the value of 'cfgbase' which was always set to
'cfgdisk->src->backingStore'.

This is wrong though since for the live definition XML we set the
respective counterpart to 'job->data.pull.base' which is NULL in the
above scenario.

This leads to a invalid pointer read when saving the config XML and may
end up in a crash.

Resolve it by setting 'cfgbase' only when 'job->data.pull.base' is
non-NULL.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1946918
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonodedev: Only set up mdevctl monitors if mdevctl.d exist
Michal Privoznik [Mon, 12 Apr 2021 15:26:06 +0000 (17:26 +0200)]
nodedev: Only set up mdevctl monitors if mdevctl.d exist

During its initialization, the nodedev driver tries to set up
monitors for /etc/mdevctl.d directory, so that it can register
mdevs as they come and go. However, if the file doesn't exist
there is nothing to monitor and therefore we can exit early. In
fact, we have to otherwise monitorFileRecursively() fails and
whole driver initialization fails with it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonodedev: Separate mdevctl monitor setup into a function
Michal Privoznik [Mon, 12 Apr 2021 15:15:25 +0000 (17:15 +0200)]
nodedev: Separate mdevctl monitor setup into a function

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonodedev: Don't join not spawned threads
Michal Privoznik [Mon, 12 Apr 2021 14:25:13 +0000 (16:25 +0200)]
nodedev: Don't join not spawned threads

During the nodedev driver initialization two threads are created:
one for listening on udev events (like device plug/unplug) and
the other for enumerating devices (so that the main thread doing
the driver init is not blocked). If something goes wrong at any
point then nodeStateCleanup() is called which joins those two
threads (possibly) created before. But it tries to join them even
they weren't created which is undefined behaviour (and it just so
happens that it crashes on my system).

If those two virThread variables are turned into pointers then we
can use comparison against NULL to detect whether threads were
created.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonodedev: Lock @priv sooner
Michal Privoznik [Mon, 12 Apr 2021 14:20:57 +0000 (16:20 +0200)]
nodedev: Lock @priv sooner

The nodedev driver private data object @priv is created by
calling udevEventDataNew(). After that, driver->privateData
pointer is set to the freshly allocated object and only a few
lines after all of this the object is locked. Technically it is
safe because there should not be any other thread at this point,
but defensive style of programming says it's better if the object
is locked before driver's privateData is set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonodedev: Unlock @priv if initialization of mdevctlMonitors fails
Michal Privoznik [Mon, 12 Apr 2021 14:18:24 +0000 (16:18 +0200)]
nodedev: Unlock @priv if initialization of mdevctlMonitors fails

If initialization of priv->mdevctlMonitors fails, then the
control jumps over to cleanup label where nodeStateCleanup() is
called which tries to lock @priv. But since @priv was already
locked before taking the jump a deadlock occurs. The solution is
to jump onto @unlock label, just like the code around is doing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agobhyve: Fix declaration of 'params' in 'bhyveParsePCIFbuf'
Peter Krempa [Mon, 12 Apr 2021 16:18:49 +0000 (18:18 +0200)]
bhyve: Fix declaration of 'params' in 'bhyveParsePCIFbuf'

In commit ad80bba90a3 I mistakenly didn't delete '**' from the
variable declaration when converting it to 'GStrv' and deleted the
'separator' variable since it was declared on the same line as a
different variable.

Fixes: ad80bba90a3
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
4 years agoci: README: Mention necessary step for cirrus to pick up the github project
Peter Krempa [Wed, 7 Apr 2021 08:59:26 +0000 (10:59 +0200)]
ci: README: Mention necessary step for cirrus to pick up the github project

Unless you create such an commit, cirrus-ci.com will not pick up the
github project and cirrus-run will fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotests: qemucapabilitiesdata: Fix wrong command identifier in caps_4.0.0.riscv64.replies
Peter Krempa [Thu, 8 Apr 2021 15:08:09 +0000 (17:08 +0200)]
tests: qemucapabilitiesdata: Fix wrong command identifier in caps_4.0.0.riscv64.replies

Commit cbd4ab4cc69 added a hunk with a broken reply ID.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemucapabilitiesdata: Fix formatting of manually added hunk
Peter Krempa [Thu, 8 Apr 2021 14:50:18 +0000 (16:50 +0200)]
tests: qemucapabilitiesdata: Fix formatting of manually added hunk

Commit 66c5674e797 added a query for the device properties of 'usb-host'
but the command header isn't formated the same way as if it were
autogenerated. Reformat all the files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2xmltest: Always include basic set of capabilities
Peter Krempa [Fri, 9 Apr 2021 13:41:53 +0000 (15:41 +0200)]
qemuxml2xmltest: Always include basic set of capabilities

Use virQEMUCapsInitQMPBasicArch to add the basic set of capabilities
which all qemu versions will get.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2argvtest: Parse 'arch' from XML early
Peter Krempa [Fri, 9 Apr 2021 13:18:41 +0000 (15:18 +0200)]
qemuxml2argvtest: Parse 'arch' from XML early

If we want to provide correct (fake) caps already for the XML parser we
need to be able to parse the arch early so that we can properly
initialize the caps cache prior to calling the XML parser.

This patch adds code which parses the arch and updates the caps cache
prior to the parse step.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2argvtest: Rewrite parsing of XMLs to provide earlier parsing
Peter Krempa [Wed, 31 Mar 2021 14:11:42 +0000 (16:11 +0200)]
qemuxml2argvtest: Rewrite parsing of XMLs to provide earlier parsing

In upcoming patches we'll need to parse a certain bit of XML before
calling the full XML parser. This effectively open-codes what
virDomainDefParseFile to reach virDomainDefParseNode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirQEMUCapsInitQMPBasicArch: Use switch for arch-based decisions
Peter Krempa [Tue, 30 Mar 2021 15:05:01 +0000 (17:05 +0200)]
virQEMUCapsInitQMPBasicArch: Use switch for arch-based decisions

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2(argv|xml)test: Don't exit early when testQemuInfoSetArgs fails
Peter Krempa [Fri, 26 Mar 2021 17:21:34 +0000 (18:21 +0100)]
qemuxml2(argv|xml)test: Don't exit early when testQemuInfoSetArgs fails

Set the return code to failure and continue testing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2xmltest: testInfoSetPaths: Remove return value
Peter Krempa [Fri, 26 Mar 2021 17:53:32 +0000 (18:53 +0100)]
qemuxml2xmltest: testInfoSetPaths: Remove return value

The function doesn't fail. Remove the return value and checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs/platforms: Drop separate link to qemu-kvm on repology.org
Peter Krempa [Fri, 26 Mar 2021 16:12:54 +0000 (17:12 +0100)]
docs/platforms: Drop separate link to qemu-kvm on repology.org

The qemu-kvm page redirects to qemu on repology.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoRemove test 'args' file rewrapping infrastructure
Peter Krempa [Tue, 6 Apr 2021 14:49:47 +0000 (16:49 +0200)]
Remove test 'args' file rewrapping infrastructure

All tests which use files with 'ldargs' and 'args' suffix as output now
use the internal and better line splitting.

Remove the test-wrap-argv.py script, the syntax check which used it and
the helper rewrapping the output when regenerating test output.

For any further use, we require code to use virCommand anyways and thus
it has internal wrapping now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonodedevmdevctltest: Use internal linewrapping and variable command path stripping
Peter Krempa [Fri, 9 Apr 2021 07:21:28 +0000 (09:21 +0200)]
nodedevmdevctltest: Use internal linewrapping and variable command path stripping

Remove `nodedevCompareToFile` which was stripping the path to mdevctl
since it's no longer needed if we use the new features of
virCommandSetDryRun.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agobhyvexml2argvtest: Use internal wrapping of command line arguments
Peter Krempa [Wed, 31 Mar 2021 08:46:36 +0000 (10:46 +0200)]
bhyvexml2argvtest: Use internal wrapping of command line arguments

virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

The main advantage is that arguments for an option are always on the
same line which makes it more easy to see what changed in a diff and
prevents re-wrapping of the line if a wrapping point moves over the
threshold.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonwfilterxml2firewalldata: Use internal wrapping to wrap output files
Peter Krempa [Tue, 6 Apr 2021 12:19:40 +0000 (14:19 +0200)]
nwfilterxml2firewalldata: Use internal wrapping to wrap output files

As with previous commits use virCommandSetDryRun to invoke
virCommandToString so that it returns pre-wrapped string.

Since virCommand is better aware of where the arguments terminate we can
see an improvement where comments are no longer line-wrapped.

The changes to the 'commonRules' strings were done with the following
regex:

 s/ -/ \\\\\\n-/

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonetworkxml2firewalltest: Use internal wrapping of command line arguments
Peter Krempa [Wed, 31 Mar 2021 08:46:36 +0000 (10:46 +0200)]
networkxml2firewalltest: Use internal wrapping of command line arguments

virCommandSetDryRun allows to invoke virCommandToString so that the
command string is already wrapped.

We now also need to load the base arguments file without unwrapping the
arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agostoragevolxml2argvtest: Use internal wrapping of command line arguments
Peter Krempa [Wed, 31 Mar 2021 08:46:36 +0000 (10:46 +0200)]
storagevolxml2argvtest: Use internal wrapping of command line arguments

virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agostoragepoolxml2argvtest: Use internal wrapping of command line arguments
Peter Krempa [Wed, 31 Mar 2021 08:46:36 +0000 (10:46 +0200)]
storagepoolxml2argvtest: Use internal wrapping of command line arguments

virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agostorage: Format mount options before positional arguments
Peter Krempa [Tue, 6 Apr 2021 14:40:42 +0000 (16:40 +0200)]
storage: Format mount options before positional arguments

Move calls to virStorageBackendFileSystemMountAddOptions earlier so that
the options are formatted before the positional arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2argvtest: Use internal wrapping of command line arguments
Peter Krempa [Wed, 31 Mar 2021 08:46:36 +0000 (10:46 +0200)]
qemuxml2argvtest: Use internal wrapping of command line arguments

virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

The main advantage is that arguments for an option are always on the
same line which makes it more easy to see what changed in a diff and
prevents re-wrapping of the line if a wrapping point moves over the
threshold.

Additionally the used output is the same we have in the VM log file when
a VM is starting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agosyntax-check: Remove 90 char limit for 'argv' files
Peter Krempa [Wed, 31 Mar 2021 07:39:29 +0000 (09:39 +0200)]
syntax-check: Remove 90 char limit for 'argv' files

Splitting lines with arguments causes in many cases a rewrap if the
arguments are modified making it harder to see what actually changed.

In upcoming patches some rewrapping of 'args' files will be removed so
remove this check first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirCommandToStringFull: Improve linebreaking behaviour
Peter Krempa [Tue, 6 Apr 2021 13:17:42 +0000 (15:17 +0200)]
virCommandToStringFull: Improve linebreaking behaviour

Put multiple values for an option if followed by another option as used
in certain iptables arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirTestLoadFileJSON: Don't try to unwrap JSON documents
Peter Krempa [Wed, 31 Mar 2021 07:29:22 +0000 (09:29 +0200)]
virTestLoadFileJSON: Don't try to unwrap JSON documents

Use virFileReadAll to load the file instead of virTestLoadFile which
tries to unwrap the file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirTestCompareToFile: Add possibility to skip unwrapping of input file
Peter Krempa [Wed, 31 Mar 2021 07:18:57 +0000 (09:18 +0200)]
virTestCompareToFile: Add possibility to skip unwrapping of input file

In some cases we might want to compare already wrapped data against a
wrapped file. Introduce virTestCompareToFileFull with a 'unwrap' boolean
which will control the unwrapping.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotestutils: Remove unused virTestClearCommandPath
Peter Krempa [Tue, 6 Apr 2021 09:24:47 +0000 (11:24 +0200)]
testutils: Remove unused virTestClearCommandPath

virCommand(ToString) now provides the functionality internally so we
don't have to keep the string-munging function around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonwfilterebiptablestest: Strip path from test output via virCommandSetDryRun
Peter Krempa [Tue, 6 Apr 2021 09:21:21 +0000 (11:21 +0200)]
nwfilterebiptablestest: Strip path from test output via virCommandSetDryRun

Enable the internal path clearing instead of using
virTestClearCommandPath.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonwfilterxml2firewalltest: Strip path from test output via virCommandSetDryRun
Peter Krempa [Tue, 6 Apr 2021 09:21:21 +0000 (11:21 +0200)]
nwfilterxml2firewalltest: Strip path from test output via virCommandSetDryRun

Enable the internal path clearing instead of using
virTestClearCommandPath.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agonetworkxml2firewalltest: Strip path from test output via virCommandSetDryRun
Peter Krempa [Tue, 6 Apr 2021 09:21:21 +0000 (11:21 +0200)]
networkxml2firewalltest: Strip path from test output via virCommandSetDryRun

Enable the internal path clearing instead of using
virTestClearCommandPath.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirCommandSetDryRun: Add flags to linebreak and strip prefix from the command buffer
Peter Krempa [Tue, 6 Apr 2021 08:56:23 +0000 (10:56 +0200)]
virCommandSetDryRun: Add flags to linebreak and strip prefix from the command buffer

virCommandToStringFull used internally when virCommandSetDryRun is
requested allows to strip command path and wrap lines nicely. Expose
these via virCommandSetDryRun so that tests can use those features
instead of local hacks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirCommandSetDryRun: Rework resetting of the dry run data
Peter Krempa [Thu, 1 Apr 2021 15:54:09 +0000 (17:54 +0200)]
virCommandSetDryRun: Rework resetting of the dry run data

While virCommandSetDryRun is used in tests only, there were some cases
when error paths would not call the function with NULL arguments to
reset the dry run infrastructure.

Introduce virCommandDryRunToken type which must be allocated via
virCommandDryRunTokenNew and passed to virCommandSetDryRun.

This way we can use automatic variable cleaning to trigger the cleanup
of virCommandSetDryRun parameters and also the use of the token variable
ensures that all callers of virCommandSetDryRun clean up after
themselves and also that the token isn't left unused in the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotests: storagepoolxml2argvtest: Use integrated command path stripping
Peter Krempa [Tue, 6 Apr 2021 16:38:57 +0000 (18:38 +0200)]
tests: storagepoolxml2argvtest: Use integrated command path stripping

Replace virTestClearCommandPath by virCommandToStringFull which allows
to strip the command prefix internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirCommandToString: Allow stripping command path
Peter Krempa [Thu, 1 Apr 2021 14:09:54 +0000 (16:09 +0200)]
virCommandToString: Allow stripping command path

In tests we don't want to use the full path to commands as it's
unpleasant to keep that working on all systems.

Add an integrated way to strip the prefix which will be used to replace
virTestClearCommandPath() as a more systemic solution.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2xmloutdata: Remove unused symlinks to test XML files
Peter Krempa [Fri, 26 Mar 2021 17:09:33 +0000 (18:09 +0100)]
qemuxml2xmloutdata: Remove unused symlinks to test XML files

The symlinks are not used by the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2xmloutdata: Remove unused output XML files
Peter Krempa [Fri, 26 Mar 2021 17:01:06 +0000 (18:01 +0100)]
qemuxml2xmloutdata: Remove unused output XML files

The files are no longer referenced by existing test cases. Remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2argvdata: Remove unused 'xml' files
Peter Krempa [Fri, 26 Mar 2021 16:47:17 +0000 (17:47 +0100)]
qemuxml2argvdata: Remove unused 'xml' files

The files are no longer referenced by either qemuxml2argvtest or
qemuxml2xmltest. Remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuxml2argvdata: Remove unused 'args' files
Peter Krempa [Fri, 26 Mar 2021 16:39:43 +0000 (17:39 +0100)]
qemuxml2argvdata: Remove unused 'args' files

The files were added in error (audio-*) for test cases which produce an
error, left over after converting to DO_TEST_CAPS_LATEST
(disk-detect-zeroes), or left over after splitting test cases
(disk-network-tlsx509).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotests: string: Remove pointless test for virStringListFreeCount
Peter Krempa [Tue, 23 Mar 2021 17:33:26 +0000 (18:33 +0100)]
tests: string: Remove pointless test for virStringListFreeCount

It's way more useful to run valgrind against the rest of the code than
this test to see whether virStringListFreeCount works. Remove the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virstring: Remove the virStringSplitCount wrapper funcion
Peter Krempa [Tue, 23 Mar 2021 17:17:40 +0000 (18:17 +0100)]
util: virstring: Remove the virStringSplitCount wrapper funcion

Callers which need the count of elements now count it in place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirVMXParseConfig: Replace virStringSplitCount by g_strsplit
Peter Krempa [Thu, 1 Apr 2021 13:36:49 +0000 (15:36 +0200)]
virVMXParseConfig: Replace virStringSplitCount by g_strsplit

Remove the last usage of virStringSplitCount

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirSystemdActivationInitFromNames: Replace virStringSplit by g_strsplit
Peter Krempa [Thu, 1 Apr 2021 13:35:39 +0000 (15:35 +0200)]
virSystemdActivationInitFromNames: Replace virStringSplit by g_strsplit

While the code invokes the string list length calculation twice, it
happens only on error path, which by itself should never happen.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoopenvzParseBarrierLimit: Rework string handling
Peter Krempa [Thu, 1 Apr 2021 13:34:52 +0000 (15:34 +0200)]
openvzParseBarrierLimit: Rework string handling

Use g_strsplit instead of virStringSplitCount and automatically free the
temporary string list.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseXLVnuma: Replace virStringSplitCount by g_strsplit
Peter Krempa [Thu, 1 Apr 2021 13:34:03 +0000 (15:34 +0200)]
xenParseXLVnuma: Replace virStringSplitCount by g_strsplit

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParsePCI: Replace virStringSplitCount by g_strsplit
Peter Krempa [Thu, 1 Apr 2021 13:33:22 +0000 (15:33 +0200)]
xenParsePCI: Replace virStringSplitCount by g_strsplit

Count the number of elements in place just for the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virresctrl: Use g_strsplit instead of virStringSplitCount
Peter Krempa [Tue, 23 Mar 2021 17:06:33 +0000 (18:06 +0100)]
util: virresctrl: Use g_strsplit instead of virStringSplitCount

In 3 of 4 instances the code didn't even need the count of the elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virresctrl: Remove empty 'cleanup' sections
Peter Krempa [Tue, 23 Mar 2021 16:50:52 +0000 (17:50 +0100)]
util: virresctrl: Remove empty 'cleanup' sections

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virresctrl: Use automatic memory freeing
Peter Krempa [Tue, 23 Mar 2021 16:45:16 +0000 (17:45 +0100)]
util: virresctrl: Use automatic memory freeing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirResctrlAllocGetUnused: Use g_autoptr for variables of virResctrlAlloc type
Peter Krempa [Tue, 23 Mar 2021 16:43:47 +0000 (17:43 +0100)]
virResctrlAllocGetUnused: Use g_autoptr for variables of virResctrlAlloc type

Refactor the handling of variables so that the cleanup section can be
sanitized.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirResctrlAllocNewFromInfo: Use g_autoptr for 'ret'
Peter Krempa [Tue, 23 Mar 2021 16:42:31 +0000 (17:42 +0100)]
virResctrlAllocNewFromInfo: Use g_autoptr for 'ret'

Remove 'cleanup' and 'error' labels by switching 'ret' to automatic
pointer and stealing it in the return statement.

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