diff options
author | Manos Pitsidianakis <manos.pitsidianakis@linaro.org> | 2024-10-03 16:28:49 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-10-11 12:32:17 +0200 |
commit | 5a5110d290c0f2dca3d98c608b0ec9a01d2181b9 (patch) | |
tree | be22aaecedc4bd8dad05dff6ea3b308a31c8e4ac /rust/qemu-api/src/tests.rs | |
parent | dc43b18d2e1ed50e6c912427d5f7fbd2c62007bb (diff) | |
download | qemu-5a5110d290c0f2dca3d98c608b0ec9a01d2181b9.zip qemu-5a5110d290c0f2dca3d98c608b0ec9a01d2181b9.tar.gz qemu-5a5110d290c0f2dca3d98c608b0ec9a01d2181b9.tar.bz2 |
rust: add crate to expose bindings and interfaces
Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and
provides some declaration macros for symbols visible to the rest of
QEMU.
Co-authored-by: Junjie Mao <junjie.mao@intel.com>
Co-authored-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Link: https://lore.kernel.org/r/0fb23fbe211761b263aacec03deaf85c0cc39995.1727961605.git.manos.pitsidianakis@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api/src/tests.rs')
-rw-r--r-- | rust/qemu-api/src/tests.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/rust/qemu-api/src/tests.rs b/rust/qemu-api/src/tests.rs new file mode 100644 index 0000000..df54edb --- /dev/null +++ b/rust/qemu-api/src/tests.rs @@ -0,0 +1,49 @@ +// Copyright 2024, Linaro Limited +// Author(s): Manos Pitsidianakis <manos.pitsidianakis@linaro.org> +// SPDX-License-Identifier: GPL-2.0-or-later + +use crate::{ + bindings::*, declare_properties, define_property, device_class_init, vm_state_description, +}; + +#[test] +fn test_device_decl_macros() { + // Test that macros can compile. + vm_state_description! { + VMSTATE, + name: c"name", + unmigratable: true, + } + + #[repr(C)] + pub struct DummyState { + pub char_backend: CharBackend, + pub migrate_clock: bool, + } + + declare_properties! { + DUMMY_PROPERTIES, + define_property!( + c"chardev", + DummyState, + char_backend, + unsafe { &qdev_prop_chr }, + CharBackend + ), + define_property!( + c"migrate-clk", + DummyState, + migrate_clock, + unsafe { &qdev_prop_bool }, + bool + ), + } + + device_class_init! { + dummy_class_init, + props => DUMMY_PROPERTIES, + realize_fn => None, + reset_fn => None, + vmsd => VMSTATE, + } +} |