]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
5 months agoMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Stefan Hajnoczi [Sat, 21 Dec 2024 13:06:50 +0000 (08:06 -0500)] 
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* qdev: second part of Property cleanups
* rust: second part of QOM rework
* rust: callbacks wrapper
* rust: pl011 bugfixes
* kvm: cleanup errors in kvm_convert_memory()

 # -----BEGIN PGP SIGNATURE-----
 #
 # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmdkaEkUHHBib256aW5p
 # QHJlZGhhdC5jb20ACgkQv/vSX3jHroN0/wgAgIJg8BrlRKfmiz14NZfph8/jarSj
 # TOWYVxL2v4q98KBuL5pta2ucObgzwqyqSyc02S2DGSOIMQCIiBB5MaCk1iMjx+BO
 # pmVU8gNlD8faO8SSmnnr+jDQt+G+bQ/nRgQJOAReF8oVw3O2aC/FaVKpitMzWtvv
 # PLnJWdrqqpGq14OzX8iNCzSujxppAuyjrhT4lNlekzDoDfdTez72r+rXkvg4GzZL
 # QC3xLYg/LrT8Rs+zgOhm/AaIyS4bOyMlkU9Du1rQ6Tyne45ey2FCwKVzBKrJdGcw
 # sVbzEclxseLenoTbZqYK6JTzLdDoThVUbY2JwoCGUaIm+74P4NjEsUsTVg==
 # =TuQM
 # -----END PGP SIGNATURE-----
 # gpg: Signature made Thu 19 Dec 2024 13:39:05 EST
 # gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
 # gpg:                issuer "pbonzini@redhat.com"
 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
 # gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
 # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
 #      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (42 commits)
  rust: pl011: simplify handling of the FIFO enabled bit in LCR
  rust: pl011: fix migration stream
  rust: pl011: extend registers to 32 bits
  rust: pl011: fix break errors and definition of Data struct
  rust: pl011: always use reset() method on registers
  rust: pl011: match break logic of C version
  rust: pl011: fix declaration of LineControl bits
  target/i386: Reset TSCs of parked vCPUs too on VM reset
  kvm: consistently return 0/-errno from kvm_convert_memory
  rust: qemu-api: add a module to wrap functions and zero-sized closures
  rust: qom: add initial subset of methods on Object
  rust: qom: add casting functionality
  rust: tests: allow writing more than one test
  bql: add a "mock" BQL for Rust unit tests
  rust: re-export C types from qemu-api submodules
  rust: rename qemu-api modules to follow C code a bit more
  rust: qom: add possibility of overriding unparent
  rust: qom: put class_init together from multiple ClassInitImpl<>
  Constify all opaque Property pointers
  hw/core/qdev-properties: Constify Property argument to PropertyInfo.print
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 months agoMerge tag 'pull-loongarch-20241219' of https://gitlab.com/bibo-mao/qemu into staging
Stefan Hajnoczi [Thu, 19 Dec 2024 20:46:43 +0000 (15:46 -0500)] 
Merge tag 'pull-loongarch-20241219' of https://gitlab.com/bibo-mao/qemu into staging

loongarch queue

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQQNhkKjomWfgLCz0aQfewwSUazn0QUCZ2PKBQAKCRAfewwSUazn
# 0QAZAQCxbLnvzOb9TPORlg5w0n/xFaKCL7dJbJE4WjlM7dhLkAEA5G8JVoP5Ju2B
# mcK7wbymyXNX1ocsukL/JM2JavHS+AI=
# =JoSk
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 19 Dec 2024 02:23:49 EST
# gpg:                using EDDSA key 0D8642A3A2659F80B0B3D1A41F7B0C1251ACE7D1
# gpg: Good signature from "bibo mao <maobibo@loongson.cn>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 7044 3A00 19C0 E97A 31C7  13C4 8E86 8FB7 A176 9D4C
#      Subkey fingerprint: 0D86 42A3 A265 9F80 B0B3  D1A4 1F7B 0C12 51AC E7D1

* tag 'pull-loongarch-20241219' of https://gitlab.com/bibo-mao/qemu:
  hw/intc/loongarch_extioi: Code cleanup about loongarch_extioi
  hw/intc/loongarch_extioi: Add pre_save interface
  hw/intc/loongarch_extioi: Inherit from loongarch_extioi_common
  hw/intc/loongarch_extioi: Add common file loongarch_extioi_common
  hw/intc/loongarch_extioi: Add unrealize interface
  hw/intc/loongarch_extioi: Add common realize interface
  hw/intc/loongarch_extioi: Rename LoongArchExtIOI with LoongArchExtIOICommonState
  include: Rename LoongArchExtIOI with LoongArchExtIOICommonState
  include: Move struct LoongArchExtIOI to header file loongarch_extioi_common
  include: Add loongarch_extioi_common header file
  hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic
  hw/intc/loongarch_pch: Add pre_save and post_load interfaces
  hw/intc/loongarch_pch: Inherit from loongarch_pic_common
  hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common
  hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState
  hw/intc/loongarch_pch: Merge instance_init() into realize()
  include: Move struct LoongArchPCHPIC to loongarch_pic_common header file
  include: Add loongarch_pic_common header file

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 months agorust: pl011: simplify handling of the FIFO enabled bit in LCR
Paolo Bonzini [Wed, 4 Dec 2024 20:49:34 +0000 (21:49 +0100)] 
rust: pl011: simplify handling of the FIFO enabled bit in LCR

Use ==/!= instead of going through bool and xor.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: pl011: fix migration stream
Paolo Bonzini [Tue, 10 Dec 2024 11:53:22 +0000 (12:53 +0100)] 
rust: pl011: fix migration stream

The Rust vmstate macros lack the type-safety of their C equivalents (so
safe, much abstraction), and therefore they were predictably wrong.

The registers have already been changed to 32-bits in the previous patch,
but read_pos/read_count/read_trigger also have to be u32 instead of usize.
The easiest way to do so is to let the FIFO use u32 indices instead
of usize.

My plan for making VMStateField typesafe is to have a trait to retrieve
a basic VMStateField; for example something like vmstate_uint32 would
become an implementation of the VMState trait on u32.  Then you'd write
something like "vmstate_of!(Type, field).with_version_id(2)".  That is,
vmstate_of retrieves the basic VMStateField and fills in the offset,
and then more changes can be applied on top.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: pl011: extend registers to 32 bits
Paolo Bonzini [Tue, 10 Dec 2024 11:12:47 +0000 (12:12 +0100)] 
rust: pl011: extend registers to 32 bits

The PL011 Technical Reference Manual lists the "real" size of the
registers in table 3-1, and only rounds up to the next byte when
describing the registers; for example, UARTDR is listed as having
width 12/8 (12 bits read, 8 written) and only bits 15:0 are listed
in "Table 3-2 UARTDR Register".

However, in practice these are 32-bit registers, accessible only
through 32-bit MMIO accesses; preserving the fiction that they're
smaller introduces multiple casts (to go from the bilge bitfield
type to e.g u16 to u64) and more importantly it breaks the
migration stream because the Rust vmstate macros are not yet
type safe.

So, just make everything 32-bits wide.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: pl011: fix break errors and definition of Data struct
Paolo Bonzini [Wed, 4 Dec 2024 16:14:00 +0000 (17:14 +0100)] 
rust: pl011: fix break errors and definition of Data struct

The Data struct is wrong, and does not show how bits 8-15 of DR
are the receive status.  Fix it, and use it to fix break
errors ("c >> 8" in the C code does not translate to
"c.to_be_bytes()[3]").

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: pl011: always use reset() method on registers
Paolo Bonzini [Wed, 4 Dec 2024 15:44:42 +0000 (16:44 +0100)] 
rust: pl011: always use reset() method on registers

For CR, the ugly-ish "0.into()" idiom is already hidden within the
reset method.  Do not repeat it.

For FR, standardize on reset() being equivalent to "*self = Self::default()"
and let reset_fifo toggle only the bits that are related to FIFOs.  This
commit also reproduces C commit 02b1f7f6192 ("hw/char/pl011: Split RX/TX
path of pl011_reset_fifo()", 2024-09-13).

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: pl011: match break logic of C version
Paolo Bonzini [Wed, 4 Dec 2024 15:40:29 +0000 (16:40 +0100)] 
rust: pl011: match break logic of C version

Check loopback_enabled(), not fifo_enabled(), like the C code.

Also, set_break_error() must not happen until the break is read from
the FIFO.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: pl011: fix declaration of LineControl bits
Paolo Bonzini [Tue, 10 Dec 2024 11:05:02 +0000 (12:05 +0100)] 
rust: pl011: fix declaration of LineControl bits

The bits in the LineControl struct were backwards. :(

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agotarget/i386: Reset TSCs of parked vCPUs too on VM reset
Maciej S. Szmigiero [Thu, 12 Dec 2024 14:51:15 +0000 (15:51 +0100)] 
target/i386: Reset TSCs of parked vCPUs too on VM reset

Since commit 5286c3662294 ("target/i386: properly reset TSC on reset")
QEMU writes the special value of "1" to each online vCPU TSC on VM reset
to reset it.

However parked vCPUs don't get that handling and due to that their TSCs
get desynchronized when the VM gets reset.
This in turn causes KVM to turn off PVCLOCK_TSC_STABLE_BIT in its exported
PV clock.
Note that KVM has no understanding of vCPU being currently parked.

Without PVCLOCK_TSC_STABLE_BIT the sched clock is marked unstable in
the guest's kvm_sched_clock_init().
This causes a performance regressions to show in some tests.

Fix this issue by writing the special value of "1" also to TSCs of parked
vCPUs on VM reset.

Reproducing the issue:
1) Boot a VM with "-smp 2,maxcpus=3" or similar

2) device_add host-x86_64-cpu,id=vcpu,node-id=0,socket-id=0,core-id=2,thread-id=0

3) Wait a few seconds

4) device_del vcpu

5) Inside the VM run:
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
Observe the sched_clock_stable() value is 1.

6) Reboot the VM

7) Once the VM boots once again run inside it:
# echo "t" >/proc/sysrq-trigger; dmesg | grep sched_clock_stable
Observe the sched_clock_stable() value is now 0.

Fixes: 5286c3662294 ("target/i386: properly reset TSC on reset")
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Link: https://lore.kernel.org/r/5a605a88e9a231386dc803c60f5fed9b48108139.1734014926.git.maciej.szmigiero@oracle.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agokvm: consistently return 0/-errno from kvm_convert_memory
Paolo Bonzini [Thu, 12 Dec 2024 15:55:51 +0000 (16:55 +0100)] 
kvm: consistently return 0/-errno from kvm_convert_memory

In case of incorrect parameters, kvm_convert_memory() was returning
-1 instead of -EINVAL.  The guest won't notice because it will move
anyway to RUN_STATE_INTERNAL_ERROR, but fix this for consistency and
clarity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: qemu-api: add a module to wrap functions and zero-sized closures
Paolo Bonzini [Sat, 30 Nov 2024 16:26:24 +0000 (17:26 +0100)] 
rust: qemu-api: add a module to wrap functions and zero-sized closures

One recurring issue when writing Rust bindings is how to convert a Rust
function ("fn" or "impl Fn") to a C function, and how to pass around
"self" to a C function that only takes a void*.

An easy solution would be to store on the heap a pair consisting of
a pointer to the Rust function and the pointer to "self", but it is
possible to do better.  If an "Fn" has zero size (that is, if it is a
zero-capture closures or a function pointer---which in turn includes all
methods), it is possible to build a generic Rust function that calls it
even if you only have the type; you don't need either the pointer to the
function itself (because the address of the code is part of the type)
or any closure data (because it has size zero).

Introduce a wrapper that provides the functionality of calling the
function given only its type.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: qom: add initial subset of methods on Object
Paolo Bonzini [Tue, 5 Nov 2024 23:01:57 +0000 (00:01 +0100)] 
rust: qom: add initial subset of methods on Object

Add an example of implementing instance methods and converting the
result back to a Rust type.  In this case the returned types are a
string (actually a Cow<str>; but that's transparent as long as it derefs
to &str) and a QOM class.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: qom: add casting functionality
Paolo Bonzini [Thu, 19 Dec 2024 13:32:16 +0000 (14:32 +0100)] 
rust: qom: add casting functionality

Add traits that let client cast typecast safely between object types.
In particular, an upcast is compile-time guaranteed to succeed, and a
YOLO C-style downcast must be marked as unsafe.

The traits are based on an IsA<> trait that declares what
is a subclass of what, which is an idea taken from glib-rs
(https://docs.rs/glib/latest/glib/object/trait.IsA.html).
The four primitives are also taken from there
(https://docs.rs/glib/latest/glib/object/trait.Cast.html).  However,
the implementation of casting itself is a bit different and uses the
Deref trait.

This removes some pointer arithmetic from the pl011 device; it is also a
prerequisite for the definition of methods, so that they can be invoked
on all subclass structs.  This will use the IsA<> trait to detect the
structs that support the methods.

glib also has a "monadic" casting trait which could be implemented on
Option (as in https://docs.rs/glib/latest/glib/object/trait.CastNone.html)
and perhaps even Result.  For now I'm leaving it out, as the patch is
already big enough and the benefit seems debatable.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: tests: allow writing more than one test
Paolo Bonzini [Tue, 5 Nov 2024 21:34:13 +0000 (22:34 +0100)] 
rust: tests: allow writing more than one test

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agobql: add a "mock" BQL for Rust unit tests
Paolo Bonzini [Fri, 15 Nov 2024 11:08:43 +0000 (12:08 +0100)] 
bql: add a "mock" BQL for Rust unit tests

Right now, the stub BQL in stubs/iothread-lock.c always reports itself as
unlocked.  However, Rust would like to run its tests in an environment where
the BQL *is* locked.  Provide an extremely dirty function that flips the
return value of bql_is_locked() to true.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: re-export C types from qemu-api submodules
Paolo Bonzini [Thu, 31 Oct 2024 09:14:11 +0000 (10:14 +0100)] 
rust: re-export C types from qemu-api submodules

Long term we do not want device code to use "bindings" at all, so make it
possible to get the relevant types from the other modules of qemu-api.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: rename qemu-api modules to follow C code a bit more
Paolo Bonzini [Tue, 29 Oct 2024 13:15:27 +0000 (14:15 +0100)] 
rust: rename qemu-api modules to follow C code a bit more

A full match would mean calling them qom::object and hw::core::qdev.  For now,
keep the names shorter but still a bit easier to find.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: qom: add possibility of overriding unparent
Paolo Bonzini [Tue, 29 Oct 2024 14:00:26 +0000 (15:00 +0100)] 
rust: qom: add possibility of overriding unparent

Add a blanket definition of ClassInitImpl<ObjectClass> that thunks
ObjectImpl::UNPARENT and overrides it in ObjectClass if it is not
None.

ClassInitImpl<DeviceClass> can now call its superclass's ClassInitImpl,
so that the C and Rust hierarchies match more closely.

This is mostly done as an example of implementing the metaclass
hierarchy under ClassInitImpl.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust: qom: put class_init together from multiple ClassInitImpl<>
Paolo Bonzini [Fri, 29 Nov 2024 14:19:23 +0000 (15:19 +0100)] 
rust: qom: put class_init together from multiple ClassInitImpl<>

Parameterize the implementation of ClassInitImpl so that it is
possible to call up the chain of implementations, one superclass at
a time starting at ClassInitImpl<Self::Class>.

In order to avoid having to implement (for example)
ClassInitImpl<PL011Class>, also remove the dummy PL011Class and
PL011LuminaryClass structs and specify the same ObjectType::Class as
the superclass.  In the future this default behavior can be handled by
a procedural macro, by looking at the first field in the struct.

Note that the new trait is safe: the calls are started by
rust_class_init<>(), which is not public and can convert the class
pointer to a Rust reference.

Since CLASS_BASE_INIT applies to the type that is being defined,
and only to it, move it to ObjectImpl.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agoConstify all opaque Property pointers
Richard Henderson [Wed, 18 Dec 2024 13:42:51 +0000 (07:42 -0600)] 
Constify all opaque Property pointers

Via sed "s/  Property [*]/  const Property */".

The opaque pointers passed to ObjectProperty callbacks are
the last instances of non-const Property pointers in the tree.
For the most part, these callbacks only use object_field_prop_ptr,
which now takes a const pointer itself.

This logically should have accompanied d36f165d952 which
allowed const Property to be registered.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-25-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/core/qdev-properties: Constify Property argument to PropertyInfo.print
Richard Henderson [Wed, 18 Dec 2024 13:42:50 +0000 (07:42 -0600)] 
hw/core/qdev-properties: Constify Property argument to PropertyInfo.print

This logically should have accompanied d36f165d952 which
allowed const Property to be registered.

There is exactly one instance of this method: print_pci_devfn.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-24-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/core/qdev-properties: Constify Property argument to object_field_prop_ptr
Richard Henderson [Wed, 18 Dec 2024 13:42:49 +0000 (07:42 -0600)] 
hw/core/qdev-properties: Constify Property argument to object_field_prop_ptr

This logically should have accompanied d36f165d952 which
allowed const Property to be registered.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-23-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agoinclude/hw/qdev-properties: Shrink struct Property
Richard Henderson [Wed, 18 Dec 2024 13:42:48 +0000 (07:42 -0600)] 
include/hw/qdev-properties: Shrink struct Property

Before, via pahole:

arm32, a 32-bit host which aligns uint64_t:

struct Property {
        const char  *              name;                 /*     0     4 */
        const PropertyInfo  *      info;                 /*     4     4 */
        ptrdiff_t                  offset;               /*     8     4 */
        uint8_t                    bitnr;                /*    12     1 */
        /* XXX 3 bytes hole, try to pack */
        uint64_t                   bitmask;              /*    16     8 */
        _Bool                      set_default;          /*    24     1 */
        /* XXX 7 bytes hole, try to pack */
        union {
                int64_t            i;                    /*    32     8 */
                uint64_t           u;                    /*    32     8 */
        } defval;                                        /*    32     8 */
        int                        arrayoffset;          /*    40     4 */
        const PropertyInfo  *      arrayinfo;            /*    44     4 */
        int                        arrayfieldsize;       /*    48     4 */
        const char  *              link_type;            /*    52     4 */
        /* size: 56, cachelines: 1, members: 11 */
        /* sum members: 46, holes: 2, sum holes: 10 */
};

arm64, an arbitrary 64-bit host:

struct Property {
        const char  *              name;                 /*     0     8 */
        const PropertyInfo  *      info;                 /*     8     8 */
        ptrdiff_t                  offset;               /*    16     8 */
        uint8_t                    bitnr;                /*    24     1 */
        /* XXX 7 bytes hole, try to pack */
        uint64_t                   bitmask;              /*    32     8 */
        _Bool                      set_default;          /*    40     1 */
        /* XXX 7 bytes hole, try to pack */
        union {
                int64_t            i;                    /*    48     8 */
                uint64_t           u;                    /*    48     8 */
        } defval;                                        /*    48     8 */
        int                        arrayoffset;          /*    56     4 */
        /* XXX 4 bytes hole, try to pack */
        const PropertyInfo  *      arrayinfo;            /*    64     8 */
        int                        arrayfieldsize;       /*    72     4 */
        /* XXX 4 bytes hole, try to pack */
        const char  *              link_type;            /*    80     8 */
        /* size: 88, cachelines: 2, members: 11 */
        /* sum members: 66, holes: 4, sum holes: 22 */
};

Afterward there are no holes in either structure.
For arm32, size 48, padding 2, saved 8 bytes.
For arm64, size 72, padding 6, saved 16 bytes.

Saves 20k from qemu-system-aarch64 on a 64-bit host.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-22-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agoinclude/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST
Richard Henderson [Wed, 18 Dec 2024 13:42:47 +0000 (07:42 -0600)] 
include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST

Now that all of the Property arrays are counted, we can remove
the terminator object from each array.  Update the assertions
in device_class_set_props to match.

With struct Property being 88 bytes, this was a rather large
form of terminator.  Saves 30k from qemu-system-aarch64.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-21-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agotarget/riscv: Do not abuse DEFINE_PROP_END_OF_LIST
Richard Henderson [Wed, 18 Dec 2024 13:42:46 +0000 (07:42 -0600)] 
target/riscv: Do not abuse DEFINE_PROP_END_OF_LIST

These are not arrays of Property and had no business
using DEFINE_PROP_END_OF_LIST.  Use plain { } instead.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-20-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/core: Remove device_class_set_props function
Richard Henderson [Wed, 18 Dec 2024 13:42:45 +0000 (07:42 -0600)] 
hw/core: Remove device_class_set_props function

All uses of device_class_set_props() are now using arrays.
Validate this compile-time in the device_class_set_props macro and
call device_class_set_props_n using the known size of the array.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-19-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agorust/qemu-api: Use device_class_set_props_n
Richard Henderson [Wed, 18 Dec 2024 13:42:44 +0000 (07:42 -0600)] 
rust/qemu-api: Use device_class_set_props_n

This means we can update declare_properties to drop the
zero terminator at the end of the array as well.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-18-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/arm/armsse: Use device_class_set_props_n
Richard Henderson [Wed, 18 Dec 2024 13:42:43 +0000 (07:42 -0600)] 
hw/arm/armsse: Use device_class_set_props_n

We must remove DEFINE_PROP_END_OF_LIST so the count is correct.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-17-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/scsi/megasas: Use device_class_set_props_n
Richard Henderson [Wed, 18 Dec 2024 13:42:42 +0000 (07:42 -0600)] 
hw/scsi/megasas: Use device_class_set_props_n

We must remove DEFINE_PROP_END_OF_LIST so the count is correct.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-16-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agomigration: Use device_class_set_props_n
Richard Henderson [Wed, 18 Dec 2024 13:42:41 +0000 (07:42 -0600)] 
migration: Use device_class_set_props_n

Export the migration_properties array size from options.c;
use that to feed device_class_set_props_n.  We must remove
DEFINE_PROP_END_OF_LIST so the count is correct.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-15-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/core: Introduce device_class_set_props_n
Richard Henderson [Wed, 18 Dec 2024 13:42:40 +0000 (07:42 -0600)] 
hw/core: Introduce device_class_set_props_n

Record the size of the array in DeviceClass.props_count_.
Iterate with known count in qdev_prop_walk.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-14-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agoinclude/hw/qdev-core: Detect most empty Property lists at compile time
Richard Henderson [Wed, 18 Dec 2024 13:42:39 +0000 (07:42 -0600)] 
include/hw/qdev-core: Detect most empty Property lists at compile time

Add a macro expansion of device_class_set_props which can check
on the type and size of PROPS before calling the function.

Avoid the macro in migration.c because migration_properties
is defined externally with indeterminate size.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-13-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/virtio: Remove empty Property lists
Richard Henderson [Wed, 18 Dec 2024 13:42:38 +0000 (07:42 -0600)] 
hw/virtio: Remove empty Property lists

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-12-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/sparc: Remove empty Property lists
Richard Henderson [Wed, 18 Dec 2024 13:42:37 +0000 (07:42 -0600)] 
hw/sparc: Remove empty Property lists

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-11-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/xen: Remove empty Property lists
Richard Henderson [Wed, 18 Dec 2024 13:42:36 +0000 (07:42 -0600)] 
hw/xen: Remove empty Property lists

There is no point in registering no properties.
Remove xen_sysdev_class_init entirely, as it did nothing else.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-10-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/s390x: Remove empty Property lists
Richard Henderson [Wed, 18 Dec 2024 13:42:35 +0000 (07:42 -0600)] 
hw/s390x: Remove empty Property lists

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-9-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/tricore: Remove empty Property lists
Richard Henderson [Wed, 18 Dec 2024 13:42:34 +0000 (07:42 -0600)] 
hw/tricore: Remove empty Property lists

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-8-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/ppc: Only register spapr_nvdimm_properties if CONFIG_LIBPMEM
Richard Henderson [Wed, 18 Dec 2024 13:42:33 +0000 (07:42 -0600)] 
hw/ppc: Only register spapr_nvdimm_properties if CONFIG_LIBPMEM

Do not register an empty set of properties.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-7-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/pci-host/astro: Remove empty Property list
Richard Henderson [Wed, 18 Dec 2024 13:42:32 +0000 (07:42 -0600)] 
hw/pci-host/astro: Remove empty Property list

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-6-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agotarget/s390x: Use s390x_cpu_properties for system mode only
Richard Henderson [Wed, 18 Dec 2024 13:42:31 +0000 (07:42 -0600)] 
target/s390x: Use s390x_cpu_properties for system mode only

Avoid the empty property list for user-only mode.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-5-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agotarget/ppc: Remove empty property list
Richard Henderson [Wed, 18 Dec 2024 13:42:30 +0000 (07:42 -0600)] 
target/ppc: Remove empty property list

Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-4-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/ide: Constify sysbus_ahci_properties
Richard Henderson [Wed, 18 Dec 2024 13:42:29 +0000 (07:42 -0600)] 
hw/ide: Constify sysbus_ahci_properties

Reviewed-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-3-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agomigration: Constify migration_properties
Richard Henderson [Wed, 18 Dec 2024 13:42:28 +0000 (07:42 -0600)] 
migration: Constify migration_properties

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218134251.4724-2-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5 months agohw/intc/loongarch_extioi: Code cleanup about loongarch_extioi
Bibo Mao [Fri, 13 Dec 2024 07:34:48 +0000 (15:34 +0800)] 
hw/intc/loongarch_extioi: Code cleanup about loongarch_extioi

Remove definition about LoongArchExtIOI and LOONGARCH_EXTIOI, and
replace them with LoongArchExtIOICommonState and macro
LOONGARCH_EXTIOI_COMMON separately. Also remove unnecessary header
files.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_extioi: Add pre_save interface
Bibo Mao [Fri, 8 Nov 2024 07:42:05 +0000 (15:42 +0800)] 
hw/intc/loongarch_extioi: Add pre_save interface

Add vmstate pre_save interface, which can be used extioi kvm driver
in future.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_extioi: Inherit from loongarch_extioi_common
Bibo Mao [Fri, 13 Dec 2024 07:32:39 +0000 (15:32 +0800)] 
hw/intc/loongarch_extioi: Inherit from loongarch_extioi_common

Set TYPE_LOONGARCH_EXTIOI inherit from TYPE_LOONGARCH_EXTIOI_COMMON
object, it shares vmsate and property of TYPE_LOONGARCH_EXTIOI_COMMON,
and has its own realize() function.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_extioi: Add common file loongarch_extioi_common
Bibo Mao [Wed, 18 Dec 2024 09:28:04 +0000 (17:28 +0800)] 
hw/intc/loongarch_extioi: Add common file loongarch_extioi_common

Add new common file loongarch_extioi_common.c, and move vmstate
and property structure to common file.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_extioi: Add unrealize interface
Bibo Mao [Fri, 20 Sep 2024 03:48:10 +0000 (11:48 +0800)] 
hw/intc/loongarch_extioi: Add unrealize interface

For loongarch extioi emulation driver, add unrealize interface and
remove instance_finalize interface and move the code to unrealize
interface.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_extioi: Add common realize interface
Bibo Mao [Fri, 20 Sep 2024 07:49:12 +0000 (15:49 +0800)] 
hw/intc/loongarch_extioi: Add common realize interface

Add common realize function, it is only to check validity of property.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_extioi: Rename LoongArchExtIOI with LoongArchExtIOICommonState
Bibo Mao [Wed, 18 Dec 2024 09:24:24 +0000 (17:24 +0800)] 
hw/intc/loongarch_extioi: Rename LoongArchExtIOI with LoongArchExtIOICommonState

With some structure such as vmstate and property, rename LoongArchExtIOI
with LoongArchExtIOICommonState, these common structure will be moved
to common file.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agoinclude: Rename LoongArchExtIOI with LoongArchExtIOICommonState
Bibo Mao [Fri, 20 Sep 2024 02:17:06 +0000 (10:17 +0800)] 
include: Rename LoongArchExtIOI with LoongArchExtIOICommonState

Rename structure LoongArchExtIOI with LoongArchExtIOICommonState,
since it is defined in file loongarch_extioi_common.h

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agoinclude: Move struct LoongArchExtIOI to header file loongarch_extioi_common
Bibo Mao [Fri, 20 Sep 2024 02:08:56 +0000 (10:08 +0800)] 
include: Move struct LoongArchExtIOI to header file loongarch_extioi_common

Move definiton of structure LoongArchExtIOI from header file loongarch_extioi.h
to file loongarch_extioi_common.h.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agoinclude: Add loongarch_extioi_common header file
Bibo Mao [Fri, 20 Sep 2024 02:01:07 +0000 (10:01 +0800)] 
include: Add loongarch_extioi_common header file

Add common header file include/hw/intc/loongarch_extioi_common.h, and
move some macro definition from include/hw/intc/loongarch_extioi.h to
the common header file.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic
Bibo Mao [Wed, 18 Sep 2024 04:05:00 +0000 (12:05 +0800)] 
hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic

Remove definition about LoongArchPCHPIC and LOONGARCH_PCH_PIC, and
replace them with LoongArchPICCommonState and LOONGARCH_PIC_COMMON
separately. Also remove unnecessary header files.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_pch: Add pre_save and post_load interfaces
Bibo Mao [Wed, 18 Sep 2024 03:50:49 +0000 (11:50 +0800)] 
hw/intc/loongarch_pch: Add pre_save and post_load interfaces

Add vmstate pre_save and post_load interfaces, which can be used
by pic kvm driver in future.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_pch: Inherit from loongarch_pic_common
Bibo Mao [Wed, 18 Sep 2024 06:45:50 +0000 (14:45 +0800)] 
hw/intc/loongarch_pch: Inherit from loongarch_pic_common

Set TYPE_LOONGARCH_PIC inherit from TYPE_LOONGARCH_PIC_COMMON object,
it shares vmsate and property of TYPE_LOONGARCH_PIC_COMMON, and has
its own realize() function.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_pch: Move some functions to file loongarch_pic_common
Bibo Mao [Wed, 18 Dec 2024 09:18:56 +0000 (17:18 +0800)] 
hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common

Move some common functions to file loongarch_pic_common.c, the common
functions include loongarch_pic_common_realize(), property structure
loongarch_pic_common_properties and vmstate structure
vmstate_loongarch_pic_common.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState
Bibo Mao [Wed, 18 Dec 2024 09:10:14 +0000 (17:10 +0800)] 
hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState

With pic vmstate, rename structure name vmstate_loongarch_pch_pic with
vmstate_loongarch_pic_common, and with pic property rename
loongarch_pch_pic_properties with loongarch_pic_common_properties.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agohw/intc/loongarch_pch: Merge instance_init() into realize()
Bibo Mao [Wed, 18 Sep 2024 02:16:28 +0000 (10:16 +0800)] 
hw/intc/loongarch_pch: Merge instance_init() into realize()

Memory region is created in instance_init(), merge it into function
realize(). There is no special class_init() for loongarch_pch object.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agoinclude: Move struct LoongArchPCHPIC to loongarch_pic_common header file
Bibo Mao [Wed, 18 Sep 2024 06:43:10 +0000 (14:43 +0800)] 
include: Move struct LoongArchPCHPIC to loongarch_pic_common header file

Move structure LoongArchPCHPIC from header file loongarch_pch_pic.h
to file loongarch_pic_common.h, and rename structure name with
LoongArchPICCommonState.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agoinclude: Add loongarch_pic_common header file
Bibo Mao [Sat, 14 Sep 2024 09:34:06 +0000 (17:34 +0800)] 
include: Add loongarch_pic_common header file

Add common header file hw/intc/loongarch_pic_common.h, and move
some macro definition from hw/intc/loongarch_pch_pic.h to the common
header file.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
5 months agoMerge tag 'qga-pull-2024-12-18' of https://github.com/kostyanf14/qemu into staging
Stefan Hajnoczi [Thu, 19 Dec 2024 01:24:59 +0000 (20:24 -0500)] 
Merge tag 'qga-pull-2024-12-18' of https://github.com/kostyanf14/qemu into staging

qga-pull-2024-12-18

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEwsLBCepDxjwUI+uE711egWG6hOcFAmdit4wACgkQ711egWG6
# hOfQ0xAAjByk0U6cTjIOTgNb3GDEE65CnL/dqiriOtmTPdbmVT4WqkQjPNG8REge
# lA0eDr7oBLWn/Yku7nqMjn4IcnBop92h9jL3RpQNeIbvPdQcpaPEORCCulky58l0
# 0hM/SnhBmRomZ2CwWu4mvl4bKRzn7WCg7mdPbBZEtvAfNdiUGOH5nwdUoJKtcPTj
# OeEOTxcN+FeYNyMRqCUJ4S44OAIh7WMbi4h/0gxufU8KFGYbQphk4xITIBFXBfIf
# oRxqwSMTLXG7nzegfad4HGX2pFUR6Omtmlgn3Cvh8UF8xEJIJIk1mA6Wd2R2am9j
# pdyKwo25K6FSkSvH43cH/IXTaQVvfCLIOOUA7rlAhfWrDsvRuisfh75T9jMOYH5S
# /jB9Vjd8E85qpTwQD2HuphJMzFRpWEeOeMJ2jWHWuMj+d3lHrR3hAmpGFBy7Xmxb
# KyVkUBgaulqoPQqt7C1urNxHjr6FoWDU1AqIAYQdqOJ5TLh/j5o6oz2ZJDOT+RiG
# NZLhTJWtjwA3Rbu1BcF2eyYv20cqeHVAFhS5tJdXOoHyqoJ7Hf+4G56zhXgjxfV9
# 60W3ETQwUPrrUtmb+qDZzmEagSQjj3UpMGEQFWXHKx4zBBXYeYU9O0Xvy04RGh+L
# PV4Y35yPegQ69GbRYUAagXk8Rh3Gbh2l4iFQz+QYCvd1b2CxYFg=
# =nY8c
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 18 Dec 2024 06:52:44 EST
# gpg:                using RSA key C2C2C109EA43C63C1423EB84EF5D5E8161BA84E7
# gpg: Good signature from "Kostiantyn Kostiuk (Upstream PR sign) <kkostiuk@redhat.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: C2C2 C109 EA43 C63C 1423  EB84 EF5D 5E81 61BA 84E7

* tag 'qga-pull-2024-12-18' of https://github.com/kostyanf14/qemu:
  qga: Don't access global variable in run_agent_once()
  qemu-ga-win: Fix a typo error
  qga: skip bind mounts in fs list

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 months agoMerge tag 'pull-request-2024-12-18' of https://gitlab.com/thuth/qemu into staging
Stefan Hajnoczi [Thu, 19 Dec 2024 01:24:51 +0000 (20:24 -0500)] 
Merge tag 'pull-request-2024-12-18' of https://gitlab.com/thuth/qemu into staging

* Lots of functional test improvements (clean-ups, don't fail on
  temporary download errors, etc.)
* Convert some more avocado tests to the functional framework
* Disallow building with libnfs v6 due to an API breakage

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmdirOIRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbU0NRAAke8X0B6OOD+99lY5nc7Hrh7N1m+sw5Lw
# TVwIpxdhxU11vgdlCodfdoVJCV1NGVHwkR57lLNr+bdspWDBBwlmUWn0+t2QCXGe
# oyQsV+boznsjG9pan6v6DcU/gOu7/7ZydhJi+M8Msf8ah0lcn/otAdC4ZFB93JLh
# 6xPnj69y8HomCW+wMyXl7WTjcWX0wQFzweEYY8p7X7p1rtjYyseiZlRjNAvPgTMI
# jznZ6v9/qU54xR9RnKdW+0m1Qu06nx26Wz+ZBlvrJS1Llloe23X9+LY1tDD0Xh1D
# 9P0v9PuaBWRRF+UjVjl37LMyn9h1aaKFKBoWQiKMbyvOVr4ncobjRgN8r5kdNxDP
# FZ/fA1GiX8O3foN9uB9JLKd6Hl49LAqQSPzAneEc3pfQLH3NdAjPxJDbJH5fyMa7
# qVOQC0Bdy8+2kCxFfKbemrwDOFcyq1fVYcADPDZySjMiPnwFJ1Qpni1tXY1PZ+Tl
# Q18AsFJanyAAn7L+8R3Yl54983SuR5eXIFxO+Tq9mw1V1V2h+Cm09HGcS8y5bxFG
# Xh+jhMsMB98NFLR87W6olwl57gKllSbTYuGtiz9TrbnuT/THhUJ0k/B76L7C9HWE
# ZefkFxC5Zy8jrcz3pgarO+19V+eXg5rwGtEngRQrji/3cY5CbK7Jeh5nvZQeASpb
# nZ/gJ/gC8Gs=
# =SWw6
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 18 Dec 2024 06:07:14 EST
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2024-12-18' of https://gitlab.com/thuth/qemu: (38 commits)
  meson.build: Disallow libnfs v6 to fix the broken macOS build
  tests/functional: Convert the hotplug_cpu avocado test
  tests/functional: Convert the intel_iommu avocado test
  tests/functional: Add a helper function for retrieving the hostfwd port
  tests/functional: Convert the arm virt avocado test
  tests/functional: Convert the quanta-gsj avocado test
  MAINTAINERS: add myself as reviewer for functional test suite
  tests/functional: ignore errors when caching assets, except for 404
  tests/functional: skip tests if assets are not available
  tests/functional: remove now unused 'run_cmd' helper
  tests/functional: replace 'run_cmd' with subprocess helpers
  tests/functional: drop back compat imports from utils.py
  tests/functional: convert tests to new uncompress helper
  tests/functional: add 'uncompress' to QemuBaseTest
  tests/functional: add a generalized uncompress helper
  tests/functional: convert tests to new archive_extract helper
  tests/functional: add 'archive_extract' to QemuBaseTest
  tests/functional: add a generalized archive_extract
  tests/functional: let cpio_extract accept filenames
  tests/functional: add common deb_extract helper
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 months agoMerge tag 'pull-target-arm-20241217' of https://git.linaro.org/people/pmaydell/qemu...
Stefan Hajnoczi [Wed, 18 Dec 2024 19:21:21 +0000 (14:21 -0500)] 
Merge tag 'pull-target-arm-20241217' of https://git.linaro.org/people/pmaydell/qemu-arm into staging

target-arm queue:
 * remove a line of redundant code
 * convert various TCG helper fns to use 'fpst' alias
 * Use float_status in helper_fcvtx_f64_to_f32
 * Use float_status in helper_vfp_fcvt{ds,sd}
 * Implement FEAT_XS
 * hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs
 * tests/functional: update sbsa-ref firmware used in test

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmdhsj0ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3vldEACY/BJeDSfE3X6fi2qiVF+p
# hs2NaeiM6HS3+/1oPlPz7sW87cGV58hPW0vOCjZYlfw+Afv2wuL9zb2C7IV+PJOn
# Vy1L/tBezYvgBwi1+bRvLpCge3UKdbRNa6aowGmLnvcnQuZ6lOOcmQ8Jq/a5W1TM
# xOrvPYp0FbcfGXLcDLIluCozupsq4aJsh0gWayzr9zm2tWnzMAhb/GQLuCmLLn35
# pUiAI209xU393AOfdCpAmCGjDCqcqbjHpz0AqrIPtOwaDO3hRlJIMw1eGk2dS0BD
# R0vZG+WFSQMV972reVoTT83W7NmIeeqhZgeKDv2R347EHsbCKt5PIUpWX2zYvk+H
# rfCltOxFVWvJ0e33b9opk2/GfgckkTGw+6ZYMIdMm8UxABrdEaHcWCV0qMyLk2JH
# 4EKYlmKeR8yqkPRDbGkRVANEIDxRBmL96kN6il0wSM742y7UMwMzP3C344Jg0tf/
# AhGrwjsuRW8oeEZMgk9Z0i/J6q3CNxRQSVGGQtYsEt8fs5OXLltLrXEX+aZNF5ua
# ry5SfLWlwIR+0AO4oNaJqJYNQArqhzDUgsY4ryzrueZnaaMShobMn0AP2H3+/l4X
# W3wlIqOQ97ivk0Snc9WpDQyhPPOZuj4LN4IkTkodHu7+eoMrkvojf/BVc5kku2VL
# dE224ctbEbKsbydwubSVfQ==
# =Z/7q
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 17 Dec 2024 12:17:49 EST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [full]
# gpg:                 aka "Peter Maydell <peter@archaic.org.uk>" [unknown]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20241217' of https://git.linaro.org/people/pmaydell/qemu-arm:
  tests/functional: update sbsa-ref firmware used in test
  hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs
  tests/tcg/aarch64: add system test for FEAT_XS
  target/arm: Enable FEAT_XS for the max cpu
  target/arm: Add decodetree entry for DSB nXS variant
  target/arm: Add ARM_CP_ADD_TLBI_NXS type flag to TLBI insns
  target/arm: Add ARM_CP_ADD_TLBI_NXS type flag for NXS insns
  target/arm: Implement fine-grained-trap handling for FEAT_XS
  target/arm: Use float_status in helper_vfp_fcvt{ds,sd}
  target/arm: Use float_status in helper_fcvtx_f64_to_f32
  target/arm: Convert neon_helper.c to use env alias
  target/arm: Convert vec_helper.c to use env alias
  target/arm: Convert sme_helper.c to fpst alias
  target/arm: Convert sve_helper.c to fpst alias
  target/arm: Convert neon_helper.c to fpst alias
  target/arm: Convert vec_helper.c to fpst alias
  target/arm: Convert helper-a64.c to fpst alias
  target/arm: Convert vfp_helper.c to fpst alias
  target/arm: remove redundant code

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5 months agoqga: Don't access global variable in run_agent_once()
Michal Privoznik [Thu, 5 Dec 2024 16:18:45 +0000 (17:18 +0100)] 
qga: Don't access global variable in run_agent_once()

The run_agent_once() function is already given GAState via an
argument. There's no need to access the global ga_state variable
which points to the argument anyways (thanks to
initialize_agent()). Worse, some parts of the function use the
argument and the other use the global variable.  Stick with the
function argument.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Link: https://lore.kernel.org/r/8ae7f5d5032b14a5b956fe8aaf47bae5ca401699.1733414906.git.mprivozn@redhat.com
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
5 months agoqemu-ga-win: Fix a typo error
Dehan Meng [Tue, 10 Dec 2024 05:46:16 +0000 (13:46 +0800)] 
qemu-ga-win: Fix a typo error

There is a typo error for api 'guest-get-osinfo',
the win2025's version in WIN_10_0_SERVER_VERSION_MATRIX
should be adjusted.

Signed-off-by: Dehan Meng <demeng@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Link: https://lore.kernel.org/r/20241210054616.260386-1-demeng@redhat.com
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
5 months agoqga: skip bind mounts in fs list
Jean-Louis Dupond [Wed, 2 Oct 2024 10:06:35 +0000 (12:06 +0200)] 
qga: skip bind mounts in fs list

The filesystem list in build_fs_mount_list should skip bind mounts.
This because we end up in locking situations when doing fsFreeze. Like
mentioned in [1] and [2].

Next to that, the build_fs_mount_list call did a fallback via
build_fs_mount_list_from_mtab if mountinfo did not exist.
There it skipped bind mounts, but this is broken for newer OS.
This as mounts does not return the path of the bind mount but the
underlying dev/partition, so S_ISDIR will never return true in
dev_major_minor call.

This patch simply checks the existing devmajor:devminor tuple in the
mounts, and if it already exists, this means we have the same devices
mounted again, a bind mount. So skip this.

Same approach is used in open-vm-tools [3].

[1]: https://gitlab.com/qemu-project/qemu/-/issues/592
[2]: https://gitlab.com/qemu-project/qemu/-/issues/520
[3]: https://github.com/vmware/open-vm-tools/commit/d58847b497e212737007958c945af1df22a8ab58

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Link: https://lore.kernel.org/r/20241002100634.162499-2-jean-louis@dupond.be
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
5 months agomeson.build: Disallow libnfs v6 to fix the broken macOS build
Thomas Huth [Wed, 18 Dec 2024 06:21:59 +0000 (07:21 +0100)] 
meson.build: Disallow libnfs v6 to fix the broken macOS build

The macOS builds in our CI (and possibly other very recent distros)
are currently broken since the update to libnfs version 6 there.
That version apparently comes with a big API breakage. v5.0.3 was
the final release of the old API (see the libnfs commit here:
https://github.com/sahlberg/libnfs/commit/4379837 ).

Disallow version 6.x for now to get the broken CI job working
again. Once somebody had enough time to adapt our code in
block/nfs.c, we can revert this change again.

Message-ID: <20241218065157.209020-1-thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: Convert the hotplug_cpu avocado test
Thomas Huth [Tue, 17 Dec 2024 13:52:45 +0000 (14:52 +0100)] 
tests/functional: Convert the hotplug_cpu avocado test

Since we don't have ssh support in the functional test framework yet,
simply use the serial console for this test instead. It's also
sufficient to only boot into an initrd here, no need to fire up a
full-blown guest, so the test now finishes much faster.

While we're at it, also unplug the CPU now and check that it is gone
in the guest.

Message-ID: <20241217142020.155776-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: Convert the intel_iommu avocado test
Thomas Huth [Fri, 6 Dec 2024 18:02:24 +0000 (19:02 +0100)] 
tests/functional: Convert the intel_iommu avocado test

Convert the intel_iommu test to the new functional framework.
This test needs some changes since we neither support the old 'LinuxTest'
class in the functional framework yet, nor a way to use SSH for running
commands in the guest. So we now directly download a Fedora kernel and
initrd and set up the serial console for executing the commands and for
looking for the results. Instead of configuring the cloud image via
cloud-init, we now simply mount the file system manually from an initrd
rescue shell.

While the old test was exercising the network with a "dnf install"
command (which is not the best option for the CI since this depends
on third party servers), the new code is now setting up a little
HTTP server in the guest and transfers a file from the guest to the
host instead.

The test should now run much faster and more reliable (since we
don't depend on the third party servers for "dnf install" anymore),
so we can also drop the @skipUnless decorator now.

Message-ID: <20241217121550.141072-3-thuth@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: Add a helper function for retrieving the hostfwd port
Thomas Huth [Fri, 13 Dec 2024 16:02:59 +0000 (17:02 +0100)] 
tests/functional: Add a helper function for retrieving the hostfwd port

It's just a wrapper around get_info_usernet_hostfwd_port from the
qemu module that is also calling the right monitor command for
retrieving the information from QEMU.

Message-ID: <20241217121550.141072-2-thuth@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: Convert the arm virt avocado test
Thomas Huth [Thu, 5 Dec 2024 16:28:07 +0000 (17:28 +0100)] 
tests/functional: Convert the arm virt avocado test

Straight forward conversion, basically just the hashsums needed
to be updated to sha256 now.

Message-ID: <20241206102358.1186644-7-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: Convert the quanta-gsj avocado test
Thomas Huth [Wed, 4 Dec 2024 14:21:36 +0000 (15:21 +0100)] 
tests/functional: Convert the quanta-gsj avocado test

Straight forward conversion, basically just the hashsums needed
to be updated to sha256 now.

Message-ID: <20241206102358.1186644-6-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agoMAINTAINERS: add myself as reviewer for functional test suite
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:53 +0000 (15:59 +0000)] 
MAINTAINERS: add myself as reviewer for functional test suite

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-33-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: ignore errors when caching assets, except for 404
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:52 +0000 (15:59 +0000)] 
tests/functional: ignore errors when caching assets, except for 404

We see periodic errors caching assets due to a combination of transient
networking and server problems. With the previous patch to skip running
a test when it has missing assets, we can now treat most cache download
errors as non-fatal.

Only HTTP 404 is retained as fatal, since it is a strong indicator of
a fully broken test rather than a transient error.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-32-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: skip tests if assets are not available
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:51 +0000 (15:59 +0000)] 
tests/functional: skip tests if assets are not available

If downloading of assets has been disabled, then skip running a
test if the assets it has registered are not already downloaded.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-31-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: remove now unused 'run_cmd' helper
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:50 +0000 (15:59 +0000)] 
tests/functional: remove now unused 'run_cmd' helper

All usage has been replaced by direct 'subprocess' helpers.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-30-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: replace 'run_cmd' with subprocess helpers
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:49 +0000 (15:59 +0000)] 
tests/functional: replace 'run_cmd' with subprocess helpers

The 'run_cmd' helper is re-implementing a convenient helper that
already exists in the form of the 'run' and 'check_call' methods
provided by 'subprocess'.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-29-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: drop back compat imports from utils.py
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:48 +0000 (15:59 +0000)] 
tests/functional: drop back compat imports from utils.py

Now that all tests are converted over to the higher level wrapper
functions, the back compat imports from utils.py are redundant.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-28-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: convert tests to new uncompress helper
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:47 +0000 (15:59 +0000)] 
tests/functional: convert tests to new uncompress helper

Replace use of lzma_uncompress and gzip_uncompress with the
new uncompress helper.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-27-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add 'uncompress' to QemuBaseTest
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:46 +0000 (15:59 +0000)] 
tests/functional: add 'uncompress' to QemuBaseTest

This helper wrappers utils.uncompress, forcing the use of the scratch
directory, to ensure any uncompressed files are cleaned at test
termination.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-26-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add a generalized uncompress helper
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:45 +0000 (15:59 +0000)] 
tests/functional: add a generalized uncompress helper

There are many types of compression that the tests deal with, and
it makes sense to have a single helper 'uncompress' that can deal
with all.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-25-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: convert tests to new archive_extract helper
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:44 +0000 (15:59 +0000)] 
tests/functional: convert tests to new archive_extract helper

Replace use of utils.archive_extract and extract_from_deb with the
new archive_extract helper.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-24-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add 'archive_extract' to QemuBaseTest
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:43 +0000 (15:59 +0000)] 
tests/functional: add 'archive_extract' to QemuBaseTest

This helper wrappers archive.archive_extract, forcing the use of the
scratch directory, to ensure any extracted files are cleaned at test
termination. If a specific member is requested, then the path to the
extracted file is also returned.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-23-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add a generalized archive_extract
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:42 +0000 (15:59 +0000)] 
tests/functional: add a generalized archive_extract

There are many types of archives that the tests deal with. Provide
a generalized 'archive_extract' that can detect the format and
delegate to the appropriate helper for extraction. This ensures
that all archive extraction code follows the same design pattern.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-22-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: let cpio_extract accept filenames
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:41 +0000 (15:59 +0000)] 
tests/functional: let cpio_extract accept filenames

Currently cpio_extract differs from tar_extract/zip_extract
in that it only allows a file-like object as input. Adapt it
to also support filenames.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-21-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add common deb_extract helper
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:40 +0000 (15:59 +0000)] 
tests/functional: add common deb_extract helper

This mirrors the existing archive_extract, cpio_extract and zip_extract
helpers

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-20-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add common zip_extract helper
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:39 +0000 (15:59 +0000)] 
tests/functional: add common zip_extract helper

This mirrors the existing archive_extract and cpio_extract helpers

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-19-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: move uncompress handling into new uncompress.py file
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:38 +0000 (15:59 +0000)] 
tests/functional: move uncompress handling into new uncompress.py file

More uncompress related code will be added shortly, so having a
separate file makes more sense.

The utils.py imports the functions from archive.py, so that
existing callers don't need to be modified. This avoids
redundant code churn until later in the series when all
calls will be adapted for other reasons.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-18-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: move archive handling into new archive.py file
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:37 +0000 (15:59 +0000)] 
tests/functional: move archive handling into new archive.py file

More archive related code will be added shortly, so having a
separate file makes more sense.

The utils.py imports the functions from archive.py, so that
existing callers don't need to be modified. This avoids
redundant code churn until later in the series when all
calls will be adapted for other reasons.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-17-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: remove redundant 'rmtree' call
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:36 +0000 (15:59 +0000)] 
tests/functional: remove redundant 'rmtree' call

Everything in the scratch directory is automatically purged. Calling
'rmtree' again breaks the ability to optionally preserve the scratch
directory contents.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-16-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: switch over to using self.scratch_file()
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:35 +0000 (15:59 +0000)] 
tests/functional: switch over to using self.scratch_file()

Replace any instances of

  os.path.join(self.workdir, ".../...")
  self.workdir + "/.../..."

with

  self.scratch_file("...", "...")

which is more compact and portable

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-15-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: switch over to using self.data_file(...)
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:34 +0000 (15:59 +0000)] 
tests/functional: switch over to using self.data_file(...)

This removes direct path manipulation to figure out the source dir

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-14-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: switch over to using self.build_file(...)
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:33 +0000 (15:59 +0000)] 
tests/functional: switch over to using self.build_file(...)

This removes direct access of the 'BUILD_DIR' variable.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-13-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: switch over to using self.log_file(...)
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:32 +0000 (15:59 +0000)] 
tests/functional: switch over to using self.log_file(...)

This removes direct access of the 'self.logdir' variable.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-12-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: add helpers for building file paths
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:31 +0000 (15:59 +0000)] 
tests/functional: add helpers for building file paths

Add helper methods that construct paths for

 * log files - to be preserved at the end of a test
 * scratch files - to be purged at the end of a test
 * build files - anything relative to the build root
 * data files - anything relative to the functional test source root
 * socket files - a short temporary dir to avoid UNIX socket limits

These are to be used instead of direct access to the self.workdir,
or self.logdir variables, or any other place where paths are built
manually.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-11-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: drop 'has_cmd' and 'has_cmds' helpers
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:30 +0000 (15:59 +0000)] 
tests/functional: drop 'has_cmd' and 'has_cmds' helpers

The 'which' helper is simpler, not depending on the external 'which'
binary, and is sufficient for test needs.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-10-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: switch to new test skip decorators
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:29 +0000 (15:59 +0000)] 
tests/functional: switch to new test skip decorators

This ensures consistency of behaviour across all the tests, and requires
that we provide gitlab bug links when marking a test to be skipped due
to unreliability.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-9-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 months agotests/functional: introduce some helpful decorators
Daniel P. Berrangé [Tue, 17 Dec 2024 15:59:28 +0000 (15:59 +0000)] 
tests/functional: introduce some helpful decorators

Reduce repeated boilerplate with some helper decorators:

 @skipIfNotPlatform("x86_64", "aarch64")

  => Skip unless the build host platform matches

 @skipIfMissingCommands("mkisofs", "losetup")

  => Skips unless all listed commands are found in $PATH

 @skipIfMissingImports("numpy", "cv2")

  => Skips unless all listed modules can be imported

 @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/NNN")

  => Skips unless env var requests flaky tests with the
     reason documented in the referenced gitlab bug

 @skipBigData

  => Skips unless env var permits tests creating big data files

 @skipUntrustedTest

  => Skips unless env var permits tests which are potentially
     dangerous to the host

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-8-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>