From nobody Fri Nov 14 17:01:10 2025 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=quarantine dis=none) header.from=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1762527253; cv=none; d=zohomail.com; s=zohoarc; b=hc/AsXivRnMbCmT8T+AhckOq4vnGOA7ZZPCCuxKGRvO91OlsqJTNEZsL3cRXZneqUzXvsvcoL0BhRSuNiOgLLlcBt7aga8vzUfDMhU8Mu5uKLXzj/SsswHMLefDxmeZHL0VA6mSxk53wd9QhagiOscQUqJ1UUAbLnW2vJ+p217Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762527253; h=Content-Type: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=izy7/qPzPQoipaFGeT4gnLUB0venGvr75VtHiWV0UpE=; b=iT1yIxzLSNg3mWUdDcxwmB8IUDVXTmw6fY2IzKxP4iOEUszfxpai2Hs2xLRPZm9FFTbdoFKi7JYRTXyTgSECFGjNMING6vcfaRZkdYK1sYU0MHhJe6Jw4Qt5IXgVT5X2eqa3+G7eAWhLlyBmRCZF9vebiMvgEAzDeNCtqoVGDV4= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762527253627802.7875433150627; Fri, 7 Nov 2025 06:54:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vHNqU-0003hW-8d; Fri, 07 Nov 2025 09:53:46 -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 1vHNqK-0003Ra-KW for qemu-devel@nongnu.org; Fri, 07 Nov 2025 09:53:36 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450: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 1vHNqH-0001tw-74 for qemu-devel@nongnu.org; Fri, 07 Nov 2025 09:53:35 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-429c8632fcbso574664f8f.1 for ; Fri, 07 Nov 2025 06:53:32 -0800 (PST) Received: from chigot-Dell.home ([2a01:cb15:80db:7c00:e453:acd:db85:b66e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42abe63e131sm5922435f8f.20.2025.11.07.06.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Nov 2025 06:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1762527211; x=1763132011; 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=izy7/qPzPQoipaFGeT4gnLUB0venGvr75VtHiWV0UpE=; b=JDOClDWblSY32a8MSvybJqHK3t2KwT1q4OFBEBWbR7mls7yuQz91/V6iayiYp4rWY/ IFIOUqNafMspdIj1vWW3yTM/r1QMsjgOeGS56JoOJuxtyfJOFYiUZPLiJ5vjXzDY/SAh Jo6vw8Z3iY9tY+PcEZnuFTtZi5yKCe40zqTGmbL6MazlknmAlBRQRftcdFIE4qergGrQ 8/J1Q42ySsXce2n5tnf3EvBbJY3YWalz0tSVwX+JKfOqj3zs+t5165ZHuCika7szn28T d5QrIcdnj+IWgavVIY5Vfd+gIQTxsDjLYF2Q2Bb9KVFpiwbTKhDs56yUT+S7kn62ZulA 9C+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762527211; x=1763132011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=izy7/qPzPQoipaFGeT4gnLUB0venGvr75VtHiWV0UpE=; b=uHRABxrxZOMopSjaiY39gfS8UHpXol+lhwGZBjptCgDigaE+qCs42NEVoFrfyTJiwi CowsgMoJfW4Y2hkulldNqQmFBykZ/LLA9tQjJu253Mlc3tu0LllM7Md1j1CTYS/VeWBl Jme4A6BEpwqwFdDtN2wY5pu5NzLT/tMp+N4/qEnaJqWzTNJW/AGJfSGhM5AFcuTBi7RN fSoKGxH3ikojKnAInfzxSfHDprZcohRXTXxVD44yUkyiz4qfYQNfgEJVI3w1Wvl+UiZP OMBdhB9q43IpVsJeUv/C0srvF63lXPdjTj2vEG/c+hwMkxGgrFRfrV4amauRX+ThmLTk SoKA== X-Gm-Message-State: AOJu0YzqPa9hOLmE91TIg5DTGuQTKfRBHzWVAXcVZLjZqxXaQ8Sjdwty nqqZXqup8TRYCE2mHyfabgrd7ty+Xc5Grrj0ATx9f9JHi6Cy1Mc+vfQh0AmCmfDDNA== X-Gm-Gg: ASbGncvlGxZo8Jpu1wbuscU//Dr1RXWwUx8p2Jv+drquxOykY7KgA7sjCkwpEdENs0H 406L4UDXJsw2p0xry8AywsbXyOLsRHqPmAdgyQmaTZ+dsh2ZkrcCzMtcm2Bw7EH9SXQL7za0jrz LD6/hQaXY5x8vj4kCmC0awXCDlAYv8RfrO1LtnHqVGXeuqqG50vXpe7mR9nJoCrROtnTMjnpVGF Tx6UUtgG0Krggj1w0k6eGjWM6yS5KbuDDCYeJ2s4oSYOVWEXLmyge0IMhJQT6e0Y+Plk3Kdwagb QmDUAmaSUyGH+OLdte62uuyKcsqs/MGb4+HMew/QXqyUvQLya9pk5h+WytJ7+wcUxxy4SaTixml WuxRKxL+ScrxZS2XMKml7VwYRdcM8KfWOLfGTRsw9fRhhZfujdNtiQv2u4jmLrwgcKwr5JxL5Gk t0gGX7IdE= X-Google-Smtp-Source: AGHT+IFmIv057xjnjIyUjYmI6jz+jSUOzHJNO7gZIIdGv9cWlh+CWydPo7XQNDYBm87fBaOk79rOnw== X-Received: by 2002:a05:6000:258a:b0:429:cda2:a025 with SMTP id ffacd0b85a97d-42ae58b14fbmr3400600f8f.13.1762527211131; Fri, 07 Nov 2025 06:53:31 -0800 (PST) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, eblake@redhat.com, armbru@redhat.com, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= Subject: [PATCH v2 1/5] vvfat: introduce partitioned option Date: Fri, 7 Nov 2025 15:53:23 +0100 Message-ID: <20251107145327.539481-2-chigot@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251107145327.539481-1-chigot@adacore.com> References: <20251107145327.539481-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::429; envelope-from=chigot@adacore.com; helo=mail-wr1-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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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 @adacore.com) X-ZM-MESSAGEID: 1762527255859158500 This option tells whether a hard disk should be partitioned or not. It defaults to true and have the prime effect of preventing a master boot record (MBR) to be initialized. This is useful as some operating system (QNX, Rtems) don't recognized FAT mounted disks (especially SD cards) if a MBR is present. Signed-off-by: Cl=C3=A9ment Chigot --- block/vvfat.c | 21 +++++++++++++++++++-- qapi/block-core.json | 10 +++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 814796d918..de6031db98 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -306,7 +306,8 @@ typedef struct BDRVVVFATState { array_t fat,directory,mapping; char volume_label[11]; =20 - uint32_t offset_to_bootsector; /* 0 for floppy, 0x3f for disk */ + /* 0x3f for partitioned disk, 0x0 otherwise */ + uint32_t offset_to_bootsector; =20 unsigned int cluster_size; unsigned int sectors_per_cluster; @@ -1082,6 +1083,12 @@ static QemuOptsList runtime_opts =3D { .type =3D QEMU_OPT_BOOL, .help =3D "Make the image writable", }, + { + .name =3D "partitioned", + .type =3D QEMU_OPT_BOOL, + .def_value_str =3D "true", + .help =3D "Do not add a Master Boot Record on this disk", + }, { /* end of list */ } }, }; @@ -1092,6 +1099,7 @@ static void vvfat_parse_filename(const char *filename= , QDict *options, int fat_type =3D 0; bool floppy =3D false; bool rw =3D false; + bool partitioned =3D true; int i; =20 if (!strstart(filename, "fat:", NULL)) { @@ -1116,6 +1124,10 @@ static void vvfat_parse_filename(const char *filenam= e, QDict *options, rw =3D true; } =20 + if (strstr(filename, ":unpartitioned:")) { + partitioned =3D false; + } + /* Get the directory name without options */ i =3D strrchr(filename, ':') - filename; assert(i >=3D 3); @@ -1131,6 +1143,7 @@ static void vvfat_parse_filename(const char *filename= , QDict *options, qdict_put_int(options, "fat-type", fat_type); qdict_put_bool(options, "floppy", floppy); qdict_put_bool(options, "rw", rw); + qdict_put_bool(options, "partitioned", partitioned); } =20 static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, @@ -1196,7 +1209,10 @@ static int vvfat_open(BlockDriverState *bs, QDict *o= ptions, int flags, if (!s->fat_type) { s->fat_type =3D 16; } - s->offset_to_bootsector =3D 0x3f; + /* Reserver space for MBR */ + if (qemu_opt_get_bool(opts, "partitioned", true)) { + s->offset_to_bootsector =3D 0x3f; + } cyls =3D s->fat_type =3D=3D 12 ? 64 : 1024; heads =3D 16; secs =3D 63; @@ -3246,6 +3262,7 @@ static const char *const vvfat_strong_runtime_opts[] = =3D { "floppy", "label", "rw", + "partitioned", =20 NULL }; diff --git a/qapi/block-core.json b/qapi/block-core.json index b82af74256..8a479ba090 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3464,8 +3464,8 @@ # # @fat-type: FAT type: 12, 16 or 32 # -# @floppy: whether to export a floppy image (true) or partitioned hard -# disk (false; default) +# @floppy: whether to export a floppy image (true) or hard disk +# (false; default) # # @label: set the volume label, limited to 11 bytes. FAT16 and FAT32 # traditionally have some restrictions on labels, which are @@ -3474,11 +3474,15 @@ # # @rw: whether to allow write operations (default: false) # +# @partitioned: whether a hard disk will be partitioned +# (default: true) +# (since 10.2) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsVVFAT', 'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool', - '*label': 'str', '*rw': 'bool' } } + '*label': 'str', '*rw': 'bool', '*partitioned': 'bool' } } =20 ## # @BlockdevOptionsGenericFormat: --=20 2.43.0