fix(vhd-lib/createStreamNbd): create binary instead of object stream

This reduces memory consumption.
This commit is contained in:
Florent Beauchamp 2023-12-07 14:53:11 +00:00 committed by Julien Fontanet
parent 5a0cfd86c7
commit 7ddfb2a684
2 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,8 @@
### Bug fixes
- [Backup] Reduce memory consumption when using NBD (PR [#7216](https://github.com/vatesfr/xen-orchestra/pull/7216))
> Users must be able to say: “I had this issue, happy to know it's fixed”
- [REST API] Returns a proper 404 _Not Found_ error when a job does not exist instead of _Internal Server Error_
@ -41,6 +43,7 @@
<!--packages-start-->
- @xen-orchestra/xapi patch
- vhd-lib patch
- xo-server minor
- xo-server-auth-saml minor
- xo-server-transport-email major

View File

@ -14,8 +14,8 @@ const {
const { fuHeader, checksumStruct } = require('./_structs')
const assert = require('node:assert')
exports.createNbdRawStream = async function createRawStream(nbdClient) {
const stream = Readable.from(nbdClient.readBlocks())
exports.createNbdRawStream = function createRawStream(nbdClient) {
const stream = Readable.from(nbdClient.readBlocks(), { objectMode: false })
stream.on('error', () => nbdClient.disconnect())
stream.on('end', () => nbdClient.disconnect())
@ -103,7 +103,7 @@ exports.createNbdVhdStream = async function createVhdStream(nbdClient, sourceStr
yield bufFooter
}
const stream = Readable.from(iterator())
const stream = Readable.from(iterator(), { objectMode: false })
stream.length = (offsetSector + blockSizeInSectors + 1) /* end footer */ * SECTOR_SIZE
stream._nbd = true
stream.on('error', () => nbdClient.disconnect())