Commit Graph

7404 Commits

Author SHA1 Message Date
Michal Privoznik
196e6faabd lib: Use G_N_ELEMENTS instead of sizeof()/sizeof()
For statically declared arrays one can use G_N_ELEMENTS() instead
of explicit sizeof(array) / sizeof(item). I've noticed couple of
places where the latter was used.

I am not fixing every occurrence because we have some places
which do not use glib (examples and NSS module).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-03 14:46:54 +01:00
Michal Privoznik
4f607caba0 virpcivpdtest: Declare variables at multiple lines
In testPCIVPDResourceCustomCompareIndex() there are two variables
declared at one line. They are both g_autoptr() decorated which
makes it worse, because coccinelle fails to parse that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-03 14:46:54 +01:00
Ján Tomko
20ccc19a3c tests: qemuxml2argv: remove validation warning
This warning is emitted for pretty much every test case,
making it hard to see what the actual error is.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-03 10:14:12 +01:00
Dmitrii Shcherbakov
935fbcf9da PCI VPD: Fix a wrong return code in a test case
The test case should return -1, not 0 in case a valid resource could
not be parsed successfully but the ret value is initialized to 0.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-11-02 13:43:23 +00:00
Dmitrii Shcherbakov
600f580d62 PCI VPD: Skip fields with invalid values
While invalid values need to be ignored when presenting VPD data to the
user, it would be good to attempt to parse a valid portion of the VPD
instead of marking it invalid as a whole.

Based on a mailing list discussion, the set of accepted characters is
extended to the set of printable ASCII characters.

https://listman.redhat.com/archives/libvir-list/2021-October/msg01043.html

The particular example encountered on real hardware was multi-faceted:

* "N/A" strings present in read-only fields. This would not be a useful
  valid value for a field (especially if a unique serial number is
  expected), however, it was decided to delegate handling of those kinds
  of values to higher-level software;
* "4W/1W PCIeG2x4" - looks like some vendors use even more printable
  characters in the ASCII range than we currently allow. Since the
  PCI/PCIe VPD specs mention alphanumeric characters without specifying
  the full character set, it looks like this is ambiguous for vendors
  and they tend to use printable ASCII characters;
* 0xFF bytes present in VPD-W field values. Those bytes do not map to
  printable ASCII code points and were probably used by the vendor as
  placeholders. Ignoring the whole VPD because of that would be too
  strict.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-11-02 13:43:23 +00:00
Dmitrii Shcherbakov
43820e4b80 PCI VPD: handle additional edge cases
* RV and RW fields must be at the last position in their respective
  section (per the conditions in the spec). Therefore, the parser now
  stops iterating over fields as soon as it encounters one of those
  fields and checks whether the end of the resource has been reached;
* The lack of the RW field is not treated as a parsing error since we
  can still extract valid data even though this is a PCI/PCIe VPD spec
  violation;
* Individual fields must have a valid length - the parser needs to check
  for invalid length values that violate boundary conditions of the
  resource.
* A zero-length field may be the last one in the resource, however, the
  boundary check is currently too strict to allow that.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-11-02 13:43:23 +00:00
Michal Privoznik
b72419f387 lib: Introduce and use g_autoptr() for virInterfaceDef
There are a lot of places where we call virInterfaceDefFree()
explicitly. We can define autoptr cleanup macro and annotate
declarations with g_autoptr() and remove plenty of those explicit
free calls.

This also fixes a memory leak in udevInterfaceGetXMLDesc() which
called virInterfaceDefFree() only in successful path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-02 10:52:18 +01:00
zhenwei pi
74447e404d tests: qemu: add kvm-pv-ipi off test
Since b2757b697e
(qemu: support kvm-pv-ipi off), libvirt supports xml definition like:

      <features>
        <kvm>
          <pv-ipi state='off'/>
        </kvm>
      </features>

Add test case for this feature.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-02 09:23:53 +01:00
zhenwei pi
4c54af1c93 tests: qemu: use domain type 'kvm' for kvm-features-off
KVM features off test cases should be tested for a KVM domain, so
keep align kvm-features-off test with kvm-features except KVM
features on/off.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-02 09:23:53 +01:00
Peter Krempa
cc54647fb0 testQEMUSchemaValidateEnum: Validate deprecated members
Starting from QEMU-6.2 enum members can be deprecated. Add support to
the validator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
43e2c6544e testQEMUSchemaValidateDeprecated: Move to the top
Move the function to the top of the file so other functions placed
towards the top will be able to reuse it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
cf68184e74 testQEMUSchemaValidateEnum: Use new 'members' for 'enum' meta type
Switch to the new more featured way to report enum members which will
also allow us to detect use of deprecated members.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
91453650f3 testQEMUSchemaValidateEnum: Refactor logic to simplify switching to new QMP schema format
QEMU-6.2 is reporting enum values in the new 'members' array which we'll
be switching to. Rewrite the logic so that adding the new checker is
more straightforward.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
5f5e490c93 qemucapabilitiestest: Update capability probe for qemu-6.2 on x86_64
Update to v6.1.0-1735-gc52d69e7db which has Markus' patches for
improvements of enum probing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
ac9f3a4444 qemu: monitor: Remove unused qemuMonitorSetCPU
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:14:53 +01:00
Peter Krempa
4b1199a5c4 qemuhotplugtest: Remove tests for legacy cpu hotplug on x86
Modern cpu hotplug was introduced in qemu-2.7, thus all qemu versions
actually support it. Remove the tests for the legacy hotplug.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:14:53 +01:00
Michal Privoznik
2996a94dd0 lib: Don't check for virCapabilitiesAddGuestDomain() retval
The virCapabilitiesAddGuestDomain() function can't fail. It
aborts on OOM. Therefore, there's no need to check for its
return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:08:26 +01:00
Michal Privoznik
c18d9e23fa lib: Don't check for virCapabilitiesAddGuest() retval
The virCapabilitiesAddGuest() function can't fail. It aborts on
OOM. Therefore, there's no need to check for its return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:05:52 +01:00
zhangjl02
f3ac931d36 virnetdevopenvswitch: unify calculation of ovs and tc
For other interface type, values in tc rules are calculated by
multiply by 8*1000 instead of 8*1024.

Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-01 15:56:47 +01:00
Ani Sinha
d89fd6d93d qemu: Fix hotplug error message format to conform to spec
Error messages must conform to spec as specified here:
https://www.libvirt.org/coding-style.html#error-message-format

This change makes some error messages conform to the spec above.

Fixes: 8eadf82fb5 ("conf: introduce option to enable/disable pci hotplug on pci-root controller")

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-25 23:42:01 -04:00
Laine Stump
97475487f8 Revert "qemu: capablities: detect acpi-pci-hotplug-with-bridge-support"
This reverts commit 58ba0f6a3d.

Conflict:
  * src/qemu/qemu_capabilities.[ch]

    Because other new cap flags had been added since the original
    commit, reformatting was necessary to follow the "groups of
    five" pattern.

  * tests.qemucapabilitiesdata/caps_6.2.0.x86_64.xml

    This file was added after the original commit that we
    are reverting, so had to be manually edited to remove
    the two capabilities.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:41 -04:00
Laine Stump
dba9893831 Revert "conf: introduce support for acpi-bridge-hotplug feature"
This reverts commit 7300ccc9b3.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:41 -04:00
Laine Stump
26e8eda46e Revert "qemu: command: add support for acpi-bridge-hotplug feature"
This reverts commit bef0f0d8be.

Conflicts:
 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args

  * this file had been renamed from its original, then renamed back,
    which understandably confused git. It's being completely removed
    here anyway, so the contents don't matter.

 tests/qemuxml2argvtest.c

  * change in context around removed chunk

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:41 -04:00
Laine Stump
1a786fda0e Revert "qemuxml2argvtest: Use real-caps testing for 'acpi-hotplug-bridge-disable'"
This reverts commit 2d20f0bb05.

Conflicts:
 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.args
 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args

  the test output of these files was regenerated because the tests
  were changed upstream to use JSON on the commandline at a later
  commit than the commit being reverted here (where they were changed
  to use latest caps, but the patches to use JSON on the commandline
  hadn't been committed yet).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Laine Stump
85094a4d60 Revert "qemuxml2argvtest: Add '-enable' variants for ACPI-hotplug related cases"
This reverts commit 6414603105.

Conflicts:
 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-enable.x86_64-latest.args
 tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-enable.x86_64-latest.args
 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-enable.x86_64-latest.args

These files are unrelated to the functionality we need to remove, so
they weren't removed, and the associated test cases weren't removed
from qemuxml2argvtest.c

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Laine Stump
ea373d6c07 Revert "qemuxml2xmltest: Convert all acpi-hotplug control related tests to DO_TEST_CAPS_LATEST"
This reverts commit da896d440c.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Laine Stump
d65eb5dd8d Revert "qemu: capabilities: Remove QEMU_CAPS_PIIX4_ACPI_HOTPLUG_BRIDGE"
This reverts commit 618e8665db.

This is the first in a series of 10 commits that revert (in reverse
order) the changes to add the <acpi-hotplug-bridge state='on|off'/>
switch to libvirt domain XML, which unfortunately needs to be removed
due to QEMU developers discovering a flaw with the design of the QEMU
commandline switch used to implement the libvirt switch that will
likely result in a new and different method of selecting hotplug
modes. Because the libvirt switch has not been in any official
releases of libvirt, we are still able to remove it completely, rather
than deprecating it.

The original commits began with commit
58ba0f6a3d. The other original commit
IDs are documented in each revert commit.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Peter Krempa
8e3a7c6db9 qemublocktest: Don't leak 'disk' in testQemuImageCreateLoadDiskXML
The function returns only the source portion but forgot to free the disk
wrapper.

Fixes: 9696427ad6
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 16:11:49 +02:00
Or Ozeri
060f344c80 conf: add luks2 encryption format
This commit extends libvirt XML configuration to support luks2 encryption format.
This means that <encryption format="luks2" engine="librbd"> becomes valid.
Currently librbd is the only engine that supports this new format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
59090adf63 qemu: add librbd encryption engine
rbd encryption is new in qemu 6.1.0.
This commit adds a new encryption engine property which
allows the user to use this new encryption engine.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
ab1d46d612 conf: add encryption engine property
This commit extends libvirt XML configuration to support a custom encryption engine.
This means that <encryption format="luks" engine="qemu">  becomes valid.
The only engine for now is qemu. However, a new engine (librbd) will be added in an upcoming commit.
If no engine is specified, qemu will be used (assuming qemu driver is used).

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
0398be5da6 qemu: capablities: Detect presence of 'rbd-encryption' as QEMU_CAPS_RBD_ENCRYPTION
rbd encryption is new in qemu 6.1.0.
This commit adds capability probing for it.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
9696427ad6 qemu: add disk post parse to qemublocktest
The post parse callback is part of the real (non-test) processing flow.
This commit adds it (for disks) to the qemublocktest flow as well.
Specifically, this will be needed for tests that use luks encryption,
so that the default encryption engine (which is added in an upcoming commit)
will be overridden by qemu.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Michal Privoznik
857df2fe50 lib: Drop intermediary return variables
In a few places we declare a variable (which is optionally
followed by a code not touching it) then set the variable to a
value and return the variable immediately. It's obvious that the
variable is needless and the value can be returned directly
instead.

This patch was generated using this semantic patch:

  @@
  type T;
  identifier ret;
  expression E;
  @@
  - T ret;
  ... when != ret
      when strict
  - ret = E;
  - return ret;
  + return E;

After that I fixed couple of formatting issues because coccinelle
formatted some lines differently than our coding style.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-25 12:48:46 +02:00
Michal Privoznik
7ce6a2f30e qemumigparamstest: Drop "unsupported" test case
The aim of "unsupported" test case is to check whether our code
handles 'CommandNotFound' error returned for
'query-migrate-parameters' monitor command. Well, the command is
pretty old and every QEMU that we are dealing with supports it.
Thus this test case is useless. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-22 07:00:44 +02:00
Dmitrii Shcherbakov
3954378d06 Add PCI VPD Capability Support
* XML serialization and deserialization of PCI VPD;
* PCI VPD capability flags added and used in relevant places;
* XML to XML tests for the added capability.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-10-21 17:34:04 +01:00
Dmitrii Shcherbakov
38003e7551 Add PCI VPD-related helper functions to virpci
Add helper functions to virpci to provide means of checking for a VPD
file presence and for VPD resource retrieval using the PCI VPD parser.

The added test assesses the basic functionality of VPD retrieval while
the full parser is tested by virpcivpdtest.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-10-21 17:34:04 +01:00
Dmitrii Shcherbakov
59c1bc3a0e Add a PCI/PCIe device VPD Parser
Add support for deserializing the binary PCI/PCIe VPD format and storing
results in memory.

The VPD format is specified in "I.3. VPD Definitions" in PCI specs
(2.2+) and "6.28.1 VPD Format" PCIe 4.0. As section 6.28 in PCIe 4.0
notes, the PCI Local Bus and PCIe VPD formats are binary compatible
and PCIe 4.0 merely started incorporating what was already present in
PCI specs.

Linux kernel exposes a binary blob in the VPD format via sysfs since
v2.6.26 (commit 94e6108803469a37ee1e3c92dafdd1d59298602f) which requires
a parser to interpret.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-10-21 17:34:04 +01:00
Andrea Bolognani
d2872fc47f tests: Add replies for QEMU 6.2.0 on aarch64
These were generated using a QEMU binary built from commit
v6.1.0-1552-g362534a643

Notably, this causes the arguments of -device to be generated
in JSON format.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-20 16:52:45 +02:00
Daniel P. Berrangé
f18592adb1 qemu: remove use of implicit boolean syntax for guest features
Some guest features that map to the -cpu arg are still added using
implicit syntax "feature" which is a deprecated shorthand for
"feature=on".

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-10-20 13:19:49 +01:00
Daniel P. Berrangé
ff3e93a26b qemu: remove use of (+|-)name syntax for -cpu featres
The -cpu arg gained support for feature=on|off syntax for the x86
emulator in 2.4.0

  commit 38e5c119c2925812bd441450ab9e5e00fc79e662
  Author: Eduardo Habkost <ehabkost@redhat.com>
  Date:   Mon Mar 23 17:29:32 2015 -0300

    target-i386: Register QOM properties for feature flags

Most other targets gained this syntax even earlier in 1.4.1

  commit 1590bbcb02921dfe8e3cf66e3a3aafd31193babf
  Author: Andreas Färber <afaerber@suse.de>
  Date:   Mon Mar 3 23:33:51 2014 +0100

    cpu: Implement CPUClass::parse_features() for the rest of CPUs

    CPUs who do not provide their own implementation of feature parsing
    will treat each option as a QOM property and set it to the supplied
    value.

There appears no reason to keep supporting "+|-feature" syntax,
given the current minimum QEMU version.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-10-20 13:01:41 +01:00
Daniel P. Berrangé
a81784ea3a qemu: always use hyphens in hyperv feature names
QEMU switched from using underscores in x86 CPU features to hyphens
in the 2.8.0 series with two commits

  commit fc7dfd205f3287893c436d932a167bffa30579c8 (HEAD, refs/bisect/bad)
  Author: Eduardo Habkost <ehabkost@redhat.com>
  Date:   Fri Sep 30 15:49:40 2016 -0300

    target-i386: Remove underscores from feat_names arrays

  commit 54b8dc7c19cd781e96f1e9b001ca6001d804eb19
  Author: Eduardo Habkost <ehabkost@redhat.com>
  Date:   Fri Sep 30 15:49:38 2016 -0300

    target-i386: Register aliases for feature names with underscores

Libvirt names use underscores so we conditionally tranlate the
names when talking to new QEMU. Since the min QEMU was raised to
version 2.11.0, all QEMU versions we talk to expect hypens, so
the translation can be done unconditionally.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-10-20 13:01:33 +01:00
Daniel P. Berrangé
7bf6292fb3 qemu: always translate underscores to hyphens in CPU features
QEMU switched from using underscores in x86 CPU features to hyphens
in the 2.8.0 series with two commits

  commit fc7dfd205f3287893c436d932a167bffa30579c8 (HEAD, refs/bisect/bad)
  Author: Eduardo Habkost <ehabkost@redhat.com>
  Date:   Fri Sep 30 15:49:40 2016 -0300

    target-i386: Remove underscores from feat_names arrays

  commit 54b8dc7c19cd781e96f1e9b001ca6001d804eb19
  Author: Eduardo Habkost <ehabkost@redhat.com>
  Date:   Fri Sep 30 15:49:38 2016 -0300

    target-i386: Register aliases for feature names with underscores

Libvirt names use underscores so we conditionally tranlate the
names when talking to new QEMU. Since the min QEMU was raised to
version 2.11.0, all QEMU versions we talk to expect hypens, so
the translation can be done unconditionally.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-10-20 13:01:22 +01:00
Peter Krempa
5f5631707f qemuMonitorGetAllBlockStatsInfo: Remove 'backingChain' argument
All (proper) callers pass true so we can remove the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-20 13:43:37 +02:00
Peter Krempa
6f34a991c7 testCompareXMLToArgvValidateSchemaCommand: Add validation for '-device'
Now that we use JSON with -device we can validate it at least partially
(since the schema for 'device_add' is for now incomplete) against the
QMP schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:59 +02:00
Peter Krempa
c9b13e0557 qemu: Use JSON directly for '-device'
Starting with QEMU-6.2 started accepting a JSON object as argument for
'-device' which will also become the only syntax considered stable by
qemu in the future.

Since libvirt was recently converted to generate the properties via JSON
to begin wit we can start using it on the commandline as well, by simply
enabling the QEMU_CAPS_DEVICE_JSON capability, which we do by probing
for the 'json-cli' feature flag of 'device_add'.

Normally a change which changes a commandline output should be happening
only after the impacted real-caps test files are forked in the version
preceding the change, but in this case it's not necessary as the logic
for generating the device properties stays identical and we just change
the output format (avoid conversion). Additionally we still have a lot
of tests validating the conversion to the old commandline options.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Peter Krempa
697e796981 qemuMonitorTestProcessCommandDefaultValidate: Partially validate 'device_add'
Use the 'allowIncomplete' argument of testQEMUSchemaValidateCommand to
validate at least properties which are already described by the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Peter Krempa
b17fd211e2 testQEMUSchemaValidateCommand: Add possibility for partial QMP validation
The QMP schema for 'device_add' is not complete yet. Allow validation of
incomplete schema so that we can enable at least some validation. Once
there's more schema in the future all present members are still
validated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Peter Krempa
387c900de9 qemucapabilitiestest: Update qemu-6.2 cycle capability test data
Update to v6.1.0-1510-gc148a05721 which most notably adds the 'json-cli'
feature for 'device_add' QMP command meaning that -device accepts JSON.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Michal Privoznik
c2c67fe4fd objecteventtest: Don't overwrite @ret on failure
Our general pattern is to initialize @ret to -1 and set it to 0
only at the end of a function. Some functions in
objecteventtest.c do not follow this pattern.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-10-18 12:09:33 +02:00