summaryrefslogtreecommitdiff
path: root/vl.c
AgeCommit message (Collapse)AuthorFilesLines
2009-10-05Enable host-clock-based RTCJan Kiszka1-1/+16
Switch RTC emulations to the new host_clock instead of vm_clock by default. This has the advantage that the emulated RTC will follow automatically the host time while it might be tuned via NTP. vm_clock can still be selected by passing '-rtc clock=vm' on the command line. Note that some RTC emulations (at least M48T59) already use the host time unconditionally while others (namely MC146818) do not. This patch introduces the required infrastructure for selecting the base clock but only converts MC146818 for now. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Refactor RTC command line switchesJan Kiszka1-35/+76
Deprecate -localtime, -setdate and -rtc-td-hack in favor of a new unified command line switch: -rtc [base=utc|localtime|date][,driftfix=none|slew] Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Introduce QEMU_CLOCK_HOSTJan Kiszka1-11/+35
Despite its name QEMU_CLOCK_REALTIME is (normally) not using CLOCK_REALTIME / the host system time as base. In order to allow also non-trivial RTC emulations (MC146818) to follow the host time instead of the virtual guest time, introduce the new clock type QEMU_CLOCK_HOST. It is unconditionally based on CLOCK_REALTIME, thus will follow system time changes of the host. The only limitation of its current implementation is that pending host_clock timers may not fire early if the host time is pushed forward beyond their expiry. So far no urgent need to overcome this limitation was identified, so it's left as simple as it is (expiry on next alarm timer tick). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05win32: Drop dead dyntick timer codeJan Kiszka1-5/+1
nearest_delta_us is calculated but not used. Drop it. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Rename QEMU_TIMER_* to QEMU_CLOCK_*Jan Kiszka1-21/+21
These constants select clocks, not timers. And init_timers initializes clocks. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05do proper cpu_self checkGlauber Costa1-2/+7
Currently, our check for qemu_cpu_self only checks if there is a cpu currently in execution (represented by cpu_single_env being set). While this might be okay for tcg, it is certainly not okay for kvm, since multiple cpus might be executing. Instead, I propose we use pthread primitives to test if the caller thread is the same as env->thread. For tcg, it will have the same semantics as before, since all CPUStates will point to the same thread, and we'll only have one in execution at a time. Signed-off-by: Glauber Costa <glommer@mothafucka.localdomain> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-02Fix warning about undefined madvise() on OpenSolarisBlue Swirl1-0/+3
OpenSolaris headers can't export madvise() with a sane set of #defines. For background, see MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for discussion about Solaris header problems. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-10-01Revert "Get rid of _t suffix"Anthony Liguori1-14/+14
In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Get rid of _t suffixmalc1-14/+14
Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
2009-09-27Win32: avoid a warningBlue Swirl1-4/+4
GetLastError() returns a DWORD. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-27vl: Add failure check for SetEventmalc1-1/+5
Signed-off-by: malc <av1474@comtv.ru>
2009-09-27vl: Do not use perror after failed Win32 API callsmalc1-3/+5
Signed-off-by: malc <av1474@comtv.ru>
2009-09-26fix -daemonize with kvmMarcelo Tosatti1-10/+10
Otherwise fork might not inherit state initialized by kvm_init(). Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-09-25Fix coding style issueMark McLoughlin1-1/+1
Replace: if (-1 == foo()) with: if (foo() == -1) While this coding style is not in direct contravention of our currently ratified CODING_STYLE treaty, it could be argued that the Article 3 of the European Convention on Human Rights (prohibiting torture and "inhuman or degrading treatment") reads on the matter. [This commit message was brought to you without humour, as is evidenced by the absence of any emoticons] Signed-off-by: Mark McLoughlin <markmc@redhat.com> Cc: Avi Kivity <avi@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-15support media=cdrom for if=noneGerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-14Revert "Open chr device for all serial ports"Aurelien Jarno1-9/+7
This reverts commit 55338f1dd4648d78ee130d83a92f1059ff1f3887.
2009-09-14Open chr device for all serial portsAurelien Jarno1-7/+9
Now that labels must be unique, the chr devices can't be opened anymore within the serial port code (in case they are not already opened in vl.c), as they end up with the same label. Instead opened so non-assigned one directly in vl.c, with a different label. This make MIPS Malta board emulation working again. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl1-28/+28
Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-11Make get_ticks_per_sec() a static inlineAnthony Liguori1-14/+6
ticks_per_sec is a constant. There's no need to store it as a variable as it never changes since our time is based on units. Convert get_ticks_per_sec() to a static inline and move the constant into qemu-timer.h. Remove all references to QEMU_TIMER_BASE so that we consistently use this interface. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11timers: move them to VMStateJuan Quintela1-22/+12
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11timers: Createt TimersState and put all timers state thereJuan Quintela1-31/+39
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11Unexport ticks_per_sec variable. Create get_ticks_per_sec() functionJuan Quintela1-5/+10
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11timers: remove useless checkJuan Quintela1-6/+0
loadvm_state is called from: vl.c during startup, vmstart() is called after finishing loading. The other caller do_loadvm() does the call after a vm_stop(). At both places where we can be saving state we are stoped a few lines before Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11ram: Remove SaveVM Version 2 supportJuan Quintela1-93/+1
It don't work. It fails in this check if (qemu_get_be32(f) != last_ram_offset) With 512MB of ram, values were for me: v = 20c00000 last_ram_offset = 20840000 Last time that some code changed that was this one. commit 94a6b54fd6d2d3321066cb4db7abeeb417af9365 Implement dynamic guest ram allocation. (I.e. it has been broken since at least April) Going back to the previous commit, ram load correctly, but vga screen gets corrupted and ide don't load correctly. At this point I decide that removing support is the only viable thing. The last user of the ram_compress_* were RAM_SAVE_FLAG_FULL flag, but that flag was never ever been stored in an image. Mark the flag obsolete and remove the functions. Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11ram: remove support for loading v1Juan Quintela1-42/+0
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11switch chardev to QemuOpts: infrastructure, null deviceGerd Hoffmann1-0/+10
start switching chardevs to QemuOpts. This patch adds the infrastructure and converts the null device. The patch brings two new functions: qemu_chr_open_opts() same as qemu_chr_open(), but uses QemuOpts instead of a option char string. qemu_chr_parse_compat() accepts a traditional chardev option string, returns the corresponding QemuOpts instance, to handle backward compatibility. The patch also adds a new -chardev switch which can be used to create named+unconnected chardevs, like this: -chardev null,id=test This uses the new qemu_chr_open_opts. Thus with this patch alone only the null device works. The other devices will follow ... Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-11Revert "don't call cpu_sychronize_state from reset handlers"Anthony Liguori1-6/+1
This reverts commit 733318ea9c6d846a6a047b87619e7d9d6e9707d1. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09don't call cpu_sychronize_state from reset handlersGlauber Costa1-1/+6
Doing this will make the vcpu ioctl be issued from the I/O thread, instead of cpu thread. The correct behaviour is to call it from within the cpu thread, as soon as we are ready to go. Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qemu-kvm: fix segfault when running kvm without /dev/kvm, falling back to ↵Dustin Kirkland1-10/+10
non-accelerated mode qemu-kvm: fix segfault when running kvm without /dev/kvm, falling back to non-accelerated mode We're seeing segfaults on systems without access to /dev/kvm. It looks like the global kvm_allowed is being set just a little too late in vl.c. This patch moves the kvm initialization a bit higher in the vl.c main, just after options processing, and solves the segfaults. We're carrying this patch in Ubuntu 9.10 Alpha. Please apply upstream, or advise if and why this might not be the optimal solution. Signed-off-by: Dustin Kirkland <kirkland@canonical.com> Move the kvm_init() call a bit higher to fix a segfault when /dev/kvm is not available. The kvm_allowed global needs to be set correctly a little earlier. Signed-off-by: Dustin Kirkland <kirkland@canonical.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09mv strdup to qemu_strdup in vl.cJean-Christophe DUBOIS1-3/+3
There are few places in vl.c not using the qemu version of malloc/free/strdup. Fix it. Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09fix vl.c compilation if CONFIG_KVM is not definedJean-Christophe DUBOIS1-1/+2
vl.c will not link if CONFIG_KVM is not defined. This patch fixes the problem. Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09fix PATH_MAX conditional compilationJean-Christophe DUBOIS1-9/+2
PATH_MAX is used elsewhere in the qemu source tree without protection. In addtion the actual code would not compile if PATH_MAX is not defined Last the free() call is wrong as p is not malloc()ed. Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qdev/usb: make qemu aware of usb busses.Gerd Hoffmann1-118/+36
Move usb code from vl.c to usb-bus.c and make it use the new data structures added by qdev conversion. qemu usb core should be able to handle multiple USB busses just fine now (untested though). Kill some usb_*_init() legacy functions, use usb_create_simple() instead. Kill some FIXMEs added by the first qdev/usb patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qdev/usb: add usb bus support to qdev, convert drivers.Gerd Hoffmann1-2/+2
* Add USBBus. * Add USBDeviceInfo, move device callbacks here. * Add usb-qdev helper functions. * Switch drivers to qdev. TODO: * make the rest of qemu aware of usb busses and kill the FIXMEs added by this patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09allow passing null machine pointer to drive_init().Gerd Hoffmann1-1/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-06Checks in select_soundhw were never intended to accept abbreviationsmalc1-1/+1
Signed-off-by: malc <av1474@comtv.ru>
2009-09-04monitor: Port handler_1 to use QDictLuiz Capitulino1-5/+6
This commit ports command handlers that receive one argument to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04Support for multiple -monitor devicesJan Kiszka1-16/+46
Rebased version of Anthony's patch: Allow to specify more than one monitor terminal via the -monitor command line switch. This is particularly useful when libvirt or some other management tool already occupies the primary monitor but you need another one for debugging. The current clumsy workaround is to multiplex such additional terminals over a qemu character device (e.g. -serial mon:<device>). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04do not issue ioctl from within the io threadGlauber Costa1-1/+1
According to Documentation/kvm/api.txt, (and well, to common sense), we should not be calling vcpu ioctls from within the iothread. Since vcpu initialization issues a vcpu ioctl, move it a little bit further in time to prevent it. Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04Delay sighandler_setup()Juan Quintela1-5/+5
If we are using --serial telnet:0:5555,server or similar, ^C will not kill qemu. We need to first connect using telnet, and the the ^C takes effect. Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27switch balloon initialization to -device.Gerd Hoffmann1-16/+18
With that patch applied "-balloon virtio,args" becomes a shortcut for "-device virtio-balloon-pci,args". Side effects: - ballon device gains support for id=<tag>. - ballon device is off by default now. - initialization order changes, which may in different pci slot assignment depending on the VM configuration. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27add qemu_error() + friendsGerd Hoffmann1-0/+1
This patch adds some functions for error reporting to address the problem that error messages should be routed to different destinations depending on the context of the caller, i.e. monitor command errors should go to the monitor, command line errors to stderr. qemu_error() is a printf-like function to report errors. qemu_errors_to_file() and qemu_errors_to_mon() switch the destination for the error message to the specified file or monitor. When setting a new destination the old one will be kept. One can switch back using qemu_errors_to_previous(). i.e. it works like a stack. main() calls qemu_errors_to_file(stderr), so errors go to stderr by default. monitor callbacks are wrapped into qemu_errors_to_mon() + qemu_errors_to_previous(), so any errors triggered by monitor commands will go to the monitor. Each thread has its own error message destination. qemu-kvm probably should add a qemu_errors_to_file(stderr) call to the i/o-thread initialization code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27qdev: convert watchdogsMarkus Armbruster1-5/+13
-watchdog NAME is now equivalent to -device NAME, except it treats option argument '?' specially, and supports only one watchdog. A side effect is that a device created with -watchdog may now receive a different PCI address. i6300esb is now available on any machine with a PCI bus, not just PCs. ib700 is still PC only, but that could be changed easily. The only remaining use of struct WatchdogTimerModel and watchdog_add_model() is supporting '-watchdog ?'. Should be replaced by searching device_info_list for watchdog devices when we can identify them there. Also fixes ib700 not to use vm_clock before it is initialized: in wdt_ib700_init(), called from register_watchdogs(), which runs before init_timers(). The bug made ib700_write_enable_reg() crash in qemu_del_timer(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27Move watchdog, watchdog_action, give them internal linkageMarkus Armbruster1-2/+0
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27raw-posix: add Linux native AIO supportChristoph Hellwig1-0/+22
Now that do have a nicer interface to work against we can add Linux native AIO support. It's an extremly thing layer just setting up an iocb for the io_submit system call in the submission path, and registering an eventfd with the qemu poll handler to do complete the iocbs directly from there. This started out based on Anthony's earlier AIO patch, but after estimated 42,000 rewrites and just as many build system changes there's not much left of it. To enable native kernel aio use the aio=native sub-command on the drive command line. I have also added an option to qemu-io to test the aio support without needing a guest. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27make load_vmstate() return errorsJuan Quintela1-2/+5
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27split do_loadvm() into do_loadvm() and load_vmstate()Juan Quintela1-1/+1
do_loadvm() is now called from the monitor. load_vmstate() is called by do_loadvm() and when -loadvm command line is used. Command line don't have to play games with vmstop()/vmstart() Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27extend -smp parsing to include cores= and threads= optionsAndre Przywara1-9/+57
For injecting multi-core and multi-threading CPU topology into guests extend the -smp syntax to accommodate cores and threads specification. Syntax: -smp smp_value[,cores=nr_cores][,threads=nr_threads]\ [,socket=nr_sockets][,maxcpus=max_cpus] smp_value is the legacy value specifying the total number of vCPUs for the guest. If you specify one of cores, threads or sockets this value can be omitted. Missing values will be computed to fulfill: smp_value = nr_cores * nr_threads * nr_sockets where it will favour sockets over cores over threads (to mimic the current behavior, which will only inject multiple sockets.) So -smp 4,threads=2 will inject two sockets with 2 threads each, -smp cores=4 is an abbreviation for -smp 4,cores=4,threads=1,sockets=1. If max_cpus (the number of hotpluggable CPUs) is omitted, it will be set to smp_value. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-24Unbreak large mem support by removing kqemuAnthony Liguori1-51/+2
kqemu introduces a number of restrictions on the i386 target. The worst is that it prevents large memory from working in the default build. Furthermore, kqemu is fundamentally flawed in a number of ways. It relies on the TSC as a time source which will not be reliable on a multiple processor system in userspace. Since most modern processors are multicore, this severely limits the utility of kqemu. kvm is a viable alternative for people looking to accelerate qemu and has the benefit of being supported by the upstream Linux kernel. If someone can implement work arounds to remove the restrictions introduced by kqemu, I'm happy to avoid and/or revert this patch. N.B. kqemu will still function in the 0.11 series but this patch removes it from the 0.12 series. Paul, please Ack or Nack this patch. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-24QEMU set irq0override in fw_cfgJes Sorensen1-0/+1
Hi, After discussing the issue with Avi, Gleb and a couple others on irq, we came to the conclusion that it is preferred to have QEMU request features from the BIOS, rather than notifying the BIOS that it is running on QEMU or KVM. This way memory ranges can change etc. and an older BIOS will continue to work on newer QEMU if it receives the info as a fw_cfg value. This one also matches what qemu-kvm does for irq0override, except I haven't made it configurable. I leave that as an exercise for whoever would be interested in switching off irq0override. Thanks, Jes Set irq0 override in fw_cfg, informing the BIOS that QEMU expects override on irq0. This matches qemu-kvm, and will help sharing a single BIOS binary. Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>