- kvm-virtio-kconfig-memory-devices-are-PCI-only.patch [RHEL-72977] - kvm-hw-s390-ccw-device-Convert-to-three-phase-reset.patch [RHEL-72977] - kvm-hw-s390-virtio-ccw-Convert-to-three-phase-reset.patch [RHEL-72977] - kvm-target-s390-Convert-CPU-to-Resettable-interface.patch [RHEL-72977] - kvm-reset-Use-ResetType-for-qemu_devices_reset-and-Machi.patch [RHEL-72977] - kvm-reset-Add-RESET_TYPE_WAKEUP.patch [RHEL-72977] - kvm-virtio-mem-Use-new-Resettable-framework-instead-of-L.patch [RHEL-72977] - kvm-virtio-mem-Add-support-for-suspend-wake-up-with-plug.patch [RHEL-72977] - kvm-virtio-mem-unplug-memory-only-during-system-resets-n.patch [RHEL-72977] - kvm-s390x-s390-virtio-ccw-don-t-crash-on-weird-RAM-sizes.patch [RHEL-72977] - kvm-s390x-s390-virtio-hcall-remove-hypercall-registratio.patch [RHEL-72977] - kvm-s390x-s390-virtio-hcall-prepare-for-more-diag500-hyp.patch [RHEL-72977] - kvm-s390x-rename-s390-virtio-hcall-to-s390-hypercall.patch [RHEL-72977] - kvm-s390x-s390-virtio-ccw-move-setting-the-maximum-guest.patch [RHEL-72977] - kvm-s390x-introduce-s390_get_memory_limit.patch [RHEL-72977] - kvm-s390x-s390-hypercall-introduce-DIAG500-STORAGE_LIMIT.patch [RHEL-72977] - kvm-s390x-s390-stattrib-kvm-prepare-for-memory-devices-a.patch [RHEL-72977] - kvm-s390x-s390-skeys-prepare-for-memory-devices.patch [RHEL-72977] - kvm-s390x-s390-virtio-ccw-prepare-for-memory-devices.patch [RHEL-72977] - kvm-s390x-pv-prepare-for-memory-devices.patch [RHEL-72977] - kvm-s390x-remember-the-maximum-page-size.patch [RHEL-72977] - kvm-s390x-virtio-ccw-add-support-for-virtio-based-memory.patch [RHEL-72977] - kvm-s390x-virtio-mem-support.patch [RHEL-72977] - kvm-hw-virtio-Also-include-md-stubs-in-case-CONFIG_VIRTI.patch [RHEL-72977] - kvm-virtio-mem-don-t-warn-about-THP-sizes-on-a-kernel-wi.patch [RHEL-72977] - kvm-redhat-Enable-virtio-mem-on-s390x.patch [RHEL-72977] - Resolves: RHEL-72977 ([IBM 9.7 FEAT] KVM: Enable virtio-mem support - qemu part)
		
			
				
	
	
		
			142 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 6bc0cdecdc736d642bb6c040e07d79a0a3e591ea Mon Sep 17 00:00:00 2001
 | |
| From: Juraj Marcin <jmarcin@redhat.com>
 | |
| Date: Wed, 4 Sep 2024 12:37:14 +0200
 | |
| Subject: [PATCH 07/26] virtio-mem: Use new Resettable framework instead of
 | |
|  LegacyReset
 | |
| 
 | |
| RH-Author: Thomas Huth <thuth@redhat.com>
 | |
| RH-MergeRequest: 351: Enable virtio-mem support on s390x
 | |
| RH-Jira: RHEL-72977
 | |
| RH-Acked-by: David Hildenbrand <david@redhat.com>
 | |
| RH-Acked-by: Juraj Marcin <None>
 | |
| RH-Commit: [7/26] 31fddbeb4aaf6794b83399a7e2996f01d918d748 (thuth/qemu-kvm-cs)
 | |
| 
 | |
| LegacyReset does not pass ResetType to the reset callback method, which
 | |
| the new Resettable framework uses. Due to this, virtio-mem cannot use
 | |
| the new RESET_TYPE_WAKEUP to skip the reset during wake-up from a
 | |
| suspended state.
 | |
| 
 | |
| This patch adds overrides Resettable interface methods in VirtIOMEMClass
 | |
| to use the new Resettable framework and replaces
 | |
| qemu_[un]register_reset() calls with qemu_[un]register_resettable().
 | |
| 
 | |
| Message-ID: <20240904103722.946194-4-jmarcin@redhat.com>
 | |
| Reviewed-by: David Hildenbrand <david@redhat.com>
 | |
| Signed-off-by: Juraj Marcin <jmarcin@redhat.com>
 | |
| Signed-off-by: David Hildenbrand <david@redhat.com>
 | |
| (cherry picked from commit c009a311e93963860cfba917605a4bf903a06bce)
 | |
| Signed-off-by: Thomas Huth <thuth@redhat.com>
 | |
| ---
 | |
|  hw/virtio/virtio-mem.c         | 38 +++++++++++++++++++++-------------
 | |
|  include/hw/virtio/virtio-mem.h |  4 ++++
 | |
|  2 files changed, 28 insertions(+), 14 deletions(-)
 | |
| 
 | |
| diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
 | |
| index ba11aa4646..025ae4abac 100644
 | |
| --- a/hw/virtio/virtio-mem.c
 | |
| +++ b/hw/virtio/virtio-mem.c
 | |
| @@ -895,18 +895,6 @@ static int virtio_mem_validate_features(VirtIODevice *vdev)
 | |
|      return 0;
 | |
|  }
 | |
|  
 | |
| -static void virtio_mem_system_reset(void *opaque)
 | |
| -{
 | |
| -    VirtIOMEM *vmem = VIRTIO_MEM(opaque);
 | |
| -
 | |
| -    /*
 | |
| -     * During usual resets, we will unplug all memory and shrink the usable
 | |
| -     * region size. This is, however, not possible in all scenarios. Then,
 | |
| -     * the guest has to deal with this manually (VIRTIO_MEM_REQ_UNPLUG_ALL).
 | |
| -     */
 | |
| -    virtio_mem_unplug_all(vmem);
 | |
| -}
 | |
| -
 | |
|  static void virtio_mem_prepare_mr(VirtIOMEM *vmem)
 | |
|  {
 | |
|      const uint64_t region_size = memory_region_size(&vmem->memdev->mr);
 | |
| @@ -1123,7 +1111,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
 | |
|          vmstate_register_any(VMSTATE_IF(vmem),
 | |
|                               &vmstate_virtio_mem_device_early, vmem);
 | |
|      }
 | |
| -    qemu_register_reset(virtio_mem_system_reset, vmem);
 | |
| +    qemu_register_resettable(OBJECT(vmem));
 | |
|  
 | |
|      /*
 | |
|       * Set ourselves as RamDiscardManager before the plug handler maps the
 | |
| @@ -1143,7 +1131,7 @@ static void virtio_mem_device_unrealize(DeviceState *dev)
 | |
|       * found via an address space anymore. Unset ourselves.
 | |
|       */
 | |
|      memory_region_set_ram_discard_manager(&vmem->memdev->mr, NULL);
 | |
| -    qemu_unregister_reset(virtio_mem_system_reset, vmem);
 | |
| +    qemu_unregister_resettable(OBJECT(vmem));
 | |
|      if (vmem->early_migration) {
 | |
|          vmstate_unregister(VMSTATE_IF(vmem), &vmstate_virtio_mem_device_early,
 | |
|                             vmem);
 | |
| @@ -1844,12 +1832,31 @@ static void virtio_mem_unplug_request_check(VirtIOMEM *vmem, Error **errp)
 | |
|      }
 | |
|  }
 | |
|  
 | |
| +static ResettableState *virtio_mem_get_reset_state(Object *obj)
 | |
| +{
 | |
| +    VirtIOMEM *vmem = VIRTIO_MEM(obj);
 | |
| +    return &vmem->reset_state;
 | |
| +}
 | |
| +
 | |
| +static void virtio_mem_system_reset_hold(Object *obj, ResetType type)
 | |
| +{
 | |
| +    VirtIOMEM *vmem = VIRTIO_MEM(obj);
 | |
| +
 | |
| +    /*
 | |
| +     * During usual resets, we will unplug all memory and shrink the usable
 | |
| +     * region size. This is, however, not possible in all scenarios. Then,
 | |
| +     * the guest has to deal with this manually (VIRTIO_MEM_REQ_UNPLUG_ALL).
 | |
| +     */
 | |
| +    virtio_mem_unplug_all(vmem);
 | |
| +}
 | |
| +
 | |
|  static void virtio_mem_class_init(ObjectClass *klass, void *data)
 | |
|  {
 | |
|      DeviceClass *dc = DEVICE_CLASS(klass);
 | |
|      VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 | |
|      VirtIOMEMClass *vmc = VIRTIO_MEM_CLASS(klass);
 | |
|      RamDiscardManagerClass *rdmc = RAM_DISCARD_MANAGER_CLASS(klass);
 | |
| +    ResettableClass *rc = RESETTABLE_CLASS(klass);
 | |
|  
 | |
|      device_class_set_props(dc, virtio_mem_properties);
 | |
|      dc->vmsd = &vmstate_virtio_mem;
 | |
| @@ -1876,6 +1883,9 @@ static void virtio_mem_class_init(ObjectClass *klass, void *data)
 | |
|      rdmc->replay_discarded = virtio_mem_rdm_replay_discarded;
 | |
|      rdmc->register_listener = virtio_mem_rdm_register_listener;
 | |
|      rdmc->unregister_listener = virtio_mem_rdm_unregister_listener;
 | |
| +
 | |
| +    rc->get_state = virtio_mem_get_reset_state;
 | |
| +    rc->phases.hold = virtio_mem_system_reset_hold;
 | |
|  }
 | |
|  
 | |
|  static const TypeInfo virtio_mem_info = {
 | |
| diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h
 | |
| index 5f5b02b8f9..a1af144c28 100644
 | |
| --- a/include/hw/virtio/virtio-mem.h
 | |
| +++ b/include/hw/virtio/virtio-mem.h
 | |
| @@ -14,6 +14,7 @@
 | |
|  #define HW_VIRTIO_MEM_H
 | |
|  
 | |
|  #include "standard-headers/linux/virtio_mem.h"
 | |
| +#include "hw/resettable.h"
 | |
|  #include "hw/virtio/virtio.h"
 | |
|  #include "qapi/qapi-types-misc.h"
 | |
|  #include "sysemu/hostmem.h"
 | |
| @@ -115,6 +116,9 @@ struct VirtIOMEM {
 | |
|  
 | |
|      /* listeners to notify on plug/unplug activity. */
 | |
|      QLIST_HEAD(, RamDiscardListener) rdl_list;
 | |
| +
 | |
| +    /* State of the resettable container */
 | |
| +    ResettableState reset_state;
 | |
|  };
 | |
|  
 | |
|  struct VirtIOMEMClass {
 | |
| -- 
 | |
| 2.48.1
 | |
| 
 |