fix(xo-server): VMDK/OVA import (#6669)
This commit is contained in:
committed by
GitHub
parent
f8fd6b78f5
commit
61d5a964ee
@@ -18,6 +18,7 @@
|
||||
- [NBD Backup] Fix VDI not disconnecting from control domain (PR [#6660](https://github.com/vatesfr/xen-orchestra/pull/6660))
|
||||
- [NBD Backup] Improve performance by avoid unnecessary VDI transfers
|
||||
- [Home/Pool] Do not check for support on non `XCP-ng` pool (PR [#6661](https://github.com/vatesfr/xen-orchestra/pull/6661))
|
||||
- [VMDK/OVA import] Fix error importing a VMDK or an OVA generated from XO (PR [#6669](https://github.com/vatesfr/xen-orchestra/pull/6669))
|
||||
|
||||
### Packages to release
|
||||
|
||||
@@ -41,6 +42,7 @@
|
||||
- xo-cli patch
|
||||
- xo-server patch
|
||||
- xo-server-transport-email patch
|
||||
- xo-vmdk-to-vhd patch
|
||||
- xo-web patch
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
@@ -11,6 +11,7 @@ import { vmdkToVhd } from 'xo-vmdk-to-vhd'
|
||||
|
||||
import { VDI_FORMAT_VHD, VDI_FORMAT_RAW } from '../xapi/index.mjs'
|
||||
import { parseSize } from '../utils.mjs'
|
||||
import { readChunk } from '@vates/read-chunk'
|
||||
|
||||
const log = createLogger('xo:disk')
|
||||
|
||||
@@ -225,6 +226,14 @@ async function handleImport(req, res, { type, name, description, vmdkData, srId,
|
||||
)
|
||||
try {
|
||||
await vdi.$importContent(vhdStream, { format: diskFormat })
|
||||
let buffer
|
||||
const CHUNK_SIZE = 1024 * 1024
|
||||
// drain remaining content ( padding .header)
|
||||
// didn't succeed to ensure the stream is completly consumed with resume/finished
|
||||
do {
|
||||
buffer = await readChunk(part, CHUNK_SIZE)
|
||||
} while (buffer.length === CHUNK_SIZE)
|
||||
|
||||
res.end(format.response(0, vdi.$id))
|
||||
} catch (e) {
|
||||
await vdi.$destroy()
|
||||
|
||||
@@ -186,7 +186,11 @@ export default class VMDKDirectParser {
|
||||
const grainPosition = this.grainFileOffsetList[tableIndex] * SECTOR_SIZE
|
||||
const grainSizeBytes = this.header.grainSizeSectors * SECTOR_SIZE
|
||||
const lba = this.grainLogicalAddressList[tableIndex] * grainSizeBytes
|
||||
assert.strictEqual(grainPosition >= position, true)
|
||||
assert.strictEqual(
|
||||
grainPosition >= position,
|
||||
true,
|
||||
`Grain position ${grainPosition} must be after current position ${position}`
|
||||
)
|
||||
await this.virtualBuffer.readChunk(grainPosition - position, `blank from ${position} to ${grainPosition}`)
|
||||
let grain
|
||||
if (this.header.flags.hasMarkers) {
|
||||
|
||||
@@ -1780,7 +1780,13 @@ const importDisk = async ({ description, file, name, type, vmdkData }, sr) => {
|
||||
})
|
||||
formData.append('file', file)
|
||||
const result = await post(res.$sendTo, formData)
|
||||
const body = await result.json()
|
||||
const text = await result.text()
|
||||
let body
|
||||
try {
|
||||
body = JSON.parse(text)
|
||||
} catch (error) {
|
||||
throw new Error(`Body is not a JSON, original message is : ${text}`)
|
||||
}
|
||||
if (result.status !== 200) {
|
||||
throw new Error(body.error.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user