From patchwork Wed Dec 1 08:03:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 370431 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB18426T020165 for ; Wed, 1 Dec 2010 08:04:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753835Ab0LAIDq (ORCPT ); Wed, 1 Dec 2010 03:03:46 -0500 Received: from mail-wy0-f194.google.com ([74.125.82.194]:62889 "EHLO mail-wy0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753628Ab0LAIDo convert rfc822-to-8bit (ORCPT ); Wed, 1 Dec 2010 03:03:44 -0500 Received: by wyb32 with SMTP id 32so2678314wyb.1 for ; Wed, 01 Dec 2010 00:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=dqVJCZ5IscYxCz29Yt7dq/JY8eRI1LDdJfvXILaCSnk=; b=fPaZ1a1myFcCCuiOv6DH2HfumgSM/HWxJq8sYT72x5Io/DM/9EWSY0yaUBETUqCdpn I0JZt2n91AqojOSGpFoIKLDyWFFKZ3psoRYNLV7JVYhvXNbMnU21eOo/EP0gHyulw1IJ GQs4/ovt7/QmN+NlgfgM5fonQuCuSCLHhZ+bI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=bP4KRqjCSeTBZfFJGJ6wft6VenInp8Dx/TDqqOY3nXlMpnQ8hh8gFWxHwwzt24Zytz fY7d3GqtO+BceJ7WYAOVnEUghvEKOKC+CBjRPAjtos8NPOpf1Q+iPzu1jDyNz3KGjKNK axlXokqKE1qSJgYXMNtpMT2fu32ItjxHvNYX4= MIME-Version: 1.0 Received: by 10.216.186.141 with SMTP id w13mr1524724wem.91.1291190623118; Wed, 01 Dec 2010 00:03:43 -0800 (PST) Received: by 10.216.10.3 with HTTP; Wed, 1 Dec 2010 00:03:43 -0800 (PST) In-Reply-To: <20101128114627.GC4499@redhat.com> References: <1290665220-26478-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> <1290665220-26478-6-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> <20101128092857.GA3342@redhat.com> <20101128114627.GC4499@redhat.com> Date: Wed, 1 Dec 2010 17:03:43 +0900 X-Google-Sender-Auth: NcLmTfVVxMQbqODSdZx2DxAXV6E Message-ID: Subject: Re: [PATCH 05/21] virtio: modify save/load handler to handle inuse varialble. From: Yoshiaki Tamura To: "Michael S. Tsirkin" , Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, avi@redhat.com, anthony@codemonkey.ws, aliguori@us.ibm.com, dlaor@redhat.com, ananth@in.ibm.com, psuriset@linux.vnet.ibm.com, vatsa@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, ohmura.kei@lab.ntt.co.jp Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 01 Dec 2010 08:04:02 +0000 (UTC) diff --git a/hw/virtio.c b/hw/virtio.c index c8a0fc6..875c7ca 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -664,12 +664,16 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) qemu_put_be32(f, i); for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) { + uint16_t last_avail_idx; + if (vdev->vq[i].vring.num == 0) break; + last_avail_idx = vdev->vq[i].last_avail_idx - vdev->vq[i].inuse; + qemu_put_be32(f, vdev->vq[i].vring.num); qemu_put_be64(f, vdev->vq[i].pa); - qemu_put_be16s(f, &vdev->vq[i].last_avail_idx); + qemu_put_be16s(f, &last_avail_idx); if (vdev->binding->save_queue) vdev->binding->save_queue(vdev->binding_opaque, i, f); }