mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
qemu: Implement support for locking domain's memory pages
This commit is contained in:
parent
555866389c
commit
fd74f74fe6
@ -230,6 +230,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
||||
"mem-merge",
|
||||
"vnc-websocket",
|
||||
"drive-discard",
|
||||
"mlock",
|
||||
);
|
||||
|
||||
struct _virQEMUCaps {
|
||||
@ -2246,6 +2247,7 @@ struct virQEMUCapsCommandLineProps {
|
||||
static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
|
||||
{ "machine", "mem-merge", QEMU_CAPS_MEM_MERGE },
|
||||
{ "drive", "discard", QEMU_CAPS_DRIVE_DISCARD },
|
||||
{ "realtime", "mlock", QEMU_CAPS_MLOCK },
|
||||
};
|
||||
|
||||
static int
|
||||
|
@ -187,6 +187,7 @@ enum virQEMUCapsFlags {
|
||||
QEMU_CAPS_MEM_MERGE = 146, /* -machine mem-merge */
|
||||
QEMU_CAPS_VNC_WEBSOCKET = 147, /* -vnc x:y,websocket */
|
||||
QEMU_CAPS_DRIVE_DISCARD = 148, /* -drive discard=off(ignore)|on(unmap) */
|
||||
QEMU_CAPS_MLOCK = 149, /* -realtime mlock=on|off */
|
||||
|
||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||
};
|
||||
|
@ -6541,6 +6541,17 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
cfg->hugepagePath, NULL);
|
||||
}
|
||||
|
||||
if (def->mem.locked && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_MLOCK)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("memory locking not supported by QEMU binary"));
|
||||
goto error;
|
||||
}
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MLOCK)) {
|
||||
virCommandAddArg(cmd, "-realtime");
|
||||
virCommandAddArgFormat(cmd, "mlock=%s",
|
||||
def->mem.locked ? "on" : "off");
|
||||
}
|
||||
|
||||
virCommandAddArg(cmd, "-smp");
|
||||
if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
|
||||
goto error;
|
||||
|
4
tests/qemuxml2argvdata/qemuxml2argv-mlock-off.args
Normal file
4
tests/qemuxml2argvdata/qemuxml2argv-mlock-off.args
Normal file
@ -0,0 +1,4 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
|
||||
/usr/bin/qemu -S -M pc -m 214 -realtime mlock=off \
|
||||
-smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot c -usb -net none -serial none -parallel none
|
15
tests/qemuxml2argvdata/qemuxml2argv-mlock-off.xml
Normal file
15
tests/qemuxml2argvdata/qemuxml2argv-mlock-off.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
4
tests/qemuxml2argvdata/qemuxml2argv-mlock-on.args
Normal file
4
tests/qemuxml2argvdata/qemuxml2argv-mlock-on.args
Normal file
@ -0,0 +1,4 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
|
||||
/usr/bin/qemu -S -M pc -m 214 -realtime mlock=on \
|
||||
-smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot c -usb -net none -serial none -parallel none
|
18
tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml
Normal file
18
tests/qemuxml2argvdata/qemuxml2argv-mlock-on.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<memoryBacking>
|
||||
<locked/>
|
||||
</memoryBacking>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -0,0 +1,4 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
|
||||
/usr/bin/qemu -S -M pc -m 214 \
|
||||
-smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
||||
-no-acpi -boot c -usb -net none -serial none -parallel none
|
15
tests/qemuxml2argvdata/qemuxml2argv-mlock-unsupported.xml
Normal file
15
tests/qemuxml2argvdata/qemuxml2argv-mlock-unsupported.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -1007,6 +1007,11 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE_SCSI_GENERIC,
|
||||
QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX);
|
||||
|
||||
DO_TEST("mlock-on", QEMU_CAPS_MLOCK);
|
||||
DO_TEST_FAILURE("mlock-on", NONE);
|
||||
DO_TEST("mlock-off", QEMU_CAPS_MLOCK);
|
||||
DO_TEST("mlock-unsupported", NONE);
|
||||
|
||||
virObjectUnref(driver.config);
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlopt);
|
||||
|
Loading…
Reference in New Issue
Block a user