summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-10-28 11:39:59 +0000
committerMark McLoughlin <markmc@redhat.com>2009-10-28 11:39:59 +0000
commit51df62225ded6893e7151e33d1ec7a928fe2c1cb (patch)
tree1253e326ae37b53930871372dd7b53c1320ac574 /posix-aio-compat.c
parentMerge commit '844e78ef9c6102cc3e33e4aa00efc8abdf0d8dde' into upstream-merge (diff)
parentposix-aio-compat: Split out posix_aio_process_queue (diff)
downloadqemu-kvm-51df62225ded6893e7151e33d1ec7a928fe2c1cb.tar.gz
qemu-kvm-51df62225ded6893e7151e33d1ec7a928fe2c1cb.tar.bz2
qemu-kvm-51df62225ded6893e7151e33d1ec7a928fe2c1cb.zip
Merge commit '59c7b155aa6e1cbfe8a92e2322ea59ab31965c10' into upstream-merge
* commit '59c7b155aa6e1cbfe8a92e2322ea59ab31965c10': (81 commits) posix-aio-compat: Split out posix_aio_process_queue monitor: Convert do_closefd() to QObject monitor: Convert do_getfd() to QObject monitor: Convert do_eject() to QObject monitor: Convert do_pci_device_hot_remove() to QObject monitor: Convert do_migrate_cancel() to QObject monitor: Convert do_migrate_set_speed() to QObject monitor: Convert do_migrate() to QObject monitor: Convert do_physical_memory_save() to QObject monitor: Convert do_memory_save() to QObject lsi_scsi: port to vmstate vmstate: Add VMSTATE_BUFFER_UNSAFE vmware_vga: port to vmstate vmware_vga: the support to change dinamically depth is not there vmware_vga: scratch is really an array of uint32_t vmware_vga: remove !EMBED_STDVGA code vmware_vga: qemu_malloc() returns void * vmware_vga: Remove uselss casts from void * vmware_vga: Pass pci_vmsga_state_t arg no VGACommonState vga: remove unused vga_common_save/load ... Conflicts: posix-aio-compat.c Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'posix-aio-compat.c')
-rw-r--r--posix-aio-compat.c65
1 files changed, 38 insertions, 27 deletions
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 65f2bfdef..4007be376 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -414,47 +414,25 @@ static int qemu_paio_error(struct qemu_paiocb *aiocb)
return ret;
}
-static void posix_aio_read(void *opaque)
+static int posix_aio_process_queue(void *opaque)
{
PosixAioState *s = opaque;
struct qemu_paiocb *acb, **pacb;
int ret;
- union {
- struct qemu_signalfd_siginfo siginfo;
- char buf[128];
- } sig;
- size_t offset;
-
- /* try to read from signalfd, don't freak out if we can't read anything */
- offset = 0;
- while (offset < 128) {
- ssize_t len;
-
- len = read(s->fd, sig.buf + offset, 128 - offset);
- if (len == -1 && errno == EINTR)
- continue;
- if (len == -1 && errno == EAGAIN) {
- /* there is no natural reason for this to happen,
- * so we'll spin hard until we get everything just
- * to be on the safe side. */
- if (offset > 0)
- continue;
- }
-
- offset += len;
- }
+ int result = 0;
for(;;) {
pacb = &s->first_aio;
for(;;) {
acb = *pacb;
if (!acb)
- goto the_end;
+ return result;
ret = qemu_paio_error(acb);
if (ret == ECANCELED) {
/* remove the request */
*pacb = acb->next;
qemu_aio_release(acb);
+ result = 1;
} else if (ret != EINPROGRESS) {
/* end of aio */
if (ret == 0) {
@@ -471,13 +449,46 @@ static void posix_aio_read(void *opaque)
/* call the callback */
acb->common.cb(acb->common.opaque, ret);
qemu_aio_release(acb);
+ result = 1;
break;
} else {
pacb = &acb->next;
}
}
}
- the_end: ;
+
+ return result;
+}
+
+static void posix_aio_read(void *opaque)
+{
+ PosixAioState *s = opaque;
+ union {
+ struct qemu_signalfd_siginfo siginfo;
+ char buf[128];
+ } sig;
+ size_t offset;
+
+ /* try to read from signalfd, don't freak out if we can't read anything */
+ offset = 0;
+ while (offset < 128) {
+ ssize_t len;
+
+ len = read(s->fd, sig.buf + offset, 128 - offset);
+ if (len == -1 && errno == EINTR)
+ continue;
+ if (len == -1 && errno == EAGAIN) {
+ /* there is no natural reason for this to happen,
+ * so we'll spin hard until we get everything just
+ * to be on the safe side. */
+ if (offset > 0)
+ continue;
+ }
+
+ offset += len;
+ }
+
+ posix_aio_process_queue(s);
}
static int posix_aio_flush(void *opaque)