qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH v5 2/5] Support adding a file to qemu's ram allo


From: Avi Kivity
Subject: [Qemu-devel] Re: [PATCH v5 2/5] Support adding a file to qemu's ram allocation
Date: Mon, 10 May 2010 13:39:27 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4

On 04/21/2010 08:53 PM, Cam Macdonell wrote:
This avoids the need of using qemu_ram_alloc and mmap with MAP_FIXED to map a
host file into guest RAM.  This function mmaps the opened file anywhere and adds
the memory to the ram blocks.

Usage is

qemu_ram_mmap(fd, size, MAP_SHARED, offset);

Signoff?

+ram_addr_t qemu_ram_mmap(int fd, ram_addr_t size, int flags, off_t offset)
+{
+    RAMBlock *new_block;
+
+    size = TARGET_PAGE_ALIGN(size);
+    new_block = qemu_malloc(sizeof(*new_block));
+
+    /* map the file passed as a parameter to be this part of memory */
+    new_block->host = mmap(0, size, PROT_READ|PROT_WRITE, flags, fd, offset);
+
+    if (new_block->host == MAP_FAILED)
+        exit(1);

Braces after if ()

+    if (kvm_enabled())
+        kvm_setup_guest_memory(new_block->host, size);
+

More braces.

--
error compiling committee.c: too many arguments to function





reply via email to

[Prev in Thread] Current Thread [Next in Thread]