timer: protect timers_state's clock with seqlock
QEMU_CLOCK_VIRTUAL may be read outside BQL. This will make itsfoundation, i.e. cpu_clock_offset exposed to race condition.Using private lock to protect it.
After this patch, reading QEMU_CLOCK_VIRTUAL is thread safe...
seqlock: introduce read-write seqlock
Seqlock implementation for QEMU. Usage idiom
reader: do { start = seqlock_read_begin(&sl); ... } while (seqlock_read_retry(&sl, start));
writer: seqlock_write_lock(&sl); ... seqlock_write_unlock(&sl);...
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 'sweil/mingw' into staging
Merge remote-tracking branch 'sweil/tci' into staging
Message-id: 1380137693-3729-1-git-send-email-sw@weilnetz.de...
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...
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
pc,pci,virtio fixes and cleanups
This includes pc and pci cleanups and enhancements,and a virtio-net bugfix related to softmac programming.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
bitops: Add rotate functions (rol8, ror8, ...)
These functions were copies from include/linux/bitopts.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Richard Henderson <rth@twiddle.net>
qemu-timer: make qemu_timer_mod_ns() and qemu_timer_del() thread-safe
Introduce QEMUTimerList->active_timers_lock to protect the linked listof active timers. This allows qemu_timer_mod_ns() to be called from anythread.
Note that vm_clock is not thread-safe and its use of...
range: add min/max operations on ranges
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
range: add Range to typedefs
will help simplify header dependencies.
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>...
aio / timers: Rearrange timer.h & make legacy functions call non-legacy
Rearrange timer.h so it is in order by function type.
Make legacy functions call non-legacy functions rather than vice-versa.
Convert cpus.c to use new API.
Signed-off-by: Alex Bligh <alex@alex.org.uk>...
aio / timers: Remove main_loop_timerlist
Now we have timerlistgroups implemented and main_loop_tlg, weno longer need the concept of a default timer list associatedwith each clock. Remove it and simplify initialisation ofclocks and timer lists.
aio / timers: Switch entire codebase to the new timer API
This is an autogenerated patch using scripts/switch-timer-api.
Switch the entire code base to using the new timer API.
Note this patch may introduce some line length issues.
aio / timers: Remove legacy interface
Remove the legacy interface from include/qemu/timers.h.
Ensure struct QEMUClock is not exposed at all.
Signed-off-by: Alex Bligh <alex@alex.org.uk>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
aio / timers: Remove alarm timers
Remove alarm timers from qemu-timers.c now we use g_poll / ppollinstead.
aio / timers: Remove legacy qemu_clock_deadline & qemu_timerlist_deadline
Remove qemu_clock_deadline and qemu_timerlist_deadline now we are usingthe ns functions throughout.
aio / timers: Add qemu_clock_get_ms and qemu_clock_get_ms
Add utility functions qemu_clock_get_ms and qemu_clock_get_us
aio / timers: Add documentation and new format calls
Add documentation for existing qemu timer calls. Add new formatcalls of the format timer_XXX rather than qemu_XXX_timerfor consistency.
aio / timers: Add a notify callback to QEMUTimerList
Add a notify pointer to QEMUTimerList so it knows what to notifyon a timer change.
aio / timers: On timer modification, qemu_notify or aio_notify
On qemu_mod_timer_ns, ensure qemu_notify or aio_notify is called toend the appropriate poll(), irrespective of use_icount value.
On qemu_clock_enable, ensure qemu_notify or aio_notify is called for...
aio / timers: Introduce new API timer_new and friends
Introduce new API for creating timers - timer_new and_ns, _ms, _us derivatives.
aio / timers: Use all timerlists in icount warp calculations
Notify all timerlists derived from vm_clock in icount warpcalculations.
When calculating timer delay based on vm_clock deadline, useall timerlists.
For compatibility, maintain an apparent bug where when using...
aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress
Make qemu_run_timers and qemu_run_all_timers return progressso that aio_poll etc. can determine whether a timer has beenrun.
aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList
Split QEMUClock into QEMUClock and QEMUTimerList so that we canhave more than one QEMUTimerList associated with the same clock.
Introduce a main_loop_timerlist concept and make existingqemu_clock_* calls that actually should operate on a QEMUTimerList...
aio / timers: Untangle include files
include/qemu/timer.h has no need to include main-loop.h anddoing so causes an issue for the next patch. Unfortunatelyvarious files assume including timers.h will pull in main-loop.h.Untangle this mess.
aio / timers: Add QEMUTimerListGroup and helper functions
Add QEMUTimerListGroup and helper functions, to representa QEMUTimerList associated with each clock. Add a defaultQEMUTimerListGroup representing the default timer listswhich are not associated with any other object (e.g....
aio / timers: add ppoll support with qemu_poll_ns
Add qemu_poll_ns which works like g_poll but takes a nanosecondtimeout.
aio / timers: Rename qemu_timer_* functions
Rename four functions in preparation for new API.
Rename qemu_timer_expired to timer_expiredRename qemu_timer_expire_time_ns to timer_expire_time_nsRename qemu_timer_pending to timer_pendingRename qemu_timer_expired_ns to timer_expired_ns...
aio / timers: Rename qemu_new_clock and expose clock types
Rename qemu_new_clock to qemu_clock_new.
Expose clock types.
aio / timers: add qemu-timer.c utility functions
Add utility functions to qemu-timer.c for nanosecond timing.
Add qemu_clock_deadline_ns to calculate deadlines tonanosecond accuracy.
Add utility function qemu_soonest_timeout to calculate soonest deadline....
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>...
QemuOpts: Add qemu_opt_unset()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
bitops: Provide sextract32() and sextract64()
A common operation in instruction decoding is to take a fieldfrom an instruction that represents a signed integer in somearbitrary number of bits, and sign extend it into a C signedinteger type for manipulation. Provide new functions sextract32()...
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....
log: Change log_cpu_state[_mask]() argument to CPUState
Since commit 878096eeb278a8ac1ccd6667af73e026f29b4cf5 (cpu: Turncpu_dump_{state,statistics}() into CPUState hooks) CPUArchState is nolonger needed.
Add documentation and make the functions available through qemu/log.h...
pci,misc enhancements
This includes some pci enhancements:
Better support for systems with multiple PCI root busesFW cfg interface for more robust pci programming in BIOSMinor fixes/cleanups for fw cfg and cross-version migration -...
add a header file for atomic operations
We're already using them in several places, but __sync builtins are justtoo ugly to type, and do not provide seqcst load/store operations.
Reviewed-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
range: add Range structure
Sometimes we need to pass ranges around, add ahandy structure for this purpose.
Note: memory.c defines its own concept of AddrRange structure forworking with 128 addresses. It's necessary there for doing range math.This is not needed for most users: struct Range is...
pci: store PCI hole ranges in guestinfo structure
Will be used to pass hole ranges to guests.
int128: optimize and add test cases
For add, the carry only requires checking one of the arguments.For sub and neg, we can similarly optimize computation of thecarry.
For ge, we can just do lexicographic order.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Merge remote-tracking branch 'afaerber/qom-cpu' into staging
cpu: Turn cpu_dump_{state,statistics}() into CPUState hooks
Make cpustats monitor command available unconditionally.
Prepares for changing kvm_handle_internal_error() and kvm_cpu_exec()arguments to CPUState.
Signed-off-by: Andreas Färber <afaerber@suse.de>
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...
audio: Replace static functions in header file by macros, remove GCC_ATTR
Using macros instead of static functions for dolog and for ldebugsimplifies the code and can also reduce the total code size.
GCC_ATTR was only used in audio_int.h, so it is now unused and...
memory: make section size a 128-bit integer
So far, the size of all regions passed to listeners could fit in 64 bits,because artificial regions (containers and aliases) are eliminated bythe memory core, leaving only device regions which have reasonable sizes...
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>
log.h: Supply missing includes
<stdio.h> has always been missing. Rest missed in commit eeacee4.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Laszlo "ever the optimist" Ersek <lersek@redhat.com>Message-id: 1370610036-10577-3-git-send-email-armbru@redhat.com...
error-report.h: Supply missing include
Missed in commit e5924d8.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Laszlo "ever the optimist" Ersek <lersek@redhat.com>Message-id: 1370610036-10577-2-git-send-email-armbru@redhat.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h
This will avoid issues with hwaddr and ram_addr_t when includingsysemu/memory_mapping.h for CONFIG_USER_ONLY, e.g., from qom/cpu.h.
pci: misc cleanups
This includes some pci-related cleanups,and fw cfg cleanups which will be useful for on-goingpci related work.
fw_cfg: move typedef to qemu/typedefs.h
Less header dependencies this way.
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...
remove some double-includes
Some source files #include the same header more thanonce for no good reason. Remove second #includes insuch cases.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
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....
osdep.h: include sys/types.h for ssize_t definition
sys/types.h is taken out from "ifdef OpenBSD" guard. It should besafe for other systems, according to following survey:http://hacks.owlfolio.org/header-survey/
This fixes build for CONFIG_IOVEC-less systems (mingw)....
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...
Remove unnecessary FreeBSD #include
sys/param.h was included to define __FreeBSD_version, but the conditionalusing it was removed by commit d05ef160453e98546a4197496dc8a3cb2defac53(Brad Smith, "Allow clock_gettime() monotonic clock to be utilized on more...
Merge remote-tracking branch 'bonzini/scsi-next' into staging
virtio-scsi: create VirtIOSCSICommon
This patch refactors existing virtio-scsi code into VirtIOSCSICommonin order to allow virtio_scsi_init_common() to be used by both internalvirtio_scsi_init() and external vhost-scsi-pci code.
Cc: Michael S. Tsirkin <mst@redhat.com>...
bswap: fix compiler warning
The bswap functions use memcpy but the bswap.h header itself does not seem toinclude it in some configuration such as cross compiling for powerpc64on x86_64 machine.
The patch explicitly includes string.h.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>...
memory: move core typedefs to qemu/typedefs.h
sysemu: avoid proliferation of include/ subdirectories
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>...
compiler: fix warning with GCC 4.8.0
GCC 4.8.0 introduces a new warning:
block/qcow2-snapshot.c: In function 'qcow2_write_snapshots’: block/qcow2-snapshot.c:252:18: error: typedef 'qemu_build_bug_on__253' locally defined but not used [-Werror=unused-local-typedefs]...
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...
main-loop: add qemu_get_aio_context()
It is very useful to get the main loop AioContext, which is a staticvariable in main-loop.c.
I'm not sure whether qemu_get_aio_context() will be necessary in thefuture once devices focus on using their own AioContext instead of the...
qemu-option: Add qemu_opts_absorb_qdict()
This adds a function that adds all entries of a QDict to a QemuOpts ifthe keys are known, and leaves only the rest in the QDict.
This way a single QDict of -drive options can be processed in multipleplaces (generic block layer, block driver, backing file block driver,...
chardev: add udp support to qapi
This patch adds 'udp' support to qapi.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Add a TPM Passthrough backend driver implementation
This patch is based of off version 9 of Stefan Berger's patch series "QEMU Trusted Platform Module (TPM) integration" and adds a new backend driver for it.
This patch adds a passthrough backend driver for passing commands sent to the...
qemu-file: check exit status when closing a pipe QEMUFile
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>...
block-migration: add lock
Some state is shared between the block migration code and its AIOcallbacks. Once block migration will run outside the iothread,the block migration code and the AIO callbacks will be able torun concurrently. Protect the critical sections with a separate...
Merge remote-tracking branch 'bonzini/hw-dirs' into staging
move socket_set_nodelay to osdep.c
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw: move fifo.[ch] to libqemuutil
fifo.c is generic code that can be easily unit tested. So itbelongs in libqemuutil.
qemu-log: default to stderr for logging output
Switch the default for qemu_log logging output from "/tmp/qemu.log" to stderr. This is an incompatible change in some sense, but loggingis mostly used for debugging purposes so it shouldn't affect production...
qemu-log: Remove qemu_log_try_set_file() and its users
Remove the function qemu_log_try_set_file() and its users (whichare all in TCG code generation functions for various targets).This function was added to abstract out code which was originallywritten as "if (!logfile) logfile = stderr;" in order that BUG:...
iohandler: switch to GPollFD
Convert iohandler_select_fill() and iohandler_select_poll() to useGPollFD instead of rfds/wfds/xfds.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>Message-id: 1361356113-11049-7-git-send-email-stefanha@redhat.com...
host-utils: Use __int128_t for mul[us]64
Replace some x86_64 specific inline assembly with something thatall 64-bit hosts ought to optimize well. At worst this becomesa call to the gcc __multi3 routine, which is no worse than ourimplementation in util/host-utils.c....
bitops: Remove routines redundant with host-utils
Signed-off-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
bitops: Write bitops_flsl in terms of clzl
hbitmap: Use non-bitops ctzl
Both uses of ctz have already eliminated zero, and thus the differencein edge conditions between the two routines is irrelevant.
Signed-off-by: Richard Henderson <rth@twiddle.net>Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
host-utils: Fix coding style and add comments
Add function comments to the routines, documenting the cornercases upon which we are standardizing. Fix the few instancesof non-standard coding style.
Signed-off-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Eric Blake <eblake@redhat.com>...
host-utils: Add host long specific aliases for clz, ctz, ctpop
We will standardize on these names, rather than the similar routinescurrently residing in qemu/bitops.h.
qemu-log: Rename CPULogItem, cpu_log_items to QEMULogItem, qemu_log_items
Rename the typedef CPULogItem and the public array cpu_log_itemsto names that better reflect the fact that the qemu_log functionalityisn't restricted to TCG CPU debug logs any more....
qemu-log: Rename the public-facing cpu_set_log function to qemu_set_log
Rename the public-facing function cpu_set_log to qemu_set_log. Thisrequires us to rename the internal-only qemu_set_log() todo_qemu_set_log().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
qemu-log: Rename cpu_str_to_log_mask to qemu_str_to_log_mask
Rename cpu_str_to_log_mask() to qemu_str_to_log_mask(), sincethe qemu_log functionality is no longer restricted to TCG CPUdebug logging.
qemu-log: Abstract out "print usage message about valid log categories"
Abstract out the "print a human readable list of all thevalid log categories" functionality which is currently duplicatedin three separate places. (We leave the monitor.c help_cmd()...
qemu-log: Unify {cpu_set,set_cpu}_log_filename as qemu_set_log_filename
The qemu_log() functionality is no longer specific to TCG CPU debug logs.Rename cpu_set_log_filename() to qemu_set_log_filename() and drop thepointless wrapper set_cpu_log_filename()....
bswap: Fix width of swap in leul_to_cpu
The misnamed HOST_LONG_BITS is really HOST_POINTER_BITS. Here we'reexplicitly using an unsigned long, rather than uintptr_t, so it ismore correct to select the swap size via ULONG_MAX.
Acked-by: Andreas Färber <afaerber@suse.de>...
bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl
We had two copies of a ffs function for longs with subtly differentsemantics and, for the one in bitops.h, a confusing name: the resultwas off-by-one compared to the library function ffsl....