From patchwork Fri Aug 19 13:39:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 9290355 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 4956B600CB for ; Fri, 19 Aug 2016 13:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39CA4293E6 for ; Fri, 19 Aug 2016 13:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AB0D2941B; Fri, 19 Aug 2016 13:55:25 +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 82AF0293E6 for ; Fri, 19 Aug 2016 13:55:24 +0000 (UTC) Received: from localhost ([::1]:57437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bakGY-0002M6-JO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Aug 2016 09:55:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bakGI-0002KY-FV for qemu-devel@nongnu.org; Fri, 19 Aug 2016 09:55:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bakGE-0002X6-HR for qemu-devel@nongnu.org; Fri, 19 Aug 2016 09:55:06 -0400 Received: from mail-he1eur01on0139.outbound.protection.outlook.com ([104.47.0.139]:41437 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bakGD-0002Wh-Sm for qemu-devel@nongnu.org; Fri, 19 Aug 2016 09:55:02 -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=vOlEAcerWcUyxlQD9BlN1ekBjuBJyTGpt0TORv0NraY=; b=P6Hzl8h/Q8OihprR3VQa14aCwhxGlhAFDCi/iEdATPLEpSgXKJ9XA5gcl/jHZf7ZT241VTPQf5NgOZIVQ8qhvD7SBFWil80iISOdlKFKetKuPyvXUfYKbOJNjFR5X/RBJmliiUtCdQPx8pqnTYJHbDdWK4RNOCq5DQXtSgakom0= 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.549.15; Fri, 19 Aug 2016 13:39:41 +0000 From: Roman Kagan To: Date: Fri, 19 Aug 2016 16:39:21 +0300 Message-ID: <1471613966-7267-3-git-send-email-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471613966-7267-1-git-send-email-rkagan@virtuozzo.com> References: <1471613966-7267-1-git-send-email-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM4PR01CA0021.eurprd01.prod.exchangelabs.com (10.164.74.159) To DB6PR0802MB2469.eurprd08.prod.outlook.com (10.172.251.17) X-MS-Office365-Filtering-Correlation-Id: ae1c9f5f-b646-4b04-1d6e-08d3c8364660 X-Microsoft-Exchange-Diagn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QR2CFRjNxJWYN+PiGVishqNXLCNTahad4p18ow/qM86uSzB9drB0OkNNi6cvT4vrUqGrMXPwZadV5Owe2OhJDtoRNawo+Ru/b4ecylp349jho= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2469; 31:KUTbBSa9zkC08fskFUfpcwEZth4a9zYH8BMd7OJUV876YJ++4Z+suiDAYps0qhDlpkuKhUqkLfaDxEW2Vr1W2a8dYaycA4wKHExBwSms0XV+MC/V7WqP7HKAIhaRt6gFDcS7Ka+iggWjQYPjKVjpnbfqW3JD2acF4omr5QBaMOEK+fZbrqwjSotHcd7q+SxTnNWudaKUx8wwpwDhXY3Gon2zMmuqIggPu6DNXWPguoo=; 4:80KyD0XJxkRGB/CM+D8xreu2oXn878dZuDzsWoIz+e6UFUwk/Sf8IbIDGwJkovnZiqTiahoe3pg71A28E7kERlJCWAp7oGZ6PR6bSLZPf65OEJbF4h8KFkNho8LeZvsdUYISNbLMKp/ltkehh6ktTKVOzxtE6380ooScyukQ560qpLejYnaoDDcK1EvRidj7PbQnaSVko/VNGR7pEof9KaefCkedtQt/JUIqCQQPvzlqi2NQyu2gkM6GIvyDfYtDD6E7Vazoxb7zSb0b2E20XCXRJV3oGJlLVLoIvYPls7r0NEBLHEntNngvyGweS34RqgecinVxP3jza//hKcIHD//UEIxafzDZtbr1QKN5zvE2oO80q++BqWfe1C0m0Zfjvha4XPjUv7Jh/LfrqXkCV65Bs+Cez4MaR0L+11bgu8A= 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)(3002001)(10201501046)(6043046)(6042046); SRVR:DB6PR0802MB2469; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2469; X-Forefront-PRVS: 0039C6E5C5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(33646002)(229853001)(305945005)(7736002)(81156014)(92566002)(8676002)(81166006)(7846002)(48376002)(105586002)(47776003)(66066001)(50466002)(101416001)(2906002)(4326007)(586003)(36756003)(2351001)(106356001)(86362001)(50986999)(76176999)(3846002)(6116002)(77096005)(5003940100001)(19580395003)(69596002)(19580405001)(97736004)(189998001)(68736007)(2950100001)(53416004)(110136002)(42186005)(50226002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0802MB2469; H:rkaganb.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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:syh59e8SxZaaC+00BsvETUU9zdz6jAXEp9Fig/x?= =?us-ascii?Q?yEPV2KfkYs7OqX1JAlQYNL9NsEFw3271s3AJTlBnVDe+RxG65u5pl5Z+iOB9?= =?us-ascii?Q?NbHAOI5qmciEntrTP0OdLCYTSZs2cyZ65lztjePE3pa1PaAAQbZAGQopcIYS?= =?us-ascii?Q?CycndCMLuigHiL1JLL9cC4X++9PeHi/2mrQs5w/KOTU0p9InH3le14FMT78i?= =?us-ascii?Q?w8EU+to9aRDoZfo0jsxaRb4b8T2TEZRXjropSo6zkdk3p6VRweSHygSVG1AM?= =?us-ascii?Q?DTe8KMZ5OT9UpdFtAZmngjhSC4hIzThMfYUJD5rlQlqyJfI0oznglJJ+Qk3q?= =?us-ascii?Q?7RoqeaLf3Fc8XR8LO8YUvQjghfcaLi+ZUra3aTIavpBELQtt0LMIje6y1MVP?= =?us-ascii?Q?D4xSA/CtK5BpfcX1ulr5hMswyj44RPKZnxocS+Qkytg02rftgixi3aQqG5Gh?= =?us-ascii?Q?ab40REbq4GH8H2makigdIaZEebrg5d+jSPIEt8e3tusf+ftt+UpiQx8SKPB6?= =?us-ascii?Q?tkgu8Xi6Wk2ecsxJx3MT7iQb2OyZgSKLyygJhHIJ5M6DZqrjLEu79V8FB29w?= =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pOxfPKQT+hYGU0Ea0Bs2yPEG8vdYrIR0TWnowAwDLqh/OMHcmxR439mJoqWTTQ+fOaNrnwf6RosuvPJRXdl80FH2kpMm99to20R8QrWGUi8bLSfwSaYWGU7UzPfFyEgdQ==; 24:Bj9u/4UMx6LIPx9AWho+bwFsRFeF58Do6gD8DUAIG+xeSGg7Rb8ck7nxhDWJYdVjyzE4LqB4adoilg4tv/nya/3fDpjrAWvWJ5prI0ebGrM=; 7:Th8sMj4nxALL9GLbgd/hlFTu08cefW+awBYqbqfwC1u5hyA59qgvrs+jbahHOT3+5WDgWr/9Dx/5/bD7DmIYQZ4EPqCxGaBXGMwGbPUD+JvKrRUK72854b1oRnb2le3skx5JqRpdzWu3LrY6VwfJtaXw3gcbC95BdI0H/S8QDuwrBHFLeUezZgBBcrPL5feAAQCZJVjlV8r5B99/+wa5x0FzTUQXxh0fQTm96hUw92ytPIuHlRN050SrepK29ZIm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2469; 20:H2W/pHy82fQ/voSyZ1N/ekIAyk5GZ+lKOOpr770nip4CtULhG8bNeuL2kSNdxNY1u05XyYCd5be/M6/nwrst02YAko0ar8lvP5AKkBa6R4OT9HCRiWyEA7zIQrK4hx5t/cj+4hFIn+KQMJb6xZZOevU2f12toG9ZBJuowk8xMJM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2016 13:39:41.8310 (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.0.139 Subject: [Qemu-devel] [PATCH v2 2/6] 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 , 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 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 Cc: Stefan Hajnoczi --- v1 > v2: - added assert in virtio_balloon_receive_stats hw/virtio/virtio-balloon.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 5af429a..fb8784e 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -262,12 +262,8 @@ 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); - } + /* enforced by stats virtqueue depth being 1 */ + assert(!s->stats_vq_elem); s->stats_vq_elem = elem; @@ -443,7 +439,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); }