summaryrefslogtreecommitdiffstats
path: root/osdep.c
Commit message (Collapse)AuthorAgeFilesLines
* osdep: Fix compilation failure on BSD systemsPeter Maydell2012-08-161-1/+7
| | | | | | | | | | | | | Fix compilation failure on BSD systems (which don't have O_DIRECT or O_NOATIME: osdep.c:116: error: ‘O_DIRECT’ undeclared (first use in this function) osdep.c:116: error: (Each undeclared identifier is reported only once osdep.c:116: error: for each function it appears in.) osdep.c:116: error: ‘O_NOATIME’ undeclared (first use in this function) Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* block: Enable qemu_open/close to work with fd setsCorey Bryant2012-08-151-0/+111
| | | | | | | | | | | When qemu_open is passed a filename of the "/dev/fdset/nnn" format (where nnn is the fdset ID), an fd with matching access mode flags will be searched for within the specified monitor fd set. If the fd is found, a dup of the fd will be returned from qemu_open. Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Convert close calls to qemu_closeCorey Bryant2012-08-151-0/+5
| | | | | | | | This patch converts all block layer close calls, that correspond to qemu_open calls, to qemu_close. Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* vnc: disable VNC password authentication (security type 2) when in FIPS modePaul Moore2012-08-031-0/+29
| | | | | | | | | | | | | | | | FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS compliance mode and the user has specified '-enable-fips' on the QEMU command line. This patch causes QEMU to emit a message to stderr when the host system is running in FIPS mode and a VNC password was specified on the commend line. If the system is not running in FIPS mode, or is running in FIPS mode but VNC password authentication was not requested, QEMU operates normally. Signed-off-by: Paul Moore <pmoore@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Allow machines to configure the QEMU_VERSION that's exposed via hardwareCrístian Viana2012-06-191-0/+11
| | | | | | | | | | | | QEMU exposes its version to the guest's hardware and in some cases that is wrong (e.g. Windows prints messages about driver updates when you switch the QEMU version). There is a new field now on the struct QEmuMachine, hw_version, which may contain the version that the specific machine should report. If that field is set, then that machine will report that version to the guest. Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* move corking functions to osdep.cPaolo Bonzini2011-12-221-0/+9
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* add qemu_send_full and qemu_recv_fullPaolo Bonzini2011-12-211-0/+67
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Remove unused sysemu.h include directivesBlue Swirl2011-04-151-1/+0
| | | | | | | Remove unused sysemu.h include directives to speed up build with the following patches. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Remove unncessary includesJes Sorensen2010-10-301-8/+0
| | | | | | | | | No need to include stdlib.h for BSD as it is included by qemu-common.h, windows.h is handled by sysemu.h and osdep.c no longer needs malloc.h Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Separate qemu_pidfile() into OS specific versionsJes Sorensen2010-10-301-38/+0
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Move qemu_gettimeofday() to OS specific filesJes Sorensen2010-10-301-31/+0
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* We only support eventfd under POSIX, move qemu_eventfd() to os-posix.cJes Sorensen2010-10-301-34/+0
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu_pipe() is used only by POSIX code, so move to oslib-posix.cJes Sorensen2010-10-301-22/+0
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Move osdep socket code to oslib-{posix,win32}.cJes Sorensen2010-10-301-38/+0
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Move QEMU OS dependant library functions to OS specific filesJes Sorensen2010-10-301-85/+0
| | | | | | | | | | | | This moves library functions used by both QEMU and the QEMU tools, such as qemu-img, qemu-nbd etc. from osdep.c to oslib-{posix,win32}.c In addition it introduces oslib-obj.y to the Makefile set to be included by the various targets, instead of relying on these library functions magically getting included via block-obj-y. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Introduce qemu_madvise()Andreas Färber2010-09-251-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vl.c has a Sun-specific hack to supply a prototype for madvise(), but the call site has apparently moved to arch_init.c. Haiku doesn't implement madvise() in favor of posix_madvise(). OpenBSD and Solaris 10 don't implement posix_madvise() but madvise(). MinGW implements neither. Check for madvise() and posix_madvise() in configure and supply qemu_madvise() as wrapper. Prefer madvise() over posix_madvise() due to flag availability. Convert all callers to use qemu_madvise() and QEMU_MADV_*. Note that on Solaris the warning is fixed by moving the madvise() prototype, not by qemu_madvise() itself. It helps with porting though, and it simplifies most call sites. v7 -> v8: * Some versions of MinGW have no sys/mman.h header. Reported by Blue Swirl. v6 -> v7: * Adopt madvise() rather than posix_madvise() semantics for returning errors. * Use EINVAL in place of ENOTSUP. v5 -> v6: * Replace two leftover instances of POSIX_MADV_NORMAL with QEMU_MADV_INVALID. Spotted by Blue Swirl. v4 -> v5: * Introduce QEMU_MADV_INVALID, suggested by Alexander Graf. Note that this relies on -1 not being a valid advice value. v3 -> v4: * Eliminate #ifdefs at qemu_advise() call sites. Requested by Blue Swirl. This will currently break the check in kvm-all.c by calling madvise() with a supported flag, which will not fail. Ideas/patches welcome. v2 -> v3: * Reuse the *_MADV_* defines for QEMU_MADV_*. Suggested by Alexander Graf. * Add configure check for madvise(), too. Add defines to Makefile, not QEMU_CFLAGS. Convert all callers, untested. Suggested by Blue Swirl. * Keep Solaris' madvise() prototype around. Pointed out by Alexander Graf. * Display configure check results. v1 -> v2: * Don't rely on posix_madvise() availability, add qemu_madvise(). Suggested by Blue Swirl. Signed-off-by: Andreas Färber <afaerber@opensolaris.org> Cc: Blue Swirl <blauwirbel@gmail.com> Cc: Alexander Graf <agraf@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* trace: Trace qemu_malloc() and qemu_vmalloc()Stefan Hajnoczi2010-09-091-6/+18
| | | | | | | | It is often useful to instrument memory management functions in order to find leaks or performance problems. This patch adds trace events for the memory allocation primitives. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* win32: Add missing function ffsStefan Weil2010-06-271-0/+7
| | | | | | | | | | | | | | | | | | mingw32 does not include function ffs. Commit c6d29ad6e24533cc3762e1d654275607e1d03058 added a declaration for ffs, but an implementation was missing. For compilations with optimization, the compiler creates inline code, so the implementation is not always needed. Without optimization, linking fails without this patch. v2: Use __builtin_ffs as suggested by Richard Henderson Cc: Richard Henderson <rth@twiddle.net> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* documentation: qemu_write_full don't work with non-blocking fd'sJuan Quintela2010-03-091-0/+5
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix qemu_eventfd compile when !CONFIG_EVENTFDAvi Kivity2010-02-231-1/+1
| | | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* use eventfd for iothreadPaolo Bonzini2010-02-171-0/+32
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* fix placement of config-host.h inclusionPaolo Bonzini2010-02-101-3/+4
| | | | | | | The #ifdef CONFIG_SOLARIS below was useless without this patch. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Tell users about out-of-memory errorsStefan Weil2010-01-261-1/+9
| | | | | | | | | | | | | | | | | | | | | Aborting without an error message when memory is short is not helpful, so print the reason for the abort. Try qemu -m 1000000 or qemu -m 2000 (win32) to force an out-of-memory error. v2: * Fix error message for win32. * Fix error message for posix_memalign. Thanks to malc for the hints. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Introduce qemu_write_full()Kirill A. Shutemov2010-01-261-0/+27
| | | | | | | | A variant of write(2) which handles partial write. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* osdep.c: Fix accept4 fallbackKevin Wolf2010-01-131-1/+1
| | | | | | | | | | Commit 3a03bfa5 added a fallback in case the Linux kernel running qemu is older than the kernel of the build system. Unfortunately, v1 was committed instead of v2, so the code has a bug that was revealed in the review (checking for the wrong error code). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* fix pidfile option to work in WIN32Juha Riihimäki2009-12-181-11/+2
| | | | | | | | | | | | | | Explicit read/write locking pidfile under WIN32 is bit extreme nobody get the chance to read the pidfile. Convert to a write-only lock. Also, creating pidfile was disabled along with daemonize under WIN32. Enable it, but do not enable daemon support which doesn't exist under WIN32 atm. From: Juha Riihimäki <juha.riihimaki@nokia.com> Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com> Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* osdep: Fix runtime failure on older Linux kernelsAndre Przywara2009-12-181-6/+12
| | | | | | | | | | | | | If QEMU finds newer kernel header files on compilation time, it will use advertised features like pipe2 or SOCK_CLOEXEC by just doing a compile test. If later the executables are executed on an older kernel (<2.6.27, like Xen Dom0 2.6.18), then QEMU will fail on opening sockets and creating pipes and returns the rather unspecific "qemu_init_main_loop failed". This patch fixes this by checking the return values of these calls for EINVAL and ENOSYS and falling back to the older versions automatically. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Don't leak file descriptorsKevin Wolf2009-12-031-1/+103
| | | | | | | | We're leaking file descriptors to child processes. Set FD_CLOEXEC on file descriptors that don't need to be passed to children to stop this misbehaviour. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add #defines needed by OpenSolaris, fix breakage by the #definesBlue Swirl2009-09-121-2/+2
| | | | | | | | We need to define _XOPEN_SOURCE and __EXTENSIONS__ macros in order to get CMSG_ and TIOCWIN macros defined. But then _POSIX_C_SOURCE gets defined, which is (incorrectly) used as an indicator for existence of posix_memalign() in osdep.c. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Only build osdep onceAnthony Liguori2009-08-241-3/+0
| | | | | | We no longer need hackery to work around kqemu Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Unbreak large mem support by removing kqemuAnthony Liguori2009-08-241-121/+0
| | | | | | | | | | | | | | | | | | | | | | kqemu introduces a number of restrictions on the i386 target. The worst is that it prevents large memory from working in the default build. Furthermore, kqemu is fundamentally flawed in a number of ways. It relies on the TSC as a time source which will not be reliable on a multiple processor system in userspace. Since most modern processors are multicore, this severely limits the utility of kqemu. kvm is a viable alternative for people looking to accelerate qemu and has the benefit of being supported by the upstream Linux kernel. If someone can implement work arounds to remove the restrictions introduced by kqemu, I'm happy to avoid and/or revert this patch. N.B. kqemu will still function in the 0.11 series but this patch removes it from the 0.12 series. Paul, please Ack or Nack this patch. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* rename HOST_BSD to CONFIG_BSDJuan Quintela2009-07-271-3/+3
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* change HOST_SOLARIS to CONFIG_SOLARIS{_VERSION}Juan Quintela2009-07-271-3/+3
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Add out of memory and zero size argument checks to be consistent withmalc2009-07-081-5/+25
| | | | the qemu_malloc routines
* Add tool_osdep.cPaul Brook2009-05-131-0/+3
| | | | | | | | | | osdep.c is built in both as a toplevel target independant object, and as a per-target object because of kqemu dependencies. Under some circumstances make picks up the wrong one. Build the former as tool-osdep to avoid this conflict. Signed-off-by: Paul Brook <paul@codesourcery.com>
* kqemu: merge CONFIG_KQEMU and USE_KQEMUblueswir12009-04-191-3/+3
| | | | | | | | | | Basically a recursive ":%s/USE_KQEMU/CONFIG_KQEMU/g". Signed-off-by: Paul Bolle <pebolle@tiscali.nl> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7189 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix windows build and clean up use of <windows.h>aliguori2009-03-081-1/+0
| | | | | | | | | | | | | We want to globally define WIN_LEAN_AND_MEAN and WINVER to particular values so let's do it in OS_CFLAGS. Then, we can pepper in windows.h includes where using #includes that require it. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6783 c046a42c-6fe2-441c-8c8c-71466251a162
* Rename _BSD to HOST_BSD so that it's more obvious that it's defined by configureblueswir12009-03-081-3/+3
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6775 c046a42c-6fe2-441c-8c8c-71466251a162
* Support for DragonFly BSD (Hasso Tepper)blueswir12009-03-071-2/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6746 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix BSD breakage from r6736blueswir12009-03-071-0/+3
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6742 c046a42c-6fe2-441c-8c8c-71466251a162
* Sparse fixes: NULL use, header order, ANSI prototypes, staticblueswir12009-03-071-3/+2
| | | | | | | | | | | | | Fix Sparse warnings: * use NULL instead of plain 0 * rearrange header include order to avoid redefining types accidentally * ANSIfy SLIRP * avoid "restrict" keyword * add static git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6736 c046a42c-6fe2-441c-8c8c-71466251a162
* Remove redundant #ifdef _BSDblueswir12008-12-111-4/+0
| | | | | | | | | | since _BSD if already handled in osdep.c:qemu_memalign(), we don't need to check it in the calling function again. getpagesize() is available in BSD. Signed-off-by: Andre Przywara <andre.przywara@amd.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5983 c046a42c-6fe2-441c-8c8c-71466251a162
* Use MAP_ANON also for FreeBSD (Juergen Lock)blueswir12008-11-221-2/+5
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5778 c046a42c-6fe2-441c-8c8c-71466251a162
* Use qemu_memalign instead of memalign in qemu_vmallocmalc2008-11-181-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5730 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix -linux-user build by reverting r5701aliguori2008-11-111-14/+1
| | | | | | | | | | | | | Unfortunately, -linux-user doesn't use osdep as it replaces some of those functions with specific ones. The code #ifdef code in exec.c needs to remain in place so instead of introducing a qemu_getpagesize() let's just use getpagesize() in the non-Windows implementation of qemu_vmalloc. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5703 c046a42c-6fe2-441c-8c8c-71466251a162
* Allocate guest memory on host page boundaries (Hollis Blanchard)aliguori2008-11-111-1/+1
| | | | | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5702 c046a42c-6fe2-441c-8c8c-71466251a162
* Define OS-dependent qemu_getpagesize() (Hollis Blanchard)aliguori2008-11-111-0/+13
| | | | | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5701 c046a42c-6fe2-441c-8c8c-71466251a162
* Use common objects for qemu-img and qemu-nbdaliguori2008-09-151-0/+27
| | | | | | | | | | | | | | | | | | | | | | | Right now, we sprinkle #if defined(QEMU_IMG) && defined(QEMU_NBD) all over the code. It's ugly and causes us to have to build multiple object files for linking against qemu and the tools. This patch introduces a new file, qemu-tool.c which contains enough for qemu-img, qemu-nbd, and QEMU to all share the same objects. This also required getting qemu-nbd to be a bit more Windows friendly. I also changed the Windows block-raw to use normal IO instead of overlapping IO since we don't actually do AIO yet on Windows. I changed the various #if 0's to #if WIN32_AIO to make it easier for someone to eventually fix AIO on Windows. After this patch, there are no longer any #ifdef's related to qemu-img and qemu-nbd. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5226 c046a42c-6fe2-441c-8c8c-71466251a162
* Preliminary OpenBSD host support (based on OpenBSD patches by Todd T. Fries)blueswir12008-08-151-2/+15
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5012 c046a42c-6fe2-441c-8c8c-71466251a162
* Use correct types to enable > 2G support, based on a patch fromaurel322008-04-271-1/+0
| | | | | | | Anthony Liguori. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4265 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud