From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781025967; cv=none; d=zohomail.com; s=zohoarc; b=JNdwPyMufgRl3AepG8vrtQ2n5+QRtk1Pjfp1WdxD00MMM/Xq2EGdWOMg31W58DhseFw46hNjGkY4C2bglmgrJv4cADMywdC1F6jF55wfmQGfqUYS2cC1CPJLF2eMy4lWESKP4uuMyFEFdWYrn2mRxIBWWQYty2OJ7pVVivBjeHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781025967; h=Content-Type: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=aVVARmJUwhep7oD37d2RCWN4JLy97YXNlME0a8arUGM=; b=CVOIKegvB53NN2aJDsPFCGmAhPcpY47Y/0USCe6z2PqnMoeFeOEf7uLsErgc9739TAn9tDf42rmG/78PsSp/xrzPClmmN4/1RtTedcLPXqweJ3ZBnDJkBCpSf+MnWnOJL9uMZwPWQWjaGQnPQiTsMDDwLMxjg2vbJ9yPVDFkZLw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781025967818316.2519160542158; Tue, 9 Jun 2026 10:26:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0Cp-0007WB-AZ; Tue, 09 Jun 2026 13:25:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Cd-0007Kw-Lh for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:29 -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 1wX0Ca-0001p7-4e for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:25 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-Mn3wGF-3M4eQafikD8vjMQ-1; Tue, 09 Jun 2026 13:25:21 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-51760f997fdso172884531cf.2 for ; Tue, 09 Jun 2026 10:25:21 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025922; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aVVARmJUwhep7oD37d2RCWN4JLy97YXNlME0a8arUGM=; b=Z01QdNG+wea6xfS2B3ZgWSRjIIym0Vfb89BPTFaf+zJ3K6DmQjhKcc4kRK76M2JcomK9oK 0IdL0hm16JtTobpBJc6NE/5IodR4tkts3vDw6niQlzv2sDWbyWVTxM/578xQtF7P6CboTm dM9yu1KJZ8BTGWIOokoNrR9BY5/nx4U= X-MC-Unique: Mn3wGF-3M4eQafikD8vjMQ-1 X-Mimecast-MFC-AGG-ID: Mn3wGF-3M4eQafikD8vjMQ_1781025920 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025920; x=1781630720; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aVVARmJUwhep7oD37d2RCWN4JLy97YXNlME0a8arUGM=; b=jF0NpfXHA9T2ym3Cd1t/5cJ7w9+3nIVgghZosb0zGV5GHM8/GFbQDqhGk7UrmI1b9S rle+snf7xlwBAUyxz9pZKLXrVD4JQybYG0vKUFy+7jIgJtU9CUdRh1zLAODrJ6tVIEfT leNF3TmcNNq11cMQ9KDMJPNRYdZBVdjeNqsLHnPiA32b8h2K1DstM4SaVaqU9iiEtOY8 8Xg97b6/Me5un/93sL+/n+edVcsofu3tsUIks4wApv3l75uHffPp2K61nHeFeiwfXbfQ i+57yB0kZ3QFtsE+v/d73lz07bAt/Sl9mrkJ0hQNu09MoCzi5pRIFtmuFzJyfJOd3n++ DugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025920; x=1781630720; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aVVARmJUwhep7oD37d2RCWN4JLy97YXNlME0a8arUGM=; b=pngTpbqpyCPdVO1/ihDrdTicn3rK8Eh/jgm4O8caFGlUxzhcKG97sd7/0dfBaSLcpU OHYqZC1K17fQXqcVXSWMNL4/Quab7RCZfz7rtnQucVxCeMd0pFsKyP9ybiyv4xqL2rRf L9MTc2CzLa59/PBs5/WYYiUgCaXIxtsL+VkTvsrg2LkVbM3cogc4WJPll3v/FoltKBJP KQIXFSjI/t1z7YSqll2Pa+U13qqHTeuGFkqekE0+OghBuVvUVV0wd+rHyE0qfU32hDRd f3H9ZRFFFkKizOyjJk4AUE/l9RuE5iHhCodYo3jYO1lNoTYYr0Oni7EqyRM3DHiUBRc+ Ou7w== X-Gm-Message-State: AOJu0YxCSp/sGnAIb+TCWhFKeWxf00S9TBhJOvfE/uhA+PujthCRlLS7 +NvC/IXtGTcLf9jmuPt89iwOAwka/onCoFMq21s4IWHhVw9YhN2Fe9Ka9LtNBdlA8K8G/9NWquv 8DlnvthfDI2/ab1g5O4fsAYtpXWfrjd88m57TF2/NpitjgmLAKnRBINT76XCA5wtfo+oR+DPDvj 7JNFxMl9YfLwCQW+TMuu0nDnS7rDlujXF+yk2XfA== X-Gm-Gg: Acq92OF3BOfithApu3Ok7AfTRJFYafUMuqKD4gkyDPt8DXq00sNlsMePWqQMYE8VsIr bgmJ+EGABdAsfhoV/tM5GCvjAdXrY/d8fHdwurxE3sg3rw8AliIO6nBeEY5bF5nqtD3eE8XVKsD AVn8ev/2C6GSafqxHEbD+1hZV5hDsOb6io7It0aQwsrMmM5VkSMqtIKCQ0azVXmafe7mlnJoJ/U gGr3poTFrUnd82LYTw6LkRcUQlNpO/LrBaWVjwoQeQ76wkSJ0AGAUoAWMd4aDw+13jer+vRZY72 Di3UVp7aof7BaB7edq5a31Ti22bHaR0y+eL7ZySEh8pZCSehMPNBymlf8YH6LF8vPjKBdrP1FNm gsmhqfHgFogY4Q3M2fpkzles= X-Received: by 2002:a05:622a:47cf:b0:517:2c1e:8b6 with SMTP id d75a77b69052e-51795c66183mr278467501cf.38.1781025920373; Tue, 09 Jun 2026 10:25:20 -0700 (PDT) X-Received: by 2002:a05:622a:47cf:b0:517:2c1e:8b6 with SMTP id d75a77b69052e-51795c66183mr278466621cf.38.1781025919664; Tue, 09 Jun 2026 10:25:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 01/10] migration: Use OBJECT_DECLARE_SIMPLE_TYPE Date: Tue, 9 Jun 2026 13:25:05 -0400 Message-ID: <20260609172514.2037645-2-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@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.445, 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1781025969707158500 Migration object's class has nothing special, switch to the newly introduced macro. Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.h | 9 +-------- migration/migration.c | 7 +++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 841f49b215..293ad60e07 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -263,14 +263,7 @@ void fill_destination_postcopy_migration_info(Migratio= nInfo *info); =20 #define TYPE_MIGRATION "migration" =20 -typedef struct MigrationClass MigrationClass; -DECLARE_OBJ_CHECKERS(MigrationState, MigrationClass, - MIGRATION_OBJ, TYPE_MIGRATION) - -struct MigrationClass { - /*< private >*/ - DeviceClass parent_class; -}; +OBJECT_DECLARE_SIMPLE_TYPE(MigrationState, MIGRATION); =20 struct MigrationState { /*< private >*/ diff --git a/migration/migration.c b/migration/migration.c index 074d3f2c69..278cad502a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -297,7 +297,7 @@ void migration_object_init(void) { /* This can only be called once. */ assert(!current_migration); - current_migration =3D MIGRATION_OBJ(object_new(TYPE_MIGRATION)); + current_migration =3D MIGRATION(object_new(TYPE_MIGRATION)); =20 /* * Init the migrate incoming object as well no matter whether @@ -3975,7 +3975,7 @@ static void migration_class_init(ObjectClass *klass, = const void *data) =20 static void migration_instance_finalize(Object *obj) { - MigrationState *ms =3D MIGRATION_OBJ(obj); + MigrationState *ms =3D MIGRATION(obj); =20 qapi_free_BitmapMigrationNodeAliasList(ms->parameters.block_bitmap_map= ping); qapi_free_strList(ms->parameters.cpr_exec_command); @@ -3993,7 +3993,7 @@ static void migration_instance_finalize(Object *obj) =20 static void migration_instance_init(Object *obj) { - MigrationState *ms =3D MIGRATION_OBJ(obj); + MigrationState *ms =3D MIGRATION(obj); =20 ms->state =3D MIGRATION_STATUS_NONE; ms->mbps =3D -1; @@ -4040,7 +4040,6 @@ static const TypeInfo migration_type =3D { */ .parent =3D TYPE_DEVICE, .class_init =3D migration_class_init, - .class_size =3D sizeof(MigrationClass), .instance_size =3D sizeof(MigrationState), .instance_init =3D migration_instance_init, .instance_finalize =3D migration_instance_finalize, --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781026054; cv=none; d=zohomail.com; s=zohoarc; b=ErZ9ohvWrbvh23uL1mKDm5HHd6tpya+1i5Bzy7iSOcDguHG+aej8f+GfIo8UOVq+FXFWqJmfdXhZDRJJEG1fOtzi3dbraiunigdJPufHoHTfoVh/XZRVKz5MEPrrtuJwTjnwyv3MjvPAnoAJ5C2f27+jx6Wbq67FpCb8oOyz1pU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781026054; 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=RTdK9UhiIM0qRwABF6UWGsM5x1elL2UrbbjIZlAcG7s=; b=HvvpZ4/cukQL3e3j1jnz790w8rtUhRe0Abg4luHSRICMwvh56nq6W0Jsd0RX7xywzCpv1ZKlKXgU8nUbCARZ66g+iTrII216hDKwc/BwnhKPm4myI6n5bGfSji5sHpgPwhwgIiflJaLWiD+KbCgyFicefIWFKxerc0K7SbrpLtE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781026054598342.81313165053916; Tue, 9 Jun 2026 10:27:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0Cx-0007b7-Kj; Tue, 09 Jun 2026 13:25:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Ch-0007Nr-Fq for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:33 -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 1wX0Cd-0001qH-CS for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:28 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-N3zhHAT1PDKwOu4b-PNZng-1; Tue, 09 Jun 2026 13:25:22 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-5179e5ba14cso63547581cf.2 for ; Tue, 09 Jun 2026 10:25:22 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025924; 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=RTdK9UhiIM0qRwABF6UWGsM5x1elL2UrbbjIZlAcG7s=; b=DUsTE6YaEfAbqQmf4AwHlxPwL5AKx9QNIGqNmqiERrq2Pl1eg3PGzdDe55slE7B4cB476c ngQMwoomvfEk8RJ3vqiIvPIqcC2VvOQxemHUzOykTHrcaMM4yaGixiF72uZ1cp/YUEUYwb PIOy3SgYrAM591Ybb/X2KH0su5XaImU= X-MC-Unique: N3zhHAT1PDKwOu4b-PNZng-1 X-Mimecast-MFC-AGG-ID: N3zhHAT1PDKwOu4b-PNZng_1781025922 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025922; x=1781630722; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RTdK9UhiIM0qRwABF6UWGsM5x1elL2UrbbjIZlAcG7s=; b=TktzWdHStHpw3i/M2RE3EtWX7Hd1r5VHiWRmq9fBniVILeIADPFthfxTvtBSyjzUkv 8GJiR8Ox/CIN0aUgRC8UJEywoskB0mpsCxVd8XgaJJIDxbXKpapyhyHe+He6qL94AsIL 7GE8LxFsGy2MgJbSaFSzxc7kx/Wn0UdBl3KUMEg5BIuE24XfzPQBAyiXYKQc+4VL2uwp pmSNLAl84wSrFbV3r03WtoPLbPOYMkZICW00ENuPLeNSwKJvimLZRGgTwFQ5gpDwksmQ S5fiXcDpMaY7mvLoEeUkMjwcZWhNAlD4Z3SrtWXW0KbAE1qrWaMK32moSqg60PrBLWaa MVDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025922; x=1781630722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RTdK9UhiIM0qRwABF6UWGsM5x1elL2UrbbjIZlAcG7s=; b=XKI4Zks2X0GfT2tNrdcLC/bbqSHX3EX/SLpHkX67rMGtAIiqvf+UxDSpO66rqi8Deb uctKhM0qIFizF8F+WqHrfiqgr/onWUl72KsY73m5TF+0eP5rhRe58xtBGGBaYyz5Hwpq 0CoY6RAohx67B1n+gbWxwwaJ57LI2/bo1IUBTt4EojlfA333OPXtW8i+2yss7Lx6LS+U OPgl7e1Vf0Skf63dXbKGIPuTxn2J8JiykStjuCh77qNs5Y3g75mlOcG6cq+0DArmzPW3 +o0t8DHM26GavVAehPj3WflsjGgz/t7OGJ0315b0I5S0+nsGv1aof2nASJdxP/IoIz2R t8bg== X-Gm-Message-State: AOJu0YwDF4NgFZh+v65FGkEYGTxXk1ml2o7jEU/X866T7m1wbItJ1ba0 cXj3IzQMQgkdYAMo4G/sRIYM73uTGMG+GXevnEF8IRuMo3EKxlSA8S6Quq8uFXx5QNmCQGdeK0d GbrcyoaBMxpvUW0X1EtnK9CvjELQ6CvWv2NgnSq/HVqJipAwdqaDhLUGkQX4nLfkPH63W6+/An5 WoYR1mDi/spM3o86mpCXi3vGCY+0jIl8xda6l+5w== X-Gm-Gg: Acq92OHKBzAOiAOEHP5VLkOCR5OoOamSXLZqpCtgP1jFtS6TLPtpkTrf079L/O3ZkmP pDLSoQNgGWyI7HNToW7Ppa8jEaongH6IQrZVLuf6tS0lfYovLmNFhDAofxghhW3qjYNDKtU/DUv q4Iz3sXiW+nbxYYBJC4iPAqolujuCeoshTej9AA4DyTTLJxmjmyekuLX6bliRBLt7aqFEwBk9Ki g5IPY1GVYMuegv27mpBybxjbQ5RrRaFERUTpByENejU82up5XaKDgvKbsefPEt+aw5jmbLHg9lq Q/52c8cydcuf+0UXHeZOqGCT24fPxesDsCgo/pWKLavwBx+3ECbRZXAguD32+/gum0UJGsBTbaa oL6wODhR9hDKYEuvIN1xKKrQ= X-Received: by 2002:a05:622a:1b09:b0:50e:631c:c390 with SMTP id d75a77b69052e-51795c5be37mr317023091cf.44.1781025922107; Tue, 09 Jun 2026 10:25:22 -0700 (PDT) X-Received: by 2002:a05:622a:1b09:b0:50e:631c:c390 with SMTP id d75a77b69052e-51795c5be37mr317022371cf.44.1781025921523; Tue, 09 Jun 2026 10:25:21 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 02/10] qdev: Export global_props() Date: Tue, 9 Jun 2026 13:25:06 -0400 Message-ID: <20260609172514.2037645-3-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@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.445, 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1781026056917158500 Content-Type: text/plain; charset="utf-8" Make it accessible from outside (to apply -global properties). Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- include/hw/core/qdev-properties.h | 2 ++ hw/core/qdev-properties.c | 2 +- rust/bindings/hwcore-sys/lib.rs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-prope= rties.h index eba5436e53..248bbcbba7 100644 --- a/include/hw/core/qdev-properties.h +++ b/include/hw/core/qdev-properties.h @@ -321,4 +321,6 @@ void qdev_prop_allow_set_link_before_realize(const Obje= ct *obj, const char *name, Object *val, Error **errp); =20 +GPtrArray *global_props(void); + #endif diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 34d7b26a73..1d531189ec 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -958,7 +958,7 @@ void qlist_append_link(QList *qlist, Object *obj) qlist_append_str(qlist, path); } =20 -static GPtrArray *global_props(void) +GPtrArray *global_props(void) { static GPtrArray *gp; =20 diff --git a/rust/bindings/hwcore-sys/lib.rs b/rust/bindings/hwcore-sys/lib= .rs index 8cef4a7961..85e71f5145 100644 --- a/rust/bindings/hwcore-sys/lib.rs +++ b/rust/bindings/hwcore-sys/lib.rs @@ -20,7 +20,7 @@ =20 use chardev_sys::Chardev; use common::Zeroable; -use glib_sys::GSList; +use glib_sys::{GPtrArray, GSList}; use migration_sys::VMStateDescription; use qom_sys::{ InterfaceClass, Object, ObjectClass, ObjectProperty, ObjectPropertyAcc= essor, --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781026048; cv=none; d=zohomail.com; s=zohoarc; b=Rop+a3bErFlQ1sw+AnOQ9R8O3q+jD9p0R4+yNA4dB70WUOi/AnlLaupAETFIVXVYPhBAZSvaZn0XlhD5Y7gDalX1eaZfxKYbCKtV8/RkPsE1sBHFygHOVCZfY1pAXhBh/OuPblhb9/jw86dYnB+W9yve+yrRqTo4S1ofkVwggu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781026048; 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=TAvDvHwNOpZMXGaEBVC9aqY/2Ki2d+eUzFoO5QqTfx8=; b=jYxrWnNdqKCHDQjR87VtGXwDwfsg0a4p94azl4AKCc0cBrHvrfgbXbKqysN2sZqktRA/y0Vpih5nZoCGooMaSOmZ/tIkEKv/9McHf14gwLQCzqpxOPG+KspdxFbGQE0i0qpIeRqEMVrHUAs+GQrpEo1vmqS+vMUlyYF+pGPoaNk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781026048950665.9219640844611; Tue, 9 Jun 2026 10:27:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D3-0007dt-03; Tue, 09 Jun 2026 13:25:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Ch-0007O7-Hp for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:33 -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 1wX0Cd-0001qh-Dm for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:30 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-217-Izz0TyI5Ngy-e6IiNuWBYQ-1; Tue, 09 Jun 2026 13:25:24 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-51776d4355cso161051981cf.0 for ; Tue, 09 Jun 2026 10:25:24 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025925; 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=TAvDvHwNOpZMXGaEBVC9aqY/2Ki2d+eUzFoO5QqTfx8=; b=XhNQvRTLSepVBGM2GfTwGIwzwqMlyhadlREq5mNG5z8iCBXe2/pyCI7mV3opvAjYl1XWDY iDEGqrkoXwZgtjaJ3E9uYG2WASkdv+A12mllFm53fISifl4Ae4KcnFpXqwjQsBF0u+bpsP 8NiDoGK1EuVlQ6FMREGfaNasKlQWD/A= X-MC-Unique: Izz0TyI5Ngy-e6IiNuWBYQ-1 X-Mimecast-MFC-AGG-ID: Izz0TyI5Ngy-e6IiNuWBYQ_1781025924 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025924; x=1781630724; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TAvDvHwNOpZMXGaEBVC9aqY/2Ki2d+eUzFoO5QqTfx8=; b=cCmjGo5Y5q15LpK/ZqA39f3uImeAaIxiBTZY8/oher2MSlA4RdHLgg44hYEPbJedC0 d2mXEkPIrj5LSWDXB/3u65cAgz4m1qK/TTZN2CjUC7/Dtdd33mdvTd20nMJbttneWySi drtRSsiOb5oJg4ff+ftChNZcXGBPh20r5mMNKmjiJ+pLCLqCzJob6xNjdCRICZZR9rXL qUT/xjzp4QQFl4/Usis2+cGm2Gx/NuHG8OnIs7pmVKY97DfiDiXwbwb63vKBR8EeNj74 X7UVl9ClO65QxZMTaUbv8MCBGqK3ajjEWjiPEzvBiE9E8qsirbFkdE/sJwzy61p91xEp k4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025924; x=1781630724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TAvDvHwNOpZMXGaEBVC9aqY/2Ki2d+eUzFoO5QqTfx8=; b=GlYZTq6d3AwOWj/9ApphmivNsUyfHTHpKcrRVTAr2MCZWizqctSf75y8ektYwrMEzw 94zoL+dsROn4EwzufdHQOjX34VL1o7o1TUirg1nf1nFLjqWjkjeJ3fsz514DiubVSrcJ YBcWz4oNOHDBox5BJ5HRFIS1yLUREbIVWSVXkUEMgXj7jfmTsYbW2oUAYyQ+ITVZd2cr 3fBSpBs1TwLqWlVhayhUwLUMT+D1I9C+iUTeppUWtxhY5xnuyxv9LYAMBi3sKFfHrA1r cNERCAO31OEMwD18h2e75bc58Yz4GrbOmsmbddUz9Pq1zUH9D2nFH2ZKtlpgWg+mYd5V +IGg== X-Gm-Message-State: AOJu0YxSnyjTACqra78bAyDBn5TlPcCZf6xSVdxlm8bgUUgYdvdwZXJT 1DXsuRMH7YURpzddNRNQ+pSrn9lJLalQqx0sfq4Y2o4pWvlcuH2+SqVxTzSR0ZKv4wmlxyvSs4Q WmcfegcLu2bSKh4tAIVCH9NnxV97Q6DdBVrdyr/WnXK5S+8dRLwIZG9r+YrqQ4h/+ypTiIL4xLT 0R3x1ffUClgDiEnKjyEFcWiJmMwcUK4jGKYuIAgg== X-Gm-Gg: Acq92OGoEZTleq0Y1zB7UaLGJlw9pNLxDIqIupF42LSoSM2soe3PthufflFDYv1PHeq y2QKU3al0ANpWANEWKQ/M31ke789amkqUB6vZ3wRgyh5lvIibj9cuzVYzg8SYtYw88KX4CPPmEa mFZF90Vh1o4ccLt1hZMl/MxkVeXqP1TFU7b6ySGt2ReLEwjNphQTwTjJfwa+gz+2NlJnuI4h3xb vX6FVQYrfFk71rEhqalLad9PRTH0+tdyFEcdl1GE9UmFVFsJmtlc6z7KSIoJD/52KmbT8ZVlvsd 1MrTKnJ6UoT4II/F6wqnhu6HuMZM3grEe7iEZiWQYK10uhZ1HyhDDJEZIkQhkvAtt/jX/j3oSG+ oi4mIdtogg0OSGriLzIFz/Kk= X-Received: by 2002:a05:622a:a593:b0:517:7871:693f with SMTP id d75a77b69052e-51798672991mr221134961cf.8.1781025923976; Tue, 09 Jun 2026 10:25:23 -0700 (PDT) X-Received: by 2002:a05:622a:a593:b0:517:7871:693f with SMTP id d75a77b69052e-51798672991mr221134161cf.8.1781025923234; Tue, 09 Jun 2026 10:25:23 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 03/10] qdev: Introduce DEFINE_PROP_*_NODEFAULT for bool/uint32 Date: Tue, 9 Jun 2026 13:25:07 -0400 Message-ID: <20260609172514.2037645-4-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@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.445, 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1781026051506154100 Content-Type: text/plain; charset="utf-8" Introduce two macros that will be used in follow up patch to create qdev bool or uint32 properties without a default value. Do not introduce the rest until they can be used. Signed-off-by: Peter Xu --- include/hw/core/qdev-properties.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-prope= rties.h index 248bbcbba7..43878d1f9e 100644 --- a/include/hw/core/qdev-properties.h +++ b/include/hw/core/qdev-properties.h @@ -124,6 +124,9 @@ extern const PropertyInfo qdev_prop_link; .set_default =3D true, \ .defval.u =3D (bool)_defval) =20 +#define DEFINE_PROP_BOOL_NODEFAULT(_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool) + /** * The DEFINE_PROP_UINT64_CHECKMASK macro checks a user-supplied value * against corresponding bitmask, rejects the value if it violates. @@ -201,6 +204,8 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) +#define DEFINE_PROP_UINT32_NODEFAULT(_n, _s, _f) \ + DEFINE_PROP_UNSIGNED_NODEFAULT(_n, _s, _f, qdev_prop_uint32, uint32_t) #define DEFINE_PROP_INT32(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t) #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781026038; cv=none; d=zohomail.com; s=zohoarc; b=CYjtZ4q6C4eFcTKkQBMQYht6KrRO0WgfNTFvsWwLuQIZBPUXKQ849YNvRkyPZbcLImz3qUdVix/YtzAjsnCgLQp9T0vR4aydUc0yNfUPgWKljAP2/DXCSZDYJchyW5KEzfs0a2J+2cszzUBBORhZiGAEyWD6ZzBMf2dwEY0g/lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781026038; h=Content-Type: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=3NdlNtbeLa0/ps13OdYmmm+9iFxk0+Y/xOAdI1YEzAQ=; b=XjkOQ2K/G7gql3Sj5U1Tv9uoZgT70dSEFjb/JmwZ1Jb4ufJPNyCqCqhyf972n7WMWs1G/5Q/81cjySC7t68BRSqCTFiCCgEszcV0wMZmpKdr+XgP3tNYh/l0yps/R6S9f/GfuBbhtam0PYRgnT/Uycy8RqkVz8ukm3iK9Wog7c4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781026038624410.6352857410444; Tue, 9 Jun 2026 10:27:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D4-0007g5-Dl; Tue, 09 Jun 2026 13:25:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Ch-0007O9-Ht for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:33 -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 1wX0Cf-0001rJ-27 for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:30 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-ThDCM-r_P1K9eKTYlh-_lg-1; Tue, 09 Jun 2026 13:25:26 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-517d766e05aso15457421cf.0 for ; Tue, 09 Jun 2026 10:25:26 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3NdlNtbeLa0/ps13OdYmmm+9iFxk0+Y/xOAdI1YEzAQ=; b=Tlk78389EI7y3M8hGShRQ8f5OiGvN/OyWNl2kOh6BWu71ML77PZnvTByoSNFDi+fEyxN8d 6YikEcaRbdGvamkdacX1Ril3tV6EHcP0N7mfbAMxgKRv61TDeWUveiKpIGDPWYGG1TsxH+ qIku7F9wdj2qiTSi3LYoxm2WX+5CdhQ= X-MC-Unique: ThDCM-r_P1K9eKTYlh-_lg-1 X-Mimecast-MFC-AGG-ID: ThDCM-r_P1K9eKTYlh-_lg_1781025925 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025925; x=1781630725; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3NdlNtbeLa0/ps13OdYmmm+9iFxk0+Y/xOAdI1YEzAQ=; b=hBm/GjCD3p+7KkM6V2DemMWlGq8mTT5UG1DZWn7M73qb98t2px4K04SPV/KSRvk1Lp 9ODL9Hj9zI186KESUdUZcHyyRaD1K31TEFCkcJRZMzfZpCjjptDh5Cd1TV+Op6JWsBMC /YTPL49pCAXjHJjogHevmg7u+76Tee6SChb1Yutn6RBgHZHGFcjNrD1G2QiPEDH/SGeI WNx+pkqOprWHhQr0MkbyktZsUARYbltyh25dXid7BnexwNfzzPeNk/GmVpEyr8UTOlbx EBV03Z2od6QMbaRojbcis3uWrdFrrDsBUT17PPRPUcofoZr93nNwd1Zhj4qAfCO4hdnB jUGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025925; x=1781630725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3NdlNtbeLa0/ps13OdYmmm+9iFxk0+Y/xOAdI1YEzAQ=; b=be+YPK3Ib8L5geg18wLrGtdHTsTIaIoAPs4WZJbFedS3oEjENIgREsZPUIyPlqRVgC kiPfl9Tx8dOeMjBl12dpoA8cQ18xddbjAy56zN9v7DpkfdOlgMgIT2XE0iq98AMwl/pj Er7R5jzRQkcn66Il3g/Wmdl6OdiVFTozkckmx+UmzqZhcahUWaQFLHz2pn1Uwz1puXnu OfVU/UFDxi7HMVsbFyK4x6IAOg1JHVucKD5VRrRa+6qmmlYWzb+pScSdQtKmPe837YHX cGt0Iw65R2oz0qGT1FRDRJCoyfma0pPq4u/5sBYDdZNmT/MttabaSd+zI0p/WmCpYOUA JlgQ== X-Gm-Message-State: AOJu0Yw7v3lvZVOGBbCfaFAukBKE04a6InUZpsbXaNBkrBFLSUqdQ2mZ CIbr2cFhPhbMonFfEld/VTbihrrWqVpRK9BbSeQpurZUYXM0RZoyXYK1UIObSHRSaTSYFFEo/bi /kDLQenW7Xb2iDyDMV83X6OT5NCnoShTuLfJEZTDmZVt+XYdWUqcOFRZcXmhoKTvAJI2rrZ6tRv ie3PTTryCfscQw7DL548s1a7wcWJ6OC+27lqEThw== X-Gm-Gg: Acq92OFunI9AJi4j2jxi/y3pTlxn1m9vNWOwX0JPcBE1UFGv4tEa2pN9T2/yQ9dzi2j 6jyarDnXVgzgGxb9U9jHjNjetwXEJA+LqS3shhEwFXU0HNRbqQ4/Kj988mVouZfP1SZ40SIBuT+ S8GxaUq6vIAoReg7FjSyVDViXx0fxx3HQetOXxeInom4fZK6h4Mr6nkFrGfe7OoeTQi/FrcuROA aMJBE9Dp9LcKJVENp8C6xXYwdcdxNL2BxpZBHJdP2TCYswuG9j9eARXJoQOaHqAB0MS1jU6jVI4 +Pm4WF0IiFmHkSY7vvYMEXf2MjcLkNKLVMzDUJ+UYhnWCVOSyGDlfWO/jG/CjKeI8z61v6N9zFa xOJjtUWxPg3l4lPHbmVxPcus= X-Received: by 2002:a05:622a:5518:b0:50b:3429:a10b with SMTP id d75a77b69052e-517986d4a6emr218254851cf.12.1781025925478; Tue, 09 Jun 2026 10:25:25 -0700 (PDT) X-Received: by 2002:a05:622a:5518:b0:50b:3429:a10b with SMTP id d75a77b69052e-517986d4a6emr218254171cf.12.1781025924798; Tue, 09 Jun 2026 10:25:24 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland , Marc Zyngier Subject: [PATCH v2 04/10] hw/arm: Use nodefault version of qdev props when not needed Date: Tue, 9 Jun 2026 13:25:08 -0400 Message-ID: <20260609172514.2037645-5-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@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.445, 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, SPF_HELO_PASS=-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: qemu development 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: 1781026041773154100 We're going to introduce defvars for object properties just like qdev-props defvars. It work slightly differently in that props can be added in instance_init() with default values, then the default values can only apply after instance_init() completes. It means any explicit set of property values within instance_init() when used together with object property's default value (or qdev-prop, which builts the default value framework on top) will stop working. This patch touches two of such use cases where the device may add qdev properties with a default value first, then quickly set another value within instance_init(). These are the only two outliers I found across the QEMU tree that do it this way. Switch them to use qdev-prop's NODEFAULT APIs, and always initialize the values manually. Example 1: bcm283x_base_init() adds qdev prop bcm2836_enabled_cores_property with a default value 0, then it immediately set another value inside the same instance_init() hook. Example 2: aarch64_add_pauth_properties() adds qdev prop arm_cpu_pauth_property, but then it will immediately update the same field (cpu->prop_pauth) conditionally when hwaccel_enabled()=3D=3Dtrue. Without the change, some arm test may fail (boot-serial-test) after introducing object property's default value framework, because devices' values will be overwritten by the properties' later. OTOH, this patch itself should introduce no functional change. Cc: Marc Zyngier Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Xu --- hw/arm/bcm2836.c | 3 ++- target/arm/cpu64.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index f4ecea908b..9e4d30c99c 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -19,7 +19,8 @@ #include "target/arm/gtimer.h" =20 static const Property bcm2836_enabled_cores_property =3D - DEFINE_PROP_UINT32("enabled-cpus", BCM283XBaseState, enabled_cpus, 0); + DEFINE_PROP_UINT32_NODEFAULT( + "enabled-cpus", BCM283XBaseState, enabled_cpus); =20 static void bcm283x_base_init(Object *obj) { diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 2816735577..a3a014a994 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -635,7 +635,7 @@ void aarch64_cpu_pauth_finalize(ARMCPU *cpu, Error **er= rp) } =20 static const Property arm_cpu_pauth_property =3D - DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true); + DEFINE_PROP_BOOL_NODEFAULT("pauth", ARMCPU, prop_pauth); static const Property arm_cpu_pauth_impdef_property =3D DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); static const Property arm_cpu_pauth_qarma3_property =3D @@ -660,6 +660,7 @@ void aarch64_add_pauth_properties(Object *obj) */ cpu->prop_pauth =3D cpu_isar_feature(aa64_pauth, cpu); } else { + cpu->prop_pauth =3D true; qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_proper= ty); qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_proper= ty); qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma5_proper= ty); --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781026068; cv=none; d=zohomail.com; s=zohoarc; b=Vxj0um5I9M7INRC7rxUU58GfvWyDYpME1T0kewLXOSOmhs3K3egtlyk7+HG66PDbF27/fbauMwlqL5TW6ge/AFhURluB9oM1VDglbU5qTmgmYd7wLYVVWrP7L1qM/3rECuSpzEqe5N20zsNadvcQC24M2rPuUbhBJjBeXwrhKBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781026068; 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=+RIIsjklWbcutayG6SOK/nSI0TGaNMIJ0fYUtITssro=; b=YditUFwn62jSmuNhPBWuoZg4xAvBQ71EQF/qoeQkRanPV58s7itwG460YaiRHEYSnLkwWx0WoxNuJyt6+gZj+Kvqstnq94Jac21lJeg2wDkVs5GHnUxOS3CO+IB1MiaUqLo+4xNqUwpdFb2U3PdWYjcVHQXA48AOmdWHXgudjVs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781026068523483.9194571219673; Tue, 9 Jun 2026 10:27:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D3-0007ei-Qz; Tue, 09 Jun 2026 13:25:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Cn-0007WL-C9 for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25: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 1wX0Ch-0001rr-6t for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:35 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-6QdCOea9MDWMIPA4fy0Dqw-1; Tue, 09 Jun 2026 13:25:28 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-517615db531so155818581cf.1 for ; Tue, 09 Jun 2026 10:25:28 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025929; 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=+RIIsjklWbcutayG6SOK/nSI0TGaNMIJ0fYUtITssro=; b=RjcvIJ0W5gENpcMLmHupCaUTcbiPaWKn4Q5JF8gx7EMGnouNz6bSXMqYpaQWDe+CpAO+b4 6xsOo6T+//8hvkBrxBX5AbrG8O4HMMZA4MqOjfrttZ6JFhw82RzekUjDlqTyeyK+xIrqY3 FhknczvEd/KqJKQlweSA1SHhxlfMuZE= X-MC-Unique: 6QdCOea9MDWMIPA4fy0Dqw-1 X-Mimecast-MFC-AGG-ID: 6QdCOea9MDWMIPA4fy0Dqw_1781025928 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025928; x=1781630728; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+RIIsjklWbcutayG6SOK/nSI0TGaNMIJ0fYUtITssro=; b=ZR7tPvI+8WqwWzUkRSlaYUJf9Wig8GKff9UK5D1vdHIhVTTtYoYebtWrbtiRHUXKC1 zqQ3gNGb6TPVP/bSu8QWJxBd0kPvoe34eLqY353cf7GVdwI9OO2NAp9X1gCG6P+KhuXM wfKfKah3kHhcBGiw+UrJ/OeJ0sgyBz6CJJYz7TDvfaU2IAG78jeKGQRTg3luea33VdQg d5hjNYliiQKszj0l+xiam+dbBXX1hiQrC3YbNtrwPo3yp0uuJFhIMESA6l0Tgpg+Bo17 Uo0v5LFE96UZ8vNrWT8FXgvpggcWiFXC56sO+elh987XYGSWz+xVkib5DhiLLRjMLF9r pLvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025928; x=1781630728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+RIIsjklWbcutayG6SOK/nSI0TGaNMIJ0fYUtITssro=; b=qhVZifiBeV/lxlYQXW4Ex490jHIWDV5LW9dY4IbN0NDzAa1WeukDimSV/IvBdiGujv CrePZ1BOdyhfLBSQUnU4M1d+jqUfvzki0IougLDvsLrY0LTujIbxQ0WGeMj8DLYVU7ZG Kc183a0Vc2SfvOU6BjOVHWhfj99L8/hS2/xI71lqOM/9d8IfycLHotbQtZiIisK4lTiZ DEB2YR3KqjVuIYGIA+1ptdrjm/7LFwuIuDgBL1zRHJe91LwqUkpetARiP+IrG5esxJDA b/Um/7yYXRJQNn3m/NrTFlFOdNNVm73ZB9ggZRIN6ov1E6njbjisnF8uMLE3vvl3wolS StsQ== X-Gm-Message-State: AOJu0YyCIbBvI2YKrfyaU4P/msOToRIkzuHXv5ubWvadZr3lG6aGRQUg vAYRFS/Oq3T0Umqf95atTu8At2Ow5CuEWzrMwUdOy+atz7FkVDQgk2INuFlV9xY9rP5gHoOFreK 3ZN5ez7n/1GIsmuphKEpnwnAxnkJBngHHxrZpFsVytUnC3FgvMcKcKgPy3WEVPMCYtEjFCAs8bu 5WlldqPAzHmbuy0V60ApLxlX42+cTmxq/ueGP+VQ== X-Gm-Gg: Acq92OGZSCuXEEck7WSDSZmtTDl44EM9ehIaLGdzbHAWy9uLDmkRxh1D7Wv4QGEBhr5 aqSbHcg79eebuKLlu4TZEr2xLBISt8B8smdOYYt1z5HKPJv4EBBKWUeiS2BSyzcbp+7KimUAQ78 2YP6Dl3diXLcdw+M7vsrzx3rILhiUC3u+IhoDx8WewmCSIY2CkwNjkQdhQuBsmSKHhLXSW/N8nN eg+pdsnQ5Sroww88RvJa+JpXLf/x8fBsMd7ApoluTym/RIHnm/lE4pNAFxDdI7LhgWMQr2DHLIX OrWFbYYIDXe8eIpZA/jO8k4ZhQ4OeWQQKh0yPFHSfm+T4iOtme3oIz4zVOGptn79S2tqt19s5pP cb6GO4hr6upcioN6uwde+TvA= X-Received: by 2002:a05:622a:1808:b0:517:96f0:5658 with SMTP id d75a77b69052e-51796f06eadmr297342271cf.14.1781025927452; Tue, 09 Jun 2026 10:25:27 -0700 (PDT) X-Received: by 2002:a05:622a:1808:b0:517:96f0:5658 with SMTP id d75a77b69052e-51796f06eadmr297341161cf.14.1781025926446; Tue, 09 Jun 2026 10:25:26 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 05/10] qom: Create object-property-ptr.[ch] Date: Tue, 9 Jun 2026 13:25:09 -0400 Message-ID: <20260609172514.2037645-6-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@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.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1781026069149158500 Content-Type: text/plain; charset="utf-8" Create object-property-ptr.[ch] files to include all the helpers for object_property_add*_ptr(). These set of helpers are handy because they look extremely familiar with qdev-properties, allowing the caller to provide a pointer and it will manage all the setters and getters. The follow up patches may introduce more of such helpers. Since object.c has been already too big, split that part out. No functional change intended. Signed-off-by: Peter Xu --- include/qom/object-property-ptr.h | 103 +++++++++++++ include/qom/object.h | 99 +----------- qom/object-property-ptr.c | 248 ++++++++++++++++++++++++++++++ qom/object.c | 240 ----------------------------- qom/meson.build | 1 + 5 files changed, 358 insertions(+), 333 deletions(-) create mode 100644 include/qom/object-property-ptr.h create mode 100644 qom/object-property-ptr.c diff --git a/include/qom/object-property-ptr.h b/include/qom/object-propert= y-ptr.h new file mode 100644 index 0000000000..6066c377fb --- /dev/null +++ b/include/qom/object-property-ptr.h @@ -0,0 +1,103 @@ +/* + * Object property helpers to operate on a pointer. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_OBJECT_PROPERTY_PTR_H +#define QEMU_OBJECT_PROPERTY_PTR_H + +typedef enum { + /* Automatically add a getter to the property */ + OBJ_PROP_FLAG_READ =3D 1 << 0, + /* Automatically add a setter to the property */ + OBJ_PROP_FLAG_WRITE =3D 1 << 1, + /* Automatically add a getter and a setter to the property */ + OBJ_PROP_FLAG_READWRITE =3D (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE), +} ObjectPropertyFlags; + +/** + * object_property_add_uint8_ptr: + * @obj: the object to add a property to + * @name: the name of the property + * @v: pointer to value + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add an integer property in memory. This function will add a + * property of type 'uint8'. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *nam= e, + const uint8_t *v, + ObjectPropertyFlags flags); + +ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass, + const char *name, + const uint8_t *v, + ObjectPropertyFlags flags); + +/** + * object_property_add_uint16_ptr: + * @obj: the object to add a property to + * @name: the name of the property + * @v: pointer to value + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add an integer property in memory. This function will add a + * property of type 'uint16'. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *na= me, + const uint16_t *v, + ObjectPropertyFlags flags); + +ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass, + const char *name, + const uint16_t *v, + ObjectPropertyFlags flags); + +/** + * object_property_add_uint32_ptr: + * @obj: the object to add a property to + * @name: the name of the property + * @v: pointer to value + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add an integer property in memory. This function will add a + * property of type 'uint32'. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *na= me, + const uint32_t *v, + ObjectPropertyFlags flags); + +ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass, + const char *name, + const uint32_t *v, + ObjectPropertyFlags flags); + +/** + * object_property_add_uint64_ptr: + * @obj: the object to add a property to + * @name: the name of the property + * @v: pointer to value + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add an integer property in memory. This function will add a + * property of type 'uint64'. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *na= me, + const uint64_t *v, + ObjectPropertyFlags flags); + +ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass, + const char *name, + const uint64_t *v, + ObjectPropertyFlags flags); + +#endif diff --git a/include/qom/object.h b/include/qom/object.h index 11f55613fc..6ea569d580 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1931,99 +1931,6 @@ ObjectProperty *object_class_property_add_tm(ObjectC= lass *klass, const char *name, void (*get)(Object *, struct tm *, Error **)); =20 -typedef enum { - /* Automatically add a getter to the property */ - OBJ_PROP_FLAG_READ =3D 1 << 0, - /* Automatically add a setter to the property */ - OBJ_PROP_FLAG_WRITE =3D 1 << 1, - /* Automatically add a getter and a setter to the property */ - OBJ_PROP_FLAG_READWRITE =3D (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE), -} ObjectPropertyFlags; - -/** - * object_property_add_uint8_ptr: - * @obj: the object to add a property to - * @name: the name of the property - * @v: pointer to value - * @flags: bitwise-or'd ObjectPropertyFlags - * - * Add an integer property in memory. This function will add a - * property of type 'uint8'. - * - * Returns: The newly added property on success, or %NULL on failure. - */ -ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *nam= e, - const uint8_t *v, - ObjectPropertyFlags flags); - -ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass, - const char *name, - const uint8_t *v, - ObjectPropertyFlags flags); - -/** - * object_property_add_uint16_ptr: - * @obj: the object to add a property to - * @name: the name of the property - * @v: pointer to value - * @flags: bitwise-or'd ObjectPropertyFlags - * - * Add an integer property in memory. This function will add a - * property of type 'uint16'. - * - * Returns: The newly added property on success, or %NULL on failure. - */ -ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *na= me, - const uint16_t *v, - ObjectPropertyFlags flags); - -ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass, - const char *name, - const uint16_t *v, - ObjectPropertyFlags flags); - -/** - * object_property_add_uint32_ptr: - * @obj: the object to add a property to - * @name: the name of the property - * @v: pointer to value - * @flags: bitwise-or'd ObjectPropertyFlags - * - * Add an integer property in memory. This function will add a - * property of type 'uint32'. - * - * Returns: The newly added property on success, or %NULL on failure. - */ -ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *na= me, - const uint32_t *v, - ObjectPropertyFlags flags); - -ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass, - const char *name, - const uint32_t *v, - ObjectPropertyFlags flags); - -/** - * object_property_add_uint64_ptr: - * @obj: the object to add a property to - * @name: the name of the property - * @v: pointer to value - * @flags: bitwise-or'd ObjectPropertyFlags - * - * Add an integer property in memory. This function will add a - * property of type 'uint64'. - * - * Returns: The newly added property on success, or %NULL on failure. - */ -ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *na= me, - const uint64_t *v, - ObjectPropertyFlags flags); - -ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass, - const char *name, - const uint64_t *v, - ObjectPropertyFlags flags); - /** * object_property_add_alias: * @obj: the object to add a property to @@ -2141,4 +2048,10 @@ char *object_property_help(const char *name, const c= har *type, =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref) =20 +/* + * Object property ptr helpers cannot be included at the beginning of the + * file, because it depends on QOM definitions in current header. + */ +#include "qom/object-property-ptr.h" + #endif diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c new file mode 100644 index 0000000000..02c01ed7f0 --- /dev/null +++ b/qom/object-property-ptr.c @@ -0,0 +1,248 @@ +/* + * Object property helpers to operate on a pointer. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "qom/object.h" +#include "qapi/visitor.h" + +static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *na= me, + void *opaque, Error **errp) +{ + uint8_t value =3D *(uint8_t *)opaque; + visit_type_uint8(v, name, &value, errp); +} + +static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *na= me, + void *opaque, Error **errp) +{ + uint8_t *field =3D opaque; + uint8_t value; + + if (!visit_type_uint8(v, name, &value, errp)) { + return; + } + + *field =3D value; +} + +static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + uint16_t value =3D *(uint16_t *)opaque; + visit_type_uint16(v, name, &value, errp); +} + +static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + uint16_t *field =3D opaque; + uint16_t value; + + if (!visit_type_uint16(v, name, &value, errp)) { + return; + } + + *field =3D value; +} + +static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + uint32_t value =3D *(uint32_t *)opaque; + visit_type_uint32(v, name, &value, errp); +} + +static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + uint32_t *field =3D opaque; + uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { + return; + } + + *field =3D value; +} + +static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + uint64_t value =3D *(uint64_t *)opaque; + visit_type_uint64(v, name, &value, errp); +} + +static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + uint64_t *field =3D opaque; + uint64_t value; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + *field =3D value; +} + +ObjectProperty * +object_property_add_uint8_ptr(Object *obj, const char *name, + const uint8_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint8_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint8_ptr; + } + + return object_property_add(obj, name, "uint8", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, + const uint8_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint8_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint8_ptr; + } + + return object_class_property_add(klass, name, "uint8", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_property_add_uint16_ptr(Object *obj, const char *name, + const uint16_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint16_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint16_ptr; + } + + return object_property_add(obj, name, "uint16", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, + const uint16_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint16_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint16_ptr; + } + + return object_class_property_add(klass, name, "uint16", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_property_add_uint32_ptr(Object *obj, const char *name, + const uint32_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint32_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint32_ptr; + } + + return object_property_add(obj, name, "uint32", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, + const uint32_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint32_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint32_ptr; + } + + return object_class_property_add(klass, name, "uint32", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_property_add_uint64_ptr(Object *obj, const char *name, + const uint64_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint64_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint64_ptr; + } + + return object_property_add(obj, name, "uint64", + getter, setter, NULL, (void *)v); +} + +ObjectProperty * +object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, + const uint64_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_uint64_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_uint64_ptr; + } + + return object_class_property_add(klass, name, "uint64", + getter, setter, NULL, (void *)v); +} diff --git a/qom/object.c b/qom/object.c index 0ac201de4c..fc738549dc 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2673,246 +2673,6 @@ static char *object_get_type(Object *obj, Error **e= rrp) return g_strdup(object_get_typename(obj)); } =20 -static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *na= me, - void *opaque, Error **errp) -{ - uint8_t value =3D *(uint8_t *)opaque; - visit_type_uint8(v, name, &value, errp); -} - -static void property_set_uint8_ptr(Object *obj, Visitor *v, const char *na= me, - void *opaque, Error **errp) -{ - uint8_t *field =3D opaque; - uint8_t value; - - if (!visit_type_uint8(v, name, &value, errp)) { - return; - } - - *field =3D value; -} - -static void property_get_uint16_ptr(Object *obj, Visitor *v, const char *n= ame, - void *opaque, Error **errp) -{ - uint16_t value =3D *(uint16_t *)opaque; - visit_type_uint16(v, name, &value, errp); -} - -static void property_set_uint16_ptr(Object *obj, Visitor *v, const char *n= ame, - void *opaque, Error **errp) -{ - uint16_t *field =3D opaque; - uint16_t value; - - if (!visit_type_uint16(v, name, &value, errp)) { - return; - } - - *field =3D value; -} - -static void property_get_uint32_ptr(Object *obj, Visitor *v, const char *n= ame, - void *opaque, Error **errp) -{ - uint32_t value =3D *(uint32_t *)opaque; - visit_type_uint32(v, name, &value, errp); -} - -static void property_set_uint32_ptr(Object *obj, Visitor *v, const char *n= ame, - void *opaque, Error **errp) -{ - uint32_t *field =3D opaque; - uint32_t value; - - if (!visit_type_uint32(v, name, &value, errp)) { - return; - } - - *field =3D value; -} - -static void property_get_uint64_ptr(Object *obj, Visitor *v, const char *n= ame, - void *opaque, Error **errp) -{ - uint64_t value =3D *(uint64_t *)opaque; - visit_type_uint64(v, name, &value, errp); -} - -static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *n= ame, - void *opaque, Error **errp) -{ - uint64_t *field =3D opaque; - uint64_t value; - - if (!visit_type_uint64(v, name, &value, errp)) { - return; - } - - *field =3D value; -} - -ObjectProperty * -object_property_add_uint8_ptr(Object *obj, const char *name, - const uint8_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint8_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint8_ptr; - } - - return object_property_add(obj, name, "uint8", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, - const uint8_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint8_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint8_ptr; - } - - return object_class_property_add(klass, name, "uint8", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_property_add_uint16_ptr(Object *obj, const char *name, - const uint16_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint16_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint16_ptr; - } - - return object_property_add(obj, name, "uint16", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, - const uint16_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint16_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint16_ptr; - } - - return object_class_property_add(klass, name, "uint16", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_property_add_uint32_ptr(Object *obj, const char *name, - const uint32_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint32_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint32_ptr; - } - - return object_property_add(obj, name, "uint32", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, - const uint32_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint32_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint32_ptr; - } - - return object_class_property_add(klass, name, "uint32", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_property_add_uint64_ptr(Object *obj, const char *name, - const uint64_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint64_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint64_ptr; - } - - return object_property_add(obj, name, "uint64", - getter, setter, NULL, (void *)v); -} - -ObjectProperty * -object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, - const uint64_t *v, - ObjectPropertyFlags flags) -{ - ObjectPropertyAccessor *getter =3D NULL; - ObjectPropertyAccessor *setter =3D NULL; - - if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { - getter =3D property_get_uint64_ptr; - } - - if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { - setter =3D property_set_uint64_ptr; - } - - return object_class_property_add(klass, name, "uint64", - getter, setter, NULL, (void *)v); -} - typedef struct { Object *target_obj; char *target_name; diff --git a/qom/meson.build b/qom/meson.build index bd6f4aadd7..2c746aaa9c 100644 --- a/qom/meson.build +++ b/qom/meson.build @@ -3,6 +3,7 @@ qom_ss.add(files( 'container.c', 'object.c', 'object_interfaces.c', + 'object-property-ptr.c', 'qom-qobject.c', )) if have_system --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781025975; cv=none; d=zohomail.com; s=zohoarc; b=KrSokS2aHvbZMAXr1+TqRfR2NAGvUFC3VM2sg950qx6WGXxYb1RtSfda0VYEmvq0kVU20dk1rjuKxuRqRnX34Q+/I4x1HzQ4Doco0ektloUtMuwFxL/kxBui5oS4h/gmoMdAs6REjoODBppaSF0KieZBWuXr8rBHqOSHALwqVGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781025975; 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=jwLp2AvTjapZW+/ErJH1EShXN1MPuQYDgyT1L5wHR6o=; b=lwYGQHdYd7sEzqocagKh5jD9d2fy1v/2fKNQVbuCHTk09Jper3w9W6IC5jOVWRnVQ32YqJHlcSdk7MPRhiwEdBgyAYET07bhYEYtwtgjm26G/DPRafQHWIh4QSIr9IQFaQHRoEk6c0VHmMNLmxZ1LI7ku09dykgbY8Adkd2PBf4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781025975946369.9065843994257; Tue, 9 Jun 2026 10:26:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D1-0007dr-UD; Tue, 09 Jun 2026 13:25:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Cr-0007Xf-F6 for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:43 -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 1wX0Cn-0001uN-3R for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:40 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-m9XVQS3JPBu5BhyWvEKSwA-1; Tue, 09 Jun 2026 13:25:34 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8cceb5a9686so70703076d6.0 for ; Tue, 09 Jun 2026 10:25:34 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025935; 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=jwLp2AvTjapZW+/ErJH1EShXN1MPuQYDgyT1L5wHR6o=; b=iZNdObHyQZPrVYzuCJR+k9MtDo4r3GkAUCabumDH2zNw8jB7GbplAXjVwA0VbPIDKuVEAk qvBXTl443XmAhG439GZgz3T2D4baqsWOCKcR+SkQsKSKOnczxSCrYLwE0k6aobtT15uxMX w07k1xyl5nNiMvJoxzKpmmUjKmMs178= X-MC-Unique: m9XVQS3JPBu5BhyWvEKSwA-1 X-Mimecast-MFC-AGG-ID: m9XVQS3JPBu5BhyWvEKSwA_1781025933 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025933; x=1781630733; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jwLp2AvTjapZW+/ErJH1EShXN1MPuQYDgyT1L5wHR6o=; b=PlgwPHrnURK7QiaTwQwLu/kkNTvER11jsM7x3cHzd10vdl71CLv/+T6RoHLP7/1wde MlMMIBSzogBDXleJ3TKmRyC4bh9P1B4hXTnwcm+zHGQtI4NUBFz5DrofeNBuE3quknGQ T0gdypUDs0B6jpiN9z4duUPC8DxoHYlNYFE/B8t358gM9dyZ2EzYewWfXX3xBvj/UhnL UxYV2Cv/Qd8I8ifKqCMqPCP4npOjm/kIKBOT+8SWWeHZ+JZfziQC3QGdDhp+EAaJdtxC OCyE+DEFNqoh8PAmtJhIcX4Oav6qzKK/PytvbVya7qAdOhk4rCsZ4gwNiWzNAwl8BJmz eYHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025933; x=1781630733; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jwLp2AvTjapZW+/ErJH1EShXN1MPuQYDgyT1L5wHR6o=; b=Md2CfvNcXw8A8iF+7Da+w+HiBp25EfKvWkJHyP4CSAoX9gj3sc65x/1tIssKYoUBLv 5+BAMnzro1ZG7mwM6ldGrvMjt5mTLDsvQTjQFdA2wG8lv8TV85apMmtO0HSbxTOfQfxK LQ8lkjAWC0Bek/LCQSkO/slSAep7x+9y67ih2kXGHGy/HIUo8LaxSh/HQlC4xVQbE2QS M4YlvOYeRjPFl0BGKxsmIXmD1PTRaQgrQ2dKvrK5A0MWL08hNZutVgSoGO7H8ByA7HIy uEM8SSlYgJXwnSrhbGNA1Wt2ZFYiyzg2zBOErOBg1N/vVMZuC+QsZb2lYQg2FwtPp2ra gT0g== X-Gm-Message-State: AOJu0Yzubw/X1emMmPjtZbpIvStr9k9CUQr92VFWsNO7oiqrIYXTZyox d033nZ7j/Cv9E59RlRBGShm7Zf/atqgyoIOd3AKyAWtH2HFPILEPU2zWaj0xWm1spIitqpp67aj /j0FmJ616VpBhfsFE8/42Z98iuOHnex/gtExbtG9p0IghjKY8hDI0aQPPWsBrd7odUjAUNyZPeD CKNPtJxSDTHTVkUqdv9wTOscPlRjS6ycQRST5bsA== X-Gm-Gg: Acq92OFLVE6wJQQ3dZ9o7ICQ9vAH/L5k1zkf3Iqpf1iV64sgyFre2CSsFTxrczvczHl fyVd8zVUUi3vx2kcd5jlch/+dfpKy12kcFPw06Za3SEzCeC6lR9rvYcHvHE6OnanrMg7YrnBrz0 83dp3WaXmzbc4Xx5VAdIi209AN3GKGw8uwlg2rxFpgpTPoQF06ZSTfaTlaErYQ/7SJo608lmcbv voCUeW2idc8FtIWhHqkuoY97SDxvyWLQKRX77mTf29eVwHE/3QySLUXkvCEYSIsRp11s7w0dTXX XCyvN05v6YCBPgPV5GvYkxvId8q1Wd9NwbTqI2M/7+Jd5rcNLpmBmeKNTE49RhRZBQdTHykL2pk fFi1p/wwyCOLW41W6RGZsae0= X-Received: by 2002:a05:622a:460d:b0:517:a9ef:ce23 with SMTP id d75a77b69052e-517a9efd0c9mr162127391cf.16.1781025933335; Tue, 09 Jun 2026 10:25:33 -0700 (PDT) X-Received: by 2002:a05:622a:460d:b0:517:a9ef:ce23 with SMTP id d75a77b69052e-517a9efd0c9mr162126561cf.16.1781025932578; Tue, 09 Jun 2026 10:25:32 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 06/10] qom: Add object_property_add_bool_ptr() Date: Tue, 9 Jun 2026 13:25:10 -0400 Message-ID: <20260609172514.2037645-7-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@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.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1781025977458158501 Content-Type: text/plain; charset="utf-8" Add a helper to set qom property via a bool pointer. Signed-off-by: Peter Xu --- include/qom/object-property-ptr.h | 15 ++++++++++++ qom/object-property-ptr.c | 39 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/qom/object-property-ptr.h b/include/qom/object-propert= y-ptr.h index 6066c377fb..9cd8600094 100644 --- a/include/qom/object-property-ptr.h +++ b/include/qom/object-property-ptr.h @@ -16,6 +16,21 @@ typedef enum { OBJ_PROP_FLAG_READWRITE =3D (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE), } ObjectPropertyFlags; =20 +/** + * object_property_add_bool_ptr: + * @obj: the object to add a property to + * @name: the name of the property + * @v: pointer to value + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add a property of type 'bool' to the object. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty * +object_property_add_bool_ptr(Object *obj, const char *name, const bool *v, + ObjectPropertyFlags flags); + /** * object_property_add_uint8_ptr: * @obj: the object to add a property to diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c index 02c01ed7f0..49f223da7b 100644 --- a/qom/object-property-ptr.c +++ b/qom/object-property-ptr.c @@ -7,6 +7,26 @@ #include "qom/object.h" #include "qapi/visitor.h" =20 +static void property_get_bool_ptr(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + bool value =3D *(bool *)opaque; + visit_type_bool(v, name, &value, errp); +} + +static void property_set_bool_ptr(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + bool *field =3D opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + + *field =3D value; +} + static void property_get_uint8_ptr(Object *obj, Visitor *v, const char *na= me, void *opaque, Error **errp) { @@ -87,6 +107,25 @@ static void property_set_uint64_ptr(Object *obj, Visito= r *v, const char *name, *field =3D value; } =20 +ObjectProperty * +object_property_add_bool_ptr(Object *obj, const char *name, + const bool *v, ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_bool_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_bool_ptr; + } + + return object_property_add(obj, name, "bool", + getter, setter, NULL, (void *)v); +} + ObjectProperty * object_property_add_uint8_ptr(Object *obj, const char *name, const uint8_t *v, --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781025985; cv=none; d=zohomail.com; s=zohoarc; b=MJMG9k5YwrdADdIbLj9lKUdgfTf5bHBqkyKQ+smg+mo+xiIv3xo8g7+xH5MvjKql5qYieqxp29sEwOv4ctTrX8kFnb7xG/L5mLaXogaqn5BCu+1P+jJDS3b4EbDWch9roNQIcGPd8X3Ku3fgn9XhYPGqZ2D0xK7DhjnodLFwF5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781025985; 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=mqrDCR+oRMqmtrsRDcLBvqMYTFGEeRtYsKQ4H1N/ZoA=; b=UD+t43Z4pICf7o2+NlFo+u5zF/9ld/arOUYT7C6X2a2Pa+hQ41O7y7KoWXPsyQJhtinwv8HzrugEP5DPnAhND+6qG6xhJ0vfvgswO6FrqZRst/xtiipgFGnvzMT2wG7SjLmvqzKVys63AI1HYSkBmYGDbpDZ2xr8StJ45wLXF0E= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781025985199513.126901637408; Tue, 9 Jun 2026 10:26:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D9-0007m4-4W; Tue, 09 Jun 2026 13:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Cr-0007Xh-Fi for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:43 -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 1wX0Cp-0001wH-1Z for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:41 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-Xf15pr7ENqi3i5rvGhTvdg-1; Tue, 09 Jun 2026 13:25:36 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-5178fc89b1bso73796321cf.1 for ; Tue, 09 Jun 2026 10:25:35 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025937; 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=mqrDCR+oRMqmtrsRDcLBvqMYTFGEeRtYsKQ4H1N/ZoA=; b=RhGfw11t6e+jWO69po1iwqjUXf40YivrKsJ0A2gyk+b1DKQXMsGjHQg6SBLW6PKC1wDPpU iK8YtUfIL8uqaJnJcpdibzIPKX2B3HGgF3Emzsjc1r6TaDTzwAyk0BhlSnUQrF2IvwHvId j4WJ6vSx6okvRXWEW5ni+byG7iOV5jk= X-MC-Unique: Xf15pr7ENqi3i5rvGhTvdg-1 X-Mimecast-MFC-AGG-ID: Xf15pr7ENqi3i5rvGhTvdg_1781025935 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025935; x=1781630735; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mqrDCR+oRMqmtrsRDcLBvqMYTFGEeRtYsKQ4H1N/ZoA=; b=WG/ZcHKowof8F6BfZVk97TZH8qQx42miRZg0/XwanERINb2tCZ8wqI7kz6Qyfn2eaK xK7oGUvvIQLeKf8hQ9JxTih493eJ8RWE4hf3ZZMVIwdOG4rtMth5YF0ggYcQeP2kZ7YB XYZLsUlSjCbh5B/zFHWZmBRHEJ/JGy/2Whuu3pc2V+RKKoVkixb6rgMiGx/Jj1l82/EU xceGtoKAvKTEaIdjGZo29zpuTHIsLUt40FZYdlVfRRSrOiTyiJQXCdKYRg+nuhh8Yuy/ UEhHMWHmMvjXamrbrwUiafX8Ux9+rGw1F44UmLwKN1v6LHPl55JrmVWe8r/DmQn8bheP mmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025935; x=1781630735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mqrDCR+oRMqmtrsRDcLBvqMYTFGEeRtYsKQ4H1N/ZoA=; b=R1SKpWPAbJPfy8xB6XGKoHES2ierLNXKndAaMWQzDdEmLs0FBmchYpewrpc2SuXJDi AU5ilOb0BKlniR4h98bpHqBwp9pVWd9X8z0IBe12QdotCGH703vbuxcuRvEUuvQH941I Pd/64WyShRbUPR7kTI3QvmHwvoSvTXRQXbLI0rhWaeMjJlFIe/nrvnvRYmYvKGz1Aq3I 5bpTBWu8aFVdLtG1B/GshOQ0CT+LEn1n2eE2DLEKvqJ9xZz0/CuXHwjvb5fxAmbBLE9D ykxYunNOCtlFcIon5U5rhZDpUQgidfFng3er/mwqS1EMIVxK+GVgZZ6R29cjgLJYW+aB rghw== X-Gm-Message-State: AOJu0Yy1ILEQWTzvFucZE1Aa1xlKfWiqTBs7dXd5CseDo+TOX/inLNvd /AAWaYbCmFodC30R2MhWRLfEXIulVvRcHoV2OixqHxhwkrGIqAJ2FQ+zUacATclK8ZTaUUwkq79 GHfvsOiPouB64JUruWmyyBsh0TRdhoaFOw5mjUTCT9U0e1yMPP047Mizbp1lr7xmFKVmSM5QK+x KiCj0+ZfZsrYStwsGonve+8VG/dZsxwTDnEcnQrQ== X-Gm-Gg: Acq92OFyi+5QQlI34mCPsae3tP0/CfbX9P5UVXhsXVDoO7cRiru6dT6CyWlb6nIDOlm eixnkIJarANLRVMlmc61PbcS9WHJXKWBq0GrgsbCOkMjfGba2cvxyiw98za3vVt1E7yd3DeEqiF PkAa2qhynn7ZmL4GYyx0Az4Y0c0uAt9BKNihwAZiezjAe+aACgoWy+rIaAAHckzvn5xkYXa8ke5 3svOitMljupznm4VIlZBPVgbN1a2yyVKxGCisXSqLPDHr2My6vlWP8sggMoVxquqxFZyYdyo3Oj tVA20KlVWIGBKSAyhW8om+sRRmorFsXVYE47/H9qMWvNkTidXB6nbAqNzLMnK6fYm7CUmNCQzA1 u4aHloHyfmTZaWNnEYZzYNyQ= X-Received: by 2002:ac8:610f:0:b0:517:707b:14f1 with SMTP id d75a77b69052e-51795c09df1mr301393091cf.46.1781025934920; Tue, 09 Jun 2026 10:25:34 -0700 (PDT) X-Received: by 2002:ac8:610f:0:b0:517:707b:14f1 with SMTP id d75a77b69052e-51795c09df1mr301392161cf.46.1781025934194; Tue, 09 Jun 2026 10:25:34 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 07/10] qom: Add object_property_add_size_ptr() Date: Tue, 9 Jun 2026 13:25:11 -0400 Message-ID: <20260609172514.2037645-8-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@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.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1781025987127154100 Content-Type: text/plain; charset="utf-8" Add a helper to set qom property via a size pointer. Signed-off-by: Peter Xu --- include/qom/object-property-ptr.h | 16 +++++++++++++ qom/object-property-ptr.c | 40 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/qom/object-property-ptr.h b/include/qom/object-propert= y-ptr.h index 9cd8600094..be467c64af 100644 --- a/include/qom/object-property-ptr.h +++ b/include/qom/object-property-ptr.h @@ -115,4 +115,20 @@ ObjectProperty *object_class_property_add_uint64_ptr(O= bjectClass *klass, const uint64_t *v, ObjectPropertyFlags flags); =20 +/** + * object_property_add_size_ptr: + * @obj: the object to add a property to + * @name: the name of the property + * @v: pointer to value + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add a property of type 'size' to the object. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty * +object_property_add_size_ptr(Object *obj, const char *name, + const uint64_t *v, + ObjectPropertyFlags flags); + #endif diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c index 49f223da7b..21ceb2510d 100644 --- a/qom/object-property-ptr.c +++ b/qom/object-property-ptr.c @@ -107,6 +107,26 @@ static void property_set_uint64_ptr(Object *obj, Visit= or *v, const char *name, *field =3D value; } =20 +static void property_get_size_ptr(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + uint64_t value =3D *(uint64_t *)opaque; + visit_type_size(v, name, &value, errp); +} + +static void property_set_size_ptr(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + uint64_t *field =3D opaque; + uint64_t value; + + if (!visit_type_size(v, name, &value, errp)) { + return; + } + + *field =3D value; +} + ObjectProperty * object_property_add_bool_ptr(Object *obj, const char *name, const bool *v, ObjectPropertyFlags flags) @@ -285,3 +305,23 @@ object_class_property_add_uint64_ptr(ObjectClass *klas= s, const char *name, return object_class_property_add(klass, name, "uint64", getter, setter, NULL, (void *)v); } + +ObjectProperty * +object_property_add_size_ptr(Object *obj, const char *name, + const uint64_t *v, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter =3D NULL; + ObjectPropertyAccessor *setter =3D NULL; + + if ((flags & OBJ_PROP_FLAG_READ) =3D=3D OBJ_PROP_FLAG_READ) { + getter =3D property_get_size_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) =3D=3D OBJ_PROP_FLAG_WRITE) { + setter =3D property_set_size_ptr; + } + + return object_property_add(obj, name, "size", + getter, setter, NULL, (void *)v); +} --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781026080; cv=none; d=zohomail.com; s=zohoarc; b=CHplQNCoTlgtJ8uGJdyM2Y4LbOGHLbtKuyF1jRRbVYlfATbsm+m55lByNMeCHpl4t10KTBH1V+N6GX1gTjdNCkM2Kw9IUx8MjNStQZazzuntpuQFxULHb+bps36BKJcafbDFmBKcB+zk4Spac08pb/ImIHsM/F2Oxd5Ie0j19GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781026080; 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=ho/BMxX8YnQ131yrIsVBM8rRwXj38KUVhIf57yJSr4U=; b=lqbkJ1a/VYDWLdjVo+oMmlpeXko3cjuC1atTH59nBose2qf0Qc3PXHLjQ53GR1Vm7VmjbtQytA1S0Wb3u4UoB0mL4fCRz01X1OyWobJXIQiSd6xI7wiooE8WYvTltiK46ewFej7zjeIHt3Akcz7mj+Uack8nn5zY8EUtuUSuACA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781026080567791.5102107688064; Tue, 9 Jun 2026 10:28:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0DP-0007xm-27; Tue, 09 Jun 2026 13:26:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Ct-0007Yk-Ff for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:45 -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 1wX0Cp-0001wQ-1k for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:42 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-470-FWqkvaQFO-efcUz4EcTqNQ-1; Tue, 09 Jun 2026 13:25:37 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-5175a1e32e3so158592571cf.0 for ; Tue, 09 Jun 2026 10:25:37 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025938; 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=ho/BMxX8YnQ131yrIsVBM8rRwXj38KUVhIf57yJSr4U=; b=bg8GlfcNg+UjwN8AglCYLU3chZkPv6YbR9Lay57UGJAnRxPnNe+oDg85LS0+CjaaUknsP7 GX/FYW/aScVbjAztQrRKTFnO6MBXTsKvU0aROVx8yjJMAUPoIoGeMYXn3CqV9a1O+9pV7d uwpvFw6jQSPTpdBZaFp8HL9etMEAYSE= X-MC-Unique: FWqkvaQFO-efcUz4EcTqNQ-1 X-Mimecast-MFC-AGG-ID: FWqkvaQFO-efcUz4EcTqNQ_1781025936 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025936; x=1781630736; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ho/BMxX8YnQ131yrIsVBM8rRwXj38KUVhIf57yJSr4U=; b=kKHFv8Byd8pcIHp+ujKMQNIjHTW0jlEiXtt6+SngpDTi/yUVWUQNx56U8RrjVpgX5v mP/mMC0kBCiK3vvbLGP+sY0ji5BGtbdOlZ5gOiUa4C0g9hEp9p8gtZZpXEyQo6QGvtr2 D+46KbJwyaGjIa/CoLKjvO/xRY5rSRfqO9oLDMyAphat68AlzBPGODV+92AHC32AYG8N FWBVwfMTL7KUvEkSYfWyNxw5veXvwVx9EKTyrfrVMkZt1XQmrXFwjWlpngLaVPp8ThZC V5mwd6Xb6/a9CjVQuQTTRihFf3X64RyABRwBE+RmAwOtLW7jahIaMcQ4ip2AJ6OfvEnB 20cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025936; x=1781630736; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ho/BMxX8YnQ131yrIsVBM8rRwXj38KUVhIf57yJSr4U=; b=B1d1CfQsHV9t+j6EqkNlXCHyfnTzzUmu/FfCLZull/crBnHVVY4gyr/STSMrF4nm87 I+mi3QVFquHfz8XDXL2ehxbash5r4YRdHOFAs/lM26qIUXLeWeQ+deCwJCh31sNdDmD4 7IKIRW2bpVDeRzbzsoPzt4aBp+KMu/pfu3So+JwBTx4ttMdTV/jZ8rihN9ajK4zaeFyM UiBQ6Cy7oNzrQfT2ApA7dns+z1+O9rHJHg5IyZPcU0VmE/7hPlcMmi9vLs4xap/2Wgqt oF4Usnj9515wtkKO7Jnpi00NXvzZd5AhUofJ/wEHW43D8ge7/Vr9XJrdlGV/ZTNBEwQK EeVw== X-Gm-Message-State: AOJu0YwqLZ4bZHE1S8m96DQvEk82QgWolMWz/wpk34tQzXOapshfRYhm cSBrFhpGml+LB2fmJIaoQVGIpKkbiVfn1Vv/DIgvVjZnOQbtaIO0JSAsQATwQxQzWebLCloT1Yh 27r7heTZFnkCT5oNH9bUAS1xOlUbz3lOz3ETLyGiZFXqYPQyIGL/zg4EI6ciiJkZWKcxg13XJOs d3GZMhsCcSIywEXaBd4iBS2znaBNo4YWkOMwXB1g== X-Gm-Gg: Acq92OFuzRlEmV603N32+o7ao4iN7eXVotp5+PiXWcqJ32RtGGTgtjP3rFy/Pts091F TbMbs6tW+e0gvqF3nWBc1sBRkSTHgxHnUYIqSW5Jc4k54DIZED92e4jxiKUC8PJHHZSrx9cORKo xUkmwEucG9gcw1QzY72HshFF9JuBUG6SKJL6sw+23XLFeVL6upok1GbmZKOxj9CZXKwmTgrqwTB vg0LUc3/BLJBfIMQ0qVfeO1VY54luDjjxkr25St2hbL7eYV6jtZ5aGauIGrFKdipi1gTkk2otJa rTPwSPa8Oda35FJsxTvgDb94ZPofVR1VTk+Rh+GUCQWtkFMjrrZDlpiYnR9lUl7QFu7/PNw2sDO victygV9lXqJ0cTmTHw1JDjw= X-Received: by 2002:a05:622a:400c:b0:517:7971:a234 with SMTP id d75a77b69052e-51795b729ffmr305681801cf.4.1781025936415; Tue, 09 Jun 2026 10:25:36 -0700 (PDT) X-Received: by 2002:a05:622a:400c:b0:517:7971:a234 with SMTP id d75a77b69052e-51795b729ffmr305680851cf.4.1781025935723; Tue, 09 Jun 2026 10:25:35 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 08/10] qom: Add object_property_add_*_ptr_def() Date: Tue, 9 Jun 2026 13:25:12 -0400 Message-ID: <20260609172514.2037645-9-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@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.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1781026082070154100 Content-Type: text/plain; charset="utf-8" Add sister functions for existing pointer versions, to make it even easier to use by: - always make properties to be rw-able - allowing to specify default values - no retcode needed (assert on failure, always) Signed-off-by: Peter Xu --- include/qom/object-property-ptr.h | 28 +++++++++++++ qom/object-property-ptr.c | 67 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/include/qom/object-property-ptr.h b/include/qom/object-propert= y-ptr.h index be467c64af..ecd6f7819b 100644 --- a/include/qom/object-property-ptr.h +++ b/include/qom/object-property-ptr.h @@ -131,4 +131,32 @@ object_property_add_size_ptr(Object *obj, const char *= name, const uint64_t *v, ObjectPropertyFlags flags); =20 +/* + * Below are sister helpers of above, except that: + * + * (1) nothing is returned + * (2) always make the property to be both readable and writeable + * (3) allow setting default value + * + * Please refer to the sister functions for the documentation. + */ +void +object_property_add_bool_ptr_def(Object *obj, const char *name, + const bool *v, bool def); +void +object_property_add_uint8_ptr_def(Object *obj, const char *name, + const uint8_t *v, uint8_t def); +void +object_property_add_uint16_ptr_def(Object *obj, const char *name, + const uint16_t *v, uint16_t def); +void +object_property_add_uint32_ptr_def(Object *obj, const char *name, + const uint32_t *v, uint32_t def); +void +object_property_add_uint64_ptr_def(Object *obj, const char *name, + const uint64_t *v, uint64_t def); +void +object_property_add_size_ptr_def(Object *obj, const char *name, + const uint64_t *v, uint64_t def); + #endif diff --git a/qom/object-property-ptr.c b/qom/object-property-ptr.c index 21ceb2510d..ae9081d2d8 100644 --- a/qom/object-property-ptr.c +++ b/qom/object-property-ptr.c @@ -325,3 +325,70 @@ object_property_add_size_ptr(Object *obj, const char *= name, return object_property_add(obj, name, "size", getter, setter, NULL, (void *)v); } + +void +object_property_add_bool_ptr_def(Object *obj, const char *name, + const bool *v, bool def) +{ + ObjectProperty *prop; + + prop =3D object_property_add_bool_ptr(obj, name, v, + OBJ_PROP_FLAG_READWRITE); + object_property_set_default_bool(prop, def); +} + + +void +object_property_add_uint8_ptr_def(Object *obj, const char *name, + const uint8_t *v, uint8_t def) +{ + ObjectProperty *prop; + + prop =3D object_property_add_uint8_ptr(obj, name, v, + OBJ_PROP_FLAG_READWRITE); + object_property_set_default_uint(prop, def); +} + +void +object_property_add_uint16_ptr_def(Object *obj, const char *name, + const uint16_t *v, uint16_t def) +{ + ObjectProperty *prop; + + prop =3D object_property_add_uint16_ptr(obj, name, v, + OBJ_PROP_FLAG_READWRITE); + object_property_set_default_uint(prop, def); +} + +void +object_property_add_uint32_ptr_def(Object *obj, const char *name, + const uint32_t *v, uint32_t def) +{ + ObjectProperty *prop; + + prop =3D object_property_add_uint32_ptr(obj, name, v, + OBJ_PROP_FLAG_READWRITE); + object_property_set_default_uint(prop, def); +} + +void +object_property_add_uint64_ptr_def(Object *obj, const char *name, + const uint64_t *v, uint64_t def) +{ + ObjectProperty *prop; + + prop =3D object_property_add_uint64_ptr(obj, name, v, + OBJ_PROP_FLAG_READWRITE); + object_property_set_default_uint(prop, def); +} + +void +object_property_add_size_ptr_def(Object *obj, const char *name, + const uint64_t *v, uint64_t def) +{ + ObjectProperty *prop; + + prop =3D object_property_add_size_ptr(obj, name, v, + OBJ_PROP_FLAG_READWRITE); + object_property_set_default_uint(prop, def); +} --=20 2.53.0 From nobody Tue Jun 9 23:09:18 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781026049; cv=none; d=zohomail.com; s=zohoarc; b=RXvAbt73+hZIvwPeBP69Z1qhkKHZHIS8hJLL+Ta9UMSnRUdNRg4wSSbE431XyQwHa7feX9iDykd6AOFW87MieKGziqtcqcroZUbn20D13SjBNtkXBdmduxyWeBTcHj9iSe1HoqWCbPcayE6Xgbwhwg98VkQl4fMU+h+3dCOn9aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781026049; 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=ZxoWieFRl5alZGyqHw8uY/Fy15O9Y6SOJg0ST4pPYm0=; b=iOk+0jciEMXnkoCOn2Dt/Bmv8Tue1hQuZ8zG0FxGZD6XUg31NzHcqrw/jfE9w9EmT9hXSGBfTooxwXDfcQe9Q1yBLP5AkJNtxFWpxkhPNfJJ+wFfk34vN/p2pUlvwS+88ZKtFGHRtzPGxy5IOHRRqTq8g8NRwuopf0g6kigwL6Y= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781026049280530.7499003585023; Tue, 9 Jun 2026 10:27:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D8-0007iF-A5; Tue, 09 Jun 2026 13:25:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Cv-0007ZP-CH for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:47 -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 1wX0Ct-0001yj-38 for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:44 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-hyrcOKY3MKCWbyGYTtj19Q-1; Tue, 09 Jun 2026 13:25:38 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-5177f07eb05so113541161cf.3 for ; Tue, 09 Jun 2026 10:25:38 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025942; 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=ZxoWieFRl5alZGyqHw8uY/Fy15O9Y6SOJg0ST4pPYm0=; b=cucbWn18pUEaVc7fwvtGmK6JqJmivvtLxxP+el0UwOLOx2/UylnpbX0FeDNkiR/QrcNsT8 jJ6syunYE8K5UFg5h0f+oME/6w8SBUN08TzwIyQHK4WQr2aOgxkLJ4DZB7x0VzIoO2p3f3 oW9lmUXzsHHb5MxngJ6S8JWy6E9uiHo= X-MC-Unique: hyrcOKY3MKCWbyGYTtj19Q-1 X-Mimecast-MFC-AGG-ID: hyrcOKY3MKCWbyGYTtj19Q_1781025938 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025938; x=1781630738; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZxoWieFRl5alZGyqHw8uY/Fy15O9Y6SOJg0ST4pPYm0=; b=hGNt6yeXzhv4EDj1Wnv0gVzHkNMMq8wGvUjcEVqIeIR7f2jxdFZk4/lDnuPZDzcBjH UByHjBXQqVzc0HHI/5//xL1663UpZyY4Ks3vmXvkz3FdaN5KRQ3rkqS/hGWG9GKlAlY1 7IkQY8b2LhVOo+mwQwT3aF69JeEz3x4P09t6GPNvamUT0NDtGqkbTIKOQMVGZQ/MLoUt JfrTaNnt96y2cQDV3PpAW3TZG9ZBTv4NyKb3c8zB74dVdOEAQqySYvT31CzC6Q3bDuES pKkwiSjPHaPcwgXTw9Ljkuo6crov+8DC9LvTUG/p6T0BNtSQOdtFT9ECGaJVPjyxOOzf GSaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025938; x=1781630738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZxoWieFRl5alZGyqHw8uY/Fy15O9Y6SOJg0ST4pPYm0=; b=iv9G+n0sk9xY7nNs2gFYB8Lj3tfAhU4xHeNUTvxNrGbEJ3mzN8MZArzpyEdXn7fV0D BR59IiD86HIdE8cSug71o3XHGORCbGY3nXS9HvOxcZ5K1jPQe+7RdWTGwnDIgnqVEB5o ZcU2L8dG3GYpcoxq1pK+am02wfHFOy0uLgqida4DRvKDjwNeUFCibMy9tB4+075CgogZ pQNc94CkJQJLmc6l+smrSTzrHcpcnFLPEkJFwolvjhFyv2J/mp8VMDDUsmjSJwHe5l/n 0S2NvwbGZkdRP10FMoTjl5EFJKo0ES8BAjsXpJ1DYX23dLw53HfNh7v6POLm9NNhTd1E WyIA== X-Gm-Message-State: AOJu0YwRDd8tJlbiD7rxLyK6qs/9f9JkhKwW6HwS2zpx0a2lyOQVT4H9 vdtDqdjLVFwpr8WBS5Tc3ks6iz+aAV6mQ2FJT/QhJGwPtBVpbA+PZLMzhqHfKF1MooWJ9qz2Js4 RauxCpgF0ZsuwG6OwKoH5kHBfqhSdJmIhziKh75WSLLrwcymDOlZhHG4toCi+0QiqC9II7B4oI3 uECGcr9wH+hp/Sqgqamwuy64ykVzPsyi+E40N5fA== X-Gm-Gg: Acq92OGsogyH61WRh3kswPymo44EJDxVn5DVQpgTQs1x99EIolsJUFopvQV0jCZ+s6w HhvYSs3Nvk6isMc0hlP2LNdjdvqlLzbWwAjrYcuaN2GlDyJVGg0Nb0R+MbuScad8XyxafBJQ5pM N0sfzay3rsceliPbMjsOOFCyyoyGqu56m/N/ZedEr1BR0D04YCkUpkO8RIX/mlVtLBOKTg222to z7vsqaTGWMpPcrq5KM9k3+umWYDji8mfcyOB1kHyYyBDhRVOAuA0bgF9dgW29L/FA3jXuc1qcba QjLFF32Q4KDzRJ5TgiSrBgvtdjus/Z3xO+oeT//96WVJV553tU8kMM/VW5sUfxVcBE1VCEr24PV f9zLSiIGXGaBMp190TfmwUzM= X-Received: by 2002:ac8:1342:0:b0:517:6339:41d0 with SMTP id d75a77b69052e-51795bbf6c2mr213878621cf.29.1781025937892; Tue, 09 Jun 2026 10:25:37 -0700 (PDT) X-Received: by 2002:ac8:1342:0:b0:517:6339:41d0 with SMTP id d75a77b69052e-51795bbf6c2mr213877991cf.29.1781025937264; Tue, 09 Jun 2026 10:25:37 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 09/10] qom: Allow default values for instance properties Date: Tue, 9 Jun 2026 13:25:13 -0400 Message-ID: <20260609172514.2037645-10-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@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.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1781026051539154100 Content-Type: text/plain; charset="utf-8" ObjectProperty allows default value settings via proper setup of prop->init() and prop->defval. It currently is only supported in class properties, not instance properties. However, since QOM allows class and instance properties, it should also allow instance to add properties during instance_init() and allow the default values to be applied properly for this instance only. Add the logic. It will be useful for all kinds of pointer based properties because pointers are normally not accessble in a class but only when an instance is available. This will be able to achieve similar function as what qdev properties have (which works by remembering offsets within a structure instead). Signed-off-by: Peter Xu --- qom/object.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/qom/object.c b/qom/object.c index fc738549dc..eaef615924 100644 --- a/qom/object.c +++ b/qom/object.c @@ -487,6 +487,20 @@ static void object_class_property_init_all(Object *obj) } } =20 +static void object_property_init_all(Object *obj) +{ + GHashTableIter iter; + gpointer key, val; + + g_hash_table_iter_init(&iter, obj->properties); + while (g_hash_table_iter_next(&iter, &key, &val)) { + ObjectProperty *prop =3D val; + if (prop->init) { + prop->init(obj, prop); + } + } +} + static void object_initialize_with_type(Object *obj, size_t size, TypeImpl= *type) { type_initialize(type); @@ -498,10 +512,22 @@ static void object_initialize_with_type(Object *obj, = size_t size, TypeImpl *type memset(obj, 0, type->instance_size); obj->class =3D type->class; object_ref(obj); + /* + * A few steps to initialize properties for the objects: + * + * (1) apply default values from class properties when available + * (2) invoke instance_init(), which may add per-instance properties, + * which may further contain default values + * (3) apply default values from instance properties when available + * + * instance_post_init() should happen at last, after the instance is + * fully initialized. + */ object_class_property_init_all(obj); obj->properties =3D g_hash_table_new_full(g_str_hash, g_str_equal, NULL, object_property_free); object_init_with_type(obj, type); + object_property_init_all(obj); object_post_init_with_type(obj, type); } =20 --=20 2.53.0 From nobody Tue Jun 9 23:09:19 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781025974; cv=none; d=zohomail.com; s=zohoarc; b=Pa0ZY4lVfWrIk1xwdh8PKPZqNYEi1vUTmZmZinkA3YGsYTnkhQeLPOy0iTWnLxtWWoj7h5PyEOH5QR2RGciySr2T07E9qNIjY6cySgZGqgnoXY8ZUasoAYnF5eVOpvLZpogYr0WY/IjKeUUZ6y0lNjhB+ijQq0t4GjamF0CXurs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781025974; 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=nEeE/ILPbUfNm0fHrOlFecQ+K6hT8Mcwf1ycjvTaswU=; b=MfAuUv7YWEsZu1+jHDiLq0rUMnPNpejNRoMhA79Z36ePdt+K8c44JfGlcAfy/VFnZio+/ey0+g2V5lFC1pMeIHyOd5cl8ziaPdrHRJDF5R1Y6lCz/rrFwV3GRQsmhsriLFOp9vWH+oyNzRqnqS+FpcV4/5RLwYLIpbfxaS+8QoE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781025974700731.8104744441708; Tue, 9 Jun 2026 10:26:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wX0D9-0007mL-4w; Tue, 09 Jun 2026 13:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wX0Cw-0007aA-Di for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:47 -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 1wX0Ct-0001yZ-3m for qemu-devel@nongnu.org; Tue, 09 Jun 2026 13:25:46 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-HpWW51MUOMmJEDZzkWkzxg-1; Tue, 09 Jun 2026 13:25:40 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-517600719a9so96755031cf.2 for ; Tue, 09 Jun 2026 10:25:40 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775da2c56sm187524711cf.21.2026.06.09.10.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 10:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781025941; 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=nEeE/ILPbUfNm0fHrOlFecQ+K6hT8Mcwf1ycjvTaswU=; b=DfgDpzLsTXjLs5dyilDVMi6GmEDUnn+ltbbjchdyCT0u09lkGV6jKm7GDJ+UmUau3z9IYs 6p1zxNK40PIcz2vIJMiqz+EiZXNw+cysTBawcYG7y7pqKQlpun0+lu9q5UQo9jHRZARL29 8BYPri227aaNqsQXTlt76cUCWv5fMKg= X-MC-Unique: HpWW51MUOMmJEDZzkWkzxg-1 X-Mimecast-MFC-AGG-ID: HpWW51MUOMmJEDZzkWkzxg_1781025940 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781025940; x=1781630740; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nEeE/ILPbUfNm0fHrOlFecQ+K6hT8Mcwf1ycjvTaswU=; b=Wm7yPlLI57YIOvuX06IJtVuuQEWtcWT/pH6nQSqfyyHKavchVuxEU3KoHv2onED10E cEQNar2788/Ekur6ABLSRjsVKyKXzozOL0RoGb7xwjSLWmudkKfMkXoKv2cjEhoN7QnB xLlFdDUnUZUBMg2Dh4TSzhZd3fiFJBBujxw/JC4Kf517DvrcACrBfNuUjr72O3d78dHY qPr125Lg9zq2mFGcBpyn5jUVatEOiWZIB1E7bgc6Uux0gQdL8IRYflqJhq7IKIl59eAu l93TCln9Kw6gitQPJ8ENQrVQvEcig1B4uqjxBWAp/o2QYqoV/QsHvnOjZCIEUZ23BwMI YWzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781025940; x=1781630740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nEeE/ILPbUfNm0fHrOlFecQ+K6hT8Mcwf1ycjvTaswU=; b=l4QowYb8g8F6gskIwr/rgSTZuK7KjXrSGmV+EBlK/k0HCy/7NAfjV2gDgROxviv2sT 9qgaLuI5Ycnokd2dsgoYSTAUlyx9/GoY5inQQojXHeUZxXwQmcPbjoAkcUThCaLZJ6Fe BAlX1zApQegD5RJwFS5j6B0Nb0Hnh4TNRvvkIOzNSuM7UeOOG8CwIja3F6Xao8mHcJmS UOoUfj0HfmvSHdF69Yfl96B20C4qrlG1C43Bb8yPhcOogadDXm5pFmR/b4clVIX5ABzP WJ2WKF5VoYysaeaOpwVPoguVXzxvhcZgAaIZB1yToFUDsRyrjMdDQYMQXndhVnph5Idz twHw== X-Gm-Message-State: AOJu0YzO6EN2OHBe8OJePo9HGARC2liKSDeQEZPfRLL+RrlSSrULcGOr WFtd/LxGsb+ndksZTLVi2DpKO+V9oHDOSqgBCUB75Swp1TrF0W4GgO634wqGLjQFuIMPovISzNz bErSv4u0AkmzI/UHL1nSzX8trZ/0azDrbHPDxvMG4EHWszq8cbdSX/LikY9aAtg50A1xa+gUCpy Ov/KFoTMr9DEQh6E0a06jtZPRjb3YYJse/ZYycPQ== X-Gm-Gg: Acq92OEQ63GM4oa8PQhmU3KM2egCx9EfwtZG7lE8H1G8l8/nDSFiGWKJiSoiOIB8A2B P6hmtM0crPLyo0y5qAkZcFg3exdWwtsXNCGnqupXI9G5J2tgNiJJSPAIncl/3hiLQT6UJKyrjen llw5wBtFpVCDjaLtBH9NdBdbpIRXB2aY3b8YzQdelrJOEyXc612C9yD4pNM6ctTmJPu/cgPorop YXjnIdn/avbZIy2rqBflOaCmrPT2B0DJkg+QQlXKH7N51eXwdaE4KIVzVzYQsECyAeFT3aRoqvq 6dH9XALGq1xtW+85L/L1V/5Hp0IZfjwZCp9EFpPPQ2IFXng1htozu5ZA4fVSL3BU7OKq/QRJ1YI GQo1yqO+Rkg9nbPVniywOLjA= X-Received: by 2002:a05:622a:4d98:b0:517:59a1:82cb with SMTP id d75a77b69052e-51795bbdc93mr312956701cf.48.1781025939758; Tue, 09 Jun 2026 10:25:39 -0700 (PDT) X-Received: by 2002:a05:622a:4d98:b0:517:59a1:82cb with SMTP id d75a77b69052e-51795bbdc93mr312955831cf.48.1781025938988; Tue, 09 Jun 2026 10:25:38 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Vladimir Sementsov-Ogievskiy , Peter Maydell , "Dr . David Alan Gilbert" , Eric Blake , Akihiko Odaki , Peter Xu , Paolo Bonzini , Kevin Wolf , Sana Sharma , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Juraj Marcin , qemu-rust@nongnu.org, Markus Armbruster , Mark Cave-Ayland Subject: [PATCH v2 10/10] migration: Switch to TYPE_OBJECT with object properties Date: Tue, 9 Jun 2026 13:25:14 -0400 Message-ID: <20260609172514.2037645-11-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260609172514.2037645-1-peterx@redhat.com> References: <20260609172514.2037645-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@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.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1781025979258154100 Content-Type: text/plain; charset="utf-8" The migration object used to depend on TYPE_DEVICE due to: - Usage of qdev properties - Apply compat properties and global properties This patch re-based the object to TYPE_OBJECT with the changes: - Switch to object properties API - Manually apply both compat and global properties in post_init() Note that to avoid too many property getter/setter helpers, this patch used the object_property_add_*_ptr_def() APIs so that an pointer is passed to bind to the property. Such API is used for most of the conversions. After patch, the migration object initializes instance properties within its instance_init() callback, in migrate_params_init(). One side effect of this change is, since we switched to a loop to add all capabilities, the name of the properties representing a migration capability may chance from previously hard-coded ones (many with x-). It's fine since it's only used in -global so it's only for debugging. Similarly, I removed "x-" from other properites that used to start with "x-" but actually are not experimental. After the whole conversion, we don't need migration_properties or the count anymore, hence can be removed. While at it, we can also remove two DEFINE_PROP*() API that only migration uses (DEFINE_PROP_STR_OR_NULL, and DEFINE_PROP_MIG_CAP). Signed-off-by: Peter Xu --- migration/options.h | 8 +- migration/migration.c | 35 ++- migration/options.c | 526 ++++++++++++++++++++++++++---------------- 3 files changed, 351 insertions(+), 218 deletions(-) diff --git a/migration/options.h b/migration/options.h index b46221998a..eadbb8cf61 100644 --- a/migration/options.h +++ b/migration/options.h @@ -18,11 +18,6 @@ #include "hw/core/qdev-properties-system.h" #include "migration/client-options.h" =20 -/* migration properties */ - -extern const Property migration_properties[]; -extern const size_t migration_properties_count; - /* capabilities */ =20 bool migrate_auto_converge(void); @@ -92,6 +87,7 @@ uint64_t migrate_rdma_chunk_size(void); /* parameters helpers */ =20 bool migrate_params_check(MigrationParameters *params, Error **errp); -void migrate_params_init(MigrationParameters *params); +void migrate_params_init(MigrationState *s); void migrate_tls_opts_free(MigrationParameters *params); + #endif diff --git a/migration/migration.c b/migration/migration.c index 278cad502a..ae0c373549 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3964,15 +3964,6 @@ fail: } } =20 -static void migration_class_init(ObjectClass *klass, const void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - - dc->user_creatable =3D false; - device_class_set_props_n(dc, migration_properties, - migration_properties_count); -} - static void migration_instance_finalize(Object *obj) { MigrationState *ms =3D MIGRATION(obj); @@ -4001,7 +3992,7 @@ static void migration_instance_init(Object *obj) qemu_event_init(&ms->pause_event, false); qemu_mutex_init(&ms->error_mutex); =20 - migrate_params_init(&ms->parameters); + migrate_params_init(ms); =20 qemu_sem_init(&ms->postcopy_pause_sem, 0); qemu_sem_init(&ms->rp_state.rp_sem, 0); @@ -4028,20 +4019,26 @@ static bool migration_object_check(MigrationState *= ms, Error **errp) return migrate_caps_check(old_caps, ms->capabilities, errp); } =20 -static const TypeInfo migration_type =3D { - .name =3D TYPE_MIGRATION, +static void migration_instance_post_init(Object *obj) +{ /* - * NOTE: TYPE_MIGRATION is not really a device, as the object is - * not created using qdev_new(), it is not attached to the qdev - * device tree, and it is never realized. + * Apply these properties on top of default values: + * + * (1) machine compat properties + * (2) -global settings in cmdlines * - * TODO: Make this TYPE_OBJECT once QOM provides something like - * TYPE_DEVICE's "-global" properties. + * Need to be applied in order so (2) takes precedence over (1). */ - .parent =3D TYPE_DEVICE, - .class_init =3D migration_class_init, + object_apply_compat_props(obj); + object_apply_global_props(obj, global_props(), &error_fatal); +} + +static const TypeInfo migration_type =3D { + .name =3D TYPE_MIGRATION, + .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(MigrationState), .instance_init =3D migration_instance_init, + .instance_post_init =3D migration_instance_post_init, .instance_finalize =3D migration_instance_finalize, }; =20 diff --git a/migration/options.c b/migration/options.c index 5cbfd29099..1cc99382d3 100644 --- a/migration/options.c +++ b/migration/options.c @@ -54,7 +54,7 @@ /* The delay time (in ms) between two COLO checkpoints */ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100) #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 -#define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE +#define DEFAULT_MIGRATE_MULTIFD_COMPRESSION "none" /* 0: means nocompress, 1: best speed, ... 9: best compress ratio */ #define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1 /* @@ -81,216 +81,355 @@ #define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5 #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100 =20 -#define DEFINE_PROP_MIG_CAP(name, x) \ - DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false) - -const PropertyInfo qdev_prop_StrOrNull; -#define DEFINE_PROP_STR_OR_NULL(_name, _state, _field) \ - DEFINE_PROP(_name, _state, _field, qdev_prop_StrOrNull, StrOrNull *, \ - .set_default =3D true) - #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD 1000 /* millisecond= s */ #define DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT 1 /* MB/s */ #define DEFAULT_MIGRATE_X_RDMA_CHUNK_SIZE MiB =20 -const Property migration_properties[] =3D { - DEFINE_PROP_BOOL("store-global-state", MigrationState, - store_global_state, true), - DEFINE_PROP_BOOL("send-configuration", MigrationState, - send_configuration, true), - DEFINE_PROP_BOOL("send-section-footer", MigrationState, - send_section_footer, true), - DEFINE_PROP_BOOL("send-switchover-start", MigrationState, - send_switchover_start, true), - DEFINE_PROP_BOOL("multifd-flush-after-each-section", MigrationState, - multifd_flush_after_each_section, false), - DEFINE_PROP_UINT8("x-clear-bitmap-shift", MigrationState, - clear_bitmap_shift, CLEAR_BITMAP_SHIFT_DEFAULT), - DEFINE_PROP_BOOL("x-preempt-pre-7-2", MigrationState, - preempt_pre_7_2, false), - DEFINE_PROP_BOOL("multifd-clean-tls-termination", MigrationState, - multifd_clean_tls_termination, true), - - /* Migration parameters */ - DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState, - parameters.throttle_trigger_threshold, - DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD), - DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState, - parameters.cpu_throttle_initial, - DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL), - DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState, - parameters.cpu_throttle_increment, - DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT), - DEFINE_PROP_BOOL("x-cpu-throttle-tailslow", MigrationState, - parameters.cpu_throttle_tailslow, false), - DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState, - parameters.max_bandwidth, MAX_THROTTLE), - DEFINE_PROP_SIZE("avail-switchover-bandwidth", MigrationState, - parameters.avail_switchover_bandwidth, 0), - DEFINE_PROP_UINT64("x-downtime-limit", MigrationState, - parameters.downtime_limit, - DEFAULT_MIGRATE_SET_DOWNTIME), - DEFINE_PROP_UINT32("x-checkpoint-delay", MigrationState, - parameters.x_checkpoint_delay, - DEFAULT_MIGRATE_X_CHECKPOINT_DELAY), - DEFINE_PROP_UINT8("multifd-channels", MigrationState, - parameters.multifd_channels, - DEFAULT_MIGRATE_MULTIFD_CHANNELS), - DEFINE_PROP_MULTIFD_COMPRESSION("multifd-compression", MigrationState, - parameters.multifd_compression, - DEFAULT_MIGRATE_MULTIFD_COMPRESSION), - DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState, - parameters.multifd_zlib_level, - DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL), - DEFINE_PROP_UINT8("multifd-qatzip-level", MigrationState, - parameters.multifd_qatzip_level, - DEFAULT_MIGRATE_MULTIFD_QATZIP_LEVEL), - DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState, - parameters.multifd_zstd_level, - DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL), - DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, - parameters.xbzrle_cache_size, - DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), - DEFINE_PROP_SIZE("max-postcopy-bandwidth", MigrationState, - parameters.max_postcopy_bandwidth, - DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH), - DEFINE_PROP_UINT8("max-cpu-throttle", MigrationState, - parameters.max_cpu_throttle, - DEFAULT_MIGRATE_MAX_CPU_THROTTLE), - DEFINE_PROP_SIZE("announce-initial", MigrationState, - parameters.announce_initial, - DEFAULT_MIGRATE_ANNOUNCE_INITIAL), - DEFINE_PROP_SIZE("announce-max", MigrationState, - parameters.announce_max, - DEFAULT_MIGRATE_ANNOUNCE_MAX), - DEFINE_PROP_SIZE("announce-rounds", MigrationState, - parameters.announce_rounds, - DEFAULT_MIGRATE_ANNOUNCE_ROUNDS), - DEFINE_PROP_SIZE("announce-step", MigrationState, - parameters.announce_step, - DEFAULT_MIGRATE_ANNOUNCE_STEP), - DEFINE_PROP_STR_OR_NULL("tls-creds", MigrationState, parameters.tls_cr= eds), - DEFINE_PROP_STR_OR_NULL("tls-hostname", MigrationState, - parameters.tls_hostname), - DEFINE_PROP_STR_OR_NULL("tls-authz", MigrationState, parameters.tls_au= thz), - DEFINE_PROP_UINT64("x-vcpu-dirty-limit-period", MigrationState, - parameters.x_vcpu_dirty_limit_period, - DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD), - DEFINE_PROP_UINT64("vcpu-dirty-limit", MigrationState, - parameters.vcpu_dirty_limit, - DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT), - DEFINE_PROP_MIG_MODE("mode", MigrationState, - parameters.mode, - MIG_MODE_NORMAL), - DEFINE_PROP_ZERO_PAGE_DETECTION("zero-page-detection", MigrationState, - parameters.zero_page_detection, - ZERO_PAGE_DETECTION_MULTIFD), - DEFINE_PROP_UINT64("x-rdma-chunk-size", MigrationState, - parameters.x_rdma_chunk_size, - DEFAULT_MIGRATE_X_RDMA_CHUNK_SIZE), - - /* Migration capabilities */ - DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), - DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_AL= L), - DEFINE_PROP_MIG_CAP("x-auto-converge", MIGRATION_CAPABILITY_AUTO_CONVE= RGE), - DEFINE_PROP_MIG_CAP("x-events", MIGRATION_CAPABILITY_EVENTS), - DEFINE_PROP_MIG_CAP("x-postcopy-ram", MIGRATION_CAPABILITY_POSTCOPY_RA= M), - DEFINE_PROP_MIG_CAP("x-postcopy-preempt", - MIGRATION_CAPABILITY_POSTCOPY_PREEMPT), - DEFINE_PROP_MIG_CAP("postcopy-blocktime", - MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME), - DEFINE_PROP_MIG_CAP("x-colo", MIGRATION_CAPABILITY_X_COLO), - DEFINE_PROP_MIG_CAP("x-release-ram", MIGRATION_CAPABILITY_RELEASE_RAM), - DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH), - DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD), - DEFINE_PROP_MIG_CAP("x-background-snapshot", - MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT), -#ifdef CONFIG_LINUX - DEFINE_PROP_MIG_CAP("x-zero-copy-send", - MIGRATION_CAPABILITY_ZERO_COPY_SEND), -#endif - DEFINE_PROP_MIG_CAP("x-switchover-ack", - MIGRATION_CAPABILITY_SWITCHOVER_ACK), - DEFINE_PROP_MIG_CAP("x-dirty-limit", MIGRATION_CAPABILITY_DIRTY_LIMIT), - DEFINE_PROP_MIG_CAP("mapped-ram", MIGRATION_CAPABILITY_MAPPED_RAM), - DEFINE_PROP_MIG_CAP("x-ignore-shared", - MIGRATION_CAPABILITY_X_IGNORE_SHARED), -}; -const size_t migration_properties_count =3D ARRAY_SIZE(migration_propertie= s); - -static void get_StrOrNull(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static void migration_object_init_props_bool(MigrationState *s) { - const Property *prop =3D opaque; - StrOrNull **ptr =3D object_field_prop_ptr(obj, prop); - StrOrNull *str_or_null =3D *ptr; + Object *obj =3D OBJECT(s); + int i; =20 - /* - * The property should never be NULL because it's part of - * s->parameters and a default value is always set by qdev. It - * should also never be QNULL as the setter doesn't allow it. - */ - assert(str_or_null && str_or_null->type !=3D QTYPE_QNULL); - visit_type_str(v, name, &str_or_null->u.s, errp); + struct MigPropBool { + const char *name; + void *ptr; + bool defvar; + } bool_list[] =3D { + { + "store-global-state", + &s->store_global_state, + true, + }, + { + "send-configuration", + &s->send_configuration, + true, + }, + { + "send-section-footer", + &s->send_section_footer, + true, + }, + { + "send-switchover-start", + &s->send_switchover_start, + true, + }, + { + "x-preempt-pre-7-2", + &s->preempt_pre_7_2, + false, + }, + { + "x-cpu-throttle-tailslow", + &s->parameters.cpu_throttle_tailslow, + false, + }, + { + "multifd-clean-tls-termination", + &s->multifd_clean_tls_termination, + true, + }, + { + "multifd-flush-after-each-section", + &s->multifd_flush_after_each_section, + false, + }, + }; + struct MigPropBool *prop; + + for (i =3D 0; i < ARRAY_SIZE(bool_list); i++) { + prop =3D &bool_list[i]; + object_property_add_bool_ptr_def(obj, prop->name, + prop->ptr, prop->defvar); + } } =20 -static void set_StrOrNull(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static void migration_object_init_props_uint8(MigrationState *s) { - const Property *prop =3D opaque; - StrOrNull **ptr =3D object_field_prop_ptr(obj, prop); - StrOrNull *str_or_null; - char *str; + Object *obj =3D OBJECT(s); + int i; =20 - if (!visit_type_str(v, name, &str, errp)) { - return; - } + struct MigPropUint8 { + const char *name; + void *ptr; + uint8_t defvar; + } uint8_list[] =3D { + { + "clear-bitmap-shift", + &s->clear_bitmap_shift, + CLEAR_BITMAP_SHIFT_DEFAULT, + }, + { + "throttle-trigger-threshold", + &s->parameters.throttle_trigger_threshold, + DEFAULT_MIGRATE_THROTTLE_TRIGGER_THRESHOLD, + }, + { + "cpu-throttle-initial", + &s->parameters.cpu_throttle_initial, + DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, + }, + { + "cpu-throttle-increment", + &s->parameters.cpu_throttle_increment, + DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + }, + { + "multifd-channels", + &s->parameters.multifd_channels, + DEFAULT_MIGRATE_MULTIFD_CHANNELS, + }, + { + "multifd-zlib-level", + &s->parameters.multifd_zlib_level, + DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL, + }, + { + "multifd-qatzip-level", + &s->parameters.multifd_qatzip_level, + DEFAULT_MIGRATE_MULTIFD_QATZIP_LEVEL, + }, + { + "multifd-zstd-level", + &s->parameters.multifd_zstd_level, + DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL, + }, + { + "max-cpu-throttle", + &s->parameters.max_cpu_throttle, + DEFAULT_MIGRATE_MAX_CPU_THROTTLE, + }, + }; + struct MigPropUint8 *prop; =20 - /* - * This property only applies to the command line usage of - * migration's TLS options (-global migration.tls-*) where the - * NULL value cannot be provided as input (only strings are - * allowed). Therefore, this StrOrNull implementation never - * produces a QNULL value to avoid ever returning values outside - * the range of what was previously handled by consumers of the - * TLS options. - */ - str_or_null =3D g_new0(StrOrNull, 1); - str_or_null->type =3D QTYPE_QSTRING; - str_or_null->u.s =3D str; + for (i =3D 0; i < ARRAY_SIZE(uint8_list); i++) { + prop =3D &uint8_list[i]; + object_property_add_uint8_ptr_def(obj, prop->name, + prop->ptr, prop->defvar); + } +} =20 - qapi_free_StrOrNull(*ptr); - *ptr =3D str_or_null; +static void migration_object_init_props_uint32(MigrationState *s) +{ + object_property_add_uint32_ptr_def(OBJECT(s), "x-checkpoint-delay", + &s->parameters.x_checkpoint_delay, + DEFAULT_MIGRATE_X_CHECKPOINT_DELAY); } =20 -static void release_StrOrNull(Object *obj, const char *name, void *opaque) +static void migration_object_init_props_uint64(MigrationState *s) { - const Property *prop =3D opaque; - qapi_free_StrOrNull(*(StrOrNull **)object_field_prop_ptr(obj, prop)); + Object *obj =3D OBJECT(s); + int i; + + struct MigPropUint64 { + const char *name; + void *ptr; + uint64_t defvar; + } uint64_list[] =3D { + { + "downtime-limit", + &s->parameters.downtime_limit, + DEFAULT_MIGRATE_SET_DOWNTIME, + }, + { + "x-vcpu-dirty-limit-period", + &s->parameters.x_vcpu_dirty_limit_period, + DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT_PERIOD, + }, + { + "vcpu-dirty-limit", + &s->parameters.vcpu_dirty_limit, + DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT, + }, + { + "x-rdma-chunk-size", + &s->parameters.x_rdma_chunk_size, + DEFAULT_MIGRATE_X_RDMA_CHUNK_SIZE, + }, + }; + struct MigPropUint64 *prop; + + for (i =3D 0; i < ARRAY_SIZE(uint64_list); i++) { + prop =3D &uint64_list[i]; + object_property_add_uint64_ptr_def(obj, prop->name, + prop->ptr, prop->defvar); + } } =20 -static void set_default_value_tls_opt(ObjectProperty *op, const Property *= prop) +static void migration_object_init_props_size(MigrationState *s) { - /* - * Initialization to the empty string here is important so - * query-migrate-parameters doesn't need to deal with a NULL value - * when it's called before any TLS option has been set. - */ - object_property_set_default_str(op, ""); + Object *obj =3D OBJECT(s); + int i; + + struct MigPropSize { + const char *name; + void *ptr; + uint64_t defvar; + } size_list[] =3D { + { + "xbzrle-cache-size", + &s->parameters.xbzrle_cache_size, + DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE, + }, + { + "max-postcopy-bandwidth", + &s->parameters.max_postcopy_bandwidth, + DEFAULT_MIGRATE_MAX_POSTCOPY_BANDWIDTH, + }, + { + "announce-initial", + &s->parameters.announce_initial, + DEFAULT_MIGRATE_ANNOUNCE_INITIAL, + }, + { + "announce-max", + &s->parameters.announce_max, + DEFAULT_MIGRATE_ANNOUNCE_MAX, + }, + { + "announce-rounds", + &s->parameters.announce_rounds, + DEFAULT_MIGRATE_ANNOUNCE_ROUNDS, + }, + { + "announce-step", + &s->parameters.announce_step, + DEFAULT_MIGRATE_ANNOUNCE_STEP, + }, + { + "max-bandwidth", + &s->parameters.max_bandwidth, + MAX_THROTTLE, + }, + { + "avail-switchover-bandwidth", + &s->parameters.avail_switchover_bandwidth, + 0, + }, + }; + struct MigPropSize *prop; + + for (i =3D 0; i < ARRAY_SIZE(size_list); i++) { + prop =3D &size_list[i]; + object_property_add_size_ptr_def(obj, prop->name, + prop->ptr, prop->defvar); + } } =20 -/* - * String property like qdev_prop_string, except it's backed by a - * StrOrNull instead of a char *. This is intended for - * TYPE_MIGRATION's TLS options. - */ -const PropertyInfo qdev_prop_StrOrNull =3D { - .type =3D "StrOrNull", - .get =3D get_StrOrNull, - .set =3D set_StrOrNull, - .release =3D release_StrOrNull, - .set_default_value =3D set_default_value_tls_opt, -}; +static void migration_object_init_props_caps(MigrationState *s) +{ + Object *obj =3D OBJECT(s); + int i; + + /* Migration capabilties are always turned off by default */ + for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { + object_property_add_bool_ptr_def(obj, + MigrationCapability_str(i), + &s->capabilities[i], + false); + } +} + +#define DEFINE_TLS_PROP_HELPERS(varname) \ + static char *mig_prop_##varname##_get(Object *obj, Error **errp) \ + { \ + MigrationState *s =3D MIGRATION(obj); \ + StrOrNull *var =3D s->parameters.varname; \ + \ + assert(var->type =3D=3D QTYPE_QSTRING); = \ + return g_strdup(var->u.s); \ + } \ + \ + static void mig_prop_##varname##_set(Object *obj, const char *str, \ + Error **errp) \ + { \ + MigrationState *s =3D MIGRATION(obj); \ + StrOrNull *new =3D g_new0(StrOrNull, 1); \ + \ + qapi_free_StrOrNull(s->parameters.varname); \ + \ + new->type =3D QTYPE_QSTRING; \ + new->u.s =3D g_strdup(str); \ + s->parameters.varname =3D new; \ + } + +DEFINE_TLS_PROP_HELPERS(tls_creds) +DEFINE_TLS_PROP_HELPERS(tls_authz) +DEFINE_TLS_PROP_HELPERS(tls_hostname) + +static void migration_object_init_props_tls(MigrationState *s) +{ + Object *obj =3D OBJECT(s); + ObjectProperty *prop; + + prop =3D object_property_add_str(obj, "tls-creds", + mig_prop_tls_creds_get, + mig_prop_tls_creds_set); + object_property_set_default_str(prop, ""); + + prop =3D object_property_add_str(obj, "tls-hostname", + mig_prop_tls_hostname_get, + mig_prop_tls_hostname_set); + object_property_set_default_str(prop, ""); + + prop =3D object_property_add_str(obj, "tls-authz", + mig_prop_tls_authz_get, + mig_prop_tls_authz_set); + object_property_set_default_str(prop, ""); +} + +#define DEFINE_ENUM_PROP_HELPERS(param_name) \ + static int mig_prop_##param_name##_get(Object *obj, Error **errp) \ + { \ + return (int) MIGRATION(obj)->parameters.param_name; \ + } \ + \ + static void mig_prop_##param_name##_set(Object *obj, int val, \ + Error **errp) \ + { \ + MIGRATION(obj)->parameters.param_name =3D val; \ + } + +DEFINE_ENUM_PROP_HELPERS(multifd_compression) +DEFINE_ENUM_PROP_HELPERS(zero_page_detection) +DEFINE_ENUM_PROP_HELPERS(mode) + +static void migration_object_init_props_enum(MigrationState *s) +{ + Object *obj =3D OBJECT(s); + ObjectProperty *prop; + + prop =3D object_property_add_enum(obj, "multifd-compression", + "MultiFDCompression", + &MultiFDCompression_lookup, + mig_prop_multifd_compression_get, + mig_prop_multifd_compression_set); + object_property_set_default_str(prop, DEFAULT_MIGRATE_MULTIFD_COMPRESS= ION); + + prop =3D object_property_add_enum(obj, "mode", "MigMode", &MigMode_loo= kup, + mig_prop_mode_get, mig_prop_mode_set); + object_property_set_default_str(prop, "normal"); + + prop =3D object_property_add_enum(obj, "zero-page-detection", + "ZeroPageDetection", + &ZeroPageDetection_lookup, + mig_prop_zero_page_detection_get, + mig_prop_zero_page_detection_set); + object_property_set_default_str(prop, "multifd"); +} + +static void migration_object_init_properties(MigrationState *s) +{ + migration_object_init_props_bool(s); + migration_object_init_props_uint8(s); + migration_object_init_props_uint32(s); + migration_object_init_props_uint64(s); + migration_object_init_props_size(s); + migration_object_init_props_caps(s); + migration_object_init_props_tls(s); + migration_object_init_props_enum(s); +} =20 bool migrate_auto_converge(void) { @@ -1107,9 +1246,10 @@ MigrationParameters *qmp_query_migrate_parameters(Er= ror **errp) return params; } =20 -void migrate_params_init(MigrationParameters *params) +void migrate_params_init(MigrationState *s) { - migrate_mark_all_params_present(params); + migration_object_init_properties(s); + migrate_mark_all_params_present(&s->parameters); } =20 static void migrate_post_update_params(MigrationParameters *new, Error **e= rrp) --=20 2.53.0