mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-09-10 22:14:48 -05:00
fix(nbd-client): nbddisk must emit full size block (#9233)
This commit is contained in:
committed by
GitHub
parent
16de2e9fca
commit
6277a12c4a
@@ -40,7 +40,17 @@ export class NbdDisk extends RandomAccessDisk {
|
||||
if (!this.#nbdClient) {
|
||||
throw new Error("can't readBlock before init")
|
||||
}
|
||||
const data = await this.#nbdClient.readBlock(index, this.getBlockSize())
|
||||
let data = await this.#nbdClient.readBlock(index, this.getBlockSize())
|
||||
if (data.length !== this.getBlockSize()) {
|
||||
// this condition only work on non aligned disks
|
||||
// we won't accept truncated block from unaligned disks
|
||||
if (index === Math.ceil(this.getVirtualSize() / this.getBlockSize()) - 1) {
|
||||
// last block add zeros at the end
|
||||
data = Buffer.concat([data], this.getBlockSize())
|
||||
} else {
|
||||
throw new Error(`Block ${index} is not at the right size, expecting ${this.getBlockSize()}, got ${data.length}`)
|
||||
}
|
||||
}
|
||||
return {
|
||||
index,
|
||||
data,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
- [i18n] Update Czech, German, French, Italian, Dutch, Portuguese (Brazil), and Ukrainian translations, and add Danish translation (PR [#9165](https://github.com/vatesfr/xen-orchestra/pull/9165))
|
||||
|
||||
### Bug fixes
|
||||
- [V2V] fix transfer failing at 99% for unaligned disk (PR [#9233](https://github.com/vatesfr/xen-orchestra/pull/9233))
|
||||
|
||||
### Packages to release
|
||||
|
||||
@@ -35,8 +36,7 @@
|
||||
|
||||
<!--packages-start-->
|
||||
|
||||
- @xen-orchestra/web minor
|
||||
- @xen-orchestra/web-core minor
|
||||
- xo-web minor
|
||||
- @vates/nbd-client patch
|
||||
- vhd-lib patch
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Readable } from 'stream'
|
||||
import { BaseVhd, FULL_BLOCK_BITMAP } from './BaseVhd.mjs'
|
||||
import assert from 'node:assert'
|
||||
|
||||
/**
|
||||
* @typedef {Readable & { length: number }} VhdStream
|
||||
@@ -23,6 +24,7 @@ export class DiskConsumerVhdStream extends BaseVhd {
|
||||
yield header
|
||||
yield bat
|
||||
for await (const { data } of blockGenerator) {
|
||||
assert.strictEqual(data.length, 2 * 1024 * 1024)
|
||||
yield Buffer.concat([FULL_BLOCK_BITMAP, data])
|
||||
}
|
||||
yield footer
|
||||
|
||||
Reference in New Issue
Block a user