Commit Graph

44132 Commits

Author SHA1 Message Date
Peter Krempa
ff024b60cc qemu: Move creation and opening of chardev backend FDs to host prepare step
The opening of files for FD passing for a chardev backend was
historically done in the function which is formatting the commandline.

This has multiple problems. Firstly the function takes a lot of
parameters which need to be passed through the commandline formatters.
This made the 'qemuBuildChrChardevStr' extremely unappealing to the
extent that we have multiple other custom formatters in places which
didn't really want to use the function.

Additionally the function is also creating files in the host in certain
configurations which is wrong for a commandline formatter to do. This
meant that e.g. not all chardev test cases can be converted to use
DO_TEST_CAPS_LATEST as we attempt to use such code path and attempt to
create files outside of the test directory.

This patch moves the opening of the filedescriptors from
'qemuBuildChrChardevFileStr' into a new helper
'qemuProcessPrepareHostBackendChardevOne' which is called using
'qemuDomainDeviceBackendChardevForeach'.

To preserve test behaviour we also have another instance
'testPrepareHostBackendChardevOne' which is populating mock
filedescriptors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:42 +01:00
Peter Krempa
728f0079ea qemu: domain: Introduce helpers for initializing chardev backend of devices
Introduce qemuDomainDeviceBackendChardevForeach(One) which calls the
callback if either given device has a chardev backend or for all chardev
backends of all devices.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:42 +01:00
Peter Krempa
7d0faffbd9 virDomainDeviceInfoIterateFlags: Export the symbol
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:42 +01:00
Peter Krempa
97881a2fd4 virHostCPUGetInfoPopulateLinux: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:42 +01:00
Peter Krempa
78db8bf006 virt-host-validate-qemu: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:42 +01:00
Peter Krempa
68919edb3b virt-host-validate-common: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:42 +01:00
Peter Krempa
4c4b4b3691 virLXCControllerSetup(Resource|Cgroup)Limits: Refactor cleanup
Remove the pointless cleanup sections.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:37:40 +01:00
Peter Krempa
94490b59f1 lxc_controller: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
9566576c02 libxlDomainGetNumaParameters: Don't clear a freshly allocated bitmap
The bitmap is allocated just above the explicit clear, so it's already
empty.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
e4b00827ed libxl_driver: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
6181d8a61b lxcSetCpusetTune: Refactor memory clearing
Use automatic memory clearing for virBitmap and remove a reuse of a
temporary string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
17159773ee test_driver: Use automatic memory freeing for temporary virBitmaps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
f33c86be1d util: bitmap: Unify parsing of bitmaps
There were two separate instances of string->virBitmap code:
virBitmapParseInternal and virBitmapParseUnlimited.

By adding a flag to switch to expanding APIs we can merge the two
implementations into one.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
515672c0d9 virBitmapParseInternal: Allocate the bitmap in the caller
In order to prepare for reuse of the function, move the allocation of
the bitmap to the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
d8579b07c8 virBitmapParseSeparator: Remove separator parsing capability
Since the feature is not needed remove it and remove the function to
virBitmapParseInternal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
f3af9e36fb virBitmapSetBitExpand: Remove return value
The function can't fail at this point. Remove the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
7d48c3d2d6 virBitmapClearBitExpand: Remove return value
The function can't fail at this point. Remove the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:25 +01:00
Peter Krempa
58fec2cef4 virBitmapUnion: Remove return value
The function can't fail at this point. Remove the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
ab88ace58d virBitmapExpand: Remove return value
There's nothing that can fail in the function. Remove the return value
and adjust callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
3c9b04cb12 util: bitmap: Unexport 'virBitmapParseSeparator'
The function isn't used besides tests. Since the separator parsing
capability is trivial we can keep it in place and just unexport it for
now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
628be89e87 test_virCapabilitiesGetCpusForNodemask: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
f89c929b1e virnumamock: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
33eb88cdc9 virshParseCPUList: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
babbfb5be9 virCgroupGetPercpuStats: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
8366175482 virHostCPUParseNode: Use automatic memory freeing for virBitmap
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
20ddaa9797 virHostCPUHasValidSubcoreConfiguration: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
19228b6016 virHostCPUCountThreadSiblings: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
4aa3d8fffa qemuSnapshotCreateInactiveExternal: Automatically free temporary variables
Automatically free 'cmd' and 'created' by moving them to the appropriate
scopes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
e4b4ccb94f qemuProcessValidateHotpluggableVcpus: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
41cd3d434d qemuDomainSetVcpuInternal: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
44797bae44 qemuDomainSetVcpusInternal: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
5b7653a628 qemuDomainSelectHotplugVcpuEntities: Refactor cleanup
Use automatic memory freeing for the 'ret' bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
4ab26d3e3e qemu: driver: Automatically free temporary virBitmap-s
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
0b18972630 qemuDomainAssignMemorySlots: Refactor cleanup
Automatically free the 'slotmap' bitmap and get rid of the cleanup
section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
5cbdea694d virDomainDriverGetIOThreadsConfig: Automatically free virBitmap
Use g_autoptr for the temp bitmap. To achieve this the variable must be
moved down to the appropriate scope.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
33d6d05754 virDomainNumatuneParseXML: Refactor cleanup
Use automatic memory clearing for the temporary strings and bitmap and
remove the cleanup section. There are multiple temporary strings added
so that we don't reuse one.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
29da6dcc9d virDomainSchedulerParse: Refactor cleanup
Automatically free the 'ret' temporary bitmap and get rid of the cleanup
section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
473df98ad8 conf: capabilities: Clean up freeing of virBitmap
Use automatic freeing where possible and use g_clear_pointer instead of
manual NULL-ing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Peter Krempa
5b3f00d087 virCapabilitiesInitCaches: Refactor freeing of temporary variables
Move the 'path' and 'type' variables down to the appropriate block and
use automatic freeing for them as well as the temporary virBitmap.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 16:36:24 +01:00
Michal Privoznik
9ca80bfa11 Revert "lxc: controller: Fix container launch on cgroup v1"
Unfortunately, this fix breakes machinectl in a very nasty way,
for instance 'machinectl shell' drops into the host shell. It's
worse than being unable to start a container with CGroupsV1.

Revert until a proper fix is figured out.

This reverts commit 1b9ce05ce2.

References: https://gitlab.com/libvirt/libvirt/-/issues/182
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-12-10 16:22:49 +01:00
Andrea Bolognani
2bdd654269 remote: Avoid crash in remoteSplitURIScheme()
We need to make sure the URI scheme is present before passing
it to strchr(), otherwise we're going to get

  $ virt-ssh-helper foo
  Segmentation fault (core dumped)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-12-10 14:15:23 +01:00
Michal Privoznik
3179220e4f Revert "qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()"
This reverts commit 69977ff105.

After previous commit it's no longer possible that QEMU driver is
not initialized in qemuStateShutdownPrepare() nor
qemuStateShutdownWait().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-12-10 13:51:01 +01:00
Michal Privoznik
05e518f47a remote_daemon: Set shutdown callbacks only after init is done
The initialization of drivers happens in a separate thread.
However, the main thread continues initialization and sets
shutdown callbacks (virStateShutdownPrepare() and
virStateShutdownWait()) even though the driver init thread is
still running. This is dangerous because if the daemon decides to
quit early (e.g. because SIGINT was delivered) the
shutdownPrepare and shutdownWait callback are called over
partially init drivers.

Set callbacks only after all drivers were initialized.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/218
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2027400

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-12-10 13:51:01 +01:00
Peter Krempa
6e6a11bc0a qemu_monitor_json.h: Unify header formatting
Use the modern style and fix all offenders since new functions were
already using the contemporary style.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-10 09:51:39 +01:00
Peter Krempa
108676c225 qemuValidateDomainDeviceDefDiskFrontend: Aggregate disk iomode validation
Move the two checks under a common block.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-09 14:04:44 +01:00
Peter Krempa
217e1527e9 qemuValidateDomainDeviceDefDiskFrontend: Fix error message if io='native' is unsupported
The error is a hard error, so the part about fallback doesn't make
sense. Spell the attribute the same way as it's in XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-09 14:04:44 +01:00
Andrea Bolognani
8a637cc766 docs: Update more links to point to the new Go modules
A couple of links were still pointing to the obsolete Go
packages instead of the current module-aware ones.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-12-09 12:16:17 +01:00
Andrea Bolognani
9fffea7353 NEWS: Fix spacing between releases
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2021-12-08 17:43:33 +01:00
Ján Tomko
33538bc46b qemu: do not compare missing cpu data
For x86, we invalidate qemu caps cache if the host CPUID changed.
However other cpu drivers do not have the 'getHostData' function
implemented.

Skip the comparison if we do not have host CPUData available,
since virCPUDataIsIdentical always returns an error in that case.

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

Fixes: 3bc6f46d30
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-12-08 15:27:58 +01:00
Peter Krempa
4cc91f26d0 NEWS: Mention synchronous copy job additions
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-07 09:00:39 +01:00