From patchwork Thu Jun 30 07:31:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 9206837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3B4760752 for ; Thu, 30 Jun 2016 07:50:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFEC528594 for ; Thu, 30 Jun 2016 07:50:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A44BC285BA; Thu, 30 Jun 2016 07:50:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 308FC28594 for ; Thu, 30 Jun 2016 07:50:53 +0000 (UTC) Received: from localhost ([::1]:47549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIWkO-0005sP-Ag for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Jun 2016 03:50:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIWZ4-0000ox-1G for qemu-devel@nongnu.org; Thu, 30 Jun 2016 03:39:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIWYx-00009P-4P for qemu-devel@nongnu.org; Thu, 30 Jun 2016 03:39:08 -0400 Received: from mga03.intel.com ([134.134.136.65]:32064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIWYw-00009L-Ul for qemu-devel@nongnu.org; Thu, 30 Jun 2016 03:39:03 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 30 Jun 2016 00:39:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,550,1459839600"; d="scan'208";a="997876652" Received: from ll.sh.intel.com (HELO localhost) ([10.239.13.123]) by fmsmga001.fm.intel.com with ESMTP; 30 Jun 2016 00:39:00 -0700 From: Liang Li To: qemu-devel@nongnu.org Date: Thu, 30 Jun 2016 15:31:43 +0800 Message-Id: <1467271903-23812-1-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [PATCH] balloon: Fix failure of updating guest memory status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Liang Li , Ladi Prosek , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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);