From patchwork Tue May 25 13:15:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12278779 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A61D9C47084 for ; Tue, 25 May 2021 13:18:58 +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 58ADB6141C for ; Tue, 25 May 2021 13:18:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58ADB6141C 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]:44400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llWxV-0007SE-8S for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 09:18:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llWv6-0004ws-AJ for qemu-devel@nongnu.org; Tue, 25 May 2021 09:16:28 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:42664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llWv3-0004ec-P9 for qemu-devel@nongnu.org; Tue, 25 May 2021 09:16:28 -0400 Received: by mail-qk1-x72c.google.com with SMTP id o27so30281517qkj.9 for ; Tue, 25 May 2021 06:16:25 -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=Sdr5QeVVXUzVRxHybwL8+Vtn8VAM6fR6pGxyRGaL+0Q=; b=LmQUSJLCcP87mBUcK0GgDJiDSfr6K/rhnMt4GoNsnzdy72ox9quTzN/LK3uqAj1YH0 M7vGaq6mRFnaEdyTW8OK1DlH2ECjR56jhZSYvEp0lk2KC42lv40Bc/rQ/9wFx+jqakdU 1H9IZw3l640XJ+UHIqqqfS3aTQjGNVDCldT/1GFJkdrsPqbejtzqreBJxAhDEvHCKzpH +kVGZI+91Bd/wfmHAPbZw9V+15dQ6lFyAWsf74lTILwsJB/u7ATqhZBwNJsFTpun51Bd +SASMG4soq2Q4lhCMxsruFFXaExS/FDcjWo1JXOCsrQr/ydTobDxXFcxO1JP5LQtZaRM jm0Q== 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=Sdr5QeVVXUzVRxHybwL8+Vtn8VAM6fR6pGxyRGaL+0Q=; b=NmcEsm01+Z7dXb/9yNLk+tJZgs6SwwM9G6ocgN2OaNMRv18KAS8klKFXpLOiUuPHIF XYKT5r0DdKCxnk2HTYaLI+2EoQ2SwQk6VkgOGTHhH2ZZQU4Q/hsM3RhqkVqQ5AmYjyQc KPJ+ZJKjgro8YVTdDDab6OfIZJhVqDscAjuEY7dvrHOJ5dYMQDPEE1cTW6TuLXIrsbBp h80XpaHi4CVyAAfIB5tTPD1EsmrF8ovsWoe1VcV5QJMsvCHZhBtQ0TZgmsFeqXXBohf2 3pRjPg+9D7aI/Z9g3RWGHNjRtP21GVRlYnaMf0Ozjulub/UKjlvGEr7OFnNLOB+D5vur 1o9g== X-Gm-Message-State: AOAM533mgrkK0xpWyKSZ82RBE4w1QD+omKxmDthoSUHM9IMQJDbxVA37 /6fseOz7eXNoBxiVgyxNefjOT5SrnxM= X-Google-Smtp-Source: ABdhPJzH/VFpbKN/wETKhLlsQSeY/AGnfmZzjaKMNDv20KSIxjhPf7ep7Bni6FsgTQEMu6NYDrYZlA== X-Received: by 2002:a05:620a:30d:: with SMTP id s13mr34891455qkm.58.1621948584721; Tue, 25 May 2021 06:16:24 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id p14sm13213596qki.27.2021.05.25.06.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 06:16:24 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH v2 1/3] block/blkdebug: add blocksize parameter Date: Tue, 25 May 2021 13:15:43 +0000 Message-Id: <20210525131545.529451-2-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525131545.529451-1-kit.westneat@gmail.com> References: <20210525131545.529451-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=kit.westneat@gmail.com; helo=mail-qk1-x72c.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 +++++++++++++++++++++++++++++ 1 file changed, 29 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, From patchwork Tue May 25 13:15:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12278777 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 4D904C4707F for ; Tue, 25 May 2021 13:18:58 +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 DCD9F6141C for ; Tue, 25 May 2021 13:18:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCD9F6141C 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]:44418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llWxU-0007Sy-RR for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 09:18:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llWv6-0004xA-KR for qemu-devel@nongnu.org; Tue, 25 May 2021 09:16:28 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:44885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llWv4-0004fF-Ka for qemu-devel@nongnu.org; Tue, 25 May 2021 09:16:28 -0400 Received: by mail-qv1-xf30.google.com with SMTP id a7so11625049qvf.11 for ; Tue, 25 May 2021 06:16:26 -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=fTbXGAY0hkx6KvmWw7radja7auGtH3fX99Dz14gdFV+RiUQK/ErP3bL7pibjKdvOPt jzvuBOi24yILQY75ASu4uZWGwi1lmwJWrXt1+S3QffkKskOM3UNi5NFvzlMoVsPeN/jd ONOiWnwdPRIkJLzAYPw5c9wQFlC7W0yFNzsd58JplGH5CJ/lGRd7ZPeSJ79jCmGv7wYU lzkwIBeVUqxYiRE5yzFstTnEq9AZUUuHGzFDQxWn3Bu5Fq/+aXVvXUsYtgmP9xzQu1bG HaHFS4tf4UzntKoA+fCPVdVnYTSEfyaA9GYdpXpQRVy0PpEr+VQyqj9xnZjufAA9Tx1W RMuA== 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=CXcW+P1LRuYAC5YE7hqbnl+m7sqObuxU17xq8l8oWmOoTJGTpTgjsk5Rh6e2qSJ6CQ Di0vRV/KZrB5oetOggkC/jfWozyAHU3JbGTR6GXns/pe6DsGYptSo6F8l/wXCS4lsRnP solH4h/ZVoH9JJUAoq0LEGKB5NyBI5WNQPTfyyGkXXoFQeF4j+k3S13VRjijfRaRuOiP C9dShWpgGVv0mAAK2k4k2TudDKP7iBKfv8sfsHWQl7bnQPjnVzqier8EbNZ+vAwTeoZ0 TfAYaDbj4kR2hdL64oIcnkVZi1wC4d+ZsTpReaAmh3ikncIRIqSHCQxFl5fwTo5EGS/M ZJkA== X-Gm-Message-State: AOAM532ItroD6G3I1V4b5a1xtIE67HuTDrIHyEO7xJIiudavAVsULWCq 58GU0ReLpQHXGBPlmSZa7FtzJ0ydQnQ= X-Google-Smtp-Source: ABdhPJzYJeHC6YYasbPgQY3dpd3r5Hhz0KmJzd62TmEjYUKtcMl9n+xqYoBkWM0ETAqP/gmF25ncIg== X-Received: by 2002:a0c:b292:: with SMTP id r18mr37213154qve.57.1621948585456; Tue, 25 May 2021 06:16:25 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id p14sm13213596qki.27.2021.05.25.06.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 06:16:24 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH v2 2/3] tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test Date: Tue, 25 May 2021 13:15:44 +0000 Message-Id: <20210525131545.529451-3-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525131545.529451-1-kit.westneat@gmail.com> References: <20210525131545.529451-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=kit.westneat@gmail.com; helo=mail-qv1-xf30.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 13:15:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12278781 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 F0182C2B9F8 for ; Tue, 25 May 2021 13:20:56 +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 9B0D361423 for ; Tue, 25 May 2021 13:20:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B0D361423 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]:53024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llWzP-0004p1-KW for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 09:20:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llWv8-00051N-VY for qemu-devel@nongnu.org; Tue, 25 May 2021 09:16:31 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:40616) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llWv5-0004gb-HL for qemu-devel@nongnu.org; Tue, 25 May 2021 09:16:30 -0400 Received: by mail-qt1-x834.google.com with SMTP id i12so3508941qtr.7 for ; Tue, 25 May 2021 06:16:27 -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=UG6RZt6RGDrh2uQcORhrCvG8uZPHCBViCRDY6QTsAfs=; b=Dlb0rk1CmB+Yg10dJBuOH0nLbwx435LArcq6S7349iUvHmmi9Pvee4jPE9jDEo5zKz d74WSjOfUKdYJrKCp/u3mApADidFru8RFjYC6+FyxuG6TvxIYVl+cU6FKZgl5CvxyCGg oC5l5a0d5aDps1skhqtmNOuvNJFW45IaPIJGETrb6HUWhtSk5LdkQUo1+71+ApZ1J7kg stwMMfkFHVlVlJVB+s4qnAqvxlbKuEDhD1bJFwFublErV0VA+E1d3fLTgy1jWkDsM5DN mZ7VpbV4T6HzmJXy3H56eEKvqE7hCroFZe90cHND7zxkGCu3XkjZcJ//lR/U8x52PAqN T7dQ== 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=UG6RZt6RGDrh2uQcORhrCvG8uZPHCBViCRDY6QTsAfs=; b=hsItyaMC+MmlIHhq023jmjTG2o3s4N4+7n88rP4Osmmp+1IecO77a2TT9BgV3rYdnk 0dtSrsZR3jI2b6cUflr9SqEqU/t/Pw339ScgEWRQalvnBinDx/wTwjw3c0wj1/0J/c9V FEOtXIwyp6aR2c+5B7AX9wA2SpUtIupVjP/Dj6EZXTyoRqnhA1ZKTRBgPhHufF01v89+ osyjSrQq3R9pNMGpmhP5rxoK6vRlh3Ewt1rJSPgAklJ8STr8j83Mq+fwCC9MXJpD9TRb xNAqmVp+Anw6XDcTSV2PE52d6958R4AXoGT7uzwA9lMgh6cC/BQXwGTi+ZFqDH4M1eQm HAAw== X-Gm-Message-State: AOAM530y5hKQRJz6sL77Na+k4knCAwgnp/sVhLg1UbxGkRB4FPkDLGzm Kl4Kp58AxKxnloEhecz9EtfHmhHqKhw= X-Google-Smtp-Source: ABdhPJwAkhHZo7RmXYnY6emPfhhGxx0Ly7f6Jrhipo64X9APkuO5iruNxcOyHk2s4AYRhnaM9fcMIg== X-Received: by 2002:ac8:5f8f:: with SMTP id j15mr31934090qta.116.1621948586280; Tue, 25 May 2021 06:16:26 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id p14sm13213596qki.27.2021.05.25.06.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 06:16:25 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH v2 3/3] block/blkdebug: add log-blocksize and phys-blocksize parameters Date: Tue, 25 May 2021 13:15:45 +0000 Message-Id: <20210525131545.529451-4-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525131545.529451-1-kit.westneat@gmail.com> References: <20210525131545.529451-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=kit.westneat@gmail.com; helo=mail-qt1-x834.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 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 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",