summaryrefslogtreecommitdiffstats
path: root/include/qemu/osdep.h
Commit message (Collapse)AuthorAgeFilesLines
* osdep: Change default value of qemu_hw_version() to "2.5+"Eduardo Habkost2015-11-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | There are two issues with qemu_hw_version() today: 1) If a machine has hw_version set, the value returned by it is not very useful, because it is not the actual QEMU version. 2) If a machine does't set hw_version, the return value of qemu_hw_version() is broken, because it will change when upgrading QEMU. For those reasons, using qemu_hw_version() is strongly discouraged, and should be used only in code that used QEMU_VERSION in the past and needs to keep compatibility. To fix (2), instead of making every machine broken by default unless they set hw_version, make qemu_hw_version() simply return "2.5+" if qemu_set_hw_version() is not called. Suggested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Add QEMU_MADV_NOHUGEPAGEDr. David Alan Gilbert2015-11-101-0/+9
| | | | | | | | | | | | | Add QEMU_MADV_NOHUGEPAGE as an OS-independent version of MADV_NOHUGEPAGE. We include sys/mman.h before making the test to ensure that we pick up the system defines. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* osdep: Rename qemu_{get, set}_version() to qemu_{, set_}hw_version()Eduardo Habkost2015-11-041-2/+2
| | | | | | | | | | | | | | | This makes the purpose of the function clearer: it is not about the version of QEMU that's running, but the version string exposed in the emulated hardware. Cc: Andrzej Zaborowski <balrogg@gmail.com> Cc: Peter Maydell <peter.maydell@linaro.org> Cc: John Snow <jsnow@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <1446233769-7892-3-git-send-email-ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* osdep: add qemu_fork() wrapper for safely handling signalsDaniel P. Berrange2015-10-201-0/+16
| | | | | | | | | | | | | | | | | | | | | When using regular fork() the child process of course inherits all the parents' signal handlers. If the child then proceeds to close() any open file descriptors, it may break some of those registered signal handlers. The child generally does not want to ever run any of the signal handlers that the parent may have installed in the short time before it exec's. The parent may also have blocked various signals which the child process will want enabled. This introduces a wrapper qemu_fork() that takes care to sanitize signal handling across fork. Before forking it blocks all signals in the parent thread. After fork returns, the parent unblocks the signals and carries on as usual. The child, however, resets all the signal handlers back to their defaults before it unblocks signals. The child process can now exec the binary in a "clean" signal environment. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* oslib-win32: only provide localtime_r/gmtime_r if missingDaniel P. Berrange2015-09-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The oslib-win32 file currently provides a localtime_r and gmtime_r replacement unconditionally. Some versions of Mingw-w64 would provide crude macros for localtime_r/gmtime_r which QEMU takes care to disable. Latest versions of Mingw-w64 now provide actual functions for localtime_r/gmtime_r, but with a twist that you have to include unistd.h or pthread.h before including time.h. By luck some files in QEMU have such an include order, resulting in compile errors: CC util/osdep.o In file included from include/qemu-common.h:48:0, from util/osdep.c:48: include/sysemu/os-win32.h:77:12: error: redundant redeclaration of 'gmtime_r' [-Werror=redundant-decls] struct tm *gmtime_r(const time_t *timep, struct tm *result); ^ In file included from include/qemu-common.h:35:0, from util/osdep.c:48: /usr/i686-w64-mingw32/sys-root/mingw/include/time.h:272:107: note: previous definition of 'gmtime_r' was here In file included from include/qemu-common.h:48:0, from util/osdep.c:48: include/sysemu/os-win32.h:79:12: error: redundant redeclaration of 'localtime_r' [-Werror=redundant-decls] struct tm *localtime_r(const time_t *timep, struct tm *result); ^ In file included from include/qemu-common.h:35:0, from util/osdep.c:48: /usr/i686-w64-mingw32/sys-root/mingw/include/time.h:269:107: note: previous definition of 'localtime_r' was here This change adds a configure test to see if localtime_r exits, and only enables the QEMU impl if missing. We also re-arrange qemu-common.h try attempt to guarantee that all source files get unistd.h before time.h and thus see the localtime_r/gmtime_r defs. [sw: Use "official" spellings for Mingw-w64, MinGW in comments.] [sw: Terminate sentences with a dot in comments.] Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Stefan Weil <sw@weilnetz.de>
* osdep.h: Add header commentPeter Maydell2015-08-191-0/+24
| | | | | | | | Add a header comment to osdep.h, explaining what the header is for and some rules to avoid circular-include difficulties. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
* osdep.h: Move some OS header includes and fixups from qemu-common.hPeter Maydell2015-08-191-1/+48
| | | | | | | | | qemu-common.h has some system header includes and fixups for things that might be missing. This is really an OS dependency and belongs in osdep.h, so move it across. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
* osdep.h: Move some compiler-specific things to compiler.hPeter Maydell2015-08-191-47/+1
| | | | | | | | osdep.h has a few things which are really compiler specific; move them to compiler.h, and include compiler.h from osdep.h. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
* osdep.h: Remove qemu_printfPeter Maydell2015-08-191-2/+0
| | | | | | | | | qemu_printf is an ancient remnant which has been a simple #define to printf for over a decade, and is used in only a few places. Expand it out in those places and remove the #define. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
* util: move read_password method out of qemu-img into osdep/oslibDaniel P. Berrange2015-05-221-0/+2
| | | | | | | | | | | | The qemu-img.c file has a read_password() method impl that is used to prompt for passwords on the console, with impls for POSIX and Windows. This will be needed by qemu-io.c too, so move it into the QEMU osdep/oslib files where it can be shared without code duplication Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* memory: expose alignment used for allocating RAM as MemoryRegion APIIgor Mammedov2014-11-231-1/+2
| | | | | | | | | | introduce memory_region_get_alignment() that returns underlying memory block alignment or 0 if it's not relevant/implemented for backend. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* util: introduce MIN_NON_ZEROPeter Lieven2014-11-031-0/+6
| | | | | | | | | | | | at least in block layer we have the case of limits being defined for a BlockDriverState. However, in this context often zero (0) has the special meanining of undefined which means no limit. If two of those limits are combined and the minimum is needed the minimum function should only return zero if both parameters are zero. Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* util: Move general qemu_getauxval to util/getauxval.cFam Zheng2014-09-091-4/+0
| | | | | | | | | So that we won't have an empty getauxval.o which is disliked by ranlib. Reported-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* block: Introduce qemu_try_blockalign()Kevin Wolf2014-08-151-0/+1
| | | | | | | This function returns NULL instead of aborting when an allocation fails. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net>
* qemu/osdep: Remove the need for qemu_init_auxvalRichard Henderson2014-06-231-12/+0
| | | | | | | | | Instead of getting backup auxv data from the env pointer given to main, read it from /proc/self/auxv. We can do this at any time, so we're not tied to any ordering wrt a call to qemu_init_auxval from main. Tested-by: Tom Musta <tommusta@gmail.com> Signed-off-by: Richard Henderson <rth@twiddle.net>
* hostmem: add merge and dump propertiesPaolo Bonzini2014-06-191-0/+10
| | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* osdep: add merge and dump flagsMichael S. Tsirkin2014-06-191-0/+4
| | | | | | will be used by follow up patch Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* memory: move preallocation code out of exec.cPaolo Bonzini2014-06-191-0/+2
| | | | | | | | | | | | 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>
* util: Split out exec_dir from os_find_datadirFam Zheng2014-02-201-0/+9
| | | | | | | | | With this change, main() calls qemu_init_exec_dir and uses argv[0] to init exec_dir. The saved value can be retrieved with qemu_get_exec_dir later. It will be reused by module loading. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* osdep: add qemu_set_tty_echo()Stefan Hajnoczi2014-01-221-0/+2
| | | | | | | | | Using stdin with readline.c requires disabling echo and line buffering. Add a portable wrapper to set the terminal attributes under Linux and Windows. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* osdep: Create qemu_getauxval and qemu_init_auxvalRichard Henderson2013-11-301-0/+25
| | | | | | Abstract away dependence on a system implementation of getauxval. Signed-off-by: Richard Henderson <rth@twiddle.net>
* osdep: add qemu_get_local_state_pathname()Laszlo Ersek2013-05-301-0/+11
| | | | | | | | | | | | | | | This function returns ${prefix}/var/RELATIVE_PATHNAME on POSIX-y systems, and <CSIDL_COMMON_APPDATA>/RELATIVE_PATHNAME on Win32. http://msdn.microsoft.com/en-us/library/bb762494.aspx [...] This folder is used for application data that is not user specific. For example, an application can store a spell-check dictionary, a database of clip art, or a log file in the CSIDL_COMMON_APPDATA folder. [...] Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memoryPaolo Bonzini2013-05-141-0/+1
| | | | | | | | | | | | | | | We switched from qemu_memalign to mmap() but then we don't modify qemu_vfree() to do a munmap() over free(). Which we cannot do because qemu_vfree() frees memory allocated by qemu_{mem,block}align. Introduce a new function that does the munmap(), luckily the size is available in the RAMBlock. Reported-by: Amos Kong <akong@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Amos Kong <akong@redhat.com> Message-id: 1368454796-14989-3-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* osdep, kvm: rename low-level RAM allocation functionsPaolo Bonzini2013-05-141-1/+1
| | | | | | | | | | This is preparatory to the introduction of a separate freeing API. Reported-by: Amos Kong <akong@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Amos Kong <akong@redhat.com> Message-id: 1368454796-14989-2-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* osdep.h: include sys/types.h for ssize_t definitionIgor Mitsyanko2013-05-121-1/+1
| | | | | | | | | | | sys/types.h is taken out from "ifdef __OpenBSD__" guard. It should be safe for other systems, according to following survey: http://hacks.owlfolio.org/header-survey/ This fixes build for CONFIG_IOVEC-less systems (mingw). Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* win32: add readv/writev emulationPaolo Bonzini2013-04-291-0/+17
| | | | | | | | | | | | | | | Commit e9d8fbf (qemu-file: do not use stdio for qemu_fdopen, 2013-03-27) introduced a usage of writev, which mingw32 does not have. Even though qemu_fdopen itself is not used on mingw32, the future-proof solution is to add an implementation of it. This is simple and similar to how we emulate sendmsg/recvmsg in util/iov.c. Some files include osdep.h without qemu-common.h, so move the definition of iovec to osdep.h too, and include osdep.h from qemu-common.h unconditionally (protection against including files when NEED_CPU_H is defined is not needed since the removal of AREG0). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio-scsi: create VirtIOSCSICommonPaolo Bonzini2013-04-191-0/+4
| | | | | | | | | | This patch refactors existing virtio-scsi code into VirtIOSCSICommon in order to allow virtio_scsi_init_common() to be used by both internal virtio_scsi_init() and external vhost-scsi-pci code. Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Asias He <asias@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-file: check exit status when closing a pipe QEMUFilePaolo Bonzini2013-03-111-0/+7
| | | | | | | | | This is what exec_close does. Move this to the underlying QEMUFile. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-0/+178
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud