mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
rust: split "qom" crate
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250827104147.717203-13-marcandre.lureau@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
f6b4f0dd9c
commit
fcf4c00b4d
@@ -3520,6 +3520,7 @@ F: rust/common/
|
||||
F: rust/migration/
|
||||
F: rust/qemu-api
|
||||
F: rust/qemu-api-macros
|
||||
F: rust/qom/
|
||||
F: rust/rustfmt.toml
|
||||
F: rust/util/
|
||||
F: scripts/get-wraps-from-cargo-registry.py
|
||||
|
||||
Generated
+14
@@ -82,6 +82,7 @@ dependencies = [
|
||||
"migration",
|
||||
"qemu_api",
|
||||
"qemu_api_macros",
|
||||
"qom",
|
||||
"util",
|
||||
]
|
||||
|
||||
@@ -121,6 +122,7 @@ dependencies = [
|
||||
"migration",
|
||||
"qemu_api",
|
||||
"qemu_api_macros",
|
||||
"qom",
|
||||
"util",
|
||||
]
|
||||
|
||||
@@ -164,6 +166,7 @@ dependencies = [
|
||||
"common",
|
||||
"migration",
|
||||
"qemu_api_macros",
|
||||
"qom",
|
||||
"util",
|
||||
]
|
||||
|
||||
@@ -176,6 +179,17 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "qom"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bql",
|
||||
"common",
|
||||
"migration",
|
||||
"qemu_api_macros",
|
||||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
|
||||
@@ -7,6 +7,7 @@ members = [
|
||||
"migration",
|
||||
"qemu-api-macros",
|
||||
"qemu-api",
|
||||
"qom",
|
||||
"hw/char/pl011",
|
||||
"hw/timer/hpet",
|
||||
"util",
|
||||
|
||||
@@ -20,6 +20,7 @@ common = { path = "../../../common" }
|
||||
util = { path = "../../../util" }
|
||||
bql = { path = "../../../bql" }
|
||||
migration = { path = "../../../migration" }
|
||||
qom = { path = "../../../qom" }
|
||||
qemu_api = { path = "../../../qemu-api" }
|
||||
qemu_api_macros = { path = "../../../qemu-api-macros" }
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ _libpl011_rs = static_library(
|
||||
migration_rs,
|
||||
bql_rs,
|
||||
qemu_api_macros,
|
||||
qom_rs,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ use qemu_api::{
|
||||
memory::{hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder},
|
||||
prelude::*,
|
||||
qdev::{Clock, ClockEvent, DeviceImpl, DeviceState, ResetType, ResettablePhasesImpl},
|
||||
qom::{ObjectImpl, Owned, ParentField, ParentInit},
|
||||
sysbus::{SysBusDevice, SysBusDeviceImpl},
|
||||
};
|
||||
use qom::{prelude::*, ObjectImpl, Owned, ParentField, ParentInit};
|
||||
use util::{log::Log, log_mask_ln};
|
||||
|
||||
use crate::registers::{self, Interrupt, RegisterOffset};
|
||||
|
||||
@@ -15,6 +15,7 @@ common = { path = "../../../common" }
|
||||
util = { path = "../../../util" }
|
||||
migration = { path = "../../../migration" }
|
||||
bql = { path = "../../../bql" }
|
||||
qom = { path = "../../../qom" }
|
||||
qemu_api = { path = "../../../qemu-api" }
|
||||
qemu_api_macros = { path = "../../../qemu-api-macros" }
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ _libhpet_rs = static_library(
|
||||
migration_rs,
|
||||
bql_rs,
|
||||
qemu_api_macros,
|
||||
qom_rs,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -27,10 +27,9 @@ use qemu_api::{
|
||||
},
|
||||
prelude::*,
|
||||
qdev::{DeviceImpl, DeviceState, Property, ResetType, ResettablePhasesImpl},
|
||||
qom::{ObjectImpl, ObjectType, ParentField, ParentInit},
|
||||
qom_isa,
|
||||
sysbus::{SysBusDevice, SysBusDeviceImpl},
|
||||
};
|
||||
use qom::{prelude::*, ObjectImpl, ParentField, ParentInit};
|
||||
use util::timer::{Timer, CLOCK_VIRTUAL, NANOSECONDS_PER_SECOND};
|
||||
|
||||
use crate::fw_cfg::HPETFwConfig;
|
||||
|
||||
@@ -28,6 +28,7 @@ subdir('bits')
|
||||
subdir('util')
|
||||
subdir('migration')
|
||||
subdir('bql')
|
||||
subdir('qom')
|
||||
subdir('qemu-api')
|
||||
|
||||
subdir('hw')
|
||||
|
||||
@@ -137,7 +137,7 @@ pub const fn vmstate_varray_flag<T: VMState>(_: PhantomData<T>) -> VMStateFlags
|
||||
///
|
||||
/// [`BqlCell`]: ../../bql/cell/struct.BqlCell.html
|
||||
/// [`BqlRefCell`]: ../../bql/cell/struct.BqlRefCell.html
|
||||
/// [`Owned`]: ../../qemu_api/qom/struct.Owned.html
|
||||
/// [`Owned`]: ../../qom/qom/struct.Owned.html
|
||||
#[macro_export]
|
||||
macro_rules! vmstate_of {
|
||||
($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:expr)?])? $(, $test_fn:expr)? $(,)?) => {
|
||||
|
||||
@@ -98,11 +98,11 @@ fn derive_object_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream
|
||||
|
||||
Ok(quote! {
|
||||
::common::assert_field_type!(#name, #parent,
|
||||
::qemu_api::qom::ParentField<<#name as ::qemu_api::qom::ObjectImpl>::ParentType>);
|
||||
::qom::ParentField<<#name as ::qom::ObjectImpl>::ParentType>);
|
||||
|
||||
::util::module_init! {
|
||||
MODULE_INIT_QOM => unsafe {
|
||||
::qemu_api::bindings::type_register_static(&<#name as ::qemu_api::qom::ObjectImpl>::TYPE_INFO);
|
||||
::qom::type_register_static(&<#name as ::qom::ObjectImpl>::TYPE_INFO);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -168,11 +168,11 @@ fn test_derive_object() {
|
||||
::common::assert_field_type!(
|
||||
Foo,
|
||||
_unused,
|
||||
::qemu_api::qom::ParentField<<Foo as ::qemu_api::qom::ObjectImpl>::ParentType>
|
||||
::qom::ParentField<<Foo as ::qom::ObjectImpl>::ParentType>
|
||||
);
|
||||
::util::module_init! {
|
||||
MODULE_INIT_QOM => unsafe {
|
||||
::qemu_api::bindings::type_register_static(&<Foo as ::qemu_api::qom::ObjectImpl>::TYPE_INFO);
|
||||
::qom::type_register_static(&<Foo as ::qom::ObjectImpl>::TYPE_INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ common = { path = "../common" }
|
||||
migration = { path = "../migration" }
|
||||
util = { path = "../util" }
|
||||
bql = { path = "../bql" }
|
||||
qom = { path = "../qom" }
|
||||
qemu_api_macros = { path = "../qemu-api-macros" }
|
||||
|
||||
[lints]
|
||||
|
||||
@@ -22,9 +22,15 @@ foreach enum : c_bitfields
|
||||
_qemu_api_bindgen_args += ['--bitfield-enum', enum]
|
||||
endforeach
|
||||
|
||||
_qemu_api_bindgen_args += ['--blocklist-type', 'VMStateDescription']
|
||||
blocked_type = [
|
||||
'ObjectClass',
|
||||
'VMStateDescription',
|
||||
'Error',
|
||||
]
|
||||
foreach type: blocked_type
|
||||
_qemu_api_bindgen_args += ['--blocklist-type', type]
|
||||
endforeach
|
||||
|
||||
_qemu_api_bindgen_args += ['--blocklist-type', 'Error']
|
||||
# TODO: Remove this comment when the clang/libclang mismatch issue is solved.
|
||||
#
|
||||
# Rust bindings generation with `bindgen` might fail in some cases where the
|
||||
@@ -52,7 +58,6 @@ _qemu_api_rs = static_library(
|
||||
'src/memory.rs',
|
||||
'src/prelude.rs',
|
||||
'src/qdev.rs',
|
||||
'src/qom.rs',
|
||||
'src/sysbus.rs',
|
||||
],
|
||||
{'.' : _qemu_api_bindings_inc_rs},
|
||||
@@ -61,7 +66,7 @@ _qemu_api_rs = static_library(
|
||||
rust_abi: 'rust',
|
||||
rust_args: _qemu_api_cfg,
|
||||
dependencies: [anyhow_rs, bql_rs, common_rs, foreign_rs, libc_rs, migration_rs, qemu_api_macros,
|
||||
util_rs, qom, hwcore, chardev],
|
||||
qom_rs, util_rs, hwcore, chardev],
|
||||
)
|
||||
|
||||
qemu_api_rs = declare_dependency(link_with: [_qemu_api_rs],
|
||||
@@ -74,7 +79,7 @@ test('rust-qemu-api-integration',
|
||||
override_options: ['rust_std=2021', 'build.rust_std=2021'],
|
||||
rust_args: ['--test'],
|
||||
install: false,
|
||||
dependencies: [bql_rs, common_rs, util_rs, migration_rs, qemu_api_rs]),
|
||||
dependencies: [bql_rs, common_rs, util_rs, migration_rs, qom_rs, qemu_api_rs]),
|
||||
args: [
|
||||
'--test', '--test-threads', '1',
|
||||
'--format', 'pretty',
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
use common::Zeroable;
|
||||
use migration::bindings::VMStateDescription;
|
||||
use qom::bindings::ObjectClass;
|
||||
use util::bindings::Error;
|
||||
|
||||
#[cfg(MESON)]
|
||||
|
||||
@@ -20,8 +20,9 @@ use std::{
|
||||
|
||||
use bql::{BqlRefCell, BqlRefMut};
|
||||
use common::{callbacks::FnCall, errno, Opaque};
|
||||
use qom::prelude::*;
|
||||
|
||||
use crate::{bindings, prelude::*};
|
||||
use crate::bindings;
|
||||
|
||||
/// A safe wrapper around [`bindings::Chardev`].
|
||||
#[repr(transparent)]
|
||||
|
||||
@@ -12,12 +12,9 @@ use std::{
|
||||
|
||||
use bql::BqlCell;
|
||||
use common::Opaque;
|
||||
use qom::{prelude::*, ObjectClass};
|
||||
|
||||
use crate::{
|
||||
bindings::{self, qemu_set_irq},
|
||||
prelude::*,
|
||||
qom::ObjectClass,
|
||||
};
|
||||
use crate::bindings::{self, qemu_set_irq};
|
||||
|
||||
/// An opaque wrapper around [`bindings::IRQState`].
|
||||
#[repr(transparent)]
|
||||
@@ -36,7 +33,7 @@ pub struct IRQState(Opaque<bindings::IRQState>);
|
||||
///
|
||||
/// Interrupts are implemented as a pointer to the interrupt "sink", which has
|
||||
/// type [`IRQState`]. A device exposes its source as a QOM link property using
|
||||
/// a function such as [`SysBusDeviceMethods::init_irq`], and
|
||||
/// a function such as [`crate::sysbus::SysBusDeviceMethods::init_irq`], and
|
||||
/// initially leaves the pointer to a NULL value, representing an unconnected
|
||||
/// interrupt. To connect it, whoever creates the device fills the pointer with
|
||||
/// the sink's `IRQState *`, for example using `sysbus_connect_irq`. Because
|
||||
@@ -114,4 +111,5 @@ unsafe impl ObjectType for IRQState {
|
||||
const TYPE_NAME: &'static CStr =
|
||||
unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_IRQ) };
|
||||
}
|
||||
|
||||
qom_isa!(IRQState: Object);
|
||||
|
||||
@@ -17,7 +17,6 @@ pub mod chardev;
|
||||
pub mod irq;
|
||||
pub mod memory;
|
||||
pub mod qdev;
|
||||
pub mod qom;
|
||||
pub mod sysbus;
|
||||
|
||||
// Allow proc-macros to refer to `::qemu_api` inside the `qemu_api` crate (this
|
||||
|
||||
@@ -11,11 +11,9 @@ use std::{
|
||||
|
||||
pub use bindings::{hwaddr, MemTxAttrs};
|
||||
use common::{callbacks::FnCall, uninit::MaybeUninitField, zeroable::Zeroable, Opaque};
|
||||
use qom::prelude::*;
|
||||
|
||||
use crate::{
|
||||
bindings::{self, device_endian, memory_region_init_io},
|
||||
prelude::*,
|
||||
};
|
||||
use crate::bindings::{self, device_endian, memory_region_init_io};
|
||||
|
||||
pub struct MemoryRegionOps<T>(
|
||||
bindings::MemoryRegionOps,
|
||||
@@ -186,6 +184,7 @@ unsafe impl ObjectType for MemoryRegion {
|
||||
const TYPE_NAME: &'static CStr =
|
||||
unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_MEMORY_REGION) };
|
||||
}
|
||||
|
||||
qom_isa!(MemoryRegion: Object);
|
||||
|
||||
/// A special `MemTxAttrs` constant, used to indicate that no memory
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user