Paolo Bonzini writes:
> From: Junjie Mao
>
> offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation
> that was found on the Rust forums, and whose author agreed to license as
> MIT for use in QEMU.
>
> The alternative allows only one level of fi
Paolo Bonzini writes:
> Il ven 1 nov 2024, 11:21 Junjie Mao ha scritto:
>
> How about specifying also the exact version in Cargo.toml, e.g.:
>
> [dependencies]
> -proc-macro2 = "1"
> -quote = "1"
> -syn = { version = "2", fe
t be the case once more devices are added.
Cargo workspace fits our use case very well!
Reviewed-by: Junjie Mao
ect dependencies will be unchanged even
after a cargo generate-lockfile.
Unfortunately, versions of nested dependencies, such as either and
unicode-ident, may still have newer patch versions after a lockfile
regeneration. That can be worked around by turning nested dependencies
to direct ones with fixed version constraints, but looks quite ugly.
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> Replay the configuration that would be computed by build.rs when compiling
> on a 1.63.0 compiler.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
One question below.
> ---
> subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++-
I would suggest adding those dependencies and version constraints in
Cargo.toml, not Cargo.lock. Future devices in Rust will have their
Cargo.lock derived from Cargo.toml of qemu-api and qemu-api-macro, so
missing version info there will force device writers to manually tweak
their Cargo.lock.
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> Apply a patch that removes "let ... else" constructs, replacing them with
> "if let ... else" or "let ... = match ...". "let ... else" was stabilized in
> Rust 1.65.0.
>
> Reviewed-by: Zhao Liu
> Signed-off-
Kevin Wolf writes:
> Am 22.10.2024 um 08:00 hat Junjie Mao geschrieben:
>>
>> Paolo Bonzini writes:
>>
>> > On Tue, Oct 22, 2024 at 4:12 AM Junjie Mao wrote:
>> >> > +($type:ident => $body:block) => {
>>
Junjie Mao writes:
> offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation
> that was found on the Rust forums, and whose author agreed to license as
> MIT for use in QEMU.
>
> The alternative allows only one level of field access, but apart from this
> c
Bonzini
Signed-off-by: Paolo Bonzini
Signed-off-by: Junjie Mao
---
rust/hw/char/pl011/src/device.rs | 2 +-
rust/qemu-api-macros/Cargo.toml | 6 +-
rust/qemu-api-macros/src/lib.rs | 71 +-
rust/qemu-api/Cargo.lock
s. If
> we do mark all these fields not public, what would break?
>
The only thing that breaks today is std::mem::offset_of! which respects
field visibility. Defining a Property const structure requires getting
the field offset outside of the state context.
To me properties are still pri
Paolo Bonzini writes:
> Il lun 21 ott 2024, 09:24 Junjie Mao ha scritto:
>
> > Thanks. I still prefer to keep the procedural macro code minimal, and
> have the
> > code generation in a separate macro, but this is a nice start!
> >
>
> I'm not s
i
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> rustc_args is needed to smooth the difference in warnings between the various
> versions of rustc. Always include those arguments.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
can run clippy by:
mkdir build.clippy && cd build.clippy
RUSTC=clippy-driver ../configure --enable-rust ...
ninja librust_x86_64_softmmu.a
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> Remove the duplicate code by using the module_init! macro; at the same time,
> simplify how module_init! is used, by taking inspiration from the
> implementation
> of #[derive(Object)].
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
any other code would.
>
> Reviewed-by: Zhao Liu
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> On Mon, Oct 21, 2024 at 1:35 PM Junjie Mao wrote:
>>
>>
>> Paolo Bonzini writes:
>>
>> > Adjust the integration test to compile with a subset of QEMU object
>> > files, and make it actually create an object of the class it
;
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
t;
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
ble as a "const"
> function until Rust 1.75.0, so this also prepares for having handwritten
> implementations of the trait until we can assume that version.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> Il lun 21 ott 2024, 12:39 Junjie Mao ha scritto:
>
> Paolo Bonzini writes:
>
> > Use the "struct update" syntax to initialize most of the fields to zero,
> > and simplify the handmade type-checking of $name.
>
cutable(
'rust_qemu_api_integration',
'tests/tests.rs',
override_options: ['rust_std=2021', 'build.rust_std=2021'],
rust_args: [
'--test',
],
install: false,
dependencies: [qemu_api, qemu_api_macros],
link_whole: [rust_qemu_api_objs, libqemuutil]),
args: [
'--test',
'--format', 'pretty',
],
protocol: 'rust',
suite: ['unit', 'rust'])
--
Best Regards
Junjie Mao
indings::Property>::zeroed().assume_init()
> }
zeroed() is const only since 1.75.0 [1]. Is there any alternative for
older Rust versions?
[1] https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#method.zeroed
--
Best Regards
Junjie Mao
any other code would.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
A few minor comments on cosmetic below.
> ---
> meson.build | 10 -
> rust/qemu-api/meson.build| 20 +++--
> rust/qemu-api/src/tests.rs | 49 --
>
This is similar to how the ctor crate operates; without this change,
> "#[derive(Object)]" does not work on Fedora 41.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
d I had a conversation on this. He mentioned that he had a
second Rust device that needs this macro [1].
[1] https://lore.kernel.org/qemu-devel/itblf.by425lac...@linaro.org/
--
Best Regards
Junjie Mao
>
> Signed-off-by: Paolo Bonzini
> ---
> rust/qemu-api/src/defi
Paolo Bonzini writes:
> Mangled symbols do not cause any issue; disabling mangling is only useful if
> C headers reference the Rust function, which is not the case here.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> On 10/21/24 07:40, Junjie Mao wrote:
>> offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation
>> that was found on the Rust forums, and whose author agreed to license as
>> MIT for use in QEMU.
>> The alternative all
fg is added to packagefiles/syn-2-rs/meson.build, which requires meson
to re-checkout the subproject.
[1]
https://lore.kernel.org/qemu-devel/20241015131735.518771-1-pbonz...@redhat.com
Co-authored-by: Paolo Bonzini
Signed-off-by: Paolo Bonzini
Signed-off-by: Junjie Mao
---
rust/hw/char/pl01
Paolo Bonzini writes:
> On Thu, Oct 17, 2024 at 7:35 AM Junjie Mao wrote:
>> Paolo Bonzini writes:
>> > offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation
>> > that was found on the Rust forums, and whose author agreed to license
Junjie Mao writes:
> Paolo Bonzini writes:
>
>> Il mer 16 ott 2024, 08:10 Junjie Mao ha scritto:
>>
>> In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from
>> apt) the feature `proc_macro_byte_character` is not yet stablized but
>> u
e and field point to the MaybeUninit<$parent> and are casted
// to u8 for calculating their distance.
unsafe { field.cast::().offset_from(base.cast::()) as usize }
}};
}
[1] https://docs.rs/memoffset/latest/memoffset/
--
Best Regards
Junjie Mao
Paolo Bonzini writes:
> Il mer 16 ott 2024, 08:10 Junjie Mao ha scritto:
>
> In my Ubuntu 22.04 environment (rustc 1.76.0 and bindgen 0.59.1 from
> apt) the feature `proc_macro_byte_character` is not yet stablized but
> used in proc-macro2. Downgrading proc-macro2 to 1.0.79
Paolo Bonzini writes:
> Avoid repeated lines of the form
>
> Program scripts/rust/rust_root_crate.sh found: YES
> (/home/pbonzini/work/upstream/qemu/scripts/rust/rust_root_crate.sh)
>
> in the meson logs.
>
> Signed-off-by: Paolo Bonzini
Reviewed-by: Junjie Mao
Tha
pes and thus break the
build. Allowlists for bindgen 0.59.1 can only be specified as regex on
function, type or var. I don't find (yet) an equivalent way of
--allowlist-file. A dirty trick is `--blocklist-item IPPORT_RESERVED`,
which works but is so ad-hoc.
--
Best Regards
Junjie Mao
tory = syn-2.0.58
+source_url = https://crates.io/api/v1/crates/syn/2.0.58/download
+source_filename = syn-2.0.58.0.tar.gz
+source_hash = 44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687
#method = cargo
patch_directory = syn-2-rs
--
Best Regards
Junjie Mao
> if get_option('rust').enabled()
> - error('rustc
io.h) but probably we have to leave the warning in.
>
> Paolo
I agree with Paolo's comments. It was reported that using inconsistent
versions of clang and libclang can lead to unsound bindings even they
compile. I would recommend to keep that warning till a proper
resolution, e.g. clang-sys provides consistent paths, is present.
--
Best Regards
Junjie Mao
ves: https://gitlab.com/qemu-project/qemu/-/issues/2576
> Fixes: ffa8a3e3b2e6 ("virtio-pci: Add lookup subregion of VirtIOPCIRegion MR")
>
> Signed-off-by: Gao Shiyuan
> Signed-off-by: Zuo Boqun
> Signed-off-by: Wang Liang
Reviewed-by: Junjie Mao
Thanks!
--
Best Regards
Junjie Mao
"Zuo,Boqun" writes:
> On Wed, Sep 25, 2024 8:58 PM Junjie Mao wrote:
>> > As shown below, if a virtio PCI device is attached under a pci-bridge,
>> > the MR of VirtIOPCIRegion does not belong to any address space. So
>> > memory_region_f
ate
and a test driver. In that sense, I don't think mixed C/Rust code can be
unit-tested in the current draft of Rust enabling where the C and Rust
code are separately built into libraries and finally linked together.
--
Best Regards
Junjie Mao
a38c7..fddceaaa47 100644
> --- a/include/hw/virtio/virtio-pci.h
> +++ b/include/hw/virtio/virtio-pci.h
> @@ -147,6 +147,7 @@ struct VirtIOPCIProxy {
> };
> MemoryRegion modern_bar;
> MemoryRegion io_bar;
> +AddressSpace modern_as;
How about naming it "config_as" or "config_mem_as"? While the PCI
configuration access capability is specific to modern devices, what it
maps (and only maps) are the virtio config regions.
Also, we may need another "config_io_as" for the port I/O mapped
notification config region.
> uint32_t legacy_io_bar_idx;
> uint32_t msix_bar_idx;
> uint32_t modern_io_bar_idx;
--
Best Regards
Junjie Mao
fig
regions. The PCI capability can be regarded as a window to a register
space that is inaccessible otherwise under certain conditions. Also,
device-specific address spaces are not rare today.
Directly travering the subregions does not look like a good approach as
it breaks abstraction. Accesses to memory regions require extra care
about RCU and refcount. Scatter such operations in multiple files will
make the abstraction harder to maintain.
Adding another API for finding a subregion within a region not in any
address space is an alternative, but I'm not sure if that looks like an
overkill.
--
Best Regards
Junjie Mao
Junjie Mao writes:
> Manos Pitsidianakis writes:
>
>> This commit adds a re-implementation of hw/char/pl011.c in Rust.
>>
>> How to build:
>>
>> 1. Configure a QEMU build with:
>>--enable-system --target-list=aarch64-softmmu --enable-rust
>> 2
y: Manos Pitsidianakis
Reviewed-by: Junjie Mao
> ---
> MAINTAINERS| 1 +
> rust/meson.build | 1 +
> rust/qemu-api-macros/Cargo.lock| 47
> ++
> r
Rust version
>of the pl011 device
>
> Co-authored-by: Junjie Mao
> Co-authored-by: Paolo Bonzini
> Signed-off-by: Junjie Mao
> Signed-off-by: Paolo Bonzini
> Signed-off-by: Manos Pitsidianakis
> ---
[snip]
> diff --git a/rust/hw/char/pl011/src/device.rs
>
Manos Pitsidianakis writes:
> 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
> Co-authored-by: Paolo Bonzini
> Signed-off-by: Junjie
On 9/4/2024 7:01 PM, Paolo Bonzini wrote:
On Wed, Aug 28, 2024 at 6:12 AM Manos Pitsidianakis
wrote:
Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and
provides some declaration macros for symbols visible to the rest of
QEMU.
The only comment I have is that I would drop
On 8/31/2024 4:25 PM, Manos Pitsidianakis wrote:
On Fri, 30 Aug 2024 14:03, Alex Bennée wrote:
[.snip.]
It is there:
/usr/lib/llvm-14/lib/clang/14.0.6/include/stdatomic.h
in the search path:
clang -E -Wp,-v -
clang -cc1 version 14.0.6 based upon LLVM 14.0.6 default target
x86_64-pc-linu
On 8/30/2024 2:43 PM, Manos Pitsidianakis wrote:
🎱
On Fri, 30 Aug 2024, 04:19 Junjie Mao, <mailto:junjie@intel.com>> wrote:
On 8/28/2024 9:08 PM, Alex Bennée wrote:
> Manos Pitsidianakis mailto:manos.pitsidiana...@linaro.org>> writes:
>
>&g
RGS");
println!(
"cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_{}",
std::env::var("TARGET").unwrap()
);
println!(
"cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_{}",
std::env::var("TARGET&q
On 8/26/2024 2:12 PM, Manos Pitsidianakis wrote:
On Mon, 26 Aug 2024 08:03, Junjie Mao wrote:
Hi Manos,
On 8/23/2024 4:11 PM, Manos Pitsidianakis wrote:
Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and
provides some declaration macros for symbols visible to the rest
On 8/26/2024 2:41 PM, Manos Pitsidianakis wrote:
On Mon, 26 Aug 2024 08:31, Junjie Mao wrote:
+unsafe impl GlobalAlloc for QemuAllocator {
+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+ if layout.align() == 0 {
+ g_malloc0(layout.size().try_into().unwrap(
On 8/23/2024 4:11 PM, Manos Pitsidianakis wrote:
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
Co-authored-by: Paolo Bonzini
Signed-off-by: Junjie Mao
Signed-off-by
os, but the later
generates code that uses types defined by the former. So to me qemu-api-macros
should depend on qemu-api, not vice versa.
---
Best Regards
Junjie Mao
Hi Manos,
On 8/23/2024 4:11 PM, Manos Pitsidianakis wrote:
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
Co-authored-by: Paolo Bonzini
Signed-off-by: Junjie Mao
On 8/16/2024 4:17 PM, Manos Pitsidianakis wrote:
On Fri, 16 Aug 2024, 11:06 Junjie Mao, <mailto:junjie@intel.com>> wrote:
On 8/15/2024 7:42 PM, Manos Pitsidianakis wrote:
> Outstanding issues
> ==
>
> Outstanding issues that
On 8/15/2024 7:42 PM, Manos Pitsidianakis wrote:
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
Co-authored-by: Paolo Bonzini
Signed-off-by: Junjie Mao
Signed-off-by
jects using the C
linker. That somehow works (with some tricks) but is not officially supported
and may break in the future.
I'm working on (1), but would like to have your thoughts and preference on those
options.
[1] https://github.com/rust-lang/rust/issues/73632
---
Best Regards
Junjie Mao
Signed-off-by: Junjie Mao
---
rust/hw/char/pl011/meson.build | 4 +---
rust/meson.build | 4 +---
rust/qemu-api/meson.build | 2 +-
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/rust/hw/char/pl011/meson.build b/rust/hw/char/pl011/meson.build
index 1c139d3af9
Signed-off-by: Junjie Mao
---
subprojects/packagefiles/arbitrary-int-1-rs/meson.build | 4 +---
subprojects/packagefiles/bilge-impl-0.2-rs/meson.build| 2 +-
subprojects/packagefiles/either-1-rs/meson.build | 2 +-
subprojects/packagefiles/itertools-0.11-rs/meson.build
11-rfc-v6
[3]. Feel free to squash these changes into that series.
[1] https://github.com/mesonbuild/meson/pull/7934
[2] https://gitlab.com/bonzini/qemu/-/tree/rust-for-manos
[3]
https://lore.kernel.org/qemu-devel/rust-pl011-rfc-v6.git.manos.pitsidiana...@linaro.org
Junjie Mao (2):
meson: subpr
f --git a/subprojects/packagefiles/unicode-ident-1-rs/meson.build
b/subprojects/packagefiles/unicode-ident-1-rs/meson.build
index 80d088282c..c398f59211 100644
--- a/subprojects/packagefiles/unicode-ident-1-rs/meson.build
+++ b/subprojects/packagefiles/unicode-ident-1-rs/meson.build
@@ -19,4 +19,4 @@ unicode_ident_dep = declare_dependency(
link_with: _unicode_ident_rs,
)
-meson.override_dependency('unicode-ident-1-rs-native', unicode_ident_dep)
+meson.override_dependency('unicode-ident-1-rs-native', unicode_ident_dep,
native: true)
Besides, I think we don't need the "-native" suffix in the dependency names
since we already have that "native: true" argument. I also tested configuration
and build after execute "find . -name 'meson.build' | xargs -n 1 sed -i
's/-native//g'" under subprojects/packagefiles, and it worked as well.
With the changes above, I'm able to cross-build except for one known linking
issue [1].
[1] https://github.com/llvm/llvm-project/pull/93890
Thanks
Junjie Mao
Paolo
63 matches
Mail list logo