Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Asias He <asias@redhat.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
	target-devel@vger.kernel.org
Subject: Re: [PATCH V2 1/2] tcm_vhost: Initialize vq->last_used_idx when set endpoint
Date: Thu, 28 Mar 2013 11:21:53 +0800	[thread overview]
Message-ID: <20130328032153.GA9454@hj.localdomain> (raw)
In-Reply-To: <1364439247.17698.72.camel@haakon2.linux-iscsi.org>

On Wed, Mar 27, 2013 at 07:54:07PM -0700, Nicholas A. Bellinger wrote:
> Hi Asias,
> 
> On Thu, 2013-03-28 at 10:17 +0800, Asias He wrote:
> > This patch fixes guest hang when booting seabios and guest.
> > 
> >   [    0.576238] scsi0 : Virtio SCSI HBA
> >   [    0.616754] virtio_scsi virtio1: request:id 0 is not a head!
> > 
> > vq->last_used_idx is initialized only when /dev/vhost-scsi is
> > opened or closed.
> > 
> >    vhost_scsi_open -> vhost_dev_init() -> vhost_vq_reset()
> >    vhost_scsi_release() -> vhost_dev_cleanup -> vhost_vq_reset()
> > 
> > So, when guest talks to tcm_vhost after seabios does, vq->last_used_idx
> > still contains the old valule for seabios. This confuses guest.
> > 
> > Fix this by calling vhost_init_used() to init vq->last_used_idx when
> > we set endpoint.
> > 
> > Signed-off-by: Asias He <asias@redhat.com>
> > ---
> >  drivers/vhost/tcm_vhost.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> > index 43fb11e..5e3d4487 100644
> > --- a/drivers/vhost/tcm_vhost.c
> > +++ b/drivers/vhost/tcm_vhost.c
> > @@ -781,8 +781,9 @@ static int vhost_scsi_set_endpoint(
> >  {
> >  	struct tcm_vhost_tport *tv_tport;
> >  	struct tcm_vhost_tpg *tv_tpg;
> > +	struct vhost_virtqueue *vq;
> >  	bool match = false;
> > -	int index, ret;
> > +	int index, ret, i;
> >  
> >  	mutex_lock(&vs->dev.mutex);
> >  	/* Verify that ring has been setup correctly. */
> > @@ -826,6 +827,12 @@ static int vhost_scsi_set_endpoint(
> >  	if (match) {
> >  		memcpy(vs->vs_vhost_wwpn, t->vhost_wwpn,
> >  		       sizeof(vs->vs_vhost_wwpn));
> > +		for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
> > +			vq = &vs->vqs[i];
> > +			mutex_lock(&vq->mutex);
> > +			vhost_init_used(vq);
> > +			mutex_unlock(&vq->mutex);
> > +		}
> 
> Already tried a similar patch earlier today, but as vhost_init_used()
> depends upon a vq->private_data being set it does not actually
> re-initialize ->last_used_idx..
> 

Sigh... Ah, We have this in vhost_init_used

        if (!vq->private_data)
                return 0;


Michael, how bad if we let the original patch 1/2 and 2/2 go to 3.9.

-- 
Asias

  reply	other threads:[~2013-03-28  3:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28  2:17 [PATCH V2 0/2] tcm_vhost endpoint Asias He
2013-03-28  2:17 ` [PATCH V2 1/2] tcm_vhost: Initialize vq->last_used_idx when set endpoint Asias He
2013-03-28  2:54   ` Nicholas A. Bellinger
2013-03-28  3:21     ` Asias He [this message]
2013-03-28  2:17 ` [PATCH V2 2/2] tcm_vhost: Use vq->private_data to indicate if the endpoint is setup Asias He
2013-03-28  6:16   ` Michael S. Tsirkin
2013-03-28  8:10     ` Asias He
2013-03-28  8:33       ` Michael S. Tsirkin
2013-03-28  8:47         ` Asias He
2013-03-28  9:06           ` Michael S. Tsirkin
2013-03-29  6:27             ` Asias He
2013-03-31  8:23               ` Michael S. Tsirkin
2013-04-01  2:20                 ` Asias He
2013-04-01 22:57                 ` Rusty Russell
2013-04-02 13:10                   ` Michael S. Tsirkin
2013-04-12 11:37                   ` Michael S. Tsirkin
2013-03-28  9:18       ` Michael S. Tsirkin
2013-03-29  6:22         ` Asias He
2013-03-31  8:20           ` Michael S. Tsirkin
2013-04-01  2:13             ` Asias He
2013-04-02 12:15               ` Michael S. Tsirkin
2013-04-02 15:10                 ` Asias He
2013-04-02 15:18                   ` Michael S. Tsirkin
2013-04-03  6:08                     ` Asias He

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=20130328032153.GA9454@hj.localdomain \
    --to=asias@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=nab@linux-iscsi.org \
    --cc=pbonzini@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=stefanha@redhat.com \
    --cc=target-devel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.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