Paolo Bonzini [Sun, 18 Dec 2011 16:05:09 +0000 (17:05 +0100)]
qom: introduce get/set methods for Property
This patch adds a visitor interface to Property. This way, QOM will be
able to expose Properties that access a fixed field in a struct without
exposing also the everything-is-a-string "feature" of qdev properties.
Whenever the printed representation in both QOM and qdev (which is
typically the case for device backends), parse/print code can be reused
via get_generic/set_generic. Dually, whenever multiple PropertyInfos
have the same representation in both the struct and the visitors the
code can be reused (for example among all of int32/uint32/hex32).
Paolo Bonzini [Sun, 18 Dec 2011 16:05:06 +0000 (17:05 +0100)]
qom: push permission checks up into qdev_property_add_legacy
qdev_property_get and qdev_property_set can generate permission
denied errors themselves. Do not duplicate this functionality in
qdev_get/set_legacy_property, and clean up excessive indentation.
Paolo Bonzini [Sun, 18 Dec 2011 16:05:04 +0000 (17:05 +0100)]
qapi: protect against NULL QObject in qmp_input_get_object
A NULL qobj can occur when a parameter is fetched via qdict_get, but
the parameter is not in the command. By returning NULL, the caller can
choose whether to raise a missing parameter error, an invalid parameter
type error, or use a default value. For example, qom-set could can
use this to reset a property to its default value, though at this time
it will fail with "Invalid parameter type". In any case, anything is
better than crashing!
Michael Ellerman [Mon, 19 Dec 2011 06:19:31 +0000 (17:19 +1100)]
vl.c: In qemu -h output, only print options for the arch we are running as
Only print options in the help output that are accepted by our arch.
This is less confusing for users and also for other programs that
consume the help output.
The options affected are:
-g and -prom-env only displayed on PPC or SPARC
-win2k-hack, -rtc-td-hack, -no-fd-bootchk, -no-acpi, -no-hpet,
-acpitable, -smbios only displayed on i386
-semihosting only displayed on ARM, M68K or XTENSA
Michael Ellerman [Mon, 19 Dec 2011 06:19:30 +0000 (17:19 +1100)]
vl.c: Move option generation logic into a wrapper file
In vl.c and qemu-options.h we define macros and include qemu-options.def
in order to generate different content. Move the bulk of the def'ing and
undef'ing into a wrapper, this will make it cleaner when we add another
macro in the next patch.
AFAICS undefining GEN_DOCS services no purpose, but I've left it for now.
Peter Maydell [Thu, 15 Dec 2011 18:58:26 +0000 (18:58 +0000)]
stellaris: Calculate system clock period on reset
Calculate the system clock period on reset; otherwise it remains
set to the default value of zero and attempting to use it provokes
a hang. This is one of the issues noted in LP:696094.
Remove some dependency rules which aren't necessary (the automatically
generated .d files cover all these). These were leftovers from dyngen
days, when the object files also had a dependency on some generated
files.
Alex Rozenman [Tue, 13 Dec 2011 10:52:08 +0000 (12:52 +0200)]
phys_page_find_alloc: Use correct initial region_offset.
This fixes a common bug with initial region_offset value.
Usually, the pages are re-assigned afterwards, so the bug
has a very small effect on regular QEMU use flows.
Michael Roth [Thu, 8 Dec 2011 03:48:07 +0000 (21:48 -0600)]
network scripts: don't block SIGCHLD before forking
This patch fixes a bug where child processes of launch_script() can
misbehave due to SIGCHLD being blocked. In the case of `sudo`, this
causes a permanent hang.
Previously a SIGCHLD handler was added to reap fork_exec()'d zombie
processes by calling waitpid(-1, ...). This required other
fork()/waitpid() callers to temporarilly block SIGCHILD to avoid
having the final wait status being intercepted by the SIGCHLD
handler:
Peter Maydell [Thu, 15 Dec 2011 13:33:54 +0000 (13:33 +0000)]
HACKING: clarify allocation/free recommendations
Clarify the allocation/free recommendations; this is mostly
just tidying up following the global-search-and-replace done
with the conversion to the GLib g_malloc and friends.
Stefan Hajnoczi [Thu, 15 Dec 2011 10:05:18 +0000 (10:05 +0000)]
usb: fix usb_qdev_init() error handling again
Commit f462141f18ffdd75847f6459ef83d90b831d12c0 introduced clean up code
when usb_qdev_init() fails. Unfortunately it calls .handle_destroy()
when .init() was never invoked or failed. This can lead to crashes when
.handle_destroy() tries to clean up things that were never initialized.
This patch is careful to undo only those steps that completed along the
usb_qdev_init() code path. It's not as pretty as the unified error
handling in f462141f18ffdd75847f6459ef83d90b831d12c0 but it's necessary.
Andreas Färber [Wed, 30 Nov 2011 15:26:21 +0000 (16:26 +0100)]
exec.c: Fix subpage memory access to RAM MemoryRegion
Commit 95c318f5e1f88d7e5bcc6deac17330fd4806a2d3 (Fix segfault in mmio
subpage handling code.) prevented a segfault by making all subpage
registrations over an existing memory page perform an unassigned access.
Symptoms were writes not taking effect and reads returning zero.
Very small page sizes are not currently supported either,
so subpage memory areas cannot fully be avoided.
Therefore change the previous fix to use a new IO_MEM_SUBPAGE_RAM
instead of IO_MEM_UNASSIGNED. Suggested by Avi.
vl.c: Print the actual program name in help output
In help() we do what boils down to:
printf("%s", "qemu");
This seems to be an artifact of be995c27640a82c7056b6f53d02ec823570114e5
("removed unused code"), which removed some ifdef'ery that used to print
a different name depending on CONFIG_SOFTMMU.
Instead print the actual program name, originally from argv[0].
Paolo Bonzini [Tue, 13 Dec 2011 12:43:52 +0000 (13:43 +0100)]
fix win32 build
On Windows, cpus.c needs access to the hThread. Add a Windows-specific
function to grab it. This requires changing the CPU threads to
joinable. There is no substantial change because the threads run
in an infinite loop.
Anthony Liguori [Mon, 12 Dec 2011 20:29:36 +0000 (14:29 -0600)]
qdev: add explicitly named devices to the root complex
We first add a 'peripheral' container to the root device that we add user
created devices to. This provides all user created devices with a unique and
isolated namespace.
Anthony Liguori [Mon, 12 Dec 2011 20:29:35 +0000 (14:29 -0600)]
qom: qom_{get, set} monitor commands (v2)
This allows clients to read and write device model properties through QMP. QAPI
doesn't support Visitor types yet and these commands are special in that they
don't work with fixed types.
I've added a documentation stub to qapi-schema.json so we can keep consistency
there.
Anthony Liguori [Mon, 12 Dec 2011 20:29:32 +0000 (14:29 -0600)]
qom: add link properties (v2)
Links represent an ephemeral relationship between devices. They are meant to
replace the qdev concept of busses by allowing more informal relationships
between devices.
Links are fairly limited in their usefulness without implementing QOM-style
subclassing and interfaces.
Anthony Liguori [Mon, 12 Dec 2011 20:29:30 +0000 (14:29 -0600)]
qdev: provide a path resolution (v2)
There are two types of supported paths--absolute paths and partial paths.
Absolute paths are derived from the root device and can follow child<> or
link<> properties. Since they can follow link<> properties, they can be
arbitrarily long. Absolute paths look like absolute filenames and are prefixed
with a leading slash.
Partial paths are look like relative filenames. They do not begin with a
prefix. The matching rules for partial paths are subtle but designed to make
specifying devices easy. At each level of the composition tree, the partial
path is matched as an absolute path. The first match is not returned. At
least two matches are searched for. A successful result is only returned if
only one match is founded. If more than one match is found, a flag is returned
to indicate that the match was ambiguous.
At the end of the day, partial path support means that if you create a device
called 'ide0', you can just say 'ide0' as the path name and it will Just Work.
If we internally create a device called 'i440fx', you can just say 'i440fx' and
it will Just Work and long as you don't do anything silly.
A management tool should probably always use absolute paths since then they
don't have to deal with the possibility of ambiguity.
Anthony Liguori [Mon, 12 Dec 2011 20:29:28 +0000 (14:29 -0600)]
qom: introduce root device
This is based on Jan's suggestion for how to do unique naming. The root device
is the root of composition. All devices are reachable via child<> links from
this device.
Anthony Liguori [Mon, 12 Dec 2011 20:29:27 +0000 (14:29 -0600)]
qom: register legacy properties as new style properties (v2)
Expose all legacy properties through the new QOM property mechanism. The qdev
property types are exposed through the 'legacy<>' namespace. They are always
visited as strings since they do their own string parsing.
Anthony Liguori [Mon, 12 Dec 2011 20:29:26 +0000 (14:29 -0600)]
qom: add new dynamic property infrastructure based on Visitors (v2)
qdev properties are settable only during construction and static to classes.
This isn't flexible enough for QOM.
This patch introduces a property interface for qdev that provides dynamic
properties that are tied to objects, instead of classes. These properties are
Visitor based instead of string based too.
Paolo Bonzini [Fri, 25 Nov 2011 11:06:22 +0000 (12:06 +0100)]
qiov: prevent double free or use-after-free
qemu_iovec_destroy does not clear the QEMUIOVector fully, and the data
could thus be used after free or freed again. While I do not know any
example in the tree, I observed this using virtio-scsi (and SCSI
scatter/gather) when canceling DMA requests.
Avi Kivity [Mon, 5 Dec 2011 17:20:12 +0000 (19:20 +0200)]
coroutine: switch per-thread free pool to a global pool
ucontext-based coroutines use a free pool to reduce allocations and
deallocations of coroutine objects. The pool is per-thread, presumably
to improve locality. However, as coroutines are usually allocated in
a vcpu thread and freed in the I/O thread, the pool accounting gets
screwed up and we end allocating and freeing a coroutine for every I/O
request. This is expensive since large objects are allocated via the
kernel, and are not cached by the C runtime.
Fix by switching to a global pool. This is safe since we're protected
by the global mutex.
Kevin Wolf [Wed, 7 Dec 2011 11:42:10 +0000 (12:42 +0100)]
qemu-img rebase: Fix for undersized backing files
Backing files may be smaller than the corresponding COW file. When
reading directly from the backing file, qemu-img rebase must consider
this and assume zero sectors after the end of backing files.
Paolo Bonzini [Mon, 14 Nov 2011 16:50:54 +0000 (17:50 +0100)]
block: avoid useless checks on acb->bh
Coverity is confused by this "if" and reports leaks on acb->bh.
The bottom half is always deleted before releasing the AIOCB,
in either bdrv_aio_cancel_em or bdrv_aio_bh_cb.