*/
#include "qemu/osdep.h"
-#include "migration/qemu-file.h"
+#include "qemu-file-channel.h"
+#include "qemu-file.h"
#include "io/channel-socket.h"
#include "qemu/iov.h"
static ssize_t channel_writev_buffer(void *opaque,
struct iovec *iov,
int iovcnt,
- int64_t pos)
+ int64_t pos,
+ Error **errp)
{
QIOChannel *ioc = QIO_CHANNEL(opaque);
ssize_t done = 0;
while (nlocal_iov > 0) {
ssize_t len;
- len = qio_channel_writev(ioc, local_iov, nlocal_iov, NULL);
+ len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);
if (len == QIO_CHANNEL_ERR_BLOCK) {
- qio_channel_wait(ioc, G_IO_OUT);
+ if (qemu_in_coroutine()) {
+ qio_channel_yield(ioc, G_IO_OUT);
+ } else {
+ qio_channel_wait(ioc, G_IO_OUT);
+ }
continue;
}
if (len < 0) {
- /* XXX handle Error objects */
done = -EIO;
goto cleanup;
}
static ssize_t channel_get_buffer(void *opaque,
uint8_t *buf,
int64_t pos,
- size_t size)
+ size_t size,
+ Error **errp)
{
QIOChannel *ioc = QIO_CHANNEL(opaque);
ssize_t ret;
do {
- ret = qio_channel_read(ioc, (char *)buf, size, NULL);
+ ret = qio_channel_read(ioc, (char *)buf, size, errp);
if (ret < 0) {
if (ret == QIO_CHANNEL_ERR_BLOCK) {
- qio_channel_yield(ioc, G_IO_IN);
+ if (qemu_in_coroutine()) {
+ qio_channel_yield(ioc, G_IO_IN);
+ } else {
+ qio_channel_wait(ioc, G_IO_IN);
+ }
} else {
- /* XXX handle Error * object */
return -EIO;
}
}
}
-static int channel_close(void *opaque)
+static int channel_close(void *opaque, Error **errp)
{
+ int ret;
QIOChannel *ioc = QIO_CHANNEL(opaque);
- qio_channel_close(ioc, NULL);
+ ret = qio_channel_close(ioc, errp);
object_unref(OBJECT(ioc));
- return 0;
+ return ret;
}
static int channel_shutdown(void *opaque,
bool rd,
- bool wr)
+ bool wr,
+ Error **errp)
{
QIOChannel *ioc = QIO_CHANNEL(opaque);
} else {
mode = QIO_CHANNEL_SHUTDOWN_WRITE;
}
- if (qio_channel_shutdown(ioc, mode, NULL) < 0) {
- /* XXX handler Error * object */
+ if (qio_channel_shutdown(ioc, mode, errp) < 0) {
return -EIO;
}
}
static int channel_set_blocking(void *opaque,
- bool enabled)
+ bool enabled,
+ Error **errp)
{
QIOChannel *ioc = QIO_CHANNEL(opaque);
- if (qio_channel_set_blocking(ioc, enabled, NULL) < 0) {
+ if (qio_channel_set_blocking(ioc, enabled, errp) < 0) {
return -1;
}
return 0;