aboutsummaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-05-14 17:43:21 +0800
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 18:44:19 +0300
commit38183310be7af6af5ee60e7c9e9647133a7d11c3 (patch)
tree5b43582a4745b4c604c1366c1f3d47d5aadc0f70 /exec.c
parente1c57ab86f3c4ea6532b51cfecf32770b45f5e7a (diff)
downloadqemu-38183310be7af6af5ee60e7c9e9647133a7d11c3.zip
qemu-38183310be7af6af5ee60e7c9e9647133a7d11c3.tar.gz
qemu-38183310be7af6af5ee60e7c9e9647133a7d11c3.tar.bz2
memory: move preallocation code out of exec.c
So that backends can use it. Since we need the page size for efficiency, move code to compute it out of translate-all.c and into util/oslib-win32.c. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c44
1 files changed, 1 insertions, 43 deletions
diff --git a/exec.c b/exec.c
index 02167ca..dae50a1 100644
--- a/exec.c
+++ b/exec.c
@@ -1011,13 +1011,6 @@ static long gethugepagesize(const char *path)
return fs.f_bsize;
}
-static sigjmp_buf sigjump;
-
-static void sigbus_handler(int signal)
-{
- siglongjmp(sigjump, 1);
-}
-
static void *file_ram_alloc(RAMBlock *block,
ram_addr_t memory,
const char *path)
@@ -1082,42 +1075,7 @@ static void *file_ram_alloc(RAMBlock *block,
}
if (mem_prealloc) {
- int ret, i;
- struct sigaction act, oldact;
- sigset_t set, oldset;
-
- memset(&act, 0, sizeof(act));
- act.sa_handler = &sigbus_handler;
- act.sa_flags = 0;
-
- ret = sigaction(SIGBUS, &act, &oldact);
- if (ret) {
- perror("file_ram_alloc: failed to install signal handler");
- exit(1);
- }
-
- /* unblock SIGBUS */
- sigemptyset(&set);
- sigaddset(&set, SIGBUS);
- pthread_sigmask(SIG_UNBLOCK, &set, &oldset);
-
- if (sigsetjmp(sigjump, 1)) {
- fprintf(stderr, "file_ram_alloc: failed to preallocate pages\n");
- exit(1);
- }
-
- /* MAP_POPULATE silently ignores failures */
- for (i = 0; i < (memory/hpagesize); i++) {
- memset(area + (hpagesize*i), 0, 1);
- }
-
- ret = sigaction(SIGBUS, &oldact, NULL);
- if (ret) {
- perror("file_ram_alloc: failed to reinstall signal handler");
- exit(1);
- }
-
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+ os_mem_prealloc(fd, area, memory);
}
block->fd = fd;