From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH 28/33] rust: repurpose qemu_api -> tests
Date: Mon, 8 Sep 2025 12:50:00 +0200 [thread overview]
Message-ID: <20250908105005.2119297-29-pbonzini@redhat.com> (raw)
In-Reply-To: <20250908105005.2119297-1-pbonzini@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The crate purpose is only to provide integration tests at this point,
that can't easily be moved to a specific crate.
It's also often a good practice to have a single integration test crate
(see for ex https://github.com/rust-lang/cargo/issues/4867)
Drop README.md, use docs/devel/rust.rst instead.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Link: https://lore.kernel.org/r/20250827104147.717203-20-marcandre.lureau@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
MAINTAINERS | 2 +-
rust/qemu-api/wrapper.h | 53 -------------
rust/Cargo.lock | 30 ++++----
rust/Cargo.toml | 2 +-
rust/meson.build | 4 +-
rust/qemu-api/.gitignore | 2 -
rust/qemu-api/README.md | 19 -----
rust/qemu-api/build.rs | 1 -
rust/qemu-api/meson.build | 75 -------------------
rust/qemu-api/src/bindings.rs | 33 --------
rust/qemu-api/src/lib.rs | 18 -----
rust/qemu-api/src/prelude.rs | 5 --
rust/{qemu-api => tests}/Cargo.toml | 7 +-
rust/tests/meson.build | 14 ++++
.../tests/vmstate_tests.rs | 0
15 files changed, 35 insertions(+), 230 deletions(-)
delete mode 100644 rust/qemu-api/wrapper.h
delete mode 100644 rust/qemu-api/.gitignore
delete mode 100644 rust/qemu-api/README.md
delete mode 120000 rust/qemu-api/build.rs
delete mode 100644 rust/qemu-api/meson.build
delete mode 100644 rust/qemu-api/src/bindings.rs
delete mode 100644 rust/qemu-api/src/lib.rs
delete mode 100644 rust/qemu-api/src/prelude.rs
rename rust/{qemu-api => tests}/Cargo.toml (78%)
create mode 100644 rust/tests/meson.build
rename rust/{qemu-api => tests}/tests/vmstate_tests.rs (100%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 92cf6929bd8..de4f858df68 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3518,11 +3518,11 @@ F: rust/chardev/
F: rust/common/
F: rust/hw/core/
F: rust/migration/
-F: rust/qemu-api
F: rust/qemu-macros/
F: rust/qom/
F: rust/rustfmt.toml
F: rust/system/
+F: rust/tests/
F: rust/util/
F: scripts/get-wraps-from-cargo-registry.py
diff --git a/rust/qemu-api/wrapper.h b/rust/qemu-api/wrapper.h
deleted file mode 100644
index 7c9c20b14fe..00000000000
--- a/rust/qemu-api/wrapper.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * QEMU System Emulator
- *
- * Copyright (c) 2024 Linaro Ltd.
- *
- * Authors: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-/*
- * This header file is meant to be used as input to the `bindgen` application
- * in order to generate C FFI compatible Rust bindings.
- */
-
-#ifndef __CLANG_STDATOMIC_H
-#define __CLANG_STDATOMIC_H
-/*
- * Fix potential missing stdatomic.h error in case bindgen does not insert the
- * correct libclang header paths on its own. We do not use stdatomic.h symbols
- * in QEMU code, so it's fine to declare dummy types instead.
- */
-typedef enum memory_order {
- memory_order_relaxed,
- memory_order_consume,
- memory_order_acquire,
- memory_order_release,
- memory_order_acq_rel,
- memory_order_seq_cst,
-} memory_order;
-#endif /* __CLANG_STDATOMIC_H */
-
-#include "qemu/osdep.h"
-#include "qemu-io.h"
-#include "exec/memattrs.h"
-#include "hw/char/pl011.h"
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 2018d13fbf5..ac79c6a34a9 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -187,21 +187,6 @@ dependencies = [
"unicode-ident",
]
-[[package]]
-name = "qemu_api"
-version = "0.1.0"
-dependencies = [
- "bql",
- "chardev",
- "common",
- "hwcore",
- "migration",
- "qemu_macros",
- "qom",
- "system",
- "util",
-]
-
[[package]]
name = "qemu_macros"
version = "0.1.0"
@@ -252,6 +237,21 @@ dependencies = [
"util",
]
+[[package]]
+name = "tests"
+version = "0.1.0"
+dependencies = [
+ "bql",
+ "chardev",
+ "common",
+ "hwcore",
+ "migration",
+ "qemu_macros",
+ "qom",
+ "system",
+ "util",
+]
+
[[package]]
name = "unicode-ident"
version = "1.0.12"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index b2a5c230fa2..d8183c614d4 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -6,13 +6,13 @@ members = [
"common",
"migration",
"qemu-macros",
- "qemu-api",
"qom",
"system",
"hw/core",
"hw/char/pl011",
"hw/timer/hpet",
"util",
+ "tests",
]
[workspace.package]
diff --git a/rust/meson.build b/rust/meson.build
index 9f6a0b161d2..bd9b9cb83ea 100644
--- a/rust/meson.build
+++ b/rust/meson.build
@@ -18,8 +18,6 @@ quote_rs_native = dependency('quote-1-rs', native: true)
syn_rs_native = dependency('syn-2-rs', native: true)
proc_macro2_rs_native = dependency('proc-macro2-1-rs', native: true)
-qemuutil_rs = qemuutil.partial_dependency(link_args: true, links: true)
-
genrs = []
subdir('common')
@@ -32,7 +30,7 @@ subdir('qom')
subdir('system')
subdir('chardev')
subdir('hw/core')
-subdir('qemu-api')
+subdir('tests')
subdir('hw')
diff --git a/rust/qemu-api/.gitignore b/rust/qemu-api/.gitignore
deleted file mode 100644
index df6c2163e03..00000000000
--- a/rust/qemu-api/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore generated bindings file overrides.
-/src/bindings.inc.rs
diff --git a/rust/qemu-api/README.md b/rust/qemu-api/README.md
deleted file mode 100644
index ed1b7ab263d..00000000000
--- a/rust/qemu-api/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# QEMU bindings and API wrappers
-
-This library exports helper Rust types, Rust macros and C FFI bindings for internal QEMU APIs.
-
-The C bindings can be generated with `bindgen`, using this build target:
-
-```console
-$ make bindings.inc.rs
-```
-
-## Generate Rust documentation
-
-Common Cargo tasks can be performed from the QEMU build directory
-
-```console
-$ make clippy
-$ make rustfmt
-$ make rustdoc
-```
diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs
deleted file mode 120000
index 71a3167885c..00000000000
--- a/rust/qemu-api/build.rs
+++ /dev/null
@@ -1 +0,0 @@
-../util/build.rs
\ No newline at end of file
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
deleted file mode 100644
index fe81f16d990..00000000000
--- a/rust/qemu-api/meson.build
+++ /dev/null
@@ -1,75 +0,0 @@
-_qemu_api_cfg = run_command(rustc_args,
- '--config-headers', config_host_h, '--features', files('Cargo.toml'),
- capture: true, check: true).stdout().strip().splitlines()
-
-c_enums = [
- 'MemoryDeviceInfoKind',
-]
-_qemu_api_bindgen_args = []
-foreach enum : c_enums
- _qemu_api_bindgen_args += ['--rustified-enum', enum]
-endforeach
-
-blocked_type = [
- 'Chardev',
- 'Error',
- 'MemTxAttrs',
- 'MemoryRegion',
- 'ObjectClass',
- 'VMStateDescription',
- 'device_endian',
-]
-foreach type: blocked_type
- _qemu_api_bindgen_args += ['--blocklist-type', type]
-endforeach
-
-# TODO: Remove this comment when the clang/libclang mismatch issue is solved.
-#
-# Rust bindings generation with `bindgen` might fail in some cases where the
-# detected `libclang` does not match the expected `clang` version/target. In
-# this case you must pass the path to `clang` and `libclang` to your build
-# command invocation using the environment variables CLANG_PATH and
-# LIBCLANG_PATH
-_qemu_api_bindings_inc_rs = rust.bindgen(
- input: 'wrapper.h',
- dependencies: common_ss.all_dependencies(),
- output: 'bindings.inc.rs',
- include_directories: bindings_incdir,
- bindgen_version: ['>=0.60.0'],
- args: bindgen_args_common + _qemu_api_bindgen_args,
- )
-
-_qemu_api_rs = static_library(
- 'qemu_api',
- structured_sources(
- [
- 'src/lib.rs',
- 'src/bindings.rs',
- 'src/prelude.rs',
- ],
- {'.' : _qemu_api_bindings_inc_rs},
- ),
- override_options: ['rust_std=2021', 'build.rust_std=2021'],
- rust_abi: 'rust',
- rust_args: _qemu_api_cfg,
- dependencies: [anyhow_rs, bql_rs, chardev_rs, common_rs, foreign_rs, hwcore_rs, libc_rs, migration_rs, qemu_macros,
- qom_rs, system_rs, util_rs, hwcore],
-)
-
-qemu_api_rs = declare_dependency(link_with: [_qemu_api_rs],
- dependencies: [qemu_macros, qom, hwcore, chardev, migration])
-
-test('rust-qemu-api-integration',
- executable(
- 'rust-qemu-api-integration',
- files('tests/vmstate_tests.rs'),
- override_options: ['rust_std=2021', 'build.rust_std=2021'],
- rust_args: ['--test'],
- install: false,
- dependencies: [bql_rs, common_rs, util_rs, migration_rs, qom_rs, qemu_api_rs]),
- args: [
- '--test', '--test-threads', '1',
- '--format', 'pretty',
- ],
- protocol: 'rust',
- suite: ['unit', 'rust'])
diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs
deleted file mode 100644
index 9c863e9b5b4..00000000000
--- a/rust/qemu-api/src/bindings.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-#![allow(
- dead_code,
- improper_ctypes_definitions,
- improper_ctypes,
- non_camel_case_types,
- non_snake_case,
- non_upper_case_globals,
- unnecessary_transmutes,
- unsafe_op_in_unsafe_fn,
- clippy::pedantic,
- clippy::restriction,
- clippy::style,
- clippy::missing_const_for_fn,
- clippy::ptr_offset_with_cast,
- clippy::useless_transmute,
- clippy::missing_safety_doc,
- clippy::too_many_arguments
-)]
-
-//! `bindgen`-generated declarations.
-
-use chardev::bindings::Chardev;
-use migration::bindings::VMStateDescription;
-use qom::bindings::ObjectClass;
-use system::bindings::{device_endian, MemTxAttrs, MemoryRegion};
-use util::bindings::Error;
-
-#[cfg(MESON)]
-include!("bindings.inc.rs");
-
-#[cfg(not(MESON))]
-include!(concat!(env!("OUT_DIR"), "/bindings.inc.rs"));
diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs
deleted file mode 100644
index 21b886035f3..00000000000
--- a/rust/qemu-api/src/lib.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2024, Linaro Limited
-// Author(s): Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#![cfg_attr(not(MESON), doc = include_str!("../README.md"))]
-#![deny(clippy::missing_const_for_fn)]
-
-#[rustfmt::skip]
-pub mod bindings;
-
-// preserve one-item-per-"use" syntax, it is clearer
-// for prelude-like modules
-#[rustfmt::skip]
-pub mod prelude;
-
-// Allow proc-macros to refer to `::qemu_api` inside the `qemu_api` crate (this
-// crate).
-extern crate self as qemu_api;
diff --git a/rust/qemu-api/src/prelude.rs b/rust/qemu-api/src/prelude.rs
deleted file mode 100644
index 8db56f9f817..00000000000
--- a/rust/qemu-api/src/prelude.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2024 Red Hat, Inc.
-// Author(s): Paolo Bonzini <pbonzini@redhat.com>
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-//! Commonly used traits and types for QEMU.
diff --git a/rust/qemu-api/Cargo.toml b/rust/tests/Cargo.toml
similarity index 78%
rename from rust/qemu-api/Cargo.toml
rename to rust/tests/Cargo.toml
index 9abb88aa1f8..8d106d896d7 100644
--- a/rust/qemu-api/Cargo.toml
+++ b/rust/tests/Cargo.toml
@@ -1,12 +1,11 @@
[package]
-name = "qemu_api"
+name = "tests"
version = "0.1.0"
-authors = ["Manos Pitsidianakis <manos.pitsidianakis@linaro.org>"]
-description = "Rust bindings for QEMU"
-readme = "README.md"
+description = "Rust integration tests for QEMU"
resolver = "2"
publish = false
+authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
diff --git a/rust/tests/meson.build b/rust/tests/meson.build
new file mode 100644
index 00000000000..00688c66fb1
--- /dev/null
+++ b/rust/tests/meson.build
@@ -0,0 +1,14 @@
+test('rust-integration',
+ executable(
+ 'rust-integration',
+ files('tests/vmstate_tests.rs'),
+ override_options: ['rust_std=2021', 'build.rust_std=2021'],
+ rust_args: ['--test'],
+ install: false,
+ dependencies: [bql_rs, common_rs, util_rs, migration_rs, qom_rs]),
+ args: [
+ '--test', '--test-threads', '1',
+ '--format', 'pretty',
+ ],
+ protocol: 'rust',
+ suite: ['unit', 'rust'])
diff --git a/rust/qemu-api/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_tests.rs
similarity index 100%
rename from rust/qemu-api/tests/vmstate_tests.rs
rename to rust/tests/tests/vmstate_tests.rs
--
2.51.0
next prev parent reply other threads:[~2025-09-08 10:56 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 10:49 [PATCH 00/33] First Rust update for QEMU 10.2 Paolo Bonzini
2025-09-08 10:49 ` [PATCH 01/33] ci: temporarily remove rust from Debian and Ubuntu Paolo Bonzini
2025-09-11 3:14 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 03/33] meson, cargo: require Rust 1.83.0 Paolo Bonzini
2025-09-11 3:19 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 04/33] rust: add missing const markers for MSRV==1.83.0 Paolo Bonzini
2025-09-11 3:20 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 05/33] rust: use inline const expressions Paolo Bonzini
2025-09-11 6:15 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 06/33] rust: add qdev Device derive macro Paolo Bonzini
2025-09-11 6:58 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 07/33] rust: vmstate: convert to use builder pattern Paolo Bonzini
2025-09-08 10:49 ` [PATCH 08/33] rust: vmstate: use const_refs_to_static Paolo Bonzini
2025-09-11 10:07 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 09/33] rust: qdev: const_refs_to_static Paolo Bonzini
2025-09-11 10:20 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 10/33] docs/rust: update msrv Paolo Bonzini
2025-09-11 10:21 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 11/33] rust: remove unused global qemu "allocator" Paolo Bonzini
2025-09-11 10:21 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 12/33] rust: add workspace authors Paolo Bonzini
2025-09-11 10:23 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 13/33] rust: move vmstate_clock!() to qdev module Paolo Bonzini
2025-09-11 10:25 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 14/33] rust: move VMState handling to QOM module Paolo Bonzini
2025-09-11 10:26 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 15/33] rust: move Cell vmstate impl Paolo Bonzini
2025-09-11 10:31 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 16/33] rust: split Rust-only "common" crate Paolo Bonzini
2025-09-11 10:44 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 17/33] rust: make build.rs generic over various ./rust/projects Paolo Bonzini
2025-09-12 7:43 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 18/33] rust: split "util" crate Paolo Bonzini
2025-09-12 8:00 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 19/33] rust: split "migration" crate Paolo Bonzini
2025-09-12 8:09 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 20/33] rust: split "bql" crate Paolo Bonzini
2025-09-12 8:31 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 21/33] rust: split "qom" crate Paolo Bonzini
2025-09-08 10:49 ` [PATCH 22/33] rust: split "chardev" crate Paolo Bonzini
2025-09-12 8:35 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 23/33] rust: split "system" crate Paolo Bonzini
2025-09-12 8:38 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 24/33] rust: split "hwcore" crate Paolo Bonzini
2025-09-12 8:41 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 25/33] rust: rename qemu_api_macros -> qemu_macros Paolo Bonzini
2025-09-12 8:41 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 26/33] rust/hpet: drop now unneeded qemu_api dep Paolo Bonzini
2025-09-12 8:42 ` Zhao Liu
2025-09-08 10:49 ` [PATCH 27/33] rust/pl011: drop dependency on qemu_api Paolo Bonzini
2025-09-12 8:45 ` Zhao Liu
2025-09-08 10:50 ` Paolo Bonzini [this message]
2025-09-12 8:57 ` [PATCH 28/33] rust: repurpose qemu_api -> tests Zhao Liu
2025-09-08 10:50 ` [PATCH 29/33] rust: re-export qemu_macros internal helper in "bits" Paolo Bonzini
2025-09-12 9:01 ` Zhao Liu
2025-09-08 10:50 ` [PATCH 30/33] rust: re-export qemu macros from common/qom/hwcore Paolo Bonzini
2025-09-12 9:03 ` Zhao Liu
2025-09-08 10:50 ` [PATCH 31/33] docs: update rust.rst Paolo Bonzini
2025-09-12 9:13 ` Zhao Liu
2025-09-08 10:50 ` [PATCH 32/33] rust: meson: remove unnecessary complication in device crates Paolo Bonzini
2025-09-12 9:20 ` Zhao Liu
2025-09-08 10:50 ` [PATCH 33/33] rust: do not inline do_init_io Paolo Bonzini
2025-09-12 9:21 ` Zhao Liu
[not found] ` <20250908105005.2119297-3-pbonzini@redhat.com>
2025-09-11 3:17 ` [PATCH 02/33] configure: bump Meson to 1.9.0 for use with Rust Zhao Liu
2025-09-11 10:04 ` [PATCH 00/33] First Rust update for QEMU 10.2 Peter Maydell
2025-09-11 11:18 ` Marc-André Lureau
2025-09-12 7:42 ` Zhao Liu
2025-09-12 8:47 ` Marc-André Lureau
2025-09-15 14:27 ` Paolo Bonzini
2025-09-15 17:51 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908105005.2119297-29-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).