qemu-rust
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/11] rust: Add some block layer bindings


From: Kevin Wolf
Subject: Re: [PATCH 03/11] rust: Add some block layer bindings
Date: Wed, 12 Feb 2025 14:13:22 +0100

Am 12.02.2025 um 10:29 hat Paolo Bonzini geschrieben:
> On 2/11/25 22:43, Kevin Wolf wrote:
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >   rust/wrapper.h                | 4 ++++
> >   meson.build                   | 1 +
> >   rust/qemu-api/src/zeroable.rs | 5 +++--
> >   3 files changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/rust/wrapper.h b/rust/wrapper.h
> > index 41be87adcf..c3e1e6f9cf 100644
> > --- a/rust/wrapper.h
> > +++ b/rust/wrapper.h
> > @@ -53,3 +53,7 @@ typedef enum memory_order {
> >   #include "chardev/char-fe.h"
> >   #include "qapi/error.h"
> >   #include "chardev/char-serial.h"
> > +#include "block/block.h"
> > +#include "block/block_int.h"
> > +#include "block/qdict.h"
> > +#include "qapi/qapi-visit-block-core.h"
> > diff --git a/meson.build b/meson.build
> > index 30aae6b3c3..154195bc80 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -4045,6 +4045,7 @@ if have_rust
> >       '--with-derive-default',
> >       '--no-layout-tests',
> >       '--no-prepend-enum-name',
> > +    '--allowlist-item', 'EINVAL|EIO',
> 
> I've got some errno bindings that I wrote for chardev, I'll send them
> shortly.

Yes, we definitely need some proper bindings there. I'm already tired of
writing things like this:

    return -(bindings::EINVAL as std::os::raw::c_int)

Or even:

    return e
        .raw_os_error()
        .unwrap_or(-(bindings::EIO as std::os::raw::c_int))

Which actually already shows that your errno binding patch does the
opposite direction of what I needed in this series. My problem is when I
need to return an int to C, and I either have an io::Result or I just
want to directly return an errno value. So we'll have to add that part
to your errno module, too.

Kevin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]