From patchwork Tue May 25 12:47:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12278683 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 DAD5DC2B9F8 for ; Tue, 25 May 2021 12:49: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 719DC6142C for ; Tue, 25 May 2021 12:49:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 719DC6142C 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]:43270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llWVP-0003Cd-6S for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 08:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llWU4-0001IY-Vg for qemu-devel@nongnu.org; Tue, 25 May 2021 08:48:33 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:44732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llWU3-00045x-Co for qemu-devel@nongnu.org; Tue, 25 May 2021 08:48:32 -0400 Received: by mail-qv1-xf34.google.com with SMTP id a7so11574811qvf.11 for ; Tue, 25 May 2021 05:48:30 -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=o2yGfcWr7aHdFQyGe4z+DLXUhszXdOaTt4aicOQsph8=; b=tgq+YLCBp+Ln5L25I0D1MPZmU5cpINdiQJNcpf0CpOh+qNAz3yX8BDSCwnn3f/amMF Y/0A8bfGRy6CtYK6G2Twgc8C+DWnSFAYhb590n22HVfXYXR5GNa/gT+n+DnchZZhdhOZ RWVBcT3ath1uAIg8INsBeAO+Joq2aIEdZBbeWWQX3PIXdKzZGs7ECQC9+FHEdQ+ftUag Jw8yGHFL2H3g10kImKc59iocTSv6f7/xfnCULkrHDXY9vL4nlz35bvhrd42AOSvu9FIW ipvd1uAZyMQ+kkdhNlkJHubRJWLd5nx9E9pCBJM8rnkLxGEEEm98zvASaDx9bgCPVk9S MAqg== 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=o2yGfcWr7aHdFQyGe4z+DLXUhszXdOaTt4aicOQsph8=; b=JJHygGrqrDzNOsc2DbeQCg0j/At+hKX6ryL7p+TdYHXeBkuHjg38L/HIqpKX4YASgG uZCVnuDABjOtWiB4yQ/PJMJKkHE57kbM7jUDS5iPYgWzV3LVQwmc8GXime7IR/twvqiF PLMcH1kjqqnxJRihmv73WaZOFUdp/H3DGPQNK6dVRV5++572dkoegpkDVUy8pNNf1QBu oMAJ0nHlNsBXleHBwaJpuPNAZOdo6o0lsYDTkGuYmbyPyomTh/VL1NiWiBFgpANmQVEu 0xER9ZBOdHgHS27jo+YSC9RuiNonN9SG1nroIfuw5PD+0ETMDGBJ67uMLtAWl48vD/wN tprw== X-Gm-Message-State: AOAM531dOWroJL5kCltpYjMwFPB/F4SURHg2XARl6wXJsngvFuFDz7Jx XGge1EFkpwIReQceGiZGybs3GfycrGo= X-Google-Smtp-Source: ABdhPJz7k1sBl5MJcQ0xQRL3l7NYMtJ5Bbw25qahs9N/0XlqBPOa3sod1uKcbgpMa+2EX5q1PdmdDQ== X-Received: by 2002:a0c:f48c:: with SMTP id i12mr35210809qvm.7.1621946910171; Tue, 25 May 2021 05:48:30 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id a68sm13036749qkd.51.2021.05.25.05.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 05:48:29 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH 1/3] block/blkdebug: add blocksize parameter Date: Tue, 25 May 2021 12:47:51 +0000 Message-Id: <20210525124753.528516-2-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525124753.528516-1-kit.westneat@gmail.com> References: <20210525124753.528516-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=kit.westneat@gmail.com; helo=mail-qv1-xf34.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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index 2c0b9b0ee8..c7500746a8 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,13 @@ 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 +997,18 @@ 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 +1035,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 +1060,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 12:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12278687 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 643F9C2B9F8 for ; Tue, 25 May 2021 12:51:38 +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 1DB5F61408 for ; Tue, 25 May 2021 12:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DB5F61408 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]:47570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llWX2-0006Ed-Tg for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 08:51:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llWUA-0001VB-HW for qemu-devel@nongnu.org; Tue, 25 May 2021 08:48:38 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:40905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llWU7-00048o-Hk for qemu-devel@nongnu.org; Tue, 25 May 2021 08:48:38 -0400 Received: by mail-qt1-x82d.google.com with SMTP id i12so3443503qtr.7 for ; Tue, 25 May 2021 05:48:35 -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=N1vErSLPnbM9DSp6U1L0Sbxqjsv59zIXbG3fgAM+mzU=; b=FM6F+GDyGWRkJlpws3JjSJ6dH8Q7yrRLQtwoWyxQ6VVdrps1rMuv971BrzLc5iyOPi 358RD66Zhp+wnoOhqHbh6Lsd6oYPOp3Aj5oU+6aVHSBtFjveL+ZGjKJi92J3Knoow0ds JKsjB6W5YwquBJac394P7HH5uB0Ye0Zy2NO9W3wju0mDbU5j7RJ1tK73zEasWX/jXC4Y QG+8E1l9M3Et8nAaOVN/eBJKS/Eub6IISaA0c5M3fJU+j9WqeRysmWvWWBt+tWg2KIRA 6S//KAgPezH58iKtAa+UiBEV+QDxmhJvwLmRXaoy0nX4NkeA6xbYR73vERwx/rxh5bMB yfSg== 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=N1vErSLPnbM9DSp6U1L0Sbxqjsv59zIXbG3fgAM+mzU=; b=IEeQpVudQb52HT/LJjXrjmRvZ/KOaJmt/+7vuvzpmSkgkxKYvWfZfRT4DZwt1mTQZR m/SAhmivySatDmOvVMmbfC/i1B2DOhde5wupkeaTTqmZGl1UTGqFDLW1esf61Gn6xTNg APAaeDoRf3IiwUlW5s4DM5pEsj2ej97X3V1msGRATmI4f1rwV1jQwZ1HrbjMFd2EiUku hr7IZkTNlfm+i2PCGSUVdg9lqBLCKRfT78B38fOyLaYwtps1L0kdcFMD6+A2/ugHzlVb eizC+jOni0t/tEShzWDkZTzAQB03+MdrsPYBSgXYjb+6oDkdIgPhLsiD22K1vKg3hTIo yVCw== X-Gm-Message-State: AOAM533l0Fug5eG59KJXQ3BrK6OiT8m2yhvrD4aaDEIxV5LLSKZTsE52 bPszOhE/428ZXQFLGLxcK1hOE9crgpA= X-Google-Smtp-Source: ABdhPJy6zuKOl3SjpyyAFM7DmQyYZqt99MzLVt9cpHcTGsfH/GUxWgOgEDhCMmRG3T0aUMBJno/PQw== X-Received: by 2002:a05:622a:15cb:: with SMTP id d11mr14313953qty.11.1621946914203; Tue, 25 May 2021 05:48:34 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id a68sm13036749qkd.51.2021.05.25.05.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 05:48:33 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH 2/3] tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test Date: Tue, 25 May 2021 12:47:52 +0000 Message-Id: <20210525124753.528516-3-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525124753.528516-1-kit.westneat@gmail.com> References: <20210525124753.528516-1-kit.westneat@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=kit.westneat@gmail.com; helo=mail-qt1-x82d.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 | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index 1b7ecc1c8f..6557e4f422 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -200,6 +200,40 @@ 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 +327,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 +367,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 12:47:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kit Westneat X-Patchwork-Id: 12278685 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 AEAC0C2B9F8 for ; Tue, 25 May 2021 12:50:09 +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 5636A61408 for ; Tue, 25 May 2021 12:50:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5636A61408 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]:43970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llWVc-0003gs-Do for qemu-devel@archiver.kernel.org; Tue, 25 May 2021 08:50:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llWUC-0001aO-IZ for qemu-devel@nongnu.org; Tue, 25 May 2021 08:48:40 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:39571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llWUA-0004Am-8G for qemu-devel@nongnu.org; Tue, 25 May 2021 08:48:40 -0400 Received: by mail-qt1-x834.google.com with SMTP id c15so1128114qte.6 for ; Tue, 25 May 2021 05:48:37 -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=1HqbblJpGSscK6SzMXTtB/qUs5tLjwyqus/aCL6LCrw=; b=dNq30uZzqUaqCOc0fAkH0D7KK93R4YVl/XaxXA6vew+7LW7Y1dzwfVphuWw9ue9kHX kdq8xvzywZr7v5WdmUH8q1Z4fU9Sm8HTliu1wx0NMaklyg6KaF1kGmBxyOSUYsw2dPZt 6objEDUcyfMzEtdrPY/JBhXOLE5taQDFrsypgHRtsRYRBCnbU9YNshViWC4Y2Kq+0RON ZbocrkN8PugwerVqsn3Hq9ckB4/tRXSbp8Yd8r2TvGMJOkz6j5hUNTJim6mmv3SpaOh5 fH243vpqUV8Hwg9gANZpxss74Lsw6Y+eMdBpYSL0rt4YnT+Z1cFz1/w5igPj9MR4ynQ9 i3mw== 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=1HqbblJpGSscK6SzMXTtB/qUs5tLjwyqus/aCL6LCrw=; b=GlpW4wpSbG7FK46WuYdJWQqJJajjNxua0xHruWEVy6Wdc/4xpH+gMzNxrkt3o4CbWU Em68dpf+WKndZn/XH+DuBXOrEBR6PWNL0681LKWAEBW1HHiWyOKQKg5s7uPq2g4hNxKd d9e25iQYPEA/8pMWfnAvu5YW/gAniCgDLJffB0j1HrAYaFTnsHumroA5O7JzEtcoVYWF DkuswPw1UlXhzqGD8BoGYBqroXZX2K3rhQXEQE3A4JICVqmktILl16zHxCeafoc3/hYJ fpNGjKMJCneVyn7rKD5lq5h46SH9UPb7dKBjiSz+GL7N6eA8IAK82MmpOWsWRXti8ev9 sLVg== X-Gm-Message-State: AOAM530UZcYjWSjo/gq/L/ZxkJMZRZk0YFvphvvCQWTxJTLACSThGf+q c0RIfu57nZw83OZHkrCzPMURKlqhGZE= X-Google-Smtp-Source: ABdhPJyE3I911PrYG72YKmJIRTox1TvWnQu5nxgiVVVWgx9xYRQ1rzDqGI4e6YUmeA7bfK8Gu61ChA== X-Received: by 2002:ac8:6911:: with SMTP id e17mr31784317qtr.135.1621946917008; Tue, 25 May 2021 05:48:37 -0700 (PDT) Received: from nishikirei.com.com ([104.131.0.80]) by smtp.gmail.com with ESMTPSA id a68sm13036749qkd.51.2021.05.25.05.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 05:48:36 -0700 (PDT) From: Kit Westneat To: qemu-devel@nongnu.org Subject: [PATCH 3/3] block/blkdebug: add log-blocksize and phys-blocksize parameters Date: Tue, 25 May 2021 12:47:53 +0000 Message-Id: <20210525124753.528516-4-kit.westneat@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210525124753.528516-1-kit.westneat@gmail.com> References: <20210525124753.528516-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 | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index c7500746a8..e5cfdab32b 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 */ } }, @@ -575,6 +587,20 @@ 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; @@ -1001,11 +1027,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; } @@ -1036,6 +1060,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",