From 056b68af773b31fa98fe4538f6424c0079b61415 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Wed, 20 Jul 2016 11:54:03 +0200 Subject: fix qemu exit on memory hotplug when allocation fails at prealloc time When adding hostmem backend at runtime, QEMU might exit with error: "os_mem_prealloc: Insufficient free host memory pages available to allocate guest RAM" It happens due to os_mem_prealloc() not handling errors gracefully. Fix it by passing errp argument so that os_mem_prealloc() could report error to callers and undo performed allocation when os_mem_prealloc() fails. Signed-off-by: Igor Mammedov Message-Id: <1469008443-72059-1-git-send-email-imammedo@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/qemu/osdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/qemu/osdep.h') diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index fbb875959f..d7c111d169 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -379,7 +379,7 @@ unsigned long qemu_getauxval(unsigned long type); void qemu_set_tty_echo(int fd, bool echo); -void os_mem_prealloc(int fd, char *area, size_t sz); +void os_mem_prealloc(int fd, char *area, size_t sz, Error **errp); int qemu_read_password(char *buf, int buf_size); -- cgit 1.4.1 From e9fd416e66539ad43bbab018f346cb164136c099 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 21 Jul 2016 13:34:47 -0600 Subject: osdep: Document differences in rounding macros Make it obvious which macros are safe in which situations. Useful since QEMU_ALIGN_UP and ROUND_UP both purport to do the same thing, but differ on whether the alignment must be a power of 2. Signed-off-by: Eric Blake Message-Id: <1469129688-22848-4-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu/osdep.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/qemu/osdep.h') diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index d7c111d169..9e9fa61546 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -158,7 +158,8 @@ extern int daemon(int, int); /* Round number down to multiple */ #define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) -/* Round number up to multiple */ +/* Round number up to multiple. Safe when m is not a power of 2 (see + * ROUND_UP for a faster version when a power of 2 is guaranteed) */ #define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) /* Check if n is a multiple of m */ @@ -175,6 +176,9 @@ extern int daemon(int, int); /* Check if pointer p is n-bytes aligned */ #define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n)) +/* Round number up to multiple. Requires that d be a power of 2 (see + * QEMU_ALIGN_UP for a safer but slower version on arbitrary + * numbers) */ #ifndef ROUND_UP #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d)) #endif -- cgit 1.4.1