From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998313; cv=none; d=zohomail.com; s=zohoarc; b=j6JMeibvCfzskB7Hnge3WzpJ1LA1EBkHQkpTl1oXJZH0XKRjC/mMIC06HrlPKPZimEMSkY1IYMR002hDVY6p5eVR6FtuSnowZ17NDFOurcFyJscIz7GjHy4hzDvvv8Im/+4tnniIRuYjcT/KbtIJoUHV9rlB570MGeOgV4/hC4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998313; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=OQ8XtN0i9uB/gRRK2xzfUT/u47Sg0mX2wOMpc2ThCm0=; b=fv1U8IJWtv7YXuqksWu6GPDyIfFkNST9fJlY8DrP2kPBw3xsvcRhZFNNiAgp0UseujZJKvFJC1dA1jrkAaZDoonAYDpLrAIH6ZJtOjd6kEI+hEV7a4OKw29fRAsh5BmXxCbcEd4Ms/UtOQQoUMPSniEMiASL5RmYJEFgqpnPh1E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998313613881.5830078099723; Tue, 15 Oct 2024 06:18:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hQx-000223-70; Tue, 15 Oct 2024 09:17:55 -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 1t0hQs-00021W-VE for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:17:51 -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 1t0hQr-0001D2-Jk for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:17:50 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-akAhcvkeOZSEanfaVGVRtg-1; Tue, 15 Oct 2024 09:17:44 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d462b64e3so2180711f8f.3 for ; Tue, 15 Oct 2024 06:17:44 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fbf8567sm1563603f8f.76.2024.10.15.06.17.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OQ8XtN0i9uB/gRRK2xzfUT/u47Sg0mX2wOMpc2ThCm0=; b=CSONrs4YyoHzXo8fF4/1LReJmpxvYuxcAGUDu47plKsjR2qLiObX8RnPYByHjSpvBAHQdH dB0p2z4ml/tdMVmtOZ5naRWhYy6B/dEzBT54HC/Mk5kxkVfjcDRMR9yDOELj3SXZDT9h+w zoIFBteI1OEA5BkwMcTHMMo06IHXfVw= X-MC-Unique: akAhcvkeOZSEanfaVGVRtg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998263; x=1729603063; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OQ8XtN0i9uB/gRRK2xzfUT/u47Sg0mX2wOMpc2ThCm0=; b=AmXoFyWs5VYuon5UojwaOkSJHsyJRKghi8hQaNKFWISjQS6jGeriqiOEI7a+9uOKp3 IlinhRYAYKS4t1wPgXoxIAu/BtsDLEq8nqgbPCunc0MhYCfDtIHI8YTgOBL3rODiwKg7 ZCQT/HppNno3uSrqOd93wZOL7F5v6e4gJJvi05O3M+/9Ys2+9m/AcQekGjPk8Its6u5M TaIkgRqCFJz9IdA9nuuwT2t95AmrUnr4Otj4HfrBjLb0CXUZX3CRUGPAi/MFJE0ale/z S3R21qAvqw8TvjYJWic4Rwt2tywapvMguYeN0s2WCp4dnOe9EIcJVpyZtIdv4AOLCCEI NHLA== X-Gm-Message-State: AOJu0YzHc3b4h4XygBbdra+lLzB/Xq4N4rJM7xi8y82MLe8DSsqDSZ9D 9qN01PF6CX2dCNGEwr5tNq0HWFKh40G03yk7O0BlB3mJ1WSLdG+JrwOs9I75uphb6K/47aA19A6 N30SFwyJZbRFRdrNnJx29LdIVvCTo3qmkSwvJloDhXICEUjQGTr2qL0wk6Zi18WEbJ80/OYWAN+ 0aXkbdUvJnA7PZGXt9cQXJ7S4g1wxnz7AN+quYaZU= X-Received: by 2002:adf:fa52:0:b0:37d:4a7b:eeb2 with SMTP id ffacd0b85a97d-37d5ff1c34emr7953373f8f.35.1728998263333; Tue, 15 Oct 2024 06:17:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOjUTgCroxJOa5wJt3TxRn4Qker7RUyVW2/1uMxKwQdah9mQg0HfwFqdQOsr2Jg34xeCLQhg== X-Received: by 2002:adf:fa52:0:b0:37d:4a7b:eeb2 with SMTP id ffacd0b85a97d-37d5ff1c34emr7953351f8f.35.1728998262891; Tue, 15 Oct 2024 06:17:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/16] meson: import rust module into a global variable Date: Tue, 15 Oct 2024 15:17:19 +0200 Message-ID: <20241015131735.518771-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998315158116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- meson.build | 1 + rust/qemu-api-macros/meson.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index c85f964bed4..c2e736d2051 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,7 @@ meson.add_postconf_script(find_program('scripts/symlink-i= nstall-tree.py')) =20 not_found =3D dependency('', required: false) keyval =3D import('keyval') +rust =3D import('rust') ss =3D import('sourceset') fs =3D import('fs') =20 diff --git a/rust/qemu-api-macros/meson.build b/rust/qemu-api-macros/meson.= build index 517b9a4d2d5..24325dea5c2 100644 --- a/rust/qemu-api-macros/meson.build +++ b/rust/qemu-api-macros/meson.build @@ -2,7 +2,7 @@ quote_dep =3D dependency('quote-1-rs', native: true) syn_dep =3D dependency('syn-2-rs', native: true) proc_macro2_dep =3D dependency('proc-macro2-1-rs', native: true) =20 -_qemu_api_macros_rs =3D import('rust').proc_macro( +_qemu_api_macros_rs =3D rust.proc_macro( 'qemu_api_macros', files('src/lib.rs'), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998391; cv=none; d=zohomail.com; s=zohoarc; b=EWPNxeI+ijvY4xfiEp2QxU/L44dzXxRRPHEdHSNVSmoiItcNDT9xq/CEORpSAjybiBnCDUsDHYLZCNOa1pfPVLhYgG9QskTcM4mZ4/FcGGxLMXyYFnbscuWaconTDx+KVSvdXB6rgfELP5E+iN4PsZd2ce2wlWobMWB3kVzQ+MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998391; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=vZ1Ej6J1Xip3zM5oXGhlOoK0TB4E/q4HLVZ4bLRAX5M=; b=JYfpCfduPMQiSPLh4KMEhP8Y7GT3J0vhaBCvHXS2wujle62KIvsjox23trn84hmIF87ji4c0HiyVijCCyfyQFZcQuh5zahw0BpKrltHGW8HzBYI82w+pktihGqvHWxkxxcXrfQZhSIJJFmmNzmLHMpHy/Jq0I2gnGB9c/mMwC0s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998391567846.625206253765; Tue, 15 Oct 2024 06:19:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hQx-00022c-Vc; Tue, 15 Oct 2024 09:17:55 -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 1t0hQu-00021f-1V for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:17:54 -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 1t0hQr-0001DA-LI for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:17:51 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-5qFZKKYcPzauhScpTUSyhQ-1; Tue, 15 Oct 2024 09:17:47 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43058dce286so30856495e9.2 for ; Tue, 15 Oct 2024 06:17:47 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f569933sm17908435e9.13.2024.10.15.06.17.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZ1Ej6J1Xip3zM5oXGhlOoK0TB4E/q4HLVZ4bLRAX5M=; b=cbeWAB9dl2RRXGerOjrRk2VnHp3L/VKjcyhkxRj0pjAbJHJj7Ojru9tioSx+eM3OeSYiN0 IbHrgc+LbPo1aZNNKo2qaz6X0OxX5zhKxR+XdCsvgA1HZ79mlNjXKlsGHAkic0oR6mzShV xKv2RUr4RvTNjUSwas7ZqpHWg/1utRw= X-MC-Unique: 5qFZKKYcPzauhScpTUSyhQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998266; x=1729603066; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vZ1Ej6J1Xip3zM5oXGhlOoK0TB4E/q4HLVZ4bLRAX5M=; b=gk/P/b6aFQFEm43CJYVccjFiBDGqcI2s+TQu9T65iE7iyB2IVr9VsPWvF6uyMp7+MV E7CuKi9a/22Eb8/DywWUoBkvJ+qtDuTe9ugGIUprl+LgdRLCiWTpCiXzmgWFV97ytlF6 jrXJVORUmJxQlX2Qf8sxJazut5rmcE5Nd9ZCBInyknbumK0mJ7Fw8eqUedvCsz/OmpB7 cn3NwndpQTsJbDzZY8vy36wDgMIAhxSzZd9f4nl1k8jHbp7D5gSQSGyiwQyrsc5MF58J tBz1159ViaTrkYUQj8fG0IFGvGnPqxg91H6XP716q+AHzEJltzUzWlgyp3rPZUfOWyJV WJKQ== X-Gm-Message-State: AOJu0YzU+3C4LOaDhajqJgr+IIlEU/lk3L4NTDfcA5PNKCNyblg/hwC5 ifokZPkJwwTultM5f1vAj/DTZDBeHds75sFXmarQpk/Cex1nmiArfL3cpJepF+nfqfnzbZhavVE tSZf3mVL4MyUDS5u72L46MQzVIeDIaqLGTva48uWCTO429B+GNGcK8vz2zB0BONyRehivDgHs5p njFWmA2DO39EkKrUcqo7IQ7w39iuXYA/aS1B/OT0A= X-Received: by 2002:a05:600c:4f07:b0:426:6308:e2f0 with SMTP id 5b1f17b1804b1-4312560975amr99148085e9.26.1728998266147; Tue, 15 Oct 2024 06:17:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4kEsNGdcOKLd8Oyi2NSf/W7cNeeKzwn65FhISQ1harOA53k4+e/WhViqzP16JZ05qMEslrQ== X-Received: by 2002:a05:600c:4f07:b0:426:6308:e2f0 with SMTP id 5b1f17b1804b1-4312560975amr99147895e9.26.1728998265746; Tue, 15 Oct 2024 06:17:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/16] meson: remove repeated search for rust_root_crate.sh Date: Tue, 15 Oct 2024 15:17:20 +0200 Message-ID: <20241015131735.518771-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998393378116600 Content-Type: text/plain; charset="utf-8" Avoid repeated lines of the form Program scripts/rust/rust_root_crate.sh found: YES (/home/pbonzini/work/ups= tream/qemu/scripts/rust/rust_root_crate.sh) in the meson logs. Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Reviewed-by: Zhao Liu --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index c2e736d2051..37f94ab32aa 100644 --- a/meson.build +++ b/meson.build @@ -3977,6 +3977,7 @@ endif =20 =20 feature_to_c =3D find_program('scripts/feature_to_c.py') +rust_root_crate =3D find_program('scripts/rust/rust_root_crate.sh') =20 if host_os =3D=3D 'darwin' entitlement =3D find_program('scripts/entitlement.sh') @@ -4078,7 +4079,7 @@ foreach target : target_dirs if crates.length() > 0 rlib_rs =3D custom_target('rust_' + target.underscorify() + '.rs', output: 'rust_' + target.underscorify() + '.= rs', - command: [find_program('scripts/rust/rust_ro= ot_crate.sh')] + crates, + command: [rust_root_crate, crates], capture: true, build_by_default: true, build_always_stale: true) --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998313; cv=none; d=zohomail.com; s=zohoarc; b=a4bk8Bvfd41L1TwWxeo+JCAONmvQF4ripOWXa/LWbrAy/VRHhul8A5VNCUz8yZBGd/Jv4qPcyV9tirsN6wv2iVOo+KdQOMsrlX+yi0vj1GZvzSW9p/e6tSR2lizBcp7/6n4tXumPDg1m/WR0uv/rOpWW1Mxm6lQC2TOdI4tl/dI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998313; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=jAbsj1TUYq+4pfKeL2OaEWTmSq8KVDWcMjyzGlJmWtQ=; b=jjK2vHrTfKG/VPlzE53tFnVb6PovkP4/QG9YL+3e7DnWF8yu56thmPHTI7qvgSVUOGfu83YUf1u60gDFeeXJMVqIEI3/3bQ2hzArEy4ym57Pfac4mVlnPyliBdP20Wo8u4A4aBRwdPyhMw1Jl+VmWl3vgy0J0Zrf8LJAYJyXybc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998313558746.9485790223321; Tue, 15 Oct 2024 06:18:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hR0-00023K-Gk; Tue, 15 Oct 2024 09:17:58 -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 1t0hQy-00022w-QM for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:17:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0hQx-0001Dc-Aw for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:17:56 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-L7V3psWsN-iYySyLny8H5g-1; Tue, 15 Oct 2024 09:17:52 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d4854fa0eso2681377f8f.2 for ; Tue, 15 Oct 2024 06:17:50 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f569933sm17909365e9.13.2024.10.15.06.17.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jAbsj1TUYq+4pfKeL2OaEWTmSq8KVDWcMjyzGlJmWtQ=; b=LdtoWY/+9j1/tx7U+NycL3538jENzZPwo0aFkzBoCzO6Lt5qMu4cQfBbnQJi5J2RuzzLUT Jz05J2VTlYJtoG6RuaMg1dRMmwl4/o94SyiVEKaK/FbQmWe94iDEtGbanx09vIWIhcHrxj y8Ck4yjtW+kLtkKTV+BFVbmLc55fWPc= X-MC-Unique: L7V3psWsN-iYySyLny8H5g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998269; x=1729603069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jAbsj1TUYq+4pfKeL2OaEWTmSq8KVDWcMjyzGlJmWtQ=; b=d2kLrGPk6eNELHaL+KzL0FSe1v7K1hG93PzAWD0Q+j6kDSmv3sQEIU6N8qZi9P9fjo hWdubbfNgpNHGc9nI/DpB2jMU1msPgzdlGxMxATEJ8ainBbjbYAQDrXwxwnT9T65k6TR q7Cq9BzKbxrXbIxFNMkwOHJgxcnHiBYmGFQultFyY644e4yJeNpOg6KyTKRSYL5JCn3i 6Eoi3iSXHU7u3oV3qEuhMMK2sy5guQegRWIt35d7OS/Mgo8M5EVdFY8cUI37tZbeaZ6P 37KTOaoCRiBa5HBq2te15EfSG5iyOV7nqDlpddHGRuLrsLuA1/PhynkUJO+2hpJTkNgP S/eg== X-Gm-Message-State: AOJu0Yy3Nvo1biLryPilN2yAOI85lpidyTIpavI+xPqqvs06PBLn9/VZ uOR1rPe2LbcIf3+GQvtZwjkrTWE6ZEJIbmYNNh9Gf6pvDidky7hhBP8b23oi8qMdrdy23wjGDZx y6bhKUPN8vFRm3tuW8bcRJ9n99pnPhtwFAHipXNO0XbnW7Wayw2yp5ThhVykxX1meydx0rXmdGf 0o2UmfX6ssLPxkXv1yDg+SnKvUd6Bn/vRfHSNkDtQ= X-Received: by 2002:a5d:570e:0:b0:37d:4a16:81d6 with SMTP id ffacd0b85a97d-37d86bfcc85mr205280f8f.24.1728998269155; Tue, 15 Oct 2024 06:17:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvBh4qY087oOAqphQj1l23YTgfFYlxk/niS/5xlWx08gth0mFZRgS2oKzPjfeJL/G7uwM0vw== X-Received: by 2002:a5d:570e:0:b0:37d:4a16:81d6 with SMTP id ffacd0b85a97d-37d86bfcc85mr205248f8f.24.1728998268583; Tue, 15 Oct 2024 06:17:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/16] rust: pass rustc_args when building all crates Date: Tue, 15 Oct 2024 15:17:21 +0200 Message-ID: <20241015131735.518771-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998315223116600 Content-Type: text/plain; charset="utf-8" rustc_args is needed to smooth the difference in warnings between the vario= us versions of rustc. Always include those arguments. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- meson.build | 18 +++++++++++------- rust/qemu-api/meson.build | 2 +- rust/qemu-api/src/device_class.rs | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 37f94ab32aa..2545185014e 100644 --- a/meson.build +++ b/meson.build @@ -3317,6 +3317,17 @@ endif =20 genh +=3D configure_file(output: 'config-host.h', configuration: config_ho= st_data) =20 +if have_rust and have_system + rustc_args =3D run_command( + find_program('scripts/rust/rustc_args.py'), + '--config-headers', meson.project_build_root() / 'config-host.h', + capture : true, + check: true).stdout().strip().split() + rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] + add_project_arguments(rustc_args, native: false, language: 'rust') + add_project_arguments(rustc_args, native: true, language: 'rust') +endif + hxtool =3D find_program('scripts/hxtool') shaderinclude =3D find_program('scripts/shaderinclude.py') qapi_gen =3D find_program('scripts/qapi-gen.py') @@ -3909,12 +3920,6 @@ common_all =3D static_library('common', dependencies: common_ss.all_dependencies()) =20 if have_rust and have_system - rustc_args =3D run_command( - find_program('scripts/rust/rustc_args.py'), - '--config-headers', meson.project_build_root() / 'config-host.h', - capture : true, - check: true).stdout().strip().split() - rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', @@ -4087,7 +4092,6 @@ foreach target : target_dirs rlib_rs, dependencies: target_rust.dependencies(), override_options: ['rust_std=3D2021', 'build.r= ust_std=3D2021'], - rust_args: rustc_args, rust_abi: 'c') arch_deps +=3D declare_dependency(link_whole: [rlib]) endif diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index c72d34b607d..42ea815fa5a 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -10,7 +10,7 @@ _qemu_api_rs =3D static_library( ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', - rust_args: rustc_args + [ + rust_args: [ '--cfg', 'MESON', # '--cfg', 'feature=3D"allocator"', ], diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 1ea95beb78d..b6b68cf9ce2 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -16,10 +16,12 @@ macro_rules! device_class_init { ) { let mut dc =3D ::core::ptr::NonNull::new(klass.cast::<$crate::bindings::D= eviceClass>()).unwrap(); - dc.as_mut().realize =3D $realize_fn; - dc.as_mut().vmsd =3D &$vmsd; - $crate::bindings::device_class_set_legacy_reset(dc.as_mut(), $= legacy_reset_fn); - $crate::bindings::device_class_set_props(dc.as_mut(), $props.a= s_mut_ptr()); + unsafe { + dc.as_mut().realize =3D $realize_fn; + dc.as_mut().vmsd =3D &$vmsd; + $crate::bindings::device_class_set_legacy_reset(dc.as_mut(= ), $legacy_reset_fn); + $crate::bindings::device_class_set_props(dc.as_mut(), $pro= ps.as_mut_ptr()); + } } }; } --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998465; cv=none; d=zohomail.com; s=zohoarc; b=FXuOD0JejQvySW56U+LcLl6AbgaV3Agbtakxo7rGkeNAug/kuwdn08iii94JL7K5vhwWTGPhYXa4KU+zq1ER7iSC8f437BPqj8ul2MVaX9lGmi93oMqMRpsxjgN0m8lmPpNxvT3jAIjCO1JUVj0hWgZu0FGxcr+x7bM+Ki3Qc/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998465; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=20vvSyFpZURhPY07pvl6EKKD9oQ8iAAak08m0L+pzSY=; b=PezUGwChWJJE8PaobobAm4sGAsdOQzmrylIIU9fHTUQHYZ6WBd22hkuHlvVDU7IB0neQiwHhGmehHucKGSOA98Peunbdzso20aq7gIXeQLh7q1NsQ0TlHk2X+02x0pFifQsTIpulFc/FLHQ09A5eMQIh8ftnACe+T3e9wOYHgIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998465871532.2455575631728; Tue, 15 Oct 2024 06:21:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hR7-00024A-69; Tue, 15 Oct 2024 09:18:05 -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 1t0hR2-00023l-NA for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:00 -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 1t0hR0-0001Dm-Tk for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:00 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-wZbqc7OkOUSKCqq96gXbFg-1; Tue, 15 Oct 2024 09:17:55 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d67f4bf98so1440819f8f.1 for ; Tue, 15 Oct 2024 06:17:53 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fbf81b4sm1560697f8f.79.2024.10.15.06.17.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=20vvSyFpZURhPY07pvl6EKKD9oQ8iAAak08m0L+pzSY=; b=V3qBAUZBEfpt+IlYQwfOR2fEPKkLPaXy9OsAWPiDTobVl5cxJr75Iua3TojJCJh0i3RSZX b+LIEHlepCmlCLtXN9xiOzvT8L5qleFVfkLbtFx/zn2WtkLToRlK1Fevq1f3UG0T8kqaD4 cZcEsjsim5GNOrCQv5hcrg04brRylQA= X-MC-Unique: wZbqc7OkOUSKCqq96gXbFg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998272; x=1729603072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=20vvSyFpZURhPY07pvl6EKKD9oQ8iAAak08m0L+pzSY=; b=YDflC7Pq+QLooRKtKOHAs53nzHit7VP6eKjHcNarHM55oNr2hq4I4oB562uKJh/jQI WINo3/v0bVFFHgrgKva/cpQ93l3R1cuXOOHgGXPvwY5ZP2oF5kZrhil/6/GBwvqX9veG S+gdij6S9eYuo+iiEfOj6PdslXcr6pS852yOZQ+L8FMnocZqs+eNfmEZ1Nws5kboIMa8 wFh1OaWxRFSngJETIy8FrcI7SSIjzR1sSdmbjovXK7eK52zG2X24fb2DeDA7itPf4aBw v9+ss+Px5Kgz0IitpekCI40U30TaZv/JlnJz5v6Hi3UCPA9jNIJbobNsyf0muyecP5Se f8IQ== X-Gm-Message-State: AOJu0YxChvc0k+fP+PoBAk58nGnsdafhgg8TSbIgEOnBgvVdjfNNGlg0 Zc+Qon6HYbRnhoY8zfn2Ps6vLHN+jxZin0IcX5cuDZZ5RINT1yJaBR5fgM9Eo2CoiqfHFMy4V5t 9xkN5eH5KEfBk73vLxr1Z4k0Rmb6m64tWkZeEJRYf/D6FyJDwABDv6C959afUQPzqPwAH3aDenR jrrRibf1YZ3Q69VWqFbFvfrHq5RSjntfpURDXIUUA= X-Received: by 2002:a05:6000:1568:b0:37d:476d:2d58 with SMTP id ffacd0b85a97d-37d86d50563mr246503f8f.45.1728998272140; Tue, 15 Oct 2024 06:17:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4mddPrdb45gV5NBoEKhlQc+PATGqGnWPTKEfPL9FP1OuhPMgYp/iDN/rmLsvcjcxMWlmaNw== X-Received: by 2002:a05:6000:1568:b0:37d:476d:2d58 with SMTP id ffacd0b85a97d-37d86d50563mr246470f8f.45.1728998271556; Tue, 15 Oct 2024 06:17:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/16] rust: patch bilge-impl to allow compilation with 1.63.0 Date: Tue, 15 Oct 2024 15:17:22 +0200 Message-ID: <20241015131735.518771-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998467898116600 Content-Type: text/plain; charset="utf-8" Apply a patch that removes "let ... else" constructs, replacing them with "if let ... else" or "let ... =3D match ...". "let ... else" was stabilize= d in Rust 1.65.0. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- .gitattributes | 2 + subprojects/bilge-impl-0.2-rs.wrap | 1 + .../packagefiles/bilge-impl-1.63.0.patch | 45 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 subprojects/packagefiles/bilge-impl-1.63.0.patch diff --git a/.gitattributes b/.gitattributes index 6dc6383d3d1..9ce7a19581a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,5 @@ *.rs diff=3Drust *.rs.inc diff=3Drust Cargo.lock diff=3Dtoml merge=3Dbinary + +*.patch -text -whitespace diff --git a/subprojects/bilge-impl-0.2-rs.wrap b/subprojects/bilge-impl-0.= 2-rs.wrap index eefb10c36c2..b24c34a9043 100644 --- a/subprojects/bilge-impl-0.2-rs.wrap +++ b/subprojects/bilge-impl-0.2-rs.wrap @@ -5,3 +5,4 @@ source_filename =3D bilge-impl-0.2.0.tar.gz source_hash =3D feb11e002038ad243af39c2068c8a72bcf147acf05025dcdb916fcc000= adb2d8 #method =3D cargo patch_directory =3D bilge-impl-0.2-rs +diff_files =3D bilge-impl-1.63.0.patch diff --git a/subprojects/packagefiles/bilge-impl-1.63.0.patch b/subprojects= /packagefiles/bilge-impl-1.63.0.patch new file mode 100644 index 00000000000..987428a6d65 --- /dev/null +++ b/subprojects/packagefiles/bilge-impl-1.63.0.patch @@ -0,0 +1,45 @@ +--- a/src/shared/discriminant_assigner.rs ++++ b/src/shared/discriminant_assigner.rs +@@ -26,20 +26,20 @@ + let discriminant_expr =3D &discriminant.1; + let variant_name =3D &variant.ident; +=20 +- let Expr::Lit(ExprLit { lit: Lit::Int(int), .. }) =3D discriminan= t_expr else { ++ if let Expr::Lit(ExprLit { lit: Lit::Int(int), .. }) =3D discrimi= nant_expr { ++ let discriminant_value: u128 =3D int.base10_parse().unwrap_or= _else(unreachable); ++ if discriminant_value > self.max_value() { ++ abort!(variant, "Value of variant exceeds the given numbe= r of bits") ++ } ++ ++ Some(discriminant_value) ++ } else { + abort!( + discriminant_expr, + "variant `{}` is not a number", variant_name; + help =3D "only literal integers currently supported" + ) +- }; +- +- let discriminant_value: u128 =3D int.base10_parse().unwrap_or_els= e(unreachable); +- if discriminant_value > self.max_value() { +- abort!(variant, "Value of variant exceeds the given number of= bits") + } +- +- Some(discriminant_value) + } +=20 + fn assign(&mut self, variant: &Variant) -> u128 { +--- a/src/shared/fallback.rs ++++ b/src/shared/fallback.rs +@@ -22,8 +22,9 @@ + } + Unnamed(fields) =3D> { + let variant_fields =3D fields.unnamed.iter(); +- let Ok(fallback_value) =3D variant_fields.exactly_one() e= lse { +- abort!(variant, "fallback variant must have exactly o= ne field"; help =3D "use only one field or change to a unit variant") ++ let fallback_value =3D match variant_fields.exactly_one()= { ++ Ok(ok) =3D> ok, ++ _ =3D> abort!(variant, "fallback variant must have ex= actly one field"; help =3D "use only one field or change to a unit variant") + }; +=20 + if !is_last_variant { --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998313; cv=none; d=zohomail.com; s=zohoarc; b=kK07vb55ontVLp0/WCdEYQNdVU5ThIhoIlFk0wCtjvZpnBmCMGesR6kzVNJo6CirzCEpVnkiqCYRnG8qvtcx6UUI2taiXkobhF3JsMTfQM84Ko5OLjpn0742TFY6YMUY2vvhnS6pXRcnY/aNbXjwTzEuDNdlJ71vTZRFttuH/KU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998313; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=u45iLCwaL6UDPFZFrxkclA/Jz3UXse/PWIiVqr58mZQ=; b=JHgHRumE2kbGxU2uulZTQ6gM6q09w8rMgMdKvgqJE+Ex/upbStmfb7n+3tTN/9UpVcqytNcTAs7FPVfeg9A08U3yGMmUIFIXFF8pmc8olJpYdWazewV8SZnW08zce4owsl1p5FsF0Vwdw5p6Qkmk5PMjfwb7R7xApaT7L9PxQhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998313529724.2903922087391; Tue, 15 Oct 2024 06:18:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hR8-00024o-1H; Tue, 15 Oct 2024 09:18:06 -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 1t0hR6-00024E-Vn for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:05 -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 1t0hR3-0001EQ-Sl for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:04 -0400 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-201-zbt9zO1fPlifDZX_27JrHg-1; Tue, 15 Oct 2024 09:17:56 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d609ef9f7so1322918f8f.3 for ; Tue, 15 Oct 2024 06:17:56 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fa89c55sm1564662f8f.46.2024.10.15.06.17.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u45iLCwaL6UDPFZFrxkclA/Jz3UXse/PWIiVqr58mZQ=; b=Vbpjts/KDSpUg9e3zbqDwwH3PjkcXVTynvL4RMUSYhCiRX6DJvvDlD+IHdyPNMNVNNZYFB qP0KMhWD+YSd8MET8iZfGdF3+w+ZmQkwScCOefB6Oj6eO0zIthnMeeziyf26VD3BLsDZHT f6k/ZHkWGtz6MiQEwkCuAwd198RXmpI= X-MC-Unique: zbt9zO1fPlifDZX_27JrHg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998275; x=1729603075; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u45iLCwaL6UDPFZFrxkclA/Jz3UXse/PWIiVqr58mZQ=; b=doCxPlKJLCmrMpvTck6WyThV2zf+4mo7P3CVQqoqzi2xyGnekepKIiK65KsLsH7jhi StvgUIrNcHNu4brpEX35hq3bpQ7GkuN+MT+GpRBsHM246T/7bXhLD0rLSOfHm10koW+c MgSpNbrWh0ZcMWPMw/D7K5PfHt06Q4tmbfSxwjhhu9BYuirWyNLOuPLDzoEC+Xwy6X8+ qmUEvP4W9GO1FJumFXZMhBom6qVRndOPwU0c39Mw2hO2MiC5GDvCQnD2/NWiEgfF+fqt yrRpJ9ptyKkmat4jcfOksoyej/cfsZ5eCNudd2tvU6JD53nzvsD54ix03bv+huuf7fZT ksJw== X-Gm-Message-State: AOJu0YxKf6P6ZGdVcc4h6PLbSMuleHNjl9hbioe0xC/+Iu2ZfEDhD3zc xdLJhuF3Dk6CGnAYs9TsNj4QWyW+yP3gDocB4N5YxlpP/FvFDbhJbfbai9p6mINxNNZLanC3LP9 PxH1FhWE3671O19a8N9Db8/1iHGCoMoA8tVun+EsHeTboelN21PuId7LmQIF9Si0ct1C60I2GMs ghOnscDi9ZpqpEB2cJYfW5PPnYVZKuHcMIFef3PnM= X-Received: by 2002:a5d:5351:0:b0:37d:4870:dedf with SMTP id ffacd0b85a97d-37d551d3fc5mr11031840f8f.19.1728998274797; Tue, 15 Oct 2024 06:17:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVJzhrJlEsj0CCAZU0VlG8SQnJzHqtk7pSGA2WJiTolJ7kHzSRDCGLC3IkWU5eqlMVenSSHw== X-Received: by 2002:a5d:5351:0:b0:37d:4870:dedf with SMTP id ffacd0b85a97d-37d551d3fc5mr11031816f8f.19.1728998274288; Tue, 15 Oct 2024 06:17:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/16] rust: fix cfgs of proc-macro2 for 1.63.0 Date: Tue, 15 Oct 2024 15:17:23 +0200 Message-ID: <20241015131735.518771-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998315172116600 Content-Type: text/plain; charset="utf-8" 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: Zhao Liu --- subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subprojects/packagefiles/proc-macro2-1-rs/meson.build b/subpro= jects/packagefiles/proc-macro2-1-rs/meson.build index 818ec59336b..8e601b50ccc 100644 --- a/subprojects/packagefiles/proc-macro2-1-rs/meson.build +++ b/subprojects/packagefiles/proc-macro2-1-rs/meson.build @@ -15,7 +15,9 @@ _proc_macro2_rs =3D static_library( rust_abi: 'rust', rust_args: [ '--cfg', 'feature=3D"proc-macro"', - '--cfg', 'span_locations', + '--cfg', 'no_literal_byte_character', + '--cfg', 'no_literal_c_string', + '--cfg', 'no_source_text', '--cfg', 'wrap_proc_macro', ], dependencies: [ --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998326; cv=none; d=zohomail.com; s=zohoarc; b=BJDlrHLg/NdWXCe1+oda4ioWiiljComtQg4oWjoNzxG9UnqrsnHD3Og6japWdEQJKnEn85rfofPPV2l9FWElTN3sXRRUXz6StEQbRroTtXwALifbOgFjtjEmEsjWM1CsPeslR66KKUA19j9jg4Q8EpkyCDcU52LgqHcOZbVPabk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998326; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=59Gpr3pRmXw/Bed6+2Hl7KYTM3heYGiGwIXaAgGlVZY=; b=bgJuhJmlE/B8NEGXFpr+EsMgNAzuMMwwtg4bQZGHyiQ5JGMjSHw4YsbaZQWIqZp4PtbErM5MS3i8mK7p1fO5OJ8wVaj9Uk+qhI0yAuTpPMOqICtM58c1k7N40qAPWp7yD/K9TmGc8XMkKS8ZI5byIOl+7PGiAAm87YRM5L2o884= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998326827935.9660327172846; Tue, 15 Oct 2024 06:18:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hR9-00025S-Oc; Tue, 15 Oct 2024 09:18:07 -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 1t0hR5-00024D-Ga for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:05 -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 1t0hR4-0001EU-3g for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:03 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-jQv9aF-oOumVOSp3n7n-gA-1; Tue, 15 Oct 2024 09:17:59 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4311407ae76so28011395e9.3 for ; Tue, 15 Oct 2024 06:17:59 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4314209688dsm15198585e9.14.2024.10.15.06.17.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=59Gpr3pRmXw/Bed6+2Hl7KYTM3heYGiGwIXaAgGlVZY=; b=KftV6OFMSenHuX1HGkThk0KlsKuiBnJnfLc5TvQUcde7LK7P0uJG+IqLbwmLvMThIK8k1x +KK2E+Ui2iVUVGWEjwBqrJgj2jl3W+kpLjyk21Xd1f/dLx5sRshKvHtN3upB9AetDlSejG +KNTk091dT1Ru7spT6NQ8SgO4JQ10q0= X-MC-Unique: jQv9aF-oOumVOSp3n7n-gA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998277; x=1729603077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=59Gpr3pRmXw/Bed6+2Hl7KYTM3heYGiGwIXaAgGlVZY=; b=mIJQMPb9yxR02rJ1Lmp9Ws2HlojedBE+oSWN6RsjdGfs7GQbwms7ceHSY9+pkXToYF 9D+qpBvXPhzU3fyMzEIr4Fr0QTnedpuznNusghYPJlTc2EtPLyei65SYxYYLmymJoViV POZz7Kn1c82zntLeSQ7xUz0vPUkBlGJsC5bVRxUrh1HsSNaaM6hvykc5/sNJJWsH3ZDS BQgR7gOeZfqIoKsw5Pft95EwN2RNCV2ILdGwlgSQ2nVcK1bAt7AF0JgTfXWGatwGnXxv 7qTXnle0tqj4K/jwQ6+J6AsECOELikVW5GP+5mse5MaBSZwV/Wv0YafN23lGOfcxohqI 33Hw== X-Gm-Message-State: AOJu0Yx4rrsroXfLWYhCodPGyXwxASN50zf6K2J35A83L2bZFXx7qakp JN0BeqiZ23T7phIfz/0CPDgLR/GUNl65xNNb8fvAqV0+614x5BdiSXW2fsiRkxvfhQ5uOsM6uoZ bmnyzX1kJWrPIky/5sHIQiUYgNRl5Zy4cq6jyVkeFYoGx6lZVTviOV2/MRTxE2/QfK2686O9DcH bHHXGbDHaO2rlucALo1f41yP/47oo82LLMTRx6iLU= X-Received: by 2002:a05:600c:4514:b0:426:60b8:d8ba with SMTP id 5b1f17b1804b1-4314a362525mr4815335e9.28.1728998277615; Tue, 15 Oct 2024 06:17:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFs5g1AvsA+4+WeKzUhVAypQfc5xYgEBTUPN48ZEbBfTAU/1Hk5Japv5k6VQRJ5kJ/q276/WQ== X-Received: by 2002:a05:600c:4514:b0:426:60b8:d8ba with SMTP id 5b1f17b1804b1-4314a362525mr4814995e9.28.1728998277047; Tue, 15 Oct 2024 06:17:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/16] rust: do not use OnceLock for properties Date: Tue, 15 Oct 2024 15:17:24 +0200 Message-ID: <20241015131735.518771-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998327140116600 Content-Type: text/plain; charset="utf-8" Properties are initialized lazily but always accessed within the big QEMU l= ock. There is no need to have a OnceLock around them, and also OnceCell/OnceLock were only stabilized in 1.70.0; so remove it. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- rust/qemu-api/src/device_class.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index b6b68cf9ce2..87892b50c63 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -2,8 +2,6 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use std::sync::OnceLock; - use crate::bindings::Property; =20 #[macro_export] @@ -73,12 +71,15 @@ macro_rules! define_property { } =20 #[repr(C)] -pub struct Properties(pub OnceLock<[Property; N]>, pub fn(= ) -> [Property; N]); +pub struct Properties(pub Option<[Property; N]>, pub fn() = -> [Property; N]); =20 impl Properties { pub fn as_mut_ptr(&mut self) -> *mut Property { - _ =3D self.0.get_or_init(self.1); - self.0.get_mut().unwrap().as_mut_ptr() + match self.0 { + None =3D> { self.0 =3D Some(self.1()); }, + Some(_) =3D> {}, + } + self.0.as_mut().unwrap().as_mut_ptr() } } =20 @@ -104,7 +105,7 @@ const fn _calc_prop_len() -> usize { } =20 #[no_mangle] - pub static mut $ident: $crate::device_class::Properties = =3D $crate::device_class::Properties(::std::sync::OnceLock::new(), _make_pr= operties); + pub static mut $ident: $crate::device_class::Properties = =3D $crate::device_class::Properties(None, _make_properties); }; } =20 --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998388; cv=none; d=zohomail.com; s=zohoarc; b=hQChkcr1vIldSuj2YWxWGWz0LiCg7fPVTzQfAfFL+yEiGYWL6fwWsOdAeht/PPSY1wSiXdpSyzrkko3mHl7MXsT6VHgPVTjr/g17NvQfI5hBf2AfWVRWfZP3GcMumlaq5r+J999RVlaOGptgey8bUV4oviyeiNqV6d1O1jRdbQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998388; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=uvbOSOk5pfxwFgryTrkHWpnMMDPavUiusynCI97arAs=; b=S/TrCrNCbAre0f04JT/KoBrYXxNH1td/Oq4pMsYimDwYgNkaPmmpJmKCZzOwAIS0wHT2oYUWloMseA2LVr/jxpGufswXC4xdXiNnBUnkXDjiFKTm9e22a3DVnZwOkizTpyq4CRh8UlYnRl58pzd8sczaZF1RR73mauLXrDrLzyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998388154914.0615427867971; Tue, 15 Oct 2024 06:19:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRD-00025k-0U; Tue, 15 Oct 2024 09:18:11 -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 1t0hRA-00025V-3N for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0hR6-0001Ev-Kb for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:06 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-x3QoPD4yNK2YHEfsM-bTqw-1; Tue, 15 Oct 2024 09:18:02 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43113dab986so47352725e9.2 for ; Tue, 15 Oct 2024 06:18:02 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4314a829abbsm2665635e9.17.2024.10.15.06.17.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uvbOSOk5pfxwFgryTrkHWpnMMDPavUiusynCI97arAs=; b=IbSZ1Nxgq6d5JdSeE8GOcaxzZ+vEvXt6unSa5AuEX+Whs7lrVK6cAG2ORvJdrHZ8mzA3bu mVmneuJo4x0sGT/d8WQHz+BxMFsV0awnpJcQmGKseKqeDf3n4fG51OR49v/FHI/PQjQjC3 +oVtWev9mgSkOIdEVDaVCq/Mn4V2TmM= X-MC-Unique: x3QoPD4yNK2YHEfsM-bTqw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998281; x=1729603081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uvbOSOk5pfxwFgryTrkHWpnMMDPavUiusynCI97arAs=; b=istSOAztPEQzwC34M71zKFJjkFcrKl634SwnXVrGpDmLIu9iJApWJcmPH4HSki1S/I sNFwMJ6UILcWVkFxz55lTE+XvUV0wUrTqF0bpLFBCeRxcfHfV2pCGfzYMZzISVFeeEKG jkDPR1xDwjGEW9nTkC7Nto7YphqbiJ1veBb3AORGiZvcp5Gjy5XMlUEIyNbhiO9PQB0m SH8PWRLCorYLz+JulYDFzlHr1QY/fTXU7jSkzDUlkb5jdN3lnqUiYsIRxWk1tAolsvOH 5lEs+GpmGYJjPZAsncCir/GDOaJyImopXUMOGBc58mu0zspfLI4RyzP6/xAxkrXnXn6S x0ZA== X-Gm-Message-State: AOJu0YyJBXjQxGkEoFFdnP67uV0nowBIeb9IQK2SxaCdWZT/JPGlIrWl YCIqKPreIWpXeGlKBiw2x0Mfo1pPmWoixFfXZdENGC1qZv8jBFyiHf7UsybOblrP9XFpB+Ha7Wd rt9y++Oj0wiqDKT23mSYV4qnQXx7uNCTj1RMZW7cn/TgxmWqSdbVDfMVcVFpWh1I5rHIALrVlCi UeDuK6gaMIvI87dr56gOf84pZnJCIR9q0+YKQCXeM= X-Received: by 2002:a05:600c:4e13:b0:42c:b9a5:bd95 with SMTP id 5b1f17b1804b1-43125560014mr130515195e9.0.1728998280658; Tue, 15 Oct 2024 06:18:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlmy/97pNN32C4ACF2lH9mHWUol1cxRb/hxz3W279ACGfCLzTyoSQ7YR637aKz8xp02KXV7g== X-Received: by 2002:a05:600c:4e13:b0:42c:b9a5:bd95 with SMTP id 5b1f17b1804b1-43125560014mr130514715e9.0.1728998279962; Tue, 15 Oct 2024 06:17:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/16] rust: use std::os::raw instead of core::ffi Date: Tue, 15 Oct 2024 15:17:25 +0200 Message-ID: <20241015131735.518771-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998389541116600 Content-Type: text/plain; charset="utf-8" core::ffi::c_* types were introduced in Rust 1.64.0. Use the older types in std::os::raw, which are now aliases of the types in core::ffi. There is no need to compile QEMU as no_std, so this is acceptable as long as we supp= ort a version of Debian with Rust 1.63.0. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- meson.build | 3 +-- rust/hw/char/pl011/src/device.rs | 20 +++++++++++--------- rust/hw/char/pl011/src/lib.rs | 2 +- rust/hw/char/pl011/src/memory_ops.rs | 10 ++++++---- rust/qemu-api/src/definitions.rs | 4 +++- rust/qemu-api/src/device_class.rs | 8 ++++---- rust/qemu-api/src/lib.rs | 8 +++++--- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/meson.build b/meson.build index 2545185014e..175b8d82228 100644 --- a/meson.build +++ b/meson.build @@ -3923,14 +3923,13 @@ if have_rust and have_system bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', - '--ctypes-prefix', 'core::ffi', + '--ctypes-prefix', 'std::os::raw', '--formatter', 'rustfmt', '--generate-block', '--generate-cstr', '--impl-debug', '--merge-extern-blocks', '--no-doc-comments', - '--use-core', '--with-derive-default', '--no-size_t-is-usize', '--no-layout-tests', diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index c7193b41bee..cd4c01c2336 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -2,9 +2,11 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::{ - ffi::{c_int, c_uchar, c_uint, c_void, CStr}, - ptr::{addr_of, addr_of_mut, NonNull}, +use core::ptr::{addr_of, addr_of_mut, NonNull}; + +use std::{ + ffi::CStr, + os::raw::{c_int, c_uchar, c_uint, c_void} }; =20 use qemu_api::{ @@ -89,10 +91,10 @@ pub struct PL011Class { =20 impl qemu_api::definitions::Class for PL011Class { const CLASS_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void), > =3D Some(crate::device_class::pl011_class_init); const CLASS_BASE_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void), > =3D None; } =20 @@ -151,7 +153,7 @@ pub unsafe fn init(&mut self) { pub fn read( &mut self, offset: hwaddr, - _size: core::ffi::c_uint, + _size: c_uint, ) -> std::ops::ControlFlow { use RegisterOffset::*; =20 @@ -532,9 +534,9 @@ pub fn update(&self) { /// The buffer and size arguments must also be valid. #[no_mangle] pub unsafe extern "C" fn pl011_receive( - opaque: *mut core::ffi::c_void, + opaque: *mut c_void, buf: *const u8, - size: core::ffi::c_int, + size: c_int, ) { unsafe { debug_assert!(!opaque.is_null()); @@ -555,7 +557,7 @@ pub fn update(&self) { /// the same size as [`PL011State`]. We also expect the device is /// readable/writeable from one thread at any time. #[no_mangle] -pub unsafe extern "C" fn pl011_event(opaque: *mut core::ffi::c_void, event= : QEMUChrEvent) { +pub unsafe extern "C" fn pl011_event(opaque: *mut c_void, event: QEMUChrEv= ent) { unsafe { debug_assert!(!opaque.is_null()); let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index 2939ee50c99..2b157868b0f 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -45,7 +45,7 @@ pub mod device_class; pub mod memory_ops; =20 -pub const TYPE_PL011: &::core::ffi::CStr =3D c"pl011"; +pub const TYPE_PL011: &::std::ffi::CStr =3D c"pl011"; =20 /// Offset of each register from the base memory address of the device. /// diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/= memory_ops.rs index 8d066ebf6d0..2c664fd45ed 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -4,6 +4,8 @@ =20 use core::{mem::MaybeUninit, ptr::NonNull}; =20 +use std::os::raw::{c_uint, c_void}; + use qemu_api::bindings::*; =20 use crate::device::PL011State; @@ -24,9 +26,9 @@ =20 #[no_mangle] unsafe extern "C" fn pl011_read( - opaque: *mut core::ffi::c_void, + opaque: *mut c_void, addr: hwaddr, - size: core::ffi::c_uint, + size: c_uint, ) -> u64 { assert!(!opaque.is_null()); let mut state =3D unsafe { NonNull::new_unchecked(opaque.cast::()) }; @@ -46,10 +48,10 @@ =20 #[no_mangle] unsafe extern "C" fn pl011_write( - opaque: *mut core::ffi::c_void, + opaque: *mut c_void, addr: hwaddr, data: u64, - _size: core::ffi::c_uint, + _size: c_uint, ) { unsafe { assert!(!opaque.is_null()); diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index 60bd3f8aaa6..aa7cdd69c99 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -4,7 +4,9 @@ =20 //! Definitions required by QEMU when registering a device. =20 -use ::core::ffi::{c_void, CStr}; +use std::ffi::CStr; + +use std::os::raw::c_void; =20 use crate::bindings::{Object, ObjectClass, TypeInfo}; =20 diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 87892b50c63..871063d4a92 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -10,7 +10,7 @@ macro_rules! device_class_init { #[no_mangle] pub unsafe extern "C" fn $func( klass: *mut $crate::bindings::ObjectClass, - _: *mut ::core::ffi::c_void, + _: *mut ::std::os::raw::c_void, ) { let mut dc =3D ::core::ptr::NonNull::new(klass.cast::<$crate::bindings::D= eviceClass>()).unwrap(); @@ -30,7 +30,7 @@ macro_rules! define_property { $crate::bindings::Property { name: { #[used] - static _TEMP: &::core::ffi::CStr =3D $name; + static _TEMP: &::std::ffi::CStr =3D $name; _TEMP.as_ptr() }, info: $prop, @@ -51,7 +51,7 @@ macro_rules! define_property { $crate::bindings::Property { name: { #[used] - static _TEMP: &::core::ffi::CStr =3D $name; + static _TEMP: &::std::ffi::CStr =3D $name; _TEMP.as_ptr() }, info: $prop, @@ -121,7 +121,7 @@ macro_rules! vm_state_description { pub static $name: $crate::bindings::VMStateDescription =3D $crate:= :bindings::VMStateDescription { $(name: { #[used] - static VMSTATE_NAME: &::core::ffi::CStr =3D $vname; + static VMSTATE_NAME: &::std::ffi::CStr =3D $vname; $vname.as_ptr() },)* unmigratable: true, diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index e72fb4b4bb1..c2f60ac4727 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -35,6 +35,8 @@ unsafe impl Sync for bindings::VMStateDescription {} =20 use std::alloc::{GlobalAlloc, Layout}; =20 +use std::os::raw::c_void; + #[cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)] extern "C" { fn g_aligned_alloc0( @@ -47,8 +49,8 @@ fn g_aligned_alloc0( =20 #[cfg(not(HAVE_GLIB_WITH_ALIGNED_ALLOC))] extern "C" { - fn qemu_memalign(alignment: usize, size: usize) -> *mut ::core::ffi::c= _void; - fn qemu_vfree(ptr: *mut ::core::ffi::c_void); + fn qemu_memalign(alignment: usize, size: usize) -> *mut c_void; + fn qemu_vfree(ptr: *mut c_void); } =20 extern "C" { @@ -113,7 +115,7 @@ fn default() -> Self { } =20 // Sanity check. -const _: [(); 8] =3D [(); ::core::mem::size_of::<*mut ::core::ffi::c_void>= ()]; +const _: [(); 8] =3D [(); ::core::mem::size_of::<*mut c_void>()]; =20 unsafe impl GlobalAlloc for QemuAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998333; cv=none; d=zohomail.com; s=zohoarc; b=hOIIYqcEo9v+7RGL04p3EuQC72idWuXpKIMN7RzyLe9xkRMjyLtW4Lzv+S6wihwcmTrdM4gl/aifSmq0dZO+p+jpH0ugHgr9sZ+0EAhdww4IS37LBFMb6SG/hBNlkmtaeme1anL0ZHVVdWOYZ6zgzdF+Ae1kV0iw+iXHdwbYZ9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998333; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=aCwCwTmGgLCTaKNM2sPmatRSOdUjZKvsf7/Jf9mknBI=; b=HJu1mpbIj82L482+swSIElxDNVBatxNw5/KqYmSK0X6N6GwBb8ErD07/nDNy8qMO6BGImV/IGg1BaLn4ec+JoCyW95Jpn90UOKyieRmUHgSz+/keTQM1o3HYtpe8Y0fFe49sCsL9yut3Xc7WetED6zX1BVEe4dsnRYkWlbfYUSk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998333076847.041624025918; Tue, 15 Oct 2024 06:18:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRH-00026R-Nl; Tue, 15 Oct 2024 09:18:15 -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 1t0hRF-000267-41 for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:13 -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 1t0hRB-0001Gx-Eg for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:11 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-CZeSv_-YONmYnRR00n38gw-1; Tue, 15 Oct 2024 09:18:05 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42ac185e26cso33090805e9.3 for ; Tue, 15 Oct 2024 06:18:05 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f55dec4sm17913545e9.8.2024.10.15.06.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aCwCwTmGgLCTaKNM2sPmatRSOdUjZKvsf7/Jf9mknBI=; b=IvCA3XEfUa7HmKBpGOiGV1CYjsC3rXkHowVdmnwKkKpxIqQARUYHGtd0GrtpWUwwErMS77 4q5ILxvDgit8jJLrtuP/GpsjgrAiTjU3ybj3dh+/St6QGbfknkLKlYHXOzZ4P5Zpa3IVNK QUqaesxkh+y+YWy3rOFJxQ9YfKBw810= X-MC-Unique: CZeSv_-YONmYnRR00n38gw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998284; x=1729603084; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aCwCwTmGgLCTaKNM2sPmatRSOdUjZKvsf7/Jf9mknBI=; b=i/vvfx6pt+yomIcvGqYDgEwlO2pnd/+lCDiS8wIm/Ux1NMKRnZSfuR2Qhn/4WskHZy 00CMdOxp1GzQSVNpgp4rgBbwpj7N/z8JAi08BfMiy5hxWxokCrjRtjTP8+hIPX5AVqz4 TIdDln96nle0bTl19qNpA9ueXsVqNfF5/P8YfJ9JRzuYCJElf0fpv9uJJnFeGKAMJ+fF 4lPFdhsxMXYIsKZgLPdxrN2RctR+bWfQa8vIVQMhpLi+gv5TKo7e6ADlqpDGkK3Dkb8q 6VQnXkmAVJijXFRjVCAqDXYg6zbbDm/4OGNzznHnRyNaUuOiVh1goNtan/MSwhktoLSB 8GQA== X-Gm-Message-State: AOJu0YyhuhqYbEbQF5T/89cezIp5HY20SMdR5V8icZMKL4p28A/4aW6I xJLHWcvGJygwNypUVVw1nRYBMFX5CbnDggY2oFz7lRrYTtn7vFZSg7p5p53yV5WE/NO5g53KIuQ O2WsfF2JkvdzLyCQX7EgYilPBbMZHeMHn29AbMqs098+309EzIGj8ex80H93XjgYXL1UoonG5Hb uWkcOiXJPt4vNWn0/WyGaEOGINiGeWH76B4j55yoI= X-Received: by 2002:a05:600c:4e92:b0:42c:bf79:78f7 with SMTP id 5b1f17b1804b1-4314a3ac94cmr4982635e9.32.1728998283921; Tue, 15 Oct 2024 06:18:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT6eHgqusATpv6TcBpSjOJQF9Sk7UimXT8ELzQXospKO18XeD917Juo2Bgp93tYo0gCuwf1Q== X-Received: by 2002:a05:600c:4e92:b0:42c:bf79:78f7 with SMTP id 5b1f17b1804b1-4314a3ac94cmr4982385e9.32.1728998283468; Tue, 15 Oct 2024 06:18:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/16] rust: build tests for the qemu_api crate Date: Tue, 15 Oct 2024 15:17:26 +0200 Message-ID: <20241015131735.518771-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998335082116600 Content-Type: text/plain; charset="utf-8" Fix some bitrot in tests.rs, and allow the unit tests to be run via "meson test". Signed-off-by: Paolo Bonzini Reviewed-by tags, so no need to go through it again), I'm changing Reviewed-by: Zhao Liu --- rust/qemu-api/meson.build | 3 +++ rust/qemu-api/src/tests.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 42ea815fa5a..436e2f1e836 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -5,6 +5,7 @@ _qemu_api_rs =3D static_library( 'src/lib.rs', 'src/definitions.rs', 'src/device_class.rs', + 'src/tests.rs', ], {'.' : bindings_rs}, ), @@ -19,6 +20,8 @@ _qemu_api_rs =3D static_library( ], ) =20 +rust.test('rust-qemu-api-tests', _qemu_api_rs) + qemu_api =3D declare_dependency( link_with: _qemu_api_rs, ) diff --git a/rust/qemu-api/src/tests.rs b/rust/qemu-api/src/tests.rs index df54edbd4e2..f0cd4d5d716 100644 --- a/rust/qemu-api/src/tests.rs +++ b/rust/qemu-api/src/tests.rs @@ -43,7 +43,7 @@ pub struct DummyState { dummy_class_init, props =3D> DUMMY_PROPERTIES, realize_fn =3D> None, - reset_fn =3D> None, + legacy_reset_fn =3D> None, vmsd =3D> VMSTATE, } } --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998415; cv=none; d=zohomail.com; s=zohoarc; b=iXQWSIHwS6WWdxcXIP1Qe2Xk6Rkm0GwDFg3RoJMxt7F15nfTxUkVYSn464bwEwDZtebuNY2jkJXBYK8HAz+x/+VJ3j+iSqt+Jh2cqmGEs2f0iUKrtGLF1mihpQU7vbCTdlNI9P/lRV6UiT0vWzQ8Sqj81VJ+L0DMHfgQV7Gi30k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998415; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=mSJy+BswT8rFNNdI2QF0Qc2703bnkbHCgHm0DMWaW6Y=; b=Sr51jeEWl6Is9f/UjaBGJcW3NZaXpmDltYnEB37xyAFaiJgvU1fy8T7Q0xGdhH0tzAKg8+Ar+0yQ/FCMGfZtyq3XsZ02SxHZTySDyMnh5JXNeXaG2XiF4INrY9wBPD/6A6LRZ9Z3VrdMejmMnIa8APHVsyWPJPmdQf14dT9QcRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998415329966.4433913745854; Tue, 15 Oct 2024 06:20:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRJ-000270-5j; Tue, 15 Oct 2024 09:18:17 -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 1t0hRH-00026G-2f for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0hRE-0001I6-Ss for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:14 -0400 Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-WOJBC0pvMUiVA9zhEoIukw-1; Tue, 15 Oct 2024 09:18:09 -0400 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-539e75025f9so1885914e87.3 for ; Tue, 15 Oct 2024 06:18:09 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f6b31b9sm17840825e9.29.2024.10.15.06.18.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998290; 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: in-reply-to:in-reply-to:references:references; bh=mSJy+BswT8rFNNdI2QF0Qc2703bnkbHCgHm0DMWaW6Y=; b=WMruTlJ6MzFLSSuUJBe4q0AsQSSY3mKtbodMl/j97Pu8NwPHXaTr8UXTAQw3VYZnuKcSDE ZkdaP7+RuoYWFZJtbKR9LAHI4fWEUWDBi+ytQSzXSADm5j1bTyrITGUgccryrUEsux5vUU Ws42PLcJBR8C5PGp61Nobs4yz0S+7c8= X-MC-Unique: WOJBC0pvMUiVA9zhEoIukw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998287; x=1729603087; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mSJy+BswT8rFNNdI2QF0Qc2703bnkbHCgHm0DMWaW6Y=; b=mAWHGXTsz9x3WGp+6P9aU7wBzzOiVNhuW6vAWx9eJ/kLEvjb/8qJ3XD9Vkyd5JZ9B6 ZXO00qfQgrXPO/5eTC/akzFBfWf9myQ60Y8oWqZZtnWLDhrlK9fRvyGHGR0s65Ds9SHo nM2bh8WtfbO+aTHKbb5Bvi5ZL+Sm3k6wjQ4xgoDS2o5TX3W2JRFiMvJOjvwWk5ltyM0I peu2OCXgfY7VTeI7kmqoTn+/ml3PYucDnyQYLx4H0VsHl+F9A55vOxtVa1nAQBMbMMSA nZ4tJuzG72qJ1+KY0jLVMTfi2JuiKIzwA6xln5bAC1hc8L+aG7jOkKdwvBCLxNpmjcBm NOaA== X-Gm-Message-State: AOJu0Yw5Ka07J4wX8Y0v4NahqVMi6aGSk1HwcwMYqBvJnVWj0x6FOXEs wktXetucTx4No7faZ3HICA2jN4FMgz9D73L6HlGRN1Wqx1wvPXV+wYLWP5ORRKIkwUXZ3FYCAzk Hd9CdkfXCOrnF7YwK6er9FX4CexVs3tyR9NlKW5ntEo3qkyzW4ngER1iCWXKypJXJmO1ZXuEitJ O8BiZ/bPWC0cmGRj9bHkItsLMpyLuTvLQKWOT3NN4= X-Received: by 2002:a05:6512:39cb:b0:536:554a:24c2 with SMTP id 2adb3069b0e04-53a03f18ddamr217623e87.13.1728998286752; Tue, 15 Oct 2024 06:18:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW8IpPiS0mrUwgvOXGSwYEkPzEJgqtWQdAERWMRai+qN+ZR357sT9utkGh3RWjxxXJuR79NA== X-Received: by 2002:a05:6512:39cb:b0:536:554a:24c2 with SMTP id 2adb3069b0e04-53a03f18ddamr217596e87.13.1728998286018; Tue, 15 Oct 2024 06:18:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/16] rust: introduce a c_str macro Date: Tue, 15 Oct 2024 15:17:27 +0200 Message-ID: <20241015131735.518771-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998415760116600 Content-Type: text/plain; charset="utf-8" This allows CStr constants to be defined easily on Rust 1.63.0, while checking that there are no embedded NULs. c"" literals were only stabilized in Rust 1.77.0. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 3 +- rust/hw/char/pl011/src/device_class.rs | 10 +++-- rust/hw/char/pl011/src/lib.rs | 4 +- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/c_str.rs | 52 ++++++++++++++++++++++++++ rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/tests.rs | 8 ++-- 7 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 rust/qemu-api/src/c_str.rs diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index cd4c01c2336..55d933ee5e9 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -11,6 +11,7 @@ =20 use qemu_api::{ bindings::{self, *}, + c_str, definitions::ObjectImpl, }; =20 @@ -99,7 +100,7 @@ impl qemu_api::definitions::Class for PL011Class { } =20 #[used] -pub static CLK_NAME: &CStr =3D c"clk"; +pub static CLK_NAME: &CStr =3D c_str!("clk"); =20 impl PL011State { /// Initializes a pre-allocated, unitialized instance of `PL011State`. diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index b7ab31af02d..a3d1b1e929a 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -4,7 +4,11 @@ =20 use core::ptr::NonNull; =20 -use qemu_api::{bindings::*, definitions::ObjectImpl}; +use qemu_api::{ + bindings::*, + c_str, + definitions::ObjectImpl +}; =20 use crate::device::PL011State; =20 @@ -18,14 +22,14 @@ qemu_api::declare_properties! { PL011_PROPERTIES, qemu_api::define_property!( - c"chardev", + c_str!("chardev"), PL011State, char_backend, unsafe { &qdev_prop_chr }, CharBackend ), qemu_api::define_property!( - c"migrate-clk", + c_str!("migrate-clk"), PL011State, migrate_clock, unsafe { &qdev_prop_bool }, diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index 2b157868b0f..0a598e5629d 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -41,11 +41,13 @@ extern crate bilge_impl; extern crate qemu_api; =20 +use qemu_api::c_str; + pub mod device; pub mod device_class; pub mod memory_ops; =20 -pub const TYPE_PL011: &::std::ffi::CStr =3D c"pl011"; +pub const TYPE_PL011: &::std::ffi::CStr =3D c_str!("pl011"); =20 /// Offset of each register from the base memory address of the device. /// diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 436e2f1e836..b55931c6490 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -3,6 +3,7 @@ _qemu_api_rs =3D static_library( structured_sources( [ 'src/lib.rs', + 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', 'src/tests.rs', diff --git a/rust/qemu-api/src/c_str.rs b/rust/qemu-api/src/c_str.rs new file mode 100644 index 00000000000..0286dade306 --- /dev/null +++ b/rust/qemu-api/src/c_str.rs @@ -0,0 +1,52 @@ +// Copyright 2024 Red Hat, Inc. +// Author(s): Paolo Bonzini +// SPDX-License-Identifier: GPL-2.0-or-later + +#[macro_export] +/// Given a string constant _without_ embedded or trailing NULs, return +/// a CStr. +/// +/// Needed for compatibility with Rust <1.77. +macro_rules! c_str { + ($str:expr) =3D> {{ + const STRING: &str =3D concat!($str, "\0"); + const BYTES: &[u8] =3D STRING.as_bytes(); + + // "for" is not allowed in const context... oh well, + // everybody loves some lisp. This could be turned into + // a procedural macro if this is a problem; alternatively + // Rust 1.72 makes CStr::from_bytes_with_nul a const function. + const fn f(b: &[u8], i: usize) { + if i =3D=3D BYTES.len() - 1 {} + else if BYTES[i] =3D=3D 0 { + panic!("c_str argument contains NUL") + } else { + f(b, i + 1) + } + } + f(BYTES, 0); + + // SAFETY: absence of NULs apart from the final byte was checked a= bove + unsafe { std::ffi::CStr::from_bytes_with_nul_unchecked(BYTES) } + }}; +} + +#[cfg(test)] +mod tests { + use std::ffi::CStr; + use crate::c_str; + + #[test] + fn test_cstr_macro() { + let good =3D c_str!("=F0=9F=A6=80"); + let good_bytes =3D b"\xf0\x9f\xa6\x80\0"; + assert_eq!(good.to_bytes_with_nul(), good_bytes); + } + + #[test] + fn test_cstr_macro_const() { + const GOOD: &CStr =3D c_str!("=F0=9F=A6=80"); + const GOOD_BYTES: &[u8] =3D b"\xf0\x9f\xa6\x80\0"; + assert_eq!(GOOD.to_bytes_with_nul(), GOOD_BYTES); + } +} diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index c2f60ac4727..9b2483fbfa3 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -27,6 +27,7 @@ unsafe impl Sync for bindings::Property {} unsafe impl Sync for bindings::TypeInfo {} unsafe impl Sync for bindings::VMStateDescription {} =20 +pub mod c_str; pub mod definitions; pub mod device_class; =20 diff --git a/rust/qemu-api/src/tests.rs b/rust/qemu-api/src/tests.rs index f0cd4d5d716..d34b8d24187 100644 --- a/rust/qemu-api/src/tests.rs +++ b/rust/qemu-api/src/tests.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 use crate::{ - bindings::*, declare_properties, define_property, device_class_init, v= m_state_description, + bindings::*, c_str, declare_properties, define_property, device_class_= init, vm_state_description, }; =20 #[test] @@ -11,7 +11,7 @@ fn test_device_decl_macros() { // Test that macros can compile. vm_state_description! { VMSTATE, - name: c"name", + name: c_str!("name"), unmigratable: true, } =20 @@ -24,14 +24,14 @@ pub struct DummyState { declare_properties! { DUMMY_PROPERTIES, define_property!( - c"chardev", + c_str!("chardev"), DummyState, char_backend, unsafe { &qdev_prop_chr }, CharBackend ), define_property!( - c"migrate-clk", + c_str!("migrate-clk"), DummyState, migrate_clock, unsafe { &qdev_prop_bool }, --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998407; cv=none; d=zohomail.com; s=zohoarc; b=dlSnDc/zdw1BoD+fKWn+z5vgVcI8Idk/eO6aCKT5mp12rARGeKt0WX2XwSGAlDUcNAb1HvElEFbGlnXI25WQSgY0ZAzcu5T64O7UvCjCTiIjp8d6FZvsjjwsYoD/DS0ta1io381+YG0dViySFBMFx3mUXVSndix5C7fRSxd6LXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998407; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=phALTCJWI1ZZcq7L1OJeDibGPB+sOPLHD87meXDFea4=; b=MOs8awTF9WPNmrc0aoj6elunDO05AFVIQerKeHXoiKraafMwQINZNPkkcLF+YtCXX7Lls/5dG4cTZ4YBP+6PnsiPHA84+l75RI2eNDv7M6aFtQ4Zk0BZC7FqRyMvN5eudLOka7yC7eQGxq5cSVZZdlwHZCHy+EWGR7QmIm0ESUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998407113504.8836040838306; Tue, 15 Oct 2024 06:20:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRP-00027U-NI; Tue, 15 Oct 2024 09:18:23 -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 1t0hRO-00027C-Ms for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:22 -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 1t0hRJ-0001J8-OL for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:20 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-qw5qd6aVPCSpdfZ38tuC3w-1; Tue, 15 Oct 2024 09:18:12 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4314a22ed8bso1073885e9.1 for ; Tue, 15 Oct 2024 06:18:12 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fa87c44sm1557662f8f.33.2024.10.15.06.18.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=phALTCJWI1ZZcq7L1OJeDibGPB+sOPLHD87meXDFea4=; b=iIFRPaV47KZnMxQlk75FZl8K9efjlRreC3IEoxvH9i+o6XvPclD/U7uOFql0bjN1y+fXYE 8k6oo7Ur/LNYKIv225H3HL32enbau6+gocKUfoamRPE4h7uQy+FFYmOPsfjPk4GbITWfD1 sxXbLncAPttZ8ZEz0TOsL99OIovVf0g= X-MC-Unique: qw5qd6aVPCSpdfZ38tuC3w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998291; x=1729603091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=phALTCJWI1ZZcq7L1OJeDibGPB+sOPLHD87meXDFea4=; b=KN3joz8Y3gsRaSiIuSpK+uB2+azWeJ1wzbZK7Cmj7JQcQh/zD8lDnnU4roEX7iMqdX t6MBZjeBNf+LjBq+PX9U8+PhZwybg5sDILpdryfF6A3u0H4fbtELAx35fDoUw5qduQqV iKr7pNz+DY2KdpG5qDgsi/a9B5rok7JykR3JnspSUVfbw8v7hAmRZviX4nBppt9EyD/O /fHOe0FGo06KHcLcdyjH7RJ3OkxmqAozl0Dm/G6J8uvDaBiyZZCUGTQTbV6xYU6vIT6F AGpOiK5tkbyoHE7lN8RIuCUMxm86Njng26qitwB8ycRBdxY6KwL7zPw1nLRFUW+jBRhl eHFw== X-Gm-Message-State: AOJu0Yygy+4x2klEfGrvuIPNu4GAIqcJh2KyQoj8s4SEbO/dh2mXDfBg Mqy5YGaMky8SYOp9e1+FiJDf7jYxdjJHhuyGZu0PQ5nAwRjbDlUZO+gdRfyLwQ5uBYfswlLhSmo JqbafZX9SzrSn3OgJ/i/ber1U6S6iyejSCJirnIIDS7q+oSZWlM+8veVopHfvzR14WD5XGA7swF /ev6BQNyQQJx/93oJr28Itr8cKAeDh3wODlVdTQzo= X-Received: by 2002:a05:600c:4f88:b0:431:416e:2612 with SMTP id 5b1f17b1804b1-431416e2919mr18797945e9.32.1728998290736; Tue, 15 Oct 2024 06:18:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyfp6Hy1zQItJ5AqjaWJI7zZoccMsoLfeRXEFBRUhJ6k2+v/4EY2zeywqyyvbjGkXgEZxuAQ== X-Received: by 2002:a05:600c:4f88:b0:431:416e:2612 with SMTP id 5b1f17b1804b1-431416e2919mr18797535e9.32.1728998289969; Tue, 15 Oct 2024 06:18:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/16] rust: introduce alternative implementation of offset_of! Date: Tue, 15 Oct 2024 15:17:28 +0200 Message-ID: <20241015131735.518771-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998407661116600 Content-Type: text/plain; charset="utf-8" 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 can be used just by replacing core::mem::offset_of! with qemu_api::offset_of!. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 91 ++++++++++++------------- rust/qemu-api/meson.build | 12 ++-- rust/qemu-api/src/device_class.rs | 8 +-- rust/qemu-api/src/lib.rs | 4 ++ rust/qemu-api/src/offset_of.rs | 106 ++++++++++++++++++++++++++++++ rust/qemu-api/src/tests.rs | 11 ++-- 6 files changed, 176 insertions(+), 56 deletions(-) create mode 100644 rust/qemu-api/src/offset_of.rs diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 55d933ee5e9..f331a13b5f1 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -13,6 +13,7 @@ bindings::{self, *}, c_str, definitions::ObjectImpl, + with_offsets, }; =20 use crate::{ @@ -28,50 +29,52 @@ /// QEMU sourced constant. pub const PL011_FIFO_DEPTH: usize =3D 16_usize; =20 -#[repr(C)] -#[derive(Debug, qemu_api_macros::Object)] -/// PL011 Device Model in QEMU -pub struct PL011State { - pub parent_obj: SysBusDevice, - pub iomem: MemoryRegion, - #[doc(alias =3D "fr")] - pub flags: registers::Flags, - #[doc(alias =3D "lcr")] - pub line_control: registers::LineControl, - #[doc(alias =3D "rsr")] - pub receive_status_error_clear: registers::ReceiveStatusErrorClear, - #[doc(alias =3D "cr")] - pub control: registers::Control, - pub dmacr: u32, - pub int_enabled: u32, - pub int_level: u32, - pub read_fifo: [u32; PL011_FIFO_DEPTH], - pub ilpr: u32, - pub ibrd: u32, - pub fbrd: u32, - pub ifl: u32, - pub read_pos: usize, - pub read_count: usize, - pub read_trigger: usize, - #[doc(alias =3D "chr")] - pub char_backend: CharBackend, - /// QEMU interrupts - /// - /// ```text - /// * sysbus MMIO region 0: device registers - /// * sysbus IRQ 0: `UARTINTR` (combined interrupt line) - /// * sysbus IRQ 1: `UARTRXINTR` (receive FIFO interrupt line) - /// * sysbus IRQ 2: `UARTTXINTR` (transmit FIFO interrupt line) - /// * sysbus IRQ 3: `UARTRTINTR` (receive timeout interrupt line) - /// * sysbus IRQ 4: `UARTMSINTR` (momem status interrupt line) - /// * sysbus IRQ 5: `UARTEINTR` (error interrupt line) - /// ``` - #[doc(alias =3D "irq")] - pub interrupts: [qemu_irq; 6usize], - #[doc(alias =3D "clk")] - pub clock: NonNull, - #[doc(alias =3D "migrate_clk")] - pub migrate_clock: bool, +with_offsets! { + #[repr(C)] + #[derive(Debug, qemu_api_macros::Object)] + /// PL011 Device Model in QEMU + pub struct PL011State { + pub parent_obj: SysBusDevice, + pub iomem: MemoryRegion, + #[doc(alias =3D "fr")] + pub flags: registers::Flags, + #[doc(alias =3D "lcr")] + pub line_control: registers::LineControl, + #[doc(alias =3D "rsr")] + pub receive_status_error_clear: registers::ReceiveStatusErrorClear, + #[doc(alias =3D "cr")] + pub control: registers::Control, + pub dmacr: u32, + pub int_enabled: u32, + pub int_level: u32, + pub read_fifo: [u32; PL011_FIFO_DEPTH], + pub ilpr: u32, + pub ibrd: u32, + pub fbrd: u32, + pub ifl: u32, + pub read_pos: usize, + pub read_count: usize, + pub read_trigger: usize, + #[doc(alias =3D "chr")] + pub char_backend: CharBackend, + /// QEMU interrupts + /// + /// ```text + /// * sysbus MMIO region 0: device registers + /// * sysbus IRQ 0: `UARTINTR` (combined interrupt line) + /// * sysbus IRQ 1: `UARTRXINTR` (receive FIFO interrupt line) + /// * sysbus IRQ 2: `UARTTXINTR` (transmit FIFO interrupt line) + /// * sysbus IRQ 3: `UARTRTINTR` (receive timeout interrupt line) + /// * sysbus IRQ 4: `UARTMSINTR` (momem status interrupt line) + /// * sysbus IRQ 5: `UARTEINTR` (error interrupt line) + /// ``` + #[doc(alias =3D "irq")] + pub interrupts: [qemu_irq; 6usize], + #[doc(alias =3D "clk")] + pub clock: NonNull, + #[doc(alias =3D "migrate_clk")] + pub migrate_clock: bool, + } } =20 impl ObjectImpl for PL011State { diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index b55931c6490..57f813fc8f9 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,3 +1,9 @@ +_qemu_api_cfg =3D ['--cfg', 'MESON'] +# _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] +if rustc.version().version_compare('>=3D1.77.0') + _qemu_api_cfg +=3D ['--cfg', 'has_offset_of'] +endif + _qemu_api_rs =3D static_library( 'qemu_api', structured_sources( @@ -6,16 +12,14 @@ _qemu_api_rs =3D static_library( 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', + 'src/offset_of.rs', 'src/tests.rs', ], {'.' : bindings_rs}, ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', - rust_args: [ - '--cfg', 'MESON', - # '--cfg', 'feature=3D"allocator"', - ], + rust_args: _qemu_api_cfg, dependencies: [ qemu_api_macros, ], diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 871063d4a92..d4fa544df39 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -26,7 +26,7 @@ macro_rules! device_class_init { =20 #[macro_export] macro_rules! define_property { - ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { + ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { $crate::bindings::Property { name: { #[used] @@ -34,7 +34,7 @@ macro_rules! define_property { _TEMP.as_ptr() }, info: $prop, - offset: ::core::mem::offset_of!($state, $field) + offset: $crate::offset_of!($state, $field) .try_into() .expect("Could not fit offset value to type"), bitnr: 0, @@ -47,7 +47,7 @@ macro_rules! define_property { link_type: ::core::ptr::null(), } }; - ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { + ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr$(,)*) =3D= > { $crate::bindings::Property { name: { #[used] @@ -55,7 +55,7 @@ macro_rules! define_property { _TEMP.as_ptr() }, info: $prop, - offset: ::core::mem::offset_of!($state, $field) + offset: $crate::offset_of!($state, $field) .try_into() .expect("Could not fit offset value to type"), bitnr: 0, diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 9b2483fbfa3..082f1addb10 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -30,6 +30,7 @@ unsafe impl Sync for bindings::VMStateDescription {} pub mod c_str; pub mod definitions; pub mod device_class; +pub mod offset_of; =20 #[cfg(test)] mod tests; @@ -167,3 +168,6 @@ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { } } } + +#[cfg(has_offset_of)] +pub use std::mem::offset_of; diff --git a/rust/qemu-api/src/offset_of.rs b/rust/qemu-api/src/offset_of.rs new file mode 100644 index 00000000000..4e1de373674 --- /dev/null +++ b/rust/qemu-api/src/offset_of.rs @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: MIT + +/// This macro provides the same functionality as `core::mem::offset_of`, +/// except that only one level of field access is supported. The declarat= ion +/// of the struct must be wrapped with `with_offsets! { }`. +/// +/// It is needed because `offset_of!` was only stabilized in Rust 1.77. +#[cfg(not(has_offset_of))] +#[macro_export] +macro_rules! offset_of { + ($Container:ty, $field:ident) =3D> { + <$Container>::offset_to.$field + }; +} + +/// A wrapper for struct declarations, that allows using `offset_of!` in +/// versions of Rust prior to 1.77 +#[macro_export] +macro_rules! with_offsets { + // source: https://play.rust-lang.org/?version=3Dstable&mode=3Ddebug&e= dition=3D2018&gist=3D10a22a9b8393abd7b541d8fc844bc0df + // used under MIT license with permission of Yandros aka Daniel Henry-= Mantilla + ( + #[repr(C)] + $(#[$struct_meta:meta])* + $struct_vis:vis + struct $StructName:ident { + $( + $(#[$field_meta:meta])* + $field_vis:vis + $field_name:ident : $field_ty:ty + ),* + $(,)? + } + ) =3D> ( + #[repr(C)] + $(#[$struct_meta])* + $struct_vis + struct $StructName { + $( + $(#[$field_meta])* + $field_vis + $field_name : $field_ty , + )* + } + + #[cfg(not(has_offset_of))] + #[allow(nonstandard_style)] + const _: () =3D { + pub + struct StructOffsets { + $( + $field_vis + $field_name: usize, + )* + } + struct Helper; + impl $StructName { + pub + const offset_to: StructOffsets =3D StructOffsets { + $( + $field_name: Helper::$field_name, + )* + }; + } + const END_OF_PREV_FIELD: usize =3D 0; + $crate::with_offsets! { + @names [ $($field_name)* ] + @tys [ $($field_ty ,)*] + } + }; + ); + + ( + @names [] + @tys [] + ) =3D> (); + + ( + @names [$field_name:ident $($other_names:tt)*] + @tys [$field_ty:ty , $($other_tys:tt)*] + ) =3D> ( + impl Helper { + const $field_name: usize =3D { + let align =3D + std::mem::align_of::<$field_ty>() + ; + let trail =3D + END_OF_PREV_FIELD % align + ; + 0 + END_OF_PREV_FIELD + + (align - trail) + * [1, 0][(trail =3D=3D 0) as usize] + }; + } + const _: () =3D { + const END_OF_PREV_FIELD: usize =3D + Helper::$field_name + + std::mem::size_of::<$field_ty>() + ; + $crate::with_offsets! { + @names [$($other_names)*] + @tys [$($other_tys)*] + } + }; + ); +} diff --git a/rust/qemu-api/src/tests.rs b/rust/qemu-api/src/tests.rs index d34b8d24187..b582f27baa1 100644 --- a/rust/qemu-api/src/tests.rs +++ b/rust/qemu-api/src/tests.rs @@ -4,6 +4,7 @@ =20 use crate::{ bindings::*, c_str, declare_properties, define_property, device_class_= init, vm_state_description, + with_offsets, }; =20 #[test] @@ -15,10 +16,12 @@ fn test_device_decl_macros() { unmigratable: true, } =20 - #[repr(C)] - pub struct DummyState { - pub char_backend: CharBackend, - pub migrate_clock: bool, + with_offsets! { + #[repr(C)] + pub struct DummyState { + pub char_backend: CharBackend, + pub migrate_clock: bool, + } } =20 declare_properties! { --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998418; cv=none; d=zohomail.com; s=zohoarc; b=M9czxn/YBfiZozA7dNA+TJQu44CsSKwwLwWX3/VxcQ9Itml0+I2dSiyiULreHXdwVHu0XxX8lNo/IagXKQc46A4K2u0q10biAD8o4vntCs5NoDCyt5O3sxK7rsmQp2nyqayGwCubykxDyC3cIJsaVX+AuzgEacjVez4JctgkUiI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998418; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=NkEvuhMOPAMN7lnR0ouyDabIAyuNADYTX1dRMur0+m0=; b=bOKxLhHhcUinh5DHdbPUhd/mDEw/FZOm6EzKET1bmx62IAgq1emSrmYhEOocPYJOSIsyIichBs9OE2IvgiicB7fR6WtEARU280T4yDRCuzeo+W6L0L+0f9tmbgXzVG1d88vnxDD//sPNj6t1dCIa5PTyHavLSvMX1gzgxfMV96w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998418062318.2518182844185; Tue, 15 Oct 2024 06:20:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRQ-00027i-QD; Tue, 15 Oct 2024 09:18:25 -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 1t0hRO-00027D-NA for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0hRK-0001Kq-Qx for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:22 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-jYEpXeqBPheLbgMg6Q2qQg-1; Tue, 15 Oct 2024 09:18:15 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d603515cfso1317228f8f.1 for ; Tue, 15 Oct 2024 06:18:15 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fa9090asm1565509f8f.57.2024.10.15.06.18.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NkEvuhMOPAMN7lnR0ouyDabIAyuNADYTX1dRMur0+m0=; b=MczpqMTH8lkvleT899oXyeL7paDRT1hkew90AMV6zJzAFAKT9Qc8ICAj4FZW+6DfJRhY/K 1POK7CX6y8g5+KsYmvM93imzjffDswRDCHlSHzXdB5ncCQ4FIJzy3v1Rc/fk7bjVpyjykK TNx8bdk6Y0T9UT3fivd5qnLw6BN4Gn8= X-MC-Unique: jYEpXeqBPheLbgMg6Q2qQg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998294; x=1729603094; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NkEvuhMOPAMN7lnR0ouyDabIAyuNADYTX1dRMur0+m0=; b=m1WexgKn49eZc6QehmDOppVH5DlQAGMY3myOqcoXABGBdhLjglRLHG4CZ8FEIzDziq TIV3hamZg77x49jyNWGCoO6rbG38m3HEikmNEDiAqbfoHfiFCrv/FVXj66CiwXExj+no MTtQdOTRLzTurTXjuO0U7B2PuhyHN5a08kpFHDQVInW40ElFYpofZFCaPHASwZ9XgH2E h2HWVxlDFNjHuItVRI69fkYyB+xZkSGDc/ZiXPZGXS53qYGK6FpFnf/fhF4QcJISUm8F fGT30Ja7q31NZEMYWR2RF0ShjDGJs30H9vXvZtjBJWVoB3DWi/SIGk+Yc4mXl5Ej9zym QRzw== X-Gm-Message-State: AOJu0YzaGkvmOHUKqSTYetLLIVvkVBVOdpXvg1nZC0PI6oTNmOwoxdD3 7dxuvgpb26fRS9OkJJhpQU9UD7zw9iebEDi87omIHtpF7PG4sXJNn3OdHMvEDWWQ8HnMJJ8rkBN oZovnadcxME0nR+sIKvC/akE/OYODxLEZquZ6fj/6XkdyXIEMtlLpK9Shq/um/dUr8CgEqwkkGI a1KHASnpTDyxxSD0WUVS3OmpUxoRj7nHQg0BF/Voc= X-Received: by 2002:a5d:4f84:0:b0:37d:377f:51e6 with SMTP id ffacd0b85a97d-37d5ffb3611mr8124421f8f.56.1728998293654; Tue, 15 Oct 2024 06:18:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaG95vug18FDwMQ5amOXCt7Hv7dIHE8q0TMIPOeaEbftqGGEr0FJC0Ub4VldF2tiHOkp0WeA== X-Received: by 2002:a5d:4f84:0:b0:37d:377f:51e6 with SMTP id ffacd0b85a97d-37d5ffb3611mr8124393f8f.56.1728998293108; Tue, 15 Oct 2024 06:18:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/16] rust: do not use MaybeUninit::zeroed() Date: Tue, 15 Oct 2024 15:17:29 +0200 Message-ID: <20241015131735.518771-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998419678116600 Content-Type: text/plain; charset="utf-8" MaybeUninit::zeroed() is handy, but it introduces unsafe (and has a pretty = heavy syntax in general) and anyway it is not available as a "const" function unt= il Rust 1.75.0. Introduce a trait that provides the same functionality while staying within safe Rust. In the future we may want to add automatic derivation and implementation of the trait, once we can assume Rust 1.75.0; for now the implementation is manual. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device_class.rs | 5 +- rust/hw/char/pl011/src/memory_ops.rs | 11 ++-- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/device_class.rs | 4 +- rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/zeroable.rs | 75 ++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 rust/qemu-api/src/zeroable.rs diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index a3d1b1e929a..37bbf6d36cc 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -7,7 +7,8 @@ use qemu_api::{ bindings::*, c_str, - definitions::ObjectImpl + definitions::ObjectImpl, + zeroable::Zeroable, }; =20 use crate::device::PL011State; @@ -16,7 +17,7 @@ pub static VMSTATE_PL011: VMStateDescription =3D VMStateDescription { name: PL011State::TYPE_INFO.name, unmigratable: true, - ..unsafe { ::core::mem::MaybeUninit::::zeroed().as= sume_init() } + ..Zeroable::ZERO }; =20 qemu_api::declare_properties! { diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/= memory_ops.rs index 2c664fd45ed..88d17ec2e3a 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -2,11 +2,14 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::{mem::MaybeUninit, ptr::NonNull}; +use core::ptr::NonNull; =20 use std::os::raw::{c_uint, c_void}; =20 -use qemu_api::bindings::*; +use qemu_api::{ + bindings::*, + zeroable::Zeroable +}; =20 use crate::device::PL011State; =20 @@ -16,11 +19,11 @@ read_with_attrs: None, write_with_attrs: None, endianness: device_endian::DEVICE_NATIVE_ENDIAN, - valid: unsafe { MaybeUninit::::zeroed()= .assume_init() }, + valid: Zeroable::ZERO, impl_: MemoryRegionOps__bindgen_ty_2 { min_access_size: 4, max_access_size: 4, - ..unsafe { MaybeUninit::::zeroed().= assume_init() } + ..Zeroable::ZERO }, }; =20 diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 57f813fc8f9..547fc5caa3a 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -14,6 +14,7 @@ _qemu_api_rs =3D static_library( 'src/device_class.rs', 'src/offset_of.rs', 'src/tests.rs', + 'src/zeroable.rs', ], {'.' : bindings_rs}, ), diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index d4fa544df39..d2535125c48 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -100,7 +100,7 @@ const fn _calc_prop_len() -> usize { fn _make_properties() -> [$crate::bindings::Property; PROP_LEN] { [ $($prop),*, - unsafe { ::core::mem::MaybeUninit::<$crate::bindings::= Property>::zeroed().assume_init() }, + $crate::zeroable::Zeroable::ZERO, ] } =20 @@ -125,7 +125,7 @@ macro_rules! vm_state_description { $vname.as_ptr() },)* unmigratable: true, - ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::VMStat= eDescription>::zeroed().assume_init() } + ..$crate::zeroable::Zeroable::ZERO }; } } diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 082f1addb10..50951d20e14 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -31,6 +31,7 @@ unsafe impl Sync for bindings::VMStateDescription {} pub mod definitions; pub mod device_class; pub mod offset_of; +pub mod zeroable; =20 #[cfg(test)] mod tests; diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs new file mode 100644 index 00000000000..faa93d1fb33 --- /dev/null +++ b/rust/qemu-api/src/zeroable.rs @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +use std::ptr; + +/// This trait provides a replacement for core::mem::zeroed() that can be +/// used as a `const fn` prior to Rust 1.75.0. As an added bonus it remov= es +/// usage of `unsafe` blocks. +/// +/// Unlike other Zeroable traits found in other crates (e.g. +/// [`pinned_init`](https://docs.rs/pinned-init/latest/pinned_init/trait.Z= eroable.html)) +/// this is a safe trait because the value `ZERO` constant has to be writt= en by +/// hand. The `pinned_init` crate instead makes the trait unsafe, but it +/// provides a `#[derive(Zeroable)]` macro to define it with compile-time +/// safety checks. Once we can assume Rust 1.75.0 is available, we could +/// switch to their idea, and use `core::mem::zeroed()` to provide a blank= ed +/// implementation of the `ZERO` constant. +pub trait Zeroable: Default { + const ZERO: Self; +} + +impl Zeroable for crate::bindings::Property__bindgen_ty_1 { + const ZERO: Self =3D Self { i: 0 }; +} + +impl Zeroable for crate::bindings::Property { + const ZERO: Self =3D Self { + name: ptr::null(), + info: ptr::null(), + offset: 0, + bitnr: 0, + bitmask: 0, + set_default: false, + defval: Zeroable::ZERO, + arrayoffset: 0, + arrayinfo: ptr::null(), + arrayfieldsize: 0, + link_type: ptr::null(), + }; +} + +impl Zeroable for crate::bindings::VMStateDescription { + const ZERO: Self =3D Self { + name: ptr::null(), + unmigratable: false, + early_setup: false, + version_id: 0, + minimum_version_id: 0, + priority: crate::bindings::MigrationPriority::MIG_PRI_DEFAULT, + pre_load: None, + post_load: None, + pre_save: None, + post_save: None, + needed: None, + dev_unplug_pending: None, + fields: ptr::null(), + subsections: ptr::null(), + }; +} + +impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 { + const ZERO: Self =3D Self { + min_access_size: 0, + max_access_size: 0, + unaligned: false, + accepts: None, + }; +} + +impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 { + const ZERO: Self =3D Self { + min_access_size: 0, + max_access_size: 0, + unaligned: false, + }; +} --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998377; cv=none; d=zohomail.com; s=zohoarc; b=cL5yyyCVeD7tHe9Lr2G86phpxUbF2+4yaSn6RWB2jkvAM2ZiQzIKNCiVMy0DBEqJho+Z/bosKLTeamkbz5DHhIZB9mWTADJDFtYFaDm4udvB9LzDklS7NQf/c9C/lduYMc+mwTBbAw0OBlPo6rtKjuOJQKjwHv547d1Z0dakIEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998377; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=B1nRIJjPfPQ6iCRHb6OEJ4R5L0lI8jOfA213Zh847Ko=; b=h9vYz0Z4PfD/Qfslmj6JKV2bEDPnpUF2OoS42Pj7BnQZM4SYgVktyoq6AWwEapXDIKMa+hBIdoO1G2wawsV9QhK7XpsRRIIdILizcMWGAUqbI+IZCxAgW0vOoxP2c0KmLpMSIO48K1lPN7P3PXI49L0UjKYx6QzMj/tPM4F6V7o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998377090582.6890500402702; Tue, 15 Oct 2024 06:19:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRS-00028O-9p; Tue, 15 Oct 2024 09:18:26 -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 1t0hRP-00027V-RB for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:23 -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 1t0hRN-0001Mq-3h for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:23 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-457-comyW0wQPtqIfJ9C8BHQAA-1; Tue, 15 Oct 2024 09:18:17 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43113dab986so47355335e9.2 for ; Tue, 15 Oct 2024 06:18:17 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f56eab2sm17749705e9.26.2024.10.15.06.18.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B1nRIJjPfPQ6iCRHb6OEJ4R5L0lI8jOfA213Zh847Ko=; b=VI5XiTQAP2fdQM/Bdnh9AqfGvLFrOm7pw5lD2m9sBruqlMqItQU1P6g7zDqzzWYEzbjjHT Vah/FTDKgukINLwh0FV+34pk+R721HwgCSL9+WgcCekDn2egCdxrP5nXaMuZa8MnIlWmnb D/P33T/2zts7ubDLsI5vSSlIhHMa+0E= X-MC-Unique: comyW0wQPtqIfJ9C8BHQAA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998296; x=1729603096; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B1nRIJjPfPQ6iCRHb6OEJ4R5L0lI8jOfA213Zh847Ko=; b=HvzJ8a+v7qtyjrNs1Fz44QvR3E1W0kNUAlyAtGoVKeYbS4M0Gl6DdRqTuk8/PbwzQA trq0SEB3ykko8Y67P4NZFznjlk5LwqLfjxjWCo6zWqP4D4yEeGbOjOann2cX7wbKS0mL QHRU993Fj2qjxS3peqsJfM6OJgZhSnJ3b9iXuW7M8Abp5l8EqBXZdpPRrNFNoolxmf8T DWivHu9zr7lzcLo4xOdijttCXRzajhKilhXw8oXyDfRK+o8YmjZcLuYnRlwuF4xD4UfE 3G00Q/xDvapF4bmDEpklLfX6x6Dp8TNb0wRGGG6Xa1/iCupeKPh1xcPAGvqEE3vJpDCg X5dA== X-Gm-Message-State: AOJu0YwhT/EYdquQQzHgP+9HGem+V4V7qAqOJbxCpZXnXgtTD9jKppxw +VE+8nHGiOzxyjQ9dLKH2HUbYEgs8DpTutP17+T/eH5K7lDM5JXN3A0irpvFVvqreoshG/J11kd Evn07AKownaRyS1D//dET/GnAOeTZRsCncQO+LfLOawOnuauz2yFLB/1TOquN+M0zEOXkZb8vQc Xg12+unKbe5hhpAYbRWyA2y1F9UgrbYGQTv4+5840= X-Received: by 2002:a05:600c:3ba1:b0:42c:c401:6d6f with SMTP id 5b1f17b1804b1-431255e052amr143334755e9.16.1728998296355; Tue, 15 Oct 2024 06:18:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEx2tOw1Hd09qk4rvu2lR7WPCt0QMOWXGK0FQW617AJ+IZzf/t88eLzSztqQ0zCtm5ZpsAFYA== X-Received: by 2002:a05:600c:3ba1:b0:42c:c401:6d6f with SMTP id 5b1f17b1804b1-431255e052amr143334335e9.16.1728998295887; Tue, 15 Oct 2024 06:18:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/16] rust: allow version 1.63.0 of rustc Date: Tue, 15 Oct 2024 15:17:30 +0200 Message-ID: <20241015131735.518771-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998377331116600 Content-Type: text/plain; charset="utf-8" All constructs introduced by newer versions of Rust have been removed. Signed-off-by: Paolo Bonzini --- meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 175b8d82228..0e279d245b4 100644 --- a/meson.build +++ b/meson.build @@ -76,11 +76,11 @@ if not get_option('rust').disabled() and add_languages(= 'rust', required: get_opt and add_languages('rust', required: get_option('rust'), native: true) rustc =3D meson.get_compiler('rust') have_rust =3D true - if rustc.version().version_compare('<1.80.0') + if rustc.version().version_compare('<1.63.0') if get_option('rust').enabled() - error('rustc version ' + rustc.version() + ' is unsupported: Please = upgrade to at least 1.80.0') + error('rustc version ' + rustc.version() + ' is unsupported: Please = upgrade to at least 1.63.0') else - warning('rustc version ' + rustc.version() + ' is unsupported: Disab= ling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.') + warning('rustc version ' + rustc.version() + ' is unsupported: Disab= ling Rust compilation. Please upgrade to at least 1.63.0 to use Rust.') have_rust =3D false endif endif --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998434; cv=none; d=zohomail.com; s=zohoarc; b=BmhNceR1SHFSYc1Pcyf8QM7asS0FnRpz+Z3JlrGMKsyMfyQklmPMb/yGkZATiyQvc4Q61Y8nnfrAKcR81bXDEvDGI5yMkFdxVnR2bM+VoxyuEIKxm8tJRK0gxcAsdsA5XSOSyuQplnm51VtP28pRakpXucTV1rpEmb9gAgfeK1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998434; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=BdLWe8e10X1kwD0xpB96tiefr/UoeaIQizsR+wID6Y0=; b=hQ/vWWOeVFo0Qrakz+D8TayztorHuYC3ObqDZzARTCCpXVwpofWXCi5Th/cwwipupacmkjbMNM5MfiB86Xt1JPxJNz8gO+nrU6a6f/wBJ/UtRgi1XggwPj8nMZgQWbLRJjW90C2mpy70jVdc+KOMIM/Rhoau1cOjWGJ5gkF4SIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998434213229.54267349256634; Tue, 15 Oct 2024 06:20:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRT-000292-B5; Tue, 15 Oct 2024 09:18:27 -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 1t0hRQ-00027u-7j for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0hRO-0001Nq-Rz for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:24 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-4_y_-o8XPIGdoLv7khvKsA-1; Tue, 15 Oct 2024 09:18:20 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43057565db5so28938015e9.1 for ; Tue, 15 Oct 2024 06:18:20 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43096601152sm181034845e9.0.2024.10.15.06.18.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdLWe8e10X1kwD0xpB96tiefr/UoeaIQizsR+wID6Y0=; b=PO9WjlBMJ/Dez8GfVIPgxLDiOyxy6MNYdVQO++4rq/PA2gGP5mkHvFqUd3sYUbGI0vozRy xtDzYAJ+KctDHv2dxoO2+zrv6zNXLmwwvxZbmbe216ZTm1qxamMHC+/RWNpbJuaOaUTFnJ UCdfHhlI1JViFPjUc7NsFxeonmkrJNk= X-MC-Unique: 4_y_-o8XPIGdoLv7khvKsA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998299; x=1729603099; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BdLWe8e10X1kwD0xpB96tiefr/UoeaIQizsR+wID6Y0=; b=LYsmeM315ghUK1122ctjRClilBYb3Tz72A6MPDd0O5qifkzEUMz3Rj0LMM4VBBh51G UAiskAtOeKWMldq07ki3ss7OQdSqyc+yp8tgBgXLxTod7lqmGHIHTTI7bnQ0cBDCrwuA ak35qC410R5QTXYTdV+2G9V7wLYSG9WJ9hJjYiH2aH1bVKBxvahF9fGkuhn+L5Ya/ynm DtKXJxB6MzmwhvQc0wDwoNpnOSlANJCbTx80OEYrLIwf6w5Qj32akpfAKV4PHmIIbqHI s44d6jqClNVwJWU2/YReHR9ce8v89l5NbwNhlLou4P5AY4uG0++d28MnpRZ+I/HWumDn H8HQ== X-Gm-Message-State: AOJu0YyZ9Hac4YRyS5dViXnb9frDIF3stTPnl/+fTJl/DoJKiX0RuQd9 wvx07uakO23mXhp2hS2+dReXRHF3oZ+0arELAQNeP8aHg1zLDcVqJwxwHOdjE96Mo6D75Ym0TKi r1gUdFyDDbLiVAEgXDaGjI8TPPpuMOBf65HCuZrXv4aCDovMwIkWwq6LaYW6wUpGenPQG5zwyKb Nw/XD3PNFjL7R5CTIXwIibrImaJDkZFF/lcQyvp/o= X-Received: by 2002:a05:600c:46c6:b0:431:44aa:ee2c with SMTP id 5b1f17b1804b1-43144aaeec0mr13429585e9.9.1728998299168; Tue, 15 Oct 2024 06:18:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5Lb252grUWQH1PcJrO0kJpoywXi2ebXkYrfEEID1Imy11xOGW5HjR282unTgexG0ZdwvLjw== X-Received: by 2002:a05:600c:46c6:b0:431:44aa:ee2c with SMTP id 5b1f17b1804b1-43144aaeec0mr13429375e9.9.1728998298731; Tue, 15 Oct 2024 06:18:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/16] rust: do not use TYPE_CHARDEV unnecessarily Date: Tue, 15 Oct 2024 15:17:31 +0200 Message-ID: <20241015131735.518771-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998435817116600 Content-Type: text/plain; charset="utf-8" In the invocation of qdev_prop_set_chr(), "chardev" is the name of a property rather than a type and has to match the name of the property in device_class.rs. Do not use TYPE_CHARDEV here, just like in the C version of pl011_create. Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index f331a13b5f1..ca67d452e7e 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -582,7 +582,7 @@ pub fn update(&self) { let dev: *mut DeviceState =3D qdev_new(PL011State::TYPE_INFO.name); let sysbus: *mut SysBusDevice =3D dev.cast::(); =20 - qdev_prop_set_chr(dev, bindings::TYPE_CHARDEV.as_ptr(), chr); + qdev_prop_set_chr(dev, c_str!("chardev").as_ptr(), chr); sysbus_realize_and_unref(sysbus, addr_of!(error_fatal) as *mut *mu= t Error); sysbus_mmio_map(sysbus, 0, addr); sysbus_connect_irq(sysbus, 0, irq); --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998486; cv=none; d=zohomail.com; s=zohoarc; b=c7sZEecRQxVg/Yk1p4uAzF8ksvj3wdLgju2pEdJDx4kN/P5/4v+45s8UVNbw9UO+OuVVDia53DpuZ1DPkGFcPr/llrRGQzDPLVdy/3rdYFUYq4ZxfYHUPOovPT/1xtWratfkTAUnBc5AtfOmMiK7IS1WA/wqlwlgZp1qch4kELM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998486; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=guzIU8szJRoPg8gn1V5aPIVykgsXGQXnmT0CyHWL5RY=; b=bsCil0ibgnKwU2wewSHDCVdI/Fg5HMzpP9MpdVHM1Mc4Am/7aUxnNDydTs/FeUsZaHH43X6tw/eu4XIfJDJSrvtdzwA8feTF8FbgumfdHghVLLQYA05M+YhG4/rXhKQfxbV3dzY/Ok+aM1h0f6cBqYP96YmD3FJ2igwRdx6oyCU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998486631435.83851545405344; Tue, 15 Oct 2024 06:21:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRV-00029u-4L; Tue, 15 Oct 2024 09:18:29 -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 1t0hRT-00029K-Oe for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:27 -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 1t0hRS-0001Ok-9I for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:27 -0400 Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-475-Xwzp_SI9MoyoA_ah1uzquA-1; Tue, 15 Oct 2024 09:18:24 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-539fbf73a2fso1672283e87.2 for ; Tue, 15 Oct 2024 06:18:23 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f569ef4sm17900355e9.18.2024.10.15.06.18.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=guzIU8szJRoPg8gn1V5aPIVykgsXGQXnmT0CyHWL5RY=; b=azVZ9G8Bh0MplyhTU+8hNnlH8MTskL6RMnXnDeGiqg0M5SK6ehJoODYkBMqvC4oCbJUdK/ fF1x+oKkVStDYR55wb2iADkTDqIqXBBAscDwKbcCgWLIEq7TWBNlPAbM6Migy7VHdNa1sB gIvuj9jLkjHIoIpDwnkLOmGDq1AR4d4= X-MC-Unique: Xwzp_SI9MoyoA_ah1uzquA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998302; x=1729603102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=guzIU8szJRoPg8gn1V5aPIVykgsXGQXnmT0CyHWL5RY=; b=IJS1TcGopEneu+H/dbnhVE/BeTVBW+pchSdSx142XzObpndeCAXrOZPGoTeSPtQ3KK N8uLhCBEnAdsbFGRpnHsrmktXFFBF6wQbruZHbk9W5NpHF7Dfy9Xnn/jA3Tlr6JqvzZq i/UBh05LQ4+L1yyghsQCFzjYxP6pwfQbnAZcXp4NukbzoukX/O990ipNN42yi6gsbOlq MXhyR5X9SDKBnkL3p7BhplRX9bPA3NsuVrHi0rTSiVVmpGStdOpBi5eX3d6sdfMmHUy+ wyldr2dixcyw/Q6Q/1Jv8Rs94DKwx37mDTtReNF9eBYNENV8hFTcmsVifNHg0nexFVwU rwOg== X-Gm-Message-State: AOJu0Yz7mX4/A/U8YaXDwi5xw2lN9+y0Ovugy2/bS3sYqJ6BOoo0eQL7 sp/uq5ZTvKE/w2zcfatjYZkK/sZuV97S+JBky48O26wxvgxM2vdpciPa0BXNvqbtjXWlu7b3qf9 3bRGqA/RCqMgbgeB6nvaZGlbRdJwDJILwRrfJq4W+y4zJv40xiISVpQHGfW3xrCQcjtsVqzXNqu gk7DZIYfO7VuAnIOyNHjgOYjyiTCF2FmLlDQeN+74= X-Received: by 2002:a05:6512:2255:b0:539:e436:f1cc with SMTP id 2adb3069b0e04-539e574b003mr5002506e87.52.1728998302025; Tue, 15 Oct 2024 06:18:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhsSY5Q/9ZWPH6Fo3zmbC+TtIrdG3pKvpCGsctfyBz7WXqSk/GpDore8ekzA+fvsdri9guKg== X-Received: by 2002:a05:6512:2255:b0:539:e436:f1cc with SMTP id 2adb3069b0e04-539e574b003mr5002490e87.52.1728998301468; Tue, 15 Oct 2024 06:18:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/16] rust: do not use --no-size_t-is-usize Date: Tue, 15 Oct 2024 15:17:32 +0200 Message-ID: <20241015131735.518771-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998488295116600 Content-Type: text/plain; charset="utf-8" This not necessary, and adds an extra cast since size_of and align_of already return the right type. Signed-off-by: Paolo Bonzini --- meson.build | 1 - rust/qemu-api/src/definitions.rs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 0e279d245b4..3b35fcb3feb 100644 --- a/meson.build +++ b/meson.build @@ -3931,7 +3931,6 @@ if have_rust and have_system '--merge-extern-blocks', '--no-doc-comments', '--with-derive-default', - '--no-size_t-is-usize', '--no-layout-tests', '--no-prepend-enum-name', '--allowlist-file', meson.project_source_root() + '/include/.*', diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index aa7cdd69c99..4eaf2a91fab 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -83,13 +83,13 @@ macro_rules! type_info { } else { ::core::ptr::null_mut() }, - instance_size: ::core::mem::size_of::<$t>() as $crate::binding= s::size_t, - instance_align: ::core::mem::align_of::<$t>() as $crate::bindi= ngs::size_t, + instance_size: ::core::mem::size_of::<$t>(), + instance_align: ::core::mem::align_of::<$t>(), instance_init: <$t as $crate::definitions::ObjectImpl>::INSTAN= CE_INIT, instance_post_init: <$t as $crate::definitions::ObjectImpl>::I= NSTANCE_POST_INIT, instance_finalize: <$t as $crate::definitions::ObjectImpl>::IN= STANCE_FINALIZE, abstract_: <$t as $crate::definitions::ObjectImpl>::ABSTRACT, - class_size: ::core::mem::size_of::<<$t as $crate::definitions= ::ObjectImpl>::Class>() as $crate::bindings::size_t, + class_size: ::core::mem::size_of::<<$t as $crate::definitions= ::ObjectImpl>::Class>(), class_init: <<$t as $crate::definitions::ObjectImpl>::Class as= $crate::definitions::Class>::CLASS_INIT, class_base_init: <<$t as $crate::definitions::ObjectImpl>::Cla= ss as $crate::definitions::Class>::CLASS_BASE_INIT, class_data: ::core::ptr::null_mut(), --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998433; cv=none; d=zohomail.com; s=zohoarc; b=ikCp6KfAHUbqhDmFyv6mgEg/q4lMIoQUjgbH8Et/PWWPbH6GH0/FcvMx6IVYTmtVoloasEQbNQ8xLwprU+I3UM4DHm6oLpYFu+1smxS/OuV8xoQrGrM4lQTTTV+Ocb5hkEovXqVbo+qJ/sh0PBqi6YhjsFWiYlbU9Hi69Rzan7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998433; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=7x7nS4Xh6lw88VcJcF60YqjvT0tzg3gAq71y1ldvMM8=; b=MuFG7o2hG9KyndzvP162hpocjxLz98BK9CVCLvLqBQcNLq9We8klnN9O2m/vvid/p16T4ZbjEsHvudviDgTFosmfsqYRKPjlxa5wkncDAi0i7+y2jfNyduu/7HHlztmo44jDbreI/ciNEeVfzNqP9rGnb76n1jEyJQOvf7OyexI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728998433530546.7183459017197; Tue, 15 Oct 2024 06:20:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRW-0002AJ-T7; Tue, 15 Oct 2024 09:18:30 -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 1t0hRW-0002A5-5a for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:30 -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 1t0hRU-0001Pd-Mh for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:29 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-n6KMFbOtPqaZ2UDScpayRg-1; Tue, 15 Oct 2024 09:18:26 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d4af408dcso2209726f8f.0 for ; Tue, 15 Oct 2024 06:18:26 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fa92741sm1576533f8f.60.2024.10.15.06.18.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7x7nS4Xh6lw88VcJcF60YqjvT0tzg3gAq71y1ldvMM8=; b=TIvOlI4kSVU0ASX0zNAuxw4Fa+QJdWEg+FDgfxNxSy3ns+Cwe2O0Pkgaei0fFXsP/T482g LlLjr9B+ZhgVcI7JQFDFV4SlD5PVrfH7TNoeDUfhfnnPyrytxjmAFX9nfkcLsbe4Ks+I4t 3R7kzBJgMuBSEbqGt21g9sHBd8YB0Nw= X-MC-Unique: n6KMFbOtPqaZ2UDScpayRg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998305; x=1729603105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7x7nS4Xh6lw88VcJcF60YqjvT0tzg3gAq71y1ldvMM8=; b=ajox/wPVKKKSGMQH0iFM2s/5H6ji0WpNkt09sdBHj6qqRBnRKd0DRpLWDHlIzhpNFA C6eH2Nsn2Jqw1PsOK6kmJDPXpJx7EJKDmvq45MUo9RkwLGqrB0KHOE7liUhHfr9nTYm+ cdWO7HT7nnU7LZrl/+tIXLjM4EvQotUyZsNnYkA4mglUAJ92CINrd8JeWGQuLSeq8jSe Yuv3d5nUm11Rb+dY8RLNw01YRZEVeUMW7aIqF1Oq4z8LYWTYY+seHLGItGgqGl1rYbjJ 0XBnSWEhLYwj5PIj7caqJQf0/AosGMUmg7H15p2Mx1llBb/i94DF74ZWusodeZ+5Cs7B pCtg== X-Gm-Message-State: AOJu0YzutlPbmY8pEp/Uy5AqG5mUe9x/KWGmEj3H3nC5r+8po3Mjfkp0 BOVM6iBCSs21Rrtjj5aER/cfRkNNwwmEGU8x/LxVAsEXZ3o2EXAXaK7Qj2laIfAAu4EGcJy5/Z0 cCeS8d0tTuIy0QUC7AyK3fuxRArYjBobcNY5S8fGCXVKt5DnWxh7UCebcCgqZgAhbYIsCOhy3sT TOl0X7u+Y4RYAuQKJx6z85vj/Q7tuPSSA8+Sn5EFg= X-Received: by 2002:a5d:5051:0:b0:37d:4fab:c194 with SMTP id ffacd0b85a97d-37d86bd59b0mr179247f8f.25.1728998305098; Tue, 15 Oct 2024 06:18:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUPYyOliZu+SnSEXEgyGHGOQ2YnYJ97rxHKe0rzJMmnHNpaZDACcfVpC2WNzaPFfQa2MRXGg== X-Received: by 2002:a5d:5051:0:b0:37d:4fab:c194 with SMTP id ffacd0b85a97d-37d86bd59b0mr179230f8f.25.1728998304498; Tue, 15 Oct 2024 06:18:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/16] rust: do not use --generate-cstr Date: Tue, 15 Oct 2024 15:17:33 +0200 Message-ID: <20241015131735.518771-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998435863116600 Content-Type: text/plain; charset="utf-8" --generate-cstr is a good idea and generally the right thing to do, but it is not available in Debian 12 and Ubuntu 22.04. Work around the absence. Signed-off-by: Paolo Bonzini --- meson.build | 4 +++- rust/hw/char/pl011/src/device.rs | 1 + rust/qemu-api/src/device_class.rs | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 3b35fcb3feb..e08f226ee8a 100644 --- a/meson.build +++ b/meson.build @@ -3920,13 +3920,15 @@ common_all =3D static_library('common', dependencies: common_ss.all_dependencies()) =20 if have_rust and have_system + # We would like to use --generate-cstr, but it is only available + # starting with bindgen 0.66.0. The oldest supported versions + # are in Ubuntu 22.04 (0.59.1) and Debian 12 (0.60.1). bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', '--formatter', 'rustfmt', '--generate-block', - '--generate-cstr', '--impl-debug', '--merge-extern-blocks', '--no-doc-comments', diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index ca67d452e7e..ec82a2619f2 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -13,6 +13,7 @@ bindings::{self, *}, c_str, definitions::ObjectImpl, + device_class::TYPE_SYS_BUS_DEVICE, with_offsets, }; =20 diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index d2535125c48..f4eec2f748a 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -2,7 +2,9 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use crate::bindings::Property; +use std::ffi::CStr; + +use crate::bindings::{self, Property}; =20 #[macro_export] macro_rules! device_class_init { @@ -129,3 +131,7 @@ macro_rules! vm_state_description { }; } } + +// workaround until we can use --generate-cstr in bindgen. +pub const TYPE_SYS_BUS_DEVICE: &CStr =3D + unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_SYS_BUS_DE= VICE) }; --=20 2.46.2 From nobody Tue Oct 22 22:29:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1728998401; cv=none; d=zohomail.com; s=zohoarc; b=COCk8TPZeOcNoztKfaWhW12hC/R0k3iImI0TdaTH4qA315qv5HmayBuATrw7i/ZGOkH+OvNOIObuGMjdpGz29H+N+t2osC6cJt6u5FXm0LsXkRPaSUcOrVLflrpkCQJScheLp/ye+FY6dFpP5xYvMdPKroSxTpltOMOgPTLgQPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728998401; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=sAnhQzltstUpaxSarWgWHJgCpx75eSMfHNbMPr/IPaY=; b=SXXfRFJDRBP8mFBpkJsWHzhnuC4h+TD/mdlBy9klef1EcxBecbFXxwO2Gg/Wi1CEF0M13Z1mEtqn/tMVF87jrPUnonjwO+G0tOoj6BqNSi6IWYXr29/OXKsQ7Aq7jJ/OxsMys+jQRFWHxDE6k8D6mJHwWdJE7V9FeErrkzgd8II= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172899840184493.13226449476792; Tue, 15 Oct 2024 06:20:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0hRd-0002Ke-Pn; Tue, 15 Oct 2024 09:18:37 -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 1t0hRb-0002Jr-DQ for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0hRa-0001QO-1f for qemu-devel@nongnu.org; Tue, 15 Oct 2024 09:18:35 -0400 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-VxD9-DzNPaG4mPTFv5AQRQ-1; Tue, 15 Oct 2024 09:18:30 -0400 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539f7ed336bso1672756e87.2 for ; Tue, 15 Oct 2024 06:18:29 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4314bf60fc4sm849625e9.38.2024.10.15.06.18.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 06:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728998313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sAnhQzltstUpaxSarWgWHJgCpx75eSMfHNbMPr/IPaY=; b=SM2NCXQpZkkvNWcFbNwzLgSAeDqNt1OpnEZ0tbzWtRjB5fSJ6jMwmMf/+Am7DOlFsJCVWQ +kf5uF4bCtKbNqbL/ftAZpytTiu4y+IUhGNGuS+GHMEv/8t0aVCK8ffEeN4Pl0eG7YUXm7 TH9YaJZLRK65HWn0TcFOe4Pgx7+F4So= X-MC-Unique: VxD9-DzNPaG4mPTFv5AQRQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728998308; x=1729603108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sAnhQzltstUpaxSarWgWHJgCpx75eSMfHNbMPr/IPaY=; b=o5scljayQ2qvO5NlRd4HzNwNjCLa9Zo1acoh78vvIgRvp7z5oey9uJLe1otTAoBJ+y PcDNXcXMad6++10B8pZUCwnw0Chxf5DWuwETaA7pHK2SzaT7iVMHDKKs5CVszcVhw7p9 huI+AitcU9UmUeMRgRLAQXPkhmtqiCaDF4kcNjPDk5GT1OBB139+eDf1sxqmsZjeJk6x buR+RCjItfWdIBVdqQsXxsEeae04S9jyMWbIbwafANm4IF8yNEv8AHmol7wXaTp7PMz9 JD+D6skirOXkDfH2eLGi0wxopQFZ/23mdi0dMvuZnKPH+bFPw1Z2RxnD6/bFwXV2TU/G iHug== X-Gm-Message-State: AOJu0YyR6uxycpIXsc3vAbZBJ58+wfShmCBKYuzEoKu9W1PCqksJ4qv8 LLzAHq3lGjL9vSMLU9eyTb9GhJ9dwJKobf4O+oY0YVcDS9pCJGpulN2IkhwQ3YvQWVbD66Tgjb/ Ayjut8cW56vJYxXfkkmf/XirxHyrBXgW/Scq/V/yG7DUg4msxvMpuUM6MhON1OKs4lS37sc27Oi ExECdOcQoKEMZ97A5QMkPPXHHR1+y+7H1KM8q55eg= X-Received: by 2002:a05:6512:3e14:b0:539:f26f:d280 with SMTP id 2adb3069b0e04-53a03f0bdc9mr244937e87.5.1728998308126; Tue, 15 Oct 2024 06:18:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQMlOEKSLD1sF/wTcl+Lp3LcGYF2J1eHYuIUM3CKP7/KuD3qLUj+h0MwjOxIcbKS/xa4Rkmw== X-Received: by 2002:a05:6512:3e14:b0:539:f26f:d280 with SMTP id 2adb3069b0e04-53a03f0bdc9mr244902e87.5.1728998307527; Tue, 15 Oct 2024 06:18:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 16/16] rust: allow older version of bindgen Date: Tue, 15 Oct 2024 15:17:34 +0200 Message-ID: <20241015131735.518771-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015131735.518771-1-pbonzini@redhat.com> References: <20241015131735.518771-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.063, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1728998403488116600 Content-Type: text/plain; charset="utf-8" Cope with the old version that is provided in Debian 12 and Ubuntu 22.04. --size_t-is-usize is needed on bindgen <0.61.0 (Debian 12, Ubuntu 22.04), and it was removed in bindgen 0.65.0, so check for it in meson.build. Signed-off-by: Paolo Bonzini --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index e08f226ee8a..2a292935a94 100644 --- a/meson.build +++ b/meson.build @@ -74,6 +74,7 @@ endif have_rust =3D false if not get_option('rust').disabled() and add_languages('rust', required: g= et_option('rust'), native: false) \ and add_languages('rust', required: get_option('rust'), native: true) + bindgen =3D find_program('bindgen') rustc =3D meson.get_compiler('rust') have_rust =3D true if rustc.version().version_compare('<1.63.0') @@ -3939,6 +3940,9 @@ if have_rust and have_system '--allowlist-file', meson.project_source_root() + '/.*', '--allowlist-file', meson.project_build_root() + '/.*' ] + if bindgen.version().version_compare('<0.65.0') + bindgen_args +=3D ['--size_t-is-usize'] + endif c_enums =3D [ 'DeviceCategory', 'GpioPolarity', @@ -3974,7 +3978,7 @@ if have_rust and have_system dependencies: common_ss.all_dependencies(), output: 'bindings.rs', include_directories: include_directories('.', 'include'), - bindgen_version: ['>=3D0.69.4'], + bindgen_version: ['>=3D0.59.1'], args: bindgen_args, ) subdir('rust') --=20 2.46.2