qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 00/16] qom/object: Deprecate type_register()
Date: Wed, 11 Dec 2024 00:20:45 +0800	[thread overview]
Message-ID: <Z1hqXesuVF93B36S@intel.com> (raw)
In-Reply-To: <20241029085934.2799066-1-zhao1.liu@intel.com>

Hi Paolo and Dainel,

Kindly ping. Do you agree with this idea?

Thanks,
Zhao

On Tue, Oct 29, 2024 at 04:59:18PM +0800, Zhao Liu wrote:
> Date: Tue, 29 Oct 2024 16:59:18 +0800
> From: Zhao Liu <zhao1.liu@intel.com>
> Subject: [PATCH 00/16] qom/object: Deprecate type_register()
> X-Mailer: git-send-email 2.34.1
> 
> Hi maintainers,
> 
> This series is trying to deprecate type_register() and just keep
> type_register_static() to register QOM type.
> 
> This series chosen to deprecate type_register() since changes required
> to deprecate type_register() are smaller. (type_register_static() needs
> 1000+ LOC changes.)
> 
> The two main changes are patch 15 and 16, while the others are trivial
> replacements.
> 
> This series is based on commit fdf250e5a37830 ("Merge tag
> 'pull-maintainer-oct-misc-241024-1' of https://gitlab.com/stsquad/qemu
> into staging").
> 
> 
> Introduction
> ============
> 
> The type_register() and type_register_static() have existed since the
> birth of QOM (commit 2f28d2ff9dce ("qom: add the base Object class
> (v2)")).
> 
> In the code implementation, type_register_static() has always been just
> a wrapper around type_register(), and they are essentially the same.
> 
> The only difference between them is described in the documentation 
> (include/qom/object.h):
> 
> * type_register_static()
> 
> > @info and all of the strings it points to should exist for the life time
> > that the type is registered.
> 
> * type_register()
> 
> > Unlike type_register_static(), this call does not require @info or its
> > string members to continue to exist after the call returns.
> 
> From the documentation, the difference between these two interfaces
> arises from the lifetime of 2 cases:
> 
> 1. the strings contained in the TypeInfo parameter.
> 
> The *_static variant requires the strings to have a long lifetime
> (static).
> 
> I reviewed the discussions on the mailing list about the QOM v1 patch
> [1], and I understand that the consideration for static is due to
> Anthony's idea that in certain cases, the string field could be "const
> char *", allowing the address to be directly copied to the created
> Type/TypeImpl.
> 
> However, this consideration seems unnecessary in the merged v2 version,
> as Anthony followed Paolo's suggestion to pass all string fields by
> copying them via g_strdup() to the created TypeImple. This remains true
> to this day.
> 
> [1]: https://lore.kernel.org/qemu-devel/4EF1EEA4.40209@us.ibm.com/
> 
> 
> 2. the function pointer and a special item called "class_data" in
> TypeInfo
> 
> I suppose that there are currently no lifetime issues about these items
> in QEMU, as neither type_register() nor type_register_static()
> explicitly checks whether the parameters are static. If there were any
> issues, they would likely be easily detected.
> 
> Furthermore, I haven't seen any preference for these items in the usage
> of type_register() and type_register_static().
> 
> 
> Based on points 1 and 2, I think it is sufficient to explain that
> type_register() and type_register_static() are redundant in usage and do
> not require distinction. Additionally, since they are consistent in the
> code, it is safe to deprecate either one.
> 
> Since the changes required to deprecate type_register() are smaller,
> choose to deprecate type_register() and delete the requirement about
> string lifetime from the documentation.
> 
> 
> Thanks and Best Regards,
> Zhao
> ---
> Zhao Liu (16):
>   arm: Replace type_register() with type_register_static()
>   hw/block: Replace type_register() with type_register_static()
>   hw/net: Replace type_register() with type_register_static()
>   ppc: Replace type_register() with type_register_static()
>   hw/rtc: Replace type_register() with type_register_static()
>   hw/scsi: Replace type_register() with type_register_static()
>   hw/sensor: Replace type_register() with type_register_static()
>   hw/usb: Replace type_register() with type_register_static()
>   hw/virtio: Replace type_register() with type_register_static()
>   i386: Replace type_register() with type_register_static()
>   target/mips: Replace type_register() with type_register_static()
>   target/sparc: Replace type_register() with type_register_static()
>   target/xtensa: Replace type_register() with type_register_static()
>   ui: Replace type_register() with type_register_static()
>   script/codeconverter/qom_type_info: Deprecate MakeTypeRegisterStatic
>     and MakeTypeRegisterNotStatic
>   qom/object: Deprecate type_register()
> 
>  hw/arm/armsse.c                               |  2 +-
>  hw/arm/smmuv3.c                               |  4 ++--
>  hw/block/m25p80.c                             |  2 +-
>  hw/net/e1000.c                                |  2 +-
>  hw/net/eepro100.c                             |  2 +-
>  hw/ppc/spapr.c                                |  2 +-
>  hw/rtc/m48t59-isa.c                           |  2 +-
>  hw/rtc/m48t59.c                               |  2 +-
>  hw/scsi/megasas.c                             |  2 +-
>  hw/scsi/mptsas.c                              |  2 +-
>  hw/sensor/tmp421.c                            |  2 +-
>  hw/usb/hcd-ehci-pci.c                         |  2 +-
>  hw/usb/hcd-uhci.c                             |  2 +-
>  hw/virtio/virtio-pci.c                        |  8 ++++----
>  include/hw/i386/pc.h                          |  4 ++--
>  include/qom/object.h                          | 14 -------------
>  qom/object.c                                  |  7 +------
>  .../codeconverter/qom_type_info.py            | 20 -------------------
>  target/arm/cpu.c                              |  2 +-
>  target/arm/cpu64.c                            |  2 +-
>  target/i386/cpu.c                             |  2 +-
>  target/mips/cpu.c                             |  2 +-
>  target/ppc/kvm.c                              |  2 +-
>  target/sparc/cpu.c                            |  2 +-
>  target/xtensa/helper.c                        |  2 +-
>  ui/console-vc.c                               |  2 +-
>  ui/dbus.c                                     |  2 +-
>  ui/gtk.c                                      |  2 +-
>  ui/spice-app.c                                |  2 +-
>  29 files changed, 32 insertions(+), 71 deletions(-)
> 
> -- 
> 2.34.1
> 


  parent reply	other threads:[~2024-12-10 16:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29  8:59 [PATCH 00/16] qom/object: Deprecate type_register() Zhao Liu
2024-10-29  8:59 ` [PATCH 01/16] arm: Replace type_register() with type_register_static() Zhao Liu
2024-10-29  8:59 ` [PATCH 02/16] hw/block: " Zhao Liu
2024-10-29  8:59 ` [PATCH 03/16] hw/net: " Zhao Liu
2024-10-29  8:59 ` [PATCH 04/16] ppc: " Zhao Liu
2024-10-29  8:59 ` [PATCH 05/16] hw/rtc: " Zhao Liu
2024-10-29  8:59 ` [PATCH 06/16] hw/scsi: " Zhao Liu
2024-10-29  8:59 ` [PATCH 07/16] hw/sensor: " Zhao Liu
2024-10-29  8:59 ` [PATCH 08/16] hw/usb: " Zhao Liu
2024-10-29  8:59 ` [PATCH 09/16] hw/virtio: " Zhao Liu
2024-10-29  8:59 ` [PATCH 10/16] i386: " Zhao Liu
2024-10-29  8:59 ` [PATCH 11/16] target/mips: " Zhao Liu
2024-10-29  8:59 ` [PATCH 12/16] target/sparc: " Zhao Liu
2024-10-29  8:59 ` [PATCH 13/16] target/xtensa: " Zhao Liu
2024-10-29  8:59 ` [PATCH 14/16] ui: " Zhao Liu
2024-10-29  8:59 ` [PATCH 15/16] script/codeconverter/qom_type_info: Deprecate MakeTypeRegisterStatic and MakeTypeRegisterNotStatic Zhao Liu
2024-10-29  8:59 ` [PATCH 16/16] qom/object: Deprecate type_register() Zhao Liu
2024-12-10 16:20 ` Zhao Liu [this message]
2024-12-10 17:43 ` [PATCH 00/16] " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z1hqXesuVF93B36S@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).