summaryrefslogtreecommitdiff
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2016-11-30 14:11:48 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2016-11-30 14:11:58 +0900
commit2371603ef207b015cc29728296b21cb1722d8ae6 (patch)
tree25cbb62daf29066fa874b9a4b8f754bc18187806 /util/oslib-posix.c
parentd5df306aedcc13cf5a2463ddf858c8d718a788d5 (diff)
parentd4dcb59384ab4433702f015fdddda1eff8e3927f (diff)
downloadqemu-2371603ef207b015cc29728296b21cb1722d8ae6.tar.gz
qemu-2371603ef207b015cc29728296b21cb1722d8ae6.tar.bz2
qemu-2371603ef207b015cc29728296b21cb1722d8ae6.zip
Merge branch 'develop_qemu_2.7' into develop
Change-Id: Ibae70e3c0d1d88632903f98be114f47af9ca7502 Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 7afc05ca7d..d400dcd720 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -26,19 +26,6 @@
* THE SOFTWARE.
*/
-#if defined(__linux__) && \
- (defined(__x86_64__) || defined(__arm__) || defined(__aarch64__))
- /* Use 2 MiB alignment so transparent hugepages can be used by KVM.
- Valgrind does not support alignments larger than 1 MiB,
- therefore we need special code which handles running on Valgrind. */
-# define QEMU_VMALLOC_ALIGN (512 * 4096)
-#elif defined(__linux__) && defined(__s390x__)
- /* Use 1 MiB (segment size) alignment so gmap can be used by KVM. */
-# define QEMU_VMALLOC_ALIGN (256 * 4096)
-#else
-# define QEMU_VMALLOC_ALIGN getpagesize()
-#endif
-
#include "qemu/osdep.h"
#include <termios.h>
#include <termios.h>
@@ -49,8 +36,6 @@
#include "trace.h"
#include "qapi/error.h"
#include "qemu/sockets.h"
-#include "qemu/error-report.h"
-#include <sys/mman.h>
#include <libgen.h>
#include <sys/signal.h>
#include "qemu/cutils.h"
@@ -63,9 +48,10 @@
#include <sys/sysctl.h>
#endif
-#include <qemu/mmap-alloc.h>
+#include "qemu/mmap-alloc.h"
#ifdef CONFIG_MARU
+#include "qemu/error-report.h"
#include "../../tizen/src/emulator_common.h"
#endif
@@ -333,9 +319,11 @@ void qemu_init_exec_dir(const char *argv0)
return;
}
}
- dir = dirname(p);
+ dir = g_path_get_dirname(p);
pstrcpy(exec_dir, sizeof(exec_dir), dir);
+
+ g_free(dir);
}
char *qemu_get_exec_dir(void)
@@ -350,7 +338,7 @@ static void sigbus_handler(int signal)
siglongjmp(sigjump, 1);
}
-void os_mem_prealloc(int fd, char *area, size_t memory)
+void os_mem_prealloc(int fd, char *area, size_t memory, Error **errp)
{
int ret;
struct sigaction act, oldact;
@@ -362,8 +350,9 @@ void os_mem_prealloc(int fd, char *area, size_t memory)
ret = sigaction(SIGBUS, &act, &oldact);
if (ret) {
- perror("os_mem_prealloc: failed to install signal handler");
- exit(1);
+ error_setg_errno(errp, errno,
+ "os_mem_prealloc: failed to install signal handler");
+ return;
}
/* unblock SIGBUS */
@@ -372,9 +361,8 @@ void os_mem_prealloc(int fd, char *area, size_t memory)
pthread_sigmask(SIG_UNBLOCK, &set, &oldset);
if (sigsetjmp(sigjump, 1)) {
- fprintf(stderr, "os_mem_prealloc: Insufficient free host memory "
- "pages available to allocate guest RAM\n");
- exit(1);
+ error_setg(errp, "os_mem_prealloc: Insufficient free host memory "
+ "pages available to allocate guest RAM\n");
} else {
int i;
size_t hpagesize = qemu_fd_getpagesize(fd);
@@ -384,15 +372,15 @@ void os_mem_prealloc(int fd, char *area, size_t memory)
for (i = 0; i < numpages; i++) {
memset(area + (hpagesize * i), 0, 1);
}
+ }
- ret = sigaction(SIGBUS, &oldact, NULL);
- if (ret) {
- perror("os_mem_prealloc: failed to reinstall signal handler");
- exit(1);
- }
-
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+ ret = sigaction(SIGBUS, &oldact, NULL);
+ if (ret) {
+ /* Terminate QEMU since it can't recover from error */
+ perror("os_mem_prealloc: failed to reinstall signal handler");
+ exit(1);
}
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
}