From d32c9879b1e6611c8a8c1252f9833881896ef21b Mon Sep 17 00:00:00 2001 From: ayoub-el-kajji-v Date: Mon, 19 Oct 2026 16:07:07 +0200 Subject: [PATCH] fix(hosts): multipathing should not require disconnecting srs on local storage (#10592) XO-2336 --- CHANGELOG.unreleased.md | 1 + packages/xo-server/src/xapi/index.mjs | 22 ++++++++++++++----- packages/xo-web/src/common/intl/messages.js | 4 ++-- .../src/common/xo/multipathing-modal/index.js | 9 ++++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index a0674e9fdc..41d3d3297d 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -90,6 +90,7 @@ - [Servers] Fix a pool left in a broken state when its connection was lost twice in a row within 5 minutes (e.g. during a toolstack restart): it could be displayed as connecting while connected and its objects could no longer be acted upon, or it would never be reconnected automatically (PR [#10577](https://github.com/vatesfr/xen-orchestra/pull/10577)) - [Swagger] Fixed a typo in the VM collection: `xentools` → `xenTools`, and added a missing type to the server collection `poolMembersAddresses` [#10514](https://github.com/vatesfr/xen-orchestra/issues/10514) (PR [#10598](https://github.com/vatesfr/xen-orchestra/pull/10598)) - [VM/console] Fix opening console in new tab (PR [#10616](https://github.com/vatesfr/xen-orchestra/pull/10616)) +- [Host] Enabling multipathing on hosts only disconnects shared SRs, local storage SRs stay connected(PR [#10592](https://github.com/vatesfr/xen-orchestra/pull/10592)) ### Packages to release diff --git a/packages/xo-server/src/xapi/index.mjs b/packages/xo-server/src/xapi/index.mjs index e12ca60641..b99b867c95 100644 --- a/packages/xo-server/src/xapi/index.mjs +++ b/packages/xo-server/src/xapi/index.mjs @@ -297,16 +297,28 @@ export default class Xapi extends XapiBase { async setHostMultipathing($defer, hostId, multipathing) { const host = this.getObject(hostId) + // Only shared SRs are affected by multipathing, local SRs can stay connected. + // + // Unplugging a shared SR would break running VMs with disks on it, the + // user must migrate them first. + const vmsOnSharedSrs = host.$resident_VMs.filter( + vm => !vm.is_control_domain && vm.$VBDs.some(vbd => vbd.$VDI?.$SR?.shared) + ) + if (vmsOnSharedSrs.length !== 0) { + throw forbiddenOperation( + 'set host multipathing', + `the following VMs have disks on shared SRs and must be migrated first: ${vmsOnSharedSrs + .map(vm => vm?.name_label + ': ' + vm.uuid) + .join(', ')}` + ) + } + if (host.enabled) { await this.disableHost(hostId) $defer(() => this.enableHost(hostId)) } - // Xen center evacuate running VMs before unplugging the PBDs. - // The evacuate method uses the live migration to migrate running VMs - // from host to another. It only works when a shared SR is present - // in the host. For this reason we chose to show a warning instead. - const pluggedPbds = host.$PBDs.filter(pbd => pbd.currently_attached) + const pluggedPbds = host.$PBDs.filter(pbd => pbd.currently_attached && pbd.$SR?.shared) await asyncMapSettled(pluggedPbds, async pbd => { const ref = pbd.$ref await this.unplugPbd(ref) diff --git a/packages/xo-web/src/common/intl/messages.js b/packages/xo-web/src/common/intl/messages.js index 95bb0b6ed8..d96af8ba03 100644 --- a/packages/xo-web/src/common/intl/messages.js +++ b/packages/xo-web/src/common/intl/messages.js @@ -1151,9 +1151,9 @@ const messages = { hostMultipathingSrs: 'Click to see concerned SRs', hostMultipathingPaths: '{nActives, number} of {nPaths, number} path{nPaths, plural, one {} other {s}}', hostMultipathingRequiredState: - 'This action will not be fulfilled if a VM is in a running state. Please ensure that all VMs are evacuated or stopped before performing this action!', + 'This action will not be fulfilled if a VM is in a running state on shared SRs. Please ensure that all VMs are evacuated or stopped before performing this action!', hostMultipathingWarning: - 'The host{nHosts, plural, one {} other {s}} will lose their connection to the SRs. Do you want to continue?', + 'The host{nHosts, plural, one {} other {s}} will lose their connection to the shared SRs. Do you want to continue?', hostXenServerVersion: 'Version', hostStatusEnabled: 'Enabled', hostStatusDisabled: 'Disabled', diff --git a/packages/xo-web/src/common/xo/multipathing-modal/index.js b/packages/xo-web/src/common/xo/multipathing-modal/index.js index e107e436fc..7948852a15 100644 --- a/packages/xo-web/src/common/xo/multipathing-modal/index.js +++ b/packages/xo-web/src/common/xo/multipathing-modal/index.js @@ -16,10 +16,15 @@ import { Sr } from '../../render-xo-item' pbd => hostIds.includes(pbd.host) ), - pbds => { + createGetObjectsOfType('SR'), + (pbds, srs) => { const srIds = new Set([]) for (const id in pbds) { - srIds.add(pbds[id].SR) + const pbd = pbds[id] + const sr = srs[pbd.SR] + if (sr !== undefined && sr.shared) { + srIds.add(pbd.SR) + } } return [...srIds] }