From: Paolo Bonzini <pbonzini@redhat.com>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] 9pfs: fix v9fs_lock error case
Date: Thu, 26 Jan 2017 12:58:14 +0100 [thread overview]
Message-ID: <0039c2fd-34cd-10a1-7f42-0baad9e40412@redhat.com> (raw)
In-Reply-To: <20170126125433.5979903a@bahia.lan>
On 26/01/2017 12:54, Greg Kurz wrote:
> On Thu, 26 Jan 2017 11:07:05 +0100
> Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>> In this case, we are marshaling an error status instead of the errno value.
>> Reorganize the out and out_nofid labels to look like all the other cases.
>> Coverity reports this because the "err = -ENOENT" and "err = -EINVAL"
>> assignments above are dead, overwritten by the call to pdu_marshal.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>
> There was a confusion indeed: if the server fails it should report it to the
> client with an RERROR message.
>
> Responding an RLOCK message with a P9_LOCK_ERROR status only makes sense
> when actually implementing locking (i.e. calling flock() on the backend),
> which isn't the case in QEMU as stated in the comment above v9fs_lock().
> We should hence always report a P9_LOCK_SUCCESS status when responding
> an RLOCK message.
Which my patch does in a very roundabout way: the first assignment to
status is now dead, and the pdu_marshal("b") always uses P9_LOCK_SUCCESS.
> Just to make it clear, I've modified your patch to open code this and
> pushed it to https://github.com/gkurz/qemu/commits/9p-next .
Much, better, thanks.
Paolo
> BTW, I've registered to https://scan.coverity.com/projects/qemu as
> Peter suggested on IRC. I'll have a look at the other 9pfs issues.
>
> Cheers.
>
> --
> Greg
>
>> hw/9pfs/9p.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
>> index 99e9472..d028eca 100644
>> --- a/hw/9pfs/9p.c
>> +++ b/hw/9pfs/9p.c
>> @@ -3045,14 +3045,15 @@ static void coroutine_fn v9fs_lock(void *opaque)
>> goto out;
>> }
>> status = P9_LOCK_SUCCESS;
>> -out:
>> - put_fid(pdu, fidp);
>> -out_nofid:
>> err = pdu_marshal(pdu, offset, "b", status);
>> - if (err > 0) {
>> - err += offset;
>> + if (err < 0) {
>> + goto out;
>> }
>> + err += offset;
>> trace_v9fs_lock_return(pdu->tag, pdu->id, status);
>> +out:
>> + put_fid(pdu, fidp);
>> +out_nofid:
>> pdu_complete(pdu, err);
>> v9fs_string_free(&flock.client_id);
>> }
>
prev parent reply other threads:[~2017-01-26 11:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 10:07 [Qemu-devel] [PATCH] 9pfs: fix v9fs_lock error case Paolo Bonzini
2017-01-26 11:54 ` Greg Kurz
2017-01-26 11:58 ` Paolo Bonzini [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=0039c2fd-34cd-10a1-7f42-0baad9e40412@redhat.com \
--to=pbonzini@redhat.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
/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).