From: Uri Lublin <uri@il.qumranet.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Avi Kivity <avi@redhat.com>, Uri Lublin <uril@qumranet.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH] qemu: qemu_fopen_fd: differentiate between reader and writer user
Date: Thu, 16 Oct 2008 03:36:43 +0200 [thread overview]
Message-ID: <48F69AAB.4010404@il.qumranet.com> (raw)
In-Reply-To: <48F2BA83.7000101@codemonkey.ws>
Anthony Liguori wrote:
> Anthony Liguori wrote:
>>
>> Also, having checks and the read and write functions to determine if
>> the is_write flag is set along with whether buf_index > 0 that
>> fprintf()'d and aborted would be good for debugging.
>
> I have a patch that does this along with fixing a few other bugs. It's
> attached.
>
Hi Anthony,
Thanks for pushing Live Migration into upstream qemu.
This patch doesn't provide us with full duplex capability yet:
* qemu_fopen_fd() now only register get_buffer function (always a reader).
* Also there still a single buffer that should not be shared by reader/writer.
* It aborts upon a read-to-write switch and upon a write-to-read switch. That
as you've mentioned may be helpful when/if implementing a full duplex
qemu_file_* mechanism.
Below are some specific code comments.
Thanks,
Uri.
>@@ -6278,12 +6253,13 @@ typedef struct QEMUFileStdio
> FILE *outfile;
> } QEMUFileStdio;
>
>-static void file_put_buffer(void *opaque, const uint8_t *buf,
>+static int file_put_buffer(void *opaque, const uint8_t *buf,
> int64_t pos, int size)
> {
> QEMUFileStdio *s = opaque;
> fseek(s->outfile, pos, SEEK_SET);
> fwrite(buf, 1, size, s->outfile);
>+ return size;
Better return the size that was actually written
> }
>
> static int file_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
>@@ -6331,11 +6307,12 @@ typedef struct QEMUFileBdrv
> int64_t base_offset;
> } QEMUFileBdrv;
>
>-static void bdrv_put_buffer(void *opaque, const uint8_t *buf,
>- int64_t pos, int size)
>+static int bdrv_put_buffer(void *opaque, const uint8_t *buf,
>+ int64_t pos, int size)
> {
> QEMUFileBdrv *s = opaque;
> bdrv_pwrite(s->bs, s->base_offset + pos, buf, size);
>+ return size;
Same here
> }
> void qemu_fflush(QEMUFile *f)
> {
> if (!f->put_buffer)
> return;
>- if (f->buf_index > 0) {
>- f->put_buffer(f->opaque, f->buf, f->buf_offset, f->buf_index);
>- f->buf_offset += f->buf_index;
>+ if (f->is_write && f->buf_index > 0) {
>+ int len;
>+
>+ len = f->put_buffer(f->opaque, f->buf, f->buf_offset, f->buf_index);
>+ if (len > 0)
>+ f->buf_offset += f->buf_index;
>+ else
>+ f->has_error = 1;
Untabify.
> f->buf_index = 0;
> }
> }
next prev parent reply other threads:[~2008-10-16 1:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-12 16:30 [PATCH] qemu: qemu_fopen_fd: differentiate between reader and writer user Uri Lublin
2008-10-12 16:55 ` Avi Kivity
2008-10-12 18:09 ` Anthony Liguori
2008-10-12 18:17 ` Avi Kivity
2008-10-12 22:18 ` Anthony Liguori
2008-10-13 3:03 ` Anthony Liguori
2008-10-16 1:36 ` Uri Lublin [this message]
2008-10-16 4:14 ` Anthony Liguori
2008-10-16 8:13 ` Avi Kivity
2008-10-16 12:54 ` Anthony Liguori
2008-10-16 14:23 ` Uri Lublin
2008-10-16 14:32 ` Avi Kivity
2008-10-16 14:49 ` Uri Lublin
2008-10-17 2:47 ` Anthony Liguori
2008-10-19 13:46 ` Uri Lublin
2008-10-19 22:00 ` Anthony Liguori
2008-10-22 16:23 ` Uri Lublin
2008-10-16 10:52 ` Uri Lublin
2008-10-16 0:13 ` Uri Lublin
2008-10-16 4:10 ` Anthony Liguori
2008-10-16 8:16 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48F69AAB.4010404@il.qumranet.com \
--to=uri@il.qumranet.com \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=uril@qumranet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.