mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: memory_manager: Support non-power-of-2 block sizes
Replace alignment calculation of start address with functionally equivalent version that does not assume that the block size is a power of two. Signed-off-by: Martin Xu <martin.xu@intel.com> Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
f8ee89a514
commit
5a380a6918
@@ -282,9 +282,11 @@ impl MemoryManager {
|
|||||||
let mut virtiomem_resize = None;
|
let mut virtiomem_resize = None;
|
||||||
if let Some(size) = config.hotplug_size {
|
if let Some(size) = config.hotplug_size {
|
||||||
if config.hotplug_method == HotplugMethod::VirtioMem {
|
if config.hotplug_method == HotplugMethod::VirtioMem {
|
||||||
|
// Alignment must be "natural" i.e. same as size of block
|
||||||
let start_addr = GuestAddress(
|
let start_addr = GuestAddress(
|
||||||
(start_of_device_area.0 + vm_virtio::VIRTIO_MEM_DEFAULT_BLOCK_SIZE - 1)
|
(start_of_device_area.0 + vm_virtio::VIRTIO_MEM_DEFAULT_BLOCK_SIZE - 1)
|
||||||
& (!(vm_virtio::VIRTIO_MEM_DEFAULT_BLOCK_SIZE - 1)),
|
/ vm_virtio::VIRTIO_MEM_DEFAULT_BLOCK_SIZE
|
||||||
|
* vm_virtio::VIRTIO_MEM_DEFAULT_BLOCK_SIZE,
|
||||||
);
|
);
|
||||||
virtiomem_region = Some(MemoryManager::create_ram_region(
|
virtiomem_region = Some(MemoryManager::create_ram_region(
|
||||||
&config.file,
|
&config.file,
|
||||||
|
|||||||
Reference in New Issue
Block a user