aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorSatoru Moriya <satoru.moriya@hds.com>2013-04-19 16:42:06 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-04-22 08:52:23 -0500
commit888a6bc63c94ef34026399117ebf6a1fa0e7a29a (patch)
tree9a7eaa7b65500baf6099eb9118c92aa220c3b4f1 /vl.c
parent2b316774f60291f57ca9ecb6a9f0712c532cae34 (diff)
Add option to mlock qemu and guest memory
In certain scenario, latency induced by paging is significant and memory locking is needed. Also, in the scenario with untrusted guests, latency improvement due to mlock is desired. This patch introduces a following new option to mlock guest and qemu memory: -realtime mlock=on|off Signed-off-by: Satoru Moriya <satoru.moriya@hds.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1366382526-26146-1-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 2ef00d893a..6caa5f4272 100644
--- a/vl.c
+++ b/vl.c
@@ -521,6 +521,18 @@ static QemuOptsList qemu_tpmdev_opts = {
},
};
+static QemuOptsList qemu_realtime_opts = {
+ .name = "realtime",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts.head),
+ .desc = {
+ {
+ .name = "mlock",
+ .type = QEMU_OPT_BOOL,
+ },
+ { /* end of list */ }
+ },
+};
+
const char *qemu_get_vm_name(void)
{
return qemu_name;
@@ -1420,6 +1432,20 @@ static void smp_parse(const char *optarg)
max_cpus = smp_cpus;
}
+static void configure_realtime(QemuOpts *opts)
+{
+ bool enable_mlock;
+
+ enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
+
+ if (enable_mlock) {
+ if (os_mlock() < 0) {
+ fprintf(stderr, "qemu: locking memory failed\n");
+ exit(1);
+ }
+ }
+}
+
/***********************************************************/
/* USB devices */
@@ -2862,6 +2888,7 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_add_fd_opts);
qemu_add_opts(&qemu_object_opts);
qemu_add_opts(&qemu_tpmdev_opts);
+ qemu_add_opts(&qemu_realtime_opts);
runstate_init();
@@ -3835,6 +3862,13 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
break;
+ case QEMU_OPTION_realtime:
+ opts = qemu_opts_parse(qemu_find_opts("realtime"), optarg, 0);
+ if (!opts) {
+ exit(1);
+ }
+ configure_realtime(opts);
+ break;
default:
os_parse_cmd_args(popt->index, optarg);
}