]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agoconf: require target for external virtiofsd
Ján Tomko [Wed, 16 Jun 2021 13:35:16 +0000 (15:35 +0200)] 
conf: require target for external virtiofsd

When adding support for externally launched virtiofsd,
I was too liberal and did not require a target.

But the target is required, because it's passed to the
QEMU device, not to virtiofsd.

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

Fixes: 12967c3e1333a6e106110f449ccb1e96279b9527
Fixes: 56dcdec1ac8104f94371c210585bab91eb36395d
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: move filesystem target validation
Ján Tomko [Wed, 16 Jun 2021 14:59:42 +0000 (16:59 +0200)] 
conf: move filesystem target validation

Check the presence of the target in the validation phase.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Don't set NVRAM label when creating it
Michal Privoznik [Wed, 9 Jun 2021 13:44:11 +0000 (15:44 +0200)] 
qemu: Don't set NVRAM label when creating it

The NVRAM label is set in qemuSecuritySetAllLabel(). There's no
need to set its label upfront. In fact, setting it twice creates
an imbalance because it's unset only once which mangles seclabel
remembering. However, plain removal of the
qemuSecurityDomainSetPathLabel() undoes the fix for the original
bug (when dynamic ownership is off then the NVRAM is not created
with cfg->user and cfg->group but as root:root). Therefore, we
have to switch to virFileOpenAs() and pass cfg->user and
cfg->group and VIR_FILE_OPEN_FORCE_OWNER flag. There's no need to
pass VIR_FILE_OPEN_FORCE_MODE because the file will be created
with the proper mode.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1969347
Fixes: bcdaa91a27b5b2d103535270a6a287efe6cd8bfb
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: reject duplicate virtiofs tags
Ján Tomko [Wed, 16 Jun 2021 13:56:21 +0000 (15:56 +0200)] 
conf: reject duplicate virtiofs tags

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: fix filesystem schema indentation
Ján Tomko [Wed, 16 Jun 2021 13:40:38 +0000 (15:40 +0200)] 
docs: fix filesystem schema indentation

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agogitlab-ci: Don't build docs in 'sanitizer' jobs
Peter Krempa [Tue, 15 Jun 2021 15:27:18 +0000 (17:27 +0200)] 
gitlab-ci: Don't build docs in 'sanitizer' jobs

Docs are not sanitized, thus there's no point in building them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoqemu_hotplug: Report VIR_ERR_DEVICE_MISSING when device is not found
Lee Yarwood [Mon, 14 Jun 2021 10:18:37 +0000 (11:18 +0100)] 
qemu_hotplug: Report VIR_ERR_DEVICE_MISSING when device is not found

126db34a81bc9f9f9710408f88cceaa1e34bbbd7 had previously switched various
flows over to this from VIR_ERR_OPERATION_FAILED.

This change simply does the same for qemuDomainDetachPrepDisk,
qemuDomainDetachPrepInput and qemuDomainDetachPrepVsock to allow
management apps to centralise their error handling on just
VIR_ERR_DEVICE_MISSING for missing devices during a detach.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsh-volume: Apply virshStorageVolNameCompleter to vol-{key,path} commands
Lin Ma [Wed, 16 Jun 2021 08:02:54 +0000 (16:02 +0800)] 
virsh-volume: Apply virshStorageVolNameCompleter to vol-{key,path} commands

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh-volume: Apply virshStorageVolKeyCompleter to vol-{name,pool} commands
Lin Ma [Wed, 16 Jun 2021 08:02:53 +0000 (16:02 +0800)] 
virsh-volume: Apply virshStorageVolKeyCompleter to vol-{name,pool} commands

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh-volume: Add macros VIRSH_COMMON_OPT_VOL_*
Lin Ma [Wed, 16 Jun 2021 08:02:52 +0000 (16:02 +0800)] 
virsh-volume: Add macros VIRSH_COMMON_OPT_VOL_*

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh-volume: Introduce virshStorageVolKeyCompleter
Lin Ma [Wed, 16 Jun 2021 08:02:51 +0000 (16:02 +0800)] 
virsh-volume: Introduce virshStorageVolKeyCompleter

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh-pool: Remove static from virshStoragePoolList{Free,Collect}
Lin Ma [Wed, 16 Jun 2021 08:02:50 +0000 (16:02 +0800)] 
virsh-pool: Remove static from virshStoragePoolList{Free,Collect}

The functions will be used by next patch.

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirFindFileInPath: Don't pass NULL to g_canonicalize_filename()
Michal Privoznik [Tue, 15 Jun 2021 16:01:37 +0000 (18:01 +0200)] 
virFindFileInPath: Don't pass NULL to g_canonicalize_filename()

If given file is not found in $PATH then g_find_program_in_path()
returns NULL. However, g_canonicalize_filename() does not accept
NULL as input.

Fixes: 65c2901906b5e2d707f9184ff3719a5375bab427
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirStorageBackendRBDGetVolNames: Refactor cleanup in 'rbd_list' version
Peter Krempa [Mon, 14 Jun 2021 14:44:19 +0000 (16:44 +0200)] 
virStorageBackendRBDGetVolNames: Refactor cleanup in 'rbd_list' version

Use automatic memory freeing for the string list so that we can remove
the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirStorageBackendRBDGetVolNames: Fix memory leak in 'rbd_list2' version
Peter Krempa [Mon, 14 Jun 2021 15:14:13 +0000 (17:14 +0200)] 
virStorageBackendRBDGetVolNames: Fix memory leak in 'rbd_list2' version

The 'rbd_image_spec_t' struct has two string members 'id' and
'name'. We only stole the 'name' members thus the 'id's as well as the
whole list would be leaked on success.

Restructure the code so that we copy out the image names and call
rbd_image_spec_list_cleanup on success rather than on error.

The error path is then handled by using g_autofree for 'images'.

Since we no longer have a error path after allocating the returned
string list we can completely remove its cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetStringListProperty: Don't return element count
Peter Krempa [Mon, 14 Jun 2021 14:22:30 +0000 (16:22 +0200)] 
qemuMonitorJSONGetStringListProperty: Don't return element count

The only caller doesn't care about the number of elements in the string
list so we don't have to calculate it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetStringArray: Don't return element count
Peter Krempa [Mon, 14 Jun 2021 14:41:09 +0000 (16:41 +0200)] 
qemuMonitorJSONGetStringArray: Don't return element count

There's just one caller who cares (testQemuMonitorJSONGetTPMModels). Fix
it and remove the counting of elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirQEMUCapsProbeQMPTPM: Refactor handling of string lists
Peter Krempa [Mon, 14 Jun 2021 14:34:28 +0000 (16:34 +0200)] 
virQEMUCapsProbeQMPTPM: Refactor handling of string lists

This refactors multiple aspects of the function:

1) Use automatic memory freeing
2) Remove need to check element count in the returned arrays
3) Fixes questionable code linebreaks
4) Removes reuse of variables

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirQEMUCapsProcessStringFlags: Don't require 'nvalues'
Peter Krempa [Mon, 14 Jun 2021 13:37:46 +0000 (15:37 +0200)] 
virQEMUCapsProcessStringFlags: Don't require 'nvalues'

All callers pass in NULL-terminated string lists. Remove the 'nvalues'
argument and fix all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: capabilities: Use g_auto(GStrv) instead of virStringListFreeCount
Peter Krempa [Mon, 14 Jun 2021 08:30:55 +0000 (10:30 +0200)] 
qemu: capabilities: Use g_auto(GStrv) instead of virStringListFreeCount

All the capability getters which return a string list do in fact return
a NULL-terminated list so we can use g_auto(GStrv) to free it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQemuMonitorJSONGetTPMModels: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 14:38:26 +0000 (16:38 +0200)] 
testQemuMonitorJSONGetTPMModels: Refactor cleanup

Use automatic memory freeing and remove the cleanup section.t

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestQemuMonitorJSONGetCommands: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 13:56:16 +0000 (15:56 +0200)] 
testQemuMonitorJSONGetCommands: Refactor cleanup

Use g_auto(GStrv) for clearing the string list and thus remove the
'cleanup' section and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetObjectTypes: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 14:20:50 +0000 (16:20 +0200)] 
qemuMonitorJSONGetObjectTypes: Refactor cleanup

Use automatic memory clearing to simplify the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetStringArray: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 14:20:50 +0000 (16:20 +0200)] 
qemuMonitorJSONGetStringArray: Refactor cleanup

Use automatic memory clearing to simplify the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetCommands: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 14:19:11 +0000 (16:19 +0200)] 
qemuMonitorJSONGetCommands: Refactor cleanup

Use automatic memory freeing to simplify the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetMigrationCapabilities: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 08:29:36 +0000 (10:29 +0200)] 
qemuMonitorJSONGetMigrationCapabilities: Refactor cleanup

Use automatic memory clearing and remove the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONGetObjectProps: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 08:25:53 +0000 (10:25 +0200)] 
qemuMonitorJSONGetObjectProps: Refactor cleanup

Use 'g_autoptr' for the two temporary JSON objects and remove the
cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuMonitorJSONParsePropsList: Refactor cleanup
Peter Krempa [Mon, 14 Jun 2021 08:24:25 +0000 (10:24 +0200)] 
qemuMonitorJSONParsePropsList: Refactor cleanup

Use 'g_auto' for @proplist and remove @ret.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: capabilities: Fill SDL graphics support only when it's really supported
Peter Krempa [Tue, 15 Jun 2021 09:47:01 +0000 (11:47 +0200)] 
qemu: capabilities: Fill SDL graphics support only when it's really supported

virQEMUCapsFillDomainDeviceGraphicsCaps fills data needed both for
validation of the graphics type and also for correct display in the
(dom)capablities XML.

Signal the support for SDL only when qemu has the capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
4 years agotests: qemuxml2*: Add QEMU_CAPS_SDL to fake-caps tests using SDL graphics
Peter Krempa [Tue, 15 Jun 2021 09:46:54 +0000 (11:46 +0200)] 
tests: qemuxml2*: Add QEMU_CAPS_SDL to fake-caps tests using SDL graphics

Next commit will modify the code so that it validates whether SDL is
present. Certain tests need to get the SDL capability to keep working
properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
4 years agoqemu: capabilities: Un-retire QEMU_CAPS_SDL
Peter Krempa [Tue, 15 Jun 2021 09:38:26 +0000 (11:38 +0200)] 
qemu: capabilities: Un-retire QEMU_CAPS_SDL

SDL graphics can be compiled out in qemu so we need to be able to know
whether the given qemu version support it.

Base the capability on the presence of the 'sdl' member in
'query-display-options' or imply it if 'query-display-options' is not
supported as we implied it before for all versions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
4 years agoqemu: capabilities: Introduce QEMU_CAPS_QUERY_DISPLAY_OPTIONS
Peter Krempa [Tue, 15 Jun 2021 09:31:35 +0000 (11:31 +0200)] 
qemu: capabilities: Introduce QEMU_CAPS_QUERY_DISPLAY_OPTIONS

The command allows to query various display-related options. The absence
of the command will be used to imply certain video-related capabilities
before we would be able to detect them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
4 years agoqemu: validate: Don't check bus type in qemuValidateDomainDeviceDefDiskIOThreads
Peter Krempa [Thu, 10 Jun 2021 14:43:36 +0000 (16:43 +0200)] 
qemu: validate: Don't check bus type in qemuValidateDomainDeviceDefDiskIOThreads

IOThreads are supported with all 3 currently supported buses which can
have virtio devices (PCI, CCW, MMIO) , so there's no need for this check.

Additionally this check was buggy in the current location as on e.g.
hotplug cases the address may not yet be assigned for the disk and thus
a bogus error would be printed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1970277
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainCheckCCWS390AddressSupport: Remove duplicated checker
Peter Krempa [Fri, 11 Jun 2021 14:25:48 +0000 (16:25 +0200)] 
qemuDomainCheckCCWS390AddressSupport: Remove duplicated checker

For validation of explicitly configured addresses we already ported the
same style of checks to qemuValidateDomainDeviceDefAddress and implicit
address assignment should do the right thing in the first place, thus
the function is redundant and can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuValidateDomainDeviceDefAddress: Add validation of CCW address
Peter Krempa [Fri, 11 Jun 2021 13:43:35 +0000 (15:43 +0200)] 
qemuValidateDomainDeviceDefAddress: Add validation of CCW address

Base the check on the logic from qemuDomainCheckCCWS390AddressSupport,
which will be removed later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Drop handling of devices with VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390
Peter Krempa [Fri, 11 Jun 2021 13:13:31 +0000 (15:13 +0200)] 
qemu: Drop handling of devices with VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390

We don't support any qemu which would support the 'virtio-s390'
addressing, thus we can drop all code related to it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: capabilities: Retire QEMU_CAPS_VIRTIO_S390
Peter Krempa [Fri, 11 Jun 2021 13:08:49 +0000 (15:08 +0200)] 
qemu: capabilities: Retire QEMU_CAPS_VIRTIO_S390

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2*test: Remove QEMU_CAPS_VIRTIO_S390 flag
Peter Krempa [Fri, 11 Jun 2021 13:08:07 +0000 (15:08 +0200)] 
qemuxml2*test: Remove QEMU_CAPS_VIRTIO_S390 flag

The flag isn't used by the code in any way so it can be dropped from the
legacy test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Remove last uses of QEMU_CAPS_VIRTIO_S390
Peter Krempa [Fri, 11 Jun 2021 12:59:05 +0000 (14:59 +0200)] 
qemu: Remove last uses of QEMU_CAPS_VIRTIO_S390

Modify the code in the last two instances in the code to behave as if
the flag is not asserted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Always reject 'virtio-s390' addresses
Peter Krempa [Fri, 11 Jun 2021 12:51:21 +0000 (14:51 +0200)] 
qemu: Always reject 'virtio-s390' addresses

QEMU_CAPS_VIRTIO_S390 can never be asserted any more, add an explicit
check that will reject the 'virtio-s390' address type and remove the
code which would auto-fill them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2argvtest: Use other bus capability for 'non-x86_64-timer-error' case
Peter Krempa [Fri, 11 Jun 2021 12:50:01 +0000 (14:50 +0200)] 
qemuxml2argvtest: Use other bus capability for 'non-x86_64-timer-error' case

Give the test QEMU_CAPS_CCW instead of QEMU_CAPS_VIRTIO_S390 since the
latter can never be asserted any more. This preserves what the tests
wants to check so that QEMU_CAPS_VIRTIO_S390 can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: capabilities: Don't probe device properties for 'virtio-*-s390' devices
Peter Krempa [Fri, 11 Jun 2021 09:16:28 +0000 (11:16 +0200)] 
qemu: capabilities: Don't probe device properties for 'virtio-*-s390' devices

The devices no longer exist in qemu since the 2.6 release. Drop the
probing of the device properties and fix the data for
qemucapabilitiestest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: capabilities: Remove probing of 'virtio-*-s390' devices
Peter Krempa [Fri, 11 Jun 2021 09:02:10 +0000 (11:02 +0200)] 
qemu: capabilities: Remove probing of 'virtio-*-s390' devices

QEMU commit 7b3fdbd9a826791bd98e649cf44c0a6129a44179 released in 2.6
dropped the legacy s390 virtio machine and it's devices. Remove our
probing based on the devices.

The probing of properties of the appropriate devices will be removed
subsequently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: Remove 's390-virtio' machine caps faking
Peter Krempa [Fri, 11 Jun 2021 08:30:31 +0000 (10:30 +0200)] 
tests: Remove 's390-virtio' machine caps faking

The machine type was removed in qemu 2.6 and no tests now depend on it.
Remove the faking of the machine type support and the capabilities test
for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: domain: Remove hack for 's390-virtio' machine
Peter Krempa [Fri, 11 Jun 2021 08:27:20 +0000 (10:27 +0200)] 
qemu: domain: Remove hack for 's390-virtio' machine

qemuDomainDefAddDefaultDevices skipped adding the memballoon for the
's390-virtio' machine type, but since it was removed in qemu 2.6 we can
remove the hack now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2argv: Modernize 's390-allow-bogus-usb-controller' test
Peter Krempa [Fri, 11 Jun 2021 08:16:01 +0000 (10:16 +0200)] 
tests: qemuxml2argv: Modernize 's390-allow-bogus-usb-controller' test

The 's390-virtio' machine was removed from qemu in the 2.6 release.
Use the more modern s390-ccw-virtio machine type and use
VIR_TEST_CAPS_ARCH_LATEST to invoke it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2xml: Modernize 's390-defaultconsole' case
Peter Krempa [Fri, 11 Jun 2021 08:21:57 +0000 (10:21 +0200)] 
tests: qemuxml2xml: Modernize 's390-defaultconsole' case

Don't use the 's390-virtio' machine which was removed in qemu 2.6 and
use real capabilities for the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2argv: Modernize 's390-allow-bogus-usb-none' test
Peter Krempa [Fri, 11 Jun 2021 08:16:01 +0000 (10:16 +0200)] 
tests: qemuxml2argv: Modernize 's390-allow-bogus-usb-none' test

The 's390-virtio' machine was removed from qemu in the 2.6 release.
Use the more modern s390-ccw-virtio machine type and use
VIR_TEST_CAPS_ARCH_LATEST to invoke it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2argv: Remove redundant tests for the obsolete 'virtio-390' machine
Peter Krempa [Thu, 10 Jun 2021 15:11:39 +0000 (17:11 +0200)] 
tests: qemuxml2argv: Remove redundant tests for the obsolete 'virtio-390' machine

Remove the console, disk, and network test for the legacy s390 machine
which was removed in qemu 2.6. All of these have 'ccw' equivalents.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2argv: Modernize 'console-sclp' test
Peter Krempa [Thu, 10 Jun 2021 15:08:05 +0000 (17:08 +0200)] 
tests: qemuxml2argv: Modernize 'console-sclp' test

The 's390-virtio' machine was removed from qemu in the 2.6 release.
Modernize the test for sclp console since there isn't any other test for
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: qemuxml2argv: Modernize 'watchdog-diag288' test
Peter Krempa [Thu, 10 Jun 2021 15:01:37 +0000 (17:01 +0200)] 
tests: qemuxml2argv: Modernize 'watchdog-diag288' test

The 's390-virtio' machine was removed from qemu in the 2.6 release.
Modernize the test for diag288 since there isn't any other test for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agobhyveConnectDomainXMLToNative: Fix memory leak in incorrect virCommandToString usage
Peter Krempa [Fri, 11 Jun 2021 08:08:37 +0000 (10:08 +0200)] 
bhyveConnectDomainXMLToNative: Fix memory leak in incorrect virCommandToString usage

virCommandToString returns an allocated buffer, so using it directly as
argument of virBufferAdd which doesn't consume the string causes it to
be leaked. Switch to virBufferToStringBuf since we are already using a
buffer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuxml2arvtest: Ensure newline at the end of generated .args files
Peter Krempa [Fri, 11 Jun 2021 07:45:12 +0000 (09:45 +0200)] 
qemuxml2arvtest: Ensure newline at the end of generated .args files

The switch to internal linebreaking of arguments caused a problem when
generating .args files with VIR_TEST_REGENERATE_OUTPUT as the last
argument isn't terminated with a newline.

Switch to using virCommandToStringBuf and append a newline.

Fixes: 0046e0b1c26c8e0167de4a35be2902b9327b0c51
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: command: Introduce virCommandToStringBuf
Peter Krempa [Thu, 10 Jun 2021 15:43:59 +0000 (17:43 +0200)] 
util: command: Introduce virCommandToStringBuf

The new version allows passing a virBuffer to format the string into.
This will be helpful in solving a memory lean in wrong usage of
virCommandToString and also in tests where we need to add a newline
after the command in certain cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agosyntax-check: Only prohibit empty first lines in non-empty files
Martin Kletzander [Mon, 14 Jun 2021 16:57:58 +0000 (18:57 +0200)] 
syntax-check: Only prohibit empty first lines in non-empty files

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotest_driver: Implement virDomainGetSecurityLabel
Luke Yue [Mon, 7 Jun 2021 07:38:19 +0000 (15:38 +0800)] 
test_driver: Implement virDomainGetSecurityLabel

Signed-off-by: Luke Yue <lukedyue@gmail.com>
4 years agotest_driver: Implement virNodeGetSecurityModel
Luke Yue [Mon, 7 Jun 2021 07:38:18 +0000 (15:38 +0800)] 
test_driver: Implement virNodeGetSecurityModel

Signed-off-by: Luke Yue <lukedyue@gmail.com>
4 years agovirfile: Simplify virFindFileInPath() with g_find_program_in_path()
Luke Yue [Mon, 7 Jun 2021 06:10:48 +0000 (14:10 +0800)] 
virfile: Simplify virFindFileInPath() with g_find_program_in_path()

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoReplace virFileAbsPath() with g_canonicalize_filename()
Luke Yue [Mon, 7 Jun 2021 06:10:47 +0000 (14:10 +0800)] 
Replace virFileAbsPath() with g_canonicalize_filename()

Signed-off-by: Luke Yue <lukedyue@gmail.com>
4 years agodocs: add a link to Gitlab on the contributing page
Simon Chopin [Mon, 14 Jun 2021 08:23:50 +0000 (10:23 +0200)] 
docs: add a link to Gitlab on the contributing page

I expect to find a link to the repositories when clicking on
"Contribute", this patch fixes this. The wording is directly inspired by
the one on the hacking page.

Signed-off-by: Simon Chopin <chopin.simon@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: add launch-security-sev test with latest capabilities
Pavel Hrdina [Thu, 10 Jun 2021 13:58:15 +0000 (15:58 +0200)] 
tests: add launch-security-sev test with latest capabilities

QEMU 6.0.0 introduced `confidential-guest-support` -machine option as
a replacement for `memory-encryption`. In order to test it use 6.0.0
capabilities as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: use newer machine in qemuxml2argv launch-security-sev
Pavel Hrdina [Thu, 10 Jun 2021 13:55:52 +0000 (15:55 +0200)] 
tests: use newer machine in qemuxml2argv launch-security-sev

The pc-1.0 machine type was deprecated in QEMU 6.0.0. In our tests we
use 2.12.0 and 6.0.0 replies so switch to pc type.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: add AMD SEV bits into qemu-6.0.0 replies
Pavel Hrdina [Thu, 10 Jun 2021 13:54:59 +0000 (15:54 +0200)] 
tests: add AMD SEV bits into qemu-6.0.0 replies

Currently we only have AMD SEV bits in qemu-2.12.0 replies which is way
too old to test new features that require AMD SEV as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_command: use confidential-guest-support if available
Pavel Hrdina [Thu, 10 Jun 2021 13:24:19 +0000 (15:24 +0200)] 
qemu_command: use confidential-guest-support if available

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_capabilities: detect if confidential-guest-support is available
Pavel Hrdina [Mon, 14 Jun 2021 12:38:58 +0000 (14:38 +0200)] 
qemu_capabilities: detect if confidential-guest-support is available

virQEMUCapsProbeQMPMachineProps currently skips any not supported
machine type which includes `none` as well.

In order to start probing that machine type we need to add an exception
to not skip it when probing QEMU capabilities.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_capabilities: introduce confidential-guest-support capability
Pavel Hrdina [Mon, 14 Jun 2021 12:36:08 +0000 (14:36 +0200)] 
qemu_capabilities: introduce confidential-guest-support capability

In libvirt we already use `query-command-line-options` QMP command but
that is useless as it doesn't provide correct data for `-machine`
option. So we need a new and better way to get that data.

We already use `qom-list-properties` to get options for specific machine
types so we can reuse it to get options for special `none` machine type
as a generic arch independent machine type.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovircaps2xmltest: Introduce HMAT test case
Michal Privoznik [Fri, 14 May 2021 15:02:25 +0000 (17:02 +0200)] 
vircaps2xmltest: Introduce HMAT test case

This test was generated on a guest with the following NUMA
configuration:

    <numa>
      <cell id='0' cpus='0-23' memory='4194304' unit='KiB' discard='yes'>
        <cache level='1' associativity='direct' policy='writeback'>
          <size value='10' unit='KiB'/>
          <line value='8' unit='B'/>
        </cache>
        <cache level='2' associativity='full' policy='writethrough'>
          <size value='128' unit='KiB'/>
          <line value='16' unit='B'/>
        </cache>
      </cell>
      <cell id='1' memory='2097152' unit='KiB'>
        <cache level='1' associativity='direct' policy='writeback'>
          <size value='10' unit='KiB'/>
          <line value='8' unit='B'/>
        </cache>
      </cell>
      <interconnects>
        <latency initiator='0' target='0' type='access' value='5'/>
        <latency initiator='0' target='0' type='read' value='6'/>
        <latency initiator='0' target='0' type='write' value='7'/>
        <latency initiator='0' target='1' type='access' value='10'/>
        <latency initiator='0' target='1' type='read' value='11'/>
        <latency initiator='0' target='1' type='write' value='12'/>
        <bandwidth initiator='0' target='0' type='access' value='204800' unit='KiB'/>
        <bandwidth initiator='0' target='0' type='read' value='205824' unit='KiB'/>
        <bandwidth initiator='0' target='0' type='write' value='206848' unit='KiB'/>
        <bandwidth initiator='0' target='0' cache='1' type='access' value='208896' unit='KiB'/>
        <bandwidth initiator='0' target='0' cache='1' type='read' value='209920' unit='KiB'/>
        <bandwidth initiator='0' target='0' cache='1' type='write' value='210944' unit='KiB'/>
        <bandwidth initiator='0' target='1' type='access' value='102400' unit='KiB'/>
        <bandwidth initiator='0' target='1' type='read' value='103424' unit='KiB'/>
        <bandwidth initiator='0' target='1' type='write' value='104448' unit='KiB'/>
        <bandwidth initiator='0' target='1' cache='1' type='access' value='105472' unit='KiB'/>
        <bandwidth initiator='0' target='1' cache='1' type='read' value='106496' unit='KiB'/>
        <bandwidth initiator='0' target='1' cache='1' type='write' value='107520' unit='KiB'/>
      </interconnects>
    </numa>

The sysfs content was also copied over from the VM but only those
files which are accessed in the test are stored in the repo.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agocapabilities: Expose NUMA interconnects
Michal Privoznik [Mon, 17 May 2021 11:36:34 +0000 (13:36 +0200)] 
capabilities: Expose NUMA interconnects

Links between NUMA nodes can have different latencies and
bandwidths. This info is newly defined in ACPI 6.2 under
Heterogeneous Memory Attribute Table (HMAT) table. Linux kernel
learned how to report these values under sysfs and thus we can
expose them in our capabilities XML. The sysfs interface is
documented in kernel's Documentation/admin-guide/mm/numaperf.rst.

Long story short, two nodes can be in initiator-target
relationship. A node can be initiator if it has a CPU or a device
that's capable of initiating memory transfer. Therefore a node
that has just memory can only be target. An initiator-target link
can then have any combination of {bandwidth, latency} - {access,
read, write} attribute (6 in total). However, the standard says
access is applicable iff read and write values are the same.
Therefore, we really have just four combinations of attributes:
bandwidth-read, bandwidth-write, latency-read, latency-write.

This is the combination that kernel reports anyway.

Then, under /sys/system/devices/node/nodeX/acccessN/initiators we
find values for those 4 attributes and also symlinks named
"nodeN" which then represent initiators to nodeX. For instance:

  /sys/system/node/node1/access1/initiators/node0 -> ../../node0
  /sys/system/node/node1/access1/initiators/read_bandwidth
  /sys/system/node/node1/access1/initiators/read_latency
  /sys/system/node/node1/access1/initiators/write_bandwidth
  /sys/system/node/node1/access1/initiators/write_latency

This means that node0 is initiator and node1 is target and values
of the interconnect can be read.

In theory, there can be separate links to memory side caches too
(e.g. one link from node X to node Y's main memory, another from
node X to node Y's L1 cache, another one to L2 cache and so on).
But sysfs does not express this relationship just yet.

The "accessN" means either "access0" or "access1". The difference
is that while the former expresses the best interconnect between
two nodes including CPUS and I/O devices (such as GPUs and NICs),
the latter includes only CPUs and thus is what we need.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1786309
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agonuma_conf: Expose virNumaInterconnect formatter
Michal Privoznik [Mon, 3 May 2021 12:45:27 +0000 (14:45 +0200)] 
numa_conf: Expose virNumaInterconnect formatter

Expose virNumaInterconnect XML formatter so that it can be
re-used by other parts of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agonuma_conf: Rename virDomainNumaInterconnect* to virNumaInterconnect*
Michal Privoznik [Mon, 17 May 2021 15:14:16 +0000 (17:14 +0200)] 
numa_conf: Rename virDomainNumaInterconnect* to virNumaInterconnect*

There's nothing domain specific about NUMA interconnects. Rename
the virDomainNumaInterconnect* structures and enums to
virNumaInterconnect*.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agocapabilities: Expose NUMA memory side cache
Michal Privoznik [Thu, 29 Apr 2021 16:58:43 +0000 (18:58 +0200)] 
capabilities: Expose NUMA memory side cache

Memory on a NUMA node can have a side caches. Configuring these
for a domain was implemented in v6.6.0-rc1~249 and friends.
However, up until now mgmt applications did not really know what
values to pass because we were not exposing caches of the host.
With recent enough kernel these are exposed under sysfs and with
a bit of parsing we can extend our capabilities XML. The sysfs
structure is documented in kernel's
Documentation/admin-guide/mm/numaperf.rst and basically maps in
1:1 fashion to our virNumaCache structure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agonuma_conf: Expose virNumaCache formatter
Michal Privoznik [Mon, 3 May 2021 12:11:26 +0000 (14:11 +0200)] 
numa_conf: Expose virNumaCache formatter

Expose virNumaCache XML formatter so that it can be re-used by
other parts of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agonuma_conf: Rename virDomainCache* to virNumaCache*
Michal Privoznik [Thu, 20 May 2021 15:00:50 +0000 (17:00 +0200)] 
numa_conf: Rename virDomainCache* to virNumaCache*

There's nothing domain specific about NUMA memory caches. Rename the
virDomainCache* structures and enums to virNumaCache*.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agocapabilities: Separate <cpu/> formatting into a function
Michal Privoznik [Wed, 26 May 2021 13:39:38 +0000 (15:39 +0200)] 
capabilities: Separate <cpu/> formatting into a function

The way we format <cpu/> element for capabilities is not ideal,
because if there are no CPUs, i.e. no child elements, we still
output opening and closing element. To solve this,
virXMLFormatElement() could be used but that would introduce more
variables into the loop. Therefore, move the formatter into a
separate function and use virXMLFormatElement().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoschemas: Allow zero <cpu/> for capabilities
Michal Privoznik [Wed, 26 May 2021 14:23:29 +0000 (16:23 +0200)] 
schemas: Allow zero <cpu/> for capabilities

It may happen that a NUMA node has no CPUs associated with it. We
allow this for domains since v6.6.0-rc1~250. Let's update our
capabilities schema to match that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: glib-ify vircaps2xmltest
Michal Privoznik [Fri, 28 May 2021 13:59:35 +0000 (15:59 +0200)] 
tests: glib-ify vircaps2xmltest

Ideally, turning pointers into g_auto* would be done in one step
and dropping cleanup label and unused @ret variable in second
step, but since this is a test we don't care that much, do we?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovirsh-pool: Add virshPoolTypeCompleter in macro VIRSH_COMMON_OPT_POOL_X_AS
Lin Ma [Tue, 15 Jun 2021 00:38:27 +0000 (08:38 +0800)] 
virsh-pool: Add virshPoolTypeCompleter in macro VIRSH_COMMON_OPT_POOL_X_AS

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Add format completion to blockcopy command
Lin Ma [Tue, 15 Jun 2021 00:38:26 +0000 (08:38 +0800)] 
virsh: Add format completion to blockcopy command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Add target completion to dompmsuspend command
Lin Ma [Tue, 15 Jun 2021 00:38:25 +0000 (08:38 +0800)] 
virsh: Add target completion to dompmsuspend command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Use VIR_ENUM_* for --target argument in cmdDomPMSuspend
Lin Ma [Tue, 15 Jun 2021 00:38:24 +0000 (08:38 +0800)] 
virsh: Use VIR_ENUM_* for --target argument in cmdDomPMSuspend

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Add target completion to nodesuspend command
Lin Ma [Tue, 15 Jun 2021 00:38:23 +0000 (08:38 +0800)] 
virsh: Add target completion to nodesuspend command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Use VIR_ENUM_* for --target argument in cmdNodeSuspend
Lin Ma [Tue, 15 Jun 2021 00:38:22 +0000 (08:38 +0800)] 
virsh: Use VIR_ENUM_* for --target argument in cmdNodeSuspend

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Add comp-methods completion to migrate command
Lin Ma [Tue, 15 Jun 2021 00:38:21 +0000 (08:38 +0800)] 
virsh: Add comp-methods completion to migrate command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_firmware: select correct firmware for AMD SEV-ES
Pavel Hrdina [Tue, 25 May 2021 07:56:38 +0000 (09:56 +0200)] 
qemu_firmware: select correct firmware for AMD SEV-ES

When using firmware auto-selection and user enables AMD SEV-ES we need
to pick correct firmware that actually supports it. This can be detected
by having `amd-sev-es` in the firmware JSON description.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosrc: Use 1U for bit shifting
Michal Privoznik [Mon, 14 Jun 2021 10:46:58 +0000 (12:46 +0200)] 
src: Use 1U for bit shifting

In a few places we take 1 and shift it left repeatedly. So much
that it won't longer fit into signed integer. The problem is that
this is undefined behaviour. Switching to 1U makes us stay within
boundaries.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoDon't call qsort() over NULL
Michal Privoznik [Mon, 14 Jun 2021 10:46:02 +0000 (12:46 +0200)] 
Don't call qsort() over NULL

In a few places it may happen that the array we want to sort is
still NULL (e.g. because there were no leases found, no paths for
secdriver to lock or no cache banks). However, passing NULL to
qsort() is undefined and even though glibc plays nicely we
shouldn't rely on undefined behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoci: Enable address and undefined behavior sanitizers
Tim Wiederhake [Thu, 6 May 2021 15:08:38 +0000 (17:08 +0200)] 
ci: Enable address and undefined behavior sanitizers

meson supports the following sanitizers: "address" (e.g. out-of-bounds
memory access, use-after-free, etc.), "thread" (data races), "undefined"
(e.g. signed integer overflow), and "memory" (use of uninitialized
memory). Note that not all sanitizers are supported by all compilers,
and that more sanitizers exist.

Not all sanitizers can be enabled at the same time, but "address" and
"undefined" can. Both thread and memory sanitizers require an instrumented
build of all dependencies, including libc.

gcc and clang use different implementations of these sanitizers and
have proven to find different issues. Create CI jobs for both.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirt-aa-helper: Remove duplicate linking with src/datatypes.o
Tim Wiederhake [Thu, 6 May 2021 15:08:37 +0000 (17:08 +0200)] 
virt-aa-helper: Remove duplicate linking with src/datatypes.o

"virt-aa-helper" links, amongst others, against "datatypes.o" and
"libvirt.so". The latter links against "libvirt_driver.a" which in turn
also links against "datatypes.o", leading to a One-Definition-Rule
violoation for "virConnectClass" et al. in "datatypes.c".

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: openvzutilstest: Remove duplicate linking with libvirt_openvz.a
Tim Wiederhake [Thu, 6 May 2021 15:08:36 +0000 (17:08 +0200)] 
tests: openvzutilstest: Remove duplicate linking with libvirt_openvz.a

"openvzutilstest" links, amongst others, against "libvirt_openvz.a" and
"libvirt.so". The latter also links against "libvirt_openvz.a", leading
to a One-Definition-Rule violation for "openvzLocateConfFile" in
"openvz_conf.c".

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoopenvz: Add missing symbols to libvirt_openvz.syms
Tim Wiederhake [Thu, 6 May 2021 15:08:35 +0000 (17:08 +0200)] 
openvz: Add missing symbols to libvirt_openvz.syms

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: virfilemock: realpath: Allow non-null second parameter
Tim Wiederhake [Thu, 6 May 2021 15:08:34 +0000 (17:08 +0200)] 
tests: virfilemock: realpath: Allow non-null second parameter

When other preloaded libraries wrap and / or make calls to `realpath`
(e.g. LLVM's AddessSanitizer), the second parameter is no longer
guaranteed to be NULL.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agomeson: Allow undefined symbols when sanitizers are enabled
Tim Wiederhake [Thu, 6 May 2021 15:08:33 +0000 (17:08 +0200)] 
meson: Allow undefined symbols when sanitizers are enabled

When enabling sanitizers, clang adds some function symbols when
instrumenting the code. The exact names of those functions are an
implementation detail and should therefore not be added to any
syms file. This patch prevents build failures due to those symbols
not present in the syms file when building with sanitizers enabled.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agomeson: Allow larger stack frames when instrumenting
Tim Wiederhake [Thu, 6 May 2021 15:08:32 +0000 (17:08 +0200)] 
meson: Allow larger stack frames when instrumenting

When enabling sanitizers, gcc adds some instrumentation to the code
that may enlarge stack frames. Some function's stack frames are already
close to the limit of 4096 and are enlarged past that threshold,
e.g. virLXCProcessStart which reaches a frame size of 4624 bytes.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBuildDeviceVideoStr: Don't overwrite @model
Michal Privoznik [Fri, 11 Jun 2021 12:49:06 +0000 (14:49 +0200)] 
qemuBuildDeviceVideoStr: Don't overwrite @model

Now we have everything prepared so that @model doesn't have to be
rewritten. The correct model can be chosen right from the
beginning.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuBuildDeviceVideoStr: Move logic wrapping qemuBuildVirtioDevStr() into qemuDeviceV...
Michal Privoznik [Fri, 11 Jun 2021 13:13:24 +0000 (15:13 +0200)] 
qemuBuildDeviceVideoStr: Move logic wrapping qemuBuildVirtioDevStr() into qemuDeviceVideoGetModel()

We want to call qemuBuildVirtioDevStr() from
qemuBuildDeviceVideoStr() but only for some models (currently
"virtio-gpu" and "vhost-user-gpu"), not all of them. Move this
logic into qemuDeviceVideoGetModel() because this logic will be
refined.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_command: Switch from VIR_ENUM_IMPL(qemuDeviceVideoSecondary) to explicit switch()
Michal Privoznik [Fri, 11 Jun 2021 12:42:22 +0000 (14:42 +0200)] 
qemu_command: Switch from VIR_ENUM_IMPL(qemuDeviceVideoSecondary) to explicit switch()

This may look like a step backwards, but it isn't. The point is
that in near future the chosen model will depend on more than
just video type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_command: Switch from VIR_ENUM_IMPL(qemuDeviceVideo) to explicit switch()
Michal Privoznik [Fri, 11 Jun 2021 12:35:56 +0000 (14:35 +0200)] 
qemu_command: Switch from VIR_ENUM_IMPL(qemuDeviceVideo) to explicit switch()

This may look like a step backwards, but it isn't. The point is
that in near future the chosen model will depend on more than
just video type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuDeviceVideoGetModel: Deduplicate a check
Michal Privoznik [Fri, 11 Jun 2021 11:31:56 +0000 (13:31 +0200)] 
qemuDeviceVideoGetModel: Deduplicate a check

There is the same check written twice (whether given video card
is primary one and whether it supports VGA mode). Write it just
once and store it in a boolean variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuBuildDeviceVideoStr: Separate out video module selection
Michal Privoznik [Fri, 11 Jun 2021 11:22:34 +0000 (13:22 +0200)] 
qemuBuildDeviceVideoStr: Separate out video module selection

The code that decides video card model is going to be reworked
and expanded. Separate it out into a function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemuDomainSupportsVideoVga: Fix const correctness
Michal Privoznik [Fri, 11 Jun 2021 11:24:14 +0000 (13:24 +0200)] 
qemuDomainSupportsVideoVga: Fix const correctness

This function doesn't modify passed video definition. Make the
argument const.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>