mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemu: Generate -numa option
Add routines to generate -numa QEMU command line option based on <numa> ... </numa> XML specifications. Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
This commit is contained in:
parent
5f7b71b413
commit
9b6bb0fef6
@ -352,11 +352,12 @@ virCPUDefParseXML(const xmlNodePtr node,
|
||||
|
||||
ret = virStrToLong_ui(memory, NULL, 10, &def->cells[i].mem);
|
||||
if (ret == -1) {
|
||||
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Invalid 'memory' attribute in NUMA cell"));
|
||||
VIR_FREE(cpus);
|
||||
VIR_FREE(memory);
|
||||
goto error;
|
||||
}
|
||||
|
||||
VIR_FREE(cpus);
|
||||
VIR_FREE(memory);
|
||||
}
|
||||
|
@ -3401,6 +3401,65 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
|
||||
return virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
||||
static void
|
||||
qemuBuildNumaCPUArgStr(char *cpumask, virBufferPtr buf)
|
||||
{
|
||||
int i, first, last;
|
||||
int cpuSet = 0;
|
||||
|
||||
for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++) {
|
||||
if (cpumask[i]) {
|
||||
if (cpuSet) {
|
||||
last = i;
|
||||
} else {
|
||||
first = last = i;
|
||||
cpuSet = 1;
|
||||
}
|
||||
} else {
|
||||
if (!cpuSet)
|
||||
continue;
|
||||
if (first == last)
|
||||
virBufferAsprintf(buf, "%d,", first);
|
||||
else
|
||||
virBufferAsprintf(buf, "%d-%d,", first, last);
|
||||
cpuSet = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (cpuSet) {
|
||||
if (first == last)
|
||||
virBufferAsprintf(buf, "%d,", first);
|
||||
else
|
||||
virBufferAsprintf(buf, "%d-%d,", first, last);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
qemuBuildNumaArgStr(const virDomainDefPtr def, virCommandPtr cmd)
|
||||
{
|
||||
int i;
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
for (i = 0; i < def->cpu->ncells; i++) {
|
||||
virCommandAddArg(cmd, "-numa");
|
||||
virBufferAsprintf(&buf, "node,nodeid=%d", def->cpu->cells[i].cellid);
|
||||
virBufferAddLit(&buf, ",cpus=");
|
||||
qemuBuildNumaCPUArgStr(def->cpu->cells[i].cpumask, &buf);
|
||||
virBufferAsprintf(&buf, "mem=%d",
|
||||
VIR_DIV_UP(def->cpu->cells[i].mem, 1024));
|
||||
|
||||
if (virBufferError(&buf))
|
||||
goto error;
|
||||
|
||||
virCommandAddArgBuffer(cmd, &buf);
|
||||
}
|
||||
return 0;
|
||||
|
||||
error:
|
||||
virBufferFreeAndReset(&buf);
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructs a argv suitable for launching qemu with config defined
|
||||
@ -3562,6 +3621,10 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
virCommandAddArg(cmd, smp);
|
||||
VIR_FREE(smp);
|
||||
|
||||
if (def->cpu && def->cpu->ncells)
|
||||
if (qemuBuildNumaArgStr(def, cmd) < 0)
|
||||
goto error;
|
||||
|
||||
if (qemuCapsGet(qemuCaps, QEMU_CAPS_NAME)) {
|
||||
virCommandAddArg(cmd, "-name");
|
||||
if (driver->setProcessName &&
|
||||
|
5
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args
Normal file
5
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.args
Normal file
@ -0,0 +1,5 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \
|
||||
-m 214 -smp 16 -numa node,nodeid=0,cpus=0-7,mem=107 \
|
||||
-numa node,nodeid=1,cpus=8-15,mem=107 -nographic -monitor \
|
||||
unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none \
|
||||
-parallel none -usb
|
25
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml
Normal file
25
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219100</memory>
|
||||
<currentMemory>219100</currentMemory>
|
||||
<vcpu>16</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
<boot dev='network'/>
|
||||
</os>
|
||||
<cpu>
|
||||
<topology sockets="2" cores="4" threads="2"/>
|
||||
<numa>
|
||||
<cell cpus="0-7" memory="109550"/>
|
||||
<cell cpus="8-15" memory="109550"/>
|
||||
</numa>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/./qemu.sh</emulator>
|
||||
</devices>
|
||||
</domain>
|
6
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args
Normal file
6
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.args
Normal file
@ -0,0 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc \
|
||||
-m 214 -smp 16,sockets=2,cores=4,threads=2 \
|
||||
-numa node,nodeid=0,cpus=0-7,mem=107 \
|
||||
-numa node,nodeid=1,cpus=8-15,mem=107 -nographic -monitor \
|
||||
unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net none -serial none \
|
||||
-parallel none -usb
|
25
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml
Normal file
25
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219100</memory>
|
||||
<currentMemory>219100</currentMemory>
|
||||
<vcpu>16</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc'>hvm</type>
|
||||
<boot dev='network'/>
|
||||
</os>
|
||||
<cpu>
|
||||
<topology sockets="2" cores="4" threads="2"/>
|
||||
<numa>
|
||||
<cell cpus="0-7" memory="109550"/>
|
||||
<cell cpus="8-15" memory="109550"/>
|
||||
</numa>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/./qemu.sh</emulator>
|
||||
</devices>
|
||||
</domain>
|
@ -638,6 +638,8 @@ mymain(void)
|
||||
DO_TEST("cpu-exact1", false, NONE);
|
||||
DO_TEST("cpu-exact2", false, NONE);
|
||||
DO_TEST("cpu-strict1", false, NONE);
|
||||
DO_TEST("cpu-numa1", false, NONE);
|
||||
DO_TEST("cpu-numa2", false, QEMU_CAPS_SMP_TOPOLOGY);
|
||||
|
||||
DO_TEST("memtune", false, QEMU_CAPS_NAME);
|
||||
DO_TEST("blkiotune", false, QEMU_CAPS_NAME);
|
||||
|
Loading…
x
Reference in New Issue
Block a user