#[repr(C)]pub struct DeviceClass {Show 15 fields
pub parent_class: ObjectClass,
pub categories: [u64; 1],
pub fw_name: *const i8,
pub desc: *const i8,
pub props: *mut Property,
pub user_creatable: bool,
pub cannot_destroy_with_object_finalize_yet: bool,
pub hotpluggable: bool,
pub reset: Option<unsafe extern "C" fn(*mut DeviceState)>,
pub realize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>,
pub unrealize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>,
pub vmsd: *const VMStateDescription,
pub init: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>,
pub exit: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>,
pub bus_type: *const i8,
}Expand description
DeviceClass: @props: Properties accessing state fields. @realize: Callback function invoked when the #DeviceState:realized property is changed to %true. The default invokes @init if not %NULL. @unrealize: Callback function invoked when the #DeviceState:realized property is changed to %false. @init: Callback function invoked when the #DeviceState::realized property is changed to %true. Deprecated, new types inheriting directly from TYPE_DEVICE should use @realize instead, new leaf types should consult their respective parent type. @hotpluggable: indicates if #DeviceClass is hotpluggable, available as readonly “hotpluggable” property of #DeviceState instance
§Realization
Devices are constructed in two stages,
- object instantiation via object_initialize() and
- device realization via #DeviceState:realized property. The former may not fail (it might assert or exit), the latter may return error information to the caller and must be re-entrant. Trivial field initializations should go into #TypeInfo.instance_init. Operations depending on @props static properties should go into @realize. After successful realization, setting static properties will fail.
As an interim step, the #DeviceState:realized property can also be set with qdev_init_nofail(). In the future, devices will propagate this state change to their children and along busses they expose. The point in time will be deferred to machine creation, so that values set in @realize will not be introspectable beforehand. Therefore devices must not create children during @realize; they should initialize them via object_initialize() in their own #TypeInfo.instance_init and forward the realization events appropriately.
The @init callback is considered private to a particular bus implementation (immediate abstract child types of TYPE_DEVICE). Derived leaf types set an “init” callback on their parent class instead.
Any type may override the @realize and/or @unrealize callbacks but needs to call the parent type’s implementation if keeping their functionality is desired. Refer to QOM documentation for further discussion and examples.
Fields§
§parent_class: ObjectClass§categories: [u64; 1]§fw_name: *const i8§desc: *const i8§props: *mut Property§user_creatable: bool§cannot_destroy_with_object_finalize_yet: bool§hotpluggable: bool§reset: Option<unsafe extern "C" fn(*mut DeviceState)>§realize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>§unrealize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>§vmsd: *const VMStateDescription§init: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>§exit: Option<unsafe extern "C" fn(*mut DeviceState) -> i32>§bus_type: *const i8Trait Implementations§
Source§impl Clone for DeviceClass
impl Clone for DeviceClass
Source§fn clone(&self) -> DeviceClass
fn clone(&self) -> DeviceClass
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more