Done by merge virtio_mem_legacy_guests_properties into virtio_mem_properties. As we already have vmem->unplugged_inaccessible handle in virtio_mem_device_realize So we can reject the wrong option in virtio_mem_device_realize, then the call target_info() in class_init no need anymore.
Signed-off-by: Yonggang Luo <[email protected]> --- hw/virtio/virtio-mem.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index a4110d61312..81e2192c2fb 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -879,7 +879,11 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) break; } } else { - vmem->unplugged_inaccessible = ON_OFF_AUTO_ON; + if (vmem->unplugged_inaccessible != ON_OFF_AUTO_ON) { + error_setg(errp, "'%s' must be 'on' on non-x86 targets", + VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP); + return; + } } if (vmem->dynamic_memslots && @@ -1568,9 +1572,6 @@ static const Property virtio_mem_properties[] = { 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), }; @@ -1635,9 +1636,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); - } dc->vmsd = &vmstate_virtio_mem; set_bit(DEVICE_CATEGORY_MISC, dc->categories); -- 2.55.0.windows.3
