| ac561a30 | 21-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: allow nested offset_of
Nested offset_of was stabilized in Rust 1.82. Since the minimum supported version for QEMU is 1.83, allow nested field accesses in vmstate_of!
Signed-off-by
rust: migration: allow nested offset_of
Nested offset_of was stabilized in Rust 1.82. Since the minimum supported version for QEMU is 1.83, allow nested field accesses in vmstate_of!
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 02d6b8cf | 03-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: do not add qemuutil to Rust crates
This fails due to https://github.com/mesonbuild/meson/pull/15076. The config-host.h file from the qemuutil dependency ends up on the rustc command line for t
rust: do not add qemuutil to Rust crates
This fails due to https://github.com/mesonbuild/meson/pull/15076. The config-host.h file from the qemuutil dependency ends up on the rustc command line for targets that do not use structured sources.
It will be reverted once Meson 1.9.2 is released.
Reported-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 8abea41e | 07-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pull error_fatal out of SysbusDeviceMethods::sysbus_realize
Return a Result<()> from the method, and "unwrap" it into error_fatal in the caller.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Si
rust: pull error_fatal out of SysbusDeviceMethods::sysbus_realize
Return a Result<()> from the method, and "unwrap" it into error_fatal in the caller.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 113a7f5b | 19-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust/util: replace Error::err_or_unit/err_or_else with Error::with_errp
Introduce a simpler function that hides the creation of the Error**.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-b
rust/util: replace Error::err_or_unit/err_or_else with Error::with_errp
Introduce a simpler function that hides the creation of the Error**.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 0830ec94 | 10-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust/util: use anyhow's native chaining capabilities
This simplifies conversions, making it possible to convert any error into a QEMU util::Error with ".into()" (and therefore with "?").
The cost i
rust/util: use anyhow's native chaining capabilities
This simplifies conversions, making it possible to convert any error into a QEMU util::Error with ".into()" (and therefore with "?").
The cost is having a separate constructor for when the error is a simple string, but that is made easier by the ensure! macro. If necessary, another macro similar to "anyhow!" can be returned, but for now there is no need for that.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 56dbf087 | 10-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust/util: add ensure macro
The macro is similar to anyhow::ensure but uses QEMU's variation on anyhow::Error. It can be used to easily check a condition and format an error message.
Reviewed-by:
rust/util: add ensure macro
The macro is similar to anyhow::ensure but uses QEMU's variation on anyhow::Error. It can be used to easily check a condition and format an error message.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| d4fbf6ff | 28-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: allow passing ParentField<> to vmstate_of!
The common superclass for devices could have its own migration state; for it to be included in the subclass's VMState, ParentField<> must
rust: migration: allow passing ParentField<> to vmstate_of!
The common superclass for devices could have its own migration state; for it to be included in the subclass's VMState, ParentField<> must implement the VMState trait.
Reported-by: Chen Miao <chenmiao@openatom.club> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 59d8f864 | 23-Oct-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust/qemu-macros: Convert bit value to u8 within #[property]
For bit property, make the type conversion within the #[property] macro so that users do not need to handle the conversion.
Suggested-by
rust/qemu-macros: Convert bit value to u8 within #[property]
For bit property, make the type conversion within the #[property] macro so that users do not need to handle the conversion.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20251024041344.1389488-1-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 1b21518f | 22-Oct-2025 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
char: rename CharBackend->CharFrontend
The actual backend is "Chardev", CharBackend is the frontend side of it (whatever talks to the backend), let's rename it for readability.
Signed-off-by: Marc-
char: rename CharBackend->CharFrontend
The actual backend is "Chardev", CharBackend is the frontend side of it (whatever talks to the backend), let's rename it for readability.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20251022074612.1258413-1-marcandre.lureau@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 025a1d34 | 17-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: only leave leaf crates as workspace members
Everything else can be obtained as a dependency.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
| 80a3c9c0 | 16-Oct-2025 |
Martin Kletzander <mkletzan@redhat.com> |
rust: remove useless glib_sys bindings
The definition of types needed for g_autolist(), g_autoslist(), g_autoqueue() need the imports for GList, GSList and GQueue to appear everything. Rust code is
rust: remove useless glib_sys bindings
The definition of types needed for g_autolist(), g_autoslist(), g_autoqueue() need the imports for GList, GSList and GQueue to appear everything. Rust code is never going to see those, since they are not used in structs. Block the types from appearing in the bindings.
Co-authored-by: Martin Kletzander <mkletzan@redhat.com> Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 7ee5875d | 19-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: implement ToMigrationState as part of impl_vmstate_bitsized
This is most likely desirable, and is the easiest way to migrate a bit-sized value without peeking at the innards of the
rust: migration: implement ToMigrationState as part of impl_vmstate_bitsized
This is most likely desirable, and is the easiest way to migrate a bit-sized value without peeking at the innards of the bilge crate.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 29cf500e | 09-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qemu-macros: add ToMigrationState derive macro
Add a macro that recursively builds the "migrated" version of a struct.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini
rust: qemu-macros: add ToMigrationState derive macro
Add a macro that recursively builds the "migrated" version of a struct.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 44a9d1b8 | 15-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: add high-level migration wrappers
Instead of dealing with pre/post callbacks, allow devices to implement a snapshot/restore mechanism; this has two main advantages:
- it can be eas
rust: migration: add high-level migration wrappers
Instead of dealing with pre/post callbacks, allow devices to implement a snapshot/restore mechanism; this has two main advantages:
- it can be easily implemented via procedural macros
- there can be generic implementations to deal with various kinds of interior-mutable containers, from BqlRefCell to Mutex, so that C code does not see Rust concepts such as Mutex<>.
Using it is easy; you can implement the snapshot/restore trait ToMigrationState and declare your state like:
regs: Migratable<Mutex<MyDeviceRegisters>>
Migratable<> allows dereferencing to the underlying object with no run-time cost.
Note that Migratable<> actually does not accept ToMigrationState, only the similar ToMigrationStateShared trait that the user will mostly not care about. This is required by the fact that pre/post callbacks take a &self, and ensures that the argument is a Mutex or BqlRefCell (including an array or Arc<> thereof).
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 4526418a | 09-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: move VMState from bql to migration
The high-level wrapper Migratable<T> will contain a BqlCell, which would introduce a circular dependency betwen the bql and migration crates. Move the imple
rust: move VMState from bql to migration
The high-level wrapper Migratable<T> will contain a BqlCell, which would introduce a circular dependency betwen the bql and migration crates. Move the implementation of VMState for cells to "migration", together with the implementation for std types.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 8999ca00 | 17-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: extract vmstate_fields_ref
This is useful when building a VMState for generic structs, because you have to avoid nested statics. Using vmstate_fields! will fail in the likely case
rust: migration: extract vmstate_fields_ref
This is useful when building a VMState for generic structs, because you have to avoid nested statics. Using vmstate_fields! will fail in the likely case where the _FIELDS static uses Self from an outer item, because that is forbidden.
The separate macros are needed because you cannot just do
.fields(vmstate_fields_ref! { vmstate_of!(PL011State, clock), })
The value returned by vmstate_fields_ref! is not promoted to static, which is unfortunate but intentional (https://github.com/rust-lang/rust/issues/60502):
error[E0716]: temporary value dropped while borrowed --> rust/hw/char/pl011/libpl011.rlib.p/structured/device.rs:743:17 | 738 | / VMStateDescriptionBuilder::<PL011State>::new() 739 | | .name(c"pl011/clock") 740 | | .version_id(1) 741 | | .minimum_version_id(1) 742 | | .needed(&PL011State::clock_needed) 743 | | .fields(vmstate_fields_ref! { | | _________________^ 744 | || vmstate_of!(PL011State, clock), 745 | || }) | ||_________^- argument requires that borrow lasts for `'static` | |_________| | creates a temporary value which is freed while still in use 746 | .build(); | - temporary value is freed at the end of this statement
Thus it is necessary to use the "static", whether explicitly or hidden by vmstate_fields.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 5b4fa978 | 25-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: validate termination of subsection arrays
For consistency with fields(), validate the value (at least to some extent) before passing it to C.
Reviewed-by: Zhao Liu <zhao1.liu@intel
rust: migration: validate termination of subsection arrays
For consistency with fields(), validate the value (at least to some extent) before passing it to C.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 64bce66d | 25-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: do not store raw pointers into VMStateSubsectionsWrapper
Raw pointers were used to insert a NULL one at the end of the array. However, Option<&...> has the same layout and does not
rust: migration: do not store raw pointers into VMStateSubsectionsWrapper
Raw pointers were used to insert a NULL one at the end of the array. However, Option<&...> has the same layout and does not remove Sync from the type of the array.
As an extra benefit, this enables validation of the terminator of the subsection array, because is_null() in const context would not be stable until Rust 1.84.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 5c776a76 | 25-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: do not pass raw pointer to VMStateDescription::fields
Pass a slice instead; a function that accepts a raw pointer should arguably be declared as unsafe.
But since it is now much ea
rust: migration: do not pass raw pointer to VMStateDescription::fields
Pass a slice instead; a function that accepts a raw pointer should arguably be declared as unsafe.
But since it is now much easier to forget vmstate_fields!, validate the value (at least to some extent) before passing it to C. (Unfortunately, doing the same for subsections would require const ptr::is_null(), which is only stable in Rust 1.84).
Suggested-by: Zhao Liu <zhao1.liu@intel.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 818231bc | 17-Sep-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: bql: add BqlRefCell::get_mut()
This method is rarely useful in QEMU due to the pervasiveness of shared references, but add it for when a &mut BqlRefCell<> is used.
Signed-off-by: Paolo Bonzin
rust: bql: add BqlRefCell::get_mut()
This method is rarely useful in QEMU due to the pervasiveness of shared references, but add it for when a &mut BqlRefCell<> is used.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 414ac7e0 | 13-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: hpet: fix fw_cfg handling
HPET ids for fw_cfg are not assigned correctly, because there is a read but no write. This is caught by nightly Rust as an unused-assignments warning, so fix it.
Re
rust: hpet: fix fw_cfg handling
HPET ids for fw_cfg are not assigned correctly, because there is a read but no write. This is caught by nightly Rust as an unused-assignments warning, so fix it.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| ceda1563 | 13-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: migration: hide more warnings from call_func_with_field!
The call_func_with_field! macro uses dead code willingly to infer the appropriate type. This has started adding a new warning:
error:
rust: migration: hide more warnings from call_func_with_field!
The call_func_with_field! macro uses dead code willingly to infer the appropriate type. This has started adding a new warning:
error: unused variable: `value__` 79 | break phantom__(&{ let value__: $typ; value__.$($field).+ })
So shut it up together with the existing unreachable_code warning.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 194dfadd | 10-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: bits: disable double_parens check
It is showing in the output of the bits! macro when using the nightly toolchain, though it's not clear if it is intentional or a bug. Shut it up for now.
Lin
rust: bits: disable double_parens check
It is showing in the output of the bits! macro when using the nightly toolchain, though it's not clear if it is intentional or a bug. Shut it up for now.
Link: https://github.com/rust-lang/rust-clippy/issues/15852 Reported-by: Richard Henderson <richard.henderson@linaro.org> Suggested-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Link: https://lore.kernel.org/r/20251010145756.787800-1-pbonzini@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 18beee5c | 09-Oct-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: fix warning with new clippy
Newer versions of clippy are able to see that all the variants in the PL011 word length enum end with "Bits", and complain about it. Allow it.
Reported-by:
rust: pl011: fix warning with new clippy
Newer versions of clippy are able to see that all the variants in the PL011 word length enum end with "Bits", and complain about it. Allow it.
Reported-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
| 9c40c1ff | 24-Sep-2025 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
rust: use glib-sys
Don't generate FFI for glib, rely on glib-sys crate.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |