Convert fw_cfg NUMA entries into a romfile entry.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
diff --git a/src/acpi.c b/src/acpi.c
index aebf26e..f7a2e55 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -12,8 +12,8 @@
 #include "pci_ids.h" // PCI_VENDOR_ID_INTEL
 #include "pci_regs.h" // PCI_INTERRUPT_LINE
 #include "ioport.h" // inl
-#include "paravirt.h" // qemu_cfg_irq0_override
-#include "dev-q35.h" // qemu_cfg_irq0_override
+#include "config.h" // CONFIG_*
+#include "dev-q35.h"
 
 /****************************************************/
 /* ACPI tables init */
@@ -672,22 +672,16 @@
 static void *
 build_srat(void)
 {
-    int nb_numa_nodes = qemu_cfg_get_numa_nodes();
-
-    if (nb_numa_nodes == 0)
+    int filesize;
+    u64 *numadata = romfile_loadfile("etc/numa-nodes", &filesize);
+    if (!numadata)
         return NULL;
-
-    u64 *numadata = malloc_tmphigh(sizeof(u64) * (MaxCountCPUs + nb_numa_nodes));
-    if (!numadata) {
-        warn_noalloc();
-        return NULL;
-    }
-
-    qemu_cfg_get_numa_data(numadata, MaxCountCPUs + nb_numa_nodes);
+    int max_cpu = romfile_loadint("etc/max-cpus", 0);
+    int nb_numa_nodes = (filesize / sizeof(u64)) - max_cpu;
 
     struct system_resource_affinity_table *srat;
     int srat_size = sizeof(*srat) +
-        sizeof(struct srat_processor_affinity) * MaxCountCPUs +
+        sizeof(struct srat_processor_affinity) * max_cpu +
         sizeof(struct srat_memory_affinity) * (nb_numa_nodes + 2);
 
     srat = malloc_high(srat_size);
@@ -703,7 +697,7 @@
     int i;
     u64 curnode;
 
-    for (i = 0; i < MaxCountCPUs; ++i) {
+    for (i = 0; i < max_cpu; ++i) {
         core->type = SRAT_PROCESSOR;
         core->length = sizeof(*core);
         core->local_apic_id = i;
diff --git a/src/paravirt.c b/src/paravirt.c
index 79b1c56..0c91c8d 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -189,23 +189,6 @@
     return addr;
 }
 
-int qemu_cfg_get_numa_nodes(void)
-{
-    u64 cnt;
-
-    qemu_cfg_read_entry(&cnt, QEMU_CFG_NUMA, sizeof(cnt));
-
-    return (int)cnt;
-}
-
-void qemu_cfg_get_numa_data(u64 *data, int n)
-{
-    int i;
-
-    for (i = 0; i < n; i++)
-        qemu_cfg_read((u8*)(data + i), sizeof(u64));
-}
-
 static int
 qemu_cfg_read_file(struct romfile_s *file, void *dst, u32 maxlen)
 {
@@ -254,6 +237,13 @@
     qemu_romfile_add("etc/irq0-override", QEMU_CFG_IRQ0_OVERRIDE, 0, 1);
     qemu_romfile_add("etc/max-cpus", QEMU_CFG_MAX_CPUS, 0, 2);
 
+    // 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)
+                     , numacount*sizeof(u64));
+
     // ACPI tables
     char name[128];
     u16 cnt;
diff --git a/src/paravirt.h b/src/paravirt.h
index e92e236..527522b 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -26,8 +26,6 @@
 void qemu_ramsize_preinit(void);
 void qemu_biostable_setup(void);
 void qemu_cfg_preinit(void);
-int qemu_cfg_get_numa_nodes(void);
-void qemu_cfg_get_numa_data(u64 *data, int n);
 u32 qemu_cfg_e820_entries(void);
 void* qemu_cfg_e820_load_next(void *addr);
 void qemu_romfile_init(void);