[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 04/21] memory: Introduce memory_region_has_gmem_fd()
From: |
Xiaoyao Li |
Subject: |
[RFC PATCH v2 04/21] memory: Introduce memory_region_has_gmem_fd() |
Date: |
Wed, 13 Sep 2023 23:51:00 -0400 |
Introduce memory_region_has_gmem_fd() to query if the MemoryRegion has
KVM gmem fd allocated.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
include/exec/memory.h | 10 ++++++++++
softmmu/memory.c | 5 +++++
2 files changed, 15 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 227cb2578e95..4b8486ca3632 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1674,6 +1674,16 @@ static inline bool memory_region_is_romd(MemoryRegion
*mr)
*/
bool memory_region_is_protected(MemoryRegion *mr);
+/**
+ * memory_region_has_gmem_fd: check whether a memory region has KVM gmem fd
+ * associated
+ *
+ * Returns %true if a memory region's ram_block has valid gmem fd assigned.
+ *
+ * @mr: the memory region being queried
+ */
+bool memory_region_has_gmem_fd(MemoryRegion *mr);
+
/**
* memory_region_get_iommu: check whether a memory region is an iommu
*
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 7d9494ce7028..e69a5f96d5d1 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1846,6 +1846,11 @@ bool memory_region_is_protected(MemoryRegion *mr)
return mr->ram && (mr->ram_block->flags & RAM_PROTECTED);
}
+bool memory_region_has_gmem_fd(MemoryRegion *mr)
+{
+ return mr->ram_block && mr->ram_block->gmem_fd >= 0;
+}
+
uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr)
{
uint8_t mask = mr->dirty_log_mask;
--
2.34.1
- Re: [RFC PATCH v2 02/21] RAMBlock: Add support of KVM private gmem, (continued)
- [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Xiaoyao Li, 2023/09/13
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Markus Armbruster, 2023/09/19
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Xiaoyao Li, 2023/09/19
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Markus Armbruster, 2023/09/20
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Xiaoyao Li, 2023/09/20
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, David Hildenbrand, 2023/09/20
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Markus Armbruster, 2023/09/20
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Xiaoyao Li, 2023/09/21
- Re: [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, David Hildenbrand, 2023/09/21
[RFC PATCH v2 04/21] memory: Introduce memory_region_has_gmem_fd(),
Xiaoyao Li <=
[RFC PATCH v2 05/21] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot, Xiaoyao Li, 2023/09/13
[RFC PATCH v2 06/21] i386: Add support for sw-protected-vm object, Xiaoyao Li, 2023/09/13
[RFC PATCH v2 07/21] i386/pc: Drop pc_machine_kvm_type(), Xiaoyao Li, 2023/09/13