Skip to content

Commit

Permalink
Merge commit 'b195043003d90ea4027ea01cc7a6c974ac915108' into upstream…
Browse files Browse the repository at this point in the history
…-merge

* commit 'b195043003d90ea4027ea01cc7a6c974ac915108': (130 commits)
  vga: convert vga and its derivatives to the memory API
  vmsvga: don't remember pci BAR address in callback any more
  pci: add API to get a BAR's mapped address
  memory: rename PORTIO_END to PORTIO_END_OF_LIST
  Unbreak the build on ppc32
  Fix forcing multicast msgs to loopback on OpenBSD.
  Use mmap to allocate execute memory
  Fix network interface tap backend
  darwin-user: Remove two unused variables
  TCG: fix copy propagation
  Remove unused is_softmmu parameter from cpu_handle_mmu_fault
  Fix handling of conditional branches in delay slot of a conditional branch
  when overriding default tool names don't add cross-prefix
  Reorganize and fix monitor resume after migration
  qdev: Eliminate duplicate reset
  Avoid allocating TCG resources in non-TCG mode
  memory: use signed arithmetic
  memory: synchronize dirty bitmap before unmapping a range
  sdl: Refactor sdl_send_mouse_event
  sdl: Factor out event handlers from sdl_refresh
  ...

Conflicts:
	hw/cirrus_vga.c

Signed-off-by: Avi Kivity <avi@redhat.com>
avikivity committed Aug 10, 2011
2 parents ce967f6 + b195043 commit 145e11e
Showing 156 changed files with 4,868 additions and 2,603 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ qemu-io
qemu-ga
qemu-monitor.texi
QMP/qmp-commands.txt
test-coroutine
.gdbinit
*.a
*.aux
15 changes: 13 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
@@ -143,6 +143,16 @@ L: kvm@vger.kernel.org
S: Supported
F: target-i386/kvm.c

Guest CPU Cores (Xen):
----------------------

X86
M: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
L: xen-devel@lists.xensource.com
S: Supported
F: xen-*
F: */xen*

ARM Machines
------------
Gumstix
@@ -431,9 +441,10 @@ S: Maintained
F: net/

SLIRP
M: qemu-devel@nongnu.org
S: Orphan
M: Jan Kiszka <jan.kiszka@siemens.com>
S: Maintained
F: slirp/
T: git://git.kiszka.org/qemu.git queues/slirp

Usermode Emulation
------------------
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trac
qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@")

check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o: $(GENERATED_HEADERS)
check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o: $(GENERATED_HEADERS)

CHECK_PROG_DEPS = qemu-malloc.o $(oslib-obj-y) $(trace-obj-y) qemu-tool.o

@@ -161,6 +161,7 @@ check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(C
check-qlist: check-qlist.o qlist.o qint.o $(CHECK_PROG_DEPS)
check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS)
check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o error.o qerror.o qemu-error.o $(CHECK_PROG_DEPS)
test-coroutine: test-coroutine.o qemu-timer-common.o async.o $(coroutine-obj-y) $(CHECK_PROG_DEPS)

$(qapi-obj-y): $(GENERATED_HEADERS)
qapi-dir := qapi-generated
@@ -226,6 +227,7 @@ distclean: clean
rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
rm -f qemu-doc.vr
rm -f config.log
rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
for d in $(TARGET_DIRS) $(QEMULIBS); do \
rm -rf $$d || exit 1 ; \
15 changes: 14 additions & 1 deletion Makefile.objs
Original file line number Diff line number Diff line change
@@ -10,11 +10,22 @@ oslib-obj-y = osdep.o
oslib-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o
oslib-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o

#######################################################################
# coroutines
coroutine-obj-y = qemu-coroutine.o qemu-coroutine-lock.o
ifeq ($(CONFIG_UCONTEXT_COROUTINE),y)
coroutine-obj-$(CONFIG_POSIX) += coroutine-ucontext.o
else
coroutine-obj-$(CONFIG_POSIX) += coroutine-gthread.o
endif
coroutine-obj-$(CONFIG_WIN32) += coroutine-win32.o

#######################################################################
# block-obj-y is code used by both qemu system emulation and qemu-img

block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o async.o
block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o qemu-progress.o qemu-sockets.o
block-obj-y += $(coroutine-obj-y)
block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
block-obj-$(CONFIG_POSIX) += compatfd.o
@@ -90,6 +101,7 @@ common-obj-y += i2c.o smbus.o smbus_eeprom.o
common-obj-y += eeprom93xx.o
common-obj-y += scsi-disk.o cdrom.o
common-obj-y += scsi-generic.o scsi-bus.o
common-obj-y += hid.o
common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
common-obj-y += usb-serial.o usb-net.o usb-bus.o usb-desc.o
common-obj-$(CONFIG_SSI) += ssi.o
@@ -152,7 +164,7 @@ common-obj-y += qemu-timer.o qemu-timer-common.o

slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o arp_table.o
common-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))

# xen backend driver support
@@ -173,6 +185,7 @@ user-obj-y += cutils.o cache-utils.o
hw-obj-y =
hw-obj-y += loader.o
hw-obj-$(CONFIG_VIRTIO) += virtio-console.o
hw-obj-y += usb-libhw.o
hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
hw-obj-y += fw_cfg.o
hw-obj-$(CONFIG_PCI) += pci_bridge.o
98 changes: 7 additions & 91 deletions async.c
Original file line number Diff line number Diff line change
@@ -25,92 +25,8 @@
#include "qemu-common.h"
#include "qemu-aio.h"

/*
* An AsyncContext protects the callbacks of AIO requests and Bottom Halves
* against interfering with each other. A typical example is qcow2 that accepts
* asynchronous requests, but relies for manipulation of its metadata on
* synchronous bdrv_read/write that doesn't trigger any callbacks.
*
* However, these functions are often emulated using AIO which means that AIO
* callbacks must be run - but at the same time we must not run callbacks of
* other requests as they might start to modify metadata and corrupt the
* internal state of the caller of bdrv_read/write.
*
* To achieve the desired semantics we switch into a new AsyncContext.
* Callbacks must only be run if they belong to the current AsyncContext.
* Otherwise they need to be queued until their own context is active again.
* This is how you can make qemu_aio_wait() wait only for your own callbacks.
*
* The AsyncContexts form a stack. When you leave a AsyncContexts, you always
* return to the old ("parent") context.
*/
struct AsyncContext {
/* Consecutive number of the AsyncContext (position in the stack) */
int id;

/* Anchor of the list of Bottom Halves belonging to the context */
struct QEMUBH *first_bh;

/* Link to parent context */
struct AsyncContext *parent;
};

/* The currently active AsyncContext */
static struct AsyncContext *async_context = &(struct AsyncContext) { 0 };

/*
* Enter a new AsyncContext. Already scheduled Bottom Halves and AIO callbacks
* won't be called until this context is left again.
*/
void async_context_push(void)
{
struct AsyncContext *new = qemu_mallocz(sizeof(*new));
new->parent = async_context;
new->id = async_context->id + 1;
async_context = new;
}

/* Run queued AIO completions and destroy Bottom Half */
static void bh_run_aio_completions(void *opaque)
{
QEMUBH **bh = opaque;
qemu_bh_delete(*bh);
qemu_free(bh);
qemu_aio_process_queue();
}
/*
* Leave the currently active AsyncContext. All Bottom Halves belonging to the
* old context are executed before changing the context.
*/
void async_context_pop(void)
{
struct AsyncContext *old = async_context;
QEMUBH **bh;

/* Flush the bottom halves, we don't want to lose them */
while (qemu_bh_poll());

/* Switch back to the parent context */
async_context = async_context->parent;
qemu_free(old);

if (async_context == NULL) {
abort();
}

/* Schedule BH to run any queued AIO completions as soon as possible */
bh = qemu_malloc(sizeof(*bh));
*bh = qemu_bh_new(bh_run_aio_completions, bh);
qemu_bh_schedule(*bh);
}

/*
* Returns the ID of the currently active AsyncContext
*/
int get_async_context_id(void)
{
return async_context->id;
}
/* Anchor of the list of Bottom Halves belonging to the context */
static struct QEMUBH *first_bh;

/***********************************************************/
/* bottom halves (can be seen as timers which expire ASAP) */
@@ -130,8 +46,8 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
bh = qemu_mallocz(sizeof(QEMUBH));
bh->cb = cb;
bh->opaque = opaque;
bh->next = async_context->first_bh;
async_context->first_bh = bh;
bh->next = first_bh;
first_bh = bh;
return bh;
}

@@ -141,7 +57,7 @@ int qemu_bh_poll(void)
int ret;

ret = 0;
for (bh = async_context->first_bh; bh; bh = next) {
for (bh = first_bh; bh; bh = next) {
next = bh->next;
if (!bh->deleted && bh->scheduled) {
bh->scheduled = 0;
@@ -153,7 +69,7 @@ int qemu_bh_poll(void)
}

/* remove deleted bhs */
bhp = &async_context->first_bh;
bhp = &first_bh;
while (*bhp) {
bh = *bhp;
if (bh->deleted) {
@@ -199,7 +115,7 @@ void qemu_bh_update_timeout(int *timeout)
{
QEMUBH *bh;

for (bh = async_context->first_bh; bh; bh = bh->next) {
for (bh = first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
/* idle bottom halves will be polled at least
61 changes: 39 additions & 22 deletions balloon.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*
* QEMU System Emulator
* Generic Balloon handlers and management
*
* Copyright (c) 2003-2008 Fabrice Bellard
* Copyright (C) 2011 Red Hat, Inc.
* Copyright (C) 2011 Amit Shah <amit.shah@redhat.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,54 +32,63 @@
#include "balloon.h"
#include "trace.h"

static QEMUBalloonEvent *balloon_event_fn;
static QEMUBalloonStatus *balloon_stat_fn;
static void *balloon_opaque;

static QEMUBalloonEvent *qemu_balloon_event;
void *qemu_balloon_event_opaque;

void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque)
int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
QEMUBalloonStatus *stat_func, void *opaque)
{
qemu_balloon_event = func;
qemu_balloon_event_opaque = opaque;
if (balloon_event_fn || balloon_stat_fn || balloon_opaque) {
/* We're already registered one balloon handler. How many can
* a guest really have?
*/
error_report("Another balloon device already registered");
return -1;
}
balloon_event_fn = event_func;
balloon_stat_fn = stat_func;
balloon_opaque = opaque;
return 0;
}

int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque)
static int qemu_balloon(ram_addr_t target)
{
if (qemu_balloon_event) {
trace_balloon_event(qemu_balloon_event_opaque, target);
qemu_balloon_event(qemu_balloon_event_opaque, target, cb, opaque);
return 1;
} else {
if (!balloon_event_fn) {
return 0;
}
trace_balloon_event(balloon_opaque, target);
balloon_event_fn(balloon_opaque, target);
return 1;
}

int qemu_balloon_status(MonitorCompletion cb, void *opaque)
static int qemu_balloon_status(MonitorCompletion cb, void *opaque)
{
if (qemu_balloon_event) {
qemu_balloon_event(qemu_balloon_event_opaque, 0, cb, opaque);
return 1;
} else {
if (!balloon_stat_fn) {
return 0;
}
balloon_stat_fn(balloon_opaque, cb, opaque);
return 1;
}

static void print_balloon_stat(const char *key, QObject *obj, void *opaque)
{
Monitor *mon = opaque;

if (strcmp(key, "actual"))
if (strcmp(key, "actual")) {
monitor_printf(mon, ",%s=%" PRId64, key,
qint_get_int(qobject_to_qint(obj)));
}
}

void monitor_print_balloon(Monitor *mon, const QObject *data)
{
QDict *qdict;

qdict = qobject_to_qdict(data);
if (!qdict_haskey(qdict, "actual"))
if (!qdict_haskey(qdict, "actual")) {
return;

}
monitor_printf(mon, "balloon: actual=%" PRId64,
qdict_get_int(qdict, "actual") >> 20);
qdict_iter(qdict, print_balloon_stat, mon);
@@ -129,14 +140,20 @@ int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
int do_balloon(Monitor *mon, const QDict *params,
MonitorCompletion cb, void *opaque)
{
int64_t target;
int ret;

if (kvm_enabled() && !kvm_has_sync_mmu()) {
qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon");
return -1;
}

ret = qemu_balloon(qdict_get_int(params, "value"), cb, opaque);
target = qdict_get_int(params, "value");
if (target <= 0) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size");
return -1;
}
ret = qemu_balloon(target);
if (ret == 0) {
qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon");
return -1;
12 changes: 5 additions & 7 deletions balloon.h
Original file line number Diff line number Diff line change
@@ -16,14 +16,12 @@

#include "monitor.h"

typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target,
MonitorCompletion cb, void *cb_data);
typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
typedef void (QEMUBalloonStatus)(void *opaque, MonitorCompletion cb,
void *cb_data);

void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque);

int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque);

int qemu_balloon_status(MonitorCompletion cb, void *opaque);
int qemu_add_balloon_handler(QEMUBalloonEvent *event_func,
QEMUBalloonStatus *stat_func, void *opaque);

void monitor_print_balloon(Monitor *mon, const QObject *data);
int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque);
Loading
Oops, something went wrong.

0 comments on commit 145e11e

Please sign in to comment.