From nobody Tue Oct 22 22:33:36 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=1729528577; cv=none; d=zohomail.com; s=zohoarc; b=InZwtH9tTTOZGpB/JhGscSkxBFpDhZyprmabZ2blb1DVklWXIUmtkrZNL6o4GzYtcz+jQ6dBUP2w59R0jFw34u39Z+z3cXJfehkJL7ScvKWEaFMcm22NX+zAWqdbV5YFi0Mo+zt8UlIigdfi4sfl3Z0j5wO1f8bxfoe0o4BB08A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528577; h=Content-Transfer-Encoding:Cc:Cc: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; bh=QgNTM++YIgCcMVNRZLJ+GHrP659GMVVlwBbB2mHseDc=; b=l6giX6Gq7oQkqlwz+eT4ZtjIoaR/zQW97NhIWE3ystOWkeAiRyiZdCtYyXNBiYMrghkSeL6GRbLY2R78yvICIYh//zWVISbpcFGSBUWzjDHbPPWCvz/h/SPwbp8l13KeuoDvL1ltzUZNaXF1XoaCrc85eLzG+XvoWP+bhhXruo8= 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 1729528577445721.5279174845427; Mon, 21 Oct 2024 09:36:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vNo-0005rM-IC; Mon, 21 Oct 2024 12:35:52 -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 1t2vNm-0005pQ-Qn for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:35:50 -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 1t2vNl-0006H6-DN for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:35:50 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-52-CmK8tIxjNW2TpSf28P-6Sg-1; Mon, 21 Oct 2024 12:35:47 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315eaa3189so36829705e9.1 for ; Mon, 21 Oct 2024 09:35:47 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5c3497sm62752035e9.29.2024.10.21.09.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QgNTM++YIgCcMVNRZLJ+GHrP659GMVVlwBbB2mHseDc=; b=aM6zRzpALTl2GzndK30rci4luqaGZ0PTPmiPpw0h/6GGSO8BhWTLAfI1Jsub4WstbYH29g 6WktRDcSGDFxgTci2olWRImg8zgzEU1u8hOMZi4zskuosNioGoaq8XLwNv65RxVg/cygI6 QkpbiGZcptJ2SUG8gmpp6oXZJ+O+JA4= X-MC-Unique: CmK8tIxjNW2TpSf28P-6Sg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528545; x=1730133345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QgNTM++YIgCcMVNRZLJ+GHrP659GMVVlwBbB2mHseDc=; b=hrcOb0WGBxdj8CqZMMrM6XXqvXKC0le1BVOLbPlMqRpBrrxniKAwC690JqInUAiaXR kVJitZH2V8rXRIzVkRfuLmYbBUreuEasWbONzbbOEl2I2S28a7qDw12NvZS1Lnoo9WjY xfVaIvCt4JNldtNAk3NR88cDbojc3poW6WRm/Qi4/V+2oMcN/pLq31YEHAeBhYJb2Srl 2AUYZ/IDGk/FxGow1yU/7DLsmdQrPl80mjOJa2oLwgQz7lrs2D+V9vccGKG9bDnTbGo3 6d6scQddGHGu5NjEk3n314fBQUNjQgoAKWxpT6Crs63xg6MPcx7KTsRFyx1fiojyz+K0 uoEw== X-Gm-Message-State: AOJu0YyWzsLxgEYWORdNUFqlgW0knZ14pbePBSB5Dqy/18BQy+89SM0Y i8qTxDkPFor0yQ0U85wtX2gqApeClA+OV8cBZSMQqykwZ31PnRXybIjRR+86QzVSgwWTmHw25sv V4A2Ki6rMwesdcTR6jN2/nhX0Z85S3gkQkahyC24Pj8GmH7eyjunaYa1TgUBcAQaOFNrPQZKzJA 3fQQxKb6+AVkqwFolAzUg7RQN+ALcTauc43zckHkQ= X-Received: by 2002:a05:600c:4f92:b0:431:557e:b40c with SMTP id 5b1f17b1804b1-43161686a3fmr117308245e9.27.1729528545251; Mon, 21 Oct 2024 09:35:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtO1iqb6KRvjMiC8dB0Rk81DkMIeot/0voDENG6HbftMXggPeZAB/BRJKdwJOmrXxiaPcYGg== X-Received: by 2002:a05:600c:4f92:b0:431:557e:b40c with SMTP id 5b1f17b1804b1-43161686a3fmr117307955e9.27.1729528544699; Mon, 21 Oct 2024 09:35:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao , Zhao Liu Subject: [PATCH v2 01/13] meson: import rust module into a global variable Date: Mon, 21 Oct 2024 18:35:26 +0200 Message-ID: <20241021163538.136941-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528579146116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- 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 d26690ce204..ffd78b6cbb3 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:33:36 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=1729528581; cv=none; d=zohomail.com; s=zohoarc; b=T9sy7iTrUSL0c4ikqRYe9+OdbRRTG6g2BGvEkiqgHdvid5fMwh7obTyr2PGMCdwhciK2nya8jeHSzNIYRilpwI2wLLPh1K5AAC8ono7zzPgQTh/9e0lf6tmrZGYG8XXt1+GADwhG36M5mTEZDw9WscErW+YgmIqChxPHa8wAiSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528581; h=Content-Transfer-Encoding:Cc:Cc: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; bh=gqjYsCuUkJoDwHJncPx/DyxCaTkPxqR/aZbtwyZZJx4=; b=NKTqDCMlO7QhsbYwhwLoqhfztkeFSc5Vme/xSpq/jHDnW/xAHfKRIrmDHkGvWsgG1/pxYFSxuzH8ZYaOoD9gX1bRtMs5RxHwSCzTxCy3mhMGHPaFloFIOUSn2H4ZUOiCrPWuKxrxK/7aI7wZ5+R6KeT+1Wu8sklkuwp1VhOfkUY= 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 1729528581686179.3410106905735; Mon, 21 Oct 2024 09:36:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vNr-0005sZ-Hd; Mon, 21 Oct 2024 12:35: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 1t2vNq-0005sH-Qm for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:35:54 -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 1t2vNp-0006He-FN for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:35:54 -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-208-fbJnxKWBNvmhrWIJ7NG5zQ-1; Mon, 21 Oct 2024 12:35:50 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-431604a3b47so28058025e9.3 for ; Mon, 21 Oct 2024 09:35:50 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58c02csm63226225e9.27.2024.10.21.09.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gqjYsCuUkJoDwHJncPx/DyxCaTkPxqR/aZbtwyZZJx4=; b=EHBD2e7Uh/DkNWq7+tQ4Z3C7kgOD5MEuIlIsxWyNHYlILjGzHCmnJPa+L+Gl04605ZVRop ATakBjMy/LMB/CyCP4eiOFA4STSUt9+l1vTHlo706v0Wc9WY4VzpWptSyglfF0e6IvBmXo Zo6MVFUv0JHtFp/rGbohy4joNYqrewQ= X-MC-Unique: fbJnxKWBNvmhrWIJ7NG5zQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528548; x=1730133348; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gqjYsCuUkJoDwHJncPx/DyxCaTkPxqR/aZbtwyZZJx4=; b=OAATNxgmhUhoseuH7/AcTrfVzBdJag6zpPZfATKW3CguQXiGRAFPWsZBZFBgnuLTNz IhT6/Lqlzz1P2OGM4PL///4IeTSwPzONHk43jRiJv6VnquolUCO1ocurvzayvNCCiJBK 2neB0z5k2WDEYkvL2Q5OiLhkI5EyufyIr2ukujs9DmLmYKhRkD0jnqGEJq5iyHRSliL0 KzEidDF6ozSMGMtuPXoDj2xDQfGF4+7PEThP2HXQBaaqsEEjMjn066F6V88vFlCU7Q4o Z6DqRQnBgI2sF49zBdRNj6o/QAuGAb6iico136GZJKLWBf4YSXDagmibAbI0syq4FGgL HQJA== X-Gm-Message-State: AOJu0YwErM+UmrSxXBgfXAiEjwee4pCKVzucOlH9davDA22TMtiFTSfP +m+JBatRexvaSZtYBBS71GwX9oPbeXWR12us5ZM1aGwE/doE2cfB5fT7qTILldmgx4quzAh+IUF BQ2xjmwq7Ayu6fXA09sLiD+t8suP0yGB5Y8KMs5Gr9dG5ayd6pnmfxf2LkAjz6rjK+meYfgRef/ GWaWbstLx6rZesDClU5jYZMT+ofVmCgI+s+rilNsc= X-Received: by 2002:a05:600c:3b16:b0:42f:80f4:ab31 with SMTP id 5b1f17b1804b1-4316163b593mr73368905e9.18.1729528548091; Mon, 21 Oct 2024 09:35:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHDjPQvDyLCeHljoFtnfsvd6Elxa7/XI+Tm9Ec5MZxKqW8MoGMw7UvhebCVmCn2UNtYDRKWg== X-Received: by 2002:a05:600c:3b16:b0:42f:80f4:ab31 with SMTP id 5b1f17b1804b1-4316163b593mr73368705e9.18.1729528547731; Mon, 21 Oct 2024 09:35:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao , Zhao Liu Subject: [PATCH v2 02/13] meson: remove repeated search for rust_root_crate.sh Date: Mon, 21 Oct 2024 18:35:27 +0200 Message-ID: <20241021163538.136941-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528583486116600 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. Reviewed-by: Junjie Mao Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ffd78b6cbb3..f85bc22fbdd 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:33:36 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=1729528756; cv=none; d=zohomail.com; s=zohoarc; b=K/fr9ORJh7MEzzD+zSiii0yGZ0Z7pFtlLfv0OhctnlMMs5ijD5UFfBq4oE+/qsXPxJHyn76W/NG20Ngljsi9nOlZ8tMSQXBTcSC6Fas2Y8cxbceEv9uMWloZ9kW1qcE+koaJUGRMP0Z/vNZ11rMkaP8PEkaxQBNhn5mKoFQfvog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528756; h=Content-Transfer-Encoding:Cc:Cc: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; bh=9GT7AM3dNIUTb0glH6Ier4DyJgqZCZmSaW5xm7t2d5c=; b=Mu1qPXd8Bnc3Nwa9tapHAzavMG7qBYVdOaCh7QJqXZVNiVFvzfADdMQeSj9FWsE+9zyPfrPuehQl+H6Fx+nVa6cEy8fCtI1eScayU40Mdsnq38MvHIRTogf6sp+cEIFtjBM1swkMs1rp0nusCTSsw7jmXNAemz3IgvIaXRCFJBU= 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 1729528756712121.40049262937498; Mon, 21 Oct 2024 09:39:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOy-0006cb-B4; Mon, 21 Oct 2024 12:37:04 -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 1t2vNv-0005uZ-9B for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:02 -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 1t2vNt-0006I8-8A for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:35:58 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-37-7VwXp7kkMZ6K6ACdEL_CNA-1; Mon, 21 Oct 2024 12:35:53 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-431518ae047so27500045e9.0 for ; Mon, 21 Oct 2024 09:35:53 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5c2c8esm62956805e9.36.2024.10.21.09.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9GT7AM3dNIUTb0glH6Ier4DyJgqZCZmSaW5xm7t2d5c=; b=e/LmQLHxgYPKHwr4mxu3wK62XtOzicj0p8jgJQmfBK0hNkSzcZPyibrUDi31cHnIWhAuEi A41eLc7eavctUFVcSEVUkzcGmZia+X+NdSjnxbTe9+aePgd4gRAH6EpUyt1cnsbK9741BW AWHq9cjH0vOI/HpfncvJP6ficfFHrhs= X-MC-Unique: 7VwXp7kkMZ6K6ACdEL_CNA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528551; x=1730133351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9GT7AM3dNIUTb0glH6Ier4DyJgqZCZmSaW5xm7t2d5c=; b=tZN48FZSnoq6f2G8CBP3WD3+XCmkftHsuxccsEmYOpWIRwdSsFZ3mJlwjkBm1wteZV cIyp9CHjNHI8/GgxZTxT+2X5E9AB9XKHW9sfX0KrC0P6+DOSdyORAyCM1OW2N8EqOqHu XKfzc1IdaHPqD0iJuyXkCB3BQ9wsTzppM+xDSx/gcypEmAaHbkTvHlFP89JCSjex9vZ5 Xl2wF2IG/LDXIo79kP5zAwGhXxV4vrYmbem5yxEczk2u7C1lvWm23Naip/OaOL+wNDbg 2niu3GCCHaoSKIe0XOoBxlt05qsRxve790yDhPruUgdAjZp399dTe4rK9Iy9brM2113/ R/9A== X-Gm-Message-State: AOJu0YzHIVYmsQJVt37Co4pwsa2UL7qeEZUZ7EOmltR2zcpzkUJJ21xG vACNprNDRi7akhO+Bu9U9u1d6usrOKC2Y8f3yEO7/erxHcvnginEqp9Xe9g3MnaqGHGDkzMHJfR H/Ixewa2BAa5iPvRsqlJ1ZPZ1Edfc1vmObgKLPIIBjiO9XUGQuiRxhDEM0gJ/hN6cs5WwQuprGT T7fRSFh9q+C2ZaKgRmEbiTRqWKtCRfCVUbi9HbyWM= X-Received: by 2002:a05:600c:3590:b0:431:4a82:97f2 with SMTP id 5b1f17b1804b1-4317bd7f68fmr1645255e9.6.1729528551309; Mon, 21 Oct 2024 09:35:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4SLc6xQ1Gv58wzV1GBsiZAYLjnpBGJee1+5HmHNgVb8o94h9FPGT5N+Xcvf56CjVwUR1QHQ== X-Received: by 2002:a05:600c:3590:b0:431:4a82:97f2 with SMTP id 5b1f17b1804b1-4317bd7f68fmr1645095e9.6.1729528550856; Mon, 21 Oct 2024 09:35:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 03/13] meson: pass rustc_args when building all crates Date: Mon, 21 Oct 2024 18:35:28 +0200 Message-ID: <20241021163538.136941-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_H2=-1.699, 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: 1729528758040116600 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: Junjie Mao Reviewed-by: Kevin Wolf Reviewed-by: Zhao Liu --- meson.build | 20 +++++++++++++------- rust/qemu-api/meson.build | 2 +- rust/qemu-api/src/device_class.rs | 10 ++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index f85bc22fbdd..63c07a5b660 100644 --- a/meson.build +++ b/meson.build @@ -3317,6 +3317,19 @@ 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() + + # Prohibit code that is forbidden in Rust 2024 + 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 +3922,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 +4094,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:33:36 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=1729528632; cv=none; d=zohomail.com; s=zohoarc; b=F+LBt/8b/NRn/bwgCAExnAmFqWqpTmRumVgQ1aQ886mFLeuL7TdP7d42tN16KT2FaLBzPvMRE6FZbl2rtL2hLDJR7EHkFmwCv0O54ZXDsvIwmAXi74dua8PYCBuxR+BBK3O2GwKLTau8Lw3AePoG1snStoKbKJbWID+dQmRBHic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528632; h=Content-Transfer-Encoding:Cc:Cc: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; bh=+VBSGG9/QZnUbOHJ1ZUaj0+mzJGppSH57Y5XCkB20uU=; b=ORT/HyWFDtzu7QXv5L9NCsm+2fRalSvZ4HjKYu7vDaaJ9qcvqyJwypCzAlPsCcradeieJjLiOYPZ90WcRuZbKi7GjI+TaAbTnDk5s6wobIjrz4/ZiCp9yyvk4NRcbUD0/+e/+xSkK/0pHkEYKK6ATDyXY7+tXRBxj9snw07Aozw= 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 1729528632805101.49092349713123; Mon, 21 Oct 2024 09:37:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOE-00067b-H7; Mon, 21 Oct 2024 12:36:18 -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 1t2vNw-0005un-GM for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:02 -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 1t2vNu-0006IO-W3 for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:00 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-5mxRttA5MCijBc4yZAYxew-1; Mon, 21 Oct 2024 12:35:56 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43151e4ef43so34583445e9.3 for ; Mon, 21 Oct 2024 09:35:56 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5cc1e2sm63458665e9.42.2024.10.21.09.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+VBSGG9/QZnUbOHJ1ZUaj0+mzJGppSH57Y5XCkB20uU=; b=Yk3GtvRLSGY7iZFUV50TFOnDSVheFkVJ/YF3Qln5InL9h023DQ9J1lVWc97ktE5f68NBeM iTjtWeLCTKHPJg5fdNiIDu/JGc41zGWCVwIPpFwidsNWRSUCtW3DBW9Lg77fbpyGDsQUga TYoTihjTT8B2E9ToNHkxnxzL/CJjfIw= X-MC-Unique: 5mxRttA5MCijBc4yZAYxew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528555; x=1730133355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+VBSGG9/QZnUbOHJ1ZUaj0+mzJGppSH57Y5XCkB20uU=; b=n3LRHWlr+ZmF2vDLli7A3s9Hk9ZAUGYKn2g2cNoTevwTpWbNnV4nYK0gfABVCPS6uO FVSCp7MqfGXfEMarD1TKAd8AAvOOf0QJY5zdt2qD69sz5HCF/HalK4w5+HDHcvsKMSO9 0UmW9yAw92y+sTnlv4PduY+5mnI1dEUrL4r5qTOYxk8iinzFaKJ+XjKKw0+V0JceE9Th 867pFzMPyX0+nBfMVcA/3dXA/fy27N0g9/pCpXG9MVpxh5E6DWhI/u+6BgnNn8UxmPKD vvmw8VdyhyvTT9dJY3iZ93ajy3jFOv1qWDX6kVuQxzQVehf9rxRyvCXzkEIW0g4z/Aws S4Gw== X-Gm-Message-State: AOJu0YwX+JZwqtWSnxFpBFXrJsnS8o63b0cYEIhhwKi+TmvB4zg+V8OA eRA6bZQbnF+9Gld6M6tUB4g6WoctEXvsGt92E3qKOH+z0jV2mVRopKtv3ApxKw8AJP2R5BaEdU3 dD8Il1/Q61AYNvL9XjQ/oP99M3klSIWZTA/EhiEyNKf2RA53WLunFgdKI1fn7GbZZzo2trAiNpG Ko5h8GyMpB7dF4lk5nS01ps7ZZ3Hpcy9gIqgTgSU8= X-Received: by 2002:a05:600c:5124:b0:431:5bf2:2d4 with SMTP id 5b1f17b1804b1-431616a388cmr100577145e9.29.1729528554862; Mon, 21 Oct 2024 09:35:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIIIJRzkemrUvKk4iyOOzbee7lZKyXOs6e3741YOKlQdEaBc8g+wXmIVejD4MgZgdKWSgxZw== X-Received: by 2002:a05:600c:5124:b0:431:5bf2:2d4 with SMTP id 5b1f17b1804b1-431616a388cmr100576935e9.29.1729528554427; Mon, 21 Oct 2024 09:35:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 04/13] rust: do not use --no-size_t-is-usize Date: Mon, 21 Oct 2024 18:35:29 +0200 Message-ID: <20241021163538.136941-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528633618116600 Content-Type: text/plain; charset="utf-8" This not necessary and makes it harder to write code that is portable between 32- and 64-bit systems: it adds extra casts even though size_of, align_of or offset_of already return the right type. Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Reviewed-by: Kevin Wolf --- 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 63c07a5b660..6739165908e 100644 --- a/meson.build +++ b/meson.build @@ -3934,7 +3934,6 @@ if have_rust and have_system '--no-doc-comments', '--use-core', '--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 60bd3f8aaa6..0b681c593f2 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -81,13 +81,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:33:36 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=1729528646; cv=none; d=zohomail.com; s=zohoarc; b=Ib5gHP7Ib623qxnBIGtOvfM0e1+KGkQbP/Bu+Hg7erAidVbh8MUDP1HjhHCb5n8Xti9kCDrd8+zNdfQqGk0h/Ni/L0WXRdX1D2cdNMIiWBMWCbg0FuCK39OR/uv9SkolZEOM2O4XPWQLSEvZM+5r7QqCwluYwqRALrQjvoqT2fE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528646; h=Content-Transfer-Encoding:Cc:Cc: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; bh=ieLsbmqkTfVjeUAmxOVRrXd6Rl3o+mJGozPICAN/5xE=; b=QdL99EHfCeqjpC/IFeOpSXMM4u4ioal6XZABROYi09gHFa8sEi4Ml4h6S2gHs91O974ARSfrAWBMxYUBwbnjWieBMBHvDJwHYFKymt6/Nd434XVRdFqWMx0hmkkIyjWoGUMQT5YG2kI3AaEHqlVE7Eyz72Kr7V9tzR0rVf8oP/I= 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 1729528646529419.5943728004979; Mon, 21 Oct 2024 09:37:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOz-0006ol-Lo; Mon, 21 Oct 2024 12:37: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 1t2vOD-00067n-Va for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:18 -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 1t2vOA-0006K1-RG for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:17 -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-631-rM1olqiiMguaYboKpJrx_Q-1; Mon, 21 Oct 2024 12:36:10 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43163a40ee0so25575105e9.0 for ; Mon, 21 Oct 2024 09:36:06 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0b9bb15sm4711993f8f.99.2024.10.21.09.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ieLsbmqkTfVjeUAmxOVRrXd6Rl3o+mJGozPICAN/5xE=; b=F0E6w98mn9oeKoZh4sjhz28+jiI4X0vrYO0gk0KT4+/hcrDS2U/V5hxQzfpcrfvJfR+QCN v7HPKTIF1GtByNhR61hcz3NRSHx11JZ5wKpg9TpSJsHZ9zod6BJv8WBZ0XTKAbCYStdWyd NJiRBliBWfT+j0RRI1Wj5x7GXvSRhs0= X-MC-Unique: rM1olqiiMguaYboKpJrx_Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528559; x=1730133359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ieLsbmqkTfVjeUAmxOVRrXd6Rl3o+mJGozPICAN/5xE=; b=hC3jHqS1Ekt8PTe+Jv9B6ChxFjlwYgVQUsUMWIkgpw5v2Lccz+7BStlRS2QS0OHyNp FBoQOlKw8ARbF6z8mJ7Rw3pU3ZNbuoO+9UNGRr1I4Nks6/9jYHSTEcD9P3OWzkS63NcR atDpVszDpI5vABRd7sPGJFVXa12aK5yttKr5doxRib4o262feJzu0aABYIOsn9Z9j7sQ ckQY9A/vPjXss5fu043zVjS9nyyMS4MpvMjGX483kvbb1ANqWG/i+AAUx0dZeUL7slLE 0mmFQrYstlFpnx0KOEPo570G2NwYCljBQ7vB4BQKVlq4X7r/n/SR3jh3IX3iRrk3Pvyu c6vA== X-Gm-Message-State: AOJu0YztnBQvxRUcZJNUT7wdF6yXcyBwfwAFv64Od5XPbIgvIe/iLgkw Bz4XUdxnuPzvKfb0A7VTJo+/Beac1IEGLTtTHcxlr0KPLnJAo1ZyOMJqvhOKYOGGB2uWoMR0Vmp VWstsiqLMED+57Ay4r1Mz5cBTFkZJyRYH9pN13SwwVBNZOwgxx+1EZz5KYT2ulpCfDP71rOTl+7 kAmi4ve0nJfbq8jjb93W96gQClgvFUCq1cVvtcDxA= X-Received: by 2002:a05:600c:45cb:b0:431:3927:d1bc with SMTP id 5b1f17b1804b1-431616331f5mr86372445e9.2.1729528559291; Mon, 21 Oct 2024 09:35:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHu9Toro2BrXmSEvXUExVMxKz8xGKwSpCitVQrOvid8rCqjZyXrzFvZ3FJcdm0RkCQisHmB1Q== X-Received: by 2002:a05:600c:45cb:b0:431:3927:d1bc with SMTP id 5b1f17b1804b1-431616331f5mr86372195e9.2.1729528558754; Mon, 21 Oct 2024 09:35:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 05/13] rust: remove uses of #[no_mangle] Date: Mon, 21 Oct 2024 18:35:30 +0200 Message-ID: <20241021163538.136941-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_H2=-1.699, 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: 1729528647679116601 Content-Type: text/plain; charset="utf-8" Mangled symbols do not cause any issue; disabling mangling is only useful if C headers reference the Rust function, which is not the case here. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- rust/hw/char/pl011/src/device.rs | 5 ----- rust/hw/char/pl011/src/device_class.rs | 2 -- rust/hw/char/pl011/src/memory_ops.rs | 2 -- rust/qemu-api/src/definitions.rs | 1 - rust/qemu-api/src/device_class.rs | 2 -- 5 files changed, 12 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index c7193b41bee..2b43f5e0939 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -514,7 +514,6 @@ pub fn update(&self) { /// We expect the FFI user of this function to pass a valid pointer, that = has /// 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_can_receive(opaque: *mut c_void) -> c_int { unsafe { debug_assert!(!opaque.is_null()); @@ -530,7 +529,6 @@ pub fn update(&self) { /// readable/writeable from one thread at any time. /// /// The buffer and size arguments must also be valid. -#[no_mangle] pub unsafe extern "C" fn pl011_receive( opaque: *mut core::ffi::c_void, buf: *const u8, @@ -554,7 +552,6 @@ pub fn update(&self) { /// We expect the FFI user of this function to pass a valid pointer, that = has /// 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) { unsafe { debug_assert!(!opaque.is_null()); @@ -566,7 +563,6 @@ pub fn update(&self) { /// # Safety /// /// We expect the FFI user of this function to pass a valid pointer for `c= hr`. -#[no_mangle] pub unsafe extern "C" fn pl011_create( addr: u64, irq: qemu_irq, @@ -589,7 +585,6 @@ pub fn update(&self) { /// We expect the FFI user of this function to pass a valid pointer, that = has /// 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_init(obj: *mut Object) { unsafe { debug_assert!(!obj.is_null()); diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index b7ab31af02d..2ad80451e87 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -46,7 +46,6 @@ /// We expect the FFI user of this function to pass a valid pointer, that = has /// 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_realize(dev: *mut DeviceState, _errp: *mut = *mut Error) { unsafe { assert!(!dev.is_null()); @@ -60,7 +59,6 @@ /// We expect the FFI user of this function to pass a valid pointer, that = has /// 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_reset(dev: *mut DeviceState) { unsafe { assert!(!dev.is_null()); diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/= memory_ops.rs index 8d066ebf6d0..5a5320e66c3 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -22,7 +22,6 @@ }, }; =20 -#[no_mangle] unsafe extern "C" fn pl011_read( opaque: *mut core::ffi::c_void, addr: hwaddr, @@ -44,7 +43,6 @@ } } =20 -#[no_mangle] unsafe extern "C" fn pl011_write( opaque: *mut core::ffi::c_void, addr: hwaddr, diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index 0b681c593f2..49ac59af123 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -53,7 +53,6 @@ extern "C" fn __load() { #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] pub static LOAD_MODULE: extern "C" fn() =3D { extern "C" fn __load() { - #[no_mangle] unsafe extern "C" fn $func() { $body } diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index b6b68cf9ce2..2219b9f73d0 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -9,7 +9,6 @@ #[macro_export] macro_rules! device_class_init { ($func:ident, props =3D> $props:ident, realize_fn =3D> $realize_fn:exp= r, legacy_reset_fn =3D> $legacy_reset_fn:expr, vmsd =3D> $vmsd:ident$(,)*) = =3D> { - #[no_mangle] pub unsafe extern "C" fn $func( klass: *mut $crate::bindings::ObjectClass, _: *mut ::core::ffi::c_void, @@ -103,7 +102,6 @@ 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); }; } --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528618; cv=none; d=zohomail.com; s=zohoarc; b=KH7d7tQsTeyufSYFoU9Crqce7aUU+kN+xJWgZCyHaC03bbmHiiD7TXQVjm017+eeeXIW1t0rBHoulX82uYFyFeYulSlpHYcF3Kfo4xPEBFV8XIui3J3TexcsjAOT5BUBu59Q8d6vsiw3aCB0n1CBv9DJGiALvOUtop8MAXr57lI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528618; h=Content-Transfer-Encoding:Cc:Cc: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; bh=LC3eZXbf/MgMolpo8tNMzb8FwxljpvkDw9TXTcaEtG4=; b=McdsbI080g2gjaAJA1MbEJwPer22If8uBqiZO7z5GMT2PzTzhToLXZa5aR2Axh2hUagsjh5cV4Y/TeoL9DebuyO9bAA3c9W6Lkmsh42xD2lpGT2ltN6Fk5n0GPad3/cYrEoBQGB7d2x/jpkI8F5iWBp0kGi+qxsDJqUZ9gcOw7c= 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 172952861861544.38267441738674; Mon, 21 Oct 2024 09:36:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOF-0006Aq-68; Mon, 21 Oct 2024 12:36:22 -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 1t2vO4-000622-JQ for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:11 -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 1t2vO2-0006JG-Hy for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:08 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-W5rTGtOQMS-wBgFLAVDLwA-1; Mon, 21 Oct 2024 12:36:04 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4316300bb15so25077875e9.2 for ; Mon, 21 Oct 2024 09:36:03 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a47b07sm4700072f8f.25.2024.10.21.09.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LC3eZXbf/MgMolpo8tNMzb8FwxljpvkDw9TXTcaEtG4=; b=a0SeJMUqcC0uc6KyUlYgiH74upYCbDi5JvUEco9lGIrUmoXA1yfq+DxsOtiow+cxwl5F+O V0aacUJzdUsTNs7SCLN0seR7YtpLHgWRu0+4YY6O4KDIEevyOVee34u3muj5kAY/eCz0Ww FhbVmhQyVOm50w2cUuWge+q4k2IUVSE= X-MC-Unique: W5rTGtOQMS-wBgFLAVDLwA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528562; x=1730133362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LC3eZXbf/MgMolpo8tNMzb8FwxljpvkDw9TXTcaEtG4=; b=bvrXJieR7NxIKBUdfAf0dgzkLI1tVcrCMnzKFiSV1jtOMZXwvNavL6JKivybmCoft/ FOM2YhLF2jrVYIgva40XwiTrQh3mgopvb+5zhwFBdlXRHYlp5JXVbwtE78e6e57WlFRQ IcuK1/7YxiDq3HLPJEaDfR3+DoIdy2adsV3r9zIf6vJj6Riu40OOJ1dOqxG19Blh9h37 cR8/Q1d3SO6d6GtSnKKfXrJsWtRM9mDwfgWcCJI/6PiP3jOFZvFg/crh5PB3J7gpckNQ ACSM38pjAnj503wwCjOaiWbmjXDLdWnS24uCdlEBIm6BM5G0Pi6aXQLgGm6iApoTu1/d jS/g== X-Gm-Message-State: AOJu0YxOYz11BX0Z+/XUOKUA601+KC9pnQ5fwa4z76YR7UYk0YFf9EXn 33xOmCmhQR9WaZ2UAdqIWOAhszoNO4fpCo0zYxQ5boz60HBsoc0CLEw2qGCF6tLiP0+G8hBDFf0 8TyzZ95tx2fHCdUpMwLGWTxWPbWvXvNbClMjH5bm29SFsziS0gBBOsdn4vBjqz1f2f426E2S5UC eqG4C24/C7Csxpch8g+xCtYsR7s67IwA6zvzr/LGw= X-Received: by 2002:a05:600c:1d04:b0:431:43c6:e868 with SMTP id 5b1f17b1804b1-4316168989amr96211185e9.23.1729528562426; Mon, 21 Oct 2024 09:36:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFysiBm3yf0tbZkEr5nT0eHMMCE9Z/zmUvvYl+CWpu6d66CLnxg2DilTYfF7Q1Kp1VDLVTd3w== X-Received: by 2002:a05:600c:1d04:b0:431:43c6:e868 with SMTP id 5b1f17b1804b1-4316168989amr96210875e9.23.1729528561868; Mon, 21 Oct 2024 09:36:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 06/13] rust: modernize link_section usage for ELF platforms Date: Mon, 21 Oct 2024 18:35:31 +0200 Message-ID: <20241021163538.136941-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528619364116600 Content-Type: text/plain; charset="utf-8" Some newer ABI implementations do not provide .ctors; and while some linkers rewrite .ctors into .init_array, not all of them do. Use the newer .init_array ABI, which works more reliably, and apply it to all non-Apple, non-Windows platforms. This is similar to how the ctor crate operates; without this change, "#[derive(Object)]" does not work on Fedora 41. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- rust/qemu-api-macros/src/lib.rs | 7 +++++-- rust/qemu-api/src/definitions.rs | 14 ++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib= .rs index 59aba592d9a..70e3f920460 100644 --- a/rust/qemu-api-macros/src/lib.rs +++ b/rust/qemu-api-macros/src/lib.rs @@ -16,8 +16,11 @@ pub fn derive_object(input: TokenStream) -> TokenStream { let expanded =3D quote! { #[allow(non_upper_case_globals)] #[used] - #[cfg_attr(target_os =3D "linux", link_section =3D ".ctors")] - #[cfg_attr(target_os =3D "macos", link_section =3D "__DATA,__mod_i= nit_func")] + #[cfg_attr( + not(any(target_vendor =3D "apple", target_os =3D "windows")), + link_section =3D ".init_array" + )] + #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA,__m= od_init_func")] #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] pub static #module_static: extern "C" fn() =3D { extern "C" fn __register() { diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index 49ac59af123..3323a665d92 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -31,8 +31,11 @@ pub trait Class { macro_rules! module_init { ($func:expr, $type:expr) =3D> { #[used] - #[cfg_attr(target_os =3D "linux", link_section =3D ".ctors")] - #[cfg_attr(target_os =3D "macos", link_section =3D "__DATA,__mod_i= nit_func")] + #[cfg_attr( + not(any(target_vendor =3D "apple", target_os =3D "windows")), + link_section =3D ".init_array" + )] + #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA,__m= od_init_func")] #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] pub static LOAD_MODULE: extern "C" fn() =3D { extern "C" fn __load() { @@ -48,8 +51,11 @@ extern "C" fn __load() { // NOTE: To have custom identifiers for the ctor func we need to e= ither supply // them directly as a macro argument or create them with a proc ma= cro. #[used] - #[cfg_attr(target_os =3D "linux", link_section =3D ".ctors")] - #[cfg_attr(target_os =3D "macos", link_section =3D "__DATA,__mod_i= nit_func")] + #[cfg_attr( + not(any(target_vendor =3D "apple", target_os =3D "windows")), + link_section =3D ".init_array" + )] + #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA,__m= od_init_func")] #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] pub static LOAD_MODULE: extern "C" fn() =3D { extern "C" fn __load() { --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528632; cv=none; d=zohomail.com; s=zohoarc; b=JaovEHKO6/WdE8XANxMkRDkwjHz0wLfy17Q/9LasiGH+FlDLDAw1HOeSjNwhOX6VsdDVvkaQUZeU5Q3xeP9k8RUfX3QL9riDjr1q+it1hYrnv0/D6y4yIPuLEfi8uEMESqNi0h0y31RMGqsrQ76QzEgcloa2PiewRSY9OjuKSFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528632; h=Content-Transfer-Encoding:Cc:Cc: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; bh=Q404IxZFk+NIfcxl+Tcr9XRM6bnBKtIpSop9l9a12Xk=; b=e6ciigjjMrahtkloMjwg16eZ59FPcMG9ntPVSbhg93q8CEsGWnxAae+WNVCMMaWg+TxxSrO9lVCYdAZeN6KUl73bIrq7tPrYqRDg3YSEqt6xaAANuImGAVhIMvu1yTmSe3Cuvbu0c7+oTwlFGFBjfc2xnihX+O/lBNjyOifDhX0= 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 1729528632284935.8304560706031; Mon, 21 Oct 2024 09:37:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOz-0006oT-M0; Mon, 21 Oct 2024 12:37: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 1t2vOC-00065s-2G for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:17 -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 1t2vO6-0006Ji-Si for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:14 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-xAyz1ud0OsWaj2LXtjagRw-1; Mon, 21 Oct 2024 12:36:08 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315f48bd70so28269635e9.2 for ; Mon, 21 Oct 2024 09:36:08 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f57102asm62047065e9.1.2024.10.21.09.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q404IxZFk+NIfcxl+Tcr9XRM6bnBKtIpSop9l9a12Xk=; b=ictC8xMQGsEzxlhMG1jC3ioeGnlkUHdZXNr2x4/PpjPnxjdYxUORHKsUNkS7QDdsbCLJYY p9RtfwRBNpBni/6solWaxcQA7oCEPHeluKm5QU9peEmJS3nJF401oJnJDKh5ACuQg1l47I hjgOjWEG57rPsVxuRoppnjHDpG/xNZM= X-MC-Unique: xAyz1ud0OsWaj2LXtjagRw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528566; x=1730133366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q404IxZFk+NIfcxl+Tcr9XRM6bnBKtIpSop9l9a12Xk=; b=lcVgPOvrthamK7UnWGUQ4pn/A2TawrX4PpzUAspijK6wfrOISysleLY1jI27W5Os8p z70flVfJsTAAZXx789KhnZAj6sXxg0hRghGFoDnsqHwtpiFHydhgMa5RYqdJZhzBsQbV 1/5lmYq4xpBm+ELusc+i1Q0gb8JKTIYqWBm5XFMPzbmSVi7ty/5FyZSziaWlt9sMz/3U gt1Jlhoaa+5OCERhTE63eHwI6DRta34rCjQ7j/Y0C1ZuziN57VMvlYdkNjba4FY72aVO Qsa9Iex19sTgceURlh9LQz7vP0fDu5QpJ7Sjp3CQMZprx0FfsD34s+sCEyAq6AdMT67v O8Zg== X-Gm-Message-State: AOJu0YyavooiB/pSlnHLAIfQwtuY+LLrqHsyePz5cz5I087gwYzdZdFV J0lU3UWelfNMBpGPTyffCiKxAnPqBb+alaPJPLu+SCHCqDcHLHaLjJ4LbUZa22KEg14VzleNB2C yGs9uo6vn4edzIWwJJcZS6+pibDAM2+4CqSDHQRiTnuN0NIesm6wSFisMx6aMJ26WDTl28Lbl5I Sgjkc1CJEOvlHIhIu8do6KYBSns4EDrIdxX1uh1rw= X-Received: by 2002:a05:600c:19d2:b0:431:3c67:fb86 with SMTP id 5b1f17b1804b1-431616a404dmr88541325e9.33.1729528566373; Mon, 21 Oct 2024 09:36:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHecvCZ1N1dVcHdMc7UcS3N7JC2ht0pL/nBidv/7JzOv05qnQEXa6OPB3xkVzspDNQhi6fJOQ== X-Received: by 2002:a05:600c:19d2:b0:431:3c67:fb86 with SMTP id 5b1f17b1804b1-431616a404dmr88541095e9.33.1729528565907; Mon, 21 Oct 2024 09:36:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao , Zhao Liu Subject: [PATCH v2 07/13] rust: build integration test for the qemu_api crate Date: Mon, 21 Oct 2024 18:35:32 +0200 Message-ID: <20241021163538.136941-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528633685116600 Content-Type: text/plain; charset="utf-8" Adjust the integration test to compile with a subset of QEMU object files, and make it actually create an object of the class it defines. Follow the Rust filesystem conventions, where tests go in tests/ if they use the library in the same way any other code would. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Reviewed-by: Kevin Wolf --- meson.build | 10 ++++- rust/qemu-api/meson.build | 26 ++++++++++-- rust/qemu-api/src/lib.rs | 3 -- rust/qemu-api/src/tests.rs | 49 ---------------------- rust/qemu-api/tests/tests.rs | 78 ++++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+), 56 deletions(-) delete mode 100644 rust/qemu-api/src/tests.rs create mode 100644 rust/qemu-api/tests/tests.rs diff --git a/meson.build b/meson.build index 6739165908e..3c71d129494 100644 --- a/meson.build +++ b/meson.build @@ -3326,7 +3326,15 @@ if have_rust and have_system =20 # Prohibit code that is forbidden in Rust 2024 rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] - add_project_arguments(rustc_args, native: false, language: 'rust') + + # Apart from procedural macros, our Rust executables will often link + # with C code, so include all the libraries that C code needs. This + # is safe; https://github.com/rust-lang/rust/pull/54675 says that + # passing -nodefaultlibs to the linker "was more ideological to + # start with than anything". + add_project_arguments(rustc_args + ['-C', 'default-linker-libraries'], + native: false, language: 'rust') + add_project_arguments(rustc_args, native: true, language: 'rust') endif =20 diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 42ea815fa5a..1fc36078027 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -14,11 +14,31 @@ _qemu_api_rs =3D static_library( '--cfg', 'MESON', # '--cfg', 'feature=3D"allocator"', ], - dependencies: [ - qemu_api_macros, - ], ) =20 qemu_api =3D declare_dependency( link_with: _qemu_api_rs, + dependencies: qemu_api_macros, ) + +# Rust executables do not support objects, so add an intermediate step. +rust_qemu_api_objs =3D static_library( + 'rust_qemu_api_objs', + objects: [libqom.extract_all_objects(recursive: false), + libhwcore.extract_all_objects(recursive: false)]) + +test('rust-qemu-api-integration', + executable( + 'rust-qemu-api-integration', + 'tests/tests.rs', + override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_args: ['--test'], + install: false, + dependencies: [qemu_api, qemu_api_macros], + link_whole: [rust_qemu_api_objs, libqemuutil]), + args: [ + '--test', + '--format', 'pretty', + ], + protocol: 'rust', + suite: ['unit', 'rust']) diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index e72fb4b4bb1..6bc68076aae 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -30,9 +30,6 @@ unsafe impl Sync for bindings::VMStateDescription {} pub mod definitions; pub mod device_class; =20 -#[cfg(test)] -mod tests; - use std::alloc::{GlobalAlloc, Layout}; =20 #[cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)] diff --git a/rust/qemu-api/src/tests.rs b/rust/qemu-api/src/tests.rs deleted file mode 100644 index df54edbd4e2..00000000000 --- a/rust/qemu-api/src/tests.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2024, Linaro Limited -// Author(s): Manos Pitsidianakis -// SPDX-License-Identifier: GPL-2.0-or-later - -use crate::{ - bindings::*, declare_properties, define_property, device_class_init, v= m_state_description, -}; - -#[test] -fn test_device_decl_macros() { - // Test that macros can compile. - vm_state_description! { - VMSTATE, - name: c"name", - unmigratable: true, - } - - #[repr(C)] - pub struct DummyState { - pub char_backend: CharBackend, - pub migrate_clock: bool, - } - - declare_properties! { - DUMMY_PROPERTIES, - define_property!( - c"chardev", - DummyState, - char_backend, - unsafe { &qdev_prop_chr }, - CharBackend - ), - define_property!( - c"migrate-clk", - DummyState, - migrate_clock, - unsafe { &qdev_prop_bool }, - bool - ), - } - - device_class_init! { - dummy_class_init, - props =3D> DUMMY_PROPERTIES, - realize_fn =3D> None, - reset_fn =3D> None, - vmsd =3D> VMSTATE, - } -} diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs new file mode 100644 index 00000000000..aa1e0568c69 --- /dev/null +++ b/rust/qemu-api/tests/tests.rs @@ -0,0 +1,78 @@ +// Copyright 2024, Linaro Limited +// Author(s): Manos Pitsidianakis +// SPDX-License-Identifier: GPL-2.0-or-later + +use core::ffi::CStr; + +use qemu_api::{ + bindings::*, + declare_properties, define_property, + definitions::{Class, ObjectImpl}, + device_class_init, vm_state_description, +}; + +#[test] +fn test_device_decl_macros() { + // Test that macros can compile. + vm_state_description! { + VMSTATE, + name: c"name", + unmigratable: true, + } + + #[repr(C)] + #[derive(qemu_api_macros::Object)] + pub struct DummyState { + pub _parent: DeviceState, + pub migrate_clock: bool, + } + + #[repr(C)] + pub struct DummyClass { + pub _parent: DeviceClass, + } + + declare_properties! { + DUMMY_PROPERTIES, + define_property!( + c"migrate-clk", + DummyState, + migrate_clock, + unsafe { &qdev_prop_bool }, + bool + ), + } + + device_class_init! { + dummy_class_init, + props =3D> DUMMY_PROPERTIES, + realize_fn =3D> None, + legacy_reset_fn =3D> None, + vmsd =3D> VMSTATE, + } + + impl ObjectImpl for DummyState { + type Class =3D DummyClass; + const TYPE_INFO: qemu_api::bindings::TypeInfo =3D qemu_api::type_i= nfo! { Self }; + const TYPE_NAME: &'static CStr =3D c"dummy"; + const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(TYPE_DEVICE= ); + const ABSTRACT: bool =3D false; + const INSTANCE_INIT: Option =3D None; + const INSTANCE_POST_INIT: Option =3D None; + const INSTANCE_FINALIZE: Option =3D None; + } + + impl Class for DummyClass { + const CLASS_INIT: Option< + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core:= :ffi::c_void), + > =3D Some(dummy_class_init); + const CLASS_BASE_INIT: Option< + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core:= :ffi::c_void), + > =3D None; + } + + unsafe { + module_call_init(module_init_type::MODULE_INIT_QOM); + object_unref(object_new(DummyState::TYPE_NAME.as_ptr()) as *mut _); + } +} --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528743; cv=none; d=zohomail.com; s=zohoarc; b=GIEzzIxGEPChQEKnBrfo0lDyvIo1c5cdK7BoEjz+th/C8TRJMtJkhrERFoobRXV3fRomE7mYTf2T2lGIX22wTYi4YG0iSuLV8ovTMiGIVvsTgObgowXdiM+Ie/Oz48VFzNDY18AjravLs+yJIj99ADZeN+/wshaTkUYGnNFJ1tg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528743; h=Content-Transfer-Encoding:Cc:Cc: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; bh=kvb89qSp/JxmYfOj6SZi8Bx0KqHl+LVpfSQJUogsuq4=; b=kRJ3XoNQQoIMLNLp1rHAX0OCbkd+SORHwNRRE7REnwRMoUIWxDheELWwU8hxL+QQZQcrjTP1SaPPiHJYSggcftpCryRYSBjOQ5O3ec642DBqenn0/Ojzm2KSc4tCpr9E/BGQUTg2buMCLoXB1LCYTWTxA6z8NwfwIQ+woxqe9mI= 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 1729528743580157.55500671571758; Mon, 21 Oct 2024 09:39:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vP2-0006yC-1k; Mon, 21 Oct 2024 12:37:08 -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 1t2vOD-00067m-VV for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:18 -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 1t2vO9-0006Jx-Li for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:17 -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-385-IsaXhJRgMfC9XKIlxMzokA-1; Mon, 21 Oct 2024 12:36:11 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315544642eso37410185e9.3 for ; Mon, 21 Oct 2024 09:36:11 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f57fa4fsm62774405e9.16.2024.10.21.09.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kvb89qSp/JxmYfOj6SZi8Bx0KqHl+LVpfSQJUogsuq4=; b=UxvnHXxUvAngz3NM7pQsn7W1Gpx3F0T690YPCi24AOnJk+w6Xe1xefvLMLRwMd+ujX6MNQ qFL6eVRzFZh+y7Nf4ixodcsYlZbo6iDQSWn7PXBlW7Nf8cmvyz4D5u4VhyOz8E7LHEw4Cr t+Og0WGDuaGzGvF0i/QQHJpFU34/aTc= X-MC-Unique: IsaXhJRgMfC9XKIlxMzokA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528569; x=1730133369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kvb89qSp/JxmYfOj6SZi8Bx0KqHl+LVpfSQJUogsuq4=; b=mVVkyBcrkE5nJEKV9PTTZGMDk4VTCFpShtfdtWt0G+iqWE0FyfolbCOwaZgUBIRsvK MBj6RVSHHnQUM8b/wFzOSjndi2/68AQSyDtziSv6QfXFgtBDjQekGnc/W5EpSX0zRKMl V6VGz6kGu/FwNfLrIm+aH/Z8Niu4DRyLsilkQZWOxURavFIeJmTRBXOQHIox/FWn8dLH q16fetw8Kr+/KTQRbC1XmbYutjAnjzd4XcQcvatOtdkEjHiSSm0VpirhEN1uF+sks5V2 znY+XDgpv/m54VKDWOq3WEGE19xcEdYoePGDjvLPjuheLreOfZLpi3lBulV+pOuslaNp Xoog== X-Gm-Message-State: AOJu0Yz/5yvw+LNTA6PiFRiDUlQHGckZtWxFzQ/wOAY2xJiw3rUSmTQ9 aX/BhO+4S/NeGzPHwapwWBa6iZ+0THHXInTwgID5kuXjSAMmqRDdQY5u0RouE3WWiWJMK/UILB0 Vo/KUP/szWzK4N92DAyRBuYj4MQHPq8Gd6H+lYzJwk9wSQCNyOefwFMga89p65FOKPt6YkGJheO yQX9ziN4/KIuxnCbZIn9oszFkOulu7WgqJiEyIgd4= X-Received: by 2002:a05:600c:1d01:b0:42c:b74c:d8c3 with SMTP id 5b1f17b1804b1-4316168ff01mr99496365e9.32.1729528569240; Mon, 21 Oct 2024 09:36:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGoo2DZlzYa5tO9scq9rSbVdszZ2ED+SvdnMr+4+YYOsddyVtq1HlTczBGmh8mLjTphc1v7jg== X-Received: by 2002:a05:600c:1d01:b0:42c:b74c:d8c3 with SMTP id 5b1f17b1804b1-4316168ff01mr99496045e9.32.1729528568746; Mon, 21 Oct 2024 09:36:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 08/13] rust: cleanup module_init!, use it from #[derive(Object)] Date: Mon, 21 Oct 2024 18:35:33 +0200 Message-ID: <20241021163538.136941-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_H2=-1.699, 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: 1729528744090116600 Content-Type: text/plain; charset="utf-8" Remove the duplicate code by using the module_init! macro; at the same time, simplify how module_init! is used, by taking inspiration from the implement= ation of #[derive(Object)]. Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Reviewed-by: Kevin Wolf --- rust/qemu-api-macros/src/lib.rs | 33 +++------------- rust/qemu-api/src/definitions.rs | 66 ++++++++++++++------------------ 2 files changed, 33 insertions(+), 66 deletions(-) diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib= .rs index 70e3f920460..a4bc5d01ee8 100644 --- a/rust/qemu-api-macros/src/lib.rs +++ b/rust/qemu-api-macros/src/lib.rs @@ -3,43 +3,20 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 use proc_macro::TokenStream; -use quote::{format_ident, quote}; +use quote::quote; use syn::{parse_macro_input, DeriveInput}; =20 #[proc_macro_derive(Object)] pub fn derive_object(input: TokenStream) -> TokenStream { let input =3D parse_macro_input!(input as DeriveInput); - let name =3D input.ident; - let module_static =3D format_ident!("__{}_LOAD_MODULE", name); =20 let expanded =3D quote! { - #[allow(non_upper_case_globals)] - #[used] - #[cfg_attr( - not(any(target_vendor =3D "apple", target_os =3D "windows")), - link_section =3D ".init_array" - )] - #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA,__m= od_init_func")] - #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] - pub static #module_static: extern "C" fn() =3D { - extern "C" fn __register() { - unsafe { - ::qemu_api::bindings::type_register_static(&<#name as = ::qemu_api::definitions::ObjectImpl>::TYPE_INFO); - } + ::qemu_api::module_init! { + MODULE_INIT_QOM =3D> unsafe { + ::qemu_api::bindings::type_register_static(&<#name as ::qe= mu_api::definitions::ObjectImpl>::TYPE_INFO); } - - extern "C" fn __load() { - unsafe { - ::qemu_api::bindings::register_module_init( - Some(__register), - ::qemu_api::bindings::module_init_type::MODULE_INI= T_QOM - ); - } - } - - __load - }; + } }; =20 TokenStream::from(expanded) diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index 3323a665d92..f180c38bfb2 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -29,51 +29,40 @@ pub trait Class { =20 #[macro_export] macro_rules! module_init { - ($func:expr, $type:expr) =3D> { - #[used] - #[cfg_attr( - not(any(target_vendor =3D "apple", target_os =3D "windows")), - link_section =3D ".init_array" - )] - #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA,__m= od_init_func")] - #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] - pub static LOAD_MODULE: extern "C" fn() =3D { - extern "C" fn __load() { - unsafe { - $crate::bindings::register_module_init(Some($func), $t= ype); - } - } - - __load - }; - }; - (qom: $func:ident =3D> $body:block) =3D> { - // NOTE: To have custom identifiers for the ctor func we need to e= ither supply - // them directly as a macro argument or create them with a proc ma= cro. - #[used] - #[cfg_attr( - not(any(target_vendor =3D "apple", target_os =3D "windows")), - link_section =3D ".init_array" - )] - #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA,__m= od_init_func")] - #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU")] - pub static LOAD_MODULE: extern "C" fn() =3D { - extern "C" fn __load() { - unsafe extern "C" fn $func() { + ($type:ident =3D> $body:block) =3D> { + const _: () =3D { + #[used] + #[cfg_attr( + not(any(target_vendor =3D "apple", target_os =3D "windows"= )), + link_section =3D ".init_array" + )] + #[cfg_attr(target_vendor =3D "apple", link_section =3D "__DATA= ,__mod_init_func")] + #[cfg_attr(target_os =3D "windows", link_section =3D ".CRT$XCU= ")] + pub static LOAD_MODULE: extern "C" fn() =3D { + extern "C" fn init_fn() { $body } =20 - unsafe { - $crate::bindings::register_module_init( - Some($func), - $crate::bindings::module_init_type::MODULE_INIT_QO= M, - ); + extern "C" fn ctor_fn() { + unsafe { + $crate::bindings::register_module_init( + Some(init_fn), + $crate::bindings::module_init_type::$type, + ); + } } - } =20 - __load + ctor_fn + }; }; }; + + // shortcut because it's quite common that $body needs unsafe {} + ($type:ident =3D> unsafe $body:block) =3D> { + $crate::module_init! { + $type =3D> { unsafe { $body } } + } + }; } =20 #[macro_export] --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528755; cv=none; d=zohomail.com; s=zohoarc; b=LPfITlBbOj+wOVs/F5HpzGPKejtOBm2baWUrEvzf0rdajIImNHnmxoN3W+uy93soj9Hv7Xfgwwg515PV+y1v3girT1hZVp+qWaRVwd+WiMXVMY3SwpRyTZd0OgbPnO1SFfPaLnfBIU3S+4j4iD2bXEZ/Ncp+VGj0PFnuiZrcvhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528755; h=Content-Transfer-Encoding:Cc:Cc: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; bh=hHp8U+fC4YmDmSdyK3Hbe0MIdIfjHmGSBbEEt6avx3w=; b=Tt32bXepuT+7Sw1S4jNR57MP0t1eNHk+ZNbNcJdm4JhRRD9SEMIgMfzc9gk7miEXsfoc04rRSfgraSP8Qsn3giT1bx95FcmDSch5He1Bujj/vz/oYb1ZmgClLIR5PeEfpaCcPGInWCAL9NrqwlLnWuBRUA/Xo+EtAXpqrs+p0Qk= 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 1729528755714963.2147204805764; Mon, 21 Oct 2024 09:39:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vP2-0006yB-1t; Mon, 21 Oct 2024 12:37:08 -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 1t2vOF-0006E5-DB for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36: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 1t2vOD-0006KP-OI for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:19 -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-683-ra4IysxaN8yKTROnfyO01A-1; Mon, 21 Oct 2024 12:36:14 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315c1b5befso33563535e9.1 for ; Mon, 21 Oct 2024 09:36:14 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5cc5b9sm63138085e9.45.2024.10.21.09.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hHp8U+fC4YmDmSdyK3Hbe0MIdIfjHmGSBbEEt6avx3w=; b=ZI4pae39sOpSnJuIUw0l7jnmA9GiYvTHpFGh+EjkccWq2pn5R9AMiFEUs1WD071y1iY3nV HjWoJK0KAAH+eUAhl3MSpiNRYoRbluhjdEGguR4BLTJcNQn5GCkfN4hmbjKGU+Wi8xalgn wq20s4K0TvwEuVSv9DD28NbByXsktBk= X-MC-Unique: ra4IysxaN8yKTROnfyO01A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528572; x=1730133372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hHp8U+fC4YmDmSdyK3Hbe0MIdIfjHmGSBbEEt6avx3w=; b=FSv0QpluhBUVV5nEHlaN7CdNeNkHuTCoiVxyZqJaIOBObydXFUtT8AU2X0Rgajscdt 9JNI50XLeC+cJ9V/YLZUGf3g/GscFLcR0sOOVVxIv5XQPikRi7LsXVyU56y6sgI19LUS MgKIs/eA9NdXkN02evFLbXnbU022FiL/abcjmQn9AazZxiRI3KCCQ3V7GMwAP5Tx+hW1 xsVaGb+SiNsYHX9/5K4zuey2VCHOWqh+OXxrAS21T+eyqhyvL/9gvfiSpgHCYPVns3RI Zci9or8tw6qFeC41LXI/G5OBVU16uk1eEgf9pE5AAZkpdTNqz/26kmjeWmYlFf3AK5df GMUg== X-Gm-Message-State: AOJu0Yw1jp5j2jxYOHSQ0JRb1OGAjLs6mvPQHcZqX7FYkNjoZliv3aO/ 7GzBZ27m6wYUDjkWQ7VAGEIzB343yaLMJrR5zP3loQEchINu6d98XQVV0a8yIHy4acyH18v/a1H QKN7vQcl1ECOLPlMMfz57wh+w/5HHuw6MuBCZRzW9YdbczuAxc9hIqQA8x7XwVpIJNN0Lp7tXqx huARrC1F8twq1u9vgQU41R2c6UmE+nuUQFgk82sGY= X-Received: by 2002:a05:600c:1d8d:b0:426:5e91:3920 with SMTP id 5b1f17b1804b1-43161692d44mr99877815e9.29.1729528572039; Mon, 21 Oct 2024 09:36:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTpuBpV1Y/2bigGkfFPEf+RgAHG6s7VIKYboB4Cb69l40jGZAMLPiQQSnRKeIKdRBMrLo3ZA== X-Received: by 2002:a05:600c:1d8d:b0:426:5e91:3920 with SMTP id 5b1f17b1804b1-43161692d44mr99877635e9.29.1729528571622; Mon, 21 Oct 2024 09:36:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 09/13] rust: clean up define_property macro Date: Mon, 21 Oct 2024 18:35:34 +0200 Message-ID: <20241021163538.136941-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_H2=-1.699, 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: 1729528756027116600 Content-Type: text/plain; charset="utf-8" Use the "struct update" syntax to initialize most of the fields to zero, and simplify the handmade type-checking of $name. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- rust/qemu-api/src/device_class.rs | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 2219b9f73d0..5aba426d243 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -29,44 +29,27 @@ macro_rules! device_class_init { macro_rules! define_property { ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { $crate::bindings::Property { - name: { - #[used] - static _TEMP: &::core::ffi::CStr =3D $name; - _TEMP.as_ptr() - }, + // use associated function syntax for type checking + name: ::core::ffi::CStr::as_ptr($name), info: $prop, offset: ::core::mem::offset_of!($state, $field) .try_into() .expect("Could not fit offset value to type"), - bitnr: 0, - bitmask: 0, set_default: true, defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval.= into() }, - arrayoffset: 0, - arrayinfo: ::core::ptr::null(), - arrayfieldsize: 0, - link_type: ::core::ptr::null(), + ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Proper= ty>::zeroed().assume_init() } } }; ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { $crate::bindings::Property { - name: { - #[used] - static _TEMP: &::core::ffi::CStr =3D $name; - _TEMP.as_ptr() - }, + // use associated function syntax for type checking + name: ::core::ffi::CStr::as_ptr($name), info: $prop, offset: ::core::mem::offset_of!($state, $field) .try_into() .expect("Could not fit offset value to type"), - bitnr: 0, - bitmask: 0, set_default: false, - defval: $crate::bindings::Property__bindgen_ty_1 { i: 0 }, - arrayoffset: 0, - arrayinfo: ::core::ptr::null(), - arrayfieldsize: 0, - link_type: ::core::ptr::null(), + ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Proper= ty>::zeroed().assume_init() } } }; } --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528631; cv=none; d=zohomail.com; s=zohoarc; b=N0ifa85EyCH2s+2+3xbDLr5FKHGNg8aZUA/dP5ybVmdCopUzU+nwuiPGKDw7+KkdK/LjTJLxW62iijUAqVrRop0qFfN88xqtIb8p6XtlidGDuY5WvhYnayWX7p4afslox9KAzADF6wvVlrfpvXl2HkrxWydRjwAkcaCkD/eyEfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528631; h=Content-Transfer-Encoding:Cc:Cc: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; bh=Q6fXeEeyQn++bTLgXgQsS/yFO40vxiI7losxFrd52jU=; b=XF0mJOkKsCb5xXmFAig5VaoPdyZPojTiYYH/fEmsElzuDDduWUBZwbJhX2R6307nwfRVuPyx9d2RVR6bfOkIxkH7rGXIl3sMXFubEt9nee7aZa/UjLswlFz+/canJep5YUz4o9slo81hwYnWT1esytSLphZ2CX6ZCO2Z0CjTkWY= 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 1729528631472328.2765407275672; Mon, 21 Oct 2024 09:37:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOw-0006bu-AC; Mon, 21 Oct 2024 12:37:04 -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 1t2vOI-0006Fw-9H for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:24 -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 1t2vOG-0006LL-Gh for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:22 -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-140-wo72bBCBOU6_3b8s-vCNKg-1; Mon, 21 Oct 2024 12:36:18 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d458087c0so3166889f8f.1 for ; Mon, 21 Oct 2024 09:36:17 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a584f7sm4698516f8f.53.2024.10.21.09.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q6fXeEeyQn++bTLgXgQsS/yFO40vxiI7losxFrd52jU=; b=f5VoJM674a8AWIC6FcLDvQbLk665Gjce00sd1kXuDW8UCesNJL6xImptyMbbjPAiTxyvKX BOgfBfjfVdV+r7ti9549QlQqWsjTE+FhUFKZ7QsHHeomL8c7S5vo6pa6im8TqrI68FB8Rg aS9kPdcXeC8AcwIydqgrnQt5VDCZWTw= X-MC-Unique: wo72bBCBOU6_3b8s-vCNKg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528576; x=1730133376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q6fXeEeyQn++bTLgXgQsS/yFO40vxiI7losxFrd52jU=; b=t6eYaX9volYjCK3imRZhvfIG1yPm+fCwpN6XBzeZaHoipkn5ALvKrfD6oF0g8dN/r3 C+ozPJE7z96DS2/0OllWB+tlYv00+Vks9lVsrcn0pd4mEIevC0D7q8votBULoS5IZ1zI aMVUrwkoGAFjp4NDPR2vCeQ2YsLSFdZMN1/9giDdnObX6bFjONNMAy0kgvm3Tj/UjVvz Jtb55BjJUIuiy67OQCR/14uaQRm0g1OcY5fCUkihZW6DA6t/t4MhCDZS9Hu2fxuOuBLw OIgePtShcIrZP6F0MpX8dXIwj2CiedVXYk97wa3VKbYz7d2PdcO6BBnrNn2NcRUKobYo V0SA== X-Gm-Message-State: AOJu0Yw+IqJ5dxdI5xc6H/4efCkLOE8xzCSJ0W9E+lPE9JENh8EK10Ql l3Drgaa5NTlersiUfH71MGqd6tvgabZLScJD1tKTDvveRfzkLYrzDu32XxZu0cZoe19xuD6REGA TZuf+8gz0Nz+WIClUzPHL2RNvd0XGB9H5CaG4/OEEJbhvLeYXlZgwPMRNaTAiyRqYBmb5FUtupi vZTNjrnTnjhUQUEclDBi9iZP7ucCMR3hDnssqfxac= X-Received: by 2002:adf:f10e:0:b0:37e:d92f:c24a with SMTP id ffacd0b85a97d-37ef12624ebmr186003f8f.7.1729528575910; Mon, 21 Oct 2024 09:36:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMK3/foCCFBtMo7wEMvC8DQ/6La2pEr8BWwn0ngNksc+uOYCltyX6UNBYr2vLrTUWfb2nrFQ== X-Received: by 2002:adf:f10e:0:b0:37e:d92f:c24a with SMTP id ffacd0b85a97d-37ef12624ebmr185978f8f.7.1729528575370; Mon, 21 Oct 2024 09:36:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 10/13] qdev: make properties array "const" Date: Mon, 21 Oct 2024 18:35:35 +0200 Message-ID: <20241021163538.136941-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528633688116600 Content-Type: text/plain; charset="utf-8" Constify all accesses to qdev properties, except for the ObjectPropertyAccessor itself. This makes it possible to place them in read-only memory, and also lets Rust bindings switch from "static mut" arrays to "static"; which is advantageous, because mutable statics are highly discouraged. Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- include/hw/qdev-core.h | 4 ++-- include/hw/qdev-properties.h | 4 ++-- hw/core/qdev-properties.c | 26 +++++++++++++------------- system/qdev-monitor.c | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index aa97c34a4be..f9fa291cc63 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -132,7 +132,7 @@ struct DeviceClass { * ensures a compile-time error if someone attempts to assign * dc->props directly. */ - Property *props_; + const Property *props_; =20 /** * @user_creatable: Can user instantiate with -device / device_add? @@ -935,7 +935,7 @@ char *qdev_get_own_fw_dev_path_from_handler(BusState *b= us, DeviceState *dev); * you attempt to add an existing property defined by a parent class. * To modify an inherited property you need to use???? */ -void device_class_set_props(DeviceClass *dc, Property *props); +void device_class_set_props(DeviceClass *dc, const Property *props); =20 /** * device_class_set_parent_realize() - set up for chaining realize fns diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 09aa04ca1e2..26ebd230685 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -37,7 +37,7 @@ struct PropertyInfo { int (*print)(Object *obj, Property *prop, char *dest, size_t len); void (*set_default_value)(ObjectProperty *op, const Property *prop); ObjectProperty *(*create)(ObjectClass *oc, const char *name, - Property *prop); + const Property *prop); ObjectPropertyAccessor *get; ObjectPropertyAccessor *set; ObjectPropertyRelease *release; @@ -223,7 +223,7 @@ void error_set_from_qdev_prop_error(Error **errp, int r= et, Object *obj, * On error, store error in @errp. Static properties access data in a str= uct. * The type of the QOM property is derived from prop->info. */ -void qdev_property_add_static(DeviceState *dev, Property *prop); +void qdev_property_add_static(DeviceState *dev, const Property *prop); =20 /** * qdev_alias_all_properties: Create aliases on source for all target prop= erties diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 86a583574dd..315196bd85a 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -749,7 +749,7 @@ const PropertyInfo qdev_prop_array =3D { =20 /* --- public helpers --- */ =20 -static Property *qdev_prop_walk(Property *props, const char *name) +static const Property *qdev_prop_walk(const Property *props, const char *n= ame) { if (!props) { return NULL; @@ -763,10 +763,10 @@ static Property *qdev_prop_walk(Property *props, cons= t char *name) return NULL; } =20 -static Property *qdev_prop_find(DeviceState *dev, const char *name) +static const Property *qdev_prop_find(DeviceState *dev, const char *name) { ObjectClass *class; - Property *prop; + const Property *prop; =20 /* device properties */ class =3D object_get_class(OBJECT(dev)); @@ -840,7 +840,7 @@ void qdev_prop_set_string(DeviceState *dev, const char = *name, const char *value) =20 void qdev_prop_set_enum(DeviceState *dev, const char *name, int value) { - Property *prop; + const Property *prop; =20 prop =3D qdev_prop_find(dev, name); object_property_set_str(OBJECT(dev), name, @@ -956,7 +956,7 @@ const PropertyInfo qdev_prop_size =3D { /* --- object link property --- */ =20 static ObjectProperty *create_link_property(ObjectClass *oc, const char *n= ame, - Property *prop) + const Property *prop) { return object_class_property_add_link(oc, name, prop->link_type, prop->offset, @@ -969,7 +969,7 @@ const PropertyInfo qdev_prop_link =3D { .create =3D create_link_property, }; =20 -void qdev_property_add_static(DeviceState *dev, Property *prop) +void qdev_property_add_static(DeviceState *dev, const Property *prop) { Object *obj =3D OBJECT(dev); ObjectProperty *op; @@ -980,7 +980,7 @@ void qdev_property_add_static(DeviceState *dev, Propert= y *prop) field_prop_getter(prop->info), field_prop_setter(prop->info), prop->info->release, - prop); + (Property *)prop); =20 object_property_set_description(obj, prop->name, prop->info->description); @@ -994,7 +994,7 @@ void qdev_property_add_static(DeviceState *dev, Propert= y *prop) } =20 static void qdev_class_add_property(DeviceClass *klass, const char *name, - Property *prop) + const Property *prop) { ObjectClass *oc =3D OBJECT_CLASS(klass); ObjectProperty *op; @@ -1007,7 +1007,7 @@ static void qdev_class_add_property(DeviceClass *klas= s, const char *name, field_prop_getter(prop->info), field_prop_setter(prop->info), prop->info->release, - prop); + (Property *)prop); } if (prop->set_default) { prop->info->set_default_value(op, prop); @@ -1046,7 +1046,7 @@ static void qdev_get_legacy_property(Object *obj, Vis= itor *v, * Do not use this in new code! QOM Properties added through this interfa= ce * will be given names in the "legacy" namespace. */ -static void qdev_class_add_legacy_property(DeviceClass *dc, Property *prop) +static void qdev_class_add_legacy_property(DeviceClass *dc, const Property= *prop) { g_autofree char *name =3D NULL; =20 @@ -1058,12 +1058,12 @@ static void qdev_class_add_legacy_property(DeviceCl= ass *dc, Property *prop) name =3D g_strdup_printf("legacy-%s", prop->name); object_class_property_add(OBJECT_CLASS(dc), name, "str", prop->info->print ? qdev_get_legacy_property : prop->info->get, - NULL, NULL, prop); + NULL, NULL, (Property *)prop); } =20 -void device_class_set_props(DeviceClass *dc, Property *props) +void device_class_set_props(DeviceClass *dc, const Property *props) { - Property *prop; + const Property *prop; =20 dc->props_ =3D props; for (prop =3D props; prop && prop->name; prop++) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 44994ea0e16..c346ea6ae4b 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -751,7 +751,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **er= rp) =20 #define qdev_printf(fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", #= # __VA_ARGS__) =20 -static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *pro= ps, +static void qdev_print_props(Monitor *mon, DeviceState *dev, const Propert= y *props, int indent) { if (!props) --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528646; cv=none; d=zohomail.com; s=zohoarc; b=CVUnLZ7+tNeOrkN8qLBdVxzvKG/Q4DM9mY23ibOdOnEgLDwuzXly3ztEp7/vs14UbjHzGapbIiE+n8EsxHJj/iUiuk7fCjnS8zkQro1kLw65Dv4HM3Wq9likHVlxivgXBxMNqWPmdNPZpEzQwmqdD1Sl2UR+MSQSy1ukaBZiJ04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528646; h=Content-Transfer-Encoding:Cc:Cc: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; bh=Qr5dagb8vQ3bDNxUa7EXxPicbCEKo86t7f8oVBzNrBQ=; b=DU4yDTuptYxsfIUNX7VPHEKPRaiYgDG4v9e51CjFUUyBD2ynXJDN9t/Kez8bnX+GJJ7mLc8Vu8PvZ/ScOfBRrSn+z7N6I56JJaWwZz4M5ljngI7+BRZgiiPTioLa95+dUpUMoU5hoLHbVEoAo9WdN0hhrxhQ+0RXVXLpGMA/TYg= 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 1729528646178573.6938892588273; Mon, 21 Oct 2024 09:37:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vOz-0006nf-KE; Mon, 21 Oct 2024 12:37: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 1t2vOM-0006IJ-7T for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36: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 1t2vOK-0006Ln-2X for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:25 -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-619-5TJ3YyfQMGiyftT7h7QEfw-1; Mon, 21 Oct 2024 12:36:22 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-431518e6d8fso32226885e9.0 for ; Mon, 21 Oct 2024 09:36:22 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5709efsm63926925e9.10.2024.10.21.09.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qr5dagb8vQ3bDNxUa7EXxPicbCEKo86t7f8oVBzNrBQ=; b=XENkGCsOzPl1nrfhusyvB++SFMKpgsTM86HLqFyTEt+lNNTLSdcpOUI9m3mrr5KDpfpZVT stthyp/+TKyDdflHvLoec2iVj4JQQBtzGwbK+nOnBKN0wYCHcACF2kOaErbbQ2nPryXO7g KdovhL8AAbIRyahcMzL2pDD/FGPbL0M= X-MC-Unique: 5TJ3YyfQMGiyftT7h7QEfw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528580; x=1730133380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qr5dagb8vQ3bDNxUa7EXxPicbCEKo86t7f8oVBzNrBQ=; b=ldu/LlQqjoxSmzLkiQo8QonXVBIG6urXMYOvt/pLIlQ5w8zLic4vu/921ksD50O1zk IFVxCwOnA+t1fXJLdE2N01EN7GW6iH/Py2g6Is1IuwzyBlWs+gSVZNmvQPzDigt+CxHt 4lGyXp8lHZ3sTCLKq16ZzbWDyk+HI4DupVgv8SP2M5hCeqLc1mD1C/yJML80+gVxOz5R opmZtaOxFvjIyNJ5v28hRnXcz4Be4iiC/bBv2FLPh1bCwgTWWItcTYlMqFAkWQjpqHdn XTd0/Ity8dKqnMSN5951hjKXpwo9dRIpS1gfxGvbXWU8jawKPr4Nyb5E0S1xd2dcRGmq /3vA== X-Gm-Message-State: AOJu0Yw8x1bcbKikDrrfoCa8azw+5q11vxMdZpjFBUi1USn35z2IGd86 CLldoouL+4hbl0lJNGfjixgiIx59C7Tiui1HuU/smKInfiOxoWnUz8Kb+UBZwhI6xpiE9b/OKAZ KwSGetzs4fOSRjRBr8IdMMWUYNZFnoDoXW/kz6x6rYwCUqL2J81JlFNNYf+hCNZffXJ4UgUC1+z 2V5nqOLKvMwwSiYB7u45WMqY8T72Wrn2SlpUrjAfU= X-Received: by 2002:a05:600c:4751:b0:431:612f:189b with SMTP id 5b1f17b1804b1-43161649510mr87412265e9.12.1729528579913; Mon, 21 Oct 2024 09:36:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlDNUJ9aNFHH9akQxzvIEapV8Kx8cor6fWetajxrgiuBLxLfD496WyLG6iD92BJfxFAHhtPw== X-Received: by 2002:a05:600c:4751:b0:431:612f:189b with SMTP id 5b1f17b1804b1-43161649510mr87412035e9.12.1729528579456; Mon, 21 Oct 2024 09:36:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 11/13] rust: make properties array immutable Date: Mon, 21 Oct 2024 18:35:36 +0200 Message-ID: <20241021163538.136941-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_H2=-1.699, 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: 1729528647650116600 Content-Type: text/plain; charset="utf-8" Now that device_class_set_props() takes a const pointer, the only part of "define_property!" that needs to be non-const is the call to try_into(). This in turn will only break if offset_of returns a value with the most significant bit set (i.e. a struct size that is >=3D2^31 or >=3D 2^63, respectively on 32- and 64-bit system), which is impossible. Just use a cast and clean everything up to remove the run-time initialization. This also removes a use of OnceLock, which was only stabilized in 1.70.0. Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- rust/qemu-api/src/device_class.rs | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 5aba426d243..d885f2fcf19 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -2,10 +2,6 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use std::sync::OnceLock; - -use crate::bindings::Property; - #[macro_export] macro_rules! device_class_init { ($func:ident, props =3D> $props:ident, realize_fn =3D> $realize_fn:exp= r, legacy_reset_fn =3D> $legacy_reset_fn:expr, vmsd =3D> $vmsd:ident$(,)*) = =3D> { @@ -19,7 +15,7 @@ macro_rules! device_class_init { 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()); + $crate::bindings::device_class_set_props(dc.as_mut(), $pro= ps.as_ptr()); } } }; @@ -32,9 +28,7 @@ macro_rules! define_property { // use associated function syntax for type checking name: ::core::ffi::CStr::as_ptr($name), info: $prop, - offset: ::core::mem::offset_of!($state, $field) - .try_into() - .expect("Could not fit offset value to type"), + offset: ::core::mem::offset_of!($state, $field) as isize, set_default: true, defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval.= into() }, ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Proper= ty>::zeroed().assume_init() } @@ -45,47 +39,27 @@ macro_rules! define_property { // use associated function syntax for type checking name: ::core::ffi::CStr::as_ptr($name), info: $prop, - offset: ::core::mem::offset_of!($state, $field) - .try_into() - .expect("Could not fit offset value to type"), + offset: ::core::mem::offset_of!($state, $field) as isize, set_default: false, ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Proper= ty>::zeroed().assume_init() } } }; } =20 -#[repr(C)] -pub struct Properties(pub OnceLock<[Property; N]>, pub fn(= ) -> [Property; N]); - -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() - } -} - #[macro_export] macro_rules! declare_properties { ($ident:ident, $($prop:expr),*$(,)*) =3D> { - - const fn _calc_prop_len() -> usize { + pub static $ident: [$crate::bindings::Property; { let mut len =3D 1; $({ _ =3D stringify!($prop); len +=3D 1; })* len - } - const PROP_LEN: usize =3D _calc_prop_len(); - - fn _make_properties() -> [$crate::bindings::Property; PROP_LEN] { - [ - $($prop),*, - unsafe { ::core::mem::MaybeUninit::<$crate::bindings::= Property>::zeroed().assume_init() }, - ] - } - - pub static mut $ident: $crate::device_class::Properties = =3D $crate::device_class::Properties(::std::sync::OnceLock::new(), _make_pr= operties); + }] =3D [ + $($prop),*, + unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Property= >::zeroed().assume_init() }, + ]; }; } =20 --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528741; cv=none; d=zohomail.com; s=zohoarc; b=KtywRjPwhP9QgKX/aFpB6W+pMvX6+dj+qcyZK0VwhN53xMRJWt83KD4xw+IK1abaYmHybFE42BdJ40YEgudDl6n8tP/jR+4bUtS318qtzfvC3/rNc8tQgdTp1tuuLQb7yMOsVC5ktWGQ17VzyhI/Tw+j6fUCW+2lxFpOuqnx2zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528741; h=Content-Transfer-Encoding:Cc:Cc: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; bh=2BdOoYFgTDYgcexwJMKhcnGOcBQRfOI4n0cvkFXXd3Q=; b=K1Kocf2CNrAXI92W/f1ZvDqSVjcT8Zcimv1tCIVAtg3yVkNpb7omDhZ/v6G0rBCDXj2Lw2ZM4JnPZF/ufunKE2Din26Dx9al/8VSQT/LdhSxTONdQCyBSvDMQZcJzqzuSmo+vveO/s76rKAS3iRpG1cNds+fb99yXUVkpy2KdGw= 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 1729528741796237.1914686012483; Mon, 21 Oct 2024 09:39:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vP2-00075O-L3; Mon, 21 Oct 2024 12:37:09 -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 1t2vOU-0006Od-Ms for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:37 -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 1t2vOP-0006M2-RN for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:32 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-huMKzoV9P2WAA8-NPzxDHQ-1; Mon, 21 Oct 2024 12:36:26 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4314f023f55so38157375e9.2 for ; Mon, 21 Oct 2024 09:36:25 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a4856fsm4713098f8f.33.2024.10.21.09.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528587; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2BdOoYFgTDYgcexwJMKhcnGOcBQRfOI4n0cvkFXXd3Q=; b=GVKdwsHh8jmpemc2rqEk/3kXx/wgFsxvYDQvxOVNz3dsMmmYa5MgmbavSNfhWebwZGKA2Y QLzYzKH/doBsLL6ng1IJVC5jN3XtjzgyUR+vdcyns7tqGf5Ynajka0cu9sXQ+mEaxrCZbP 9BibKmUfiL6d4gI9pf0c0DoZXDqAgvY= X-MC-Unique: huMKzoV9P2WAA8-NPzxDHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528584; x=1730133384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2BdOoYFgTDYgcexwJMKhcnGOcBQRfOI4n0cvkFXXd3Q=; b=WCGMTZvX43J30n+iuBY1HwEHDd8byEu4j+v4EXKK0mNUCxhpY1SGrWZw76YKcVsDgx RP2DJFgxYk/sh0XaouZqVS4ntA3kmvqw6AFOufi0Iys4jtve/oYxGoTezyaGRYocPV1D /SiqxrO4h+mEtg7h26K76G+W0Unl3f4aQVr9Y84wYN78M/6pz1AZ79BtE1JqdiGqjRVh eLTUGBpsBjAJ14E2g4eQC6oV8q46gy7XUD+u5Ehy0YdNfuN7r5b9quILPAx/PZa/DivC XctziDPCC4qlEFJloVh8QtHlSflD0nfJmdZqnmWQqQfVX7Aij7SMoVK6lXcDnODjsV5N YJtA== X-Gm-Message-State: AOJu0Yzyk601V4lnQ/T9izXgmtdPqUJvyOln/Hn8hKQXhJJSd2uN9Ynp UAgOGan0mQ8yEZTNzOYzJCl8zXyqpmLBQBElqz/DquPgWdznZ5F5cRZwtYZKy280ohIpkq3nEFO VcNhel4D8pKt+7rz8R8Aiivxw9qxjAQG4VP6ctt2cy6S00mbS0ItHFzfwv7RlFhOnjRUWmLpMdF QgPKXoCLnGPbDUomid1thLQdby28JgInG3gJ2Ec3Y= X-Received: by 2002:a05:600c:4f09:b0:42c:c28c:e477 with SMTP id 5b1f17b1804b1-43161697686mr96761605e9.23.1729528584025; Mon, 21 Oct 2024 09:36:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGutK9twdTD9IzG41Qe+bK1s3XPTEO6ajOcTHifNBWq2SKsw0liL4BCffFEnm/joHF1lZ+bEQ== X-Received: by 2002:a05:600c:4f09:b0:42c:c28c:e477 with SMTP id 5b1f17b1804b1-43161697686mr96761325e9.23.1729528583499; Mon, 21 Oct 2024 09:36:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 12/13] rust: provide safe wrapper for MaybeUninit::zeroed() Date: Mon, 21 Oct 2024 18:35:37 +0200 Message-ID: <20241021163538.136941-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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: 1729528744303116600 Content-Type: text/plain; charset="utf-8" MaybeUninit::zeroed() is handy, but it introduces unsafe (and has a pretty heavy syntax in general). Introduce a trait that provides the same functionality while staying within safe Rust. In addition, MaybeUninit::zeroed() is not available as a "const" function until Rust 1.75.0, so this also prepares for having handwritten implementations of the trait until we can assume that version. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- rust/hw/char/pl011/src/device_class.rs | 8 ++++++-- rust/hw/char/pl011/src/memory_ops.rs | 11 +++++++---- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/device_class.rs | 8 ++++---- rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/zeroable.rs | 23 +++++++++++++++++++++++ 6 files changed, 42 insertions(+), 10 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 2ad80451e87..78fa1cdd5b6 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::*, + definitions::ObjectImpl, + zeroable::Zeroable, +}; =20 use crate::device::PL011State; =20 @@ -12,7 +16,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 5a5320e66c3..24ac9c870c1 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -2,9 +2,12 @@ // 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 qemu_api::bindings::*; +use qemu_api::{ + bindings::*, + zeroable::Zeroable +}; =20 use crate::device::PL011State; =20 @@ -14,11 +17,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 1fc36078027..1b0fd406378 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/zeroable.rs', ], {'.' : bindings_rs}, ), diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index d885f2fcf19..ed2d7ce1a54 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -31,7 +31,7 @@ macro_rules! define_property { offset: ::core::mem::offset_of!($state, $field) as isize, set_default: true, defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval.= into() }, - ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Proper= ty>::zeroed().assume_init() } + ..$crate::zeroable::Zeroable::ZERO } }; ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { @@ -41,7 +41,7 @@ macro_rules! define_property { info: $prop, offset: ::core::mem::offset_of!($state, $field) as isize, set_default: false, - ..unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Proper= ty>::zeroed().assume_init() } + ..$crate::zeroable::Zeroable::ZERO } }; } @@ -58,7 +58,7 @@ macro_rules! declare_properties { len }] =3D [ $($prop),*, - unsafe { ::core::mem::MaybeUninit::<$crate::bindings::Property= >::zeroed().assume_init() }, + $crate::zeroable::Zeroable::ZERO, ]; }; } @@ -79,7 +79,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 6bc68076aae..e94a15bb823 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -29,6 +29,7 @@ unsafe impl Sync for bindings::VMStateDescription {} =20 pub mod definitions; pub mod device_class; +pub mod zeroable; =20 use std::alloc::{GlobalAlloc, Layout}; =20 diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs new file mode 100644 index 00000000000..45ec95c9f70 --- /dev/null +++ b/rust/qemu-api/src/zeroable.rs @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/// Encapsulates the requirement that +/// `MaybeUninit::::zeroed().assume_init()` does not cause +/// undefined behavior. +/// +/// # Safety +/// +/// Do not add this trait to a type unless all-zeroes is +/// a valid value for the type. In particular, remember that raw +/// pointers can be zero, but references and `NonNull` cannot +/// unless wrapped with `Option<>`. +pub unsafe trait Zeroable: Default { + /// SAFETY: If the trait was added to a type, then by definition + /// this is safe. + const ZERO: Self =3D unsafe { ::core::mem::MaybeUninit::::zeroed= ().assume_init() }; +} + +unsafe impl Zeroable for crate::bindings::Property__bindgen_ty_1 {} +unsafe impl Zeroable for crate::bindings::Property {} +unsafe impl Zeroable for crate::bindings::VMStateDescription {} +unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 {} +unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 {} --=20 2.46.2 From nobody Tue Oct 22 22:33:36 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=1729528674; cv=none; d=zohomail.com; s=zohoarc; b=GSpG7xiu6TV4Nt4FJH6FuYvdd8iyPDqqHCjL29MN7eo/WRdXBftSdhK/e/72OM27y2xb4y0xlkAr2myAxyOVvR+Bz+6T0bc3H6jCgAHMPIoT0S3cXQZ4q7gfjgEjxmTRTtgF5L0fVzLW57ecIKykg+G/vbk7x7Kb1fCDHcWhBxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729528674; h=Content-Transfer-Encoding:Cc:Cc: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; bh=LLppDWV53KItuDjPGr/az+c8hOztlyzUeTjrRwEDn8w=; b=P8RYDhm35jLuPm6LU1R2QPCK1og8aPpIMFdG7P7RgzoUfwdJ6Pc/r3FgZqfLe+JXuKsqhWeyLiYX1LaffIQpevsidfmSwQF+P2mSsLg6MRDh+DBBk5jSq/ct3gylwcVKz/coqvdNb6Qp3N74WkcPGjufaEZvhNEWQnONP5GzGUg= 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 1729528674073505.15065221462294; Mon, 21 Oct 2024 09:37:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2vP7-0007kR-BG; Mon, 21 Oct 2024 12:37:13 -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 1t2vOU-0006Oc-Mm for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:37 -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 1t2vOR-0006MI-IY for qemu-devel@nongnu.org; Mon, 21 Oct 2024 12:36:33 -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-311-cyt-7jYsMcqxEEcvUIvI6w-1; Mon, 21 Oct 2024 12:36:29 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4315ad4938fso34318985e9.0 for ; Mon, 21 Oct 2024 09:36:29 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a5c529sm4704753f8f.62.2024.10.21.09.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 09:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729528590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LLppDWV53KItuDjPGr/az+c8hOztlyzUeTjrRwEDn8w=; b=KeTOmW+DrMHb90ndDT0Uzw3R7TVi3rLfT1B2rWezyI3Vo3qxWVabIDTpECS8flJ6xDyAzr ynWs63Qso6ESuBk6KJoUAVWO/xlfuM6gHAF8qbIbxw9Rd9R7DofKLHu6UtyOnj8/pCXn3L 7zvkZ5Ry9PyShEOYb/1rENwgpgy9XE0= X-MC-Unique: cyt-7jYsMcqxEEcvUIvI6w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729528587; x=1730133387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LLppDWV53KItuDjPGr/az+c8hOztlyzUeTjrRwEDn8w=; b=XwaQsqTrkHQ8Q8PBT74nE2xiuj7rx13DduLtKSIp8dWoccdgqdykFAdd6sreXrvAGv h87q+zCoDYX+RIzymMkg0lFJ/3wobNbjz2SCdtbZHQaaebbExANs1mUtO4/tLnM5Cipb 9sJFDIdFxeSJwVXvm+s/Wp0izscd8UiIT/0U/KNvhNGwRNVggFW81ZsAhvpDrrdQvMKf Q7jjITQ8RGVhm+MwGqANZC3vUtt6L9LjdQoi4qBuWWos3FPX2AMh+I1suEn6BEiZOE9v seojJzRH4fv5HYHX0JRNF1+GQsaPjlrAQtW2IeDAgadGVdRINCAYx3493Cwlm4Ce2tWB bD7A== X-Gm-Message-State: AOJu0Yx+w8XkKIQmUjieJsd+ZKCjUvxIZYwTV6olCuJTzkS1MG5rkxOz oS3p3pr2ve4o67HLbKl7iMAhwcI1kXkBzakPCE4a3ITQDODwcsA7IrnlWG+W4C1ycYnb32k/SJI n0X9SADe8LjQOw3wZ9OULpkOckvol6Rslm66Ftbne9fjN2FLt50aKALaRb9gvyvtHv8nSkQ/1bC NLmgjK8ABgj62uPdYVXlGcs7QNi6N4WZhuGxUNQsc= X-Received: by 2002:adf:f7d1:0:b0:37d:50e1:b3e1 with SMTP id ffacd0b85a97d-37eab6da72emr7715256f8f.16.1729528587139; Mon, 21 Oct 2024 09:36:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0E3RXCUgPvGNLsmyjB1DuEXohlouR9ILqS17064F9Ug1RPc47zYzAaPfTaRs9BJWxTYRhVw== X-Received: by 2002:adf:f7d1:0:b0:37d:50e1:b3e1 with SMTP id ffacd0b85a97d-37eab6da72emr7715242f8f.16.1729528586786; Mon, 21 Oct 2024 09:36:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Junjie Mao Subject: [PATCH v2 13/13] rust: do not use TYPE_CHARDEV unnecessarily Date: Mon, 21 Oct 2024 18:35:38 +0200 Message-ID: <20241021163538.136941-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241021163538.136941-1-pbonzini@redhat.com> References: <20241021163538.136941-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.421, 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_H2=-1.699, 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: 1729528675632116600 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. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini Reviewed-by: Kevin Wolf --- 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 2b43f5e0939..0f6918dd224 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -572,7 +572,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"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