History | View | Annotate | Download (33.1 kB)
kvm: Decouple 'async interrupt delivery' from 'kernel irqchip'
On x86 userspace delivers interrupts to the kernel asynchronously(and therefore VCPU idle management is done in the kernel) if andonly if there is an in-kernel irqchip. On other architectures this...
Fixes related to processing of qemu's -numa option
The -numa option to qemu is used to create [fake] numa nodesand expose them to the guest OS instance.
There are a couple of issues with the -numa option:
a) Max VCPU's that can be specified for a guest while using...
cpu: Move thread_kicked to CPUState
Change field type to bool.
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Move CPU_COMMON_THREAD into CPUState
CPU_COMMON_THREAD was only used for Windows, adding an hThread fieldto CPU_COMMON.
Move the field into QOM CPUState and change its type to HANDLE,which it is assigned from. This requires Windows headers, pulled in...
cpu: Move thread field into CPUState
cpus.c: Make all_cpu_threads_idle() static
Commit 946fb27c1 moved all the uses of all_cpu_threads_idle()into cpus.c. This means we can mark the function 'static'(again), if we shuffle it a bit earlier in the source file.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
kvm: Drop redundant kvm_enabled from cpu_thread_is_idle
This is now implied by kvm_irqchip_in_kernel.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Avi Kivity <avi@redhat.com>
qtest: add test framework
The idea behind qtest is pretty simple. Instead of executing a CPU via TCG orKVM, rely on an external process to send events to the device model that the CPUwould normally generate.
qtest presents itself as an accelerator. In addition, a new option is added to...
qtest: add clock management
This patch combines qtest and -icount together to turn the vm_clockinto a source that can be fully managed by the client. To this end newcommands clock_step and clock_set are added. Hooking them with libqtestis left as an exercise to the reader....
Rename CPUState -> CPUArchState
Scripted conversion: for file in .[hc] hw/.[hc] hw/kvm/*.[hc] linux-user/*.[hc] linux-user/m68k/*.[hc] bsd-user/*.[hc] darwin-user/*.[hc] tcg/*/*.[hc] target-*/cpu.h; do sed -i "s/CPUState/CPUArchState/g" $file done...
Allow to use pause_all_vcpus from VCPU context
In order to perform critical manipulations on the VM state in thecontext of a VCPU, specifically code patching, stopping and resuming ofall VCPUs may be necessary. resume_all_vcpus is already compatible, now...
Remove useless casts from cpu iterators
CPUState::next_cpu is already CPUState *.
Process pending work while waiting for initial kick-off in TCG mode
When the TCG thread is started but not yet the machine, we wait inqemu_tcg_cpu_thread_fn on tcg_halt_cond. To allow run_on_cpu already atthis time, we need to process pending request in that loop....
kvm: Set cpu_single_env only once
As we have thread-local cpu_single_env now and KVM uses exactly onethread per VCPU, we can drop the cpu_single_env updates from the loopand initialize this variable only once during setup.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
apic: Inject external NMI events via LINT1
On real hardware, NMI button events are injected via the LINT1 line ofthe APICs. E.g. kdump expect this wiring and gets upset if the per-APICLINT1 mask is not respected, i.e. if NMIs are injected to VCPUs that...
cleanup, Remove duplicated code
These two blocks of code are exactly the same, remove one.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
fix win32 build
On Windows, cpus.c needs access to the hThread. Add a Windows-specificfunction to grab it. This requires changing the CPU threads tojoinable. There is no substantial change because the threads runin an infinite loop.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
Merge remote-tracking branch 'stefanha/trivial-patches-next' into staging
qemu-thread: add API for joinable threads
Split from Jan's original qemu-thread-posix.c patch. No semantic change,just introduce the new API that POSIX and Win32 implementations willconform to.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
qapi: Convert pmemsave
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi: Convert inject-nmi
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi: Convert memsave
Please, note that the QMP command has a new 'cpu-index' parameter.
fix typo: delete redundant semicolon
Double semicolons should be single.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Merge remote-tracking branch 'kwolf/for-anthony' into staging
block: convert qemu_aio_flush() calls to bdrv_drain_all()
Many places in QEMU call qemu_aio_flush() to complete all pendingasynchronous I/O. Most of these places actually want to drain all blockrequests but there is no block layer API to do so.
This patch introduces the bdrv_drain_all() API to wait for requests...
fix spelling in main directory
reenable vm_clock when resuming all vcpus
We disable vm_clock when pausing all vcpus, but we forget toreenable it when resuming all vcpus. It will cause that theguest can not be rebooted.
Tested-by: Zhi Yong Wu <zwu.kernel@gmai.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>...
Simplify cpu_exec_all to tcg_exec_all
After the removal of the non-threaded mode cpu_exec_all is now only usedby TCG. Refactor it accordingly, also dropping its unused return value.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qapi: Convert query-cpus
simplify main loop functions
Provide a clean example of how to use the main loop in the tools.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-timer: move icount to cpus.c
None of this is needed by tools, and most of it can even be made staticinside cpus.c.
qemu-timer: do not refer to runstate_is_running()
main-loop: create main-loop.h
main-loop: create main-loop.c
runstate: Allow user to migrate twice
It should be a matter of allowing the transition POSTMIGRATE ->FINISH_MIGRATE, but it turns out that the VM won't do thetransition the second time because it's already stopped.
So this commit also adds vm_stop_force_state() which performs...
block: avoid SIGUSR2
Now that iothread is always compiled sending a signal seems only anadditional step. This patch also avoid writing to two pipe (one from signaland one in qemu_service_io).
Work with kvm enabled or disabled. strace output is more readable (less syscalls)....
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),we pass a VMSTOP macro as the 'reason' argument. This is not idealbecause the VMSTOP macros tell why qemu stopped and not exactlywhat the current VM state is....
RunState: Add additional states
Currently, only vm_start() and vm_stop() change the VM state.That's, the state is only changed when starting or stopping the VM.
This commit adds the runstate_set() function, which makes it possibleto also do state transitions when the VM is stopped or running....
Drop the vm_running global variable
Use runstate_is_running() instead, which is introduced by this commit.
main: force enabling of I/O thread
Enabling the I/O thread by default seems like an important part of declaring1.0. Besides allowing true SMP support with KVM, the I/O thread means that theTCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which...
Replace qemu_system_cond with VCPU stop mechanism
We can express the VCPU thread wakeup with the stop mechanism, savingboth qemu_system_ready and the qemu_system_cond. For KVM threads, we canjust enter the main loop as long as the thread is stopped. The central...
Do not kick vcpus in TCG mode
In TCG mode, iothread and vcpus run in lock-step. So it's pointless tosend a signal from qemu_cpu_kick to the vcpu thread - if we got here,the receiver already left the vcpu loop.
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
iothread: replace fair_mutex with a condition variable
This conveys the intention better, and scales to more than >1threads contending the mutex with the iothread (as long as allof them have a "quiescent point" like the TCG thread has).
Also, on Mac OS X the fair_mutex somehow didn't work as intended...
Fix signal handling of SIG_IPI when io-thread is enabled
Both the signal thread (via sigwait()) and the cpu thread (viaa normal signal handler) were attempting to catch SIG_IPI.
This resulted in random freezes under Darwin.
This patch separates SIG_IPI from the rest of the signals handled...
Fix signal handling when io-thread is disabled
Changes since v1:- take pthread_sigmask() out of the ifdef as it is now commonto both parts.
This fix effectively blocks, in the main thread, the signals handledby signalfd or the compatibility signal thread....
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
Remove exec-all.h include directives
Most exec-all.h include directives are now useless, remove them.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Do not include compatfd for WIN32
sigset_t, used by that header, is not available in mingw32 environments.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Fix typo in cpus.c
filed -> failed
Signed-off-by: Alexandre Raymond <cerbere@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Command line support for altering the log file location
Add command line support for logging to a location other than /tmp/qemu.log.
With logging enabled (command line option -d), the log is written tothe hard-coded path /tmp/qemu.log. This patch adds support for writing...
really fix -icount in the iothread case
The correct fix for -icount is to consider the biggest differencebetween iothread and non-iothread modes. In the traditional model,CPUs run before the iothread calls select (or WaitForMultipleObjectsfor Win32). In the iothread model, CPUs run while the iothread...
enable vm_clock to "warp" in the iothread+icount case
The previous patch however is not enough, because if the virtual CPUgoes to sleep waiting for a future timer interrupt to wake it up, qemudeadlocks. The timer interrupt never comes because time is driven by...
qemu_next_deadline should not consider host-time timers
It is purely for icount-based virtual timers. And now that we got thecode right, rename the function to clarify the intended scope.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>...
Merge remote branch 'qemu-kvm/uq/master' into staging
Fix conversions from pointer to int and vice versa
Here the int values fds0, sigfd, s, sock and fd are convertedto void pointers which are later converted back to an int value.
These conversions should always use intptr_t instead of unsigned long.
They are needed for environments where sizeof(long) != sizeof(void *)....
Expose thread_id in info cpus
Based on patch by Glauber Costa:
To allow management applications like libvirt to apply CPU affinities tothe VCPU threads, expose their ID via info cpus. This patch provides thepre-existing and used interface from qemu-kvm....
kvm: Add in-kernel irqchip awareness to cpu_thread_is_idle
With in-kernel irqchip support enabled, the vcpu threads sleep in kernelspace while halted. Account for this difference in cpu_thread_is_idle.
Implement qemu_kvm_eat_signals only for CONFIG_LINUX
qemu_kvm_eat_signals requires POSIX support with realtime extensions forsigtimedwait. Not all our target platforms provide this. Moreover,undefined sigbus_reraise was referenced on non-Linux as well....
x86: Unbreak TCG support for hardware breakpoints
Commit 83f338f73e broke x86 hardware breakpoint emulation by moving thedebug exception handling out of cpu_exec. Fix this by moving all TCGrelated bits back, only leaving the generic guest debugging parts in...
do not use timedwait on qemu_halt_cond
The following conditions can cause cpu_has_work(env) to become true:
- env->queued_work_first: run_on_cpu is already kicking the VCPU
- env->stop = 1: pause_all_vcpus is already kicking the VCPU
- env->stopped = 0: resume_all_vcpus is already kicking the VCPU...
do not use timedwait on qemu_system_cond
qemu_main_loop_start is the only place where qemu_system_ready is setto 1.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
do not use timedwait on qemu_pause_cond
all_vcpus_paused can start returning true after penv->stopped changesfrom 0 to 1. When this is done, qemu_pause_cond is always signaled.
do not use timedwait on qemu_cpu_cond
Whenever env->created becomes true, qemu_cpu_cond is signaled by {kvm,tcg}_cpu_thread_fn.
iothread stops the vcpu thread via IPI
merge all signal initialization with qemu_signalfd_init, rename
provide dummy signal init functions for win32
protect qemu_cpu_kick_self for Win32
add Win32 IPI service
Refactor thread retrieval and check
We have qemu_cpu_self and qemu_thread_self. The latter is retrieving thecurrent thread, the former is checking for equality (using CPUState). Wealso have qemu_thread_equal which is only used like qemu_cpu_self.
This refactors the interfaces, creating qemu_cpu_is_self and...
include qemu-thread.h early
exit round-robin vcpu loop if cpu->stopped is true
Sometimes vcpus are stopped directly without going through ->stop = 1.Exit the VCPU execution loop in this case as well.
always signal pause_cond after stopping a VCPU
io-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond
Refactor kvm&tcg function names in cpus.c
Pure interface cosmetics: Ensure that only kvm core services (asdeclared in kvm.h) start with "kvm_". Prepend "qemu_" to those thatviolate this rule in cpus.c. Also rename the corresponding tcg functionsfor the sake of consistency....
Refactor cpu_has_work/any_cpu_has_work in cpus.c
Avoid duplicate use of the function name cpu_has_work, it's confusing,also their scope. Refactor cpu_has_work to cpu_thread_is_idle and do thesame with any_cpu_has_work.
Fix a few coding style violations in cpus.c
No functional changes.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Improve vm_stop reason declarations
Define and use dedicated constants for vm_stop reasons, they actuallyhave nothing to do with the EXCP_* defines used so far. At this chance,specify more detailed reasons so that VM state change handlers canevaluate them....
Refactor debug and vmstop request interface
Instead of fiddling with debug_requested and vmstop_requested directly,introduce qemu_system_debug_request and turn qemu_system_vmstop_requestinto a public interface. This aligns those services with exiting ones in...
Move debug exception handling out of cpu_exec
To prepare splitting up KVM and TCG CPU entry/exit, move the debugexception into cpus.c and invoke cpu_handle_debug_exception on returnfrom qemu_cpu_exec.
This also allows to clean up the debug request signaling: We can assign...
kvm: Separate TCG from KVM cpu execution
Mixing up TCG bits with KVM already led to problems around eflagsemulation on x86. Moreover, quite some code that TCG requires on cpuenty/exit is useless for KVM. So dispatch between tcg_cpu_exec andkvm_cpu_exec as early as possible....
kvm: Drop redundant kvm_enabled from kvm_cpu_thread_fn
kvm: Handle kvm_init_vcpu errors
Do not ignore errors of kvm_init_vcpu, they are fatal.
kvm: Provide sigbus services arch-independently
Provide arch-independent kvm_on_sigbus* stubs to remove the #ifdef'eryfrom cpus.c. This patch also fixes --disable-kvm build by providing themissing kvm_on_sigbus_vcpu kvm-stub.
Refactor signal setup functions in cpus.c
Move {tcg,kvm}_init_ipi and block_io_signals to avoid prototypes, renamethe former two to clarify that they deal with more than SIG_IPI. Nofunctional changes - except for the tiny fixup of strerror usage.
The forward declaration of sigbus_handler is just temporarily, it will...
kvm: Set up signal mask also for !CONFIG_IOTHREAD
Block SIG_IPI, unblock it during KVM_RUN, just like in io-thread mode.It's unused so far, but this infrastructure will be required forself-IPIs and to process SIGBUS plus, in KVM mode, SIGIO and SIGALRM. As...
kvm: Refactor qemu_kvm_eat_signals
We do not use the timeout, so drop its logic. As we always poll oursignals, we do not need to drop the global lock. Removing those callsallows some further simplifications. Also fix the error processing ofsigpending at this chance....
kvm: Call qemu_kvm_eat_signals also under !CONFIG_IOTHREAD
Move qemu_kvm_eat_signals around and call it also when the IO-thread isnot used. Do not yet process SIGBUS, will be armed in a separate step.
Set up signalfd under !CONFIG_IOTHREAD
Will be required for SIGBUS handling. For obvious reasons, this willremain a nop on Windows hosts.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
kvm: Fix race between timer signals and vcpu entry under !IOTHREAD
Found by Stefan Hajnoczi: There is a race in kvm_cpu_exec betweenchecking for exit_request on vcpu entry and timer signals arrivingbefore KVM starts to catch them. Plug it by blocking both timer related...
kvm: Add MCE signal support for !CONFIG_IOTHREAD
Currently, we only configure and process MCE-related SIGBUS events ifCONFIG_IOTHREAD is enabled. The groundwork is laid, we just need tofactor out the required handler registration and system configuration....
Introduce VCPU self-signaling service
Introduce qemu_cpu_kick_self to send SIG_IPI to the calling VCPUcontext. First user will be kvm.
Prevent abortion on multiple VCPU kicks
If we call qemu_cpu_kick more than once before the target was able toprocess the signal, pthread_kill will fail, and qemu will abort. Preventthis by avoiding the redundant signal.
This logic can be found in qemu-kvm as well....
Stop current VCPU on synchronous reset requests
If some I/O operation ends up calling qemu_system_reset_request in VCPUcontext, we record this and inform the io-thread, but we do notterminate the VCPU loop. This can lead to fairly unexpected behavior if...
Trigger exit from cpu_exec_all on pending IO events
Except for timer events, we currently do not leave the loop over allVCPUs if an IO event was filed. That may cause unexpected IO latenciesunder !CONFIG_IOTHREAD in SMP scenarios. Fix it by setting the global...
kvm: Do not use qemu_fair_mutex
The imbalance in the hold time of qemu_global_mutex only exists in TCGmode. In contrast to TCG VCPUs, KVM drops the global lock during guestexecution. We already avoid touching the fairness lock from theIO-thread in KVM mode, so also stop using it from the VCPU threads....
cpus: flush all requests on each vm stop
Flush all requests once we have stopped allcpus and devices.Make sure disk is in consistent state.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Tested-by: Jason Wang <jasowang@redhat.com>Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
target-xxx: Use fprintf_function (format checking)
fprintf_function uses format checking with GCC_FMT_ATTR.
Cc: Blue Swirl <blauwirbel@gmail.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...