X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=util%2Foslib-posix.c;h=e00a44c86f0271ab4c430639996f5a1c7d129747;hb=30c367ed446b6ea53245589a5cf373578ac075d7;hp=631a1dea333a811fc3533c75560d8cd3a29cda56;hpb=e7a09b92b70786f9e8c5fbf787e0248c6ebbe707;p=qemu.git diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 631a1dea3..e00a44c86 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -47,6 +47,8 @@ extern int daemon(int, int); # define QEMU_VMALLOC_ALIGN getpagesize() #endif +#include + #include "config-host.h" #include "sysemu/sysemu.h" #include "trace.h" @@ -110,9 +112,7 @@ void *qemu_anon_ram_alloc(size_t size) size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; if (ptr == MAP_FAILED) { - fprintf(stderr, "Failed to allocate %zu B: %s\n", - size, strerror(errno)); - abort(); + return NULL; } ptr += offset; @@ -157,6 +157,18 @@ void qemu_set_nonblock(int fd) fcntl(fd, F_SETFL, f | O_NONBLOCK); } +int socket_set_fast_reuse(int fd) +{ + int val = 1, ret; + + ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, + (const char *)&val, sizeof(val)); + + assert(ret == 0); + + return ret; +} + void qemu_set_cloexec(int fd) { int f; @@ -232,3 +244,10 @@ int qemu_utimens(const char *path, const struct timespec *times) return utimes(path, &tv[0]); } + +char * +qemu_get_local_state_pathname(const char *relative_pathname) +{ + return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR, + relative_pathname); +}