From patchwork Thu Aug 18 18:27:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 9288735 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 0645A60574 for ; Thu, 18 Aug 2016 23:03:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA95829180 for ; Thu, 18 Aug 2016 23:03:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA59C2919C; Thu, 18 Aug 2016 23:03:01 +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 2C11C29180 for ; Thu, 18 Aug 2016 23:03:01 +0000 (UTC) Received: from localhost ([::1]:54633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baWKy-0001t0-D6 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Aug 2016 19:03:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baWKY-0001rM-Eo for qemu-devel@nongnu.org; Thu, 18 Aug 2016 19:02:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baWKS-0005UM-Fv for qemu-devel@nongnu.org; Thu, 18 Aug 2016 19:02:33 -0400 Received: from mail-ve1eur01on0107.outbound.protection.outlook.com ([104.47.1.107]:11640 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baWKS-0005UI-56 for qemu-devel@nongnu.org; Thu, 18 Aug 2016 19:02:28 -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=2aGHB/VxXHd1dKH2DiYvJeVZKTobRvk6SoOaJXXDg74=; b=RfHAUhAoDVNZE9HfCo+Yn4qNoRUFqUVLEX7ncfDnunhFkmK5X5qVoCZnr1Z3Y/HtJ9fTkRavbvqAPD0uT/TUNXs7wz5g0OdnFG2VZKbsAfHVBY7if+W9cWXJoCXhg9a3HAjeiTLTXGqw1vgXWKl72oXLp7QYFYiS3His79AFgrE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.10) by HE1PR0802MB2476.eurprd08.prod.outlook.com (10.175.34.149) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.9; Thu, 18 Aug 2016 18:28:37 +0000 From: Roman Kagan To: Date: Thu, 18 Aug 2016 21:27:52 +0300 Message-ID: <1471544874-26996-3-git-send-email-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471544874-26996-1-git-send-email-rkagan@virtuozzo.com> References: <1471544874-26996-1-git-send-email-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: VI1PR07CA0121.eurprd07.prod.outlook.com (10.165.229.175) To HE1PR0802MB2476.eurprd08.prod.outlook.com (10.175.34.149) X-MS-Office365-Filtering-Correlation-Id: 5c42ddcc-94c4-4f6a-78f6-08d3c79578f3 X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2476; 2:Hu8+ttYE8Es+a7TjFzRYL41+x+6hHQH0rszf0b2nRTBmskPlqBJymN6OD0/SIOqpyn3YfmikFgxX90OFgpR4hnc4ZaqagTq8jfw+27BTENGGROuzcAYDrHXk7IJdmXqSv/TQN7yIAwgAvCtpfTtMvodgXl6URXQ151eztwOnAH0KvcVEqOkG2NWIqjuj/zKb; 3:CwrwuZgpbrIVXPGbtoayd2Q3zJJYD+jdxhNnV0ep0+zAhfWQXf4E1gOoNQk2Dk3A90d5A6H5PH2ZunsMkOVaFDLrZl4+8IUGF5nhkurLicdPgy5V62TIXpoknkZTh4gg; 25:EQCcWEsTTxDRNMzYlxowBpXknmwab/8wzB6G42YJR/dqw1zxY26SpK5XD7L7pfrspBPNTLN2NM3R9xg2n2cy9LUBdOVa/camkCR4tTIZYTs2hxWUogcKOqrVrubSU1ytmIzQab+WogBcWLqo6G/NiWaxM46oPjqidavGMqqpPbnQrDAgD1uCDewrFq5RUCKWjnjNS34SQynH/zZdCb/hBsX+6rWErwDmOCVC00FLV+0b0FDytjKtoHJP2vMydRq6HLM3JlwBKhw8+S7gUkYypKfmMTYs6fbfbcw47vYgpooB4cfMPK4YpmHvWNbzwttHn1CFw0/3DnIO7IPAo/njoSWkHFqReBGy9ln/Rk0BZaVAbdlMUjkjoTUD0KOxUNrdueZylAkv8PPGQWrk3+EZkwRunwrpPrAyucWbZkw0eaI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0802MB2476; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2476; 31:ZuT5q+vkOAXxqyPVAr1gdW1mWU5Maojuytr8J3j1MqM8EOBb2IS3qrr/pC4h1Fo7eHosCghu9ala+v6fUbKtOuQYQC2vsIbJ54BPugWYkoPpEj0wUSkVHV4tNlYMuYhe+hY4/DaXVAkh7v0ds36cbAHxlL5cJxW56IRKG++WhMDpHJNmy3y1atkhMckn/u71oEqTq0JF58Ohed7/IT14D5kYw4bYI2DPIXexcDtLm08=; 4:LAVU8lBpCbYQvrCPOkhnb+gGoTSSTpHchOEiMxcppX45ahBpf0pp1nBb1zxQFUfkfZ9jLODC4bgy23oxVFOnf0BEtCcT1Sm3TACqpg5lHyUfQIscb1qYHPEr9TmLFdFSpkDN1g/1/LF1x4k9aGTToLV9JPkdY4NXLZ0qAZD3hsk5PKjmipaSo1MBaTrkzUt/PIzKXUzc5hcJPUqjvmdgATPjkbvofsU+3h3vM+NdKAzTF9mzC/IKeqUOuR0GYE1+z36ZbyxqtztLf+XzJn3zOSUCcz3qbeIruQF60D4OhHFatNs+0SzUmXZnh2SfujZGazIohAPX3JmVfP7lgziCc+6DxdniLNUo9sCz/fYmUAgYuL6RQgswsj9b+4lBi03LLnrH8F8Xq/3GdJewPZzfYzpc/n/di7OFg1OyUHA66ZE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6043046)(6042046); SRVR:HE1PR0802MB2476; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0802MB2476; X-Forefront-PRVS: 0038DE95A2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(76176999)(19580405001)(7846002)(7736002)(50466002)(229853001)(50226002)(6116002)(2351001)(33646002)(4326007)(305945005)(47776003)(3846002)(2906002)(586003)(81156014)(8676002)(66066001)(101416001)(42186005)(86362001)(77096005)(81166006)(50986999)(53416004)(68736007)(97736004)(105586002)(5003940100001)(92566002)(189998001)(19580395003)(110136002)(48376002)(69596002)(106356001)(2950100001)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0802MB2476; 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; HE1PR0802MB2476; 23:T8jroVWopmWTXxQPO5qd4I28u8M31Ew1N45CI6/?= =?us-ascii?Q?DzAh25EeY2DzbQEIsGdlcugV73+0XvqBZSsRdCvqAAN5XfjHeRqTUys+q2JC?= =?us-ascii?Q?EimF8x2ix3hB8Qu18k7l25W0J3SV/XV5FTssk5xgmmx8ffCc21vnBMVlkE36?= =?us-ascii?Q?6Ui4P9+FYJRjclC7VxmzPHgU1q8wi7bkZ2zVMpHDOsoi9sIeYuyk4zUFOhQn?= =?us-ascii?Q?QIHeMIs5DcFwbvZkjODgozfeamM4S8PKkeYcTb1bi5zwdQ8mmmZeRmztkE1A?= =?us-ascii?Q?FAJXM5svFS1aj4I568fqw5rA2j1knIC0op+B4Ynt1tBfTi2yeL+Ktk7jWoFY?= =?us-ascii?Q?RwCk1x+R8UixoWNjkYTVEhbhFUIUHSmLJ/yoNhMyeNP2OVQ/WjaOgXNBMHjK?= =?us-ascii?Q?tXfRXT4msDyF71JuohMNsaer9JLoTh9g8b93wpqgBCdOxmjaBh903j0cUSLG?= =?us-ascii?Q?ICiFz5BLrwHNtLZuHMfQcTuynjxuYua8B+ZMltXzT0WnRqr7EuflOT9EhcEY?= =?us-ascii?Q?lyXUc4wh1TFhKVajvr+oebYbjHUUFZcL8k8Y5dmqRPyScamYtTUSQnrJq0S2?= =?us-ascii?Q?qgzbc2CICGStuF2PfRak0nXiF9Ejw/NdmNAFM0fdqG1whwNyhvjHMIsKhNxK?= =?us-ascii?Q?TYnIxmt6UNu2m9os/X77yl8TFpsqGQHI/kNnRF/1mNIGLAuNuFkgqaYzfdjo?= =?us-ascii?Q?79XcOn2KugJvFM+jOH9umzNhsMzLD0XmapilG81zVHx5XQL2tKgFzNa49r/0?= =?us-ascii?Q?zM/hl3CCuCU+odTReTaw9sJx22bqgMNX0A/3R/0mx+bStxUBqG0lyZj1t7Yl?= =?us-ascii?Q?3cJVY8orIrYyrC/9oAVwjCknhPs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R8tbMOz02H8GRTMb/c7+pifrk8Z+p2JoIILTgH6W0287/uU9PcVgaL3plj/OTb1voEb7KMyKDJC6+k9QmS/LOglSOWjnTqn5mGYopp6EngJWPInVjO/yQ6fO0mUkDHvE2y18TN44XrycaaQLFECZFFmKkYKYyD6VCyNRJjQoxw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2476; 20:JipzHPitsRx0YswiJn9z/TCc8rzd9gvz8+sxWUo4q5idTStJ2uQnhiPyro66XCcaRlcMIsX6Suox1QGbtBifl1v9hT9PAAIEtHcGtbodz+Iqrlii2QMogu38VLtvhwxenaXh3VSb1mh4qui8uZ/VnQi87VDpBFErHd5tnWn1o58= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2016 18:28:37.4822 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2476 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.1.107 Subject: [Qemu-devel] [PATCH 2/4] virtio-balloon: make stats virtqueue length 1 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: "Denis V. Lunev" , Ladi Prosek , Roman Kagan , "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 The protocol for virtio-balloon stats virtqueue doesn't allow more than one element in the virtqueue. So, instead of trying to compensate for guest misbehavior if it sends new data before the slot has been released by the host, just define the stats virtqueue length to 1 initially and rely on the generic virtio code to handle overflows. Signed-off-by: Roman Kagan Cc: "Michael S. Tsirkin" Cc: Ladi Prosek --- hw/virtio/virtio-balloon.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 5af429a..0baf4b3 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -262,13 +262,6 @@ static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq) goto out; } - if (s->stats_vq_elem != NULL) { - /* This should never happen if the driver follows the spec. */ - virtqueue_push(vq, s->stats_vq_elem, 0); - virtio_notify(vdev, vq); - g_free(s->stats_vq_elem); - } - s->stats_vq_elem = elem; /* Initialize the stats to get rid of any stale values. This is only @@ -443,7 +436,7 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output); s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output); - s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats); + s->svq = virtio_add_queue(vdev, 1, virtio_balloon_receive_stats); reset_stats(s); }