mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-23 06:05:21 +00:00
qcow: Fix wrong alignment calculation
With the existing code, `round_up(7, 2)` would generate `6` which is obviously wrong. Also, following what's done for 'round_down()', the fixed code does not handle 'alignment == 0' explicitly. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
134e555c42
commit
5f4a6b42c0
@ -69,7 +69,7 @@ impl RawFile {
|
|||||||
|
|
||||||
fn round_up(&self, offset: u64) -> u64 {
|
fn round_up(&self, offset: u64) -> u64 {
|
||||||
let align: u64 = self.alignment.try_into().unwrap();
|
let align: u64 = self.alignment.try_into().unwrap();
|
||||||
((offset / (align + 1)) + 1) * align
|
((offset + align - 1) / align) * align
|
||||||
}
|
}
|
||||||
|
|
||||||
fn round_down(&self, offset: u64) -> u64 {
|
fn round_down(&self, offset: u64) -> u64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user