]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agovirNWFilterCreateVarsFrom: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 08:20:38 +0000 (10:20 +0200)] 
virNWFilterCreateVarsFrom: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterCreateVarsFrom: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:20:07 +0000 (10:20 +0200)] 
virNWFilterCreateVarsFrom: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirSystemdActivationNew: Remove superfluous `goto`s
Tim Wiederhake [Tue, 6 Jul 2021 11:38:53 +0000 (13:38 +0200)] 
virSystemdActivationNew: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirSystemdActivationNew: Use automatic memory management
Tim Wiederhake [Tue, 6 Jul 2021 11:38:05 +0000 (13:38 +0200)] 
virSystemdActivationNew: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirSystemdActivationNew: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 11:36:19 +0000 (13:36 +0200)] 
virSystemdActivationNew: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNWFilterLearnInit: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:27:16 +0000 (10:27 +0200)] 
virNWFilterLearnInit: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterIPAddrMapInit: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:26:21 +0000 (10:26 +0200)] 
virNWFilterIPAddrMapInit: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterDoInstantiate: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:25:30 +0000 (10:25 +0200)] 
virNWFilterDoInstantiate: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterParseParamAttributes: Remove superfluous `goto`s
Tim Wiederhake [Wed, 14 Jul 2021 09:11:01 +0000 (11:11 +0200)] 
virNWFilterParseParamAttributes: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterParseParamAttributes: Simplify loop body
Tim Wiederhake [Wed, 14 Jul 2021 09:08:50 +0000 (11:08 +0200)] 
virNWFilterParseParamAttributes: Simplify loop body

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterParseParamAttributes: Use automatic memory management
Tim Wiederhake [Wed, 14 Jul 2021 08:49:23 +0000 (10:49 +0200)] 
virNWFilterParseParamAttributes: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterParseParamAttributes: Remove tautological `if`
Tim Wiederhake [Wed, 14 Jul 2021 08:42:58 +0000 (10:42 +0200)] 
virNWFilterParseParamAttributes: Remove tautological `if`

`cur` is guaranteed to be of type `XML_ELEMENT_NODE` by using
`xmlFirstElementChild()` and `xmlNextElementSibling()`.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterParseParamAttributes: Iterate over "element" children
Tim Wiederhake [Tue, 6 Jul 2021 08:35:27 +0000 (10:35 +0200)] 
virNWFilterParseParamAttributes: Iterate over "element" children

"xmlNextElementSibling()" skips attribute nodes, making the explicit
check for the type of `cur` redundant. This prepares for the removal
of this check in the next commit.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNWFilterParseParamAttributes: `virHashNew` cannot return NULL
Tim Wiederhake [Tue, 6 Jul 2021 08:30:34 +0000 (10:30 +0200)] 
virNWFilterParseParamAttributes: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: Add AUTOPTR_CLEANUP_FUNC for virNWFilterVarValue
Tim Wiederhake [Tue, 6 Jul 2021 09:09:56 +0000 (11:09 +0200)] 
conf: Add AUTOPTR_CLEANUP_FUNC for virNWFilterVarValue

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh: fix setmem flags logic
Pavel Hrdina [Thu, 22 Jul 2021 19:00:50 +0000 (21:00 +0200)] 
virsh: fix setmem flags logic

When we dropped virDomainSetMemory usage it got kind of tricky to
figure out the flags correctly.

Originally the logic was following:

    no option | --current | --live | --config | --live --config
    ----------+-----------+--------+----------+----------------
       LIVE   |  CURRENT  |  LIVE  |  CONFIG  |  LIVE & CONFIG

But after the commit removing virDomainSetMemory usage it changed to:

    no option | --current | --live |    --config     | --live --config
    ----------+-----------+--------+-----------------+----------------
       LIVE   |  CURRENT  |  LIVE  |  LIVE & CONFIG  |  LIVE & CONFIG

This commit fixes the logic back to the original behavior except for
ESX, HyperV and Virtuozzo drivers where virDomainSetMemory() default
behavior was CURRENT instead of LIVE.

Fixes: ce8138564bba0def7d7195814fba4555915d60d5
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1980199
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Add grabToggle to evdev input
Justin Gatzen [Thu, 22 Jul 2021 06:58:45 +0000 (02:58 -0400)] 
conf: Add grabToggle to evdev input

Add support for customizable grabToggle key combinations with
<input type='evdev'>.

Signed-off-by: Justin Gatzen <justin.gatzen@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: process: Extract code for submitting event handling to separate thread
Peter Krempa [Tue, 20 Jul 2021 10:25:46 +0000 (12:25 +0200)] 
qemu: process: Extract code for submitting event handling to separate thread

The submission of the event to the helper thread has a verbose cleanup
path which was duplicated in all the event handlers. Simplify it by
extracting the code into a helper named 'qemuProcessEventSubmit' and
reuse it where appropriate.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainMemoryFailureCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainMemoryFailureCallback

Change the callback prototype and fix the callback registered in the
process code.

The removed error messages are impossible as the enum values are
converted via VIR_ENUM helpers and guarded by compiler checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainGuestCrashloadedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainGuestCrashloadedCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainRdmaGidStatusChangedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainRdmaGidStatusChangedCallback

Change the callback prototype and fix the callback registered in the
process code.

It is also impossible for @info to be non-NULL in the cleanup section so
the cleanup can be completely removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainPRManagerStatusChangedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainPRManagerStatusChangedCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainDumpCompletedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainDumpCompletedCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainBlockThresholdCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainBlockThresholdCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainAcpiOstInfoCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainAcpiOstInfoCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainMigrationPassCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainMigrationPassCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainMigrationStatusCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainMigrationStatusCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainSpiceMigratedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainSpiceMigratedCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainSerialChangeCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainSerialChangeCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainNicRxFilterChangedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainNicRxFilterChangedCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainDeviceDeletedCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainDeviceDeletedCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainGuestPanicCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainGuestPanicCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainPMSuspendDiskCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainPMSuspendDiskCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainBalloonChangeCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainBalloonChangeCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainPMSuspendCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainPMSuspendCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainPMWakeupCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainPMWakeupCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainTrayChangeCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainTrayChangeCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainJobStatusChangeCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainJobStatusChangeCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainBlockJobCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainBlockJobCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainGraphicsCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainGraphicsCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainIOErrorCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainIOErrorCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainWatchdogCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainWatchdogCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainRTCChangeCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainRTCChangeCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainResumeCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainResumeCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainStopCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainStopCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainResetCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainResetCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainShutdownCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainShutdownCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove return value from qemuMonitorDomainEventCallback
Peter Krempa [Tue, 20 Jul 2021 08:05:06 +0000 (10:05 +0200)] 
qemu: Remove return value from qemuMonitorDomainEventCallback

Change the callback prototype and fix the callback registered in the
process code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: monitor: Remove return value from qemuMonitorEmit* functions
Peter Krempa [Tue, 20 Jul 2021 07:35:39 +0000 (09:35 +0200)] 
qemu: monitor: Remove return value from qemuMonitorEmit* functions

The callers in the monitor code invoking the callbacks after events are
received don't actually check the return value from the callbacks and
there isn't really anything we could do on failure.

Remove the return value from the intermediary functions so we can later
remove them from the callback prototypes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: monitor: Remove handlers for the 'POWERDOWN' event
Peter Krempa [Tue, 20 Jul 2021 08:24:07 +0000 (10:24 +0200)] 
qemu: monitor: Remove handlers for the 'POWERDOWN' event

The qemu process code doesn't register a callback for it so we don't
need to be handling it at all.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agostorage_driver: Unlock object on ACL fail in storagePoolLookupByTargetPath
Peter Krempa [Wed, 21 Jul 2021 09:22:25 +0000 (11:22 +0200)] 
storage_driver: Unlock object on ACL fail in storagePoolLookupByTargetPath

'virStoragePoolObjListSearch' returns a locked and refed object, thus we
must release it on ACL permission failure.

Fixes: 7aa0e8c0cb8
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1984318
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosyntax-check: Prohibit 'vir' prefix for enum implementations in virsh
Peter Krempa [Tue, 13 Jul 2021 09:52:20 +0000 (11:52 +0200)] 
syntax-check: Prohibit 'vir' prefix for enum implementations in virsh

Avoid potential conflict of enum helpers declared in virsh.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-volume: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers
Peter Krempa [Mon, 19 Jul 2021 11:23:29 +0000 (13:23 +0200)] 
virsh-volume: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers

Stuff used in virsh should use 'virsh'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-network: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers
Peter Krempa [Mon, 19 Jul 2021 11:23:29 +0000 (13:23 +0200)] 
virsh-network: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers

Stuff used in virsh should use 'virsh'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-domain: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers
Peter Krempa [Mon, 19 Jul 2021 11:23:29 +0000 (13:23 +0200)] 
virsh-domain: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers

Stuff used in virsh should use 'virsh'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-host: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers
Peter Krempa [Mon, 19 Jul 2021 11:23:29 +0000 (13:23 +0200)] 
virsh-host: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers

Stuff used in virsh should use 'virsh'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agonodedev: fix internal error when no defined mdevs exist
Boris Fiuczynski [Wed, 21 Jul 2021 11:30:00 +0000 (13:30 +0200)] 
nodedev: fix internal error when no defined mdevs exist

Commit e9b534905f4 introduced an error when parsing an empty list
returned from mdevctl.

This occurs e.g. if nodedev-undefine is used to undefine the last
defined mdev which causes the following error messages

 libvirtd[33143]: internal error: Unexpected format for mdevctl response
 libvirtd[33143]: internal error: failed to query mdevs from mdevctl:
 libvirtd[33143]: mdevctl failed to updated mediated devices

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
4 years agoqemuxml2argvmock: drop virQEMUCapsGetKVMSupportsSecureGuest
Pavel Hrdina [Thu, 22 Jul 2021 13:15:18 +0000 (15:15 +0200)] 
qemuxml2argvmock: drop virQEMUCapsGetKVMSupportsSecureGuest

It is actually not needed because in qemuxml2argvtest we preload
domaincapsmock as well.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: fix compiling tests with minGW
Pavel Hrdina [Thu, 22 Jul 2021 09:45:38 +0000 (11:45 +0200)] 
tests: fix compiling tests with minGW

We need to mock virQEMUCapsGetKVMSupportsSecureGuest only if compiling
with QEMU otherwise compilation will fail with error:

/usr/lib/gcc/i686-w64-mingw32/11.1.1/../../../../i686-w64-mingw32/bin/ld: tests/libdomaincapsmock.dll.p/domaincapsmock.c.obj: in function `virQEMUCapsGetKVMSupportsSecureGuest':
/builds/libvirt/libvirt/build/../tests/domaincapsmock.c:40: undefined reference to `virQEMUCapsGet'
/usr/lib/gcc/i686-w64-mingw32/11.1.1/../../../../i686-w64-mingw32/bin/ld: /builds/libvirt/libvirt/build/../tests/domaincapsmock.c:41: undefined reference to `virQEMUCapsGet'

Fixes: 248a30c0c0ec2610e8fa2bbbc98da6d06978ad2e
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoci: Halt on sanitizer errors
Tim Wiederhake [Mon, 19 Jul 2021 12:14:20 +0000 (14:14 +0200)] 
ci: Halt on sanitizer errors

The undefined behaviour sanitizer (UBSAN) defaults to merely printing an
error message if it detects undefined behaviour. These error messages often
end up in captured output and do not fail the tests, effectively hiding
the warning. Make the test cases fail to make the issues visible.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirFileReadLimFD: Cast maxlen to size_t before adding
Tim Wiederhake [Thu, 22 Jul 2021 08:30:21 +0000 (10:30 +0200)] 
virFileReadLimFD: Cast maxlen to size_t before adding

If the function is called with maxlen equal to `INT_MAX`, adding
one will trigger a signed integer overflow.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: remove unnecessary restore in virDomainSEVDefParseXML
Boris Fiuczynski [Thu, 22 Jul 2021 09:07:42 +0000 (11:07 +0200)] 
conf: remove unnecessary restore in virDomainSEVDefParseXML

Since commit d399a728f4 placed the restore in the right scope the
restore can get removed in virDomainSEVDefParseXML.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: Restore ctxt's node in right scope
Zhenzhong Duan [Thu, 22 Jul 2021 07:44:18 +0000 (15:44 +0800)] 
conf: Restore ctxt's node in right scope

We just found <qemu:commandline> is ignored in our xml. Further debug
shows that ctxt's node pointer isn't restored in virDomainSecDefParseXML(),
which leads to parsing of remaining elements failed.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agogenericxml2xmltest: Refactor DO_TEST_FULL() calls
Kristina Hanicova [Tue, 20 Jul 2021 14:44:08 +0000 (16:44 +0200)] 
genericxml2xmltest: Refactor DO_TEST_FULL() calls

I have added 2 new macros to call tests which are expected to
fail in order to make the code more consistent and readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agogenericxml2xmltest: Substitute 'inactive' variable with 'active'
Kristina Hanicova [Wed, 21 Jul 2021 07:57:45 +0000 (09:57 +0200)] 
genericxml2xmltest: Substitute 'inactive' variable with 'active'

Having negation in a name of a bool variable seems a bit
confusing to me. I think the substitution makes the code much
more readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Fix error code for SEV launchSecurity unsupported
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:35 +0000 (11:44 +0200)] 
qemu: Fix error code for SEV launchSecurity unsupported

When SEV is not supported but specified in the domain XML by a user it
should not result in an internal error (VIR_ERR_INTERNAL_ERROR)
therefore switching to XML error (VIR_ERR_CONFIG_UNSUPPORTED).

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: Use common id lsec0 for launchSecurity
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:34 +0000 (11:44 +0200)] 
qemu: Use common id lsec0 for launchSecurity

Use the common id 'lsec0' for all launchSecurity types in the QEMU
command line construction.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agodocs: Add s390-pv in domain capabilities documentation
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:33 +0000 (11:44 +0200)] 
docs: Add s390-pv in domain capabilities documentation

Add documentation for domain capability s390-pv.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: Add availability of s390-pv in domain capabilities
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:32 +0000 (11:44 +0200)] 
conf: Add availability of s390-pv in domain capabilities

Adding availability of s390-pv in domain capabilities and adjust tests.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agodocs: Add s390-pv documentation
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:31 +0000 (11:44 +0200)] 
docs: Add s390-pv documentation

Add documentation for launch security type s390-pv.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: Add s390-pv as launch security type
Boris Fiuczynski [Wed, 21 Jul 2021 11:17:40 +0000 (13:17 +0200)] 
conf: Add s390-pv as launch security type

Add launch security type 's390-pv' as well as some tests.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: Add s390-pv-guest capability
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:29 +0000 (11:44 +0200)] 
qemu: Add s390-pv-guest capability

Add s390-pv-guest capability.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: Refactor launch security to allow more types
Boris Fiuczynski [Wed, 21 Jul 2021 11:07:51 +0000 (13:07 +0200)] 
conf: Refactor launch security to allow more types

Adding virDomainSecDef for general launch security data
and moving virDomainSEVDef as an element for SEV data.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: Make KVMSupportsSecureGuest capability available
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:27 +0000 (11:44 +0200)] 
qemu: Make KVMSupportsSecureGuest capability available

Expose existing KVMSupportsSecureGuest capability.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: Rework SEV XML parse and format methods
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:26 +0000 (11:44 +0200)] 
conf: Rework SEV XML parse and format methods

Make use of virDomainLaunchSecurity enum.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoschemas: Refactor launch security
Boris Fiuczynski [Fri, 16 Jul 2021 09:44:25 +0000 (11:44 +0200)] 
schemas: Refactor launch security

Change launch security to make it reusable for other types.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu_migration: Unregister close callback only if connection still exists
Michal Privoznik [Tue, 20 Jul 2021 15:21:34 +0000 (17:21 +0200)] 
qemu_migration: Unregister close callback only if connection still exists

When doing a peer-to-peer migration it may happen that the
connection to the destination disappears. If that happens,
there's no point in trying to unregister the close callback
because the connection is closed already. It results only in
polluting logs with this message:

  error : virNetSocketReadWire:1814 : End of file while reading data: : Input/output error

and the reason for that is unregistering a connection callback
results in RPC (among other things).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1918211
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agovirIdentityEnsureSystemToken: Fix error message
Tim Wiederhake [Tue, 20 Jul 2021 15:02:31 +0000 (17:02 +0200)] 
virIdentityEnsureSystemToken: Fix error message

This appears to be a copy-paste mistake from the check directly above.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agomeson: disable bogus warnings from sanitizers on Fedora
Daniel P. Berrangé [Mon, 19 Jul 2021 18:16:59 +0000 (19:16 +0100)] 
meson: disable bogus warnings from sanitizers on Fedora

When building with sanitizers on Fedora we get a wierd error
message

In file included from /usr/include/string.h:519,
                 from ../src/internal.h:28,
                 from ../src/util/virsocket.h:21,
                 from ../src/util/virsocketaddr.h:21,
                 from ../src/util/virnetdevip.h:21,
                 from ../src/util/virnetdevip.c:21:
In function ‘memcpy’,
    inlined from ‘virNetDevGetifaddrsAddress’ at ../src/util/virnetdevip.c:702:13,
    inlined from ‘virNetDevIPAddrGet’ at ../src/util/virnetdevip.c:754:16:
/usr/include/bits/string_fortified.h:29:10: error: ‘__builtin_memcpy’ offset [2, 27] from the object at ‘addr’ is out of the bounds of referenced subobject ‘ss_family’ with type ‘short unsigned int’ at offset 0 [-Werror=array-bounds]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/bits/socket.h:175,
                 from /usr/include/sys/socket.h:33,
                 from ../src/util/virsocket.h:66,
                 from ../src/util/virsocketaddr.h:21,
                 from ../src/util/virnetdevip.h:21,
                 from ../src/util/virnetdevip.c:21:
../src/util/virnetdevip.c: In function ‘virNetDevIPAddrGet’:
/usr/include/bits/socket.h:193:5: note: subobject ‘ss_family’ declared here
  193 |     __SOCKADDR_COMMON (ss_);    /* Address family, etc.  */
      |     ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

The code is correct, and this only happens when building at -O2.

The docs for -Warray-bounds say that a value of "2" is known to
be liable to generate false positives. Rather than downgrade the
check everywhere, we do it selectively for sanitizers.

Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agogenericxml2xmltest: Modify cachetune test to include id
Kristina Hanicova [Tue, 20 Jul 2021 12:58:09 +0000 (14:58 +0200)] 
genericxml2xmltest: Modify cachetune test to include id

I changed DO_TEST_DIFFERENT to DO_TEST, which allows us to remove
the duplicate out file. I also added id attribute for domain
element in order to parse it as a live XML ('cachetune id' is in
the output of only live XMLs). Lastly I added id of cachetune to
test its output value.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Allow 'id' attribute for 'cachetune' element
Kristina Hanicova [Tue, 20 Jul 2021 12:58:08 +0000 (14:58 +0200)] 
docs: Allow 'id' attribute for 'cachetune' element

Even though 'id' attribute is output-only, we should accept xml
files containing it.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: add kbase article on how to configure core dumps for QEMU
Daniel P. Berrangé [Tue, 20 Jul 2021 12:11:50 +0000 (13:11 +0100)] 
docs: add kbase article on how to configure core dumps for QEMU

Enabling core dumps is a reasonably straightforward task, but is not
documented clearly. This page provides as easy link to point users
to when they need to debug QEMU.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotestQemuGetLatestCaps: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 14:22:49 +0000 (16:22 +0200)] 
testQemuGetLatestCaps: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuGetLatestCaps: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:22:08 +0000 (16:22 +0200)] 
testQemuGetLatestCaps: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotestQemuGetLatestCaps: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:21:04 +0000 (16:21 +0200)] 
testQemuGetLatestCaps: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorJSONGetAllBlockJobInfo: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 14:17:55 +0000 (16:17 +0200)] 
qemuMonitorJSONGetAllBlockJobInfo: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorJSONGetAllBlockJobInfo: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:17:09 +0000 (16:17 +0200)] 
qemuMonitorJSONGetAllBlockJobInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorJSONGetAllBlockJobInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:09:55 +0000 (16:09 +0200)] 
qemuMonitorJSONGetAllBlockJobInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorGetPRManagerInfo: Remove superfluous `goto`s
Tim Wiederhake [Mon, 5 Jul 2021 14:06:35 +0000 (16:06 +0200)] 
qemuMonitorGetPRManagerInfo: Remove superfluous `goto`s

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorGetPRManagerInfo: Use automatic memory management
Tim Wiederhake [Mon, 5 Jul 2021 14:05:52 +0000 (16:05 +0200)] 
qemuMonitorGetPRManagerInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuMonitorGetPRManagerInfo: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:04:59 +0000 (16:04 +0200)] 
qemuMonitorGetPRManagerInfo: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuStateInitialize: `virHashNew` cannot return NULL
Tim Wiederhake [Mon, 5 Jul 2021 14:19:14 +0000 (16:19 +0200)] 
qemuStateInitialize: `virHashNew` cannot return NULL

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: migration: Use correct flag when preparing block dirty bitmaps
Jim Fehlig [Fri, 16 Jul 2021 15:09:37 +0000 (09:09 -0600)] 
qemu: migration: Use correct flag when preparing block dirty bitmaps

qemuMigrationSrcRunPrepareBlockDirtyBitmaps receives the flags parameter
from qemuMigrationSrcRun, where flags are based on the main API enum
values. Similar to commit f58349c9c6, use the main API enum instead of
internal driver enum when checking flags in
qemuMigrationSrcRunPrepareBlockDirtyBitmaps.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Signal domain condition in qemuProcessStop a bit later
Jiri Denemark [Fri, 16 Jul 2021 13:52:50 +0000 (15:52 +0200)] 
qemu: Signal domain condition in qemuProcessStop a bit later

Signaling the condition before vm->def->id is reset to -1 is dangerous:
in case a waiting thread wakes up, it does not see anything interesting
(the domain is still marked as running) and just enters virDomainObjWait
where it waits forever because the condition will never be signalled
again.

Originally it was impossible to get into such situation because the vm
object was locked all the time between signaling the condition and
resetting vm->def->id, but after commit 860a999802 released in 6.8.0,
qemuDomainObjStopWorker called in qemuProcessStop between
virDomainObjBroadcast and setting vm->def->id to -1 unlocks the vm
object giving other threads a chance to wake up and possibly hang.

In real world, this can be easily reproduced by killing, destroying, or
just shutting down (from the guest OS) a domain while it is being
migrated somewhere else. The migration job would never finish.

So let's make sure we delay signaling the domain condition to the point
when a woken up thread can detect the domain is not active anymore.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirThreadPoolNewFull: Prevent expanding worker pool by zero
Tim Wiederhake [Fri, 9 Jul 2021 13:09:10 +0000 (15:09 +0200)] 
virThreadPoolNewFull: Prevent expanding worker pool by zero

On libvirtd startup, the list of priority worker threads is uninitialized
(`pool->prioWorkers` is NULL), and then "expanded" to zero (`prioWorkers`)
entries.

This causes `virThreadPoolExpand` to call `VIR_EXPAND_N` on a null pointer
and an increment of zero. The zero increment triggers `virReallocN` to not
actually allocate any memory and leave the pointer NULL, which, eventually,
causes `memset(NULL, 0, 0)` to be called in `virExpandN`.

`memset` is declared `__attribute__ ((__nonnull__ 1))`, which triggers the
following warning when libvirt is compiled with address sanitizing enabled:

    $ meson -Dbuildtype=debug -Db_lundef=false -Db_sanitize=address,undefined
    build && ninja -C build
    $ ./build/run build/src/libvirtd
    src/util/viralloc.c:82:5: runtime error: null pointer passed as
    argument 1, which is declared to never be null

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoviralloc: Delete VIR_INSERT_ELEMENT_COPY and VIR_INSERT_ELEMENT_COPY_INPLACE
Tim Wiederhake [Thu, 8 Jul 2021 12:25:51 +0000 (14:25 +0200)] 
viralloc: Delete VIR_INSERT_ELEMENT_COPY and VIR_INSERT_ELEMENT_COPY_INPLACE

There are no users left.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirQEMUCapsGetMachineTypesCaps: Use GPtrArray
Tim Wiederhake [Thu, 8 Jul 2021 11:10:38 +0000 (13:10 +0200)] 
virQEMUCapsGetMachineTypesCaps: Use GPtrArray

This simplyfies the code a bit and removes one "goto", one "VIR_FREE",
and one "VIR_INSERT_ELEMENT_COPY".

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotest_driver: Implement virDomainGetControlInfo and add test
Luke Yue [Tue, 13 Jul 2021 12:21:32 +0000 (20:21 +0800)] 
test_driver: Implement virDomainGetControlInfo and add test

As test driver won't have real background job running, in order to get
all possible states, the time is used here to decide which state to be
returned. The default time will get `ok` as return value.

Note that using `virsh domtime fc4 200` won't take effect for the test
driver, to get other states, you have to enter virsh interactive
terminal and set time.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Fix crash in virQEMUCapsProbeQMPTPM
Peter Krempa [Mon, 12 Jul 2021 12:55:42 +0000 (14:55 +0200)] 
qemu: Fix crash in virQEMUCapsProbeQMPTPM

If the queried QMP command doesn't exist qemuMonitorGetTPMModels returns
0 but sets the string list to NULL which isn't accepted by
g_strv_contains.

Fixes: a5bc5f0ecf8
Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirsh: allow nodedev-list --all --tree
Jonathon Jongsma [Wed, 7 Jul 2021 21:29:29 +0000 (16:29 -0500)] 
virsh: allow nodedev-list --all --tree

Allow the tree view with --all so that we can see all inactive mdevs in
a tree structure nested under their parent devices.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>