From patchwork Wed Sep 4 21:00:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11131789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3123914F7 for ; Wed, 4 Sep 2019 21:52:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07A4B20828 for ; Wed, 4 Sep 2019 21:52:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Mik7EO0F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07A4B20828 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:40556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5dCc-0003X6-6x for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Sep 2019 17:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56081) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5cOy-0006Jj-E8 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5cOt-0007bI-1e for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:16 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:52304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5cOp-0007Wm-Hf; Wed, 04 Sep 2019 17:01:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567630868; x=1599166868; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NLbSy76QN5WmjCTE4UUALAVdKCC0nk7AnaWJw993qa0=; b=Mik7EO0F5CBFzOfC+bo+dQeRaO49vLLSeOlVu1jMunND9TbBGJOY3Ta/ 4PPlO4NoX8IeBWo3s6yhvFotzPh/d7GmIQzQ5XlZGKbOdrMeGAcmMiayt rylZ2N3CfS2og9qVhfup6+hDGA+W7GLRnwB58Z9t7p5VI+kUzGe0QTy8v SdVso8lnctNyNlbesen0Rf/CWPRhas8IMbe12jyvJ4V8AwPSukkf6hu4Y hz5VRsPRa57/w/jogbSsi58J52eO6yRzCXIqQgAAOpnWS3B7W47B9Nc8i CJR50zxpF+D3LV9SRBCmCmYsZs5Jj3zq16uNbKw2YBQ9WPi64qyaFvu+W w==; IronPort-SDR: oaVdDQfaYevYGrA5uKZKXSb8dEPaCbvwPkvIOdsBkDE0eE/ZxJZ1cydqHyl/hA0H//up4qNWB+ Sabzg4nWwYGaWUjnD+byv2BgjoD+RTD2+vMVpH2WQ4FR8AnJFyUcK/I60knlIfWD2riJFOT2LJ YrkPG5a+jBhNbAQXmp27jy5f6bQ0evPO1PyujLyXs29dvYGszW5Bk/6unL7Z1etlwaw/6lbt0s aPwBcfl9ITamBx3TiZuiiSIliAPhXCVogO8uOr0WSib9YWfWZHp0GYKFbklqSmPEJSe2f27o2i CgI= X-IronPort-AV: E=Sophos;i="5.64,468,1559491200"; d="scan'208";a="117451660" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 05:01:03 +0800 IronPort-SDR: rJvOILvfiz/apJKTGKEwxa/KctgWXLyXTnTZFtimTCFpgOyBBKgtvT4wl9Q1n6XkB7WeMDvgHk eCHPhnkjTLgecUdkrvCD4DSYI1Pn/o+vZOyLsv8Wuo/IBQhVuDOPhl0k7KIPc9e2shhUFs0v9O MTd2DsAEuYmjM87LpY9rzxaEdxBBw4PWf51N79OYqYL7kjr383SFXU9OdH2tdZzfX2GS+TfAjB EyCuhZtfS/ZJLk4325byURDrXXSZxyQjegKF2Qqgl+yjndr+ljghkKylBVnfeMQHhVInHEgJUm 8Six/4xLZWG5QpiQi7ERXvmR Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 13:58:00 -0700 IronPort-SDR: IbDXOoxcT3kKpx+XY8g/ZupGR7ax4CoqzReY9KPDfwQ6w94lL6D6mfGeTxOr2ibsXnjNBGWg5b YN3zFixs4gAy/Qmog9dgOjY60cpqbeV3z7U9e39GIf7Zg85jR+YY8rl32cxb6WjPLjSx/xyNe+ HBVBJ9l5QjeQFU3xLUx/+bK7WwcofdMarux/WNC2quf/nV0YVfrIlL5NxcJunmquQaDdJ9uN0C 0KL/rGvBdNgcfBFCg8Ye5N3oJB2Zy54DrGq7XlsTWx+5gX6sMPFd0C87no5jqaLJDZoWSZF+7i BXA= WDCIronportException: Internal Received: from dhcp-10-88-173-181.hgst.com ([10.88.173.181]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 14:01:02 -0700 From: Dmitry Fomichev To: Paolo Bonzini , Kevin Wolf , Max Reitz , "Michael S . Tsirkin" , Stefan Hajnoczi , John Snow Date: Wed, 4 Sep 2019 17:00:57 -0400 Message-Id: <20190904210100.10501-2-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904210100.10501-1-dmitry.fomichev@wdc.com> References: <20190904210100.10501-1-dmitry.fomichev@wdc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v6 1/4] block: Add zoned device model property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fomichev , Alistair Francis , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This commit adds Zoned Device Model (as defined in T10 ZBC and T13 ZAC standards) as a block driver property, along with some useful access functions. A new backend driver permission, BLK_PERM_SUPPORT_HM_ZONED, is also introduced. Only the drivers having this permission will be allowed to open host managed zoned block devices. No code is added yet to initialize or check the value of this new property, therefore this commit doesn't change any functionality. Signed-off-by: Dmitry Fomichev --- block.c | 15 +++++++++++++++ include/block/block.h | 19 ++++++++++++++++++- include/block/block_int.h | 3 +++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 874a29a983..69f565e1e9 100644 --- a/block.c +++ b/block.c @@ -4679,6 +4679,21 @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) *nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors; } +BdrvZonedModel bdrv_get_zoned_model(BlockDriverState *bs) +{ + return bs->bl.zoned_model; +} + +bool bdrv_is_hm_zoned(BlockDriverState *bs) +{ + /* + * Host Aware zone devices are supposed to be able to work + * just like regular block devices. Thus, we only consider + * Host Managed devices to be zoned here. + */ + return bdrv_get_zoned_model(bs) == BDRV_ZONED_MODEL_HM; +} + bool bdrv_is_sg(BlockDriverState *bs) { return bs->sg; diff --git a/include/block/block.h b/include/block/block.h index 124ad40809..28d065ed80 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -271,18 +271,33 @@ enum { */ BLK_PERM_GRAPH_MOD = 0x10, + /** + * This permission is required to open host-managed zoned block devices. + */ + BLK_PERM_SUPPORT_HM_ZONED = 0x20, + BLK_PERM_ALL = 0x1f, DEFAULT_PERM_PASSTHROUGH = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED - | BLK_PERM_RESIZE, + | BLK_PERM_RESIZE + | BLK_PERM_SUPPORT_HM_ZONED, DEFAULT_PERM_UNCHANGED = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH, }; char *bdrv_perm_names(uint64_t perm); +/* + * Known zoned device models. + */ +typedef enum { + BDRV_ZONED_MODEL_NONE, /* Regular block device */ + BDRV_ZONED_MODEL_HA, /* Host-aware zoned block device */ + BDRV_ZONED_MODEL_HM, /* Host-managed zoned block device */ +} BdrvZonedModel; + /* disk I/O throttling */ void bdrv_init(void); void bdrv_init_with_whitelist(void); @@ -359,6 +374,8 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, BlockDriverState *in_bs, Error **errp); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); +BdrvZonedModel bdrv_get_zoned_model(BlockDriverState *bs); +bool bdrv_is_hm_zoned(BlockDriverState *bs); void bdrv_refresh_limits(BlockDriverState *bs, Error **errp); int bdrv_commit(BlockDriverState *bs); int bdrv_change_backing_file(BlockDriverState *bs, diff --git a/include/block/block_int.h b/include/block/block_int.h index 0422acdf1c..928cbae9a5 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -635,6 +635,9 @@ typedef struct BlockLimits { /* maximum number of iovec elements */ int max_iov; + + /* Zoned device model. Zero value indicates a regular block device */ + BdrvZonedModel zoned_model; } BlockLimits; typedef struct BdrvOpBlocker BdrvOpBlocker; From patchwork Wed Sep 4 21:00:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11131839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B5F81399 for ; Wed, 4 Sep 2019 22:10:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D6DF20820 for ; Wed, 4 Sep 2019 22:10:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="AKe/Oq4A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D6DF20820 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:40892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5dTd-000258-BH for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Sep 2019 18:10:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5cOy-0006Jh-EH for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5cOt-0007bC-0Y for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:16 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:52308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5cOp-0007X8-EZ; Wed, 04 Sep 2019 17:01:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567630867; x=1599166867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LPK5dv7NDBXIbuHf7ST8MYcA/NaQLO9UasvmcvccZu0=; b=AKe/Oq4A8aSkJR/PD5brS3TKiL5bkbRrPPWTlKkhEr5SMLYJrZODy1pq 2kwPLhw5oFxwNdTUYFGYu1bIeFKY4xNLlt3ecid9EXKFL03Om+I+RjlBQ 7A5FM6AyKrKlPWsy3zDJFCMeHukk2/Mja/oqcpbUTPYeKqEdLJlPgfeGT Cf/ETlNX4DRVms2GNVGRXAnLUnmjwHfZImY7hveH06Oztf6zqJ4eANzld fOiOo4tnA5G8eX529cCxuRuT/LgP5ztDqO0Fkrwte1vsJyre6qaHmpyW8 SmSq6nZsDpimjZt+s8gapbGfoagMAzTGdNTOF8bXiGIyW78lEP2A5mUb7 Q==; IronPort-SDR: 2R7GuYyY6Tuj6dacHV55eIMJnzBgsRLxpq+zyprLLsrBpe5NcaRPhnSKc8MH+4/QFALI9x5hhR lDzDPtb/oLY0B545h0eYf+ir4/A6RAtP9dtO+FG/eeR4WEXCmJ9j0Yxjq1XCjt7Qc8CwUuEp0V OicX4bUnxVxEejKN42JUlB8kK6RpQBObTQZMMcLIfdtc0BcYUNt1/nFPjPOhDLIwGzQqrY5QMG 4YWfp/Asl0GC79phfw8ZuBAoxFhn6OH8g2Erh5g9mo7pQwhhsjDqiOomO5bcRahK4Dz2Lah8u4 RSs= X-IronPort-AV: E=Sophos;i="5.64,468,1559491200"; d="scan'208";a="117451661" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 05:01:04 +0800 IronPort-SDR: HVnHIv23UbwaJZt+pgfCJYhBmf30iHrQXV+/sbFdXHzPue5hG2monWpgJIVXJyFC3DrattTv3s PNa+xOwHqL64IqPVTvKfL7sSViOroQyxOhUisWYNjiP/sbW2tJYfuHAGeX2llmNPW8piR1yeZP 5veBR6KLBZgyH5a+oE9AFUHqRM0ACJG0p78Bzi1kd9Oope9vPofomZvIQeVeWJb6g8FR5V93IK jJb+7VBJ3WF/52vw2HYWZVdF6GODE617g89mUV0up2uSdbA6CxgGno/hojmHl34CjdZZ4faEhd +nIutWjbpX5Zb8DRm3sGvyZY Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 13:58:01 -0700 IronPort-SDR: y9e8+neQLroy0eQNSwHL/xZOw84PdorXa1Ip0129/hx1itYP55WMHycJhhPVwHB2cbD9fQCaMt Agkz8DmK7wCVqN8uO3SM9xd7cSU6Um1y1EhAD4Exl1n8be9JKHeItOJSy5CzTAMg/SO02L+7fw zJlfzwjccnkEH2EbzJae4Ly1RDIwEiO1sFKCl6O5h/Cb9zhn0whylWTbQkenlXP+I4yt49rMIH VmowHurfx+qhVG0khK0vuhdUpR4l6Y2HseifEXNve437cnMYCuxuViHgJDc0ni/iH2kKs26Faa OU4= WDCIronportException: Internal Received: from dhcp-10-88-173-181.hgst.com ([10.88.173.181]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 14:01:03 -0700 From: Dmitry Fomichev To: Paolo Bonzini , Kevin Wolf , Max Reitz , "Michael S . Tsirkin" , Stefan Hajnoczi , John Snow Date: Wed, 4 Sep 2019 17:00:58 -0400 Message-Id: <20190904210100.10501-3-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904210100.10501-1-dmitry.fomichev@wdc.com> References: <20190904210100.10501-1-dmitry.fomichev@wdc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v6 2/4] raw: Recognize zoned backing devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fomichev , Alistair Francis , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The purpose of this patch is to recognize a zoned block device (ZBD) when it is opened as a raw file. The new code initializes the zoned model propery introduced by the previous commit. This commit is Linux-specific as it gets the Zoned Block Device Model value (none/host-managed/host-aware) from sysfs on the host. In order to avoid code duplication in file-posix.c, a common helper function is added to read values of sysfs entries under /sys/block//queue. This way, the existing function that reads the value of "max_segments" entry and the the new function that reads "zoned" value both share the same helper code. Signed-off-by: Dmitry Fomichev --- block/file-posix.c | 75 ++++++++++++++++++++++++++++++++++++++-------- block/io.c | 5 ++++ 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index fbeb0068db..c7e1aff6eb 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1067,15 +1067,13 @@ static int sg_get_max_transfer_length(int fd) #endif } -static int sg_get_max_segments(int fd) +static int hdev_read_blk_queue_entry(int fd, const char *key, + char *buf, int buf_len) { #ifdef CONFIG_LINUX - char buf[32]; - const char *end; char *sysfspath = NULL; int ret; int sysfd = -1; - long max_segments; struct stat st; if (fstat(fd, &st)) { @@ -1083,23 +1081,45 @@ static int sg_get_max_segments(int fd) goto out; } - sysfspath = g_strdup_printf("/sys/dev/block/%u:%u/queue/max_segments", - major(st.st_rdev), minor(st.st_rdev)); + sysfspath = g_strdup_printf("/sys/dev/block/%u:%u/queue/%s", + major(st.st_rdev), minor(st.st_rdev), key); sysfd = open(sysfspath, O_RDONLY); if (sysfd == -1) { ret = -errno; goto out; } do { - ret = read(sysfd, buf, sizeof(buf) - 1); + ret = read(sysfd, buf, buf_len - 1); } while (ret == -1 && errno == EINTR); if (ret < 0) { ret = -errno; - goto out; } else if (ret == 0) { ret = -EIO; + } +out: + if (sysfd != -1) { + close(sysfd); + } + g_free(sysfspath); + return ret; +#else + return -ENOTSUP; +#endif +} + +static int sg_get_max_segments(int fd) +{ +#ifdef CONFIG_LINUX + char buf[32]; + const char *end; + int ret; + long max_segments; + + ret = hdev_read_blk_queue_entry(fd, "max_segments", buf, sizeof(buf)); + if (ret < 0) { goto out; } + buf[ret] = 0; /* The file is ended with '\n', pass 'end' to accept that. */ ret = qemu_strtol(buf, &end, 10, &max_segments); @@ -1108,22 +1128,45 @@ static int sg_get_max_segments(int fd) } out: - if (sysfd != -1) { - close(sysfd); - } - g_free(sysfspath); return ret; #else return -ENOTSUP; #endif } +static BdrvZonedModel hdev_get_zoned_model(int fd) +{ +#ifdef CONFIG_LINUX + char buf[32]; + BdrvZonedModel zm = BDRV_ZONED_MODEL_NONE; + int ret; + + ret = hdev_read_blk_queue_entry(fd, "zoned", buf, sizeof(buf)); + if (ret < 0) { + goto out; + } + + buf[ret - 1] = '\0'; /* replace the newline character with NULL */ + if (strcmp(buf, "host-managed") == 0) { + zm = BDRV_ZONED_MODEL_HM; + } else if (strcmp(buf, "host-aware") == 0) { + zm = BDRV_ZONED_MODEL_HA; + } + +out: + return zm; +#else + return BDRV_ZONED_MODEL_NONE; +#endif +} + static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVRawState *s = bs->opaque; + int ret; if (bs->sg) { - int ret = sg_get_max_transfer_length(s->fd); + ret = sg_get_max_transfer_length(s->fd); if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) { bs->bl.max_transfer = pow2floor(ret); @@ -1133,6 +1176,12 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) if (ret > 0) { bs->bl.max_transfer = MIN(bs->bl.max_transfer, ret * getpagesize()); } + + } + + ret = hdev_get_zoned_model(s->fd); + if (ret >= 0) { + bs->bl.zoned_model = ret; } raw_probe_alignment(bs, s->fd, errp); diff --git a/block/io.c b/block/io.c index 0fa10831ed..147c320061 100644 --- a/block/io.c +++ b/block/io.c @@ -157,6 +157,11 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) return; } bdrv_merge_limits(&bs->bl, &bs->file->bs->bl); + + /* Propagate zoned model */ + if (!bs->probed) { + bs->bl.zoned_model = bs->file->bs->bl.zoned_model; + } } else { bs->bl.min_mem_alignment = 512; bs->bl.opt_mem_alignment = getpagesize(); From patchwork Wed Sep 4 21:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11131829 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F73214F7 for ; Wed, 4 Sep 2019 21:57:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22B1520828 for ; Wed, 4 Sep 2019 21:57:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="jwxARo6y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22B1520828 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:40622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5dHN-0000ma-SV for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Sep 2019 17:57:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56076) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5cOy-0006Jf-DV for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5cOt-0007bq-N2 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:16 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:52300) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5cOp-0007Va-Mv; Wed, 04 Sep 2019 17:01:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567630868; x=1599166868; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OnXlkFcTPYgqEfiUU2UuIQATvEj+6IvGP2VEZxsujN4=; b=jwxARo6yRjklusEC/Vc67Xeek9l9xNH/lRCMT2+7oYbUtgrExzfjBVwL hjTbYyIyfrvhRPY+xCO2PNq8JaKqjouOtOl/ONbgpLotoBWHvv4gDLkCj eGedgNC+VOLBGr12lI6tznVgmYmvYIOnf6Xq8HqTK5IauCXGMKNNF2+cI 4klEXTGmhVz4Oy6M+ebd8lsY3QvoVSfakIE03HobHNxWcxL1IJIrozScO XDWcKC83fHTguSAJjSzXy4aybXnIEqU3KGuQNzDyz85sT6EIT1UHqofbG Z429mHy1DoSDqKw7UNF5U9VQxNWRvhedQOnQ/AU3z2dGSBCvnrBcBNDhd w==; IronPort-SDR: WbHX3yCigadLrHQfGXOqAlhN2k2m3yMr9LefBeFmVa6/ZVjzT3CKw2lpIlX+AexisDlEy1iP/q nWNJVG+QBJaEvMzO2JoL0HbIXgj/JZQcnJtP6LHmbeU3KfNRJ9iEIKDVZewQ7XcRRCV+awvNml BIITs/SUCgEPnvTBKJErtxBM1afAoQ+W4Y6ErOgVD+sKOf/kg8NLhB1Yy/84CxZ/xmvll5++2S Bq3b1Vxzzzuej8cRkXJmfBDfxgnM3RFPHo1QY8weo7baJ7qgJAzD56LkeEIxZN3mgzfceaq2FN jlQ= X-IronPort-AV: E=Sophos;i="5.64,468,1559491200"; d="scan'208";a="117451668" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 05:01:05 +0800 IronPort-SDR: LGsGmm3Jc940Op4Pz2Rz7Ysrrh6TAS2PCB+FOc7H14MqZxNW//MPN6kyGaR1iSjk90m7Yn1G0/ MJn6UClJ9SoRVLwalGklYDcmOqG+zid9bp4lsV80fTuNrdSwnQ6gdTv4bU0cI964xMT7WxDz23 8z6aPDooqopPotvf6D4tdsuR8RAQn/fCrNQige9Uz18+xtOdnoNS4nB5qh3P6BOdN3X46iAtwB eiz6hKbf+nb1qCPerzAqVG2pU+z6aZaXDMC1ajt6+QciSvaTAhAJXDOtBizLxj0q86pKoDJNda 5unWJuzOQysUqJSxiH6ySbGE Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 13:58:02 -0700 IronPort-SDR: cqKao75qHF6NxRG9ovjx3b4dt77CkyyhAEqcwRc56FqTjxJ/S+wVI/Ls68TdBj4BctdpBG9NSR 4ZCGb1E8Ws2BjCiUOqtjm9rUWxMejgJvH8v8k5988obAitcxecTBWmBDIwTp5SVQDuzJ5ScoZc cj4P5Ygfxupb49cGuqxi6zQSIPASP37SOFidVgiqUXffwPV8bwK30ArTPm7YdSHqY3I0Knk5t5 kqiRQ9DJYVyhmyLblNvFbzKe8ikTA2I5OABvHUvUH3+TII6lxdYpB6evgZ4hfB199gmGf7TWK6 jiU= WDCIronportException: Internal Received: from dhcp-10-88-173-181.hgst.com ([10.88.173.181]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 14:01:04 -0700 From: Dmitry Fomichev To: Paolo Bonzini , Kevin Wolf , Max Reitz , "Michael S . Tsirkin" , Stefan Hajnoczi , John Snow Date: Wed, 4 Sep 2019 17:00:59 -0400 Message-Id: <20190904210100.10501-4-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904210100.10501-1-dmitry.fomichev@wdc.com> References: <20190904210100.10501-1-dmitry.fomichev@wdc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v6 3/4] block/ide/scsi: Set BLK_PERM_SUPPORT_HM_ZONED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fomichev , Alistair Francis , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Added a new boolean argument to blkconf_apply_backend_options() to let the common block code know whether the chosen block backend can handle host managed zoned block devices. blkconf_apply_backend_options() then sets BLK_PERM_SUPPORT_HM_ZONED permission accordingly. The raw code can then use this permission to allow or deny opening a zone device by a particular block driver. Signed-off-by: Dmitry Fomichev Acked-by: Paul Durrant Reviewed-by: Stefan Hajnoczi --- hw/block/block.c | 8 ++++++-- hw/block/fdc.c | 5 +++-- hw/block/nvme.c | 2 +- hw/block/virtio-blk.c | 2 +- hw/block/xen-block.c | 2 +- hw/ide/qdev.c | 2 +- hw/scsi/scsi-disk.c | 13 +++++++------ hw/scsi/scsi-generic.c | 2 +- hw/usb/dev-storage.c | 2 +- include/hw/block/block.h | 3 ++- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/block/block.c b/hw/block/block.c index bf56c7612b..19f0e77bb2 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -86,7 +86,8 @@ void blkconf_blocksizes(BlockConf *conf) } bool blkconf_apply_backend_options(BlockConf *conf, bool readonly, - bool resizable, Error **errp) + bool resizable, bool zoned_support, + Error **errp) { BlockBackend *blk = conf->blk; BlockdevOnError rerror, werror; @@ -98,9 +99,12 @@ bool blkconf_apply_backend_options(BlockConf *conf, bool readonly, if (!readonly) { perm |= BLK_PERM_WRITE; } + if (zoned_support) { + perm |= BLK_PERM_SUPPORT_HM_ZONED; + } shared_perm = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED | - BLK_PERM_GRAPH_MOD; + BLK_PERM_GRAPH_MOD | BLK_PERM_SUPPORT_HM_ZONED; if (resizable) { shared_perm |= BLK_PERM_RESIZE; } diff --git a/hw/block/fdc.c b/hw/block/fdc.c index ac5d31e8c1..673a8b39bc 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -477,7 +477,7 @@ static void fd_change_cb(void *opaque, bool load, Error **errp) } else { if (!blkconf_apply_backend_options(drive->conf, blk_is_read_only(drive->blk), false, - errp)) { + false, errp)) { return; } } @@ -569,7 +569,8 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp) dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO; dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO; - if (!blkconf_apply_backend_options(&dev->conf, read_only, false, errp)) { + if (!blkconf_apply_backend_options(&dev->conf, read_only, false, false, + errp)) { return; } diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 12d8254250..07f08d0768 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1334,7 +1334,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) } blkconf_blocksizes(&n->conf); if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk), - false, errp)) { + false, false, errp)) { return; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 18851601cb..8be62903e2 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1127,7 +1127,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) if (!blkconf_apply_backend_options(&conf->conf, blk_is_read_only(conf->conf.blk), true, - errp)) { + false, errp)) { return; } s->original_wce = blk_enable_write_cache(conf->conf.blk); diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index f77343db60..57fe970908 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -229,7 +229,7 @@ static void xen_block_realize(XenDevice *xendev, Error **errp) } if (!blkconf_apply_backend_options(conf, blockdev->info & VDISK_READONLY, - true, errp)) { + true, false, errp)) { return; } diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 6fba6b62b8..a57a8f1a8f 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -200,7 +200,7 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp) } } if (!blkconf_apply_backend_options(&dev->conf, kind == IDE_CD, - kind != IDE_CD, errp)) { + kind != IDE_CD, false, errp)) { return; } diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 915641a0f1..8a57caafd7 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2318,7 +2318,7 @@ static void scsi_disk_unit_attention_reported(SCSIDevice *dev) } } -static void scsi_realize(SCSIDevice *dev, Error **errp) +static void scsi_realize(SCSIDevice *dev, bool zoned_support, Error **errp) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); bool read_only; @@ -2362,7 +2362,8 @@ static void scsi_realize(SCSIDevice *dev, Error **errp) } if (!blkconf_apply_backend_options(&dev->conf, read_only, - dev->type == TYPE_DISK, errp)) { + dev->type == TYPE_DISK, zoned_support, + errp)) { return; } @@ -2421,7 +2422,7 @@ static void scsi_hd_realize(SCSIDevice *dev, Error **errp) if (!s->product) { s->product = g_strdup("QEMU HARDDISK"); } - scsi_realize(&s->qdev, errp); + scsi_realize(&s->qdev, false, errp); if (ctx) { aio_context_release(ctx); } @@ -2449,7 +2450,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp) if (!s->product) { s->product = g_strdup("QEMU CD-ROM"); } - scsi_realize(&s->qdev, errp); + scsi_realize(&s->qdev, false, errp); aio_context_release(ctx); } @@ -2459,7 +2460,7 @@ static void scsi_disk_realize(SCSIDevice *dev, Error **errp) Error *local_err = NULL; if (!dev->conf.blk) { - scsi_realize(dev, &local_err); + scsi_realize(dev, false, &local_err); assert(local_err); error_propagate(errp, local_err); return; @@ -2652,7 +2653,7 @@ static void scsi_block_realize(SCSIDevice *dev, Error **errp) */ s->features |= (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS); - scsi_realize(&s->qdev, errp); + scsi_realize(&s->qdev, true, errp); scsi_generic_read_device_inquiry(&s->qdev); out: diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index e7798ebcd0..ccce710497 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -692,7 +692,7 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp) } if (!blkconf_apply_backend_options(&s->conf, blk_is_read_only(s->conf.blk), - true, errp)) { + true, true, errp)) { return; } diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 8545193488..c75c0dd6a5 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -603,7 +603,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp) blkconf_blocksizes(&s->conf); if (!blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), true, - errp)) { + false, errp)) { return; } diff --git a/include/hw/block/block.h b/include/hw/block/block.h index 607539057a..f988edc87e 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -85,7 +85,8 @@ bool blkconf_geometry(BlockConf *conf, int *trans, Error **errp); void blkconf_blocksizes(BlockConf *conf); bool blkconf_apply_backend_options(BlockConf *conf, bool readonly, - bool resizable, Error **errp); + bool resizable, bool zoned_support, + Error **errp); /* Hard disk geometry */ From patchwork Wed Sep 4 21:01:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11131835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E40E1399 for ; Wed, 4 Sep 2019 22:05:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A45920870 for ; Wed, 4 Sep 2019 22:05:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="E0v+WZae" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A45920870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:40824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5dPP-0007Uy-JT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 Sep 2019 18:05:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56074) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5cOy-0006Jd-9q for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5cOt-0007bT-5D for qemu-devel@nongnu.org; Wed, 04 Sep 2019 17:01:12 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:52308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5cOq-0007X8-53; Wed, 04 Sep 2019 17:01:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567630868; x=1599166868; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A8Oo7chqCEMQBqZaiGtNcZHXd4mPVEMe1m5nZgs3PcQ=; b=E0v+WZaelCQKWj2GAXX2OqbMttbPr4POm2mJomisUNRLTRGMmgtYYJZY LflIyjbJbC4Sx+EkondFDPl33aSb4cfufpQJd33ls533I3aJJGmQX7LCF I6gR+24m/VbtD/QH+WMmVaiRcVCHi07kuwdxwu8wIRBGeZqcr4L1L3AZe qDS7qYLRZeMGE9ptpyIaJHXp+G2ApPIlzPOZsfUQIWPFSIlnSPgndvjKe 8rwydo5Afh3/m5SZBWAX5k9sDcThRAQclwSXF5rAO9/SQPwqKIqnegwSf /GeCl5jp+r0IYML/68itaLCRhJCXdoDVhP9lHYDHlGIL66SS6FiLhz9ic Q==; IronPort-SDR: 12WXz9Ag/oyNeBk/cbQdhTYglVtUo7jRjzi9GoBfcVGsrq2MXrQPah5nRj4K/cfibB3zslpBQo 6rLCm9Moke9LoQwKgbEUQicXZhLP+mjhBvjX6CoUkUpJvHONNKU9P52ffw3VHsujjp1RcfUnGN 6bDiWt77GWQ0hj9xEVlKdeLC3f1JhBRn3VZ8U7Syh7Tr87TGBQ8tLsZ/sxW1pD0ixTzwfYEw2l G2GtEDK0ps+6FeWE18cBn4iXncBUi5Kd35jdxmD4GBOx6S6b1/XAMplggqPDkcQuV/a1KZGOA3 Cs8= X-IronPort-AV: E=Sophos;i="5.64,468,1559491200"; d="scan'208";a="117451673" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 05:01:07 +0800 IronPort-SDR: 6URNMeOSQ3nPyA05qj5VQz7giRjmW0eOa2jLxnV0PtNFUo6jbeBhSH3RZDasqBDsqMThCMPR9E x0E8dZAjLx9xDbnP/VM0MheK1DQSulaRtjuEZ8i2UIoheoyKKf4z9Cx0hEgnqJY0IVF8ijt6Lm 8K1ROz+kisu1gupMaYBstLGzZ0+vLZa3g0Ht4wV2nxED+DtqSoJjs+bkmdb0C3QPXww2m8YrDm RvLKOc9lXkF6PNb1SVgqyTIdpyrxtvcAf27a4sRg5dfIxcSJGYE2HiSFBlrS72vAiGsxL4A7Nt qtdqJTAlu8r409zmMVCvQWRu Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 13:58:03 -0700 IronPort-SDR: YjXuHS28J1ClgwTz6GpdEqvd1NEGMjCblC4lTUE35ZOhOhGP60l52BV+dxautL2JGQeI0H3WVl 9IEe320Yvr+hK0iGdUodDVPuKT06uAKKQKms6m8EB++ZiD22yR9uYLWzejYUoXKF7d+keNmEu1 HvBw6afXzhPsvVsEyE3PRW8X29WB+rdjiARPIM1F9Yyh8PiSlUKKAefLgRaZIg7XptHFK+i1e/ +TddVTHOtOa94NC7a/y8OhpEAwga6AtbKYpAY0uGMvHVM4RbP82V+aiL+8qd6we1bfNslIE0Dq MR0= WDCIronportException: Internal Received: from dhcp-10-88-173-181.hgst.com ([10.88.173.181]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 14:01:05 -0700 From: Dmitry Fomichev To: Paolo Bonzini , Kevin Wolf , Max Reitz , "Michael S . Tsirkin" , Stefan Hajnoczi , John Snow Date: Wed, 4 Sep 2019 17:01:00 -0400 Message-Id: <20190904210100.10501-5-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904210100.10501-1-dmitry.fomichev@wdc.com> References: <20190904210100.10501-1-dmitry.fomichev@wdc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v6 4/4] raw: Don't open ZBDs if backend can't handle them X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Fomichev , Alistair Francis , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Abort opening a zoned device as a raw file in case the chosen block backend driver lacks proper support for this type of storage. Signed-off-by: Dmitry Fomichev --- block/file-posix.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index c7e1aff6eb..f11d589f90 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2883,6 +2883,20 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared, goto fail; } } + + /* + * If we are opening a zoned block device, check if the backend + * driver can properly handle host-managed devices, abort if not. + */ + if (bdrv_is_hm_zoned(bs) && + (shared & BLK_PERM_SUPPORT_HM_ZONED) && + !(perm & BLK_PERM_SUPPORT_HM_ZONED)) { + error_setg(errp, + "block backend driver doesn't support host-managed zoned devices"); + ret = -ENOTSUP; + goto fail; + } + return 0; fail: