[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 30/32] qmp: add pull_event function
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 30/32] qmp: add pull_event function |
Date: |
Wed, 24 Oct 2012 11:50:54 +0200 |
From: Paolo Bonzini <address@hidden>
This function is unlike get_events in that it makes it easy to process
one event at a time. This is useful in the mirroring test cases, where
we want to process just one event (BLOCK_JOB_ERROR) and leave the others
to a helper function.
Acked-by: Luiz Capitulino <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
QMP/qmp.py | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/QMP/qmp.py b/QMP/qmp.py
index 32510a1..c551df1 100644
--- a/QMP/qmp.py
+++ b/QMP/qmp.py
@@ -136,6 +136,26 @@ class QEMUMonitorProtocol:
raise Exception(ret['error']['desc'])
return ret['return']
+ def pull_event(self, wait=False):
+ """
+ Get and delete the first available QMP event.
+
+ @param wait: block until an event is available (bool)
+ """
+ self.__sock.setblocking(0)
+ try:
+ self.__json_read()
+ except socket.error, err:
+ if err[0] == errno.EAGAIN:
+ # No data available
+ pass
+ self.__sock.setblocking(1)
+ if not self.__events and wait:
+ self.__json_read(only_event=True)
+ event = self.__events[0]
+ del self.__events[0]
+ return event
+
def get_events(self, wait=False):
"""
Get a list of available QMP events.
--
1.7.6.5
- [Qemu-devel] [PATCH 13/32] monitor: Enable adding an inherited fd to an fd set, (continued)
- [Qemu-devel] [PATCH 13/32] monitor: Enable adding an inherited fd to an fd set, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 22/32] block: add block-job-complete, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 16/32] block: add bdrv_query_info, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 18/32] block: add bdrv_open_backing_file, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 20/32] block: export dirty bitmap information in query-block, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 25/32] qmp: add drive-mirror command, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 24/32] mirror: introduce mirror job, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 23/32] block: introduce BLOCK_JOB_READY event, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 31/32] qemu-iotests: add testcases for mirroring on-source-error/on-target-error, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 29/32] mirror: add support for on-source-error/on-target-error, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 30/32] qmp: add pull_event function,
Kevin Wolf <=
- [Qemu-devel] [PATCH 32/32] osdep: Less restrictive F_SEFL in qemu_dup_flags(), Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 27/32] qemu-iotests: add mirroring test case, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 26/32] mirror: implement completion, Kevin Wolf, 2012/10/24
- [Qemu-devel] [PATCH 28/32] iostatus: forward block_job_iostatus_reset to block job, Kevin Wolf, 2012/10/24
- Re: [Qemu-devel] [PULL 00/32] Block patches, Anthony Liguori, 2012/10/29