From nobody Sat Nov 23 19:52:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1731463310; cv=none; d=zohomail.com; s=zohoarc; b=nhWx7DmAsLQVn2ChWrmcVz3Hsi15zf9LW1BYxGQiZO7gz++67BTEOjfa81l4Uy6RoVJr1js4lgJX/7qw5nMVUWdPBXz9wwDcUP7KZPipcVEdezQFbdpUdH/uWM/Cw6oR7mD8qNCaGxRDFBDywt6Cn0rNoaaVvLWO+EKS59d5gHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731463310; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5ZKQm9QTjhjenwlOdsFZFETQY1lUeJmGy2cUTCKP0i4=; b=Wcgdq3Psk4ArvozSQvuAdkDUyGABhMrjTBambuCg/BiORRFP5IykORCIyPM0p0mJwetw3gXlsguZjIxufRJPjf5c9VwIu8AVCmT+kw8vgrqWalcHfsTnPuBdIkRHpOs+W6CNcxFoz2Mjkb9k7TBxljyb5gRcUE7N2dkQTHB1T1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731463310650535.7607881232124; Tue, 12 Nov 2024 18:01:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tB2gp-0001jR-Pr; Tue, 12 Nov 2024 21:01:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tB0OP-0001Df-1n; Tue, 12 Nov 2024 18:33:53 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tB0ON-0008ST-Dz; Tue, 12 Nov 2024 18:33:52 -0500 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-720be27db27so5278124b3a.2; Tue, 12 Nov 2024 15:33:50 -0800 (PST) Received: from localhost.colo.rubrik.com ([104.171.196.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724078bfccfsm11963033b3a.82.2024.11.12.15.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 15:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731454429; x=1732059229; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5ZKQm9QTjhjenwlOdsFZFETQY1lUeJmGy2cUTCKP0i4=; b=KkFond4etmfKhy2TB7gjrWuAO5EyRT6BpXZ21ii8XQ/tByTPRaAW24PTk1HOjwIssr H2QrxWfY9tNiAk5ddMgSRUabzukwTLknLaEi+qzB2EdfWc+S+aonKt2eKSjdwqlUDvit ct1x8unuf9d9GCBA2s+5wwUrjgxmXcg1IgKya1NR9ubTqKfeHyxBqNicQrgf/yag/Au7 lCoIyseTxoCkVcEbFw1anRlAvatXhHqflfW97w16m60in4Su9zY2twovk+IPbzxcni4c m5+au2hqgEApVATMrR+Gt6mR+PFZ8kQUh0UwfCGwTavr8uCkqyxsz5iN9hXHZ7UI7QLX TPCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731454429; x=1732059229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5ZKQm9QTjhjenwlOdsFZFETQY1lUeJmGy2cUTCKP0i4=; b=Ui1nhcb6rZh2a6BkJqMj8vY5ATa+U58ddaYnsY+TKidPAU+Ai6T0dEWrSSPv28PaBj bip9ZsYiqniQ3u9qYQnCCh+zZOwlkTm6QoyoeODKX1pmC6nD8U3wqil5+ebRzhA8OOvj 3flhSuytTOAxrHMHqpZJBpQ9LNjUd+yckP81Nja5Bg9Ski0T/dnB0jJ+lSnUAKWdi0zJ 8FOmDUFXAub92aPnrbUHudhZ+OlfBAg6KR/2cyhARSX6/vl6mhBfCW0rTTC68LTUjPlc 7rciUGceyOKm65bGg7vSNhSPu5xIWuaC5AB+AHJYTQCN0DM3y8RHoK2yBHrBYt5YQZT7 dydA== X-Forwarded-Encrypted: i=1; AJvYcCWpFQplmsII61kY+1ebjLcO9dRm66Upfv/2Ii+VNP24C6bKrpyBD1/irrw8xFIiKXC0IcWH7Ge6hF+X@nongnu.org X-Gm-Message-State: AOJu0YzyBadCV3yaLXDLEx24GtEL6tHZOc5mGo8oy4Efnn5Gp5qko/mw Jr5ZY7XTuiZ2Rx/owI/jHIk/dj+MLGOww0NEWFI+/9h5+76UgZr8xxNM3GLUr5Q= X-Google-Smtp-Source: AGHT+IHtUOYYO4q6H/+jATIALOHzE7kJqlLHKzIO0bJldg6akibAKoVu6DW/i+w2QgxatOlvBdUJ6g== X-Received: by 2002:a05:6a00:2441:b0:71e:6bf1:158f with SMTP id d2e1a72fcca58-7244a5d3ad6mr6002093b3a.21.1731454428911; Tue, 12 Nov 2024 15:33:48 -0800 (PST) From: Takeshi Suzuki To: qemu-devel@nongnu.org Cc: codyprime@gmail.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, Takeshi Suzuki Subject: [PATCH 1/2] Add RW support for 4k sector size vhdx Date: Tue, 12 Nov 2024 23:33:03 +0000 Message-Id: <20241112233304.3300-2-takeshibaconsuzuki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112233304.3300-1-takeshibaconsuzuki@gmail.com> References: <20241112233304.3300-1-takeshibaconsuzuki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=takeshibaconsuzuki@gmail.com; helo=mail-pf1-x429.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-Mailman-Approved-At: Tue, 12 Nov 2024 21:01:02 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1731463311461116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Takeshi Suzuki --- block/vhdx.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/block/vhdx.c b/block/vhdx.c index 5aa1a13506..495ddc2815 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -824,8 +824,8 @@ vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState= *s) goto exit; } =20 - /* Currently we only support 512 */ - if (s->logical_sector_size !=3D 512) { + /* Currently we only support 512 and 4096 */ + if (s->logical_sector_size !=3D 512 && s->logical_sector_size !=3D 409= 6) { ret =3D -ENOTSUP; goto exit; } @@ -1060,7 +1060,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *opt= ions, int flags, =20 /* the VHDX spec dictates that virtual_disk_size is always a multiple = of * logical_sector_size */ - bs->total_sectors =3D s->virtual_disk_size >> s->logical_sector_size_b= its; + bs->total_sectors =3D s->virtual_disk_size >> BDRV_SECTOR_BITS; =20 vhdx_calc_bat_entries(s); =20 @@ -1178,11 +1178,52 @@ vhdx_co_get_info(BlockDriverState *bs, BlockDriverI= nfo *bdi) } =20 =20 +/* + * Converts bdrv sectors to sectors of s->logical_sector_size. + */ +static void bdrv_sectors_to_sectors(const int64_t bdrv_sector_num, + const int bdrv_nb_sectors, + const BDRVVHDXState *const s, + int64_t * const out_sector_num, + int * const out_nb_sectors, + /* in bytes */ + int * const out_begin_skip, + /* in bytes */ + int * const out_end_skip) { + if (bdrv_nb_sectors =3D=3D 0) { + *out_nb_sectors =3D 0; + return; + } + const int64_t begin_off =3D bdrv_sector_num * BDRV_SECTOR_SIZE; + const int64_t sector_num =3D begin_off >> s->logical_sector_size_bits; + const int begin_skip =3D begin_off - sector_num * s->logical_sector_si= ze; + const int64_t end_off =3D (bdrv_sector_num + bdrv_nb_sectors) * + BDRV_SECTOR_SIZE; + const int64_t end_sector_num =3D (end_off + s->logical_sector_size - 1= ) >> + s->logical_sector_size_bits; + const int end_skip =3D end_sector_num * s->logical_sector_size - end_o= ff; + const int nb_sectors =3D end_sector_num - sector_num; + *out_sector_num =3D sector_num; + *out_nb_sectors =3D nb_sectors; + *out_begin_skip =3D begin_skip; + *out_end_skip =3D end_skip; +} + + static int coroutine_fn GRAPH_RDLOCK vhdx_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BDRVVHDXState *s =3D bs->opaque; + int begin_skip, end_skip; + bdrv_sectors_to_sectors(sector_num, + nb_sectors, + s, + §or_num, + &nb_sectors, + &begin_skip, + &end_skip); + int ret =3D 0; VHDXSectorInfo sinfo; uint64_t bytes_done =3D 0; @@ -1216,9 +1257,16 @@ vhdx_co_readv(BlockDriverState *bs, int64_t sector_n= um, int nb_sectors, qemu_iovec_memset(&hd_qiov, 0, 0, sinfo.bytes_avail); break; case PAYLOAD_BLOCK_FULLY_PRESENT: + if (bytes_done =3D=3D 0) { + sinfo.file_offset +=3D begin_skip; + sinfo.bytes_avail -=3D begin_skip; + } + if (nb_sectors - sinfo.sectors_avail <=3D 0) { + sinfo.bytes_avail -=3D end_skip; + } qemu_co_mutex_unlock(&s->lock); ret =3D bdrv_co_preadv(bs->file, sinfo.file_offset, - sinfo.sectors_avail * BDRV_SECTOR_SIZ= E, + sinfo.bytes_avail, &hd_qiov, 0); qemu_co_mutex_lock(&s->lock); if (ret < 0) { @@ -1336,8 +1384,17 @@ static int coroutine_fn GRAPH_RDLOCK vhdx_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags) { - int ret =3D -ENOTSUP; BDRVVHDXState *s =3D bs->opaque; + int begin_skip, end_skip; + bdrv_sectors_to_sectors(sector_num, + nb_sectors, + s, + §or_num, + &nb_sectors, + &begin_skip, + &end_skip); + + int ret =3D -ENOTSUP; VHDXSectorInfo sinfo; uint64_t bytes_done =3D 0; uint64_t bat_entry =3D 0; @@ -1451,9 +1508,16 @@ vhdx_co_writev(BlockDriverState *bs, int64_t sector_= num, int nb_sectors, sinfo.bytes_avail); } /* block exists, so we can just overwrite it */ + if (bytes_done =3D=3D 0) { + sinfo.file_offset +=3D begin_skip; + sinfo.bytes_avail -=3D begin_skip; + } + if (nb_sectors - sinfo.sectors_avail <=3D 0) { + sinfo.bytes_avail -=3D end_skip; + } qemu_co_mutex_unlock(&s->lock); ret =3D bdrv_co_pwritev(bs->file, sinfo.file_offset, - sectors_to_write * BDRV_SECTOR_SIZE, + sinfo.bytes_avail, &hd_qiov, 0); qemu_co_mutex_lock(&s->lock); if (ret < 0) { --=20 2.34.1 From nobody Sat Nov 23 19:52:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1731463310; cv=none; d=zohomail.com; s=zohoarc; b=Gi642sRZy6MDv0buh2r1S2vddSXbidomG0h8u4t779Ev4YBDmvz2vNc8lkM8AKuB+EnacbhUhso2Yf8yKJ3xT3g9Sde0xECGuzxNwZKd4Eb5ppn0tMMg2EjoAeSvp2H/Q7ZUTlj0MT/UjRxvVyaSpW47j+//NG25RE658cUuv8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731463310; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=st/MPV2/1+Z8iOLeaTSiJNQxS708c/yTD2s3KbkH1AY=; b=QpfxXFi/Ac32blgH2q4AFul9WGYT59uTLAJrjJiPv4g5SUcSW+p6TQlVjlISShpAY8mZHpDdXF1qkkkDzm4kwJX9wSeZPcdcJ0lAnkX5mJ+CF1sP2GdGAjtHzLMApwVmCArAFXF0soQUgGKq/i1QKkaejS96bvu8HMqXk3UGgV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731463310741662.4837322694241; Tue, 12 Nov 2024 18:01:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tB2gq-0001jq-Jv; Tue, 12 Nov 2024 21:01:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tB0OV-0001HX-0z; Tue, 12 Nov 2024 18:34:00 -0500 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tB0OR-0008So-DU; Tue, 12 Nov 2024 18:33:58 -0500 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-720be27db27so5278168b3a.2; Tue, 12 Nov 2024 15:33:54 -0800 (PST) Received: from localhost.colo.rubrik.com ([104.171.196.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724078bfccfsm11963033b3a.82.2024.11.12.15.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 15:33:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731454433; x=1732059233; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=st/MPV2/1+Z8iOLeaTSiJNQxS708c/yTD2s3KbkH1AY=; b=SigUqxKvNqIVkFCX/iq/Pleqaoc91G3RN74CY+X0njrYZLuvSSZHCt6ZTnB8kfCxJ0 X8s17nhwRd1iUdqE82P3jdmDPUSIcGG+Tyu4d5i0DX4xECN6mQ0MgNS+UXFLX5aIFLiO BZsbOC0uMMJol8bmcnteR8ofj+ifT7YPzJ6Prn6LA6VqDOY8qRskQItOsGSPpZAdncrc vQaNZbcmLYLolkoSN0vH0R56u8nc6CzWUqJ4ELiMeuF5I8oZ45hrNmSkUPOqQIoAEHrJ QbIUYjrb8eylkpgdED0Mj/V2PKTlEfsjLx1iF8K1nmWq2gR3+v5Rkd1O87n0oGvpgZye gHpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731454433; x=1732059233; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=st/MPV2/1+Z8iOLeaTSiJNQxS708c/yTD2s3KbkH1AY=; b=xPmVDbbPnBVl2ggHiHX5GJ+j+HlWs1lBG2isV6itd75/gG6R+4lBJiHZD1zoN2JUvz 6Nh3CEyd3aQ2Zz8Lj6RQicUkdGPczNG3GEXuiHlAiUOCZY8GSwACAWBWVXzTcrxS+H+v HOtFuOX9hSMdfQVySz0/g48ENnn3Ns8L3XNIqlyLeaPK7Lj3uIQCYNJOtqFeOcTU7od1 Z4cdewSxata1aqU8ynAmq0bLXYLOKxkVYMubNTLZv7BbqO/sNRKnj5N7HnlJNEo+uSDA mXuKbM6iup8PTlR/3YoBsAaBWHQ6JOUcosMtzgSuhFHegZ9ndeHu0FTLgZvuOmhnZHVv 6H2A== X-Forwarded-Encrypted: i=1; AJvYcCVGTg2WCTFn7cruPBfN8s5WSCkCQI7mWQyY7pzWeZkpNUKxYvzpnfbRfAC9txoHwag6cv8RP2TEb4PL@nongnu.org X-Gm-Message-State: AOJu0YzsAlsAp2/krTJFvyL3lMD8csehrGer0QmKp/uHk1uQvGGVBGqM R5To4ImHKM5giA+NKqGrWXs1DEFhNLqvbMvwEfANVqac+Ji9pIMIv3GHpaZyg9U= X-Google-Smtp-Source: AGHT+IFs79WzD+MaZyfu6Tyc2zFB+obAby8BT7kSj7dCa1IhpFtJAdzjdtRzt/j8ZMDlU6bbcFWpgQ== X-Received: by 2002:a05:6a21:99a8:b0:1db:d738:f2ff with SMTP id adf61e73a8af0-1dc5f8cbcccmr5686869637.2.1731454433315; Tue, 12 Nov 2024 15:33:53 -0800 (PST) From: Takeshi Suzuki To: qemu-devel@nongnu.org Cc: codyprime@gmail.com, kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, Takeshi Suzuki Subject: [PATCH 2/2] Add iotest for 4k sector size vhdx Date: Tue, 12 Nov 2024 23:33:04 +0000 Message-Id: <20241112233304.3300-3-takeshibaconsuzuki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241112233304.3300-1-takeshibaconsuzuki@gmail.com> References: <20241112233304.3300-1-takeshibaconsuzuki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=takeshibaconsuzuki@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 12 Nov 2024 21:01:02 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1731463311430116600 Content-Type: text/plain; charset="utf-8" See https://github.com/takeshibaconsuzuki/qemu/blob/vhdx_4k_rw/tests/qemu-iotes= ts/sample_images/4k.vhdx.bz2 for binary file. Signed-off-by: Takeshi Suzuki --- tests/qemu-iotests/315 | 65 +++++++++++++++++++ tests/qemu-iotests/315.out | 20 ++++++ tests/qemu-iotests/sample_images/4k.vhdx.bz2 | Bin 0 -> 37834 bytes 3 files changed, 85 insertions(+) create mode 100644 tests/qemu-iotests/315 create mode 100644 tests/qemu-iotests/315.out create mode 100644 tests/qemu-iotests/sample_images/4k.vhdx.bz2 diff --git a/tests/qemu-iotests/315 b/tests/qemu-iotests/315 new file mode 100644 index 0000000000..e5c4978c8c --- /dev/null +++ b/tests/qemu-iotests/315 @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +# group: rw quick +# +# Test VHDX read/write from a 4k sector size sample image created with Hyp= er-V +# +# Copyright (C) 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dtakeshibaconsuzuki@gmail.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt vhdx +_supported_proto generic +_supported_os Linux + +_use_sample_img 4k.vhdx.bz2 + +echo +echo "=3D=3D=3D Verify pattern 0xaa, 1024MB - 1088MB =3D=3D=3D" +$QEMU_IO -r -c "read -pP 0xaa 1024M 64M" "$TEST_IMG" | _filter_qemu_io +echo +echo "=3D=3D=3D Verify pattern 0x00, 1088MB - 1152MB =3D=3D=3D" +$QEMU_IO -r -c "read -pP 0x00 1088M 64M" "$TEST_IMG" | _filter_qemu_io + +echo +echo "=3D=3D=3D Verify pattern write, 0xbb 1072MB - 1104MB =3D=3D=3D" +$QEMU_IO -c "write -pP 0xbb 1072M 32M" "$TEST_IMG" | _filter_qemu_io +# first verify we didn't write where we should not have +$QEMU_IO -r -c "read -pP 0xaa 1024M 48M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -r -c "read -pP 0x00 1104M 48M" "$TEST_IMG" | _filter_qemu_io +# now verify what we should have actually written +$QEMU_IO -r -c "read -pP 0xbb 1072M 32M" "$TEST_IMG" | _filter_qemu_io + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/315.out b/tests/qemu-iotests/315.out new file mode 100644 index 0000000000..31dd48b223 --- /dev/null +++ b/tests/qemu-iotests/315.out @@ -0,0 +1,20 @@ +QA output created by 315 + +=3D=3D=3D Verify pattern 0xaa, 1024MB - 1088MB =3D=3D=3D +read 67108864/67108864 bytes at offset 1073741824 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Verify pattern 0x00, 1088MB - 1152MB =3D=3D=3D +read 67108864/67108864 bytes at offset 1140850688 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Verify pattern write, 0xbb 1072MB - 1104MB =3D=3D=3D +wrote 33554432/33554432 bytes at offset 1124073472 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 50331648/50331648 bytes at offset 1073741824 +48 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 50331648/50331648 bytes at offset 1157627904 +48 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 1124073472 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +*** done diff --git a/tests/qemu-iotests/sample_images/4k.vhdx.bz2 b/tests/qemu-iote= sts/sample_images/4k.vhdx.bz2 new file mode 100644 index 0000000000..6cc10919ab Binary files /dev/null and b/tests/qemu-iotests/sample_images/4k.vhdx.bz2 d= iffer --=20 2.34.1