mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
char: introduce a blocking version of qemu_chr_fe_write
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
e769bdc26d
commit
cd18720a29
2 changed files with 42 additions and 0 deletions
27
qemu-char.c
27
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue