From patchwork Thu Sep 1 18:14:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 9309531 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 37AA1607D2 for ; Thu, 1 Sep 2016 18:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 345DB29440 for ; Thu, 1 Sep 2016 18:15:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28937294E6; Thu, 1 Sep 2016 18:15:11 +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.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 35EB729440 for ; Thu, 1 Sep 2016 18:15:09 +0000 (UTC) Received: from localhost ([::1]:38453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfWW4-0001z3-81 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Sep 2016 14:15:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfWVS-0001v0-Lq for qemu-devel@nongnu.org; Thu, 01 Sep 2016 14:14:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfWVL-00035r-Iz for qemu-devel@nongnu.org; Thu, 01 Sep 2016 14:14:29 -0400 Received: from mail-ve1eur01on0116.outbound.protection.outlook.com ([104.47.1.116]:47724 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfWVL-00035O-Al for qemu-devel@nongnu.org; Thu, 01 Sep 2016 14:14:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=B8yCyTf5q5MgQ/GsnW5TkK4BqZWnGbi1HVs2jbjqhUo=; b=imH1d0dBfOLbT85/KeMBaIzJGe6RtfN81yGh6zk223etgH6AFZb+N2P3z3a1q+kf0yQ8FvHp5V1iw4cPH8WGrVM+27aKSyN5dGAtqnCxR0sClY7y9+tmLOpDdhKaVbB+lvSG7ocJV7HMTRImNbPEXs+z+UJ2vE7p0YDdLyZq+hk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.10) by DB6PR0802MB2469.eurprd08.prod.outlook.com (10.172.251.17) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.13; Thu, 1 Sep 2016 18:14:20 +0000 From: Roman Kagan To: Date: Thu, 1 Sep 2016 21:14:00 +0300 Message-ID: <1472753640-18375-3-git-send-email-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472753640-18375-1-git-send-email-rkagan@virtuozzo.com> References: <1472753640-18375-1-git-send-email-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM5PR0501CA0039.eurprd05.prod.outlook.com (10.164.187.49) To DB6PR0802MB2469.eurprd08.prod.outlook.com (10.172.251.17) X-MS-Office365-Filtering-Correlation-Id: 2de08bfe-7ffa-40a7-4f47-08d3d293cbe5 X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2469; 2:CpKwtvJxapXqA2PZ1eDSbvD1hzbr1XSxYURJA/5tHJCerE5mOJ/mFsKVm3PNAFnrzc/FvX8l/YyU+FH2o6wRbXKsJkO4znnSOqPd9bjclfW7ie6etYP/1/d3btHNUG+6u+6Fitifcp8JsUBU1/sWs71/hOJU3xt0lzAdSpHxZR6sxJ/mymohWEWlhPPnciJl; 3:+Iefg3eMylelnJbmE867Q1xunp2nyI8gDbves689OPWw8INX5XM96SmSfWdcA7+i2zOcuBhB8DjWszRgDW6wue5GmkclUqW019eNpeWBiVrO4f/2WbMNLvaWWFgwl5rI; 25:gc7wf3R4qzuEUbY1lDLHgGraXkcew5aRfQhgD64Fk6dRL04wD7JM64mUHIMboe4xqicpLkHK/siici2m9QhL8YxOlDgSFBgfeXKiiGtMLfVFXQ6MW8NeiRqwXhRMobLaMkogEuPbi8ADrzXxAM1tbpKVpqJAKw0F63esW4RyqcFKEIKBo5k7+BYpGHg8A6xlOmHyG8zlW3kFcJsnCw0BDIFKVBXmWmNp/1UokGHi+witWKove3DHa1bJLUlokaHHHjJIPptRGl8VIXQGHLebcpSPMqLgXZd0Hl507m8nmUYIBBsmemaaUKHn03/nBeUjxdD+yjVS8bE8XHywzDRl443IEubTzo+OF4O5uQI+Byo6plblH01Dh679KaF5CiDgiNyKc3rNgUOlu8wBghzg9PBhM9o7GRLe9dBxxq/97a8= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0802MB2469; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2469; 31:rvBEsCsDV/MPX4lqyd8LR6tVSIeKPdpMzuub6QbDZnm91i3QG3Y8D4+Ltm2Onkt9xUXQIlXxJnMdEN43vTHM4m4RyG9BjXWyRl590jBVyaew2aFzgb9cChq+KIGBG1TohMbFkI4W6TKe+18fG/9oyfbu3ASHKqfJbuP5kTRY0j8tCZnAINKJzVULRMWvMspU2f+mshODQej61dECZeOXY5ERNq+QHDbd8HiaSMf5pck=; 4:5x2pNKsaptFaAl+akl8+B7zuN06Fdc4jzUKb4HVxzhWpLHMpLIOhRmY1JdpwiYiTkJAMjIbDgtMxS3JaN9H0xicd0ulqoaSUHPh285TQCgGqK5lIFZxEb45MNkltUDXVgqgpiXrsrSvAy2XA1imzhomxUyB6gdXsgzkBKRgrkjiSiRadBkyWDiSnVQUw6WHLuM8wnHzjJy8njOGzI/y+8hEz2KbBA+4h0BViw7/N2JE5s+AwMJ+qOkmhCzxjgFxOxdDA+eX1n7i2K4xicAxCtgX2VtM4hcwiLaNr4Chb1GDxZcuiOq8IocHiNzGboV3HFh+4zPUckwzaLJwzsOYcgZkQxZe1E8KDBrtonRwIuXIJ0e5VK31Z0+zXb/+2maCZQT7nHQSpAspdPiWO8Ff83CoutNVCllqyDE06HJ2JP6tqK35uebT5sNFFMusNYlXWOEciZB66m29ii9T+pxIGfQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6042046)(6043046); SRVR:DB6PR0802MB2469; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2469; X-Forefront-PRVS: 0052308DC6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(101416001)(92566002)(4326007)(305945005)(7846002)(5003940100001)(69596002)(50226002)(50466002)(8676002)(19580405001)(97736004)(36756003)(81156014)(2906002)(68736007)(66066001)(81166006)(47776003)(189998001)(48376002)(7736002)(5660300001)(229853001)(76176999)(2351001)(575784001)(86362001)(6116002)(2950100001)(42186005)(19580395003)(3846002)(53416004)(586003)(110136002)(106356001)(50986999)(77096005)(33646002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0802MB2469; H:rkaganb.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0802MB2469; 23:qDSkmAJJbQaghp0spv4V2/cUzZ5mYfj0yLx8d5s?= =?us-ascii?Q?2S0uRJQgH9edg4E4W529GoaS0kv0WAM+SGbzpFVbqTt/X1e1j/YBTPyh07Az?= =?us-ascii?Q?cV4/CPbT1xKfl2aCQwRKKXVgQ9+MSpHBzHVivRQLa2gDkjw5TBqhgbDWax6G?= =?us-ascii?Q?xvgiTFG2mf+egx5/iit0/WtXTVl45UpN9105fWYD5A44m2oMa5pK4izi2e9n?= =?us-ascii?Q?K82bI4D8A7C6xiHAxtr5FmKH9tSWiK44WZnvrseDSuCHXCxE/nZN89Vibeou?= =?us-ascii?Q?m8xtL8D4EneIh0aXVRNeKszJVKGFhG2rpCT8ibb1ertynEAzDJL8woR9Rbx3?= =?us-ascii?Q?Q03G9eAYgtQkMU6cBfMxeiRLYOV9NYLAb1KiwN1P1NxPLPg8FpqXwgl/arGP?= =?us-ascii?Q?FwUB72UILpxv+xhCEreRqEj3vrofrPupseQLv2/NP59EyVhY08XuaVK2DFis?= =?us-ascii?Q?4AnDo7Qs0cjWxIAMSgAAivUjvZSZfKgB3bTKiGtlecQ8KXPafSJkRGxdDpkZ?= =?us-ascii?Q?XFMqfgmS5LN1/5ScfqYLVzWjspcnfMzTfHKyGprQwvpMQ4GimpQEFxeEwSKa?= =?us-ascii?Q?R2h573TXouTi8Bvn9O5XDeFdcN0e86je5PfwNBXh3MyUpxbipPjZfumq3Z+a?= =?us-ascii?Q?tOjDn4eAVJgMmzSx7YMjLQsYkbyKWuoG7b5M6zoEgB+s0PHA2VuRpvF74Eye?= =?us-ascii?Q?1YMporlyTv2zgnoOFu2f9KeIOBfqje0JHsndLyxf1jG0ORhIuXBeNJtfW/4d?= =?us-ascii?Q?IWCanafz/9Cp3reARHF9jkQkcxr6ElbuDGdMHuT1mpqbgeP5s5fOCsu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Jg52B1c=; 7:2lx4HM/mntb4IclnUc1qIhPUya+WyKkRnbbP1xJUx94zdzyig5QTsCikYasOAAffLLr3kergayxfcuOGD93joDVJQAylRMxg+q5gFS1WTPETgUVJnwpolcG4Y5y7yaSbSI6ovS3XU6AnxZKFjZwdEQI2iH/MVnCa4vrGGCK/p2aS9XRQ958tpXbNqrT49Yt+MJPnO3bmDS3GArVDvH/Qd9qBjW63vXmH9zK4rhLNRfKjDDmr6VEx13xX35fErrbZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2469; 20:fmW/GlV2891NfjrfPRuk1o8R1v08q7/9yiJo/1ACRBNmoY6CsITTUXzUpnf7HpgekonC1hSQd6AXb3zM3Dw2EYbTNObfdwXPHTkOV1M0O4Cptv8mZoXRx9aVLa/JuHAPLyZNOpqTlKAN6NRylvQCc+u4fonkQF5YZvuIM2ylTl0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2016 18:14:20.7376 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2469 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.1.116 Subject: [Qemu-devel] [PATCH 2/2] virtio-balloon: resume collecting stats on vmload 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 , Roman Kagan , Stefan Hajnoczi , "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 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 Cc: "Michael S. Tsirkin" Cc: Ladi Prosek Cc: Stefan Hajnoczi --- 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 = {