aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-03-26 10:04:17 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-26 10:08:07 -0500
commitcd18720a294bd7244ffda719677dd9c737317b67 (patch)
treed2e1a7f2dff2e0065e731a0ac27a81007d0da0ca /qemu-char.c
parente769bdc26ded6d7681cddd9f67c5f87a4b5ba53c (diff)
downloadqemu-cd18720a294bd7244ffda719677dd9c737317b67.zip
qemu-cd18720a294bd7244ffda719677dd9c737317b67.tar.gz
qemu-cd18720a294bd7244ffda719677dd9c737317b67.tar.bz2
char: introduce a blocking version of qemu_chr_fe_write
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 4e011df..936150f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -140,6 +140,33 @@ int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len)
return s->chr_write(s, buf, len);
}
+int qemu_chr_fe_write_all(CharDriverState *s, const uint8_t *buf, int len)
+{
+ int offset = 0;
+ int res;
+
+ while (offset < len) {
+ do {
+ res = s->chr_write(s, buf + offset, len - offset);
+ if (res == -1 && errno == EAGAIN) {
+ g_usleep(100);
+ }
+ } while (res == -1 && errno == EAGAIN);
+
+ if (res == 0) {
+ break;
+ }
+
+ if (res < 0) {
+ return res;
+ }
+
+ offset += res;
+ }
+
+ return offset;
+}
+
int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg)
{
if (!s->chr_ioctl)