From patchwork Tue May 25 19:46:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12280001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47BBDC47086 for ; Tue, 25 May 2021 19:48:12 +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 C7E6F61409 for ; Tue, 25 May 2021 19:48:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7E6F61409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lld2A-00089a-NM for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 15:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lld0T-0006VP-Cd for qemu-devel@nongnu.org; Tue, 25 May 2021 15:46:27 -0400 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]:43591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lld0R-00073b-5H for qemu-devel@nongnu.org; Tue, 25 May 2021 15:46:25 -0400 Received: by mail-qv1-xf33.google.com with SMTP id v18so16653877qvx.10 for ; Tue, 25 May 2021 12:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WcS9fx5EbDCdRXO1Dr/7ha/qn68edJptwQ+TXT9x/lY=; b=elltH4ESUwqXlMRwpBOc+qdfCi6W/f0Fb/bSjPkO5iWR7mb9XSVczE7o3KoZ1stpBB xYazHEck1wdWHTP+nBk7gmVxv1meW7YLff1aqzFfCLzrH+gmjfzPO9ND7V4mUdbLS6UP 2fi8stEoai9k2KYqxhuz+dC0KGFOpPjVDzWgFnJdECzgAa/JS1PZRYBETOpcFyXDF29f ybp6X3yvvzQGJQgq2c1DkiWECJrRdftF0TaASeXdQpoWf4kONGSx0xdnoSUv4MdmkPjn ssJHoqW6EGR3o+HRwiid0QxL+bp+35T5er9bolJHhYG3DVY8BG3qtnFPwHuMP+YJyQi2 s+hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WcS9fx5EbDCdRXO1Dr/7ha/qn68edJptwQ+TXT9x/lY=; b=n4Y9KbhXYZax8zX+wj++Q6Fu1VmtYB1c8xp/tkTex0vdRC/GpL5dTqvCH4pn4GKQ23 jYS35vqjc7H6YpiVe1eANG/JfsuOiH5WE17pTFE3HPFqKceMgHrSuAqWzFugLditOe0z W4IajH3WQ5FOoA57hyZIiyvOxCIIcnGJ2Uj04QwjCb2X8TZE+WLfu08+L+PwsoXj8y8e ELj9XZjaQ60C8TmSc9hIAnMtk2pdeb8z5BuaSWYSCOmZ4AI2YcIxwFPpU1i3s8kyUxRj UVqQcBJbK9ObmCsTAJb7DlKQ6Cwq4wKN2SklRo80cCltl4+fU1APIuph4KDfAXSPTB3M ccDQ== X-Gm-Message-State: AOAM5327F6mZm8u+Pb+8k+pQYxgxLY7fXNWr5O0F5QiQ9Zt2L+V1Fxhk m1ybKa4WqGnTbIda1VyuJ7VVoUSiYYo= X-Google-Smtp-Source: ABdhPJxEUSIIA/RePtkLnhVrBK1Lnk9Jo2SeV4HVxb0yI5E8nRgqbenuB7BDChxwCR5GI8sw7Ea4vQ== X-Received: by 2002:a05:6214:902:: with SMTP id dj2mr39229542qvb.11.1621971980851; Tue, 25 May 2021 12:46:20 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id o5sm87206qtl.85.2021.05.25.12.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 12:46:20 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] block/blkdebug: add blocksize parameter Date: Tue, 25 May 2021 19:46:05 +0000 Message-Id: <20210525194607.553291-2-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525194607.553291-1-kit.westneat@gmail.com> References: <20210525194607.553291-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=kit.westneat@gmail.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: pbonzini@redhat.com, Kit Westneat Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Allow users to specify the block size of the qdev for testing purposes. Signed-off-by: Kit Westneat --- block/blkdebug.c | 29 +++++++++++++++++++++++++++++ qapi/block-core.json | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index 2c0b9b0ee8..d5f589920c 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -47,6 +47,7 @@ typedef struct BDRVBlkdebugState { uint64_t max_write_zero; uint64_t opt_discard; uint64_t max_discard; + uint64_t blocksize; uint64_t take_child_perms; uint64_t unshare_child_perms; @@ -455,6 +456,11 @@ static QemuOptsList runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Maximum discard size in bytes", }, + { + .name = "blocksize", + .type = QEMU_OPT_SIZE, + .help = "Blocksize of device", + }, { /* end of list */ } }, }; @@ -562,6 +568,14 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, goto out; } + s->blocksize = qemu_opt_get_size(opts, "blocksize", 512); + if (s->blocksize && (s->blocksize >= INT_MAX || + !is_power_of_2(s->blocksize))) { + error_setg(errp, "Cannot meet constraints with blocksize %" PRIu64, + s->blocksize); + goto out; + } + bdrv_debug_event(bs, BLKDBG_NONE); ret = 0; @@ -984,6 +998,19 @@ static void blkdebug_refresh_limits(BlockDriverState *bs, Error **errp) } } +static int blkdebug_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz) +{ + BDRVBlkdebugState *s = bs->opaque; + + if (!s->blocksize) { + return 0; + } + + bsz->phys = s->blocksize; + bsz->log = s->blocksize; + return 0; +} + static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp) { @@ -1010,6 +1037,7 @@ static const char *const blkdebug_strong_runtime_opts[] = { "inject-error.", "set-state.", "align", + "blocksize", "max-transfer", "opt-write-zero", "max-write-zero", @@ -1034,6 +1062,7 @@ static BlockDriver bdrv_blkdebug = { .bdrv_getlength = blkdebug_getlength, .bdrv_refresh_filename = blkdebug_refresh_filename, .bdrv_refresh_limits = blkdebug_refresh_limits, + .bdrv_probe_blocksizes = blkdebug_probe_blocksizes, .bdrv_co_preadv = blkdebug_co_preadv, .bdrv_co_pwritev = blkdebug_co_pwritev, diff --git a/qapi/block-core.json b/qapi/block-core.json index 2ea294129e..1b1f2692ef 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3404,6 +3404,9 @@ # on how the blkdebug node is used). Defaults # to none. (since 5.0) # +# @blocksize: blocksize of device in bytes, must be +# positive power of 2 (since 6.1) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsBlkdebug', @@ -3412,6 +3415,7 @@ '*align': 'int', '*max-transfer': 'int32', '*opt-write-zero': 'int32', '*max-write-zero': 'int32', '*opt-discard': 'int32', '*max-discard': 'int32', + '*blocksize': 'int', '*inject-error': ['BlkdebugInjectErrorOptions'], '*set-state': ['BlkdebugSetStateOptions'], '*take-child-perms': ['BlockPermission'], From patchwork Tue May 25 19:46:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12280003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB5CBC4707F for ; Tue, 25 May 2021 19:50:34 +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 7DC7761409 for ; Tue, 25 May 2021 19:50:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DC7761409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lld4T-0003EP-IM for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 15:50:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lld0X-0006YK-EZ for qemu-devel@nongnu.org; Tue, 25 May 2021 15:46:29 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:38827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lld0R-00073h-5K for qemu-devel@nongnu.org; Tue, 25 May 2021 15:46:29 -0400 Received: by mail-qk1-x72e.google.com with SMTP id q10so31672510qkc.5 for ; Tue, 25 May 2021 12:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J00AFYHzr+9ngwCXo9aAAPPc/2POf9OmAX8slM/yDBc=; b=ixERXFuOJzNGy6UteGxFuVMWL3cBCe0lhHSJdxDUc3TR82/ampD0Eorj6KGX9x9wR6 Vn9Aurkp3t1vZofdBBRQx6kIwu5+pjp3sjJHnipFDwMKxElx+vr00Xq9Ffb2cvGpGOTs yv/ODh/cgknVu40An0ZelHQev2syegimbPa45laFz0r6Gjq9SpELbaMjw/oFlsuPyqjJ LSAJ7jyavyJQituMS+rVEfEoycziMshMBp43p3ugEvDqxqqkf56AzHh/ARHnRX4alvqE LievYJ0ow0VQp9aZGud4KOuFtL7w+VCU4E7P7HhgHvuUjAJkCWPVw0hz3elKYAwyEFpy hPuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J00AFYHzr+9ngwCXo9aAAPPc/2POf9OmAX8slM/yDBc=; b=XAn7wai20iDPomrxq6CQWEeCMFHb6xz7Z0kCUwZ41eNjPbBo9ZfbzuHXgFKYTiczUq j2i55GBaMKdDn7aXRncSaOK1GHxCFl1WfRLt+LOWfZwUn0trhUHIpNvE3VenO+eJMvfm Z2dyh/Ul+pKHj82+E+K2W1r0FHTjF1Fp+z7K2l69N1JOVFG4C5q3x2i32Q2gkcGWJe+F CQHXONuaFrEdDGC/refVdmpqZ2etNDsAPQwlEJ2qBVJCrYtFZm4eqS3ECUrYI8pEDWgH Mi7IOH+9iba+UGh5gAk3nR+l0RV+r5oFxfz8lQ145ufnMYxnhD2IMu+iBqzlZtbcLhv2 1Pgg== X-Gm-Message-State: AOAM530RN+zCYQzifwHIwqN+ScxBJQjr5kWAf1X6Z2TVeOc5NWeoUCWo mE+sV0SAX3wUYKY9emmSA5a72y0VDCg= X-Google-Smtp-Source: ABdhPJyFE3Vem7SnGxZRGprLPufg+N9k5/udJMLA1LyaDKbFFhxHNckiADJ59DFKcoqP2mI81heK0g== X-Received: by 2002:a05:620a:2296:: with SMTP id o22mr33443292qkh.408.1621971981498; Tue, 25 May 2021 12:46:21 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id o5sm87206qtl.85.2021.05.25.12.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 12:46:21 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test Date: Tue, 25 May 2021 19:46:06 +0000 Message-Id: <20210525194607.553291-3-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525194607.553291-1-kit.westneat@gmail.com> References: <20210525194607.553291-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=kit.westneat@gmail.com; helo=mail-qk1-x72e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: pbonzini@redhat.com, Kit Westneat Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add test for issue #345 Signed-off-by: Kit Westneat --- tests/qtest/virtio-scsi-test.c | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index 1b7ecc1c8f..e569bda7d0 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -200,6 +200,42 @@ static void test_unaligned_write_same(void *obj, void *data, qvirtio_scsi_pci_free(vs); } +/* Test UNMAP with a large LBA, issue #345 */ +static void test_unmap_large_lba(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtioSCSI *scsi = obj; + QVirtioSCSIQueues *vs; + const uint8_t unmap[VIRTIO_SCSI_CDB_SIZE] = { + 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 + }; + + /* + * Default null-co device size is 2**30 + * LBA 0x7fff is ~ 1/8 into device, with 4k blocks + * if check_lba_range incorrectly using 512 bytes, will trigger sense error + */ + uint8_t unmap_params[0x18] = { + 0x00, 0x16, /* unmap data length */ + 0x00, 0x10, /* unmap block descriptor data length */ + 0x00, 0x00, 0x00, 0x00, /* reserved */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, /* LBA */ + 0x00, 0x00, 0x03, 0xff, /* sector count */ + 0x00, 0x00, 0x00, 0x00, /* reserved */ + }; + struct virtio_scsi_cmd_resp resp; + + alloc = t_alloc; + vs = qvirtio_scsi_init(scsi->vdev); + + virtio_scsi_do_command(vs, unmap, NULL, 0, unmap_params, + sizeof(unmap_params), &resp); + g_assert_cmphex(resp.response, ==, 0); + g_assert_cmphex(resp.status, !=, CHECK_CONDITION); + + qvirtio_scsi_pci_free(vs); +} + static void test_write_to_cdrom(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -293,6 +329,16 @@ static void *virtio_scsi_setup(GString *cmd_line, void *arg) return arg; } +static void *virtio_scsi_setup_4k(GString *cmd_line, void *arg) +{ + g_string_append(cmd_line, + " -drive file=blkdebug::null-co://," + "file.image.read-zeroes=on," + "if=none,id=dr1,format=raw,file.blocksize=4k " + "-device scsi-hd,drive=dr1,lun=0,scsi-id=1"); + return arg; +} + static void *virtio_scsi_setup_cd(GString *cmd_line, void *arg) { g_string_append(cmd_line, @@ -323,6 +369,10 @@ static void register_virtio_scsi_test(void) qos_add_test("unaligned-write-same", "virtio-scsi", test_unaligned_write_same, &opts); + opts.before = virtio_scsi_setup_4k; + qos_add_test("large-lba-unmap", "virtio-scsi", + test_unmap_large_lba, &opts); + opts.before = virtio_scsi_setup_cd; qos_add_test("write-to-cdrom", "virtio-scsi", test_write_to_cdrom, &opts); From patchwork Tue May 25 19:46:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12280011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 562DFC47086 for ; Tue, 25 May 2021 19:53:52 +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 D70F5610A5 for ; Tue, 25 May 2021 19:53:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D70F5610A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lld7e-0007CM-UI for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 15:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lld0X-0006Yg-Ig for qemu-devel@nongnu.org; Tue, 25 May 2021 15:46:30 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:41591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lld0S-000745-DK for qemu-devel@nongnu.org; Tue, 25 May 2021 15:46:29 -0400 Received: by mail-qt1-x829.google.com with SMTP id t20so23978884qtx.8 for ; Tue, 25 May 2021 12:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=utywv+fX2W3LjdvJtR62FVzS/O+FDyOews8kabNhQkQ=; b=e6Ww9NC1Ftujk3l3trXjLn50Q5ClSbgG6E92+weA6FQsa0l6temJGxyXqKYmyKrjqg pfyvidoJitCG0usckzV3TemrK+FP7p+5FoBQ1Bu20xdSacBFAL/Uxn0U1kADFUKcxyYs Y+q/04HGqX7VydXKpAQp6o/zpGYH186iV8vEqR//9a8yrP1L1GZnX/jUN9+/njjnPsUz nyfx6Goc939G9kNmMZNfdXD8+lx93RWq+uGCgxm7re3lsIrnY73HBrmhcx/DtICgGdVB vEFOT31I6JbAifJxRNVLRt/NJQrdhenOOPkNKmOwXIbgIc+dn43u2fRcHlzyO14BMfnt m7uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=utywv+fX2W3LjdvJtR62FVzS/O+FDyOews8kabNhQkQ=; b=iRCd1HkSRssJOw7aRxvwViDaqrhAhB9tyxCuJdd2KZc9leljP8qG0eyGoiNfjD/UmP gHIE8F+R9HCw4tW2tjbt9FVEK8zaQBqPgX4S6+RCqheRpPAjvBEaPLX4CKJu+C9aJSbs iZtFDh+wJUCChGH1OrW08pPkm5hh3thIs8mKqxhKDyejmds63EjwkFds3PqyEnr5Omwk OIFGBZS8YE6JrzVJz2RCVtwIEudhFU09TV/Q6RZDBIGb/Q3SUMiSJIV9sWOvymYCKbon x3r5Tz4ReYaWVjMOlgi00UbENnFNL8OUwszh0yYUGU9URptElrCkEUPCoiiV3p5ObaUT HSuw== X-Gm-Message-State: AOAM530eTksJyGG4pEAeaRfUyZTRVi9Dfh0Jr5wFUifpMOHxVFcsRIOp Wau+qWXsLOBHVmwhMLlD1fMSXnel3N4= X-Google-Smtp-Source: ABdhPJw9jb4zjf1Va3NDVCEPHzZS/D2rn5IMmlg4RQp4rwfG51O/I3CcOaP3Ha3HGoyUy7wV+AGDSQ== X-Received: by 2002:a05:622a:15cb:: with SMTP id d11mr16283071qty.11.1621971982286; Tue, 25 May 2021 12:46:22 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id o5sm87206qtl.85.2021.05.25.12.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 12:46:21 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] block/blkdebug: add log-blocksize and phys-blocksize parameters Date: Tue, 25 May 2021 19:46:07 +0000 Message-Id: <20210525194607.553291-4-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525194607.553291-1-kit.westneat@gmail.com> References: <20210525194607.553291-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=kit.westneat@gmail.com; helo=mail-qt1-x829.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: pbonzini@redhat.com, Kit Westneat Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Allow users to specify the logical and physical block sizes of the qdev for testing purposes. Signed-off-by: Kit Westneat --- block/blkdebug.c | 39 +++++++++++++++++++++++++++++++++------ qapi/block-core.json | 7 +++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index d5f589920c..85b3973427 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -48,6 +48,8 @@ typedef struct BDRVBlkdebugState { uint64_t opt_discard; uint64_t max_discard; uint64_t blocksize; + uint64_t phys_blocksize; + uint64_t log_blocksize; uint64_t take_child_perms; uint64_t unshare_child_perms; @@ -459,7 +461,17 @@ static QemuOptsList runtime_opts = { { .name = "blocksize", .type = QEMU_OPT_SIZE, - .help = "Blocksize of device", + .help = "Blocksize of device (512 default)", + }, + { + .name = "phys-blocksize", + .type = QEMU_OPT_SIZE, + .help = "Physical blocksize of device (Defaults to 'blocksize')", + }, + { + .name = "log-blocksize", + .type = QEMU_OPT_SIZE, + .help = "Logical blocksize of device (Defaults to 'blocksize')", }, { /* end of list */ } }, @@ -576,6 +588,22 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, goto out; } + s->phys_blocksize = qemu_opt_get_size(opts, "phys-blocksize", 0); + if (s->phys_blocksize && (s->phys_blocksize >= INT_MAX || + !is_power_of_2(s->phys_blocksize))) { + error_setg(errp, "Cannot meet constraints with phys-blocksize %" PRIu64, + s->phys_blocksize); + goto out; + } + + s->log_blocksize = qemu_opt_get_size(opts, "log-blocksize", 0); + if (s->log_blocksize && (s->log_blocksize >= INT_MAX || + !is_power_of_2(s->log_blocksize))) { + error_setg(errp, "Cannot meet constraints with log-blocksize %" PRIu64, + s->log_blocksize); + goto out; + } + bdrv_debug_event(bs, BLKDBG_NONE); ret = 0; @@ -1002,12 +1030,9 @@ static int blkdebug_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz) { BDRVBlkdebugState *s = bs->opaque; - if (!s->blocksize) { - return 0; - } + bsz->phys = s->phys_blocksize ? s->phys_blocksize : s->blocksize; + bsz->log = s->log_blocksize ? s->log_blocksize : s->blocksize; - bsz->phys = s->blocksize; - bsz->log = s->blocksize; return 0; } @@ -1038,6 +1063,8 @@ static const char *const blkdebug_strong_runtime_opts[] = { "set-state.", "align", "blocksize", + "phys-blocksize", + "log-blocksize", "max-transfer", "opt-write-zero", "max-write-zero", diff --git a/qapi/block-core.json b/qapi/block-core.json index 1b1f2692ef..4638026dbf 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3407,6 +3407,12 @@ # @blocksize: blocksize of device in bytes, must be # positive power of 2 (since 6.1) # +# @log-blocksize: logical blocksize of device in bytes, must be positive power +# of 2, or 0 for default (@blocksize) (since 6.1) +# +# @phys-blocksize: physical blocksize of device in bytes, must be positive +# power of 2, or 0 for default (@blocksize) (since 6.1) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsBlkdebug', @@ -3416,6 +3422,7 @@ '*opt-write-zero': 'int32', '*max-write-zero': 'int32', '*opt-discard': 'int32', '*max-discard': 'int32', '*blocksize': 'int', + '*log-blocksize': 'int', '*phys-blocksize': 'int', '*inject-error': ['BlkdebugInjectErrorOptions'], '*set-state': ['BlkdebugSetStateOptions'], '*take-child-perms': ['BlockPermission'],