]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
3 years agoqemu_snapshot: revert: drop unused loadvm code
Pavel Hrdina [Wed, 10 Nov 2021 14:59:26 +0000 (15:59 +0100)] 
qemu_snapshot: revert: drop unused loadvm code

Now that we always restart QEMU process the loadvm code is unused and
can be dropped.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: always restart QEMU process for running VM
Pavel Hrdina [Wed, 10 Nov 2021 14:44:07 +0000 (15:44 +0100)] 
qemu_snapshot: revert: always restart QEMU process for running VM

Our compatibility check code isn't complete and there are cases where it
fails to detect incompatible configuration and the revert fails. In
addition future support for external snapshot will always require
restarting the QEMU process.

To unify the behavior drop the compatibility check code and always
restart the QEMU process.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: always error out if VM XML is missing
Pavel Hrdina [Wed, 10 Nov 2021 12:55:58 +0000 (13:55 +0100)] 
qemu_snapshot: revert: always error out if VM XML is missing

The support to revert snapshots was introduced in libvirt 0.8.0 but
saving the whole VM XML was implemented later in libvirt 0.9.5.

That is more then 10 years ago so we can safely assume that nobody will
try reverting to snapshot created by that old libvirt. In the unlikely
scenario where someone would actually did it we would simply error out.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoutil: fix various ATTRIBUTE_NONNULL calls
Pavel Hrdina [Fri, 19 Nov 2021 17:01:23 +0000 (18:01 +0100)] 
util: fix various ATTRIBUTE_NONNULL calls

Git bisect took me to commit where incorrect usage of ATTRIBUTE_NONNULL
was introduced and caused coverity scan to fail. This patch fixes the
issue where the index starts from 1 and not 0 and two other different
cases.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Switch to -accel
Michal Privoznik [Fri, 5 Nov 2021 08:38:10 +0000 (09:38 +0100)] 
qemu: Switch to -accel

We currently use -machine accel=XXX which is just a syntax sugar
for -accel XXX. The former doesn't allow specifying arguments for
accelerator, because all arguments passed to -machine are
treated as arguments of machine itself.

The -accel argument was introduced in QEMU commit
v2.9.0-rc0~70^2~19 and since our minimum required version is
newer (2.11.0) we can safely assume its existence and use it
without any capability.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/233
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_command: Don't validate accelerator when building cmd line
Michal Privoznik [Fri, 5 Nov 2021 08:33:45 +0000 (09:33 +0100)] 
qemu_command: Don't validate accelerator when building cmd line

The domain accelerator was validated in qemuValidateDomainDef()
which calls virQEMUCapsIsVirtTypeSupported() which reports proper
error if QEMU is not capable of KVM/TCG. There is no point in
doing the validation again when building command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Modernize construction of JSON objects
Peter Krempa [Thu, 14 Oct 2021 12:17:02 +0000 (14:17 +0200)] 
qemuMonitorJSONAttachCharDevGetProps: Modernize construction of JSON objects

Use 'virJSONValueObjectAdd' instead of the step-by-step manual JSON
object building.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONBuildChrChardevReconnect: Unify with qemuBuildChrChardevReconnectStr
Peter Krempa [Fri, 19 Nov 2021 12:25:00 +0000 (13:25 +0100)] 
qemuMonitorJSONBuildChrChardevReconnect: Unify with qemuBuildChrChardevReconnectStr

When formatting the commandline we explicitly set the reconnect timeout
to 0 when it's disabled even when that's the default. Do the same in
the monitor/hotplug code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Rename 'backend_type' and 'data'
Peter Krempa [Fri, 19 Nov 2021 12:17:27 +0000 (13:17 +0100)] 
qemuMonitorJSONAttachCharDevGetProps: Rename 'backend_type' and 'data'

Rename 'data' to 'backendData' so that it's more clear what the object
represents and 'backend_type' to 'backendType' to go with the common
camel case notation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolib: Drop needless one line labels
Michal Privoznik [Thu, 4 Nov 2021 14:26:07 +0000 (15:26 +0100)] 
lib: Drop needless one line labels

In some cases we have a label that contains nothing but a return
statement. The amount of such labels rises as we use automagic
cleanup. Anyway, such labels are pointless and can be dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_command: Generate -mem-prealloc in one corner case more
Michal Privoznik [Wed, 15 Sep 2021 13:59:59 +0000 (15:59 +0200)] 
qemu_command: Generate -mem-prealloc in one corner case more

When guest has NUMA nodes and QEMU is new enough to report
default RAM ID then ideally we would use -numa memdev= combined
with memory-backend-* combo becasue -mem-path/-mem-prealloc/-numa
mem are deprecated. Well, there is one problem - the .memdev=
attribute is machine type dependent (just look at arguments of
virQEMUCapsGetMachineNumaMemSupported()) and to ensure backwards
compatibility we prefer -numa mem= over -numa memdev=.

But there was one corner case when -mem-prealloc was requested
but not generated on the cmd line. It all starts with
qemuBuildMemCommandLine() which generates just '-m XXX' and
because it sees defaultRAMid and guest NUMA nodes greater than
zero it does nothing more.

Then, qemuBuildNumaCommandLine() sees that -numa mem= is still
supported for given machine type and nothing else set
@needBackend thus qemuBuildMemPathStr() is called which output
-mem-prealloc only in a few cases assuming it was outputted
earlier.

Reported-by: Jing Qi <jinqi@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Introduce another numa-topology test
Michal Privoznik [Wed, 15 Sep 2021 14:05:49 +0000 (16:05 +0200)] 
qemuxml2argvtest: Introduce another numa-topology test

This test shows a bug we have: even though the XML says:

  <allocation mode='immediate'/>

there is no -mem-prealloc nor .prealloc=yes anywhere on the cmd
line. This will be fixed in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_capabilities.c: del 'cleanup' label in virQEMUCapsLoadHostCPUModelInfo()
Daniel Henrique Barboza [Thu, 18 Nov 2021 20:54:33 +0000 (17:54 -0300)] 
qemu_capabilities.c: del 'cleanup' label in virQEMUCapsLoadHostCPUModelInfo()

Create extra g_autofree strings and use them in an adequate scope to
eliminate the need for VIR_FREE() calls and the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agocpu_ppc64.c: remove 'guest' param from ppc64Compute()
Daniel Henrique Barboza [Thu, 18 Nov 2021 14:20:20 +0000 (11:20 -0300)] 
cpu_ppc64.c: remove 'guest' param from ppc64Compute()

ppc64Compute() is used only once, by virCPUppc64Compare(), which
doesn't use the 'guest' parameter. It was last used by an API
called 'cpuGuestData' that was dropped by commit 03fa904c0c0cb2.

Removing the 'guest' parameter will not only remove unused code from
ppc64Compute() but also remove the ppc64MakeCPUData() entirely.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: remove cleanup label from virQEMUCapsLoadCache()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:47:15 +0000 (15:47 -0300)] 
qemu_capabilities.c: remove cleanup label from virQEMUCapsLoadCache()

'str' is no longer being used and the 'cleanup' label can be removed
together with the 'ret' variable.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsValidateArch()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:41:19 +0000 (15:41 -0300)] 
qemu_capabilities.c: add virQEMUCapsValidateArch()

Create a new helper to remove the arch validation logic from the
body of virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsValidateEmulator()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:37:06 +0000 (15:37 -0300)] 
qemu_capabilities.c: add virQEMUCapsValidateEmulator()

Create a new helper to remove the emulator validation logic from the
body of virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: del 'nodes' var from virQEMUCapsLoadCache()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:29:38 +0000 (15:29 -0300)] 
qemu_capabilities.c: del 'nodes' var from virQEMUCapsLoadCache()

The 'nodes' var is not being used.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsParseGIC()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:27:54 +0000 (15:27 -0300)] 
qemu_capabilities.c: add virQEMUCapsParseGIC()

Create a new helper to remove the GIC parse logic from the body of
virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsParseFlags()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:17:44 +0000 (15:17 -0300)] 
qemu_capabilities.c: add virQEMUCapsParseFlags()

Create a new helper to remove the parse capabilities flag logic from the
body of virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu: Fix the check of AMD secure guest support
Vasiliy Ulyanov [Fri, 19 Nov 2021 12:37:38 +0000 (13:37 +0100)] 
qemu: Fix the check of AMD secure guest support

The content of /sys/module/kvm_amd/parameters/sev may vary depending on
the kernel version. Check also for 'Y' and 'y' in addition to '1' to
cover several possible variants. The fix is similar to the one
introduced in commit 3f9c1a4bb841

Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: match by network alias only if aliases are assigned
Ján Tomko [Thu, 18 Nov 2021 15:21:27 +0000 (16:21 +0100)] 
conf: match by network alias only if aliases are assigned

Commit 114e3b423210d316b3326816fd2c33335b1167fe added matching by
aliases for interfaces with same MAC address.
( https://bugzilla.redhat.com/show_bug.cgi?id=1926190 )

However, unless the domain is using user aliases (prefixed ua-),
there are no aliases in the persistent definition.

Only match by MAC/PCI/other addresses in that case, to fix update-device
with --persistent flag (AFFECT_LIVE | AFFECT_CONFIG).

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

Fixes: 114e3b423210d316b3326816fd2c33335b1167fe
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when prepa...
Peter Krempa [Tue, 16 Nov 2021 13:45:53 +0000 (14:45 +0100)] 
qemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when preparing virStorageSource

Originally the default encryption engine is populated in the disk
post-parse callback code. This works for disks but for any additional
images introduced either via the block copy API or via the backup API we
don't populate the default.

In case when the backup or block copy is requested on an encrypted image
this would then lead to an error:

 error: internal error: Unexpected enum value 0 for virStorageEncryptionEngine

This patch adds another point where we populate the default which is
when setting up a virStorageSource for actual usage.

We keep the original setting in the post-parse callback as that's the
only point that is recorded in the XML file after definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2023674
Fixes: ab1d46d6128
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Add device with 'ramfb=off' to 'hostdev-mdev-display-ramfb'
Peter Krempa [Thu, 18 Nov 2021 08:25:29 +0000 (09:25 +0100)] 
qemuxml2argvtest: Add device with 'ramfb=off' to 'hostdev-mdev-display-ramfb'

Add a test case where 'ramfb' is explicitly disabled for a mediated
device to prevent regressing again.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled
Peter Krempa [Thu, 18 Nov 2021 08:23:09 +0000 (09:23 +0100)] 
qemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled

Before commit 73c352ab8c97d3 which converted the hostdev commandline
formatter to JSON the 'ramfb' property was formatted only if it was
enabled.

The main reason for that is that enabling 'ramfb' switches the device
model to 'vfio-pci-nohotplug' which actually has the property, while
'vfio-pci' (used when 'ramfb' is disabled or absent) doesn't have it.

Restore the logic to format 'ramfb' only when it's enabled and add a
comment that it's deliberate.

Fixes: 73c352ab8c97d3
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2024435
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Fix type for faked chardev backing a TPM
Peter Krempa [Mon, 15 Nov 2021 15:52:52 +0000 (16:52 +0100)] 
qemuxml2argvtest: Fix type for faked chardev backing a TPM

The test filled the chardev type to VIR_DOMAIN_CHR_TYPE_FILE and thus
set the 'data.emulator.source->data.file.path' pointer, but the
commandline formatter is unconditionally expecting VIR_DOMAIN_CHR_TYPE_UNIX
and thus reading 'data.emulator.source->data.nix.path'. Since it's an
union it happened to land in the correct place. Fix the faked data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Properly instantiate virDomainChrSourceDef in virDomainTPMDef
Peter Krempa [Fri, 5 Nov 2021 15:51:22 +0000 (16:51 +0100)] 
conf: Properly instantiate virDomainChrSourceDef in virDomainTPMDef

'virDomainChrSourceDef' contains private data so 'virDomainChrSourceDefNew'
must be used to allocate it. 'virDomainTPMDef' was using it directly
which won't work with the chardev helper functions.

Convert it to a pointer to properly allocate private data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildStorageSourceAttachPrepare(Drive|Chardev): Unexport
Peter Krempa [Thu, 4 Nov 2021 15:50:58 +0000 (16:50 +0100)] 
qemuBuildStorageSourceAttachPrepare(Drive|Chardev): Unexport

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAttachChrDevice: Drop 'dev' variable
Peter Krempa [Thu, 18 Nov 2021 14:35:08 +0000 (15:35 +0100)] 
qemuDomainAttachChrDevice: Drop 'dev' variable

It's referenced only once and it's a shortcut to the chardev source thus
can be used directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAttachChrDeviceAssignAddr: Simplify return value handling
Peter Krempa [Thu, 18 Nov 2021 13:58:26 +0000 (14:58 +0100)] 
qemuDomainAttachChrDeviceAssignAddr: Simplify return value handling

Rather than returning a different error code if the device address needs
to be released pass in the 'need_release' flag via a pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainEnsurePCIAddress: Don't pass virQEMUDriver explicitly
Peter Krempa [Thu, 18 Nov 2021 13:50:28 +0000 (14:50 +0100)] 
qemuDomainEnsurePCIAddress: Don't pass virQEMUDriver explicitly

The function is already getting 'virDomainObj' which has already the
driver pointer present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAddChardevTLSObjects: Refactor cleanup
Peter Krempa [Thu, 18 Nov 2021 13:28:25 +0000 (14:28 +0100)] 
qemuDomainAddChardevTLSObjects: Refactor cleanup

Switch to automatic memory clearing for the two virJSONValues and remove
the 'cleanup' label and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Convert 'chr' in virDomainShmemDef to proper pointer
Peter Krempa [Tue, 2 Nov 2021 15:01:57 +0000 (16:01 +0100)] 
conf: Convert 'chr' in virDomainShmemDef to proper pointer

The main reason is to ensure that the private data are properly
allocated for every instance.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildChrChardevStr: Use proper type for the switch statement
Peter Krempa [Thu, 14 Oct 2021 14:43:00 +0000 (16:43 +0200)] 
qemuBuildChrChardevStr: Use proper type for the switch statement

Add the missing cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Rename qemuBuildHostNetStr -> qemuBuildHostNetProps
Peter Krempa [Thu, 14 Oct 2021 13:35:02 +0000 (15:35 +0200)] 
qemu: command: Rename qemuBuildHostNetStr -> qemuBuildHostNetProps

The function is already returning JSON properties, rename it
accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types
Peter Krempa [Tue, 16 Nov 2021 09:10:16 +0000 (10:10 +0100)] 
qemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types

Use 'virReportEnumRangeError' for the invalid cases and keep the
original error for known but unsupported chardevs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevCommand: Format only the properties
Peter Krempa [Wed, 13 Oct 2021 15:18:50 +0000 (17:18 +0200)] 
qemuMonitorJSONAttachCharDevCommand: Format only the properties

Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev
and rename the function to qemuMonitorJSONAttachCharDevGetProps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAddDeviceProps: Simplify construction of the command
Peter Krempa [Wed, 13 Oct 2021 15:06:15 +0000 (17:06 +0200)] 
qemuMonitorJSONAddDeviceProps: Simplify construction of the command

Use 'qemuMonitorJSONMakeCommandInternal' instead of
'qemuMonitorJSONMakeCommand' + 'virJSONValueObjectAppend'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: hotplug: Add wrapper for qemuMonitorAttachCharDev
Peter Krempa [Thu, 14 Oct 2021 13:53:48 +0000 (15:53 +0200)] 
qemu: hotplug: Add wrapper for qemuMonitorAttachCharDev

Add a simple wrapper for 'qemuMonitorAttachCharDev' named
'qemuHotplugChardevAttach' which will simplify the moving of the
character device property generator out of the monitor code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildCommandLine: Properly check return value of qemuBuildShmemCommandLine
Peter Krempa [Wed, 3 Nov 2021 12:29:15 +0000 (13:29 +0100)] 
qemuBuildCommandLine: Properly check return value of qemuBuildShmemCommandLine

Use the customary '< 0' check for return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_process.c: use g_autoptr() in qemuProcessQMPInitMonitor
Daniel Henrique Barboza [Thu, 18 Nov 2021 14:20:23 +0000 (11:20 -0300)] 
qemu_process.c: use g_autoptr() in qemuProcessQMPInitMonitor

The 'xmlopt' parameter can be auto-unref by using g_autoptr().

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agodomain_conf.h: add autoptr cleanup func to virDomainXMLOptionPtr
Daniel Henrique Barboza [Thu, 18 Nov 2021 14:20:22 +0000 (11:20 -0300)] 
domain_conf.h: add autoptr cleanup func to virDomainXMLOptionPtr

This will enable code cleanups on code that still relies on
virObjectUnref() this pointer manually.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agocpu_x86.c: remove 'guest' param from x86Compute()
Daniel Henrique Barboza [Thu, 18 Nov 2021 14:20:19 +0000 (11:20 -0300)] 
cpu_x86.c: remove 'guest' param from x86Compute()

x86Compute() is a static function called only by virCPUx86Compare()
which passes NULL to the 'guest' parameter of x86Compute().

The last caller of x86Compute() that used it with 'guest' != NULL
was an API called 'cpuGuestData'. This API was dropped by commit
03fa904c0c0cb2 a few years ago. Since then all callers of x86Compute()
uses it with 'guest' = NULL.

Removing the 'guest' parameter allow us to remove a good chunk of
logic that isn't being used for awhile.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agospec: Explicitly provide locations for QEMU data
Andrea Bolognani [Mon, 15 Nov 2021 17:49:26 +0000 (18:49 +0100)] 
spec: Explicitly provide locations for QEMU data

These are the defaults, but we prefer to be explicit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agomeson: Introduce qemu_datadir option
Andrea Bolognani [Mon, 15 Nov 2021 17:13:56 +0000 (18:13 +0100)] 
meson: Introduce qemu_datadir option

There is no guarantee that QEMU and libvirt have been configured
with the same prefix.

In particular, Homebrew on macOS will pass a different, private
prefix for each package version and then use symlinks to make
the files for a specific version appear in the usual locations.

This works perfectly fine as long as one package doesn't try to
go poking around another package's data - which is exactly what
libvirt needs to do in order to read and parse the QEMU interop
data.

qemu_datadir can now be explicitly provided to make this and
other uncommon scenarios work. The common scenario, where QEMU
and libvirt both use the same prefix, is unaffected.

https://gitlab.com/libvirt/libvirt/-/issues/168

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Rename interop locations
Andrea Bolognani [Mon, 15 Nov 2021 17:03:44 +0000 (18:03 +0100)] 
qemu: Rename interop locations

Use abstract names that more closely match the Meson
nomenclature.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Set QEMU data location correctly
Andrea Bolognani [Mon, 15 Nov 2021 17:57:52 +0000 (18:57 +0100)] 
qemu: Set QEMU data location correctly

While datadir must live under prefix, there is no requirement
that its name must necessarily be "share": a different,
arbitrary name could have been provided by the user.

Fixes: 3c876d2428ee3abbb11a50698a9e225cffb72cbc
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agomeson: Define qemu_moddir correctly
Andrea Bolognani [Mon, 15 Nov 2021 17:16:40 +0000 (18:16 +0100)] 
meson: Define qemu_moddir correctly

We can't hardcode /usr here, because the user might have
configured whatever arbitrary prefix.

Everything appeared to be okay because when joining paths
Meson will drop any component that precedes an absolute path
and libdir happens to be absolute, but we should still do
things correctly instead of relying on this.

Fixes: 2ad009eadde27491ff4248f481560953776b2a87
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agospec: Don't create unnecessary directory
Andrea Bolognani [Tue, 16 Nov 2021 10:02:01 +0000 (11:02 +0100)] 
spec: Don't create unnecessary directory

The directory is already created by the build system, so we
don't need to create it explicitly in the spec file; moreover,
the path was incorrect, because it used datadir instead of
localstatedir.

Fixes: 4e041189f85bc1b0f8d5278c0cafdd4aba55beaf
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests/qemuxml2*/graphics-spice-timeout: skip CPU model check
Daniel Henrique Barboza [Tue, 16 Nov 2021 17:21:11 +0000 (12:21 -0500)] 
tests/qemuxml2*/graphics-spice-timeout: skip CPU model check

Commit 65b0b746b516 changed spice tests to use latest caps. Before this
change, "FLAG_REAL_CAPS" wasn't being set in testQemuInfoInitArgs(). The
absence of this flag triggered the code path inside
testCompareXMLToArgv() that executed testUpdateQEMUCaps(). This function
will update the host CPU via virQEMUCapsUpdateHostCPUModel() into
virQEMUCapsInitHostCPUModel(). In this function,
virQEMUCapsInitCPUModel() would end up updating the hostCPU inside the
qemuCaps (via virQEMUCapsProbeHostCPU()). Before the forementioned
commit, the host CPU was being defaulted to x86_64, vendor Intel, for
the 'graphics-spice-timeout' test that is using the 'pc' machine type
and 'accel=kvm'.

Today, "FLAG_REAL_CAPS" is being set because we're using the latest caps
from x86_64. This means that the whole code path mentioned above is
skipped. qemuCaps are now being loaded via virQEMUCapsLoadCache()
directly. Without the handling being done by testUpdateQEMUCaps(), the
host CPU is being retrieved later on, down below
qemuProcessCreatePretendCmdPrepare() into qemuProcessUpdateGuestCPU().
The latter will attempt to update the domain cpu and executing a
virCPUCompare with the hostCPU and def->cpu.

All this logic ended up causing a failure of the
'graphics-spice-timeout' test in ppc64 and s390x hosts. This test is
being run with KVM acceleration, and the KVM driver for ppc64 and s390x
will return a default x86_64 CPU with vendor "AMD", making
virCPUCompare() fail with the following message:

"QEMU XML-2-ARGV graphics-spice-timeout.x86_64-latest   ... libvirt: CPU
Driver error : the CPU is incompatible with host CPU: host CPU vendor does
not match required CPU vendor Intel"

Fix this test by setting cpu check='none' and avoid the virCPUCompare()
that causes the problem for ppc64 and s390x hosts.

Note that this is a build fix. A more adequate fix would be to mock the
getHost() interface of the cpuDriverX86 for non-x86 hosts, allowing
'fullCPU' to be retrieved in qemuProcessUpdateGuestCPU(), and a proper
x86 CPU to be retrieved in the scenario described above.

Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agodocs: Use new URLs for Go modules in downloads page
Andrea Bolognani [Tue, 16 Nov 2021 15:56:11 +0000 (16:56 +0100)] 
docs: Use new URLs for Go modules in downloads page

We've been using the new repositories for a few months now,
but the downloads page still points to the obsolete Go packages.

Fixes: 1832c0a02b3c9ceb518a4338cb3609fd7d1233a2
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: command: Use JSON for parameters of -audiodev
Peter Krempa [Tue, 9 Nov 2021 15:58:22 +0000 (16:58 +0100)] 
qemu: command: Use JSON for parameters of -audiodev

'-audiodev' as a modern implementation based on QAPI already takes JSON
as the argument. Convert our code to use it directly.

The declaration of the QAPI types can be found in
'qemu.git/qapi/audio.json'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Use JSON for parameters of -compat
Peter Krempa [Mon, 8 Nov 2021 15:20:21 +0000 (16:20 +0100)] 
qemu: command: Use JSON for parameters of -compat

'-compat' as a modern implementation based on QAPI already takes JSON as
the argument. Convert our code to use it directly.

QEMU declares the ised QAPI types as:

{ 'enum': 'CompatPolicyInput',
  'data': [ 'accept', 'reject', 'crash' ] }

{ 'enum': 'CompatPolicyOutput',
  'data': [ 'accept', 'hide' ] }

{ 'struct': 'CompatPolicy',
  'data': { '*deprecated-input': 'CompatPolicyInput',
            '*deprecated-output': 'CompatPolicyOutput' } }

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: json: Remove virJSONValueObjectCreate(VArgs)
Peter Krempa [Tue, 9 Nov 2021 15:32:43 +0000 (16:32 +0100)] 
util: json: Remove virJSONValueObjectCreate(VArgs)

The functions were obsoleted by virJSONValueObjectAdd(VArgs)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoReplace virJSONValueObjectCreateVArgs with virJSONValueObjectAddVArgs
Peter Krempa [Tue, 9 Nov 2021 15:31:35 +0000 (16:31 +0100)] 
Replace virJSONValueObjectCreateVArgs with virJSONValueObjectAddVArgs

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: domain: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
virsh: domain: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: migration_params: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: migration_params: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirjsontest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
virjsontest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemublocktest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemublocktest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: command: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDiskSourceGetProps: Initialize 'ret'
Peter Krempa [Tue, 9 Nov 2021 12:29:43 +0000 (13:29 +0100)] 
qemuDiskSourceGetProps: Initialize 'ret'

Upcomming patch will convert virJSONValueObjectCreate which didn't check
the value of the passed argument to virJSONValueObjectAdd which will and
this would lead to crashes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: migration_cookie: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: migration_cookie: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: monitor: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor_json: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: monitor_json: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: agent: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: agent: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: block: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
Peter Krempa [Mon, 8 Nov 2021 16:24:50 +0000 (17:24 +0100)] 
qemu: block: Replace virJSONValueObjectCreate by virJSONValueObjectAdd

virJSONValueObjectAdd now works identically to virJSONValueObjectCreate
when used with a NULL argument. Replace all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirJSONValueObjectAddVArgs: Allocate new object if passed pointer is NULL
Peter Krempa [Tue, 9 Nov 2021 15:28:23 +0000 (16:28 +0100)] 
virJSONValueObjectAddVArgs: Allocate new object if passed pointer is NULL

Until now the code would crash if virJSONValueObjectAdd is used without
a valid object. Adding the functionality of allocating it if it's NULL
will allow us to replace all uses of virJSONValueObjectCreate with this
single function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirJSONValueObjectAddVArgs: Take double pointer
Peter Krempa [Tue, 9 Nov 2021 15:23:01 +0000 (16:23 +0100)] 
virJSONValueObjectAddVArgs: Take double pointer

Pass in the double pointer from the wrappers directly to
virJSONValueObjectAddVArgs, which will allow us to directly allocate the
new objects inside the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirJSONValueObjectAdd: Convert @obj argument to double pointer
Peter Krempa [Mon, 8 Nov 2021 16:18:59 +0000 (17:18 +0100)] 
virJSONValueObjectAdd: Convert @obj argument to double pointer

Change the first argument to a double pointer so that later the function
can be unified with virJSONValueObjectCreate and fix all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: device: compare drive address fields separately
Ján Tomko [Tue, 16 Nov 2021 13:46:39 +0000 (14:46 +0100)] 
conf: device: compare drive address fields separately

Commit 3210c8b04 introduced a separate field 'diskbus' for
internal use by the commandline formatter.

Adjust the check for address equality to compare the relevant
fields separately instead of the whole struct.

This means that the changes of the 'diskbus' field added
in commit 03ed14d2d4 no longer affect the outcome of the address
equality check.

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

Fixes: 3210c8b047534f7e1d3ccde7ea3bcf11e7c92ad9
Fixes: 03ed14d2d4a4e51568b1ee5a6e6c9c3371bb4d34
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 15 Nov 2021 20:16:05 +0000 (21:16 +0100)] 
Translated using Weblate (Swedish)

Currently translated at 28.9% (3018 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 28.7% (2998 of 10441 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>
3 years agoTranslated using Weblate (Polish)
Piotr Drąg [Mon, 15 Nov 2021 20:16:04 +0000 (21:16 +0100)] 
Translated using Weblate (Polish)

Currently translated at 22.4% (2347 of 10441 strings)

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

Co-authored-by: Piotr Drąg <piotrdrag@gmail.com>
Signed-off-by: Piotr Drąg <piotrdrag@gmail.com>
3 years agoTranslated using Weblate (Korean)
simmon [Mon, 15 Nov 2021 20:16:04 +0000 (21:16 +0100)] 
Translated using Weblate (Korean)

Currently translated at 100.0% (10441 of 10441 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
3 years agoqemu: add DEVICE_UNPLUG_GUEST_ERROR event support
Daniel Henrique Barboza [Fri, 29 Oct 2021 19:54:26 +0000 (16:54 -0300)] 
qemu: add DEVICE_UNPLUG_GUEST_ERROR event support

The upcoming QEMU 6.2.0 implements a new event called
DEVICE_UNPLUG_GUEST_ERROR, a new event that reports generic device
unplug errors that were detected by the guest and reported back to QEMU.

This new event is going to be specially useful for pseries guests that
uses newer kernels (must have kernel commit 29c9a2699e71), which is the
case for Fedora 34 at this moment. These guests have the capability of
reporting CPU removal errors back to QEMU which, starting in 6.2.0, will
emit the DEVICE_UNPLUG_GUEST_ERROR event. Libvirt can use this event to
abort the device removal immediately instead of waiting for 'setvcpus'
timeout.

QEMU 6.2.0 is also going to emit DEVICE_UNPLUG_GUEST_ERROR for memory
hotunplug errors, both in pseries and ACPI guests. QEMU 6.1.0 reports
memory removal errors using the MEM_UNPLUG_ERROR event, which is going to
be deprecated by DEVICE_UNPLUG_GUEST_ERROR in 6.2.0. Given that
Libvirt wasn't handling the MEM_UNPLUG_ERROR event we don't need to
worry about it - adding support to DEVICE_UNPLUG_GUEST_ERROR will be
enough to cover all future cases.

This patch adds support to DEVICE_UNPLUG_GUEST_ERROR by adding the
minimal wiring required for Libvirt to be aware of it. The monitor
callback for this event will abort the pending removal operation of the
device reported by the "device" property of the event. Most of the heavy
lifting is already done by existing code that handles
QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED, making our life
easier to abort the pending removal operation.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agotests: update QEMU and domain ppc64 capabilities for qemu 6.2
Daniel Henrique Barboza [Tue, 26 Oct 2021 17:37:06 +0000 (13:37 -0400)] 
tests: update QEMU and domain ppc64 capabilities for qemu 6.2

This patch updates domaincapsdata and qemucapabilitiesdata for ppc64
with qemu commit v6.1.0-1714-gc5b2f55981.

Changes in all 'ppc64-latest.ags' files were needed. The changes are
mundane despite the volume. For all 'ppc64-latest.args' files the
changes are:

- removing '-sandbox' command line;
- 'secret' and 'memory-backend-ram' objects are now using qom-type format;
- '-device' is now using qom-type format.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agovirsh: Remove unnecessary else branches
Michal Privoznik [Mon, 8 Nov 2021 15:09:48 +0000 (16:09 +0100)] 
virsh: Remove unnecessary else branches

In a few cases we call a public API, wrapped in an if() statement
with both branches written out explicitly. The error branch jumps
onto cleanup label, while the successful prints out a message.
Right after these ifs there's 'ret = true;' and the cleanup
label. The code is a bit more readable if only the error branch
is kept and printing happens at the same level as setting the ret
variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agoexamples/dommigrate: Make retval portable
Michal Privoznik [Mon, 8 Nov 2021 12:33:09 +0000 (13:33 +0100)] 
examples/dommigrate: Make retval portable

Currently, the dommigrate example returns 0 or 1 for success or
failure state, respectively. Except for a few cases where it
forgot to change the @ret variable just before jumping onto the
'cleanup' label. Making the code follow our usual pattern
(initialize @ret to an error value and set it to success value
only at the end) fixes those cases. Also, using EXIT_SUCCESS and
EXIT_FAILURE is more portable (even though on my system they are
just an alias to values the example already uses).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agoexamples/dommigrate: Don't set retval in usage()
Michal Privoznik [Mon, 8 Nov 2021 12:30:55 +0000 (13:30 +0100)] 
examples/dommigrate: Don't set retval in usage()

The usage() function should just print expected arguments. Make
the function return void then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agovirNetDevVPortProfileParse: Use g_autofree
Michal Privoznik [Thu, 4 Nov 2021 12:38:02 +0000 (13:38 +0100)] 
virNetDevVPortProfileParse: Use g_autofree

Explicit calls to VIR_FREE() can be dropped then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agoqemuMonitorOpen: Rework domain object refcounting
Michal Privoznik [Wed, 27 Oct 2021 12:41:58 +0000 (14:41 +0200)] 
qemuMonitorOpen: Rework domain object refcounting

Similarly to one of previous commits, there's no need to
increment domain object refcounter before unlocking it. Any
number of lock and unlock calls over domain object has no effect
on the refcounter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_agent: Drop destroy callback
Michal Privoznik [Wed, 27 Oct 2021 11:35:16 +0000 (13:35 +0200)] 
qemu_agent: Drop destroy callback

After previous cleanups this callback is unused. Remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuAgentOpen: Rework domain object refcounting
Michal Privoznik [Wed, 27 Oct 2021 11:38:22 +0000 (13:38 +0200)] 
qemuAgentOpen: Rework domain object refcounting

Currently, when opening an agent socket the qemuConnectAgent()
increments domain object refcounter and calls qemuAgentOpen()
where the domain object pointer is simply stored inside
_qemuAgent struct. If qemuAgentOpen() fails, then it clears @cb
member only to avoid qemuProcessHandleAgentDestroy() being called
(which decrements the domain object refcounter) and the domain
object refcounter is then decreased explicitly in
qemuConnectAgent().

The same result can be achieved with much cleaner code: increment
the refcounter inside qemuAgentOpen() and drop the dance around
@cb.

Also, the comment in qemuConnectAgent() about holding an extra
reference is not correct. The thread that called
qemuConnectAgent() already holds a reference to the domain
object. No matter how many time the object is locked and unlocked
the reference counter can't be decreased.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_agent: Rework domain object locking when opening agent
Michal Privoznik [Wed, 27 Oct 2021 11:38:05 +0000 (13:38 +0200)] 
qemu_agent: Rework domain object locking when opening agent

Just like qemuMonitorOpen(), hold the domain object locked
throughout the whole time of qemuConnectAgent() and unlock it
only for a brief time of actual connect() (because this is the
only part that has a potential of blocking).

The reason is that qemuAgentOpen() does access domain object
(well, its privateData) AND also at least one argument (@context)
depends on domain object. Accessing these without the lock is
potentially dangerous.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1845468#c12
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agonews: Mention the addition of virt-pki-query-dn binary
Martin Kletzander [Thu, 11 Nov 2021 14:59:48 +0000 (15:59 +0100)] 
news: Mention the addition of virt-pki-query-dn binary

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoAdd suggestions for virt-pki-query-dn usage
Martin Kletzander [Thu, 11 Nov 2021 14:56:05 +0000 (15:56 +0100)] 
Add suggestions for virt-pki-query-dn usage

To make it easier for users to figure out how the DN should be formatted.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotools: Add virt-pki-query-dn binary
Martin Kletzander [Thu, 11 Nov 2021 14:35:38 +0000 (15:35 +0100)] 
tools: Add virt-pki-query-dn binary

With this program we do not have to depend on the output of `certtool -i`, which
changed the order of the fields at some point and the newest version is
incompatible with what libvirt expects in tls_allowed_dn_list configuration
option.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoRemove needless space
Martin Kletzander [Thu, 11 Nov 2021 14:55:45 +0000 (15:55 +0100)] 
Remove needless space

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: Simplify explanation of tls_allowed_dn_list wildcards
Martin Kletzander [Thu, 11 Nov 2021 14:44:58 +0000 (15:44 +0100)] 
docs: Simplify explanation of tls_allowed_dn_list wildcards

This removes a dead link, the need for users to understand a glib function and a
improper reference to fnmatch (as we only expand asterisks to any string).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agorpc: Resize dname for longer DN from TLS certs
Martin Kletzander [Mon, 8 Nov 2021 15:04:57 +0000 (16:04 +0100)] 
rpc: Resize dname for longer DN from TLS certs

And to make that easier, allocate it on the heap.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: Drop cleanup/error labels
Michal Privoznik [Mon, 1 Nov 2021 09:20:57 +0000 (10:20 +0100)] 
tests: Drop cleanup/error labels

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agotest: Use g_autofree more
Michal Privoznik [Mon, 1 Nov 2021 09:33:49 +0000 (10:33 +0100)] 
test: Use g_autofree more

This commit doesn't aim to extinguish every VIR_FREE() call, but
only those which were touched by the previous commit. The aim is
to drop cleanup/error labels.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agotests: Use g_autoptr(qemuMonitorTest)
Michal Privoznik [Mon, 1 Nov 2021 08:51:01 +0000 (09:51 +0100)] 
tests: Use g_autoptr(qemuMonitorTest)

Instead of calling qemuMonitorTestFree() explicitly, we can use
g_autoptr() and let it be called automagically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoqemuConnectStealCPUModelFromInfo: Drop needless 'cleanup' label
Michal Privoznik [Mon, 1 Nov 2021 09:37:11 +0000 (10:37 +0100)] 
qemuConnectStealCPUModelFromInfo: Drop needless 'cleanup' label

Previous commit rendered 'cleanup' label and @ret variable
redundant. The same result can be achieved by returning 0/-1
directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoqemu: Use g_autoptr(qemuMonitorCPUModelInfo)
Michal Privoznik [Mon, 1 Nov 2021 11:58:27 +0000 (12:58 +0100)] 
qemu: Use g_autoptr(qemuMonitorCPUModelInfo)

There are two instances of an explicit call to
qemuMonitorCPUModelInfoFree() which in fact can be turned into
g_auto().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoPrefer g_auto(GStrv) over g_strfreev()
Michal Privoznik [Mon, 1 Nov 2021 09:34:10 +0000 (10:34 +0100)] 
Prefer g_auto(GStrv) over g_strfreev()

There are a few cases where a string list is freed by an explicit
call of g_strfreev(), but the same result can be achieved by
g_atuo(GStrv).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoqemuagenttest: Don't leak virTypedParameter on failure
Michal Privoznik [Mon, 1 Nov 2021 09:34:33 +0000 (10:34 +0100)] 
qemuagenttest: Don't leak virTypedParameter on failure

There are two functions (testQemuAgentOSInfo() and
testQemuAgentTimezone()) which call virTypedParamsFree() only in
successful paths. If an error is met then those parameters would
be leaked. Fix this by placing the virTypedParamsFree() calls on
better place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
3 years agoUse virSecretObjEndAPI() more
Michal Privoznik [Wed, 10 Nov 2021 09:01:02 +0000 (10:01 +0100)] 
Use virSecretObjEndAPI() more

Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virSecretObjEndAPI() can be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoUse virNodeDeviceObjEndAPI() more
Michal Privoznik [Wed, 10 Nov 2021 08:59:55 +0000 (09:59 +0100)] 
Use virNodeDeviceObjEndAPI() more

Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virNodeDeviceObjEndAPI() can be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoUse virNWFilterBindingObjEndAPI() more
Michal Privoznik [Wed, 10 Nov 2021 08:57:42 +0000 (09:57 +0100)] 
Use virNWFilterBindingObjEndAPI() more

Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virNWFilterBindingObjEndAPI() can be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoUse virInterfaceObjEndAPI() more
Michal Privoznik [Wed, 10 Nov 2021 08:56:29 +0000 (09:56 +0100)] 
Use virInterfaceObjEndAPI() more

Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virInterfaceObjEndAPI() can be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>