mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
NUMA: Enable adding NUMA node implicitly
Linux and Windows need ACPI SRAT table to make memory hotplug work properly, however currently QEMU doesn't create SRAT table if numa options aren't present on CLI. Which breaks both linux and windows guests in certain conditions: * Windows: won't enable memory hotplug without SRAT table at all * Linux: if QEMU is started with initial memory all below 4Gb and no SRAT table present, guest kernel will use nommu DMA ops, which breaks 32bit hw drivers when memory is hotplugged and guest tries to use it with that drivers. Fix above issues by automatically creating a numa node when QEMU is started with memory hotplug enabled but without '-numa' options on CLI. (PS: auto-create numa node only for new machine types so not to break migration). Which would provide SRAT table to guests without explicit -numa options on CLI and would allow: * Windows: to enable memory hotplug * Linux: switch to SWIOTLB DMA ops, to bounce DMA transfers to 32bit allocated buffers that legacy drivers/hw can handle. [Rewritten by Igor] Reported-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> Suggested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: Thomas Huth <thuth@redhat.com> Cc: Alistair Francis <alistair23@gmail.com> Cc: Takao Indoh <indou.takao@jp.fujitsu.com> Cc: Izumi Taku <izumi.taku@jp.fujitsu.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
45bd4b1c09
commit
7b8be49d36
6 changed files with 25 additions and 3 deletions
21
numa.c
21
numa.c
|
@ -216,6 +216,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
|
|||
}
|
||||
numa_info[nodenr].present = true;
|
||||
max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
|
||||
nb_numa_nodes++;
|
||||
}
|
||||
|
||||
static void parse_numa_distance(NumaDistOptions *dist, Error **errp)
|
||||
|
@ -282,7 +283,6 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
|
|||
if (err) {
|
||||
goto end;
|
||||
}
|
||||
nb_numa_nodes++;
|
||||
break;
|
||||
case NUMA_OPTIONS_TYPE_DIST:
|
||||
parse_numa_distance(&object->u.dist, &err);
|
||||
|
@ -433,6 +433,25 @@ void parse_numa_opts(MachineState *ms)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* If memory hotplug is enabled (slots > 0) but without '-numa'
|
||||
* options explicitly on CLI, guestes will break.
|
||||
*
|
||||
* Windows: won't enable memory hotplug without SRAT table at all
|
||||
*
|
||||
* Linux: if QEMU is started with initial memory all below 4Gb
|
||||
* and no SRAT table present, guest kernel will use nommu DMA ops,
|
||||
* which breaks 32bit hw drivers when memory is hotplugged and
|
||||
* guest tries to use it with that drivers.
|
||||
*
|
||||
* Enable NUMA implicitly by adding a new NUMA node automatically.
|
||||
*/
|
||||
if (ms->ram_slots > 0 && nb_numa_nodes == 0 &&
|
||||
mc->auto_enable_numa_with_memhp) {
|
||||
NumaNodeOptions node = { };
|
||||
parse_numa_node(ms, &node, NULL);
|
||||
}
|
||||
|
||||
assert(max_numa_nodeid <= MAX_NODES);
|
||||
|
||||
/* No support for sparse NUMA node IDs yet: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue