]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: numa: Always allocate the NUMA config
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Feb 2015 15:42:13 +0000 (16:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Feb 2015 16:48:48 +0000 (17:48 +0100)
Since our formatter now handles well if the config is allocated and not
filled we can safely always-allocate the NUMA config and remove the
ad-hoc allocation code.

This will help in later patches as the parser will be refactored to just
fill the data.

src/conf/domain_conf.c
src/conf/numa_conf.c
src/conf/numa_conf.h
src/libvirt_private.syms

index 724221069d670942fb877d6c95ea0fa241c40035..e9c6a825b8fc9956cc1edc836be31870b5e20f37 100644 (file)
@@ -2319,9 +2319,17 @@ virDomainDefNew(void)
 {
     virDomainDefPtr ret;
 
-    ignore_value(VIR_ALLOC(ret));
+    if (VIR_ALLOC(ret) < 0)
+        return NULL;
+
+    if (!(ret->numa = virDomainNumaNew()))
+        goto error;
 
     return ret;
+
+ error:
+    virDomainDefFree(ret);
+    return NULL;
 }
 
 
index 9b48fb87eaa6826bc312ce78a7813868b7d7e641..81b51ca51577a973660232d0bb99939b37a2fc92 100644 (file)
@@ -117,11 +117,6 @@ virDomainNumatuneNodeParseXML(virDomainNumaPtr *numatunePtr,
         goto cleanup;
     }
 
-    if (!numatune && VIR_ALLOC(numatune) < 0)
-        goto cleanup;
-
-    *numatunePtr = numatune;
-
     VIR_FREE(numatune->mem_nodes);
     if (VIR_ALLOC_N(numatune->mem_nodes, ncells) < 0)
         goto cleanup;
@@ -224,11 +219,6 @@ virDomainNumatuneParseXML(virDomainNumaPtr *numatunePtr,
 
     node = virXPathNode("./numatune/memory[1]", ctxt);
 
-    if (*numatunePtr) {
-        virDomainNumaFree(*numatunePtr);
-        *numatunePtr = NULL;
-    }
-
     if (!placement_static && !node)
         placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO;
 
@@ -454,27 +444,20 @@ virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
                      int mode,
                      virBitmapPtr nodeset)
 {
-    bool created = false;
     int ret = -1;
-    virDomainNumaPtr numatune;
+    virDomainNumaPtr numatune = *numatunePtr;
 
     /* No need to do anything in this case */
     if (mode == -1 && placement == -1 && !nodeset)
         return 0;
 
-    if (!(*numatunePtr)) {
-        if (VIR_ALLOC(*numatunePtr) < 0)
-            goto cleanup;
-
-        created = true;
+    if (!numatune->memory.specified) {
         if (mode == -1)
             mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
         if (placement == -1)
             placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_DEFAULT;
     }
 
-    numatune = *numatunePtr;
-
     /* Range checks */
     if (mode != -1 &&
         (mode < 0 || mode >= VIR_DOMAIN_NUMATUNE_MEM_LAST)) {
@@ -534,11 +517,6 @@ virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
     ret = 0;
 
  cleanup:
-    if (ret < 0 && created) {
-        virDomainNumaFree(*numatunePtr);
-        *numatunePtr = NULL;
-    }
-
     return ret;
 }
 
@@ -827,3 +805,14 @@ virDomainNumaGetCPUCountTotal(virCPUDefPtr numa)
 
     return ret;
 }
+
+
+virDomainNumaPtr
+virDomainNumaNew(void)
+{
+    virDomainNumaPtr ret = NULL;
+
+    ignore_value(VIR_ALLOC(ret));
+
+    return ret;
+}
index efb1bf01e3565c1420612cba03d1fb2ee7dfa60d..42e83db4fd543b963be0ba0e4ca95aeca271b8de 100644 (file)
@@ -56,6 +56,7 @@ typedef enum {
 
 VIR_ENUM_DECL(virNumaMemAccess)
 
+virDomainNumaPtr virDomainNumaNew(void);
 void virDomainNumaFree(virDomainNumaPtr numa);
 
 /*
index b145c8b921efb22dc2130df950fdce719d4b5ec0..b220a322d22394f6c0ab6e7aa2e654aad80f5748 100644 (file)
@@ -629,6 +629,7 @@ virNodeDeviceObjUnlock;
 # conf/numa_conf.h
 virDomainNumaEquals;
 virDomainNumaFree;
+virDomainNumaNew;
 virDomainNumatuneFormatNodeset;
 virDomainNumatuneFormatXML;
 virDomainNumatuneGetMode;