From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYESQ-0001Ab-31 for qemu-devel@nongnu.org; Fri, 12 Aug 2016 11:33:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYESL-0006TH-Vs for qemu-devel@nongnu.org; Fri, 12 Aug 2016 11:33:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYESL-0006TB-QQ for qemu-devel@nongnu.org; Fri, 12 Aug 2016 11:33:09 -0400 From: Stefan Hajnoczi Date: Fri, 12 Aug 2016 16:32:58 +0100 Message-Id: <1471015978-1123-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1471015978-1123-1-git-send-email-stefanha@redhat.com> References: <1471015978-1123-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH for-2.7 4/4] virtio-balloon: fix stats vq migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Luiz Capitulino , "Michael S. Tsirkin" , gaudenz@debian.org, Stefan Hajnoczi The statistics virtqueue is not migrated properly because virtio-balloon does not include s->stats_vq_elem in the migration stream. After migration the statistics virtqueue hangs because the host never completes the last element (s->stats_vq_elem is NULL on the destination QEMU). Therefore the guest never submits new elements and the virtqueue is hung. Instead of changing the migration stream format in an incompatible way, detect the migration case and rewind the virtqueue so the last element can be completed. Signed-off-by: Stefan Hajnoczi --- hw/virtio/virtio-balloon.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 5af429a..a8d66b9 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -99,6 +99,16 @@ static void balloon_stats_poll_cb(void *opaque) VirtIOBalloon *s = opaque; VirtIODevice *vdev = VIRTIO_DEVICE(s); + /* After live migration we fetch the current element again */ + if (s->stats_vq_elem == NULL && virtqueue_rewind(s->svq, 1)) { + VirtQueueElement *elem = virtqueue_pop(s->svq, sizeof(*elem)); + + if (elem) { + s->stats_vq_offset = iov_size(elem->out_sg, elem->out_num); + s->stats_vq_elem = elem; + } + } + if (s->stats_vq_elem == NULL || !balloon_stats_supported(s)) { /* re-schedule */ balloon_stats_change_timer(s, s->stats_poll_interval); -- 2.7.4