From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bId42-0005N9-JV for qemu-devel@nongnu.org; Thu, 30 Jun 2016 10:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bId3z-0002CZ-V0 for qemu-devel@nongnu.org; Thu, 30 Jun 2016 10:35:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bId3z-0002CB-FV for qemu-devel@nongnu.org; Thu, 30 Jun 2016 10:35:31 -0400 References: <1467271903-23812-1-git-send-email-liang.z.li@intel.com> From: Paolo Bonzini Message-ID: Date: Thu, 30 Jun 2016 16:35:27 +0200 MIME-Version: 1.0 In-Reply-To: <1467271903-23812-1-git-send-email-liang.z.li@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] balloon: Fix failure of updating guest memory status List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liang Li , qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Ladi Prosek On 30/06/2016 09:31, Liang Li wrote: > After live migration, 'guest-stats' can't get the expected memory > status in the guest. This issue is caused by commit 4eae2a657d. > The value of 's->stats_vq_elem' will be NULL after live migration, > and the check in the function 'balloon_stats_poll_cb()' will > prevent the 'virtio_notify()' from executing. So guest will not > update the memory status. > > Signed-off-by: Liang Li > Cc: Michael S. Tsirkin > Cc: Ladi Prosek > Cc: Paolo Bonzini > --- > hw/virtio/virtio-balloon.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c > index 557d3f9..cc6947f 100644 > --- a/hw/virtio/virtio-balloon.c > +++ b/hw/virtio/virtio-balloon.c > @@ -98,13 +98,19 @@ static void balloon_stats_poll_cb(void *opaque) > { > VirtIOBalloon *s = opaque; > VirtIODevice *vdev = VIRTIO_DEVICE(s); > + VirtQueueElement elem = {0}; > > - if (s->stats_vq_elem == NULL || !balloon_stats_supported(s)) { > + if (!balloon_stats_supported(s)) { > /* re-schedule */ > balloon_stats_change_timer(s, s->stats_poll_interval); > return; > } > > + if (s->stats_vq_elem == NULL) { > + virtqueue_push(s->svq, &elem, 0); > + virtio_notify(vdev, s->svq); > + return; > + } > virtqueue_push(s->svq, s->stats_vq_elem, s->stats_vq_offset); > virtio_notify(vdev, s->svq); > g_free(s->stats_vq_elem); > Hi, the right fix is to migrate s->stats_vq_elem if it is not NULL. See how it's done in hw/char/virtio-serial.c's virtio_serial_save_device (save) and fetch_active_ports_list (load). Paolo