From: Roman Kagan <rkagan@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: Roman Kagan <rkagan@virtuozzo.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Ladi Prosek <lprosek@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] virtio-balloon: resume collecting stats on vmload
Date: Thu, 1 Sep 2016 21:14:00 +0300 [thread overview]
Message-ID: <1472753640-18375-3-git-send-email-rkagan@virtuozzo.com> (raw)
In-Reply-To: <1472753640-18375-1-git-send-email-rkagan@virtuozzo.com>
Upon save/restore virtio-balloon stats acquisition stops. The reason is
that the in-use virtqueue element is not saved, and upon restore it's
not released to the guest, making further progress impossible.
Saving the information about the used element would introduce
unjustified vmstate incompatibility.
However, the number of virtqueue in-use elements can be deduced from the
data available on restore (see bccdef6b1a204db0f41ffb6e24ce373e4d7890d4
"virtio: recalculate vq->inuse after migration").
So make the stats virtqueue forget that an element was popped from it,
and start over. As this tackles the problem on the "load" side, it
is compatible with the state saved by earlier QEMU versions.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Ladi Prosek <lprosek@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/virtio/virtio-balloon.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 5af429a..8660052 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -406,7 +406,13 @@ static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f)
static int virtio_balloon_load(QEMUFile *f, void *opaque, size_t size)
{
- return virtio_load(VIRTIO_DEVICE(opaque), f, 1);
+ VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
+ VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
+ int ret = virtio_load(vdev, f, 1);
+ /* rewind needs vq->inuse populated which happens in virtio_load() after
+ * vdev->load */
+ virtqueue_rewind(s->svq);
+ return ret;
}
static int virtio_balloon_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -468,6 +474,18 @@ static void virtio_balloon_device_reset(VirtIODevice *vdev)
}
}
+static void virtio_balloon_set_status(VirtIODevice *vdev, uint8_t status)
+{
+ VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
+
+ if (vdev->vm_running && balloon_stats_supported(s) &&
+ (status & VIRTIO_CONFIG_S_DRIVER_OK) && !s->stats_vq_elem) {
+ /* poll stats queue for the element we may have discarded when the VM
+ * was stopped */
+ virtio_balloon_receive_stats(vdev, s->svq);
+ }
+}
+
static void virtio_balloon_instance_init(Object *obj)
{
VirtIOBalloon *s = VIRTIO_BALLOON(obj);
@@ -505,6 +523,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
vdc->get_features = virtio_balloon_get_features;
vdc->save = virtio_balloon_save_device;
vdc->load = virtio_balloon_load_device;
+ vdc->set_status = virtio_balloon_set_status;
}
static const TypeInfo virtio_balloon_info = {
--
2.7.4
next prev parent reply other threads:[~2016-09-01 18:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 18:13 [Qemu-devel] [PATCH 0/2] virtio-balloon: resume collecting stats on vmload Roman Kagan
2016-09-01 18:13 ` [Qemu-devel] [PATCH 1/2] virtio: add virtqueue_rewind Roman Kagan
2016-09-01 18:14 ` Roman Kagan [this message]
2016-09-01 19:26 ` [Qemu-devel] [PATCH 2/2] virtio-balloon: resume collecting stats on vmload Michael S. Tsirkin
2016-09-02 7:21 ` Roman Kagan
2016-09-02 22:53 ` Michael S. Tsirkin
2016-09-05 8:02 ` Roman Kagan
2016-09-06 1:45 ` Michael S. Tsirkin
2016-09-06 6:50 ` Roman Kagan
2016-09-06 10:15 ` 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=1472753640-18375-3-git-send-email-rkagan@virtuozzo.com \
--to=rkagan@virtuozzo.com \
--cc=lprosek@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--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 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).