From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH7Hh-0004Zh-3b for qemu-devel@nongnu.org; Tue, 12 Aug 2014 04:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XH7Hc-0000xf-96 for qemu-devel@nongnu.org; Tue, 12 Aug 2014 04:18:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH7Hc-0000wn-0i for qemu-devel@nongnu.org; Tue, 12 Aug 2014 04:18:16 -0400 Date: Tue, 12 Aug 2014 09:18:01 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20140812081800.GA2384@work-vm> References: <1407767399-3030-1-git-send-email-dgilbert@redhat.com> <1407767399-3030-20-git-send-email-dgilbert@redhat.com> <53E9A6F9.5010108@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53E9A6F9.5010108@huawei.com> Subject: Re: [Qemu-devel] [PATCH v2 19/43] postcopy: OS support test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, qemu-devel@nongnu.org, lilei@linux.vnet.ibm.com * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: > On 2014/8/11 22:29, Dr. David Alan Gilbert (git) wrote: > >From: "Dr. David Alan Gilbert" > > > >+ testarea2 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | > >+ MAP_ANONYMOUS, -1, 0); > >+ if (!testarea2) { > >+ perror("postcopy_ram_hosttest: Failed to map second test area"); > > Before return, should we munmap testarea? > BTW, i think it is better to use goto statement, > which we can handle the error cases together! Yes, thank you for spotting this; I'll fix it in my next version. Dave > > Best regards, > zhanghailiang > >+ return -1; > >+ } > >+ g_assert(((size_t)testarea2& (pagesize-1)) == 0); > >+ *(char *)testarea = 0; /* Force the map of the new page */ > >+ if (syscall(__NR_remap_anon_pages, testarea2, testarea, pagesize, 0) != > >+ pagesize) { > >+ perror("postcopy_ram_hosttest: remap_anon_pages not available"); > >+ munmap(testarea, pagesize); > >+ munmap(testarea2, pagesize); > >+ return -1; > >+ } > >+ > >+ munmap(testarea, pagesize); > >+ munmap(testarea2, pagesize); > >+ return 0; > >+} > >+ > >+#else > >+/* No target OS support, stubs just fail */ > >+ > >+int postcopy_ram_hosttest(void) > >+{ > >+ error_report("postcopy_ram_hosttest: No OS support"); > >+ return -1; > >+} > >+ > >+#endif > >+ > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK