[PATCH v2 00/35] qemu: Add infrastructure to prevent accidental disk shrink via 'virDomainBlockResize' (part 2)

Peter Krempa via Devel posted 35 patches 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cover.1777548628.git.pkrempa@redhat.com
docs/manpages/virsh.rst         |  30 +-
include/libvirt/libvirt-host.h  |   3 +
scripts/check-symfile.py        |   2 +-
scripts/genintrospection.py     | 347 ++++++++++++++++++++
scripts/meson.build             |   1 +
src/bhyve/bhyve_driver.c        |  20 +-
src/ch/ch_driver.c              |  11 +-
src/conf/domain_conf.c          |   3 +-
src/conf/domain_conf.h          |   4 +
src/conf/domain_event.c         |   4 +-
src/conf/domain_event.h         |   5 +
src/driver-hypervisor.h         |   5 +
src/libvirt-host.c              |  40 +++
src/libvirt_private.syms        |  10 +-
src/libvirt_public.syms         |   5 +
src/lxc/lxc_driver.c            |  24 +-
src/openvz/openvz_driver.c      |  12 +-
src/qemu/meson.build            |  18 ++
src/qemu/qemu_backup.c          |   8 +-
src/qemu/qemu_backup.h          |   3 +-
src/qemu/qemu_checkpoint.c      |  11 -
src/qemu/qemu_driver.c          | 543 ++++++++++++++++++++------------
src/qemu/qemu_migration.c       |  29 ++
src/qemu/qemu_migration.h       |  32 +-
src/qemu/qemu_snapshot.c        |  27 --
src/remote/remote_driver.c      |   1 +
src/remote/remote_protocol.x    |  15 +-
src/remote_protocol-structs     |  21 +-
src/util/meson.build            |   1 +
src/util/virhostcpu.c           |  10 +-
src/util/virhostcpu.h           |   6 +-
src/util/virhostmem.c           |  53 ++--
src/util/virhostmem.h           |  11 +-
src/util/virintrospection.c     |  82 +++++
src/util/virintrospection.h     |  20 ++
src/util/virnodesuspend.c       |   5 +-
src/util/virnodesuspend.h       |   3 +-
src/util/virtypedparam-public.c |  54 ++--
src/util/virtypedparam.c        | 222 +++++++++----
src/util/virtypedparam.h        |  26 +-
src/vz/vz_driver.c              |  12 +-
tests/virhostcputest.c          |   2 +-
tools/virsh-domain.c            |  59 ++++
tools/virsh-host.c              |  43 +++
44 files changed, 1384 insertions(+), 459 deletions(-)
create mode 100644 scripts/genintrospection.py
create mode 100644 src/util/virintrospection.c
create mode 100644 src/util/virintrospection.h
[PATCH v2 00/35] qemu: Add infrastructure to prevent accidental disk shrink via 'virDomainBlockResize' (part 2)
Posted by Peter Krempa via Devel 2 weeks ago
v2:
 - possibility to query flags for every API at once

   A comment in v1 suggested that polling flags one by one is
   ineffective. It was also limited to virDomainBlockResize.

   This version adds an API 'virConnectGetIntrospection' which allows
   to probe for every flag of every API at once via the introspection
   XML which also informs users about supported typed parameters.

 Patches 1-34 are new in the series. Patch 35 is adapted to use the new
 introspection API.

This is partially a RFC:
 - documentation and schema for the new XML will be contributed later
 - I've contemplated adding typed parameters as input for the new API if
   we'd want to extend it to e.g. allow probing supported stuff for e.g.
   a hypervisor version

Breakdown of patches:

Semi-unrelated refactors/fixes:
  remote_protocol-structs: fix mis-aligned
    'remote_domain_set_throttle_group_args'
  qemu: driver: Unify coding style
  util: typedparam: Convert VIR_TYPED_PARAM_CHECK_TYPE into a function
  util: virTypedParamValidateType: Don't report unknown typed parameter
    type as '(null)'
  util: Replace open-coded internals of VIR_TYPED_PARAMS_DEBUG with
    'virTypedParamDebugstr'
  util: typedparam: Unexport
    virTypedParameterTypeFromString/virTypedParameterTypeToString
  util: typedparam: Refactor and fix typed param validation
  scripts: check-symfile: Allow also symbols in 'readonly' section
  virHostCPUGet(Map|Stats): Remove unused 'flags'
  virHostMemGet(Stats|Parameters): Remove unused 'flags'
  virNodeSuspend: Remove unused 'flags'

Changes to allow the introspection script to parse flags:
  qemu: backup: Move 'virCheckFlags' to top level functions
  qemu: attach/detach device: Move 'virCheckFlags' to top level
    functions
  qemu: dump: Move 'virCheckFlags' to top level functions
  qemu: checkpoint: Move 'virCheckFlags' to top level functions
  qemuDomainRestore(Flags|Params): Refactor flag checking
  qemu: snapshot: Move flag checks to top level functions
  qemuDomainGetLaunchSecurityInfo: Move flag check to top level
  qemuDomainDetachDeviceAlias: Move 'flags' validation to top level
  qemuDomainManagedSaveDefineXML: Add top-level flag validation
  qemuDomainQemuMonitorCommand: Add top-level flag validation
  qemuConnectDomainQemuMonitorEventRegister: Add top-level flag
    validation
  qemuDomainGetMetadata: Add top-level flag validation

API addition and implementation of the introspection api supporting flag
introspection:
  API: Introduce 'virConnectGetIntrospection'
  virsh: Introduce 'introspection' command which uses
    'virConnectGetIntrospection'
  scripts: Introduce 'getintrospection' script
  qemu: Implement 'virConnectGetIntrospection'

Cleanups needed in order to support typed parameter introspection
  util: typedparam: Introduce 'virTypedParamsValidateTemplate'
  qemu: migration: Use 'virTypedParamsValidateTemplate' for migration
    params
  qemu: Reimplement 'qemuDomainValidateBlockIoTune' using
    'virTypedParamsValidateTemplate'
  util: hostmem: Make parameters for 'virHostMemSetParameters'
    introspectable
  qemuDomainSetSchedulerParameters: Make typed parameters introspectable
  qemuDomainSetIOThreadParams: Move typed parameter validation to top
    level

Implementation of typed parameter introspection:
  introspection: Add introspection of input typed parameters

Original patch to prevent shrink in virsh:
  virsh: blockresize: Use VIR_DOMAIN_BLOCK_RESIZE_EXTEND when available
    and introduce --allow-shrink

 docs/manpages/virsh.rst         |  30 +-
 include/libvirt/libvirt-host.h  |   3 +
 scripts/check-symfile.py        |   2 +-
 scripts/genintrospection.py     | 347 ++++++++++++++++++++
 scripts/meson.build             |   1 +
 src/bhyve/bhyve_driver.c        |  20 +-
 src/ch/ch_driver.c              |  11 +-
 src/conf/domain_conf.c          |   3 +-
 src/conf/domain_conf.h          |   4 +
 src/conf/domain_event.c         |   4 +-
 src/conf/domain_event.h         |   5 +
 src/driver-hypervisor.h         |   5 +
 src/libvirt-host.c              |  40 +++
 src/libvirt_private.syms        |  10 +-
 src/libvirt_public.syms         |   5 +
 src/lxc/lxc_driver.c            |  24 +-
 src/openvz/openvz_driver.c      |  12 +-
 src/qemu/meson.build            |  18 ++
 src/qemu/qemu_backup.c          |   8 +-
 src/qemu/qemu_backup.h          |   3 +-
 src/qemu/qemu_checkpoint.c      |  11 -
 src/qemu/qemu_driver.c          | 543 ++++++++++++++++++++------------
 src/qemu/qemu_migration.c       |  29 ++
 src/qemu/qemu_migration.h       |  32 +-
 src/qemu/qemu_snapshot.c        |  27 --
 src/remote/remote_driver.c      |   1 +
 src/remote/remote_protocol.x    |  15 +-
 src/remote_protocol-structs     |  21 +-
 src/util/meson.build            |   1 +
 src/util/virhostcpu.c           |  10 +-
 src/util/virhostcpu.h           |   6 +-
 src/util/virhostmem.c           |  53 ++--
 src/util/virhostmem.h           |  11 +-
 src/util/virintrospection.c     |  82 +++++
 src/util/virintrospection.h     |  20 ++
 src/util/virnodesuspend.c       |   5 +-
 src/util/virnodesuspend.h       |   3 +-
 src/util/virtypedparam-public.c |  54 ++--
 src/util/virtypedparam.c        | 222 +++++++++----
 src/util/virtypedparam.h        |  26 +-
 src/vz/vz_driver.c              |  12 +-
 tests/virhostcputest.c          |   2 +-
 tools/virsh-domain.c            |  59 ++++
 tools/virsh-host.c              |  43 +++
 44 files changed, 1384 insertions(+), 459 deletions(-)
 create mode 100644 scripts/genintrospection.py
 create mode 100644 src/util/virintrospection.c
 create mode 100644 src/util/virintrospection.h

-- 
2.54.0
Re: [PATCH v2 00/35] qemu: Add infrastructure to prevent accidental disk shrink via 'virDomainBlockResize' (part 2)
Posted by Laine Stump via Devel 1 week ago
On 4/30/26 7:43 AM, Peter Krempa via Devel wrote:
>This version adds an API 'virConnectGetIntrospection' which allows
>to probe for every flag of every API at once via the introspection
>XML which also informs users about supported typed parameters.

>[...]

> I've contemplated adding typed parameters as input for
> the new API if we'd want to extend it to e.g. allow probing 
> supported stuff for e.g. a hypervisor version

I'm also adding a new API (virDomainAnnounceInterface()) and am 
wondering about the same thing - the QEMU monitor command that it 
provides access to ("self-announce") has several arguments that allow 
setting the number of times to send the announce packet (GARP), the 
interval between each one, etc, but they all seem like those type of 
magic settings that users shouldn't mess with, and I don't want to add a 
bunch of code just to document it as "There be Dragons here!! Forsooth 
lest ye be slayed in the skirmish!!" (or something like that) and then 
nobody ever uses it. But maybe in the future I'll be proven wrong, and 
I'd hate for someone to have to add a virDomainAnnounceInterface2() API, 
so...

I'm just about to hop into that part of the task, and figure I'll keep 
the initial patches with just a "device" arg (and the "onion on your 
belt" flags), then add an extra patch that adds the virTypedParameterPtr 
to the API (with checks that nothing is put in it for now), and use that 
as a place to poll for opinions.
Re: [PATCH v2 00/35] qemu: Add infrastructure to prevent accidental disk shrink via 'virDomainBlockResize' (part 2)
Posted by Ján Tomko via Devel 1 week ago
On a Thursday in 2026, Peter Krempa via Devel wrote:
>v2:
> - possibility to query flags for every API at once
>
>   A comment in v1 suggested that polling flags one by one is
>   ineffective. It was also limited to virDomainBlockResize.
>
>   This version adds an API 'virConnectGetIntrospection' which allows
>   to probe for every flag of every API at once via the introspection
>   XML which also informs users about supported typed parameters.
>
> Patches 1-34 are new in the series. Patch 35 is adapted to use the new
> introspection API.
>
>This is partially a RFC:
> - documentation and schema for the new XML will be contributed later
> - I've contemplated adding typed parameters as input for the new API if
>   we'd want to extend it to e.g. allow probing supported stuff for e.g.
>   a hypervisor version
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano