All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Cc: "kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
	"qemu-devel\@nongnu.org" <qemu-devel@nongnu.org>,
	Avi Kivity <avi@redhat.com>,
	Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Subject: Re: virtio_blk_load() question
Date: Thu, 18 Mar 2010 08:37:23 +0100	[thread overview]
Message-ID: <m3hboenkr0.fsf@trasno.mitica> (raw)
In-Reply-To: <4BA1AC4A.2070402@lab.ntt.co.jp> (OHMURA Kei's message of "Thu, 18 Mar 2010 13:30:02 +0900")

OHMURA Kei <ohmura.kei@lab.ntt.co.jp> wrote:
> Hi,
>
> I have a question regarding virtio_blk_load().
> (qemu-kvm.git d1fa468c1cc03ea362d8fe3ed9269bab4d197510)
>
> VirtIOBlockReq structure is linked list of requests, but it doesn't seem to be
> properly linked in virtio_blk_load().
> ...
> req->next = s->rq;
> s->rq = req->next;
> ...

You are right.

> In this case, we're losing req, and s->rq always point to be same entry.
> If I'm understanding correctly, s->rq is NULL initially,
> and this would be kept.
>
> Although I'm not sure how these requests should be ordered, if the requests
> should be added to the head of list to restore the saved status by
> virtio_blk_save(), I think the following code is correct.  However, it seems to
> reverse the order of the requests, and I'm wondering whether that is
> appropriate.
>
> Would somebody tell me how virtio_blk_load() is working?

When I ported virtio to vmstate, I was unable to get that list not empty
for more than I tried.  It should be not empty in the case of one error
or similar, but I was not able to reproduce it.

> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index b80402d..267b16f 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -457,7 +457,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
>         VirtIOBlockReq *req = virtio_blk_alloc_request(s);
>         qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem));
>         req->next = s->rq;
> -        s->rq = req->next;
> +        s->rq = req;
>     }
>
>     return 0;

I agree this change is ok/needed.  Notice that my series ( [PATCH 0/9]
Virtio cleanups) that changes it to a QLIST and fixes it.

(althought again, I was never able to get that list with elements at the
time of migration).

Thanks, Juan.

WARNING: multiple messages have this Message-ID (diff)
From: Juan Quintela <quintela@redhat.com>
To: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Cc: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] Re: virtio_blk_load() question
Date: Thu, 18 Mar 2010 08:37:23 +0100	[thread overview]
Message-ID: <m3hboenkr0.fsf@trasno.mitica> (raw)
In-Reply-To: <4BA1AC4A.2070402@lab.ntt.co.jp> (OHMURA Kei's message of "Thu, 18 Mar 2010 13:30:02 +0900")

OHMURA Kei <ohmura.kei@lab.ntt.co.jp> wrote:
> Hi,
>
> I have a question regarding virtio_blk_load().
> (qemu-kvm.git d1fa468c1cc03ea362d8fe3ed9269bab4d197510)
>
> VirtIOBlockReq structure is linked list of requests, but it doesn't seem to be
> properly linked in virtio_blk_load().
> ...
> req->next = s->rq;
> s->rq = req->next;
> ...

You are right.

> In this case, we're losing req, and s->rq always point to be same entry.
> If I'm understanding correctly, s->rq is NULL initially,
> and this would be kept.
>
> Although I'm not sure how these requests should be ordered, if the requests
> should be added to the head of list to restore the saved status by
> virtio_blk_save(), I think the following code is correct.  However, it seems to
> reverse the order of the requests, and I'm wondering whether that is
> appropriate.
>
> Would somebody tell me how virtio_blk_load() is working?

When I ported virtio to vmstate, I was unable to get that list not empty
for more than I tried.  It should be not empty in the case of one error
or similar, but I was not able to reproduce it.

> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index b80402d..267b16f 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -457,7 +457,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
>         VirtIOBlockReq *req = virtio_blk_alloc_request(s);
>         qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem));
>         req->next = s->rq;
> -        s->rq = req->next;
> +        s->rq = req;
>     }
>
>     return 0;

I agree this change is ok/needed.  Notice that my series ( [PATCH 0/9]
Virtio cleanups) that changes it to a QLIST and fixes it.

(althought again, I was never able to get that list with elements at the
time of migration).

Thanks, Juan.

  reply	other threads:[~2010-03-18  7:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18  4:30 virtio_blk_load() question OHMURA Kei
2010-03-18  4:30 ` [Qemu-devel] " OHMURA Kei
2010-03-18  7:37 ` Juan Quintela [this message]
2010-03-18  7:37   ` [Qemu-devel] " Juan Quintela
2010-03-18  9:42   ` OHMURA Kei
2010-03-18  9:42     ` [Qemu-devel] " OHMURA Kei
2010-03-18 12:07     ` Juan Quintela
2010-03-18 12:07       ` [Qemu-devel] " Juan Quintela
2010-03-19  2:53       ` OHMURA Kei
2010-03-19  2:53         ` [Qemu-devel] " OHMURA Kei

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=m3hboenkr0.fsf@trasno.mitica \
    --to=quintela@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=ohmura.kei@lab.ntt.co.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=tamura.yoshiaki@lab.ntt.co.jp \
    /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.