From patchwork Mon Aug 15 21:32:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 9282295 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 5D8DD60467 for ; Mon, 15 Aug 2016 23:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5269D28E90 for ; Mon, 15 Aug 2016 23:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46BC728EA4; Mon, 15 Aug 2016 23:10:09 +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 F342F28E90 for ; Mon, 15 Aug 2016 23:10:08 +0000 (UTC) Received: from localhost ([::1]:39229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZR1E-0002eV-6G for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Aug 2016 19:10:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQy6-0000IM-P7 for qemu-devel@nongnu.org; Mon, 15 Aug 2016 19:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZQy0-0002kI-O6 for qemu-devel@nongnu.org; Mon, 15 Aug 2016 19:06:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZQy0-0002kE-I7 for qemu-devel@nongnu.org; Mon, 15 Aug 2016 19:06:48 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3840AC0AF3B6 for ; Mon, 15 Aug 2016 23:06:48 +0000 (UTC) Received: from redhat.com (vpn1-4-108.ams2.redhat.com [10.36.4.108]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u7FLWuvi027883; Mon, 15 Aug 2016 17:32:57 -0400 Date: Tue, 16 Aug 2016 00:32:55 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1471296770-7984-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 15 Aug 2016 23:06:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] virtio-balloon: stats vq migration spec compliance 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: Ladi Prosek Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP virtio spec says that devices must not touch VQs before DRIVER_OK is set. Additionally, balloon must not touch stats VQ unless the stats feature bit has been negotiated. Cc: Ladi Prosek Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 65457e9..7189260 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -427,6 +427,7 @@ static void virtio_balloon_vmstate_cb(void *opaque, int running, RunState state) { VirtIOBalloon *s = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(s); if (!running) { /* put the stats element back if the VM is not running */ @@ -436,7 +437,8 @@ static void virtio_balloon_vmstate_cb(void *opaque, int running, s->stats_vq_elem = NULL; } - } else { + } else if (balloon_stats_supported(s) && + (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { /* poll stats queue for the element we may have discarded * when the VM was stopped */ virtio_balloon_receive_stats(VIRTIO_DEVICE(s), s->svq);