[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 07/38] virito-mem: Implement get_min_alignment()
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 07/38] virito-mem: Implement get_min_alignment() |
Date: |
Tue, 3 Nov 2020 23:51:01 -0500 |
From: David Hildenbrand <david@redhat.com>
The block size determines the alignment requirements. Implement
get_min_alignment() of the TYPE_MEMORY_DEVICE interface.
This allows auto-assignment of a properly aligned address in guest
physical address space. For example, when specifying a 2GB block size
for a virtio-mem device with 10GB with a memory setup "-m 4G, 20G",
we'll no longer fail when realizing.
Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Wei Yang <richardw.yang@linux.intel.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20201008083029.9504-7-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-mem-pci.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
index 913f4a3326..fa5395cd88 100644
--- a/hw/virtio/virtio-mem-pci.c
+++ b/hw/virtio/virtio-mem-pci.c
@@ -76,6 +76,12 @@ static void virtio_mem_pci_fill_device_info(const
MemoryDeviceState *md,
info->type = MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM;
}
+static uint64_t virtio_mem_pci_get_min_alignment(const MemoryDeviceState *md)
+{
+ return object_property_get_uint(OBJECT(md), VIRTIO_MEM_BLOCK_SIZE_PROP,
+ &error_abort);
+}
+
static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data)
{
VirtIOMEMPCI *pci_mem = container_of(notifier, VirtIOMEMPCI,
@@ -110,6 +116,7 @@ static void virtio_mem_pci_class_init(ObjectClass *klass,
void *data)
mdc->get_plugged_size = virtio_mem_pci_get_plugged_size;
mdc->get_memory_region = virtio_mem_pci_get_memory_region;
mdc->fill_device_info = virtio_mem_pci_fill_device_info;
+ mdc->get_min_alignment = virtio_mem_pci_get_min_alignment;
}
static void virtio_mem_pci_instance_init(Object *obj)
--
MST
- [PULL v2 00/38] pc,pci,vhost,virtio: fixes, Michael S. Tsirkin, 2020/11/03
- [PULL v2 01/38] pc: comment style fixup, Michael S. Tsirkin, 2020/11/03
- [PULL v2 02/38] virtio-mem: Make sure "addr" is always multiples of the block size, Michael S. Tsirkin, 2020/11/03
- [PULL v2 03/38] virtio-mem: Make sure "usable_region_size" is always multiples of the block size, Michael S. Tsirkin, 2020/11/03
- [PULL v2 04/38] virtio-mem: Probe THP size to determine default block size, Michael S. Tsirkin, 2020/11/03
- [PULL v2 05/38] memory-device: Support big alignment requirements, Michael S. Tsirkin, 2020/11/03
- [PULL v2 07/38] virito-mem: Implement get_min_alignment(),
Michael S. Tsirkin <=
- [PULL v2 06/38] memory-device: Add get_min_alignment() callback, Michael S. Tsirkin, 2020/11/03
- [PULL v2 08/38] hw/acpi : Don't use '#' flag of printf format, Michael S. Tsirkin, 2020/11/03
- [PULL v2 13/38] virtio-iommu: Fix virtio_iommu_mr(), Michael S. Tsirkin, 2020/11/03
- [PULL v2 15/38] virtio-iommu: Add memory notifiers for map/unmap, Michael S. Tsirkin, 2020/11/03
- [PULL v2 17/38] virtio-iommu: Add replay() memory region callback, Michael S. Tsirkin, 2020/11/03
- [PULL v2 19/38] memory: Add interface to set iommu page size mask, Michael S. Tsirkin, 2020/11/03
- [PULL v2 20/38] vfio: Set IOMMU page size as per host supported page size, Michael S. Tsirkin, 2020/11/03
- [PULL v2 21/38] virtio-iommu: Set supported page size mask, Michael S. Tsirkin, 2020/11/03
- [PULL v2 22/38] vfio: Don't issue full 2^64 unmap, Michael S. Tsirkin, 2020/11/03
- [PULL v2 23/38] vhost-vdpa: Add qemu_close in vhost_vdpa_cleanup, Michael S. Tsirkin, 2020/11/03