summaryrefslogtreecommitdiff
path: root/util/oslib-posix.c
AgeCommit message (Collapse)AuthorFilesLines
2014-03-13oslib-posix: Fix build on FreeBSDAndreas Färber1-0/+4
Commit 10f5bff622cad71645e22c027b77ac31e51008ef (util: Split out exec_dir from os_find_datadir) moved code from os-posix.c to util/oslib-posix.c but forgot to move a FreeBSD #include alongside, needed for CTL_KERN among others. Cc: Fam Zheng <famz@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Message-id: 1394717279-23406-1-git-send-email-andreas.faerber@web.de Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-02-20util: Split out exec_dir from os_find_datadirFam Zheng1-0/+54
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>
2014-01-24qemu_memalign: Allow small alignmentsKevin Wolf1-0/+5
The functions used by qemu_memalign() require an alignment that is at least sizeof(void*). Adjust it if it is too small. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Benoît Canet <benoit@irqsave.net>
2014-01-22osdep: add qemu_set_tty_echo()Stefan Hajnoczi1-0/+18
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>
2013-10-02util: add socket_set_fast_reuse function which will replace setting SO_REUSEADDRSebastian Ottlik1-0/+12
If a socket is closed it remains in TIME_WAIT state for some time. On operating systems using BSD sockets the endpoint of the socket may not be reused while in this state unless SO_REUSEADDR was set on the socket. On windows on the other hand the default behaviour is to allow reuse (i.e. identical to SO_REUSEADDR on other operating systems) and setting SO_REUSEADDR on a socket allows it to be bound to a endpoint even if the endpoint is already used by another socket independently of the other sockets state. This can even result in undefined behaviour. Many sockets used by QEMU should not block the use of their endpoint after being closed while they are still in TIME_WAIT state. Currently QEMU sets SO_REUSEADDR for such sockets, which can lead to problems on Windows. This patch introduces the function socket_set_fast_reuse that should be used instead of setting SO_REUSEADDR when fast socket reuse is desired and behaves correctly on all operating systems. As a failure of this function can only be caused by bad QEMU internal errors, an assertion handles these situations. The return value is still passed on, to minimize changes in client code and prevent unused variable warnings if NDEBUG is defined. Signed-off-by: Sebastian Ottlik <ottlik@fzi.de> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de>
2013-09-12exec: Don't abort when we can't allocate guest memoryMarkus Armbruster1-3/+1
We abort() on memory allocation failure. abort() is appropriate for programming errors. Maybe most memory allocation failures are programming errors, maybe not. But guest memory allocation failure isn't, and aborting when the user asks for more memory than we can provide is not nice. exit(1) instead, and do it in just one place, so the error message is consistent. Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Acked-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Message-id: 1375276272-15988-8-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-05-30osdep: add qemu_get_local_state_pathname()Laszlo Ersek1-0/+9
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>
2013-05-14osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memoryPaolo Bonzini1-0/+8
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>
2013-05-14osdep, kvm: rename low-level RAM allocation functionsPaolo Bonzini1-2/+2
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>
2013-04-16migration: initialize RAM to zeroPaolo Bonzini1-17/+18
Using qemu_memalign only leaves the RAM zero by chance, because libc will usually use mmap to satisfy our huge requests. But memory will not be zero when using MALLOC_PERTURB_ with a nonzero value. In the case of incoming migration, this breaks a recently-introduced invariant (commit f1c7279, migration: do not sent zero pages in bulk stage, 2013-03-26). To fix this, use mmap ourselves to get a well-aligned, always zero block for the RAM. Mmap-ed memory is easy to "trim" at the sides. This also removes the need to do something special on valgrind (see commit c2a8238a, Support running QEMU on Valgrind, 2011-10-31), thus effectively reverts that patch. Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1365522223-20153-1-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-02oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()Stefan Hajnoczi1-2/+2
The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets. Rename to qemu_set_nonblock() just like qemu_set_cloexec(). Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-03-05oslib-posix: Align to permit transparent hugepages on ARM LinuxPeter Maydell1-1/+1
ARM Linux (like x86-64 Linux) can use transparent hugepages for KVM if memory blocks are 2MiB aligned; set QEMU_VMALLOC_ALIGN accordingly. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2013-01-26bsd-user: avoid conflict with qemu_vmallocBlue Swirl1-3/+0
Rename qemu_vmalloc() to bsd_vmalloc(), adjust the only user. Remove #ifdeffery in oslib-posix.c. Tested-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-12build: move libqemuutil.a components to util/Paolo Bonzini1-0/+228
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>