3212da00 | 12-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: add SysBusDeviceImpl
The only function, right now, is to ensure that anything with a SysBusDeviceClass class is a SysBusDevice.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paol
rust: add SysBusDeviceImpl
The only function, right now, is to ensure that anything with a SysBusDeviceClass class is a SysBusDevice.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
ac5699c5 | 12-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: add IsA bounds to QOM implementation traits
Check that the right bounds are provided to the qom_isa! macro whenever the class is defined to implement a certain class. This removes the need to
rust: add IsA bounds to QOM implementation traits
Check that the right bounds are provided to the qom_isa! macro whenever the class is defined to implement a certain class. This removes the need to add IsA<> bounds together with the *Impl trait bounds.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
c48700e8 | 18-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust: prefer importing std::ptr over core::ptr
The std::ptr is same as core::ptr, but std has already been used in many cases and there's no need to choose non-std library.
So, use std::ptr directl
rust: prefer importing std::ptr over core::ptr
The std::ptr is same as core::ptr, but std has already been used in many cases and there's no need to choose non-std library.
So, use std::ptr directly to make the used ptr library as consistent as possible.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250218080835.3341082-1-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
8a420dd1 | 14-Nov-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: add module to convert between success/-errno and io::Result
It is a common convention in QEMU to return a positive value in case of success, and a negated errno value in case of error. Unfort
rust: add module to convert between success/-errno and io::Result
It is a common convention in QEMU to return a positive value in case of success, and a negated errno value in case of error. Unfortunately, using errno portably in Rust is a bit complicated; on Unix the errno values are supported natively by io::Error, but on Windows they are not; so, use the libc crate.
This is a set of utility functions that are used by both chardev and block layer bindings.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
16534af5 | 11-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: fix doctests
Doctests were not being run by CI, and have broken. Fix them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
ee7d3aec | 30-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: vmstate: remove redundant link targets
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
ebacd14a | 30-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qemu_api: add a documentation header for all modules
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
0534248a | 10-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust/timer/hpet: define hpet_fw_cfg
Define HPETFwEntry structure with the same memory layout as hpet_fw_entry in C.
Further, define the global hpet_cfg variable in Rust which is the same as the C v
rust/timer/hpet: define hpet_fw_cfg
Define HPETFwEntry structure with the same memory layout as hpet_fw_entry in C.
Further, define the global hpet_cfg variable in Rust which is the same as the C version. This hpet_cfg variable in Rust will replace the C version one and allows both Rust code and C code to access it.
The Rust version of hpet_cfg is self-contained, avoiding unsafe access to C code.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-8-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
eadb83f9 | 10-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust: add bindings for timer
Add timer bindings to help handle idiomatic Rust callbacks.
Additionally, wrap QEMUClockType in ClockType binding to avoid unsafe calls in device code.
Signed-off-by:
rust: add bindings for timer
Add timer bindings to help handle idiomatic Rust callbacks.
Additionally, wrap QEMUClockType in ClockType binding to avoid unsafe calls in device code.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-7-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
d015d4cb | 25-Jan-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust: add bindings for memattrs
The MemTxAttrs structure contains bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED.
Therefore, manually
rust: add bindings for memattrs
The MemTxAttrs structure contains bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED.
Therefore, manually define a global constant variable MEMTXATTRS_UNSPECIFIED to support calls from Rust code.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250125125137.1223277-6-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
9a96d410 | 10-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust: add bindings for gpio_{in|out} initialization
Wrap qdev_init_gpio_{in|out} as methods in DeviceMethods. And for qdev_init_gpio_in, based on FnCall, it can support idiomatic Rust callback witho
rust: add bindings for gpio_{in|out} initialization
Wrap qdev_init_gpio_{in|out} as methods in DeviceMethods. And for qdev_init_gpio_in, based on FnCall, it can support idiomatic Rust callback without the need for C style wrapper.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-5-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
e6f1195f | 10-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust/irq: Add a helper to convert [InterruptSource] to pointer
This is useful when taking an InterruptSource slice and passing it to C function.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Si
rust/irq: Add a helper to convert [InterruptSource] to pointer
This is useful when taking an InterruptSource slice and passing it to C function.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-4-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
7f2d4181 | 10-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust/qdev: add the macro to define bit property
HPET device (Rust device) needs to define the bit type property.
Add a variant of define_property macro to define bit type property.
Signed-off-by:
rust/qdev: add the macro to define bit property
HPET device (Rust device) needs to define the bit type property.
Add a variant of define_property macro to define bit type property.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-3-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
7630ca2a | 10-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: convert pl011_create to safe Rust
Not a major change but, as a small but significant step in creating qdev bindings, show how pl011_create can be written without "unsafe" calls (apart f
rust: pl011: convert pl011_create to safe Rust
Not a major change but, as a small but significant step in creating qdev bindings, show how pl011_create can be written without "unsafe" calls (apart from converting pointers to references).
This also provides a starting point for creating Error** bindings.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
a22bd55f | 03-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: chardev, qdev: add bindings to qdev_prop_set_chr
Because the argument to the function is an Owned<Chardev>, this also adds an ObjectType implementation to Chardev.
Reviewed-by: Zhao Liu <zhao
rust: chardev, qdev: add bindings to qdev_prop_set_chr
Because the argument to the function is an Owned<Chardev>, this also adds an ObjectType implementation to Chardev.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
61faf6ac | 03-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: irq: define ObjectType for IRQState
This is a small preparation in order to use an Owned<IRQState> for the argument to sysbus_connect_irq.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
590faa03 | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: bindings for MemoryRegionOps
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
d449d29a | 13-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: bindings: add Send and Sync markers for types that have bindings
This is needed for the MemoryRegionOps<T> to be declared as static; Rust requires static elements to be Sync.
Reviewed-by: Zha
rust: bindings: add Send and Sync markers for types that have bindings
This is needed for the MemoryRegionOps<T> to be declared as static; Rust requires static elements to be Sync.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
5472a38c | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qdev: switch from legacy reset to Resettable
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
68da5402 | 07-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qdev: make ObjectImpl a supertrait of DeviceImpl
In practice it has to be implemented always in order to access an implementation of ClassInitImpl<ObjectClass>. Make the relationship explicit
rust: qdev: make ObjectImpl a supertrait of DeviceImpl
In practice it has to be implemented always in order to access an implementation of ClassInitImpl<ObjectClass>. Make the relationship explicit in the code.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
688c6741 | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qom: allow initializing interface vtables
Unlike regular classes, interface vtables can only be obtained via object_class_dynamic_cast. Provide a wrapper that allows accessing the vtable and
rust: qom: allow initializing interface vtables
Unlike regular classes, interface vtables can only be obtained via object_class_dynamic_cast. Provide a wrapper that allows accessing the vtable and pass it to a ClassInitImpl implementation, for example ClassInitImpl<ResettableClass>.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
201ef001 | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qdev: add clock creation
Add a Rust version of qdev_init_clock_in, which can be used in instance_init. There are a couple differences with the C version:
- in Rust the object keeps its own r
rust: qdev: add clock creation
Add a Rust version of qdev_init_clock_in, which can be used in instance_init. There are a couple differences with the C version:
- in Rust the object keeps its own reference to the clock (in addition to the one embedded in the NamedClockList), and the reference is dropped automatically by instance_finalize(); this is encoded in the signature of DeviceClassMethods::init_clock_in, which makes the lifetime of the clock independent of that of the object it holds. This goes unnoticed in the C version and is due to the existence of aliases.
- also, anything that happens during instance_init uses the pinned_init framework to operate on a partially initialized object, and is done through class methods (i.e. through DeviceClassMethods rather than DeviceMethods) because the device does not exist yet. Therefore, Rust code *must* create clocks from instance_init, which is stricter than C.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
66bcc554 | 06-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: callbacks: allow passing optional callbacks as ()
In some cases, callbacks are optional. Using "Some(function)" and "None" does not work well, because when someone writes "None" the compiler
rust: callbacks: allow passing optional callbacks as ()
In some cases, callbacks are optional. Using "Some(function)" and "None" does not work well, because when someone writes "None" the compiler does not know what to use for "F" in "Option<F>".
Therefore, adopt () to mean a "null" callback. It is possible to enforce that a callback is valid by adding a "let _: () = F::ASSERT_IS_SOME" before the invocation of F::call.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
ec3eba98 | 31-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qom: add object creation functionality
The basic object lifecycle test can now be implemented using safe code!
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzi
rust: qom: add object creation functionality
The basic object lifecycle test can now be implemented using safe code!
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
0fcccf3f | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qom: add reference counting functionality
Add a smart pointer that allows to add and remove references from QOM objects. It's important to note that while all QOM objects have a reference cou
rust: qom: add reference counting functionality
Add a smart pointer that allows to add and remove references from QOM objects. It's important to note that while all QOM objects have a reference count, in practice not all of them have their lifetime guarded by it. Embedded objects, specifically, are confined to the lifetime of the owner.
When writing Rust bindings this is important, because embedded objects are *never* used through the "Owned<>" smart pointer that is introduced here.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|