qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>,
	"M. Mohan Kumar" <mohan@in.ibm.com>
Cc: "M. Mohan Kumar" <mohankumar.m@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V4 04/13] hw/9pfs: File system helper process for qemu 9p proxy FS
Date: Mon, 12 Dec 2011 20:51:58 +0530	[thread overview]
Message-ID: <87ehw9hl2h.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111212120833.GA22654@stefanha-thinkpad.localdomain>

On Mon, 12 Dec 2011 12:08:33 +0000, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Fri, Dec 09, 2011 at 10:12:17PM +0530, M. Mohan Kumar wrote:
> > On Friday, December 09, 2011 12:01:14 AM Stefan Hajnoczi wrote:
> > > On Mon, Dec 05, 2011 at 09:48:41PM +0530, M. Mohan Kumar wrote:
> > > > +static int read_request(int sockfd, struct iovec *iovec, ProxyHeader
> > > > *header) +{
> > > > +    int retval;
> > > > +
> > > > +    /*
> > > > +     * read the request header.
> > > > +     */
> > > > +    iovec->iov_len = 0;
> > > > +    retval = socket_read(sockfd, iovec->iov_base, PROXY_HDR_SZ);
> > > > +    if (retval < 0) {
> > > > +        return retval;
> > > > +    }
> > > > +    iovec->iov_len = PROXY_HDR_SZ;
> > > > +    retval = proxy_unmarshal(iovec, 0, "dd", &header->type,
> > > > &header->size); +    if (retval < 0) {
> > > > +        return retval;
> > > > +    }
> > > > +    /*
> > > > +     * We can't process message.size > PROXY_MAX_IO_SZ, read the
> > > > complete +     * message from the socket and ignore it. This ensures
> > > > that +     * we can correctly handle the next request. We also return + 
> > > >    * ENOBUFS as error to indicate we ran out of buffer space. +     */
> > > > +    if (header->size > PROXY_MAX_IO_SZ) {
> > > > +        int count, size;
> > > > +        size = header->size;
> > > > +        while (size > 0) {
> > > > +            count = MIN(PROXY_MAX_IO_SZ, size);
> > > > +            count = socket_read(sockfd, iovec->iov_base + PROXY_HDR_SZ,
> > > > count); +            if (count < 0) {
> > > > +                return count;
> > > > +            }
> > > > +            size -= count;
> > > > +        }
> > > 
> > > I'm not sure recovery attempts are worthwhile here.  The client is
> > > buggy, perhaps just refuse further work.
> > 
> > But whats the issue in trying to recover in this case?
> 
> This recovery procedure is not robust because it does not always work.
> In fact it only works in the case where the header->size field was
> out-of-range but accurate.  That's not a likely case since the QEMU-side
> code that you are writing should handle this.
> 
> If the nature of the invalid request is different, either a broken or
> malicious client which does not send a valid header->size then we're
> stuck in this special-case recovery trying to gobble bytes and we never
> log an error.
> 
> A real recovery would be something like disconnecting and
> re-establishing the connection between QEMU and the helper.  This would
> allow us to get back to a clean state in all cases.
> 

Since we are not having any state in the proxy helper, returning ENOBUFS
should be similar to the above right ? One of the reason to try to
recover as much as possible, is to make sure the guest can umount the
file system properly. That is if we hit these error condition due to a
bug in proxy FS driver is qemu, we want to make sure we return some
valid error, which will atleast enable the guest/client to do an umount.

-aneesh

  reply	other threads:[~2011-12-12 15:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 16:18 [Qemu-devel] [PATCH V4 00/13] Proxy FS driver for VirtFS M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 01/13] hw/9pfs: Move pdu_marshal/unmarshal code to a seperate file M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 02/13] hw/9pfs: Add validation to {un}marshal code M. Mohan Kumar
2011-12-08 18:10   ` Stefan Hajnoczi
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 03/13] hw/9pfs: Add new proxy filesystem driver M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 04/13] hw/9pfs: File system helper process for qemu 9p proxy FS M. Mohan Kumar
2011-12-08 18:31   ` Stefan Hajnoczi
2011-12-09 16:42     ` M. Mohan Kumar
2011-12-12 12:08       ` Stefan Hajnoczi
2011-12-12 15:21         ` Aneesh Kumar K.V [this message]
2011-12-12 15:56           ` Stefan Hajnoczi
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 05/13] hw/9pfs: Open and create files M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 06/13] hw/9pfs: Create other filesystem objects M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 07/13] hw/9pfs: Add stat/readlink/statfs for proxy FS M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 08/13] hw/9pfs: File ownership and others M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 09/13] hw/9pfs: xattr interfaces in proxy filesystem driver M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 10/13] hw/9pfs: Proxy getversion M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 11/13] hw/9pfs: Documentation changes related to proxy fs M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 12/13] hw/9pfs: man page for proxy helper M. Mohan Kumar
2011-12-05 16:18 ` [Qemu-devel] [PATCH V4 13/13] hw/9pfs: Add support to use named socket for proxy FS M. Mohan Kumar
2011-12-08 17:46 ` [Qemu-devel] [PATCH V4 00/13] Proxy FS driver for VirtFS Stefan Hajnoczi
2011-12-09 14:47   ` M. Mohan Kumar

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=87ehw9hl2h.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=mohan@in.ibm.com \
    --cc=mohankumar.m@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).