Kevin Wolf <[email protected]> writes:

> Am 05.11.2025 um 08:08 hat Markus Armbruster geschrieben:
>> Kevin Wolf <[email protected]> writes:
>> 
>> [...]
>> 
>> > To me it looks a bit like what we really want is an enum for floppy
>> > sizes (though is there any real reason why we have only those two?), but
>> > an arbitrary size for hard disks.
>> >
>> > Without the enum, obviously, users could specify 1440k and that would do
>> > the right thing. Maybe special casing whatever 1.44M and 2.88M result
>> > in and translating them into 1440k and 2880k could be more justifiable
>> > than special casing 1M and 2M, but it would still be ugly.
>> >
>> > Markus, do you have any advice how this should be represented in QAPI?
>> 
>> Still want answers here?
>
> Yes, I'm still not sure how we could best represent both hard disk and
> floppy sizes in vvfat in a way that isn't completely counterintuitive
> for users, that also isn't just arbitrary magic and that works on the
> command line.
>
> Unless the need for different sizes has gone away, but I don't think we
> found any other solution for the problem that would not require a
> configurable disk/file system size?

Let me recap the problem.  Please correct my misunderstandings, if any.

Hard disks can have almost arbitrary sizes.  Almost, because it still
needs to be a multiple of the block size.

Floppy disks have one of a small set of well-known sizes.

I vaguely recall that we generally derive the device's actual size from
the backend's size.

Some devices reject certain sizes.  For instance, SD cards require a
power of 2.

Most devices seem to accept anything.  I can create an IDE, SCSI, or
floppy disk backed by a raw image of one byte.  I have no idea how it
would behave.

As is, the vvfat backend can only do certain sizes, configurable with
parameters @floppy and @fat-type.  They work for floppies, but not for
SD cards, since they're not powers of two.

Instead of deriving size and CHS from @floppy and @fat-type, Clément
proposes to specify the size (and derive fat-type and CHS[*]?).

In QMP, we specify the size in bytes.  This is fine regardless of size;
management applications don't mind sending things like "size": 1474560.

In HMP and the command line, big byte sizes are inconvenient.  That's
why we support suffixes there.  size=256M is a fine way to pick an SD
card's size.

The size suffixes seem inconvenient for floppies, though.  For instance,
2 heads * 80 tracks * 18 sectors * 512 bytes = 1474560 bytes = 1440
KiBytes, but size=1.44M does not work: 1.44 MiBytes = 1509949.44 Bytes.
However, size=1440K does.

This leads me to suggest to simply stick to numeric size, and use
appropriate suffixes.  These are obvious enough for anything but
floppies.  So advise users "use K for floppies"[**].

If this isn't good enough, I can help you explore fancier parts of QAPI,
such as alternate types.




[*] I guess we could support specifying an optional fat-type in addition
to size, and derive only CHS then.

[**] Even for a hypothetical floppy with an odd number of 512 byte
sectors: .5K works, because .5 * 1024 is an integer.


Reply via email to