[block/vpc] dynamic disk header: off-by-one error for "num_bat_entries"
Bug #1870098 reported by
Tobias Witek
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
In current qemu versions (observed in 5.0.0-rc1 as well as 2833ad487cfff7d
https:/
"Max Table Entries
This field holds the maximum entries present in the BAT. This should be equal to the number of blocks in the disk (that is, the disk size divided by the block size)."
Inside the qemu code, the value is "disk size divided by the block size *plus one*".
Calculating "num_bat_entries" as "total_
To post a comment you must log in.
Is there any actual bug resulting from this that you're observing? As I read the spec, having a longer BAT is merely unconventional, not strictly wrong. So if another application fails to deal with such images, it's probably a bug in that application.
Of course, I can't see a reason for making the BAT longer than necessary either. We do, however, need to round up if the disk size is not a multiple of the image block size. So I think what it really should be is:
num_bat_entries = DIV_ROUND_ UP(total_ sectors, block_size / 512)
If you agree, please let me know if I should submit a patch or if you would like to do that yourself. (See https:/ /wiki.qemu. org/Contribute/ SubmitAPatch)