[PATCH v4 6.5/9] squash into 'use virBitmap to store cpumask info'

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

 



---

I had to squash this patch into 6/9 in order to build successfully
with xen enabled, and it's a bit more than I can comfortably do
without an ACK. Can somebody give this a quick look?

 src/xen/xm_internal.c | 11 +++--------
 src/xenxs/xen_sxpr.c  | 12 +++---------
 src/xenxs/xen_xm.c    | 14 +++-----------
 3 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index f9ccbab..a4dec62 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -831,7 +831,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain,
     char *mapstr = NULL, *mapsave = NULL;
     int i, j, n, comma = 0;
     int ret = -1;
-    char *cpuset = NULL;
+    virBitmapPtr cpuset = NULL;
     int maxcpu = XEN_MAX_PHYSICAL_CPU;
 
     if (domain == NULL || domain->conn == NULL || domain->name == NULL
@@ -885,16 +885,11 @@ int xenXMDomainPinVcpu(virDomainPtr domain,
     mapstr = virBufferContentAndReset(&mapbuf);
     mapsave = mapstr;
 
-    if (VIR_ALLOC_N(cpuset, maxcpu) < 0) {
-        virReportOOMError();
-        goto cleanup;
-    }
-    if (virDomainCpuSetParse(mapstr, 0, cpuset, maxcpu) < 0)
+    if (virBitmapParse(mapstr, 0, &cpuset, maxcpu) < 0)
         goto cleanup;
 
-    VIR_FREE(entry->def->cpumask);
+    virBitmapFree(entry->def->cpumask);
     entry->def->cpumask = cpuset;
-    entry->def->cpumasklen = maxcpu;
     cpuset = NULL;
 
     if (xenXMConfigSaveFile(domain->conn, entry->filename, entry->def) < 0)
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 8bb3849..03f2bfe 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1197,14 +1197,8 @@ xenParseSxpr(const struct sexpr *root,
         def->mem.cur_balloon = def->mem.max_balloon;
 
     if (cpus != NULL) {
-        def->cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
-        if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
-            virReportOOMError();
-            goto error;
-        }
-
-        if (virDomainCpuSetParse(cpus, 0, def->cpumask,
-                                 def->cpumasklen) < 0) {
+        if (virBitmapParse(cpus, 0, &def->cpumask,
+                           VIR_DOMAIN_CPUMASK_LEN) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("invalid CPU mask %s"), cpus);
             goto error;
@@ -2246,7 +2240,7 @@ xenFormatSxpr(virConnectPtr conn,
         virBufferAsprintf(&buf, "(vcpu_avail %lu)", (1UL << def->vcpus) - 1);
 
     if (def->cpumask) {
-        char *ranges = virDomainCpuSetFormat(def->cpumask, def->cpumasklen);
+        char *ranges = virBitmapFormat(def->cpumask);
         if (ranges == NULL)
             goto error;
         virBufferEscapeSexpr(&buf, "(cpus '%s')", ranges);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 479fb34..14b01f8 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -369,16 +369,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 
     if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0)
         goto cleanup;
-    if (str) {
-        def->cpumasklen = 4096;
-        if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0)
-            goto no_memory;
-
-        if (virDomainCpuSetParse(str, 0,
-                                 def->cpumask, def->cpumasklen) < 0)
+    if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
             goto cleanup;
-    }
-
 
     if (xenXMConfigGetString(conf, "on_poweroff", &str, "destroy") < 0)
         goto cleanup;
@@ -1549,9 +1541,9 @@ virConfPtr xenFormatXM(virConnectPtr conn,
         goto no_memory;
 
     if ((def->cpumask != NULL) &&
-        ((cpus = virDomainCpuSetFormat(def->cpumask,
-                                       def->cpumasklen)) == NULL))
+        ((cpus = virBitmapFormat(def->cpumask)) == NULL)) {
         goto cleanup;
+    }
 
     if (cpus &&
         xenXMConfigSetString(conf, "cpus", cpus) < 0)
-- 
1.7.11.4

--
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]