From: Joel Schopp <jschopp@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v3] Move File operations to qemu-file.c
Date: Wed, 13 Mar 2013 13:18:46 -0500 [thread overview]
Message-ID: <5140C306.4040703@linux.vnet.ibm.com> (raw)
In-Reply-To: <51406DF4.8050008@redhat.com>
>> -util-obj-y = util/ qobject/ qapi/ trace/
>> +util-obj-y = util/ qobject/ qapi/ trace/ qemu-file.o
>
> Please either move it to util/ (and the include file to
> include/qemu/file.h), or leave it in common-obj-y. I prefer the former,
> since as a rule of thumb util-obj-y includes code that should be easy to
> unit-test.
I like that suggestion. I'll move qemu-file.c to the util directory.
I'd rather not move the include file as it seems to be fine where it is
and there are about 6000 places it is included that would have to be
updated as well. Moving the unmodified file locations doesn't gain
anything functional.
>> +
>> +/**
>> + * Yield until a file descriptor becomes readable
>> + *
>> + * Note that this function clobbers the handlers for the file descriptor.
>> + */
>> +static void coroutine_fn yield_until_fd_readable(int fd)
>> +{
>> + FDYieldUntilData data;
>> +
>> + assert(qemu_in_coroutine());
>> + data.co = qemu_coroutine_self();
>> + data.fd = fd;
>> + qemu_set_fd_handler(fd, fd_coroutine_enter, NULL, &data);
>> + qemu_coroutine_yield();
>> +}
>
> Coroutines are not part of libqemuutil.a, so you should be getting
> missing symbols here; I'm surprised that the patch successfully passes
> "make check" though I may be missing something.
It does pass make check. I'd rather move all the file related stuff out
of migration.
>
> Everything from here down to qemu_fopen_bdrv (included) should remain in
> savevm.c:
I like these broken out better, but I don't actually need them so I'll
go ahead and leave them where they are for now on your suggestion.
>
>> +static int block_put_buffer(void *opaque, const uint8_t *buf,
>> + int64_t pos, int size)
>> +{
>> + bdrv_save_vmstate(opaque, buf, pos, size);
>> + return size;
>> +}
>> +
>> +static int block_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
>> +{
>> + return bdrv_load_vmstate(opaque, buf, pos, size);
>> +}
>> +
>> +static int bdrv_fclose(void *opaque)
>> +{
>> + return bdrv_flush(opaque);
>> +}
>> +
>> +static const QEMUFileOps bdrv_read_ops = {
>> + .get_buffer = block_get_buffer,
>> + .close = bdrv_fclose
>> +};
>> +
>> +static const QEMUFileOps bdrv_write_ops = {
>> + .put_buffer = block_put_buffer,
>> + .close = bdrv_fclose
>> +};
>> +
>> +QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
>> +{
>> + if (is_writable)
>> + return qemu_fopen_ops(bs, &bdrv_write_ops);
>> + return qemu_fopen_ops(bs, &bdrv_read_ops);
>> +}
prev parent reply other threads:[~2013-03-13 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 22:43 [Qemu-devel] [PATCH v3] Move File operations to qemu-file.c Joel Schopp
2013-03-13 12:15 ` Paolo Bonzini
2013-03-13 18:18 ` Joel Schopp [this message]
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=5140C306.4040703@linux.vnet.ibm.com \
--to=jschopp@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).