qemu-thread-posix: Fix build against older glibc version
pthread_setname_np was introduced with 2.12.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Add a 'name' parameter to qemu_thread_create
If enabled, set the thread name at creation (on GNU systems with pthread_set_np)Fix up all the callers with a thread name
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>Acked-by: Michael S. Tsirkin <mst@redhat.com>...
Add 'debug-threads' suboption to --name
Add flag storage to qemu-thread-* to store the namethreads flag
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>Acked-by: Michael S. Tsirkin <mst@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>
target-ppc: Add ISA2.06 divdeu[o] Instructions
This patch adds the Divide Doubleword Extended Unsignedinstructions. This instruction requires dividing a 128-bitvalue by a 64 bit value. Since 128 bit integer division isnot supported in TCG, a helper is used. An architecture...
target-ppc: Add ISA2.06 divde[o] Instructions
This patch adds the Divide Doubleword Extended instructions.The implementation builds on the unsigned helper provided inthe previous patch.
Signed-off-by: Tom Musta <tommusta@gmail.com>Reviewed-by: Richard Henderson <rth@twiddle.net>...
util/iov: Use qemu/sockets.h instead of conditional code
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
modules: Fix building with --enable-modules
Compiling util/modules.c with modules enabled fails now.
Fix it by including qemu-common.h before #ifdef testing in module.c.
Signed-off-by: Fam Zheng <famz@redhat.com>Message-id: 1393453893-12125-1-git-send-email-famz@redhat.com...
modules: do not include gmodule-2.0 in static builds
gmodule-2.0's pkg-config files include -Wl,--export-dynamic, which breaksstatic builds. It is a glib bug, but we need to support --static builds forthe linux-user targets, and in the end all that is needed to fix this is:...
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches
Merge remote-tracking branch 'remotes/bonzini/configure' into staging
blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify.
qemu_iovec_compare() will be used to compare IOs vectors in quorum blkverifymode. The patch extracts these functions in order to factorize the code.
Signed-off-by: Benoit Canet <benoit@irqsave.net>...
qemu-config: Sections must consist of keys
In config_parse_qdict_section(), the QList returned byqdict_array_split() is assumed to only contain QDicts. Currently, thisis true but it may (and will) change in the future. Therefore, checkwhether the assumption actually holds....
qemu-option: has_help_option() and is_valid_option_list()
has_help_option() checks if any help option ('help' or '?') occursanywhere in an option string, so that things like 'cluster_size=4k,help'are recognised.
is_valid_option_list() ensures that the option list doesn't have options...
module: implement module loading
This patch adds loading, stamp checking and initialization of modules.
The init function of dynamic module is no longer directly called asattribute((constructor)) in static linked version, it is calledonly after passed the checking of presense of stamp symbol:...
util: Split out exec_dir from os_find_datadir
With this change, main() calls qemu_init_exec_dir and uses argv0 toinit exec_dir. The saved value can be retrieved withqemu_get_exec_dir later. It will be reused by module loading.
Signed-off-by: Fam Zheng <famz@redhat.com>...
Use error_is_set() only when necessary
error_is_set(&var) is the same as var != NULL, but it takeswhole-program analysis to figure that out. Unnecessarily hard foroptimizers, static checkers, and human readers. Dumb it down toobvious.
Gets rid of several dozen Coverity false positives....
util/fifo8: implement push/pop of multiple bytes
The patch adds functions fifo8_push_all() and fifo8_pop_buf() whichcan be used respectively to push the content of a memory buffer to thefifo and to pop multiple bytes obtaining a pointer to the fifo backing...
util/fifo8: clear fifo head upon reset
To improve the predictability of fifo8_pop_buf(), the fifo head is setto the start of data buffer upon a reset so that the first call to thefunction will be able to retrieve all data in the fifo.
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>...
osdep: drop unused #include "trace.h"
osdep.c does not use trace_*() so we can just drop the include.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qemu_memalign: Allow small alignments
The functions used by qemu_memalign() require an alignment that is atleast 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>...
qemu-progress: Drop unused include
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>
qemu-progress: Fix progress printing on SIGUSR1
Since commit a7aae221 ('Switch SIG_IPI to SIGUSR1'), SIGUSR1 is blockedduring startup, breaking the progress report in tools.
This patch reenables the signal when initialising a progress report.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
readline: move readline to a generic location
Now that the monitor and readline are decoupled, readline.h no longerbelongs in include/monitor/. Put the header into include/qemu/.
Move the source file into util/ so it can be linked as part oflibqemuutil.a....
osdep: add qemu_set_tty_echo()
Using stdin with readline.c requires disabling echo and line buffering.Add a portable wrapper to set the terminal attributes under Linux andWindows.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-option: Add qemu_config_parse_qdict()
This function basically parses command-line options given as a QDictreplacing a config file.
For instance, the QDict {"section.opt1": 42, "section.opt2": 23}corresponds to the config file:
[section]opt1 = 42...
Revert "error: Don't use error_report() for assertion msgs."
This reverts commit d32934c84c72f57e78d430c22974677b7bcabe5d.
The original implementation before this patch makes abortive errormessages much more friendly. The underlying bug that required this...
error: Don't use error_report() for assertion msgs.
Use fprintf(stderr instead. This removes dependency of libqemuutil.aon the monitor.
We can further justify this change, in that this code path should onlytrigger under a fatal error condition. fprintf-stderr is probably the...
Merge remote branch 'luiz/queue/qmp' into qmpq
bitmap: use long as index
Move index and size fields from int to long. We need that formigration. long is 64 bits on sane architectures, and 32bits shouldbe enough on all the 32bits architectures.
Signed-off-by: Juan Quintela <quintela@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
qemu-option: Remove qemu_opts_create_nofail
This is a boiler-plate _nofail variant of qemu_opts_create. Remove anduse error_abort in call sites.
null/0 arguments needs to be added for the id and fail_if_exists fieldsin affected callsites due to argument inconsistency between the normal and...
error: Add error_abort
Add a special Error * that can be passed to error handling APIs tosignal that any errors are fatal and should abort QEMU. There are twoadvantages to this:
- allows for brevity when wishing to assert success of Error ** accepting APIs. No need for this pattern:...
Merge remote-tracking branch 'kwolf/tags/for-anthony' into staging
Block patches for 2.0 (flushing block-next)
util: Use qemu_getauxval in linux qemu_cache_utils_init
With this we no longer pass down envp, and thus all systems can havethe same void prototype. So also eliminate a useless thunk.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Richard Henderson <rth@twiddle.net>
osdep: Create qemu_getauxval and qemu_init_auxval
Abstract away dependence on a system implementation of getauxval.
Signed-off-by: Richard Henderson <rth@twiddle.net>
util/error: Save errno from clobbering
There may be calls to error_setg() and especially error_setg_errno()which blindly (and until now wrongly) assume these functions not toclobber errno (e.g., they pass errno to error_setg_errno() and return-errno afterwards). Instead of trying to find and fix all of these...
qmp: access the local QemuOptsLists for drive option
Currently we have three QemuOptsList (qemu_common_drive_opts,qemu_legacy_drive_opts, and qemu_drive_opts), only qemu_drive_optsis added to vm_config_groups[].
This patch changes query-command-line-options to access three local...
qemu-thread: add QemuEvent
This emulates Win32 manual-reset events using futexes or conditionalvariables. Typical ways to use them are with multi-producer,single-consumer data structures, to test for a complex condition whoseelements come from different threads:...
compatfd: switch to QemuThread
qemu_thread_create already does signal blocking and detaching for us.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
blockdev: Separate ID generation from DriveInfo creation
blockdev-add shouldn't automatically generate IDs, but will keep most ofthe DriveInfo creation code.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>...
Merge remote-tracking branch 'mjt/trivial-patches' into staging
util/path: Fix type which is longer than 8 bit for MinGW
While dirent->d_type is 8 bit for most systems, it is 32 bit for MinGW.Reducing it to 8 bit results in a compiler warning because the macrois_dir_maybe compares that 8 bit value with 32 bit constants....
util: add socket_set_fast_reuse function which will replace setting SO_REUSEADDR
If a socket is closed it remains in TIME_WAIT state for some time. On operatingsystems using BSD sockets the endpoint of the socket may not be reused while inthis state unless SO_REUSEADDR was set on the socket. On windows on the other...
util: call socket_set_fast_reuse instead of setting SO_REUSEADDR
SO_REUSEADDR should be avoided on Windows but is desired on other operatingsystems. So instead of setting it we call socket_set_fast_reuse that will resultin the appropriate behaviour on all operating systems....
Merge remote-tracking branch 'stefanha/block' into staging
iov: avoid "orig_len may be used unitialized" warning
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
osdep: warn if open(O_DIRECT) on fails with EINVAL
Print a warning when opening a file O_DIRECT fails with EINVAL. Thissaves users a lot of time trying to figure out the EINVAL error, whichis typical when attempting to open a file O_DIRECT on Linux tmpfs....
exec: Don't abort when we can't allocate guest memory
We abort() on memory allocation failure. abort() is appropriate forprogramming errors. Maybe most memory allocation failures areprogramming errors, maybe not. But guest memory allocation failureisn't, and aborting when the user asks for more memory than we can...
Merge remote-tracking branch 'mdroth/qga-pull-2013-9-9' into staging
error: Add error_set_win32 and error_setg_win32
These functions help maintaining homogeneous formatting of error messageswith Windows error code and description (generated byg_win32_error_message()).
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>...
throttle: Add a new throttling API implementing continuous leaky bucket.
Implement the continuous leaky bucket algorithm devised on IRC as a separatemodule.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
option: Add assigned flag to QEMUOptionParameter
Adds an "assigned" flag to QEMUOptionParameter which is cleared at thebeginning of parse_option_parameters and set on (successful)set_option_parameter and set_option_parameter_int.
Signed-off-by: Max Reitz <mreitz@redhat.com>...
qemu-option: Guard against qemu_opts_set_defaults() misuse
Commit 6d4cd40 fixed qemu_opts_set_defaults() for an existing cornercase, but broke it for another one that can't be reached in currentcode.
Quote from its commit message:
I believe [opts_parse()] attempts to do the following:...
iov: handle EOF in iov_send_recv
Without this patch, iov_send_recv() never returns when do_send_recv()returns zero.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
semaphore: fix a hangup problem under load on NetBSD hosts.
Fix following bugs in "fallback implementation of counting semaphoreswith mutex+condvar" added in c166cb72f1676855816340666c3b618beef4b976: - waiting threads are not restarted properly if more than one threads...
qdev: Add SIZE type to qdev properties
This patch adds a 'SIZE' type property to qdev.
Signed-off-by: Ian Molton <ian.molton@collabora.co.uk>Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>...
aes: Remove unused code (NDEBUG, u16)
The current code includes assert.h very early (from qemu-common.h),so the definition of NDEBUG was without any effect.
In the initial version from 2004, NDEBUG was used to disable the assertions.Those assertions are not in time critical code, so it is no longer...
QemuOpts: Add qemu_opt_unset()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
add timestamp to error_report()
[Issue]When we offer a customer support service and a problem happensin a customer's system, we try to understand the problem bycomparing what the customer reports with message logs of thecustomer's system.
In this case, we often need to know when the problem happens....
qemu-option: Fix qemu_opts_set_defaults() for corner cases
Commit 4f6dd9a changed the initialization of opts in opts_parse() tothis:
if (defaults) { if (!id && !QTAILQ_EMPTY(&list->head)) { opts = qemu_opts_find(list, NULL); } else {...
qemu-option: Fix qemu_opts_find() for null id arguments
Crashes when the first list member has an ID. Admittedly nonsensicalreproducer:
$ qemu-system-x86_64 -nodefaults -machine id=foo -machine ""
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
qemu-socket: don't leak opts on error
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qemu-socket: zero-initialize SocketAddress
qemu-socket: drop pointless allocation
qemu-socket: catch monitor_get_fd failures
notify: add NotiferWithReturn so notifier list can abort
notifier_list_notify() has no return value. This is fine when we justwant to invoke side-effects.
Sometimes it's useful for notifiers to produce a return value. Thisallows notifiers to "veto" an operation and will be used by the block...
acl: acl_add can't insert before last list element, fix
Watch this:
$ upstream-qemu -nodefaults -S -vnc :0,acl,sasl -monitor stdio QEMU 1.5.50 monitor - type 'help' for more information (qemu) acl_add vnc.username drei allow acl: added rule at position 1...
qemu-option: check_params() is now unused, drop it
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Message-id: 1371208516-7857-3-git-send-email-armbru@redhat.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-socket: allow hostnames starting with a digit
According to RFC 1123 [1], hostnames can start with a digit too.
[1] http://tools.ietf.org/html/rfc1123#page-13
Signed-off-by: Ján Tomko <jtomko@redhat.com>Cc: qemu-stable@nongnu.org[Use strspn, not strcspn. - Paolo]...
error: add error_setg_file_open() helper
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Acked-by: Kevin Wolf <kwolf@redhat.com>
create qemu_openpty_raw() helper function and move it to a separate file
In two places qemu uses openpty() which is very system-dependent,and in both places the pty is switched to raw mode as well.Make a wrapper function which does both steps, and move all the...
qemu-io: Move qemu_strsep() to cutils.c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
cutils: Support 'P' and 'E' suffixes in strtosz()
osdep: add qemu_get_local_state_pathname()
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...
Rename hexdump to avoid FreeBSD libutil conflict
On FreeBSD libutil is used for openpty(), but it also provides a hexdump()which conflicts with QEMU's.
Signed-off-by: Ed Maste <emaste@freebsd.org>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Message-id: 1368718348-15199-1-git-send-email-emaste@freebsd.org...
osdep, kvm: rename low-level RAM allocation functions
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>...
osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memory
We switched from qemu_memalign to mmap() but then we don't modifyqemu_vfree() to do a munmap() over free(). Which we cannot dobecause qemu_vfree() frees memory allocated by qemu_{mem,block}align....
clean unnecessary code: don't check g_strdup arg for NULL
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qemu: add castagnoli crc32c checksum algorithm
This adds the Castagnoli CRC32C algorithm, using the 0x11EDC6F41polynomial.
This is extracted from the linux kernel cryptographic crc32.c module.
The algorithm is based on:
Castagnoli93: Guy Castagnoli and Stefan Braeuer and Martin Herrman...
win32: add readv/writev emulation
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 thoughqemu_fdopen itself is not used on mingw32, the future-proof solution isto add an implementation of it. This is simple and similar to how we...
monitor: introduce query-command-line-options
Libvirt has no way to probe if an option or property is supported,This patch introduces a new qmp command to query command lineoption information. hmp command isn't added because it's not needed.
Signed-off-by: Amos Kong <akong@redhat.com>...
ccid-card-passthru, dev-smartcard-reader: add debug environment variables
Introduces a new utility function: parse_debug_env to avoid codeduplication.
This overrides whatever debug value is set on the corresponding devicesfrom the command line, and is meant to ease the usage with any...
util: move socket_init() to osdep.c
vscclient needs to call socket_init() for portability.Moving to osdep.c since it has no internal dependency.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>Reviewed-by: Alon Levy <alevy@redhat.com>
iov: reorganize iov_send_recv, part 3
"si" and "ei" are merged in a single variable.
Reviewed-by: Juan Quintela <quintela@redhat.com>Reviewed-by: Orit Wassermann <owasserm@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
iov: handle partial writes from sendmsg and recvmsg
Partial writes can still happen in sendmsg and recvmsg, if asignal is received in the middle of a write. To handle this,retry the operation with a new offset/bytes pair.
Reviewed-by: Juan Quintela <quintela@redhat.com>...
iov: reorganize iov_send_recv, part 1
Once the initial part of the iov is dropped, it is not used anymore.Modify iov/iovcnt directly instead of adjusting them with the "si" variable.
Reviewed-by: Juan Quintela <quintela@redhat.com>Reviewed-by: Orit Wassermann <owasserm@redhat.com>...
iov: reorganize iov_send_recv, part 2
Do not touch the "bytes" argument anymore. Instead, remember theoriginal length of the last iovec if we touch it, and restore itafterwards.
This requires undoing the changes in opposite order. The previousalgorithm didn't care....
migration: initialize RAM to zero
Using qemu_memalign only leaves the RAM zero by chance, because libcwill usually use mmap to satisfy our huge requests. But memory willnot be zero when using MALLOC_PERTURB_ with a nonzero value. In thecase of incoming migration, this breaks a recently-introduced...
sysemu: avoid proliferation of include/ subdirectories
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
unicode: New mod_utf8_codepoint()
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
aes: move aes.h from include/block to include/qemu
Move aes.h from include/block to include/qemu to show it can be reusedby other subsystems.
Cc: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>...
aes: make Td[0-5] and Te[0-5] tables non static
Remove static attribute to Td[0-5] and Te[0-5] tables so that theycan be used outside of aes.c. Change their type from u32 to uint32_t,to keep the u32 udef local to aes.c. Prefix them with AES_ so that they...
Allow clock_gettime() monotonic clock to be utilized on more OS's
Allow the clock_gettime() code using monotonic clock to be utilized onmore POSIX compliannt OS's. This started as a fix for OpenBSD which waslisted in one function as part of the previous hard coded list of OS's...
oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
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>...
qemu-socket: set passed fd non-blocking in socket_connect()
socket_connect() sets non-blocking on TCP or UNIX domain sockets if acallback function is passed. Do the same for file descriptor passing,otherwise we could unexpectedly be using a blocking file descriptor....
buffer_is_zero: use vector optimizations if possible
performance gain on SSE2 is approx. 20-25%. altivecis not tested. performance for unsigned long arithmeticis unchanged.
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Eric Blake <eblake@redhat.com>...
bitops: unroll while loop in find_next_bit()
this patch adopts the loop unrolling idea of bitmap_is_zero() tospeed up the skipping of large areas with zeros in find_next_bit().
this routine is extensively used to find dirty pages inlive migration.
testing only the find_next_bit performance on a zeroed bitfield...
cutils: add a function to find non-zero content in a buffer
this adds buffer_find_nonzero_offset() which is a SSE2/Altivecoptimized function that searches for non-zero content in abuffer.
the function starts full unrolling only after the first few chunks have...
Merge remote-tracking branch 'kwolf/for-anthony' into staging
qemu-socket: Make socket_optslist public
Allow other users to create the QemuOpts needed for inet_connect_opts().
nbd: Keep hostname and port separate
The NBD block supports an URL syntax, for which a URL parser returnsseparate hostname and port fields. It also supports the traditional qemusyntax encoded in a filename. Until now, after parsing the URL to geteach piece of information, a new string is built to be fed to socket...