Cleanup QEMU_CFG_NUMA fw_cfg processing - split into two romfile entries.

The QEMU_CFG_NUMA fw_cfg entry is actually two separate tables in one
fw_cfg entry - a table for cpu affinity and a table for the memory
map.  Create two romfile entries to make that more clear.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
diff --git a/src/acpi.c b/src/acpi.c
index bc4d8ea..55c7259 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -646,14 +646,13 @@
 static void *
 build_srat(void)
 {
-    int filesize;
-    u64 *numadata = romfile_loadfile("etc/numa-nodes", &filesize);
-    if (!numadata)
-        return NULL;
-    int max_cpu = romfile_loadint("etc/max-cpus", 0);
-    int nb_numa_nodes = (filesize / sizeof(u64)) - max_cpu;
-    if (!nb_numa_nodes)
-        return NULL;
+    int numadatasize, numacpusize;
+    u64 *numadata = romfile_loadfile("etc/numa-nodes", &numadatasize);
+    u64 *numacpumap = romfile_loadfile("etc/numa-cpu-map", &numacpusize);
+    if (!numadata || !numacpumap)
+        goto fail;
+    int max_cpu = numacpusize / sizeof(u64);
+    int nb_numa_nodes = numadatasize / sizeof(u64);
 
     struct system_resource_affinity_table *srat;
     int srat_size = sizeof(*srat) +
@@ -663,8 +662,7 @@
     srat = malloc_high(srat_size);
     if (!srat) {
         warn_noalloc();
-        free(numadata);
-        return NULL;
+        goto fail;
     }
 
     memset(srat, 0, srat_size);
@@ -677,7 +675,7 @@
         core->type = SRAT_PROCESSOR;
         core->length = sizeof(*core);
         core->local_apic_id = i;
-        curnode = *numadata++;
+        curnode = *numacpumap++;
         core->proximity_lo = curnode;
         memset(core->proximity_hi, 0, 3);
         core->local_sapic_eid = 0;
@@ -731,7 +729,12 @@
     build_header((void*)srat, SRAT_SIGNATURE, srat_size, 1);
 
     free(numadata);
+    free(numacpumap);
     return srat;
+fail:
+    free(numadata);
+    free(numacpumap);
+    return NULL;
 }
 
 static void *
diff --git a/src/paravirt.c b/src/paravirt.c
index 4a26c6e..ee6a86e 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -223,8 +223,11 @@
     // NUMA data
     u64 numacount;
     qemu_cfg_read_entry(&numacount, QEMU_CFG_NUMA, sizeof(numacount));
-    numacount += romfile_loadint("etc/max-cpus", 0);
-    qemu_romfile_add("etc/numa-nodes", QEMU_CFG_NUMA, sizeof(numacount)
+    int max_cpu = romfile_loadint("etc/max-cpus", 0);
+    qemu_romfile_add("etc/numa-cpu-map", QEMU_CFG_NUMA, sizeof(numacount)
+                     , max_cpu*sizeof(u64));
+    qemu_romfile_add("etc/numa-nodes", QEMU_CFG_NUMA
+                     , sizeof(numacount) + max_cpu*sizeof(u64)
                      , numacount*sizeof(u64));
 
     // e820 data