summaryrefslogtreecommitdiffstats
path: root/cpus.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'stefanha/trivial-patches-next' into stagingAnthony Liguori2011-12-141-1/+1
|\
| * fix typo: delete redundant semicolonDong Xu Wang2011-12-061-1/+1
| | | | | | | | | | | | | | 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>
* | qemu-thread: add API for joinable threadsJan Kiszka2011-12-121-2/+4
| | | | | | | | | | | | | | | | | | | | Split from Jan's original qemu-thread-posix.c patch. No semantic change, just introduce the new API that POSIX and Win32 implementations will conform to. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* | qapi: Convert inject-nmiLuiz Capitulino2011-12-061-0/+13
| | | | | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* | qapi: Convert pmemsaveLuiz Capitulino2011-12-061-0/+30
| | | | | | | | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* | qapi: Convert memsaveLuiz Capitulino2011-12-061-0/+47
|/ | | | | | | Please, note that the QMP command has a new 'cpu-index' parameter. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2011-12-051-1/+1
|\
| * block: convert qemu_aio_flush() calls to bdrv_drain_all()Stefan Hajnoczi2011-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Many places in QEMU call qemu_aio_flush() to complete all pending asynchronous I/O. Most of these places actually want to drain all block requests but there is no block layer API to do so. This patch introduces the bdrv_drain_all() API to wait for requests across all BlockDriverStates to complete. As a bonus we perform checks after qemu_aio_wait() to ensure that requests really have finished. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | fix spelling in main directoryDong Xu Wang2011-12-021-1/+1
|/ | | | | Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* reenable vm_clock when resuming all vcpusWen Congyang2011-11-071-0/+1
| | | | | | | | | | | We disable vm_clock when pausing all vcpus, but we forget to reenable it when resuming all vcpus. It will cause that the guest can not be rebooted. Tested-by: Zhi Yong Wu <zwu.kernel@gmai.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Simplify cpu_exec_all to tcg_exec_allJan Kiszka2011-11-011-9/+5
| | | | | | | | After the removal of the non-threaded mode cpu_exec_all is now only used by 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-cpusLuiz Capitulino2011-10-271-0/+45
| | | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* simplify main loop functionsPaolo Bonzini2011-10-211-5/+0
| | | | | | Provide a clean example of how to use the main loop in the tools. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* main-loop: create main-loop.cPaolo Bonzini2011-10-211-188/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* main-loop: create main-loop.hPaolo Bonzini2011-10-211-6/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: do not refer to runstate_is_running()Paolo Bonzini2011-10-211-0/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-timer: move icount to cpus.cPaolo Bonzini2011-10-211-18/+277
| | | | | | | None of this is needed by tools, and most of it can even be made static inside cpus.c. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* runstate: Allow user to migrate twiceLuiz Capitulino2011-10-191-0/+11
| | | | | | | | | | | | | It should be a matter of allowing the transition POSTMIGRATE -> FINISH_MIGRATE, but it turns out that the VM won't do the transition the second time because it's already stopped. So this commit also adds vm_stop_force_state() which performs the transition even if the VM is already stopped. While there also allow other states to migrate. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2011-09-201-5/+0
|\
| * block: avoid SIGUSR2Frediano Ziglio2011-09-201-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that iothread is always compiled sending a signal seems only an additional step. This patch also avoid writing to two pipe (one from signal and one in qemu_service_io). Work with kvm enabled or disabled. strace output is more readable (less syscalls). [ kwolf: Merged build fix by Paolo Bonzini ] Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | Drop the vm_running global variableLuiz Capitulino2011-09-151-5/+4
| | | | | | | | | | | | Use runstate_is_running() instead, which is introduced by this commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* | RunState: Add additional statesLuiz Capitulino2011-09-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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 possible to also do state transitions when the VM is stopped or running. Additional states are also added and the current state is stored. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* | Replace the VMSTOP macros with a proper state typeLuiz Capitulino2011-09-151-5/+5
|/ | | | | | | | | | | | | | | Today, when notifying a VM state change with vm_state_notify(), we pass a VMSTOP macro as the 'reason' argument. This is not ideal because the VMSTOP macros tell why qemu stopped and not exactly what the current VM state is. One example to demonstrate this problem is that vm_start() calls vm_state_notify() with reason=0, which turns out to be VMSTOP_USER. This commit fixes that by replacing the VMSTOP macros with a proper state type called RunState. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* main: force enabling of I/O threadAnthony Liguori2011-09-021-143/+0
| | | | | | | | | | | | | | | | Enabling the I/O thread by default seems like an important part of declaring 1.0. Besides allowing true SMP support with KVM, the I/O thread means that the TCG VCPU doesn't have to multiplex itself with the I/O dispatch routines which currently requires a (racey) signal based alarm system. I know there have been concerns about performance. I think so far the ones that have come up (virtio-net) are most likely due to secondary reasons like decreased batching. I think we ought to force enabling I/O thread early in 1.0 development and commit to resolving any lingering issues. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Replace qemu_system_cond with VCPU stop mechanismJan Kiszka2011-08-221-14/+6
| | | | | | | | | | | | | | We can express the VCPU thread wakeup with the stop mechanism, saving both qemu_system_ready and the qemu_system_cond. For KVM threads, we can just enter the main loop as long as the thread is stopped. The central TCG thread is better held back before the loop as there can be side effects of the services called even when all CPUs are stopped. Creating VCPUs in stopped state will also be required for proper CPU hotplugging support. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Do not kick vcpus in TCG modeJan Kiszka2011-08-221-1/+1
| | | | | | | | | In TCG mode, iothread and vcpus run in lock-step. So it's pointless to send a signal from qemu_cpu_kick to the vcpu thread - if we got here, the receiver already left the vcpu loop. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-4/+4
| | | | | | 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 variablePaolo Bonzini2011-07-231-15/+9
| | | | | | | | | | | | | This conveys the intention better, and scales to more than >1 threads contending the mutex with the iothread (as long as all of them have a "quiescent point" like the TCG thread has). Also, on Mac OS X the fair_mutex somehow didn't work as intended and deadlocked. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Alexander Graf <agraf@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix signal handling of SIG_IPI when io-thread is enabledAlexandre Raymond2011-07-161-1/+9
| | | | | | | | | | | | | | | Both the signal thread (via sigwait()) and the cpu thread (via a 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 by the signal thread, because it is independently caught by the cpu thread. Signed-off-by: Alexandre Raymond <cerbere@gmail.com> Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix signal handling when io-thread is disabledAlexandre Raymond2011-07-161-1/+1
| | | | | | | | | | | | | | | | | Changes since v1: - take pthread_sigmask() out of the ifdef as it is now common to both parts. This fix effectively blocks, in the main thread, the signals handled by signalfd or the compatibility signal thread. This way, such signals are received synchronously in the main thread through sigfd_handler() instead of triggering the signal handler directly, asynchronously. Signed-off-by: Alexandre Raymond <cerbere@gmail.com> Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori2011-06-271-0/+3
|\
| * Do not include compatfd for WIN32Jan Kiszka2011-06-241-0/+3
| | | | | | | | | | | | | | 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>
* | Remove exec-all.h include directivesBlue Swirl2011-06-261-1/+0
|/ | | | | | Most exec-all.h include directives are now useless, remove them. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix typo in cpus.cAlexandre Raymond2011-06-201-1/+1
| | | | | | | 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 locationMatthew Fernandez2011-06-151-0/+5
| | | | | | | | | | | 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 to the hard-coded path /tmp/qemu.log. This patch adds support for writing the log to a different location by passing the -D option. Signed-off-by: Matthew Fernandez <matthew.fernandez@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu_next_deadline should not consider host-time timersPaolo Bonzini2011-04-151-2/+2
| | | | | | | | | It is purely for icount-based virtual timers. And now that we got the code 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> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* enable vm_clock to "warp" in the iothread+icount casePaolo Bonzini2011-04-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous patch however is not enough, because if the virtual CPU goes to sleep waiting for a future timer interrupt to wake it up, qemu deadlocks. The timer interrupt never comes because time is driven by icount, but the vCPU doesn't run any insns. You could say that VCPUs should never go to sleep in icount mode if there is a pending vm_clock timer; rather time should just warp to the next vm_clock event with no sleep ever taking place. Even better, you can sleep for some time related to the time left until the next event, to avoid that the warps are too visible externally; for example, you could be sending network packets continously instead of every 100ms. This is what this patch implements. qemu_clock_warp is called: 1) whenever a vm_clock timer is adjusted, to ensure the warp_timer is synchronized; 2) at strategic points in the CPU thread, to make sure the insn counter is synchronized before the CPU starts running. In any case, the warp_timer is disabled while the CPU is running, because the insn counter will then be making progress on its own. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* really fix -icount in the iothread casePaolo Bonzini2011-04-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | The correct fix for -icount is to consider the biggest difference between iothread and non-iothread modes. In the traditional model, CPUs run _before_ the iothread calls select (or WaitForMultipleObjects for Win32). In the iothread model, CPUs run while the iothread isn't holding the mutex, i.e. _during_ those same calls. So, the iothread should always block as long as possible to let the CPUs run smoothly---the timeout might as well be infinite---and either the OS or the CPU thread itself will let the iothread know when something happens. At this point, the iothread wakes up and interrupts the CPU. This is exactly the approach that this patch takes: when cpu_exec_all returns in -icount mode, and it is because a vm_clock deadline has been met, it wakes up the iothread to process the timers. This is really the "bulk" of fixing icount. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* Merge remote branch 'qemu-kvm/uq/master' into stagingAnthony Liguori2011-03-211-72/+54
|\
| * Expose thread_id in info cpusJan Kiszka2011-03-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | Based on patch by Glauber Costa: To allow management applications like libvirt to apply CPU affinities to the VCPU threads, expose their ID via info cpus. This patch provides the pre-existing and used interface from qemu-kvm. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * kvm: Add in-kernel irqchip awareness to cpu_thread_is_idleJan Kiszka2011-03-161-1/+2
| | | | | | | | | | | | | | | | With in-kernel irqchip support enabled, the vcpu threads sleep in kernel space while halted. Account for this difference in cpu_thread_is_idle. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * x86: Unbreak TCG support for hardware breakpointsJan Kiszka2011-03-151-24/+3
| | | | | | | | | | | | | | | | | | | | | | Commit 83f338f73e broke x86 hardware breakpoint emulation by moving the debug exception handling out of cpu_exec. Fix this by moving all TCG related bits back, only leaving the generic guest debugging parts in cpus.c. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> CC: TeLeMan <geleman@gmail.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
| * Implement qemu_kvm_eat_signals only for CONFIG_LINUXJan Kiszka2011-03-151-47/+47
| | | | | | | | | | | | | | | | | | | | qemu_kvm_eat_signals requires POSIX support with realtime extensions for sigtimedwait. Not all our target platforms provide this. Moreover, undefined sigbus_reraise was referenced on non-Linux as well. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> CC: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* | Fix conversions from pointer to int and vice versaStefan Weil2011-03-201-4/+4
|/ | | | | | | | | | | | Here the int values fds[0], sigfd, s, sock and fd are converted to 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 *). Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* add Win32 IPI servicePaolo Bonzini2011-03-131-3/+22
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* protect qemu_cpu_kick_self for Win32Paolo Bonzini2011-03-131-0/+4
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* provide dummy signal init functions for win32Paolo Bonzini2011-03-131-70/+73
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* merge all signal initialization with qemu_signalfd_init, renamePaolo Bonzini2011-03-131-51/+36
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* iothread stops the vcpu thread via IPIPaolo Bonzini2011-03-131-0/+2
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* do not use timedwait on qemu_cpu_condPaolo Bonzini2011-03-131-2/+2
| | | | | | | | Whenever env->created becomes true, qemu_cpu_cond is signaled by {kvm,tcg}_cpu_thread_fn. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
OpenPOWER on IntegriCloud