feat(xo-server/vm.$container): points to host if VDI on local SR
Fixes https://xcp-ng.org/forum/post/71769
This commit is contained in:
parent
7fc5d62ca9
commit
1718649e0c
@ -10,6 +10,7 @@
|
|||||||
- Disable search engine indexing via a `robots.txt`
|
- Disable search engine indexing via a `robots.txt`
|
||||||
- [Stats] Support format used by XAPI 23.31
|
- [Stats] Support format used by XAPI 23.31
|
||||||
- [REST API] Export host [SMT](https://en.wikipedia.org/wiki/Simultaneous_multithreading) status at `/hosts/:id/smt` [Forum#71374](https://xcp-ng.org/forum/post/71374)
|
- [REST API] Export host [SMT](https://en.wikipedia.org/wiki/Simultaneous_multithreading) status at `/hosts/:id/smt` [Forum#71374](https://xcp-ng.org/forum/post/71374)
|
||||||
|
- [Home & REST API] `$container` field of an halted VM now points to a host if a VDI is on a local storage [Forum#71769](https://xcp-ng.org/forum/post/71769)
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
|
@ -328,6 +328,34 @@ const TRANSFORMS = {
|
|||||||
|
|
||||||
const { creation } = xoData.extract(obj) ?? {}
|
const { creation } = xoData.extract(obj) ?? {}
|
||||||
|
|
||||||
|
let $container
|
||||||
|
if (obj.resident_on !== 'OpaqueRef:NULL') {
|
||||||
|
// resident_on is set when the VM is running (or paused or suspended on a host)
|
||||||
|
$container = link(obj, 'resident_on')
|
||||||
|
} else {
|
||||||
|
// if the VM is halted, the $container is the pool
|
||||||
|
$container = link(obj, 'pool')
|
||||||
|
|
||||||
|
// unless one of its VDI is on a non shared SR
|
||||||
|
//
|
||||||
|
// linked objects may not be there when this code run, and it will only be
|
||||||
|
// refreshed when the VM XAPI record change, this value is not guaranteed
|
||||||
|
// to be up-to-date, but it practice it appears to work fine thanks to
|
||||||
|
// `VBDs` and `current_operations` changing when a VDI is
|
||||||
|
// added/removed/migrated
|
||||||
|
for (const vbd of obj.$VBDs) {
|
||||||
|
const sr = vbd?.$VDI?.$SR
|
||||||
|
if (sr !== undefined && !sr.shared) {
|
||||||
|
const pbd = sr.$PBDs[0]
|
||||||
|
const hostId = pbd && link(pbd, 'host')
|
||||||
|
if (hostId !== undefined) {
|
||||||
|
$container = hostId
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const vm = {
|
const vm = {
|
||||||
// type is redefined after for controllers/, templates &
|
// type is redefined after for controllers/, templates &
|
||||||
// snapshots.
|
// snapshots.
|
||||||
@ -422,8 +450,7 @@ const TRANSFORMS = {
|
|||||||
xenTools,
|
xenTools,
|
||||||
...getVmGuestToolsProps(obj),
|
...getVmGuestToolsProps(obj),
|
||||||
|
|
||||||
// TODO: handle local VMs (`VM.get_possible_hosts()`).
|
$container,
|
||||||
$container: isRunning ? link(obj, 'resident_on') : link(obj, 'pool'),
|
|
||||||
$VBDs: link(obj, 'VBDs'),
|
$VBDs: link(obj, 'VBDs'),
|
||||||
|
|
||||||
// TODO: dedupe
|
// TODO: dedupe
|
||||||
|
Loading…
Reference in New Issue
Block a user