Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K2nQW-0007Z9-FV for qemu-devel@nongnu.org; Sun, 01 Jun 2008 09:16:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K2nQV-0007XS-0k for qemu-devel@nongnu.org; Sun, 01 Jun 2008 09:16:47 -0400 Received: from [199.232.76.173] (port=46616 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2nQU-0007Wa-DW for qemu-devel@nongnu.org; Sun, 01 Jun 2008 09:16:46 -0400 Received: from gwyn.kn-bremen.de ([212.63.36.242]:39979) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K2nQU-0000TQ-6e for qemu-devel@nongnu.org; Sun, 01 Jun 2008 09:16:46 -0400 Received: from saturn.kn-bremen.de (nox@localhost [127.0.0.1]) by saturn.kn-bremen.de (8.14.2/8.13.8) with ESMTP id m51DF8un073789 for ; Sun, 1 Jun 2008 15:15:08 +0200 (CEST) (envelope-from nox@saturn.kn-bremen.de) Received: (from nox@localhost) by saturn.kn-bremen.de (8.14.2/8.13.6/Submit) id m51DF8tN073788 for qemu-devel@nongnu.org; Sun, 1 Jun 2008 15:15:08 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Sun, 1 Jun 2008 15:15:07 +0200 Subject: Re: [Qemu-devel] osdep.c patch (FreeBSD hosts) Message-ID: <20080601131507.GA73766@saturn.kn-bremen.de> References: <20080529214007.GA26341@saturn.kn-bremen.de> <483F2617.7020900@bellard.org> <20080529225713.GA28563@saturn.kn-bremen.de> <20080529230305.GA28979@saturn.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080529230305.GA28979@saturn.kn-bremen.de> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Fri, May 30, 2008 at 01:03:05AM +0200, Juergen Lock wrote: > On Fri, May 30, 2008 at 12:57:13AM +0200, Juergen Lock wrote: > > On Thu, May 29, 2008 at 11:54:31PM +0200, Fabrice Bellard wrote: > > > Is it really needed to mmap() the RAM on FreeBSD ? This is a Linux > > > specific hack, and it may even be obsolete with recent Linux kernels. > > > > > Hmm actually I don't know... You think the... > > > > > > +#else > > > > + ptr = mmap(NULL, > > > > + size, > > > > + PROT_WRITE | PROT_READ, MAP_PRIVATE|MAP_ANON, > > > > + -1, 0); > > > > +#endif > > > > could be replaced by just malloc? Or would there be align issues too? > > ..and I just checked the manpage, our malloc page-aligns too (for sizes >= > pagesize), so at least that shouldn't be an issue. Ok and I just tested the following patch and it worked for me: Index: qemu/osdep.c @@ -83,7 +83,9 @@ #if defined(USE_KQEMU) +#ifndef __FreeBSD__ #include +#endif #include #include @@ -94,6 +96,7 @@ const char *tmpdir; char phys_ram_file[1024]; void *ptr; +#ifndef __FreeBSD__ #ifdef HOST_SOLARIS struct statvfs stfs; #else @@ -155,7 +158,9 @@ } unlink(phys_ram_file); } +#endif size = (size + 4095) & ~4095; +#ifndef __FreeBSD__ ftruncate(phys_ram_fd, phys_ram_size + size); ptr = mmap(NULL, size, @@ -165,6 +170,13 @@ fprintf(stderr, "Could not map physical memory\n"); exit(1); } +#else + ptr = malloc(size); + if (ptr == NULL) { + fprintf(stderr, "Could not allocate physical memory\n"); + exit(1); + } +#endif phys_ram_size += size; return ptr; }