Rust binding for QAPI (qemu-ga only, for now)
Subsystems (2)
cover Rust binding for QAPI (qemu-ga only, for now)
From: Marc-André Lureau <[email protected]>
Hi,
Among the QEMU developers, there is a desire to use Rust. (see previous thread from Stefan "Why QEMU should move from C to Rust", the rust-vmm related projects and other experiments).
Thanks to our QAPI type system and the associate code generator, it is relatively straightforward to create Rust bindings for the generated C types (also called sys/ffi binding) and functions. (rust-bindgen could probably do a similar job, but it would probably bring other issues). This provides an important internal API already.
Slightly more complicated is to expose a Rust API for those, and provide convenient conversions C<->Rust. Taking inspiration from glib-rs binding, I implemented a simplified version of the FromGlib/ToGlib traits, with simpler ownership model, sufficient for QAPI needs.
The usage is relatively simple:
- from_qemu_none(ptr: *const sys::P) -> T
Return a Rust type T for a const ffi pointer P.
- from_qemu_full(ptr: *mut sys::P) -> T
Return a Rust type T for a ffi pointer P, taking ownership.
- T::to_qemu_none() -> Stash<P>
Returns a borrowed ffi pointer P (using a Stash to destroy "glue" storage data, if any).
- T::to_qemu_full() -> P
Returns a ffi pointer P. (P resources are leaked/passed to C/ffi)
With those traits, it's relatively easy to implement the QMP callbacks. With enough interest, we could eventually add new commands in Rust, and start rewriting QGA in Rust, as it is a simple service. See qga/qmp/ for some examples. QEMU would be the next obvious target.
My biggest pain-point right now is the handling of 'if' conditions. I tried different approaches, but none of them are satisfying. I am planning to tackle this next again, along with full QEMU API schema support and hopefully some t= est
integration.
v2:
- split the original patch in smaller patches and more digestable form
- dropped the DBus interface experiment from this series
- various build-sys improvements, new configure options --with-rust(-target)
- various attempts at better meson integration, finally satisfied enough wit=
h the
current solution, which handles getting link flags from Rust sanely. (more meson stuff to come to handle config-host/features mapping etc).
- rebased, QGA QMP now uses unions, added support for it.
- start a common crate (which re-surfaced issues with foreign types and trai=
ts,
worked around with a NewPtr wrapper)
- explicit errors when ifcond are presents (after various unsucessful attemp=
ts,
I will try to tackle it in v3)
- mingw cross compilation support
- some attempts to add it to CI
- actually implement {get,set}-vcpus
- vendor the external crates
Marc-Andr=C3=A9 Lureau (15):
mingw: fix error __USE_MINGW_ANSI_STDIO redefined scripts/qapi: teach c_param_type() to return const argument type
build-sys: add --with-rust{-target} & basic build infrastructure
build-sys: add a cargo-wrapper script
qga/rust: build and link an empty static library
rust: provide a common crate for QEMU
scripts/qapi: add Rust sys bindings generation qga/rust: generate QGA QAPI sys bindings scripts/qapi: add generation of Rust bindings for types qga/rust: build Rust types
qga: add qmp! macro helper
qga: implement get-host-name in Rust
qga: implement {get,set}-vcpus in Rust
travis: add Rust
rust: use vendored-sources
.cargo/config | 5 + .gitmodules | 3 + .travis.yml | 18 +- Cargo.toml | 5 + configure | 26 ++ include/qemu/osdep.h | 10 - meson.build | 29 ++- migration/dirtyrate.c | 3 +- qga/Cargo.toml | 20 ++ qga/commands-posix.c | 159 ------------- qga/commands-win32.c | 76 ------ qga/commands.c | 34 +-- qga/lib.rs | 5 + qga/meson.build | 30 ++- qga/qapi.rs | 6 + qga/qapi_sys.rs | 5 + qga/qmp/hostname.rs | 9 + qga/qmp/mod.rs | 61 +++++ qga/qmp/vcpus.rs | 161 +++++++++++++ rust/common/Cargo.toml | 11 + rust/common/src/error.rs | 109 +++++++++ rust/common/src/lib.rs | 10 + rust/common/src/qemu.rs | 30 +++ rust/common/src/sys.rs | 58 +++++ rust/common/src/translate.rs | 309 ++++++++++++++++++++++++ rust/vendored | 1 + scripts/cargo_wrapper.py | 102 ++++++++ scripts/qapi-gen.py | 18 +- scripts/qapi/rs.py | 204 ++++++++++++++++ scripts/qapi/rs_sys.py | 254 ++++++++++++++++++++ scripts/qapi/rs_types.py | 447 +++++++++++++++++++++++++++++++++++ scripts/qapi/schema.py | 14 +- tests/test-bitmap.c | 1 - tests/test-qga.c | 4 + util/oslib-posix.c | 35 --- util/oslib-win32.c | 13 - 36 files changed, 1962 insertions(+), 323 deletions(-) create mode 100644 .cargo/config create mode 100644 Cargo.toml create mode 100644 qga/Cargo.toml create mode 100644 qga/lib.rs create mode 100644 qga/qapi.rs create mode 100644 qga/qapi_sys.rs create mode 100644 qga/qmp/hostname.rs create mode 100644 qga/qmp/mod.rs create mode 100644 qga/qmp/vcpus.rs create mode 100644 rust/common/Cargo.toml create mode 100644 rust/common/src/error.rs create mode 100644 rust/common/src/lib.rs create mode 100644 rust/common/src/qemu.rs create mode 100644 rust/common/src/sys.rs create mode 100644 rust/common/src/translate.rs create mode 160000 rust/vendored create mode 100644 scripts/cargo_wrapper.py create mode 100644 scripts/qapi/rs.py create mode 100644 scripts/qapi/rs_sys.py create mode 100644 scripts/qapi/rs_types.py
--=20
2.28.0
PATCH 1/15 mingw: fix error __USE_MINGW_ANSI_STDIO redefined
From: Marc-André Lureau <[email protected]>
Always put osdep.h first, and remove redundant stdlib.h include.
--- migration/dirtyrate.c | 3 ++- tests/test-bitmap.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)
migration/dirtyrate.c +2 -1
@@ -10,8 +10,9 @@* See the COPYING file in the top-level directory. */ -#include <zlib.h> #include "qemu/osdep.h" + +#include <zlib.h> #include "qapi/error.h" #include "cpu.h" #include "qemu/config-file.h"
tests/test-bitmap.c +0 -1
@@ -8,7 +8,6 @@* Author: Peter Xu <[email protected]> */ -#include <stdlib.h> #include "qemu/osdep.h" #include "qemu/bitmap.h"
Signature · 1 line
2.28.0
Re: [PoCv2 01/15] mingw: fix error __USE_MINGW_ANSI_STDIO redefined
Hi
Quoted 6 lines · On Mon, Oct 12, 2020 at 12:35 AM <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
Always put
osdep.hfirst, and remove redundantstdlib.hinclude.Signed-off-by Marc-André Lureau <[email protected]>
(ignore this patch, which was already sent earlier)
Quoted 35 lines
--- migration/dirtyrate.c | 3 ++- tests/test-bitmap.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)migration/dirtyrate.c +2
-1@@ -10,8 +10,9 @@* See the COPYING file in the top-level directory. */ -#include <zlib.h> #include "qemu/osdep.h" + +#include <zlib.h> #include "qapi/error.h" #include "cpu.h" #include "qemu/config-file.h" tests/test-bitmap.c +0
-2@@ -8,7 +8,6 @@* Author: Peter Xu <[email protected]> */ -#include <stdlib.h> #include "qemu/osdep.h" #include "qemu/bitmap.h" --2.28.0
PATCH 2/15 scripts/qapi: teach c_param_type() to return const argument type
In reply to [email protected]From: Marc-André Lureau <[email protected]>
As it should be, since the argument isn't owned by the callee, but a lot of code in QEMU rely on non-const arguments to tweak it.
Since Rust types / bindings are derived from the C version, we have to be more accurate there to do correct ownership conversions.
--- scripts/qapi/schema.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
scripts/qapi/schema.py +10 -4
@@ -167,8 +167,14 @@ class QAPISchemaType(QAPISchemaEntity): pass # Return the C type to be used in a parameter list. - def c_param_type(self): - return self.c_type() + # + # The argument should be considered const, since no ownership is given to the callee, + # but qemu C code frequently tweaks it. Set const=True for a stricter declaration. + def c_param_type(self, const=False): + c_type = self.c_type() + if const and c_type.endswith(pointer_suffix): + c_type = 'const ' + c_type + return c_type # Return the C type to be used where we suppress boxing. def c_unboxed_type(self):
@@ -221,10 +227,10 @@ class QAPISchemaBuiltinType(QAPISchemaType): def c_type(self): return self._c_type_name - def c_param_type(self): + def c_param_type(self, const=False): if self.name == 'str': return 'const ' + self._c_type_name - return self._c_type_name + return super().c_param_type(const) def json_type(self): return self._json_type_name
Signature · 1 line
2.28.0
PATCH 3/15 build-sys: add --with-rust{-target} & basic build infrastructure
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add the build-sys infrastructure to build Rust code. Introduce a top-level workspace, so various sub-projects (libraries, executables etc) can be developed together, sharing the dependencies and output directory.
If not Tier 1, many of the platforms QEMU supports are considered Tier 2: https://doc.rust-lang.org/nightly/rustc/platform-support.html
Rust is generally available on various distributions (thanks to Firefox, I suppose). If not, it can usually be installed with rustup by developpers.
configure will enable Rust support automatically if cargo is present. Rust support can be disabled --without-rust. When detecting windows cross building, it will use the $cpu-pc-windows-gnu target by default (more default mappings could be added over time). This can be changed with --with-rust-target=RTT.
--- Cargo.toml | 2 ++ configure | 18 ++++++++++++++++++ meson.build | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Cargo.toml
Cargo.toml new file +2 -0
@@ -0,0 +1,2 @@ +[workspace] +members = []
configure +18 -0
@@ -446,6 +446,8 @@ meson="" ninja="" skip_meson=no gettext="" +with_rust="auto" +with_rust_target="" bogus_os="no" malloc_trim="auto"
@@ -1519,6 +1521,12 @@ for opt do ;; --disable-libdaxctl) libdaxctl=no ;; + --with-rust) with_rust=yes + ;; + --without-rust) with_rust=no + ;; + --with-rust-target=*) with_rust_target="$optarg" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information"
@@ -1666,6 +1674,8 @@ Advanced options (experts only): --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS --cross-cc-ARCH=CC use compiler when building ARCH guest test cases --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests + --with-rust enable Rust compilation + --with-rust-target=RTT use the given Rust target triple --make=MAKE use specified make [$make] --python=PYTHON use specified python [$python] --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
@@ -1918,6 +1928,10 @@ if test -z "$ninja"; then done fi +if test "$with_rust" = auto && has cargo; then + with_rust=yes +fi + # Check that the C compiler works. Doing this here before testing # the host CPU ensures that we had a valid CC to autodetect the # $cpu var (and we should bail right here if that's not the case).
@@ -7046,6 +7060,10 @@ fi if test "$safe_stack" = "yes"; then echo "CONFIG_SAFESTACK=y" >> $config_host_mak fi +if test "$with_rust" = "yes" ; then + echo "CONFIG_WITH_RUST=y" >> $config_host_mak + echo "CONFIG_WITH_RUST_TARGET=$with_rust_target" >> $config_host_mak +fi # If we're using a separate build tree, set it up now. # DIRS are directories which we simply mkdir in the build tree;
meson.build +23 -0
@@ -73,6 +73,28 @@ if cpu in ['x86', 'x86_64'] } endif +with_rust = 'CONFIG_WITH_RUST' in config_host +cargo = find_program('cargo', required: with_rust) + +if with_rust + rs_target_triple = config_host['CONFIG_WITH_RUST_TARGET'] + if meson.is_cross_build() + # more default target mappings may be added over time + if rs_target_triple == '' and targetos == 'windows' + rs_target_triple = host_machine.cpu() + '-pc-windows-gnu' + endif + if rs_target_triple == '' + error('cross-compiling, but no Rust target-triple defined.') + endif + endif +endif + +if get_option('optimization') in ['0', '1', 'g'] + rs_build_type = 'debug' +else + rs_build_type = 'release' +endif + ################## # Compiler flags # ##################
@@ -1770,6 +1792,7 @@ endif if targetos == 'darwin' summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]} endif +summary_info += {'Rust support': with_rust} summary_info += {'ARFLAGS': config_host['ARFLAGS']} summary_info += {'CFLAGS': ' '.join(get_option('c_args') + ['-O' + get_option('optimization')]
Signature · 1 line
2.28.0
PATCH 4/15 build-sys: add a cargo-wrapper script
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Introduce a script to help calling cargo from Rust.
Cargo is the most convenient way to build Rust code, with various crates, and has many features that meson lacks in general for Rust. Trying to convert projects to meson automatically is an option I considered (see for ex https://github.com/badboy/bygge for ninja conversion), but the complexity of the task and the need of build.rs mechanism in various crates makes this endeavour out of scope at this point.
This script will help to invoke cargo in different ways. For now, it supports building static libraries. It sets up a common environment, run the compiler and grep its output for the linker flags. Finally it copies the built library to the expected meson output directory, and create a file with the linker arguments.
--- meson.build | 1 + scripts/cargo_wrapper.py | 101 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 scripts/cargo_wrapper.py
meson.build +1 -0
@@ -75,6 +75,7 @@ endif with_rust = 'CONFIG_WITH_RUST' in config_host cargo = find_program('cargo', required: with_rust) +cargo_wrapper = find_program('scripts/cargo_wrapper.py') if with_rust rs_target_triple = config_host['CONFIG_WITH_RUST_TARGET']
scripts/cargo_wrapper.py new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 5/15 qga/rust: build and link an empty static library
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Meson doesn't integrate very smoothly with Cargo. Use the cargo-wrapper script as a custom_target() always stale to build the Rust code. The "build-lib" command will produce a static library in the meson expected output directory, as well as link flags that must be employed to do the final link.
Those link flags can't be queried during configure time (Cargo doesn't have a user-queriable configure step), so we pass them to the linker thanks to @file argument support at build time.
--- Cargo.toml | 2 +- qga/Cargo.toml | 9 +++++++++ qga/lib.rs | 0 qga/meson.build | 18 +++++++++++++++++- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 qga/Cargo.toml create mode 100644 qga/lib.rs
Cargo.toml +1 -1
@@ -1,2 +1,2 @@ [workspace] -members = [] +members = ["qga"]
qga/Cargo.toml new file +9 -0
@@ -0,0 +1,9 @@ +[package] +name = "qga" +version = "0.1.0" +edition = "2018" +license = "GPLv2" + +[lib] +path = "lib.rs" +crate-type = ["staticlib"]
qga/lib.rs new file +0 -0
qga/meson.build +17 -1
@@ -45,9 +45,25 @@ qga_ss.add(when: 'CONFIG_WIN32', if_true: files( qga_ss = qga_ss.apply(config_host, strict: false) +qga_rs = declare_dependency() +if with_rust + cargo_qga = custom_target('cargo-qga', + build_by_default: true, + output: ['libqga.args', 'libqga.a'], + build_always_stale: true, + command: [cargo_wrapper, + 'build-lib', + meson.current_build_dir(), + meson.current_source_dir(), + meson.build_root(), + rs_build_type, + rs_target_triple]) + qga_rs = declare_dependency(link_args: '@' + cargo_qga.full_path(), sources: cargo_qga) +endif + qga = executable('qemu-ga', qga_ss.sources(), link_args: config_host['LIBS_QGA'].split(), - dependencies: [qemuutil, libudev], + dependencies: [qemuutil, libudev, qga_rs], install: true) all_qga = [qga]
Signature · 1 line
2.28.0
PATCH 6/15 rust: provide a common crate for QEMU
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This crates provides common bindings and facilities for QEMU C API shared by various projects.
Most importantly, it defines the conversion traits used to convert from C to Rust types. Those traits are largely adapted from glib-rs, since those have prooven to be very flexible, and should guide us to bind further QEMU types such as QOM. If glib-rs becomes a dependency, we should consider adopting glib translate traits. For QAPI, we need a smaller subset.
--- Cargo.toml | 5 +- rust/common/Cargo.toml | 11 ++ rust/common/src/error.rs | 109 ++++++++++++ rust/common/src/lib.rs | 10 ++ rust/common/src/qemu.rs | 30 ++++ rust/common/src/sys.rs | 58 +++++++ rust/common/src/translate.rs | 309 +++++++++++++++++++++++++++++++++++ 7 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 rust/common/Cargo.toml create mode 100644 rust/common/src/error.rs create mode 100644 rust/common/src/lib.rs create mode 100644 rust/common/src/qemu.rs create mode 100644 rust/common/src/sys.rs create mode 100644 rust/common/src/translate.rs
Cargo.toml +4 -1
@@ -1,2 +1,5 @@ [workspace] -members = ["qga"] +members = [ + "qga", + "rust/common", +]
rust/common/Cargo.toml new file +11 -0
@@ -0,0 +1,11 @@ +[package] +name = "common" +version = "0.1.0" +edition = "2018" +license = "GPLv2" + +[dependencies] +libc = "^0.2.76" + +[target."cfg(unix)".dependencies] +nix = "^0.18.0"
rust/common/src/error.rs new file +109 -0
109 lines not on this page · raw message
rust/common/src/lib.rs new file +10 -0
@@ -0,0 +1,10 @@ +mod error; +pub use error::*; + +mod qemu; +pub use qemu::*; + +mod translate; +pub use translate::*; + +pub mod sys;
rust/common/src/qemu.rs new file +30 -0
@@ -0,0 +1,30 @@ +use std::{ffi::CStr , ptr, str}; + +use crate ::{sys, translate}; + +/// A type representing an owned C QEMU Error. +pub struct CError (ptr::NonNull <sys::Error >); + +impl translate::FromQemuPtrFull <*mut sys::Error >for CError { +unsafe fn from_qemu_full (ptr: *mut sys::Error ) ->Self { +assert! (!ptr.is_null ()); +Self (ptr::NonNull ::new_unchecked (ptr)) + } +} + +impl CError { +pub fn pretty (&self) -> &str { +unsafe { +let pretty = sys::error_get_pretty (self.0 .as_ptr ()); +let bytes =CStr ::from_ptr (pretty).to_bytes (); + str::from_utf8 (bytes) + .unwrap_or_else (|err| str::from_utf8 (&bytes[..err.valid_up_to ()]).unwrap ()) + } + } +} + +impl Drop for CError { +fn drop (&mut self) { +unsafe { sys::error_free (self.0 .as_ptr ()) } + } +}
rust/common/src/sys.rs new file +58 -0
58 lines not on this page · raw message
rust/common/src/translate.rs new file +309 -0
309 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 7/15 scripts/qapi: add Rust sys bindings generation
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Generate the C QAPI types in Rust, with a few common niceties to Debug/Clone/Copy the Rust type.
An important question that remains unsolved to be usable with the QEMU schema in this version, is the handling of the 'if' compilation conditions. Since the 'if' value is a C pre-processor condition, it is hard to evaluate from Rust (we could implement a minimalistic CPP evaluator, or invoke CPP and somehow parse the output...).
The normal Rust way of handling conditional compilation is via #[cfg] features, which rely on feature arguments being passed to rustc from Cargo. This would require a long Rust feature list, and new 'if-cfg' conditions in the schema (an idea would be for Cargo to read features from meson in the future?)
--- meson.build | 4 +- scripts/qapi-gen.py | 16 ++- scripts/qapi/rs.py | 126 ++++++++++++++++++++ scripts/qapi/rs_sys.py | 254 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 394 insertions(+), 6 deletions(-) create mode 100644 scripts/qapi/rs.py create mode 100644 scripts/qapi/rs_sys.py
meson.build +3 -1
@@ -1147,7 +1147,9 @@ qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py', meson.source_root() / 'scripts/qapi/types.py', meson.source_root() / 'scripts/qapi/visit.py', meson.source_root() / 'scripts/qapi/common.py', - meson.source_root() / 'scripts/qapi-gen.py' + meson.source_root() / 'scripts/qapi/rs.py', + meson.source_root() / 'scripts/qapi/rs_sys.py', + meson.source_root() / 'scripts/qapi-gen.py', ] tracetool = [
scripts/qapi-gen.py +11 -5
@@ -16,10 +16,13 @@ from qapi.schema import QAPIError, QAPISchema from qapi.types import gen_types from qapi.visit import gen_visit +from qapi.rs_sys import gen_rs_systypes def main(argv): parser = argparse.ArgumentParser( description='Generate code from a QAPI schema') + parser.add_argument('-r', '--rust', action='store_true', + help="generate Rust code") parser.add_argument('-b', '--builtins', action='store_true', help="generate code for built-in types") parser.add_argument('-o', '--output-dir', action='store', default='',
@@ -45,11 +48,14 @@ def main(argv): print(err, file=sys.stderr) exit(1) - gen_types(schema, args.output_dir, args.prefix, args.builtins) - gen_visit(schema, args.output_dir, args.prefix, args.builtins) - gen_commands(schema, args.output_dir, args.prefix) - gen_events(schema, args.output_dir, args.prefix) - gen_introspect(schema, args.output_dir, args.prefix, args.unmask) + if args.rust: + gen_rs_systypes(schema, args.output_dir, args.prefix, args.builtins) + else: + gen_types(schema, args.output_dir, args.prefix, args.builtins) + gen_visit(schema, args.output_dir, args.prefix, args.builtins) + gen_commands(schema, args.output_dir, args.prefix) + gen_events(schema, args.output_dir, args.prefix) + gen_introspect(schema, args.output_dir, args.prefix, args.unmask) if __name__ == '__main__':
scripts/qapi/rs.py new file +126 -0
126 lines not on this page · raw message
scripts/qapi/rs_sys.py new file +254 -0
254 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 8/15 qga/rust: generate QGA QAPI sys bindings
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Use qapi-gen to generate low-level C sys bindings for QAPI types, include them to the build.
--- qga/Cargo.toml | 4 ++++ qga/lib.rs | 1 + qga/meson.build | 11 +++++++++++ qga/qapi_sys.rs | 5 +++++ 4 files changed, 21 insertions(+) create mode 100644 qga/qapi_sys.rs
qga/Cargo.toml +4 -0
@@ -4,6 +4,10 @@ version = "0.1.0" edition = "2018" license = "GPLv2" +[dependencies] +common = { path = "../rust/common" } +libc = "^0.2.76" + [lib] path = "lib.rs" crate-type = ["staticlib"]
qga/lib.rs +1 -0
@@ -0,0 +1 @@ +mod qapi_sys;
qga/meson.build +11 -0
@@ -47,10 +47,21 @@ qga_ss = qga_ss.apply(config_host, strict: false) qga_rs = declare_dependency() if with_rust + qga_qapi_rs_outputs = [ + 'qga-qapi-sys-types.rs', + ] + + qapi_gen_rs_files = custom_target('QGA QAPI Rust bindings', + output: qga_qapi_rs_outputs, + input: 'qapi-schema.json', + command: [ qapi_gen, '-r', '-o', 'qga', '-p', 'qga-', '@INPUT0@' ], + depend_files: qapi_gen_depends) + cargo_qga = custom_target('cargo-qga', build_by_default: true, output: ['libqga.args', 'libqga.a'], build_always_stale: true, + depends: [qapi_gen_rs_files], command: [cargo_wrapper, 'build-lib', meson.current_build_dir(),
qga/qapi_sys.rs new file +5 -0
@@ -0,0 +1,5 @@ +#![allow(dead_code)] +include! (concat! ( +env! ("MESON_BUILD_ROOT" ), +"/qga/qga-qapi-sys-types.rs" +));
Signature · 1 line
2.28.0
PATCH 9/15 scripts/qapi: add generation of Rust bindings for types
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Generate high-level idiomatic Rust code for the QAPI types, with to/from translations for C FFI.
- no conditional support yet
- C FFI types are mapped to higher-level types (char*->String, Foo*->Foo, has_foo/foo->Option<foo> etc)
- C enums are simply aliased
- C structures have corresponding Rust structures
- alternate are represented as Rust enum (TODO: to/from conversion)
- variants A are represented as Rust AEnum enums. A AEnum::kind() method allows to easily get the variant C kind enum value. The translation code also uses a helper enum ACEnum to hold the C pointer variant. There might be better ways to achieve the translation, but that one works for now.
- unions are represented in a similar way as C, as a struct S with a "u" member (since S may have extra 'base' fields). However, the discriminant isn't a member of S, as Rust enum variant don't need that.
- lists are represented as Vec and translated thanks to vec_to/from translate macros
--- meson.build | 1 + scripts/qapi-gen.py | 2 + scripts/qapi/rs.py | 78 +++++++ scripts/qapi/rs_types.py | 447 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 528 insertions(+) create mode 100644 scripts/qapi/rs_types.py
meson.build +1 -0
@@ -1149,6 +1149,7 @@ qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py', meson.source_root() / 'scripts/qapi/common.py', meson.source_root() / 'scripts/qapi/rs.py', meson.source_root() / 'scripts/qapi/rs_sys.py', + meson.source_root() / 'scripts/qapi/rs_types.py', meson.source_root() / 'scripts/qapi-gen.py', ]
scripts/qapi-gen.py +2 -0
@@ -17,6 +17,7 @@ from qapi.types import gen_types from qapi.visit import gen_visit from qapi.rs_sys import gen_rs_systypes +from qapi.rs_types import gen_rs_types def main(argv): parser = argparse.ArgumentParser(
@@ -50,6 +51,7 @@ def main(argv): if args.rust: gen_rs_systypes(schema, args.output_dir, args.prefix, args.builtins) + gen_rs_types(schema, args.output_dir, args.prefix, args.builtins) else: gen_types(schema, args.output_dir, args.prefix, args.builtins) gen_visit(schema, args.output_dir, args.prefix, args.builtins)
scripts/qapi/rs.py +78 -0
102 lines not on this page · raw message
scripts/qapi/rs_types.py new file +447 -0
447 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH 10/15 qga/rust: build Rust types
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- qga/lib.rs | 1 + qga/meson.build | 1 + qga/qapi.rs | 6 ++++++ 3 files changed, 8 insertions(+) create mode 100644 qga/qapi.rs
qga/lib.rs +1 -0
@@ -1 +1,2 @@ +mod qapi;mod qapi_sys;
qga/meson.build +1 -0
@@ -49,6 +49,7 @@ qga_rs = declare_dependency() if with_rust qga_qapi_rs_outputs = [ 'qga-qapi-sys-types.rs', + 'qga-qapi-types.rs', ] qapi_gen_rs_files = custom_target('QGA QAPI Rust bindings',
qga/qapi.rs new file +6 -0
@@ -0,0 +1,6 @@ +#![allow(dead_code)] +use common::*; + +new_ptr! (); + +include! (concat! (env! ("MESON_BUILD_ROOT" ),"/qga/qga-qapi-types.rs" ));
Signature · 1 line
2.28.0
PATCH 11/15 qga: add qmp! macro helper
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add a macro to help wrapping higher-level qmp handlers, by taking care of errors and return value pointer translation.
--- qga/lib.rs | 1 + qga/qmp/mod.rs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 qga/qmp/mod.rs
qga/lib.rs +1 -0
@@ -1,2 +1,3 @@mod qapi;mod qapi_sys; +mod qmp;
qga/qmp/mod.rs new file +36 -0
@@ -0,0 +1,36 @@ +use common::*; + +use crate ::*; + +macro_rules! qmp { +// the basic return value variant + ($e:expr, $errp:ident, $errval:expr) => {{ +assert! (!$errp.is_null ()); +unsafe { + *$errp = std::ptr::null_mut (); + } + +match $e { +Ok (val) => val, +Err (err) =>unsafe { + *$errp = err.to_qemu_full (); + $errval + }, + } + }}; +// the ptr return value variant + ($e:expr, $errp:ident) => {{ +assert! (!$errp.is_null ()); +unsafe { + *$errp = std::ptr::null_mut (); + } + +match $e { +Ok (val) => val.to_qemu_full ().into (), +Err (err) =>unsafe { + *$errp = err.to_qemu_full (); + std::ptr::null_mut () + }, + } + }}; +}
Signature · 1 line
2.28.0
PATCH 12/15 qga: implement get-host-name in Rust
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Use the "hostname" crate (https://github.com/svartalf/hostname)
(notice the wrong error message in our win32 implementation)
--- include/qemu/osdep.h | 10 ---------- qga/Cargo.toml | 1 + qga/commands.c | 20 ++++---------------- qga/lib.rs | 2 ++ qga/qmp/hostname.rs | 9 +++++++++ qga/qmp/mod.rs | 7 +++++++ tests/test-qga.c | 2 ++ util/oslib-posix.c | 35 ----------------------------------- util/oslib-win32.c | 13 ------------- 9 files changed, 25 insertions(+), 74 deletions(-) create mode 100644 qga/qmp/hostname.rs
include/qemu/osdep.h +0 -10
@@ -664,16 +664,6 @@ static inline void qemu_reset_optind(void)#endif } -/** -* qemu_get_host_name: -* @errp: Error object -* -* Operating system agnostic way of querying host name. -* -* Returns allocated hostname (caller should free), NULL on failure. -*/ -char *qemu_get_host_name (Error **errp); -/** * qemu_get_host_physmem: *
qga/Cargo.toml +1 -0
@@ -7,6 +7,7 @@ license = "GPLv2" [dependencies] common = { path = "../rust/common" } libc = "^0.2.76" +hostname = "^0.3.1" [lib] path = "lib.rs"
qga/commands.c +4 -16
@@ -512,25 +512,13 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)return -1 ; } +#ifndef CONFIG_WITH_RUST GuestHostName *qmp_guest_get_host_name (Error **errp) { -GuestHostName *result =NULL ; - g_autofree char *hostname = qemu_get_host_name(errp); - -/* -* We want to avoid using g_get_host_name() because that -* caches the result and we wouldn't reflect changes in the -* host name. -*/ - -if (!hostname) { - hostname =g_strdup ("localhost" ); - } - - result =g_new0 (GuestHostName,1 ); - result->host_name =g_steal_pointer (&hostname); -return result; +error_setg (errp,QERR_UNSUPPORTED ); +return NULL ; } +#endif GuestTimezone *qmp_guest_get_timezone (Error **errp) {
qga/lib.rs +2 -0
@@ -1,3 +1,5 @@ +pub use common::{err,Error ,Result }; +mod qapi;mod qapi_sys;mod qmp;
qga/qmp/hostname.rs new file +9 -0
@@ -0,0 +1,9 @@ +use crate ::*; + +pub (crate )fn get () ->Result <qapi::GuestHostName > { +let host_name = hostname::get ()? + .into_string () + .or_else (|_|err! ("Invalid hostname" ))?; + +Ok (qapi::GuestHostName { host_name }) +}
qga/qmp/mod.rs +7 -0
@@ -34,3 +34,10 @@ macro_rules! qmp { } }}; } + +mod hostname; + +#[no_mangle] +extern "C" fn qmp_guest_get_host_name (errp: *mut *mut sys::Error ) -> *mut qapi_sys::GuestHostName { +qmp! (hostname::get (), errp) +}
tests/test-qga.c +2 -0
@@ -863,6 +863,7 @@ static void test_qga_guest_exec_invalid(gconstpointer fix)static void test_qga_guest_get_host_name (gconstpointer fix) { +#ifdef CONFIG_WITH_RUST const TestFixture *fixture = fix;QDict *ret, *val;
@@ -874,6 +875,7 @@ static void test_qga_guest_get_host_name(gconstpointer fix)g_assert (qdict_haskey (val,"host-name" ));qobject_unref (ret); +#endif }static void test_qga_guest_get_timezone (gconstpointer fix)
util/oslib-posix.c +0 -35
@@ -804,41 +804,6 @@ void sigaction_invoke(struct sigaction *action, action->sa_sigaction (info->ssi_signo, &si,NULL ); } -#ifndef HOST_NAME_MAX -# ifdef _POSIX_HOST_NAME_MAX -# define HOST_NAME_MAX _POSIX_HOST_NAME_MAX -# else -# define HOST_NAME_MAX 255 -# endif -#endif - -char *qemu_get_host_name (Error **errp) -{ -long len =-1 ; - g_autofree char *hostname = NULL; - -#ifdef _SC_HOST_NAME_MAX - len =sysconf (_SC_HOST_NAME_MAX); -#endif /* _SC_HOST_NAME_MAX */ - -if (len <0 ) { - len =HOST_NAME_MAX ; - } - -/* Unfortunately, gethostname() below does not guarantee a -* NULL terminated string. Therefore, allocate one byte more -* to be sure. */ - hostname =g_new0 (char, len +1 ); - -if (gethostname (hostname, len) <0 ) { -error_setg_errno (errp, errno, -"cannot get hostname" ); -return NULL ; - } - -return g_steal_pointer (&hostname); -} -size_t qemu_get_host_physmem (void ) {#ifdef _SC_PHYS_PAGES
util/oslib-win32.c +0 -13
@@ -822,19 +822,6 @@ bool qemu_write_pidfile(const char *filename, Error **errp)return true; } -char *qemu_get_host_name (Error **errp) -{ -wchar_t tmp[MAX_COMPUTERNAME_LENGTH +1 ]; -DWORD size =G_N_ELEMENTS (tmp); - -if (GetComputerNameW (tmp, &size) ==0 ) { -error_setg_win32 (errp,GetLastError (),"failed close handle" ); -return NULL ; - } - -return g_utf16_to_utf8 (tmp, size,NULL ,NULL ,NULL ); -} -size_t qemu_get_host_physmem (void ) {MEMORYSTATUSEX statex;
Signature · 1 line
2.28.0
PATCH 13/15 qga: implement {get,set}-vcpus in Rust
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This is a rewrite of the C version (using the nix & winapi crates).
The main difference is that Rust doesn't let you mix const/mut logic, the way transfer_vcpu in C does. The Rust version does introduce some duplication, but is also more strict and can prevent mistakes.
--- qga/Cargo.toml | 6 ++ qga/commands-posix.c | 159 ------------------------------------------ qga/commands-win32.c | 76 -------------------- qga/commands.c | 14 ++++ qga/qmp/mod.rs | 18 +++++ qga/qmp/vcpus.rs | 161 +++++++++++++++++++++++++++++++++++++++++++ tests/test-qga.c | 2 + 7 files changed, 201 insertions(+), 235 deletions(-) create mode 100644 qga/qmp/vcpus.rs
qga/Cargo.toml +6 -0
@@ -9,6 +9,12 @@ common = { path = "../rust/common" } libc = "^0.2.76" hostname = "^0.3.1" +[target."cfg(unix)".dependencies] +nix = "^0.18.0" + +[target."cfg(windows)".dependencies] +winapi = { version = "^0.3.9", features = ["sysinfoapi", "winnt"] } + [lib] path = "lib.rs" crate-type = ["staticlib"]
qga/commands-posix.c +0 -159
165 lines not on this page · raw message
qga/commands-win32.c +0 -76
82 lines not on this page · raw message
qga/commands.c +14 -0
@@ -577,3 +577,17 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,return read_data; } + +#ifndef CONFIG_WITH_RUST +GuestLogicalProcessorList *qmp_guest_get_vcpus (Error **errp) +{ +error_setg (errp,QERR_UNSUPPORTED ); +return NULL ; +} + +int64_t qmp_guest_set_vcpus (GuestLogicalProcessorList *vcpus,Error **errp) +{ +error_setg (errp,QERR_UNSUPPORTED ); +return 0 ; +} +#endif
qga/qmp/mod.rs +18 -0
@@ -41,3 +41,21 @@ mod hostname;extern "C" fn qmp_guest_get_host_name (errp: *mut *mut sys::Error ) -> *mut qapi_sys::GuestHostName {qmp! (hostname::get (), errp) } + +mod vcpus; + +#[no_mangle] +extern "C" fn qmp_guest_get_vcpus ( + errp: *mut *mut sys::Error , +) -> *mut qapi_sys::GuestLogicalProcessorList { +qmp! (vcpus::get (), errp) +} + +#[no_mangle] +extern "C" fn qmp_guest_set_vcpus ( + vcpus: *const qapi_sys::GuestLogicalProcessorList , + errp: *mut *mut sys::Error , +) -> libc::c_longlong { +let vcpus =unsafe {from_qemu_none (qapi::NewPtr (vcpus)) }; +qmp! (vcpus::set (vcpus), errp, -1 ) +}
qga/qmp/vcpus.rs new file +161 -0
161 lines not on this page · raw message
tests/test-qga.c +2 -0
@@ -307,6 +307,7 @@ static void test_qga_info(gconstpointer fix)static void test_qga_get_vcpus (gconstpointer fix) { +#ifdef CONFIG_WITH_RUST const TestFixture *fixture = fix;QDict *ret;QList *list;
@@ -323,6 +324,7 @@ static void test_qga_get_vcpus(gconstpointer fix)g_assert (qdict_haskey (qobject_to (QDict, entry->value),"logical-id" ));qobject_unref (ret); +#endif }static void test_qga_get_fsinfo (gconstpointer fix)
Signature · 1 line
2.28.0
PATCH 14/15 travis: add Rust
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- .travis.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
.travis.yml +17 -1
@@ -23,6 +23,8 @@ addons: apt: packages: # Build dependencies + - cargo + - rustc - libaio-dev - libattr1-dev - libbrlapi-dev
@@ -71,7 +73,7 @@ env: global: - SRC_DIR=".." - BUILD_DIR="build" - - BASE_CONFIG="--disable-docs --disable-tools" + - BASE_CONFIG="--disable-docs --disable-tools --with-rust" - TEST_BUILD_CMD="" - TEST_CMD="make check V=1" # This is broadly a list of "mainline" softmmu targets which have support across the major distros
@@ -258,6 +260,8 @@ jobs: # Extra toolchains - gcc-9 - g++-9 + - cargo + - rustc # Build dependencies - libaio-dev - libattr1-dev
@@ -325,6 +329,8 @@ jobs: dist: focal addons: apt_packages: + - cargo + - rustc - libaio-dev - libattr1-dev - libbrlapi-dev
@@ -358,6 +364,8 @@ jobs: dist: focal addons: apt_packages: + - cargo + - rustc - libaio-dev - libattr1-dev - libbrlapi-dev
@@ -390,6 +398,8 @@ jobs: dist: bionic addons: apt_packages: + - cargo + - rustc - libaio-dev - libattr1-dev - libbrlapi-dev
@@ -432,6 +442,8 @@ jobs: dist: bionic addons: apt_packages: + - cargo + - rustc - libaio-dev - libattr1-dev - libcap-ng-dev
@@ -461,6 +473,8 @@ jobs: dist: bionic addons: apt_packages: + - cargo + - rustc - libgcrypt20-dev - libgnutls28-dev env:
@@ -472,6 +486,8 @@ jobs: compiler: clang addons: apt_packages: + - cargo + - rustc - libaio-dev - libattr1-dev - libbrlapi-dev
Signature · 1 line
2.28.0
PATCH 15/15 rust: use vendored-sources
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Most likely, QEMU will want tighter control over the sources, rather than relying on crates.io downloading, use a git submodule with all the dependencies.
"cargo vendor" makes that simple.
--- .cargo/config | 5 +++++ .gitmodules | 3 +++ configure | 8 ++++++++ rust/vendored | 1 + scripts/cargo_wrapper.py | 1 + 5 files changed, 18 insertions(+) create mode 100644 .cargo/config create mode 160000 rust/vendored
.cargo/config new file +5 -0
@@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "rust/vendored"
.gitmodules +3 -0
@@ -64,3 +64,6 @@ [submodule "roms/vbootrom"] path = roms/vbootrom url = https://git.qemu.org/git/vbootrom.git +[submodule "rust/vendored"] + path = rust/vendored + url = https://github.com/elmarco/qemu-rust-vendored.git
configure +8 -0
@@ -1932,6 +1932,14 @@ if test "$with_rust" = auto && has cargo; then with_rust=yes fi +case "$with_rust" in + yes) + if test -e "${source_path}/.git" && test $git_update = 'yes' ; then + git_submodules="${git_submodules} rust/vendored" + fi + ;; +esac + # Check that the C compiler works. Doing this here before testing # the host CPU ensures that we had a valid CC to autodetect the # $cpu var (and we should bail right here if that's not the case).
rust/vendored new file +1 -0
@@ -0,0 +1 @@ +Subproject commit 71ee65d042606d18de3175d67f9e4e4b78a1f865
scripts/cargo_wrapper.py +1 -0
@@ -51,6 +51,7 @@ def build_lib(args: argparse.Namespace) -> None: target_dir, "--manifest-path", manifest_path, + "--offline", ] if args.target_triple: cargo_cmd += ["--target", args.target_triple]
Signature · 1 line
2.28.0
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PoCv2 00/15] Rust binding for QAPI (qemu-ga only, for now)
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
e5abacf rust: use vendored-sources
f8125dc travis: add Rust0bb6095b qga: implement {get,set}-vcpus in Rust
6f1cb07 qga: implement get-host-name in Rust
6cc3f63 qga: add qmp! macro helper
abc816c qga/rust: build Rust types
8273b34 scripts/qapi: add generation of Rust bindings for types 3068424 qga/rust: generate QGA QAPI sys bindings
8d23431 scripts/qapi: add Rust sys bindings generation eb4bb2d rust: provide a common crate for QEMU
f19d443 qga/rust: build and link an empty static library 03097d9 build-sys: add a cargo-wrapper script
d8ec366 build-sys: add --with-rust{-target} & basic build infrastructure e524eda scripts/qapi: teach c_param_type() to return const argument type e68868d mingw: fix error __USE_MINGW_ANSI_STDIO redefined
=== OUTPUT BEGIN ===
1/15 Checking commit e68868d9d68b (mingw: fix error __USE_MINGW_ANSI_STDIO redefined) 2/15 Checking commit e524eda108f7 (scripts/qapi: teach c_param_type() to return const argument type)
WARNING: line over 80 characters
#27: FILE: scripts/qapi/schema.py:171:
+ # The argument should be considered const, since no ownership is given to the callee,
WARNING: line over 80 characters
#28: FILE: scripts/qapi/schema.py:172:
+ # but qemu C code frequently tweaks it. Set const=True for a stricter declaration.
total: 0 errors, 2 warnings, 28 lines checked
Patch 2/15 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/15 Checking commit d8ec36655d29 (build-sys: add --with-rust{-target} & basic build infrastructure)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#29:
new file mode 100644
total: 0 errors, 1 warnings, 85 lines checked
Patch 3/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/15 Checking commit 03097d99222b (build-sys: add a cargo-wrapper script)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #39:
new file mode 100644
WARNING: line over 80 characters
#82: FILE: scripts/cargo_wrapper.py:39:
+ target_dir, args.target_triple, args.build_type, "lib" + package_name + ".a"
WARNING: line over 80 characters
#119: FILE: scripts/cargo_wrapper.py:76:
+ "Environment: " + " ".join(["{}={}".format(k, v) for k, v in env.items()])
total: 0 errors, 3 warnings, 108 lines checked
Patch 4/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/15 Checking commit f19d443c4992 (qga/rust: build and link an empty static library)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #29:
new file mode 100644
total: 0 errors, 1 warnings, 38 lines checked
Patch 5/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/15 Checking commit eb4bb2d04ac5 (rust: provide a common crate for QEMU)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #32:
new file mode 100644
total: 0 errors, 1 warnings, 533 lines checked
Patch 6/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/15 Checking commit 8d23431862a8 (scripts/qapi: add Rust sys bindings generation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #79:
new file mode 100644
WARNING: line over 80 characters
#182: FILE: scripts/qapi/rs.py:99:
+ value = ''.join(word.title() for word in filter(None, re.split("[-_]+", value)))
ERROR: line over 90 characters
#270: FILE: scripts/qapi/rs_sys.py:55:
+ rs_systype=rs_systype(memb.type.c_type(), ''), rs_name=rs_name(memb.name))
WARNING: line over 80 characters
#332: FILE: scripts/qapi/rs_sys.py:117:
+ ret += gen_rs_sys_object(v.type.name, v.type.ifcond, v.type.base,
WARNING: line over 80 characters
#429: FILE: scripts/qapi/rs_sys.py:214:
+ rs_name=rs_name(name), rs_systype=rs_systype(element_type.c_type(), ''))
total: 1 errors, 4 warnings, 422 lines checked
Patch 7/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
8/15 Checking commit 306842468f88 (qga/rust: generate QGA QAPI sys bindings)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #61:
new file mode 100644
total: 0 errors, 1 warnings, 37 lines checked
Patch 8/15 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/15 Checking commit 8273b3417e30 (scripts/qapi: add generation of Rust bindings for types)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #179:
new file mode 100644
WARNING: line over 80 characters
#227: FILE: scripts/qapi/rs_types.py:44:
+''', var_name=var_name, rs_type=rs_type(type_name, ''), rs_systype=rs_systype(type_name))
ERROR: line over 90 characters
#231: FILE: scripts/qapi/rs_types.py:48:
+ (stash_.0 as *mut std::ffi::c_void, %(rs_name)sCEnum::%(var_name)s(stash_.1))
WARNING: line over 80 characters
#252: FILE: scripts/qapi/rs_types.py:69:
+ fn to_qemu_none(&'a self) -> Stash<'a, *mut std::ffi::c_void, %(rs_name)sEnum> {
ERROR: line over 90 characters
#368: FILE: scripts/qapi/rs_types.py:185:
+ arms += mcgen('%(rs_name)sEnum::%(kind_name)s(_) => qapi_sys::%(rs_name)sUnion { %(var_name)s: %(var_type)s { data: u_ptr_ as *mut _ } },',
ERROR: line over 90 characters
#369: FILE: scripts/qapi/rs_types.py:186:
+ rs_name=rs_name(name), kind_name=to_camel_case(var.name), var_name=rs_name(var.name), var_type=rs_systype(var.type.c_name()))
WARNING: line over 80 characters
#395: FILE: scripts/qapi/rs_types.py:212:
+ fn to_qemu_none(&'a self) -> Stash<'a, *mut qapi_sys::%(rs_name)s, %(rs_name)s> {
WARNING: line over 80 characters
#406: FILE: scripts/qapi/rs_types.py:223:
+ let ptr = sys::g_malloc0(std::mem::size_of::<*const %(rs_name)s>()) as *mut _;
ERROR: line over 90 characters
#414: FILE: scripts/qapi/rs_types.py:231:
+ sys_memb=', '.join(sys_memb), memb_none=memb_none, memb_full=memb_full, stash=', '.join(stash))
ERROR: line over 90 characters
#459: FILE: scripts/qapi/rs_types.py:276:
+ %(enum)s::%(variant)s => { %(rs_name)sEnum::%(variant)s(from_qemu_none(sys.u.%(memb)s.data as *const _)) },
ERROR: line over 90 characters
#487: FILE: scripts/qapi/rs_types.py:304:
+ rs_type=rs_type(memb.type.c_type(), '', optional=memb.optional), rs_name=rsname)
total: 6 errors, 5 warnings, 570 lines checked
Patch 9/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
10/15 Checking commit abc816c08984 (qga/rust: build Rust types)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #30:
new file mode 100644
total: 0 errors, 1 warnings, 15 lines checked
Patch 10/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
11/15 Checking commit 6cc3f639e6bc (qga: add qmp! macro helper)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #22:
new file mode 100644
total: 0 errors, 1 warnings, 39 lines checked
Patch 11/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
12/15 Checking commit 6f1cb07dcab6 (qga: implement get-host-name in Rust)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #92:
new file mode 100644
total: 0 errors, 1 warnings, 150 lines checked
Patch 12/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
13/15 Checking commit 0bb6095b4294 (qga: implement {get,set}-vcpus in Rust)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #339:
new file mode 100644
total: 0 errors, 1 warnings, 472 lines checked
Patch 13/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
14/15 Checking commit f8125dcffce4 (travis: add Rust)
15/15 Checking commit e5abacf1af78 (rust: use vendored-sources)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17:
new file mode 100644
total: 0 errors, 1 warnings, 33 lines checked
Patch 15/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]