From: Juan Quintela <quintela@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Huth <thuth@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/4] qemu-file: Don't do IO after shutdown
Date: Sun, 29 Dec 2019 19:20:11 +0100 [thread overview]
Message-ID: <87png7kn8k.fsf@trasno.org> (raw)
In-Reply-To: <20191218122702.GF3707@work-vm> (David Alan Gilbert's message of "Wed, 18 Dec 2019 12:27:02 +0000")
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Be sure that we are not doing neither read/write after shutdown of the
>> QEMUFile.
>>
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>> migration/qemu-file.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
>> index 26fb25ddc1..1e5543a279 100644
>> --- a/migration/qemu-file.c
>> +++ b/migration/qemu-file.c
>> @@ -53,6 +53,8 @@ struct QEMUFile {
>>
>> int last_error;
>> Error *last_error_obj;
>> + /* has the file has been shutdown */
>> + bool shutdown;
>> };
>>
>> /*
>> @@ -61,6 +63,7 @@ struct QEMUFile {
>> */
>> int qemu_file_shutdown(QEMUFile *f)
>> {
>> + f->shutdown = true;
>> if (!f->ops->shut_down) {
>> return -ENOSYS;
>> }
>> @@ -214,6 +217,9 @@ void qemu_fflush(QEMUFile *f)
>> return;
>> }
>>
>> + if (f->shutdown) {
>> + return;
>> + }
>
> OK, I did wonder if you need to free the iovec.
We need to improve things here. We should free it on the 1st
error/shutdown. Withought fixing all callers, I don't feel "safe" doing
it.
>
>> if (f->iovcnt > 0) {
>> expect = iov_size(f->iov, f->iovcnt);
>> ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos,
>> @@ -328,6 +334,10 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
>> f->buf_index = 0;
>> f->buf_size = pending;
>>
>> + if (f->shutdown) {
>> + return 0;
>> + }
>
> I also wondered if perhaps an error would be reasonable here; but I'm
> not sure what a read(2) does after a shutdown(2).
We should check this sooner. Same than prevoious. If there has been an
error anywhere else, we should fail qemu_fill_buffer(). Right now we
don't do it. and we should.
qemu_get_error() and the setter should dissapear. And we should just
return errors in all functions. Especially now that we have migration
thread, and we don't have callbacks anymore.
> Still,
>
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Thanks, Juan.
>> len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
>> IO_BUF_SIZE - pending, &local_error);
>> if (len > 0) {
>> @@ -642,6 +652,9 @@ int64_t qemu_ftell(QEMUFile *f)
>>
>> int qemu_file_rate_limit(QEMUFile *f)
>> {
>> + if (f->shutdown) {
>> + return 1;
>> + }
>> if (qemu_file_get_error(f)) {
>> return 1;
>> }
>> --
>> 2.23.0
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2019-12-29 18:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 5:04 [PATCH 0/4] Fix multifd + cancel + multifd Juan Quintela
2019-12-18 5:04 ` [PATCH 1/4] qemu-file: Don't do IO after shutdown Juan Quintela
2019-12-18 12:27 ` Dr. David Alan Gilbert
2019-12-18 14:35 ` Juan Quintela
2019-12-18 15:24 ` Dr. David Alan Gilbert
2019-12-29 18:20 ` Juan Quintela [this message]
2020-01-08 9:49 ` Dr. David Alan Gilbert
2020-01-08 12:40 ` Juan Quintela
2020-01-16 10:04 ` Juan Quintela
2019-12-18 5:04 ` [PATCH 2/4] multifd: Make sure that we don't do any IO after an error Juan Quintela
2019-12-18 13:57 ` Dr. David Alan Gilbert
2019-12-18 14:15 ` Juan Quintela
2019-12-18 5:04 ` [PATCH 3/4] migration-test: Make sure that multifd and cancel works Juan Quintela
2019-12-18 16:25 ` Dr. David Alan Gilbert
2019-12-29 18:27 ` Juan Quintela
2019-12-18 5:04 ` [PATCH 4/4] migration: Make sure that we don't call write() in case of error Juan Quintela
2019-12-18 16:33 ` Dr. David Alan Gilbert
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=87png7kn8k.fsf@trasno.org \
--to=quintela@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.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.