[RFC PATCH 02/11] domain_conf: introduce virDomainDimmGetFreeSlot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a bitmap dimm_slot_map to store status of slots. If you want to
use a slot, you can find a minimum value which has not been used in
the bitmap.

Signed-off-by: Zhu Guihua <zhugh.fnst@xxxxxxxxxxxxxx>
---
 src/conf/domain_conf.c | 12 ++++++++++++
 src/conf/domain_conf.h |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 526f2da..d7f7a9e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12739,6 +12739,9 @@ virDomainDefParseXML(xmlDocPtr xml,
             goto error;
     }
 
+    if (!(def->mem.dimm_slot_map = virBitmapNew(def->mem.slots)))
+        goto error;
+
     /* and info about it */
     if ((tmp = virXPathString("string(./memory[1]/@dumpCore)", ctxt)) &&
         (def->mem.dump_core = virTristateSwitchTypeFromString(tmp)) <= 0) {
@@ -16205,6 +16208,15 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
     return 0;
 }
 
+int
+virDomainDimmGetFreeSlot(virDomainDefPtr def)
+{
+    int i;
+    i = virBitmapNextClearBit(def->mem.dimm_slot_map, 0);
+
+    return i;
+}
+
 /* Check if vcpupin with same vcpuid already exists.
  * Return 1 if exists, 0 if not. */
 int
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 731d14f..d746272 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2021,6 +2021,7 @@ struct _virDomainMemtune {
     unsigned int slots; /* the maximum slots for memory devices  */
     unsigned long long maxmem; /* in kibibytes, the maximum memory
                                   for the guest */
+    virBitmapPtr dimm_slot_map;
 
     virDomainHugePagePtr hugepages;
     size_t nhugepages;
@@ -2526,6 +2527,8 @@ int virDomainDefCompatibleDevice(virDomainDefPtr def,
                                  virDomainDeviceDefPtr dev,
                                  virDomainDeviceAction action);
 
+int virDomainDimmGetFreeSlot(virDomainDefPtr def);
+
 int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list,
                         size_t *nvcpupin,
                         unsigned char *cpumap,
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]