From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2E51C83F27 for ; Wed, 16 Jul 2025 12:20:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uc17e-0003Pt-Re; Wed, 16 Jul 2025 08:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uc0vs-00055D-86 for qemu-rust@nongnu.org; Wed, 16 Jul 2025 08:08:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uc0vp-0002h9-M3 for qemu-rust@nongnu.org; Wed, 16 Jul 2025 08:08:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752667694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:autocrypt:autocrypt; bh=QVYkEoq3jsjPIHsmpjc5W3zKYgt4DxW3gtiAiotlAGY=; b=YmO7079nR6TGK8e+COskZ/T9SDBLYVSWAMEf7iHOJTwFwUlJ4G86MdrsMPfld7WQV5YbfK nCg6ENpjdFYu5+MNJbPv8vNntSaKCJ0cspZF+BwZgXg1jX37m3TwL2/ACmlZzIMwrzrVBb JFfIL/K537J4q65w5k7TOYHC+fCvTRE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-P9Wp7lS1NPeM3RZFlu0HMQ-1; Wed, 16 Jul 2025 08:08:13 -0400 X-MC-Unique: P9Wp7lS1NPeM3RZFlu0HMQ-1 X-Mimecast-MFC-AGG-ID: P9Wp7lS1NPeM3RZFlu0HMQ_1752667692 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3af3c860ed7so2899029f8f.1 for ; Wed, 16 Jul 2025 05:08:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752667691; x=1753272491; h=content-transfer-encoding:autocrypt:subject:to:content-language :from:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=QVYkEoq3jsjPIHsmpjc5W3zKYgt4DxW3gtiAiotlAGY=; b=CjRVa6YHsSC3Mcu0Qj7qbuhRjtu+6TOpT6N6dy2fUAUSsy9loM14nso+3Mv/d8Dahu u1xEXCokQ3i1Z4QvmEwyaB+TyW7RJdnOlmwzoyg/4qoymAyPcTskYdjmO4iFOoD9ZwXn 492mDqfMvUlXucpT3tJLZga4N4WAMwucyDhZjHnOtlDEL0xnwRevqDLgPiT2hUTSmOxG YHwNQIMdTUGtYlBH/J+gKL3TLAza6KVOal4JIfn8eMXRi/Vs8qmj+uuO3oKoOFooq7vB L06udCrzrlT9iZWXNxER/A9WHFGJ3is2eEY0dBXJ8Xx8eY5tnhwBviKNSX5tAY2DzZvC tDUQ== X-Forwarded-Encrypted: i=1; AJvYcCVyFHws9FTn+XOlSDV+a3OKtDy1DDEPb48V/wjQp4X5npygzKNtux6xpkRXmHoSwP9OWnHhFwT8PaQ=@nongnu.org X-Gm-Message-State: AOJu0Yyzs1mfLYATZpL+5UGodCgKODgf3DmnZxXEx6HSQHLB1AWdbc+Q Fitr+IiHQUDAF32EMxeKWo0lt+UlliW49aZGv2ZfhE6p8NCzxy1eU95/cYf3PZ86xZuQjwQ/H3B Q04+qZKX8ncD/Ltwy/6m0v9hxL369O1V7D/yRI8+H52gKFFfb0cJSJCPBIFRc1so= X-Gm-Gg: ASbGncvJVLADI5OCSgKrbdDkGeK+52NVmL49rwMPQWmV/DAaWlvS5tFek/uje+AnC2Q 7GqtWU098831afGLfiLUc/JkAGunk5QYgpElPtI+WY2v16cFRCFOHMS5sHiNeEpKJ9VTRaGAG0e s+rwH1HlEEpuwMd4yIHH5HMYY74nTwPrG+1Q0Of1e7gQ9CzhbAke2oeoVlsxM9B+EjGFRnKsIVU JFHHVflXKiL5/DP+zK2Facpg9jMwaLNLxsI3SsU8SaB02ex0BMmJ8euPGH6qc+xoF58c0pPdcpy dZjAZ5eSdaT3+NzBJPT0LEbbmoM0OlWsQ2spmWMaaG0= X-Received: by 2002:a05:6000:26d3:b0:3a4:febd:39f2 with SMTP id ffacd0b85a97d-3b60e523ce1mr1878465f8f.37.1752667691257; Wed, 16 Jul 2025 05:08:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuYAXreTlfmcE4wrzUoBLGnJ+EuOnJffkdqabBpQbbfzv6fFHRzsFGVO2tYROSDgvCTqROZw== X-Received: by 2002:a05:6000:26d3:b0:3a4:febd:39f2 with SMTP id ffacd0b85a97d-3b60e523ce1mr1878432f8f.37.1752667690636; Wed, 16 Jul 2025 05:08:10 -0700 (PDT) Received: from [192.168.10.48] ([151.49.73.155]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-45627898725sm33167265e9.1.2025.07.16.05.08.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jul 2025 05:08:09 -0700 (PDT) Message-ID: Date: Wed, 16 Jul 2025 14:08:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Paolo Bonzini To: qemu-devel , qemu-rust@nongnu.org Subject: Rust in QEMU update, July 2025 Autocrypt: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h4hWmIW7iNhPjX1iybXfmb1gAFfjtHfL xRUr64svXpyfJMScIQtBAm0ihWPltXkyITA92ngCmPdHa6M1hMh4RDX+Jf1fiWubzp1voAg0 JBrdmNZSQDz0iKmSrx8xkoXYfA3bgtFN8WJH2xgFL28XnqY4M6dLhJwV3z08tPSRqYFm4NMP dRsn0/7oymhneL8RthIvjDDQ5ktUjMe8LtHr70OZE/TT88qvEdhiIVUogHdo4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RecY9m-JHpV-g1loHaErXLS76sOc6rhA6Qvka1zm_sU_1752667692 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-rust@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: QEMU Rust-related patches and discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-rust-bounces+qemu-rust=archiver.kernel.org@nongnu.org Sender: qemu-rust-bounces+qemu-rust=archiver.kernel.org@nongnu.org While I have generally given a three months cadence to the update, this one is a bit early---mostly due to the upcoming freeze, and many subprojects having reached a point where an update is useful. Summary ''''''' Achievements Almost full safety for device code; logging and initial work on tracing; starting to look at interoperability of C<->Rust data structures Current blockers Static linking of Rust stdlib; formalize design for QAPI/QMP integration; bump to Rust 1.83 for key safety features Next steps Complete tracing and DMA support; finalize 1.83 update; explore new devices written in Rust and report on holes in bindings Table of contents ''''''''''''''''' * Status in QEMU 10.1 * Build system * Improvements to devices * Cleanups * Next steps Status in QEMU 10.1 ''''''''''''''''''' For platform availability, the only change from 10.0 to 10.1 is that the minimum supported Rust version is now 1.77 rather than 1.63. This means there's no support for building QEMU with Rust enabled with Debian bookworm, *on mips64el* only. Other architectures remain buildable on bookworm too. With the update to Meson 1.8, support for clippy and rustdoc moved from QEMU's meson.build files to Meson itself. The update also made it possible to use --enable-modules and --enable-rust together. There are two new dependencies: anyhow, a commonly used crate providing a general purpose Error implementation; and foreign, a crate that I wrote to provide utilities for conversion between C and Rust data types. Both are used to provide access to ``Error*`` from Rust code. As soon as the Rust version is bumped again from 1.77 to 1.83, Rust devices will need basically no unsafe Rust code. This means that there will be a practical benefit to writing *new* devices in Rust. If any devices are contributed that are written in Rust and do not have a C counterpart, it may be worth splitting "enable Rust" from "enable all devices written in Rust". This way, the C versions of the pl011 and HPET devices remain available on platforms without a new-enough compiler version. Build system '''''''''''' Rust is still not enabled by default. The main reason is that Rust staticlibs also link statically to the Rust standard library, thus bloating the resulting executable (and making distros hate us as well). A pending Meson pull request[1] will fix this, as long as ``system/main.c`` is rewritten or wrapped in Rust. As mentioned in the earlier updates, in parallel to QEMU work I'm looking at improvements to Meson's support for Cargo and Rust. While there weren't many news over the last few months, the plan is to add support for cross compilation and the ``[lints]`` section to its Cargo support. I have therefore made a proposal for tighter integration between ``meson.build`` files and Cargo packages[2]. .. [1] https://github.com/mesonbuild/meson/pull/14224 .. [2] https://github.com/mesonbuild/meson/issues/14639 Stefano Garzarella is looking at merging the ``buildigvm`` tool into QEMU's ``contrib/`` directory. ``buildigvm`` is written in Rust, but it has a relatively large set of dependencies that make it impractical (for now) to drive its build from Meson. While for now Stefano is going to call out to Cargo in order to build ``buildigvm``, this is not expected to last forever; ``buildigvm`` will provide a further testbed for changes to Meson. Improvements to devices ''''''''''''''''''''''' New in 10.1 is logging support, as well as ``Error*`` bindings so that ``realize()`` implementations can fail. With the recent merge of a procedural macro for property support, there is basically no remaining unsafe code in devices outside the QOM ``instance_init`` method. Merging the improvements to qdev and VMState however will require a bump of the minimum supported Rust version to 1.83.0. The remaining missing feature for pl011 and HPET is tracing. A student is working on it and he has the simpletrace backend working, with syslog and log coming next. The plan for the dtrace backend is to use the ``probe`` crate[1], possibly extending it to support ust as well. .. [1] https://github.com/cuviper/probe-rs Zhao is looking into using the ``vm-memory`` crate in QEMU. This allows devices to perform DMA, including HPET. Cleanups '''''''' With the Rust bindings and the first couple of devices taking shape, it's time to clean up some of the things that have grown a bit more haphazardly over the last year. One important change, which should make it easier for Kevin to continue his work on block layer bindings, is to split the ``qemu-api`` crate in multiple parts, roughly matching the ``declare_dependency()`` statements used for the C code. Also, pl011 and HPET were developed independently and sometimes have different idioms where we could aim for unification. The main two are: * name of files (the PL011 main source file is ``device.rs``, but the HPET one is ``hpet``.rs) and split between device code and a registers module * adjusting HPET to use the ``bilge`` crate and/or the ``bits`` macro These could be good tasks for someone who is learning Rust. Next steps '''''''''' The highest-priority missing feature, tracing, is being worked on; as is DMA. The next step could be better integration of QAPI/QMP (for which Marc-André Lureau had a prototype already in 2022) and support for QOM properties. Last month we had a discussion on whether to continue with Marc-André's approach of converting between C and Rust representations; implement QEMU's ``Visitor`` interface for Rust data structures; or focus on conversion between ``QObject`` and Rust, using ``serde`` for code generation. Markus leaned towards the latter (though it must be said that there's no code for it yet, and there could be unforeseen obstacles). Finally, I'm going to take a step back from actively writing Rust code for QEMU for some time, but I'll be available for reviews and will keep looking at upstream Meson support for the language. Paolo