summaryrefslogtreecommitdiff
path: root/vl.c
AgeCommit message (Collapse)AuthorFilesLines
2013-02-11vl: Exit unsuccessfully on option argument syntax errorMarkus Armbruster1-4/+12
We exit successfully after reporting syntax error for argument of --sandbox and --add-fd. We continue undaunted after reporting it for argument of -boot, --option-rom and --object. Change all five to exit unsuccessfully, like the other options. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 1360354939-10994-7-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-11vl: Drop redundant "parse error" reportsMarkus Armbruster1-4/+0
qemu_opts_parse() reports the error already, and in a much more useful way. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 1360354939-10994-6-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: validate -numa "cpus" parameter properlyEduardo Habkost1-5/+27
- Accept empty strings without aborting - Use parse_uint*() to parse numbers - Abort if anything except '-' or end-of-string is found after the first number. - Check for endvalue < value Also change the MAX_CPUMASK_BITS warning message from "A max of %d CPUs are supported in a guest" to "qemu: NUMA: A max of %d VCPUs are supported". Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: Extract -numa "cpus" parsing to separate functionEduardo Habkost1-18/+23
This will make it easier to refactor that code later. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: Use parse_uint_full() for NUMA nodeidEduardo Habkost1-1/+4
This should catch many kinds of errors that the current code wasn't checking for: - Values that can't be parsed as a number - Negative values - Overflow - Empty string Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: numa_add(): Validate nodeid before using itEduardo Habkost1-1/+6
Without this check, QEMU will corrupt memory if a too-large nodeid is provided in the command-line. e.g.: -numa node,mem=...,cpus=...,nodeid=65 This changes nodenr to unsigned long long, to avoid integer conversion issues when converting the strtoull() result to int. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: Check for NUMA node limit inside numa_add()Eduardo Habkost1-4/+6
Instead of checking the limit before calling numa_add(), check the limit only when we already know we're going to add a new node. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: Abort on unknown -numa option typeEduardo Habkost1-0/+3
Abort in case an invalid -numa option is provided, instead of silently ignoring it. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-04vl.c: Fix off-by-one bug when handling "-numa node" argumentEduardo Habkost1-1/+4
The numa_add() code was unconditionally adding 1 to the get_opt_name() return value, making it point after the end of the string if no ',' separator is present. Example of weird behavior caused by the bug: $ qemu-img create -f qcow2 this-file-image-has,cpus=5,mem=1000,in-its-name.qcow2 5G Formatting 'this-file-image-has,cpus=5,mem=1000,in-its-name.qcow2', fmt=qcow2 size=5368709120 encryption=off cluster_size=65536 $ ./x86_64-softmmu/qemu-system-x86_64 -S -monitor stdio -numa node 'this-file-image-has,cpus=5,mem=1000,in-its-name.qcow2' QEMU 1.3.50 monitor - type 'help' for more information (qemu) info numa 1 nodes node 0 cpus: 0 node 0 size: 1000 MB (qemu) This changes the code to nove the pointer only if ',' is found. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-01qdev: drop extra references at creation timePaolo Bonzini1-0/+1
qdev_free and qbus_free have to do unparent+unref, because nobody else drops the initial reference (the one included by object_initialize) before them. For device_init_func and do_device_add, this is trivially correct, since the DeviceState goes out of scope. For qdev_create, qdev_try_create and qbus_init, it is a bit more tricky. What we are doing here is just assuming that the caller knows what it's doing, and won't call qdev_free/qbus_free while the device is still there. This is a pretty reasonable assumption and (behind the scenes) is also what GObject/GTK does. GTK actually has a "floating reference" that goes away as soon as the caller does gtk_container_add or something like that, but in the end qbus_init and qdev_try_create are already adding the new object to its qdev parent! So in the end the two solutions are the same. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-01accel: change {xen, kvm, tcg, qtest}_allowed from int to boolliguang1-6/+6
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-01vl: correct error message when fail to init kvmliguang1-5/+7
command: qemu-system-x86_64 -hda disk.img -smp 32 --enable-kvm error: Number of SMP cpus requested (32) exceeds max cpus supported by KVM (16) failed to initialize KVM: Invalid argument No accelerator found! well, it did find kvm, but failed to init, so message "No accelerator found!" is confusing, this commit remove the confusing error message. Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-01vl: skip init accelerator if it's not availableliguang1-8/+8
Signed-off-by: liguang <lig.fnst@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-29sclpconsole: Don't instantiate sclpconsole with -nodefaultsChristian Borntraeger1-0/+1
libvirt specifies nodefaults and creates an sclp console with special parameters. Let qemu follow nodefaults and don't create an sclp console if nodefaults is specified. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-29s390: Add default support for SCLP consoleAlexander Graf1-0/+51
The current s390 machine uses the virtio console as default console, but this doesn't mean that we always want to keep it that way for new machines. This patch introduces a way for a machine type to specify that it wants the default console to be an SCLP console, which is a lot closer to what real hardware does. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Andreas Färber <afaerber@suse.de>
2013-01-26fw_cfg: Splash image loader can overrun a stack variable, fixMarkus Armbruster1-1/+1
read_splashfile() passes the address of an int variable as size_t * parameter to g_file_get_contents(), with a cast to gag the compiler. No problem on machines where sizeof(size_t) == sizeof(int). Happens to work on my x86_64 box (64 bit little endian): the least significant 32 bits of the file size end up in the right place (caller's variable file_size), and the most significant 32 bits clobber a place that gets assigned to before its next use (caller's variable file_type). I'd expect it to break on a 64 bit big-endian box. Fix up the variable types and drop the problematic cast. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19vl: Use size_t for sizes in get_boot_devices_list()Markus Armbruster1-3/+3
Code mixes uint32_t, int and size_t. Very unlikely to go wrong in practice, but clean it up anyway. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-17HMP: add QDict to info callback handlerWenchao Xia1-1/+1
This patch change all info call back function to take additional QDict * parameter, which allow those command take parameter. Now it is set to NULL at default case. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-16chardev: add error reporting for qemu_chr_new_from_optsGerd Hoffmann1-3/+6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-01-15Make default boot order machine specificAvik Sil1-2/+4
This patch makes default boot order machine specific instead of set globally. The default boot order can be set per machine in QEMUMachine boot_order. This also allows a machine to receive a NULL boot order when -boot isn't used and take an appropriate action accordingly. This helps machine boots from the devices as set in guest's non-volatile memory location in case no boot order is provided by the user. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-12qemu-option: move standard option definitions out of qemu-config.cPaolo Bonzini1-0/+205
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-01-11Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori1-6/+3
* stefanha/trivial-patches: hw/pc.c: Fix converting of ioport_register* to MemoryRegion Replace remaining gmtime, localtime by gmtime_r, localtime_r savevm: Remove MinGW specific code which is no longer needed qga/channel-posix.c: Explicitly include string.h configure: Fix comment (copy+paste bug) readline: avoid memcpy() of overlapping regions Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-11Replace remaining gmtime, localtime by gmtime_r, localtime_rStefan Weil1-6/+3
This allows removing of MinGW specific code and improves reentrancy for POSIX hosts. [Removed unused ret variable in qemu_get_timedate() to fix warning: vl.c: In function ‘qemu_get_timedate’: vl.c:451:16: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable] -- Stefan Hajnoczi] Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-07net: clean up network at qemu process terminationAmos Kong1-1/+3
We don't clean up network if fails to parse "-device" parameters without calling net_cleanup(). I touch a problem, the tap device which is created by qemu-ifup script could not be removed by qemu-ifdown script. Some similar problems also exist in vl.c In this patch, if network initialization successes, a cleanup function will be registered to be called at qemu process termination. Signed-off-by: Amos Kong <akong@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-02disallow -daemonize usage of stdio (curses display, -nographic, -serial ↵Michael Tokarev1-3/+25
stdio etc) Curses display requires stdin/out to stay on the terminal, so -daemonize makes no sense in this case. Instead of leaving display uninitialized like is done since 995ee2bf469de6bb, explicitly detect this case earlier and error out. -nographic can actually be used with -daemonize, by redirecting everything to a null device, but the problem is that according to documentation and historical behavour, -nographic redirects guest ports to stdin/out, which, again, makes no sense in case of -daemonize. Since -nographic is a legacy option, don't bother fixing this case (to allow -nographic and -daemonize by redirecting guest ports to null instead of stdin/out in this case), but disallow it completely instead, to stop garbling host terminal. If no display display needed and user wants to use -nographic, the right way to go is to use -serial null -parallel null -monitor none -display none -vga none instead of -nographic. Also prevent the same issue -- it was possible to get garbled host tty after -nographic -daemonize and it is still possible to have it by using -serial stdio -daemonize Fix this by disallowing opening stdio chardev when -daemonize is specified. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19softmmu: move remaining include files to include/ subdirectoriesPaolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-8/+8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-9/+9
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19migration: move include files to include/migration/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19monitor: move include files to include/monitor/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19exec: move include files to include/exec/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19qapi: move include files to include/qobject/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19ui: move files to ui/ and include/ui/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19net: reorganize headersPaolo Bonzini1-1/+1
Move public headers to include/net, and leave private headers in net/. Put the virtio headers in include/net/tap.h, removing the multiple copies that existed. Leave include/net/tap.h as the interface for NICs, and net/tap_int.h as the interface for OS-specific parts of the tap backend. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19build: kill libdis, move disassemblers to disas/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-11use qemu_opts_create_nofailDong Xu Wang1-7/+5
We will use qemu_opts_create_nofail function, it can make code more readable. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-12-11block: simplify default_driveChristian Borntraeger1-14/+6
Markus Armbruster pointed out that there is only one caller to default_drive with IF_DEFAULT as a type. Lets get rid of the block_default_type parameter and adopt the caller to do the right thing (asking the machine struct). Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-12-11Support default block interfaces per QEMUMachineChristian Borntraeger1-9/+12
There are QEMUMachines that have neither IF_IDE nor IF_SCSI as a default/standard interface to their block devices / drives. Therefore, this patch introduces a new field default_block_type per QEMUMachine struct. The prior use_scsi field becomes thereby obsolete and is replaced through .default_block_type = IF_SCSI. This patch also changes the default for s390x to IF_VIRTIO and removes an early hack that converts IF_IDE drives. Other parties have already claimed interest (e.g. IF_SD for exynos) To create a sane default, for machines that dont specify a default_block_type, this patch makes IF_IDE = 0 and IF_NONE = 1. I checked all users of IF_NONE (blockdev.c and ww/device-hotplug.c) as well as IF_IDE and it seems that it is ok to change the defines - in other words, I found no obvious (to me) assumption in the code regarding IF_NONE==0. IF_NONE is only set if there is an explicit if=none. Without if=* the interface becomes IF_DEFAULT. I would suggest to have some additional care, e.g. by letting this patch sit some days in the block tree. Based on an initial patch from Einar Lueck <elelueck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> CC: Igor Mitsyanko <i.mitsyanko@samsung.com> CC: Markus Armbruster <armbru@redhat.com> CC: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Alexander Graf <agraf@suse.de> Acked-by: Igor Mitsyanko <i.mitsyanko@samsung.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-11-26vl.c: Fix broken -usb optionPeter Maydell1-8/+4
Commit 094b287f0b accidentally broke the "-usb" command line option, so it would have no effect if the user had not specified any machine options at that point. (the return value from 'qemu_opts_find(qemu_find_opts("machine"), 0);' is NULL if there are no user specified options, so it is only to be used for looking up an option, not when trying to set one.) Similarly, would '-usbdevice' no longer cause USB to default to enabled. Fix this regression by using the same style of code for forcing the usb=on machine option that we use for other aliases such as '-enable-kvm'. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-16vl: add -object option to create QOM objects from the command lineAnthony Liguori1-0/+56
This will create a new QOM object in the '/objects' path. Note that properties are set in order which allows for simple objects to be initialized entirely with this option and then realized. This option is roughly equivalent to -device but for things that are not devices. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-03Merge branch 'trivial-patches' of git://github.com/stefanha/qemuBlue Swirl1-9/+12
* 'trivial-patches' of git://github.com/stefanha/qemu: pc: Drop redundant test for ROM memory region exec: make some functions static target-ppc: make some functions static ppc: add missing static vnc: add missing static vl.c: add missing static target-sparc: make do_unaligned_access static m68k: Return semihosting errno values correctly cadence_uart: More debug information Conflicts: target-m68k/m68k-semi.c
2012-11-02vl: delay thread initialization after daemonizationPaolo Bonzini1-1/+3
Commit ac4119c (chardev: Use timer instead of bottom-half to postpone open event, 2012-10-12) moved the alarm timer initialization to an earlier point but failed to consider that it depends on qemu_init_main_loop. Later, commit 1c53786 (vl: init main loop earlier, 2012-10-30) fixed this, but left -daemonize in two different ways. First, timers need to be reinitialized after forking. Second, the global mutex was being held by the parent, and thus dropped after forking. The first is now fixed using pthread_atfork. For the second part, make sure that the global mutex is not taken before daemonization, and similarly delay qemu_thread_self. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-02vl: unify calls to init_timer_alarmPaolo Bonzini1-5/+0
init_timer_alarm was being called twice. This is not needed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-01vl.c: add missing staticBlue Swirl1-9/+12
Add missing 'static' qualifiers. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-11-01Merge remote-tracking branch 'kraxel/pixman.v3' into stagingAnthony Liguori1-14/+35
* kraxel/pixman.v3: (22 commits) pixman: drop obsolete fields from DisplaySurface pixman/vnc: remove dead code. pixman/vnc: remove rgb_prepare_row* functions pixman/vnc: use pixman images in vnc. pixman: switch screendump function. vga: stop direct access to DisplaySurface fields. qxl: stop direct access to DisplaySurface fields. console: don't set PixelFormat alpha fields for 32bpp console: make qemu_alloc_display static pixman: add pixman image to DisplaySurface pixman: helper functions pixman: windup in configure & makefiles pixman: add submodule console: remove DisplayAllocator console: remove dpy_gfx_fill vga: fix text mode updating console: init displaychangelisteners on register console: untangle gfx & txt updates console: s/TextConsole/QemuConsole/ console: move set_mouse + cursor_define callbacks ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-01Merge remote-tracking branch 'bonzini/threadpool' into stagingAnthony Liguori1-11/+6
* bonzini/threadpool: (39 commits) raw-win32: implement native asynchronous I/O raw-posix: move linux-aio.c to block/ raw-win32: add emulated AIO support raw-posix: rename raw-posix-aio.h, hide unavailable prototypes raw: merge posix-aio-compat.c into block/raw-posix.c block: switch posix-aio-compat to threadpool threadpool: do not take lock in event_notifier_ready aio: add generic thread-pool facility qemu-thread: add QemuSemaphore linux-aio: use event notifiers aio: clean up now-unused functions main-loop: use aio_notify for qemu_notify_event main-loop: use GSource to poll AIO file descriptors aio: call aio_notify after setting I/O handlers aio: add aio_notify aio: make AioContexts GSources aio: add Win32 implementation aio: prepare for introducing GSource-based dispatch aio: add non-blocking variant of aio_wait aio: test node->deleted before calling io_flush ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-01Merge remote-tracking branch 'qemu-kvm/uq/master' into stagingAnthony Liguori1-0/+33
* qemu-kvm/uq/master: (28 commits) update-linux-headers.sh: Handle new kernel uapi/ directories target-i386: kvm_cpu_fill_host: use GET_SUPPORTED_CPUID target-i386: cpu: make -cpu host/check/enforce code KVM-specific target-i386: make cpu_x86_fill_host() void Emulate qemu-kvms -no-kvm option Issue warning when deprecated -tdf option is used Issue warning when deprecated drive parameter boot=on|off is used Use global properties to emulate -no-kvm-pit-reinjection Issue warning when deprecated -no-kvm-pit is used Use machine options to emulate -no-kvm-irqchip cirrus_vga: allow configurable vram size target-i386: Add missing kvm cpuid feature name i386: cpu: add missing CPUID[EAX=7,ECX=0] flag names i386: kvm: filter CPUID leaf 7 based on GET_SUPPORTED_CPUID, too i386: kvm: reformat filter_features_for_kvm() code i386: kvm: filter CPUID feature words earlier, on cpu.c i386: kvm: mask cpuid_ext4_features bits earlier i386: kvm: mask cpuid_kvm_features earlier i386: kvm: x2apic is not supported without in-kernel irqchip i386: kvm: set CPUID_EXT_TSC_DEADLINE_TIMER on kvm_arch_get_supported_cpuid() ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-01console: init displaychangelisteners on registerGerd Hoffmann1-1/+0
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01console: untangle gfx & txt updatesGerd Hoffmann1-2/+12
Stop abusing displaysurface fields for text mode displays. (bpp = 0, width = cols, height = lines). Add flags to displaystate indicating whenever text mode display (curses) or gfx mode displays (sdl, vnc, ...) are present. Add separate displaychangelistener callbacks for text / gfx mode resize & updates. This allows to enable gfx and txt diplays at the same time and also paves the way for more cleanups in the future. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-11-01console: add unregister_displaychangelistenerGerd Hoffmann1-8/+23
Also change the way the gui_timer is initialized: each time a displaychangelistener is registered or unregistered we'll check whether we need a timer (due to dpy_refresh callback being present) and if so setup a timer, otherwise zap it. This way the gui timer works correctly with displaychangelisteners coming and going. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>