From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apwuv-0004Im-Vg for qemu-devel@nongnu.org; Tue, 12 Apr 2016 07:55:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1apwuu-0008LS-Rz for qemu-devel@nongnu.org; Tue, 12 Apr 2016 07:55:37 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:35124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apwuu-0008LN-LW for qemu-devel@nongnu.org; Tue, 12 Apr 2016 07:55:36 -0400 Received: by mail-qk0-x22c.google.com with SMTP id o6so4894079qkc.2 for ; Tue, 12 Apr 2016 04:55:36 -0700 (PDT) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Tue, 12 Apr 2016 13:55:21 +0200 Message-Id: <1460462129-17363-2-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1460462129-17363-1-git-send-email-marcandre.lureau@redhat.com> References: <1460462129-17363-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 1/9] exec: check kvm mmu notifiers earlier List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau Move kvm mmu notifiers check before calling file_ram_alloc(). This shouldn't change the validation logic. Signed-off-by: Marc-André Lureau --- exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index c4f9036..dcc6632 100644 --- a/exec.c +++ b/exec.c @@ -1242,12 +1242,6 @@ static void *file_ram_alloc(RAMBlock *block, int fd = -1; int64_t page_size; - if (kvm_enabled() && !kvm_has_sync_mmu()) { - error_setg(errp, - "host lacks kvm mmu notifiers, -mem-path unsupported"); - return NULL; - } - for (;;) { fd = open(path, O_RDWR); if (fd >= 0) { @@ -1675,6 +1669,12 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, return NULL; } + if (kvm_enabled() && !kvm_has_sync_mmu()) { + error_setg(errp, + "host lacks kvm mmu notifiers, -mem-path unsupported"); + return NULL; + } + size = HOST_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); new_block->mr = mr; -- 2.5.5