[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 8/10] Introduce a buffered QEMUFile wrapper
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [PATCH 8/10] Introduce a buffered QEMUFile wrapper |
Date: |
Fri, 12 Sep 2008 18:16:47 +0300 |
On 9/9/08, Anthony Liguori <address@hidden> wrote:
> This patch introduces a buffered QEMUFile wrapper. This allows QEMUFile's to
> be
> rate limited. It also allows makes it easier to implement a QEMUFile that is
> asynchronous.
>
> The only real non-obvious part of the API is the "frozen" concept. If the
> backend
> returns EAGAIN, the QEMUFile is said to be "frozen". This means no
> additional
> output will be sent to the backend until the file is unfrozen.
> qemu_file_put_notify
> can be used to unfreeze a frozen file.
>
> A synchronous interface is also provided to wait for an unfreeze event.
> This is
> used during the final part of live migration when the VM is no longer
> running.
> +static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t
> pos, int size)
> +{
> + QEMUFileBuffered *s = opaque;
> + size_t offset = 0;
> + ssize_t ret;
> +
> + if (s->has_error)
> + return -EINVAL;
> +
> + s->freeze_output = 0;
> +
> + buffered_flush(s);
> +
> + while (offset < size) {
> + if (s->bytes_xfer > s->xfer_limit)
> + break;
> +
> + ret = s->put_buffer(s->opaque, buf + offset, size - offset);
> + if (ret == -EAGAIN) {
> + s->freeze_output = 1;
> + break;
> + }
> +
> + if (ret <= 0) {
> + s->has_error = 1;
> + break;
> + }
> +
> + offset += ret;
> + s->bytes_xfer += ret;
> + }
> +
> + buffered_append(s, buf + offset, size - offset);
> +
> + return offset;
> +}
I'd change the types of the return value and parameter "size" to ssize_t.
Re: [Qemu-devel] [PATCH 2/10] Allow the monitor to be suspended during non-blocking op, Daniel P. Berrange, 2008/09/10
[Qemu-devel] [PATCH 10/10] TCP based live migration, Anthony Liguori, 2008/09/09
[Qemu-devel] [PATCH 8/10] Introduce a buffered QEMUFile wrapper, Anthony Liguori, 2008/09/09
- Re: [Qemu-devel] [PATCH 8/10] Introduce a buffered QEMUFile wrapper,
Blue Swirl <=
[Qemu-devel] [PATCH 9/10] Introduce the UI components for live migration, Anthony Liguori, 2008/09/09
[Qemu-devel] [PATCH 6/10] Introduce v3 of savevm protocol, Anthony Liguori, 2008/09/09
[Qemu-devel] [PATCH 5/10] Add network announce function, Anthony Liguori, 2008/09/09
[Qemu-devel] [PATCH 4/10] Add dirty tracking for live migration, Anthony Liguori, 2008/09/09