aboutsummaryrefslogtreecommitdiffstats
path: root/vl.c
AgeCommit message (Collapse)AuthorFilesLines
2009-10-06Remove double error message for -device option parsingMark McLoughlin1-3/+1
qemu_opts_parse() gives a suitable error message in all failure cases so we can remove the error message from the caller. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Don't exit() in config_error()Markus Armbruster1-3/+6
Propagating errors up the call chain is tedious. In startup code, we can take a shortcut: terminate the program. This is wrong elsewhere, the monitor in particular. config_error() tries to cater for both customers: it terminates the program unless its mon parameter tells it it's working for the monitor. Its users need to return status anyway (unless passing a null mon argument, which none do), which their users need to check. So this automatic exit buys us exactly nothing useful. Only the dangerous delusion that we can get away without returning status. Some of its users fell for that. Their callers continue executing after failure when working for the monitor. This bites monitor command host_net_add in two places: * net_slirp_init() continues after slirp_hostfwd(), slirp_guestfwd(), or slirp_smb() failed, and may end up reporting success. This happens for "host_net_add user guestfwd=foo": it complains about the invalid guest forwarding rule, then happily creates the user network without guest forwarding. * net_client_init() can't detect slirp_guestfwd() failure, and gets fooled by net_slirp_init() lying about success. Suppresses its "Could not initialize device" message. Add the missing error reporting, make sure errors are checked, and drop the exit() from config_error(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Don't assign a static string to NICInfo::modelMark McLoughlin1-1/+1
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06offer right-ctrl as a grab optionDustin Kirkland1-0/+4
Add support for -ctrl-grab to use the right-ctrl button to grab/release the mouse in SDL. The multi-button ctrl-alt and ctrl-alt-shift grab buttons present an accessibility problem to users who cannot press more than one button at a time. https://bugs.edge.launchpad.net/ubuntu/+source/qemu-kvm/+bug/237635 Signed-off-by: Dustin Kirkland <kirkland@canonical.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Reorganize option rom (+linux kernel) loading.Gerd Hoffmann1-0/+3
This patch adds infrastructure to maintain memory regions which must be restored on reset. That includes roms (vga bios and option roms on pc), but is also used when loading linux kernels directly. Features: - loading files is supported. - passing blobs is supported. - target address range is supported (for optionrom area). - fixed target memory address is supported (linux kernel). New in v2: - writes to ROM are done only at initial boot. - also handle aout and uimage loaders. - drop unused fread_targphys() function. The final memory layout is created once all memory regions are registered. The option roms get addresses assigned and the registered regions are checked against overlaps. Finally all data is copyed to the guest memory. Advantages: (1) Filling memory on initial boot and on reset takes the same code path, making reset more robust. (2) The need to keep track of the option rom load address is gone. (3) Due to (2) option roms can be loaded outside pc_init(). This allows to move the pxe rom loading into the nic drivers for example. Additional bonus: There is a 'info roms' monitor command now. The patch also switches over pc.c and removes the option_rom_setup_reset() and load_option_rom() functions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Improve error reporting on file accessJustin M. Forbes1-10/+10
By making the error reporting include strerror(errno), it gives the user a bit more indication as to why qemu failed. This is particularly important for people running qemu as a non root user. Signed-off-by: Justin M. Forbes <jforbes@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05drive cleanup fixes.Gerd Hoffmann1-11/+5
Changes: * drive_uninit() wants a DriveInfo now. * drive_uninit() also calls bdrv_delete(), so callers don't need to do that. * drive_uninit() calls are moved over to the ->exit() callbacks, destroy_bdrvs() is zapped. * setting bdrv->private is not needed any more as the only user (destroy_bdrvs) is gone. * usb-storage needs no drive_uninit, scsi-disk will handle that. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05qdev hotplug: infrastructure and monitor commands.Gerd Hoffmann1-0/+2
Adds device_add and device_del commands. device_add accepts accepts the same syntax like the -device command line switch. device_del expects a device id. So you should tag your devices with ids if you want to remove them later on, like this: device_add pci-ohci,id=ohci device_del ohci Unplugging via pci_del or usb_del works too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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>