[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 00/21] nbd: add qemu-nbd --list
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4 00/21] nbd: add qemu-nbd --list |
Date: |
Fri, 18 Jan 2019 16:47:42 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 1/18/19 7:47 AM, Vladimir Sementsov-Ogievskiy wrote:
>
> > Only expose MBR partition @var{num}. Understands physical partitions
> > 1-4 and logical partitions 5-8.
>
> I'm afraid, I'm too lazy to sort out these things I don't know, so just
> believe. It at least
> corresponds to limits in code that it should be 1 <= partition <= 8 ;)
It matches the code, but I just learned the code is buggy for anything
larger than 5. According to
http://tldp.org/HOWTO/Large-Disk-HOWTO-13.html, MBR Extended/Logical
partitions form a linked-list, something like:
MBR: EBR1 EBR2
+----------+ +----------+ +----------+
+ Part 1 + |->+ Part 5 + |->+ Part 6 +
+ Part 2 + | + Next --------| + 0 +
+ Part 3 + | + 0 + + 0 +
+ Part 4 ------- + 0 + + 0 +
+----------+ +----------+ +----------+
In reality, ANY of part 1-4 can point to the first EBR, as long as there
is at most one primary partition pointing to the extended partition -
even crazier is that there are different magic numbers in historical
use, such as type 5 for Part 3 and type 85 for Part 4, where MS-DOS
would treat Partition 3 as the extended partition and ignore Part 4, but
Linux would follow both chains (where the second extended partition thus
allowed Linux access to logical partitions residing in space beyond what
DOS could access). But once you start the extended partition chain, all
logical partitions within the chain each have their own EBR table with
one entry for the partition and the next entry pointing to the next EBR,
meaning you can have more than 8 logical partitions (provided your disk
is big enough).
But our find_partition() code stupidly assumes that if there is any
extended partition type in the MBR (recognizing only type 5 or type F,
but not Linux' type 85), then all four entries in that EBR are logical
partitions 5-8 (and no more, rather than a linked list chain, as in:
MBR: EBR
+----------+ +----------+
+ Part 1 + |->+ Part 5 +
+ Part 2 + | + Part 6 +
+ Part 3 + | + Part 7 +
+ Part 4 ------- + Part 8 +
+----------+ +----------+
It's highly unlikely that there are any BIOS implementations that would
actually recognize such a partition beyond 5 as being bootable (there
might be OSs which are a bit more tolerant, since MBR doesn't seem to
have any one hard canonical specification). I'd have to compare what
the Linux kernel MBR code does, to see if we even stand a chance of
being interoperable in any manner. It doesn't help that nbdkit does not
yet support Logical MBR partitions.
Oh well, another project for another day; this documentation change is
going in as-is because it at least matches the code, even if the code is
buggy. (I'm tempted to fix nbdkit to fully support MBR logical
partitions, then rip out the partitioning code in qemu as redundant as
you could get it via nbdkit if you really need it - qemu-nbd's -P 8 has
unchanged, and thus buggy, since at least commit 7a5ca8648 in May 2008,
with no user complaining of a bug for 11 years)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v4 18/21] nbd/client: Add meta contexts to nbd_receive_export_list(), (continued)
- [Qemu-devel] [PATCH v4 18/21] nbd/client: Add meta contexts to nbd_receive_export_list(), Eric Blake, 2019/01/17
- [Qemu-devel] [PATCH v4 14/21] nbd/client: Split handshake into two functions, Eric Blake, 2019/01/17
- [Qemu-devel] [PATCH v4 19/21] qemu-nbd: Add --list option, Eric Blake, 2019/01/17
- [Qemu-devel] [PATCH v4 12/21] nbd/client: Split out nbd_receive_one_meta_context(), Eric Blake, 2019/01/17
- [Qemu-devel] [PATCH v4 13/21] nbd/client: Refactor return of nbd_receive_negotiate(), Eric Blake, 2019/01/17
- [Qemu-devel] [PATCH v4 21/21] iotests: Enhance 223, 233 to cover 'qemu-nbd --list', Eric Blake, 2019/01/17
- Re: [Qemu-devel] [PATCH v4 00/21] nbd: add qemu-nbd --list, Vladimir Sementsov-Ogievskiy, 2019/01/18
Re: [Qemu-devel] [PATCH v4 00/21] nbd: add qemu-nbd --list, Eric Blake, 2019/01/18