All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Alexander Bulekov <alxndr@bu.edu>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] virtio: clean up when virtio_queue_set_rings() fails
Date: Wed, 5 Feb 2020 16:55:11 +0100	[thread overview]
Message-ID: <20200205165511.108326a5.cohuck@redhat.com> (raw)
In-Reply-To: <20200205144946.GH58062@stefanha-x1.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1650 bytes --]

On Wed, 5 Feb 2020 14:49:46 +0000
Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Tue, Feb 04, 2020 at 05:02:39PM +0100, Cornelia Huck wrote:
> > On Tue,  4 Feb 2020 15:16:18 +0000
> > Stefan Hajnoczi <stefanha@redhat.com> wrote:

> > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > > index 2c5410e981..5d7f619a1e 100644
> > > --- a/hw/virtio/virtio.c
> > > +++ b/hw/virtio/virtio.c
> > > @@ -2163,6 +2163,11 @@ void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc,
> > >      vdev->vq[n].vring.avail = avail;
> > >      vdev->vq[n].vring.used = used;
> > >      virtio_init_region_cache(vdev, n);
> > > +    if (vdev->broken) {
> > > +        vdev->vq[n].vring.desc = 0;
> > > +        vdev->vq[n].vring.avail = 0;
> > > +        vdev->vq[n].vring.used = 0;
> > > +    }
> > >  }
> > >  
> > >  void virtio_queue_set_num(VirtIODevice *vdev, int n, int num)  
> > 
> > This looks correct; but shouldn't virtio_queue_set_addr() also set
> > .desc to 0 on failure?  
> 
> Now that you mention it, there are a number of other
> virtio_init_region_cache() callers that could be affected.
> 
> I added the error handling code to virtio_queue_set_rings() because
> that's symmetric - this function sets .desc and so it should be the one
> to clear it on error.  But now I think virtio_init_region_cache() should
> take on that responsibility so callers don't need to duplicate this
> error handling code.

Is it clear in every case what the correct error handling procedure
would be? It would feel a bit surprising if the addresses were cleared
for callers that don't directly change them.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-02-05 15:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 15:16 [PATCH] virtio: clean up when virtio_queue_set_rings() fails Stefan Hajnoczi
2020-02-04 16:02 ` Cornelia Huck
2020-02-05 14:49   ` Stefan Hajnoczi
2020-02-05 15:55     ` Cornelia Huck [this message]
2020-02-04 16:36 ` Michael S. Tsirkin
2020-02-05  6:13 ` Michael S. Tsirkin
2020-02-05 14:56   ` Stefan Hajnoczi
2020-02-06  6:28     ` Michael S. Tsirkin

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=20200205165511.108326a5.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=alxndr@bu.edu \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@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.