Commit Graph

42382 Commits

Author SHA1 Message Date
Peter Krempa
b20ef5e6de 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
651f77f898 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
d30548aa48 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
d5578879a8 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
ed4c75c4da 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
1a468c01a8 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
ea0b164367 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
675755e044 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
d0f60b89f3 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
b408580960 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
599b17d580 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
0a8d3740d0 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
f9dda2805f 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
55ead2333f 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
c29bb0fbb6 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
e637d34277 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
7a8895463b 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
1f645c10c1 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
a6aab07787 qemu: capabilities: Retire QEMU_CAPS_VIRTIO_S390
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-06-15 16:58:23 +02:00
Peter Krempa
34632516f5 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
69da676aa3 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
3dc7a0e934 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>
2021-06-15 16:58:23 +02:00
Peter Krempa
6a6b28c812 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
dde77d1cf6 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
b5a945209d 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
e1337ed0cc 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
5d83508fe8 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
eb3e106c65 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
21144ed89c 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
7b31066658 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
54aad2b99d 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
ba77c61b9b 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
c34eeeceb0 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>
2021-06-15 16:58:22 +02:00
Peter Krempa
e8a396682b 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>
2021-06-15 16:58:07 +02:00
Peter Krempa
9a82146fcd 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: 0046e0b1c2
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-06-15 16:27:35 +02:00
Peter Krempa
2d018bf769 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>
2021-06-15 16:27:35 +02:00
Martin Kletzander
50261966fd syntax-check: Only prohibit empty first lines in non-empty files
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-06-15 14:15:42 +02:00
Luke Yue
69f469ea83 test_driver: Implement virDomainGetSecurityLabel
Signed-off-by: Luke Yue <lukedyue@gmail.com>
2021-06-15 14:15:13 +02:00
Luke Yue
0af05dffb8 test_driver: Implement virNodeGetSecurityModel
Signed-off-by: Luke Yue <lukedyue@gmail.com>
2021-06-15 14:15:13 +02:00
Luke Yue
65c2901906 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>
2021-06-15 14:15:01 +02:00
Luke Yue
d2b6bab11c Replace virFileAbsPath() with g_canonicalize_filename()
Signed-off-by: Luke Yue <lukedyue@gmail.com>
2021-06-15 12:42:02 +02:00
Simon Chopin
8d1559fbc3 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>
2021-06-15 12:14:52 +02:00
Pavel Hrdina
a323c5e8b7 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>
2021-06-15 11:34:17 +02:00
Pavel Hrdina
dbdc6d52ff 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>
2021-06-15 11:33:35 +02:00
Pavel Hrdina
0b0a633d1a 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>
2021-06-15 11:33:27 +02:00
Pavel Hrdina
241969d465 qemu_command: use confidential-guest-support if available
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-06-15 11:33:25 +02:00
Pavel Hrdina
b560d1c876 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>
2021-06-15 11:33:17 +02:00
Pavel Hrdina
af5828bc91 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>
2021-06-15 11:32:41 +02:00
Michal Privoznik
7d97d7af9e 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>
2021-06-15 11:03:56 +02:00
Michal Privoznik
0cc6f8931f 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>
2021-06-15 11:03:25 +02:00