From: Anthony Liguori <anthony@codemonkey.ws>
To: Uri Lublin <uri@il.qumranet.com>
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: Wed, 15 Oct 2008 23:14:25 -0500 [thread overview]
Message-ID: <48F6BFA1.9070608@codemonkey.ws> (raw)
In-Reply-To: <48F69AAB.4010404@il.qumranet.com>
Uri Lublin wrote:
> Anthony Liguori wrote:
I have already cut your text, but I don't understand the comment about
not being "full duplex". Is there a reason why migration needs to be
bidirectional? I don't think there's a fundamental reason it needs to
be and I think there are some advantages to it being unidirectional.
> >@@ -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
At this level in the API, you have to write all of the data. The reason
I introduced a return value at all was so that you could return an
error. This is necessary to detect that a migration or save/restore has
failed. I agree the QEMUFile API isn't ideal ATM. The whole buffered
thing is a big hack. I'm open to refactoring suggestions/patches.
> > 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.
I don't see a tab in subversion so perhaps I cleaned that up before
committing :-)
Thanks for the review!
Regards,
Anthony Liguori
>
> > f->buf_index = 0;
> > }
> > }
>
next prev parent reply other threads:[~2008-10-16 4:14 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
2008-10-16 4:14 ` Anthony Liguori [this message]
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=48F6BFA1.9070608@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=uri@il.qumranet.com \
--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.