All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Yonggang Luo <luoyonggang@gmail.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-arm@nongnu.org, "Song Gao" <17746591750@163.com>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Philippe Mathieu-Daude" <philmd@mailo.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Fam Zheng" <fam@euphon.net>, "Max Filippov" <jcmvbkbc@gmail.com>,
	qemu-s390x@nongnu.org, "Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>
Subject: Re: [PATCH v2 11/12] hw/virtio/virtio-mem: register legacy-guest variant with is_available
Date: Thu, 5 Nov 2026 11:07:37 +0000	[thread overview]
Message-ID: <auxjeTD9e3H2dHlj@redhat.com> (raw)
In-Reply-To: <20261031164009.2048-12-luoyonggang@gmail.com>

On Sun, Nov 01, 2026 at 12:40:06AM +0800, Yonggang Luo wrote:
> virtio-mem decided in class_init and realize whether x86 guests can
> leave unplugged memory accessible. Register a second virtio-mem type
> that adds virtio_mem_legacy_guests_properties and sets
> VirtIOMEMClass.has_legacy_guests. Select the two with
> target_base_i386() and target_not_base_i386().
> 
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  hw/virtio/virtio-mem.c         | 52 +++++++++++++++++++++-------------
>  include/hw/virtio/virtio-mem.h |  2 ++
>  2 files changed, 34 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> index ee6a0c206af..ab2864d18c3 100644
> --- a/hw/virtio/virtio-mem.c
> +++ b/hw/virtio/virtio-mem.c
> @@ -15,6 +15,7 @@
>  #include "qemu/cutils.h"
>  #include "qemu/error-report.h"
>  #include "qemu/units.h"
> +#include "qemu/target-info.h"
>  #include "qemu/target-info-qapi.h"
>  #include "system/memory.h"
>  #include "system/numa.h"
> @@ -35,22 +36,6 @@
>  
>  static const VMStateDescription vmstate_virtio_mem_device_early;
>  
> -static bool virtio_mem_has_legacy_guests(void)
> -{
> -    /*
> -     * We only had legacy x86 guests that did not support
> -     * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have
> -     * legacy guests.
> -     */
> -    switch (target_arch()) {
> -    case SYS_EMU_TARGET_I386:
> -    case SYS_EMU_TARGET_X86_64:
> -        return true;
> -    default:
> -        return false;
> -    }
> -}
> -
>  /*
>   * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking
>   * bitmap small.
> @@ -859,7 +844,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
>      rb = vmem->memdev->mr.ram_block;
>      page_size = qemu_ram_pagesize(rb);
>  
> -    if (virtio_mem_has_legacy_guests()) {
> +    if (VIRTIO_MEM_GET_CLASS(vmem)->has_legacy_guests) {
>          switch (vmem->unplugged_inaccessible) {
>          case ON_OFF_AUTO_AUTO:
>              if (virtio_mem_has_shared_zeropage(rb)) {
> @@ -1635,9 +1620,6 @@ static void virtio_mem_class_init(ObjectClass *klass, const void *data)
>      RamDiscardSourceClass *rdsc = RAM_DISCARD_SOURCE_CLASS(klass);
>  
>      device_class_set_props(dc, virtio_mem_properties);
> -    if (virtio_mem_has_legacy_guests()) {
> -        device_class_set_props(dc, virtio_mem_legacy_guests_properties);
> -    }

Again IMHO the conditional property registration is an
unneccessary step. Just fold virtio_mem_legacy_guests_properties
into virtio_mem_properties.

In the realize() method, check virtio_mem_has_legacy_guests()
and reject values that are invalid for the non-x86 targets.


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-11-05 11:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31 16:39 [PATCH v2 00/12] qom: resolve type name conflicts, avoid target_info() in class_init or type_init Yonggang Luo
2026-10-31 16:39 ` [PATCH v2 01/12] target-info: add target_loongarch() Yonggang Luo
2026-10-31 16:39 ` [PATCH v2 02/12] hw/loongarch/virt: select virt machine types with is_available Yonggang Luo
2026-10-31 16:39 ` [PATCH v2 03/12] target-info: add target_xtensa() Yonggang Luo
2026-10-31 16:39 ` [PATCH v2 04/12] hw/xtensa: expand DEFINE_MACHINE in virt.c Yonggang Luo
2026-11-01  3:15   ` Yonggang Luo
2026-10-31 16:40 ` [PATCH v2 05/12] hw/xtensa/virt: select virt machine types with is_available Yonggang Luo
2026-10-31 16:40 ` [PATCH v2 06/12] target/arm: register separate max-v8 CPU types for arm and aarch64 Yonggang Luo
2026-11-05 10:55   ` Daniel P. Berrangé
2026-11-05 11:14     ` Yonggang Luo
2026-11-05 12:42       ` Daniel P. Berrangé
2026-11-05 13:25         ` Yonggang Luo
2026-11-05 14:16           ` Daniel P. Berrangé
2026-11-05 13:45         ` Peter Maydell
2026-11-05 13:48           ` Daniel P. Berrangé
2026-11-05 13:56             ` Peter Maydell
2026-11-05 14:03               ` Daniel P. Berrangé
2026-10-31 16:40 ` [PATCH v2 07/12] hw/scsi/scsi-disk: register s390x scsi-hd and scsi-cd variants Yonggang Luo
2026-11-05 11:02   ` Daniel P. Berrangé
2026-10-31 16:40 ` [PATCH v2 08/12] hw/virtio/virtio-pci: pass is_available through VirtioPCIDeviceTypeInfo Yonggang Luo
2026-10-31 16:40 ` [PATCH v2 09/12] hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants Yonggang Luo
2026-11-05 11:03   ` Daniel P. Berrangé
2026-11-05 11:20     ` Yonggang Luo
2026-11-05 11:38       ` Daniel P. Berrangé
2026-10-31 16:40 ` [PATCH v2 10/12] target-info: add target_base_i386() Yonggang Luo
2026-10-31 16:40 ` [PATCH v2 11/12] hw/virtio/virtio-mem: register legacy-guest variant with is_available Yonggang Luo
2026-11-05 11:07   ` Daniel P. Berrangé [this message]
2026-10-31 16:40 ` [PATCH v2 12/12] hw/microblaze: defer PetaLogix endianness default until init Yonggang Luo

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=auxjeTD9e3H2dHlj@redhat.com \
    --to=berrange@redhat.com \
    --cc=17746591750@163.com \
    --cc=cohuck@redhat.com \
    --cc=david@kernel.org \
    --cc=edgar.iglesias@gmail.com \
    --cc=fam@euphon.net \
    --cc=farman@linux.ibm.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=luoyonggang@gmail.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@mailo.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.