From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmloW-0007fZ-01 for qemu-devel@nongnu.org; Tue, 20 May 2014 11:18:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmloB-0000mS-Rs for qemu-devel@nongnu.org; Tue, 20 May 2014 11:18:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmloB-0000m6-HA for qemu-devel@nongnu.org; Tue, 20 May 2014 11:18:27 -0400 From: Igor Mammedov Date: Tue, 20 May 2014 17:15:06 +0200 Message-Id: <1400598934-31921-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1400598934-31921-1-git-send-email-imammedo@redhat.com> References: <1400598934-31921-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v2 03/31] 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, alex@alex.org.uk, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, mjt@tls.msk.ru, tangchen@cn.fujitsu.com, kraxel@redhat.com, pasteka@kabsi.at, s.priebe@profihost.ag, agarcia@igalia.com, armbru@redhat.com, aliguori@amazon.com, david@gibson.dropbear.id.au, lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, rth@twiddle.net, agraf@suse.de, andrey@xdel.ru, vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, afaerber@suse.de, aurelien@aurel32.net memory allocated for guest before QEMU is daemonized and then mapped later in guest's address space after it is daemonized, leads to EPT violation and QEMU aborts. To avoid this and similar issues switch to daemonized mode early before processing applying/processing other options. Signed-off-by: Igor Mammedov --- I haven't digged in kvm itself 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 | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index cda6220..8fd4ed9 100644 --- a/vl.c +++ b/vl.c @@ -3963,6 +3963,8 @@ int main(int argc, char **argv, char **envp) } loc_set_none(); + os_daemonize(); + if (qemu_init_main_loop()) { fprintf(stderr, "qemu_init_main_loop failed\n"); exit(1); @@ -4200,8 +4202,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); -- 1.7.1