From patchwork Sat May 6 12:43:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 9714713 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 21D966038F for ; Sat, 6 May 2017 12:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AB6328635 for ; Sat, 6 May 2017 12:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F347C28677; Sat, 6 May 2017 12:44:19 +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 9509A28667 for ; Sat, 6 May 2017 12:44:19 +0000 (UTC) Received: from localhost ([::1]:51345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6z4M-0004KZ-MC for patchwork-qemu-devel@patchwork.kernel.org; Sat, 06 May 2017 08:44:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6z3S-0004K7-Lu for qemu-devel@nongnu.org; Sat, 06 May 2017 08:43:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6z3R-0003Wc-T9 for qemu-devel@nongnu.org; Sat, 06 May 2017 08:43:22 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:40570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6z3R-0003Vj-N6; Sat, 06 May 2017 08:43:21 -0400 Received: from [2001:bc8:30d7:120:9bb5:8936:7e6a:9e36] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1d6z3P-00035F-W3; Sat, 06 May 2017 14:43:20 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.89) (envelope-from ) id 1d6z3O-00065a-MI; Sat, 06 May 2017 14:43:18 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Sat, 6 May 2017 14:43:12 +0200 Message-Id: <20170506124314.23354-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:bc8:30d7:100::1 Subject: [Qemu-devel] [PATCH 1/3] hw/block: Introduce rotational qdev property 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: Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Paolo Bonzini , John Snow , Aurelien Jarno Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The Linux kernel uses different I/O scheduler depending if the block device is a rotational device or not. Also it uses rotational devices to add entropy to the random pool. This patch add a rotational qdev property so that the block device can be configured as a rotational device or a non-rotational device. Default to true to not change the default behavior. Signed-off-by: Aurelien Jarno Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- blockdev.c | 4 ++++ include/hw/block/block.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 4d8cdedd54..c914420641 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4037,6 +4037,10 @@ QemuOptsList qemu_common_drive_opts = { .name = BDRV_OPT_READ_ONLY, .type = QEMU_OPT_BOOL, .help = "open drive file as read-only", + },{ + .name = "rotational", + .type = QEMU_OPT_BOOL, + .help = "rotational drive (off, on)", }, THROTTLE_OPTS, diff --git a/include/hw/block/block.h b/include/hw/block/block.h index f3f6e8ef02..304a579eca 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -27,6 +27,7 @@ typedef struct BlockConf { uint32_t cyls, heads, secs; OnOffAuto wce; bool share_rw; + bool rotational; BlockdevOnError rerror; BlockdevOnError werror; } BlockConf; @@ -56,7 +57,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) _conf.discard_granularity, -1), \ DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ ON_OFF_AUTO_AUTO), \ - DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false) + DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false), \ + DEFINE_PROP_BOOL("rotational", _state, _conf.rotational, true) #define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \