From: Sergio Lopez <slp@redhat.com>
To: Alex Carter <alex.j.carter@gmail.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
stefanha@gmail.com, "Markus Armbruster" <armbru@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>, Alexander <alxndr@bu.edu>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Dave Gilbert" <dgilbert@redhat.com>
Subject: Re: Why QEMU should move from C to Rust (clickbait alert ;))
Date: Thu, 27 Aug 2020 10:08:01 +0200 [thread overview]
Message-ID: <20200827080720.6eks7eoj4m2zlp6e@mhamilton> (raw)
In-Reply-To: <CAB12sgLhsgu282Ye=m2pjhdq7BE-zy2LHEdfxuxDdDLEas5+Gg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4022 bytes --]
On Fri, Aug 21, 2020 at 04:18:03PM -0400, Alex Carter wrote:
> Hi everyone,
>
> My name is Alex, I’m a student at the University of Michigan and I just
> completed an internship at IBM Research. There, I have been working on a
> project very related to this topic. I tested using Cloud Hypervisor’s
> Rust-based vhost-user virtiofs and block devices with QEMU. Bigger picture,
> I wanted to explore the implications of using Rust for vhost-user devices
> in QEMU.
>
>
>
> I agree with the points from the original post, namely:
>
> · C programming bugs are responsible for a large number of CVEs, and
> specifically CVEs coming from the implementations of virtual devices.
>
> · As a programming language, Rust has matured to a point where it is
> worth considering it more seriously for production use. It has extensive
> libraries and community support. Many big players in the industry are
> already using Rust for production workloads.
>
>
>
> Full Transparency: the Drawbacks:
>
> It would be deceptive to only showcase Rust in an ideal light.
>
> · The benchmarks I ran show a noticeable performance hit from
> switching to a RustVMM implementation of a virtiofsd device.
I think it'd be interesting to be able to repeat those tests in a
different environment. I ran multiple benchmarks in the past comparing
vhost-user-blk (Rust) vs. qemu/contrib/vhost-user-blk (C) and
vhost-user-fs (Rust) vs virtiofsd (C) and never found that performance
hit.
Much on contrary, I found Rust's zero-cost abstractions promise to
live up even with very idiomatic chunks of code (such as
vm-virtio::Queue).
> · While Rust has matured greatly, it still is missing a bit. One
> example of this that came up was that the rust compiler does not have
> Control Flow Integrity (CFI) features. While these are not as important as
> in “unsafe” languages such as C, the ability to express unsafe portions of
> code does allow for some types of memory bugs – although to a much lesser
> extent (an interesting case of this surfaced from Firecracker, and the
> handling of mmio [1]). So further protections such as Control Flow
> Integrity can still be desirable, even with rust code.
>
> · There have been years of optimization work put into the C
> implementations of these devices, and it’s hard to evaluate how optimized
> the relatively novel rust implementations are.
>
> A piece of exciting news is that many of these drawbacks show a pathway for
> future improvement. Improvements to rust infrastructure are very realistic.
> Rust boils down to LLVM just like C, so porting over C’s CFI features
> should be feasible. If more development resources are put into the RustVMM
> project, there is no reason their implementations can’t be as optimized as
> the C versions, and this could be greatly aided by expertise coming from
> the QEMU communities familiarity with these topics.
>
>
>
> I believe vhost-user devices are an excellent place to start since It
> lowers the entry barrier for developing in Rust. The device only has to
> interface with the C-based QEMU binary through a standardized protocol. It
> removes many worries of moving entirely away from C, since adding a set of
> Rust devices would simply be giving more options and room to explore.
>
>
>
> I am putting together the scripts I used for all of the tests at this repo:
>
> https://github.com/Alex-Carter01/Qemu-Rust-Testing
>
> I am working to standardize everything to make it easier to replicate. I
> would love any community involvement if people wanted to see how results
> differ based on the hardware setup, build configuration of the devices etc.
Sounds good. What kind of help would you need?
Thanks!
Sergio.
> The repo also has links to a recording of my original presentation and the
> slides I was using if you would like to look at that format or see the
> discussion which came out of it.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-08-27 8:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 20:18 Why QEMU should move from C to Rust (clickbait alert ;)) Alex Carter
2020-08-27 8:08 ` Sergio Lopez [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-06 10:24 Stefan Hajnoczi
2020-08-06 11:08 ` Daniel P. Berrangé
2020-08-06 13:39 ` Alex Bennée
2020-08-07 9:28 ` Stefan Hajnoczi
2020-08-07 9:44 ` Stefan Hajnoczi
2020-08-06 11:51 ` Sergio Lopez
2020-08-06 12:01 ` Daniel P. Berrangé
2020-08-06 13:38 ` Sergio Lopez
2020-08-06 13:43 ` Daniel P. Berrangé
2020-08-07 9:27 ` Stefan Hajnoczi
2020-08-07 9:45 ` Stefan Hajnoczi
2020-08-07 9:39 ` Stefan Hajnoczi
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=20200827080720.6eks7eoj4m2zlp6e@mhamilton \
--to=slp@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex.j.carter@gmail.com \
--cc=alxndr@bu.edu \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).