[PATCH 0/5] Deduplicate some of validation code

Michal Privoznik posted 5 patches 3 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cover.1605611915.git.mprivozn@redhat.com
src/conf/domain_capabilities.c                |   2 +-
src/conf/domain_capabilities.h                |   2 +
src/qemu/qemu_capabilities.c                  |   8 +-
src/qemu/qemu_capabilities.h                  |   9 ++
src/qemu/qemu_validate.c                      | 107 ++++--------------
.../domaincapsdata/qemu_2.10.0-q35.x86_64.xml |   1 +
.../domaincapsdata/qemu_2.10.0-tcg.x86_64.xml |   1 +
.../qemu_2.10.0-virt.aarch64.xml              |   1 +
tests/domaincapsdata/qemu_2.10.0.aarch64.xml  |   1 +
tests/domaincapsdata/qemu_2.10.0.ppc64.xml    |   1 +
tests/domaincapsdata/qemu_2.10.0.s390x.xml    |   1 +
tests/domaincapsdata/qemu_2.10.0.x86_64.xml   |   1 +
.../domaincapsdata/qemu_2.11.0-q35.x86_64.xml |   1 +
.../domaincapsdata/qemu_2.11.0-tcg.x86_64.xml |   1 +
tests/domaincapsdata/qemu_2.11.0.s390x.xml    |   1 +
tests/domaincapsdata/qemu_2.11.0.x86_64.xml   |   1 +
.../domaincapsdata/qemu_2.12.0-q35.x86_64.xml |   1 +
.../domaincapsdata/qemu_2.12.0-tcg.x86_64.xml |   1 +
.../qemu_2.12.0-virt.aarch64.xml              |   1 +
tests/domaincapsdata/qemu_2.12.0.aarch64.xml  |   1 +
tests/domaincapsdata/qemu_2.12.0.ppc64.xml    |   1 +
tests/domaincapsdata/qemu_2.12.0.s390x.xml    |   1 +
tests/domaincapsdata/qemu_2.12.0.x86_64.xml   |   1 +
.../domaincapsdata/qemu_3.0.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_3.0.0-tcg.x86_64.xml  |   1 +
tests/domaincapsdata/qemu_3.0.0.ppc64.xml     |   1 +
tests/domaincapsdata/qemu_3.0.0.s390x.xml     |   1 +
tests/domaincapsdata/qemu_3.0.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_3.1.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_3.1.0-tcg.x86_64.xml  |   1 +
tests/domaincapsdata/qemu_3.1.0.ppc64.xml     |   1 +
tests/domaincapsdata/qemu_3.1.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_4.0.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_4.0.0-tcg.x86_64.xml  |   1 +
.../qemu_4.0.0-virt.aarch64.xml               |   1 +
tests/domaincapsdata/qemu_4.0.0.aarch64.xml   |   1 +
tests/domaincapsdata/qemu_4.0.0.ppc64.xml     |   1 +
tests/domaincapsdata/qemu_4.0.0.s390x.xml     |   1 +
tests/domaincapsdata/qemu_4.0.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_4.1.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_4.1.0-tcg.x86_64.xml  |   1 +
tests/domaincapsdata/qemu_4.1.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_4.2.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml  |   1 +
.../qemu_4.2.0-virt.aarch64.xml               |   1 +
tests/domaincapsdata/qemu_4.2.0.aarch64.xml   |   1 +
tests/domaincapsdata/qemu_4.2.0.ppc64.xml     |   1 +
tests/domaincapsdata/qemu_4.2.0.s390x.xml     |   1 +
tests/domaincapsdata/qemu_4.2.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  |   1 +
.../qemu_5.0.0-virt.aarch64.xml               |   1 +
tests/domaincapsdata/qemu_5.0.0.aarch64.xml   |   1 +
tests/domaincapsdata/qemu_5.0.0.ppc64.xml     |   1 +
tests/domaincapsdata/qemu_5.0.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |   1 +
tests/domaincapsdata/qemu_5.1.0.x86_64.xml    |   1 +
.../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |   1 +
.../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |   1 +
tests/domaincapsdata/qemu_5.2.0.x86_64.xml    |   1 +
61 files changed, 97 insertions(+), 87 deletions(-)
[PATCH 0/5] Deduplicate some of validation code
Posted by Michal Privoznik 3 years, 5 months ago
These stemmed from Cole's comment on my patches:

https://www.redhat.com/archives/libvir-list/2020-November/msg00888.html

The approach might not be that obvious at first because domCaps do
qemuCaps to device model translation and during validation we want
the exact opposite - we have parsed device model and want to check
whether qemuCaps has corresponding capability.

But what we can do, is let domCaps code fill a bitmap of supported
device models and then check if the bit that corresponds to parsed
device model is set.

In this series I'm fixing RNG and video models, which were checked
this way until very recently (until I touched the code). And also
I'm introducing graphics check (which is new) because that one
looked the most sane from virQEMUCapsFillDomainCaps(). The rest
there not that much.

Michal Prívozník (5):
  domain_capabilities: Introduce VIR_DOMAIN_CAPS_ENUM_IS_SET
  qemu_validate: Deduplicate code for video model check
  qemu_validate: Deduplicate code for RNG model check
  domcaps: Report egl-headless graphics type
  qemu_validate: Deduplicate code for graphics type check

 src/conf/domain_capabilities.c                |   2 +-
 src/conf/domain_capabilities.h                |   2 +
 src/qemu/qemu_capabilities.c                  |   8 +-
 src/qemu/qemu_capabilities.h                  |   9 ++
 src/qemu/qemu_validate.c                      | 107 ++++--------------
 .../domaincapsdata/qemu_2.10.0-q35.x86_64.xml |   1 +
 .../domaincapsdata/qemu_2.10.0-tcg.x86_64.xml |   1 +
 .../qemu_2.10.0-virt.aarch64.xml              |   1 +
 tests/domaincapsdata/qemu_2.10.0.aarch64.xml  |   1 +
 tests/domaincapsdata/qemu_2.10.0.ppc64.xml    |   1 +
 tests/domaincapsdata/qemu_2.10.0.s390x.xml    |   1 +
 tests/domaincapsdata/qemu_2.10.0.x86_64.xml   |   1 +
 .../domaincapsdata/qemu_2.11.0-q35.x86_64.xml |   1 +
 .../domaincapsdata/qemu_2.11.0-tcg.x86_64.xml |   1 +
 tests/domaincapsdata/qemu_2.11.0.s390x.xml    |   1 +
 tests/domaincapsdata/qemu_2.11.0.x86_64.xml   |   1 +
 .../domaincapsdata/qemu_2.12.0-q35.x86_64.xml |   1 +
 .../domaincapsdata/qemu_2.12.0-tcg.x86_64.xml |   1 +
 .../qemu_2.12.0-virt.aarch64.xml              |   1 +
 tests/domaincapsdata/qemu_2.12.0.aarch64.xml  |   1 +
 tests/domaincapsdata/qemu_2.12.0.ppc64.xml    |   1 +
 tests/domaincapsdata/qemu_2.12.0.s390x.xml    |   1 +
 tests/domaincapsdata/qemu_2.12.0.x86_64.xml   |   1 +
 .../domaincapsdata/qemu_3.0.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_3.0.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_3.0.0.ppc64.xml     |   1 +
 tests/domaincapsdata/qemu_3.0.0.s390x.xml     |   1 +
 tests/domaincapsdata/qemu_3.0.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_3.1.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_3.1.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_3.1.0.ppc64.xml     |   1 +
 tests/domaincapsdata/qemu_3.1.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_4.0.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_4.0.0-tcg.x86_64.xml  |   1 +
 .../qemu_4.0.0-virt.aarch64.xml               |   1 +
 tests/domaincapsdata/qemu_4.0.0.aarch64.xml   |   1 +
 tests/domaincapsdata/qemu_4.0.0.ppc64.xml     |   1 +
 tests/domaincapsdata/qemu_4.0.0.s390x.xml     |   1 +
 tests/domaincapsdata/qemu_4.0.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_4.1.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_4.1.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_4.1.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml  |   1 +
 .../qemu_4.2.0-virt.aarch64.xml               |   1 +
 tests/domaincapsdata/qemu_4.2.0.aarch64.xml   |   1 +
 tests/domaincapsdata/qemu_4.2.0.ppc64.xml     |   1 +
 tests/domaincapsdata/qemu_4.2.0.s390x.xml     |   1 +
 tests/domaincapsdata/qemu_4.2.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  |   1 +
 .../qemu_5.0.0-virt.aarch64.xml               |   1 +
 tests/domaincapsdata/qemu_5.0.0.aarch64.xml   |   1 +
 tests/domaincapsdata/qemu_5.0.0.ppc64.xml     |   1 +
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml    |   1 +
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml    |   1 +
 61 files changed, 97 insertions(+), 87 deletions(-)

-- 
2.26.2

Re: [PATCH 0/5] Deduplicate some of validation code
Posted by Cole Robinson 3 years, 5 months ago
On 11/17/20 6:28 AM, Michal Privoznik wrote:
> These stemmed from Cole's comment on my patches:
> 
> https://www.redhat.com/archives/libvir-list/2020-November/msg00888.html
> 
> The approach might not be that obvious at first because domCaps do
> qemuCaps to device model translation and during validation we want
> the exact opposite - we have parsed device model and want to check
> whether qemuCaps has corresponding capability.
> 
> But what we can do, is let domCaps code fill a bitmap of supported
> device models and then check if the bit that corresponds to parsed
> device model is set.
> 
> In this series I'm fixing RNG and video models, which were checked
> this way until very recently (until I touched the code). And also
> I'm introducing graphics check (which is new) because that one
> looked the most sane from virQEMUCapsFillDomainCaps(). The rest
> there not that much.
> 
> Michal Prívozník (5):
>   domain_capabilities: Introduce VIR_DOMAIN_CAPS_ENUM_IS_SET
>   qemu_validate: Deduplicate code for video model check
>   qemu_validate: Deduplicate code for RNG model check
>   domcaps: Report egl-headless graphics type
>   qemu_validate: Deduplicate code for graphics type check
Reviewed-by: Cole Robinson <crobinso@redhat.com>

Thanks for taking care of this

- Cole