Skip to contentSkip to conversation

hw/virtio: Build virtio-mem.c once

PATCH Superseded Philippe Mathieu-Daudé 2 participants 10 messages Mar 7, 2025 – Mar 8, 2025 Arm/Amlogic Meson SoC support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover hw/virtio: Build virtio-mem.c once

Missing review: #5 (reworked, R-b tags dropped)

Since v1:
- Use max extent size of all archs (David)

Replace compile-time checks by runtime ones:
- CONFIG_DEVICES::CONFIG_ACPI -> acpi_builtin()
- TARGET_FOO || TARGET_BAR -> qemu_arch_available(FOO|BAR)

Philippe Mathieu-Daudé (7):
system: Replace arch_type global by qemu_arch_available() helper hw/acpi: Introduce acpi_builtin() helper
hw/i386/fw_cfg: Check ACPI availability with acpi_builtin() hw/virtio/virtio-mem: Remove CONFIG_DEVICES include hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime hw/virtio/virtio-mem: Convert VIRTIO_MEM_HAS_LEGACY_GUESTS to runtime hw/virtio: Compile virtio-mem.c once

 include/hw/acpi/acpi.h     |  3 ++
 include/system/arch_init.h |  2 +-
 hw/acpi/acpi-stub.c        |  5 ++
 hw/acpi/core.c             |  5 ++
 hw/i386/fw_cfg.c           |  8 ++--
 hw/scsi/scsi-disk.c        |  2 +-
 hw/virtio/virtio-mem.c     | 96 +++++++++++++++++++++-----------------
 system/arch_init.c         |  5 +-
 system/qdev-monitor.c      |  4 +-
 system/vl.c                |  6 +--
 hw/virtio/meson.build      |  2 +-
 11 files changed, 83 insertions(+), 55 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH v2 1/7 system: Replace arch_type global by qemu_arch_available() helper

qemu_arch_available() is a bit simpler to understand while reviewing than the undocumented arch_type variable.

---
 include/system/arch_init.h | 2 +-
 hw/scsi/scsi-disk.c        | 2 +-
 system/arch_init.c         | 5 ++++-
 system/qdev-monitor.c      | 4 ++--
 system/vl.c                | 6 +++---
 5 files changed, 11 insertions(+), 8 deletions(-)
include/system/arch_init.h +1 -1
index d8b77440487..51e24c3091e 100644
@@ -25,6 +25,6 @@ enum {
     QEMU_ARCH_LOONGARCH = (1 << 23),
 };
 
-extern const uint32_t arch_type;
+bool qemu_arch_available(unsigned qemu_arch_mask);
 
 #endif
hw/scsi/scsi-disk.c +1 -1
index e7f738b4841..7c87b20e694 100644
@@ -3165,7 +3165,7 @@ static void scsi_property_add_specifics(DeviceClass *dc)
     ObjectClass *oc = OBJECT_CLASS(dc);
 
     /* The loadparm property is only supported on s390x */
-    if (arch_type & QEMU_ARCH_S390X) {
+    if (qemu_arch_available(QEMU_ARCH_S390X)) {
         object_class_property_add_str(oc, "loadparm",
                                       scsi_property_get_loadparm,
                                       scsi_property_set_loadparm);
system/arch_init.c +4 -1
index b1baed18a30..61c6f680c94 100644
@@ -38,4 +38,7 @@ int graphic_height = 600;
 int graphic_depth = 32;
 #endif
 
-const uint32_t arch_type = QEMU_ARCH;
+bool qemu_arch_available(unsigned qemu_arch_mask)
+{
+    return qemu_arch_mask & QEMU_ARCH;
+}
system/qdev-monitor.c +2 -2
index 856c9e8c32e..5588ed2047d 100644
@@ -132,7 +132,7 @@ static const char *qdev_class_get_alias(DeviceClass *dc)
 
     for (i = 0; qdev_alias_table[i].typename; i++) {
         if (qdev_alias_table[i].arch_mask &&
-            !(qdev_alias_table[i].arch_mask & arch_type)) {
+            !qemu_arch_available(qdev_alias_table[i].arch_mask)) {
             continue;
         }
 
@@ -218,7 +218,7 @@ static const char *find_typename_by_alias(const char *alias)
 
     for (i = 0; qdev_alias_table[i].alias; i++) {
         if (qdev_alias_table[i].arch_mask &&
-            !(qdev_alias_table[i].arch_mask & arch_type)) {
+            !qemu_arch_available(qdev_alias_table[i].arch_mask)) {
             continue;
         }
 
system/vl.c +3 -3
index 04f78466c41..ec93988a03a 100644
@@ -878,11 +878,11 @@ static void help(int exitcode)
             g_get_prgname());
 
 #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)    \
-    if ((arch_mask) & arch_type)                               \
+    if (qemu_arch_available(arch_mask)) \
         fputs(opt_help, stdout);
 
 #define ARCHHEADING(text, arch_mask) \
-    if ((arch_mask) & arch_type)    \
+    if (qemu_arch_available(arch_mask)) \
         puts(stringify(text));
 
 #define DEFHEADING(text) ARCHHEADING(text, QEMU_ARCH_ALL)
@@ -2929,7 +2929,7 @@ void qemu_init(int argc, char **argv)
             const QEMUOption *popt;
 
             popt = lookup_opt(argc, argv, &optarg, &optind);
-            if (!(popt->arch_mask & arch_type)) {
+            if (!qemu_arch_available(popt->arch_mask)) {
                 error_report("Option not supported for this target");
                 exit(1);
             }
Signature · 1 line
2.47.1
#2 lore raw

PATCH v2 2/7 hw/acpi: Introduce acpi_builtin() helper

In reply to Philippe Mathieu-Daudé

acpi_builtin() can be used to check at runtime whether the ACPI subsystem is built in a qemu-system binary.

---
 include/hw/acpi/acpi.h | 3 +++
 hw/acpi/acpi-stub.c    | 5 +++++
 hw/acpi/core.c         | 5 +++++
 3 files changed, 13 insertions(+)
include/hw/acpi/acpi.h +3 -0
index e0e51e85b41..d1a4fa2af84 100644
@@ -150,6 +150,9 @@ struct ACPIREGS {
     Notifier wakeup;
 };
 
+/* Return whether ACPI subsystem is built in */
+bool acpi_builtin(void);
+
 /* PM_TMR */
 void acpi_pm_tmr_update(ACPIREGS *ar, bool enable);
 void acpi_pm_tmr_calc_overflow_time(ACPIREGS *ar);
hw/acpi/acpi-stub.c +5 -0
index e268ce9b1a9..790bf509e5d 100644
@@ -25,3 +25,8 @@ void acpi_table_add(const QemuOpts *opts, Error **errp)
 {
     g_assert_not_reached();
 }
+
+bool acpi_builtin(void)
+{
+    return false;
+}
hw/acpi/core.c +5 -0
index 870391ed7c8..58f8964e130 100644
@@ -78,6 +78,11 @@ static void acpi_register_config(void)
 
 opts_init(acpi_register_config);
 
+bool acpi_builtin(void)
+{
+    return true;
+}
+
 static int acpi_checksum(const uint8_t *data, int len)
 {
     int sum, i;
Signature · 1 line
2.47.1
#3 lore raw

PATCH v2 3/7 hw/i386/fw_cfg: Check ACPI availability with acpi_builtin()

In reply to Philippe Mathieu-Daudé

Replace the compile-time CONFIG_ACPI check by a runtime one.

---
 hw/i386/fw_cfg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/fw_cfg.c +4 -4
index d08aefa0291..a7f1b60b98c 100644
@@ -145,10 +145,10 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms,
      */
     fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, apic_id_limit);
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, ms->ram_size);
-#ifdef CONFIG_ACPI
-    fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
-                     acpi_tables, acpi_tables_len);
-#endif
+    if (acpi_builtin()) {
+        fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
+                         acpi_tables, acpi_tables_len);
+    }
     fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1);
 
     fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_fw_cfg, sizeof(hpet_fw_cfg));
Signature · 1 line
2.47.1
#4 lore raw

PATCH v2 4/7 hw/virtio/virtio-mem: Remove CONFIG_DEVICES include

In reply to Philippe Mathieu-Daudé

Rather than checking ACPI availability at compile time by checking the CONFIG_ACPI definition from CONFIG_DEVICES, check at runtime via acpi_builtin().

---
 hw/virtio/virtio-mem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
hw/virtio/virtio-mem.c +2 -4
index 7b140add765..5f57eccbb66 100644
@@ -28,7 +28,7 @@
 #include "migration/misc.h"
 #include "hw/boards.h"
 #include "hw/qdev-properties.h"
-#include CONFIG_DEVICES
+#include "hw/acpi/acpi.h"
 #include "trace.h"
 
 static const VMStateDescription vmstate_virtio_mem_device_early;
@@ -883,10 +883,8 @@ static uint64_t virtio_mem_get_features(VirtIODevice *vdev, uint64_t features,
     MachineState *ms = MACHINE(qdev_get_machine());
     VirtIOMEM *vmem = VIRTIO_MEM(vdev);
 
-    if (ms->numa_state) {
-#if defined(CONFIG_ACPI)
+    if (ms->numa_state && acpi_builtin()) {
         virtio_add_feature(&features, VIRTIO_MEM_F_ACPI_PXM);
-#endif
     }
     assert(vmem->unplugged_inaccessible != ON_OFF_AUTO_AUTO);
     if (vmem->unplugged_inaccessible == ON_OFF_AUTO_ON) {
Signature · 1 line
2.47.1
#5 lore raw

PATCH v2 5/7 hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime

In reply to Philippe Mathieu-Daudé

Use qemu_arch_available() to check at runtime if a target architecture is built in.

Consider the maximum extent size of any architecture built in.

---
 hw/virtio/virtio-mem.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
hw/virtio/virtio-mem.c +20 -8
index 5f57eccbb66..6ff9dab0f66 100644
@@ -15,6 +15,7 @@
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qemu/units.h"
+#include "system/arch_init.h"
 #include "system/numa.h"
 #include "system/system.h"
 #include "system/reset.h"
@@ -170,13 +171,24 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
  * necessary (as the section size can change). But it's more likely that the
  * section size will rather get smaller and not bigger over time.
  */
-#if defined(TARGET_X86_64) || defined(TARGET_I386) || defined(TARGET_S390X)
-#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))
-#elif defined(TARGET_ARM)
-#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
-#else
-#error VIRTIO_MEM_USABLE_EXTENT not defined
-#endif
+static uint64_t virtio_mem_usable_extent_size(void)
+{
+    uint64_t size = 0;
+
+    assert(qemu_arch_available(QEMU_ARCH_ARM | QEMU_ARCH_I386 | QEMU_ARCH_S390X));
+    /*
+     * FIXME: We should use the maximum of instantiated vCPUs ARCH, but
+     *        for now it is easier to take the maximum of any ARCH built in.
+     */
+    if (qemu_arch_available(QEMU_ARCH_I386 | QEMU_ARCH_S390X)) {
+        size = MAX(size, 2 * 128 * MiB);
+    }
+    if (qemu_arch_available(QEMU_ARCH_ARM)) {
+        size = MAX(size, 2 * 512 * MiB);
+    }
+
+    return size;
+}
 
 static bool virtio_mem_is_busy(void)
 {
@@ -721,7 +733,7 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *vmem,
                                             bool can_shrink)
 {
     uint64_t newsize = MIN(memory_region_size(&vmem->memdev->mr),
-                           requested_size + VIRTIO_MEM_USABLE_EXTENT);
+                           requested_size + virtio_mem_usable_extent_size());
 
     /* The usable region size always has to be multiples of the block size. */
     newsize = QEMU_ALIGN_UP(newsize, vmem->block_size);
Signature · 1 line
2.47.1
#6 lore raw

Re: [PATCH v2 5/7] hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime

Quoted 17 lines · Philippe Mathieu-Daudé

Use qemu_arch_available() to check at runtime if a target architecture is built in.

Consider the maximum extent size of any architecture built in.

---
  hw/virtio/virtio-mem.c | 28 ++++++++++++++++++++--------
  1 file changed, 20 insertions(+), 8 deletions(-)
hw/virtio/virtio-mem.c +0 -2
@@ -170,13 +171,24 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
   * necessary (as the section size can change). But it's more likely that the
   * section size will rather get smaller and not bigger over time.
   */
-#if defined(TARGET_X86_64) || defined(TARGET_I386) || defined(TARGET_S390X)
-#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))

hw/virtio/virtio-mem.c static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) · line 178

Quoted 10 lines
hw/virtio/virtio-mem.c +5 -5
-#elif defined(TARGET_ARM)
-#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
-#else
-#error VIRTIO_MEM_USABLE_EXTENT not defined
-#endif
+static uint64_t virtio_mem_usable_extent_size(void)
+{
+    uint64_t size = 0;
+
+    assert(qemu_arch_available(QEMU_ARCH_ARM | QEMU_ARCH_I386 | QEMU_ARCH_S390X));

I'm not sure this assertion is doing what I thought it'd do.

For example, building with --target-list=aarch64-softmmu,riscv32-softmmu, this device is now linked in. However, riscv32 machines won't be able to plug it until they allow TYPE_VIRTIO_MD_PCI in some of their HotplugHandlerClass handlers. Still I'd like to catch this case here to avoid bad surprises.

Quoted 13 lines
hw/virtio/virtio-mem.c +13 -0
+    /*
+     * FIXME: We should use the maximum of instantiated vCPUs ARCH, but
+     *        for now it is easier to take the maximum of any ARCH built in.
+     */
+    if (qemu_arch_available(QEMU_ARCH_I386 | QEMU_ARCH_S390X)) {
+        size = MAX(size, 2 * 128 * MiB);
+    }
+    if (qemu_arch_available(QEMU_ARCH_ARM)) {
+        size = MAX(size, 2 * 512 * MiB);
+    }
+
+    return size;
+}
#7 lore raw

Re: [PATCH v2 5/7] hw/virtio/virtio-mem: Convert VIRTIO_MEM_USABLE_EXTENT to runtime

Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 17 lines · Philippe Mathieu-Daudé

Use qemu_arch_available() to check at runtime if a target architecture is built in.

Consider the maximum extent size of any architecture built in.

---
   hw/virtio/virtio-mem.c | 28 ++++++++++++++++++++--------
   1 file changed, 20 insertions(+), 8 deletions(-)
hw/virtio/virtio-mem.c +0 -2
@@ -170,13 +171,24 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
    * necessary (as the section size can change). But it's more likely that the
    * section size will rather get smaller and not bigger over time.
    */
-#if defined(TARGET_X86_64) || defined(TARGET_I386) || defined(TARGET_S390X)
-#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))

hw/virtio/virtio-mem.c static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) · line 178

Quoted 10 lines
hw/virtio/virtio-mem.c +5 -5
-#elif defined(TARGET_ARM)
-#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
-#else
-#error VIRTIO_MEM_USABLE_EXTENT not defined
-#endif
+static uint64_t virtio_mem_usable_extent_size(void)
+{
+    uint64_t size = 0;
+
+    assert(qemu_arch_available(QEMU_ARCH_ARM | QEMU_ARCH_I386 | QEMU_ARCH_S390X));

I'm not sure this assertion is doing what I thought it'd do.

Quoted 6 lines

For example, building with --target-list=aarch64-softmmu,riscv32-softmmu, this device is now linked in. However, riscv32 machines won't be able to plug it until they allow TYPE_VIRTIO_MD_PCI in some of their HotplugHandlerClass handlers. Still I'd like to catch this case here to avoid bad surprises.

With the single binary, a lot of devices will be linked in, even though they won't be used. There is no specific very specific here, and definitely something we can tackle later, once we are able to link a single binary.

Quoted 14 lines
Quoted 13 lines
hw/virtio/virtio-mem.c +13 -0
+    /*
+     * FIXME: We should use the maximum of instantiated vCPUs ARCH, but
+     *        for now it is easier to take the maximum of any ARCH built in.
+     */
+    if (qemu_arch_available(QEMU_ARCH_I386 | QEMU_ARCH_S390X)) {
+        size = MAX(size, 2 * 128 * MiB);
+    }
+    if (qemu_arch_available(QEMU_ARCH_ARM)) {
+        size = MAX(size, 2 * 512 * MiB);
+    }
+
+    return size;
+}
#8 lore raw

PATCH v2 6/7 hw/virtio/virtio-mem: Convert VIRTIO_MEM_HAS_LEGACY_GUESTS to runtime

In reply to Philippe Mathieu-Daudé

Use qemu_arch_available() to check at runtime if a target architecture is built in.
Register virtio_mem_legacy_guests_properties[] at runtime. Code churn in virtio_mem_device_realize() is due to re-indentation.

---
 hw/virtio/virtio-mem.c | 61 ++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 29 deletions(-)
hw/virtio/virtio-mem.c +32 -29
index 6ff9dab0f66..5288fe597b3 100644
@@ -38,9 +38,10 @@ static const VMStateDescription vmstate_virtio_mem_device_early;
  * We only had legacy x86 guests that did not support
  * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have legacy guests.
  */
-#if defined(TARGET_X86_64) || defined(TARGET_I386)
-#define VIRTIO_MEM_HAS_LEGACY_GUESTS
-#endif
+static bool virtio_mem_has_legacy_guests(void)
+{
+    return qemu_arch_available(QEMU_ARCH_I386);
+}
 
 /*
  * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking
@@ -144,7 +145,6 @@ static uint64_t virtio_mem_default_block_size(RAMBlock *rb)
     return MAX(page_size, VIRTIO_MEM_MIN_BLOCK_SIZE);
 }
 
-#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS)
 static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
 {
     /*
@@ -155,7 +155,6 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
     return !qemu_ram_is_shared(rb) && qemu_ram_get_fd(rb) < 0 &&
            qemu_ram_pagesize(rb) == qemu_real_host_page_size();
 }
-#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */
 
 /*
  * Size the usable region bigger than the requested size if possible. Esp.
@@ -1009,28 +1008,28 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
     rb = vmem->memdev->mr.ram_block;
     page_size = qemu_ram_pagesize(rb);
 
-#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS)
-    switch (vmem->unplugged_inaccessible) {
-    case ON_OFF_AUTO_AUTO:
-        if (virtio_mem_has_shared_zeropage(rb)) {
-            vmem->unplugged_inaccessible = ON_OFF_AUTO_OFF;
-        } else {
-            vmem->unplugged_inaccessible = ON_OFF_AUTO_ON;
+    if (virtio_mem_has_legacy_guests()) {
+        switch (vmem->unplugged_inaccessible) {
+        case ON_OFF_AUTO_AUTO:
+            if (virtio_mem_has_shared_zeropage(rb)) {
+                vmem->unplugged_inaccessible = ON_OFF_AUTO_OFF;
+            } else {
+                vmem->unplugged_inaccessible = ON_OFF_AUTO_ON;
+            }
+            break;
+        case ON_OFF_AUTO_OFF:
+            if (!virtio_mem_has_shared_zeropage(rb)) {
+                warn_report("'%s' property set to 'off' with a memdev that does"
+                            " not support the shared zeropage.",
+                            VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP);
+            }
+            break;
+        default:
+            break;
         }
-        break;
-    case ON_OFF_AUTO_OFF:
-        if (!virtio_mem_has_shared_zeropage(rb)) {
-            warn_report("'%s' property set to 'off' with a memdev that does"
-                        " not support the shared zeropage.",
-                        VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP);
-        }
-        break;
-    default:
-        break;
+    } else {
+        vmem->unplugged_inaccessible = ON_OFF_AUTO_ON;
     }
-#else /* VIRTIO_MEM_HAS_LEGACY_GUESTS */
-    vmem->unplugged_inaccessible = ON_OFF_AUTO_ON;
-#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */
 
     if (vmem->dynamic_memslots &&
         vmem->unplugged_inaccessible != ON_OFF_AUTO_ON) {
@@ -1723,16 +1722,17 @@ static const Property virtio_mem_properties[] = {
     DEFINE_PROP_BOOL(VIRTIO_MEM_PREALLOC_PROP, VirtIOMEM, prealloc, false),
     DEFINE_PROP_LINK(VIRTIO_MEM_MEMDEV_PROP, VirtIOMEM, memdev,
                      TYPE_MEMORY_BACKEND, HostMemoryBackend *),
-#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS)
-    DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIOMEM,
-                            unplugged_inaccessible, ON_OFF_AUTO_ON),
-#endif
     DEFINE_PROP_BOOL(VIRTIO_MEM_EARLY_MIGRATION_PROP, VirtIOMEM,
                      early_migration, true),
     DEFINE_PROP_BOOL(VIRTIO_MEM_DYNAMIC_MEMSLOTS_PROP, VirtIOMEM,
                      dynamic_memslots, false),
 };
 
+static const Property virtio_mem_legacy_guests_properties[] = {
+    DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIOMEM,
+                            unplugged_inaccessible, ON_OFF_AUTO_ON),
+};
+
 static uint64_t virtio_mem_rdm_get_min_granularity(const RamDiscardManager *rdm,
                                                    const MemoryRegion *mr)
 {
@@ -1885,6 +1885,9 @@ static void virtio_mem_class_init(ObjectClass *klass, void *data)
     RamDiscardManagerClass *rdmc = RAM_DISCARD_MANAGER_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);
+    }
     dc->vmsd = &vmstate_virtio_mem;
 
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
Signature · 1 line
2.47.1
#9 lore raw

PATCH v2 7/7 hw/virtio: Compile virtio-mem.c once

In reply to Philippe Mathieu-Daudé

Remove unused "exec/ram_addr.h" header. This file doesn't use any target specific definitions anymore, compile it once by moving it to system_virtio_ss[].

---
 hw/virtio/virtio-mem.c | 1 -
 hw/virtio/meson.build  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
hw/virtio/virtio-mem.c +0 -1
index 5288fe597b3..2e51dcfdf32 100644
@@ -25,7 +25,6 @@
 #include "hw/virtio/virtio-mem.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
-#include "exec/ram_addr.h"
 #include "migration/misc.h"
 #include "hw/boards.h"
 #include "hw/qdev-properties.h"
hw/virtio/meson.build +1 -1
index a5f9f7999dd..7c3513315cb 100644
@@ -55,7 +55,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_NSM', if_true: [files('virtio-nsm.c', 'cbor-helpers.c'), libcbor])
-specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
+system_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c'))
 
Signature · 1 line
2.47.1