From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmV34-0001bd-Jr for qemu-devel@nongnu.org; Mon, 19 May 2014 17:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmV2y-0003CI-FA for qemu-devel@nongnu.org; Mon, 19 May 2014 17:24:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmV2y-0003Bx-7F for qemu-devel@nongnu.org; Mon, 19 May 2014 17:24:36 -0400 From: Igor Mammedov Date: Mon, 19 May 2014 23:24:28 +0200 Message-Id: <1400534668-19558-1-git-send-email-imammedo@redhat.com> In-Reply-To: <5369F9A8.8030800@profihost.ag> References: <5369F9A8.8030800@profihost.ag> Subject: [Qemu-devel] [PATCH] vl.c: daemonize before guest memory allocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mst@redhat.com, jan.kiszka@siemens.com, s.priebe@profihost.ag, aliguori@amazon.com, pbonzini@redhat.com memory allocated for guest before QEMU is demonized and then mapped later in guest's addess space after it is demonized, leads to EPT violation and QEMU abort. To avoid this and similar issues switch to deamonized mode early before processing applying/processing other options. Signed-off-by: Igor Mammedov --- I haven't digged in kvm itsefl yet why EPT violation happens, but fix on QEMU side looks trivial so it won't hurt to use it anyway. there is simpler reporoducer without migration: start guest with '-object memory-ram,id=foo,size=1G' when guest is up and running hotplug dimm device using 'foo' memdev as backend. --- vl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/vl.c b/vl.c index ca9db1c..19f731d 100644 --- a/vl.c +++ b/vl.c @@ -4012,6 +4012,14 @@ int main(int argc, char **argv, char **envp) } loc_set_none(); + os_daemonize(); + + if (pid_file && qemu_create_pidfile(pid_file) != 0) { + os_pidfile_error(); + exit(1); + } + + if (qemu_init_main_loop()) { fprintf(stderr, "qemu_init_main_loop failed\n"); exit(1); @@ -4249,13 +4257,6 @@ int main(int argc, char **argv, char **envp) } #endif - os_daemonize(); - - if (pid_file && qemu_create_pidfile(pid_file) != 0) { - os_pidfile_error(); - exit(1); - } - /* store value for the future use */ qemu_opt_set_number(qemu_find_opts_singleton("memory"), "size", ram_size); -- 1.9.0