From bbcd4184b032264cee9856d7f305837865dfcd9b Mon Sep 17 00:00:00 2001 From: Florent BEAUCHAMP Date: Fri, 19 Jan 2024 16:34:06 +0100 Subject: [PATCH] feat(xo-web,backups): fix dynamic disks count with suspend_VDI (#7315) `suspend_VDI` was counted as a dynamic VHD. This commit ignores it in the computation, but add a tag if the backup is with memory. --- @xen-orchestra/backups/formatVmBackups.mjs | 20 ++++++++++++++++---- CHANGELOG.unreleased.md | 2 ++ packages/xo-web/src/common/render-xo-item.js | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/@xen-orchestra/backups/formatVmBackups.mjs b/@xen-orchestra/backups/formatVmBackups.mjs index 7ebe8d9d5df..c6e88fa8dd8 100644 --- a/@xen-orchestra/backups/formatVmBackups.mjs +++ b/@xen-orchestra/backups/formatVmBackups.mjs @@ -2,8 +2,20 @@ import mapValues from 'lodash/mapValues.js' import { dirname } from 'node:path' function formatVmBackup(backup) { - const { isVhdDifferencing } = backup + const { isVhdDifferencing, vmSnapshot } = backup + let differencingVhds + let dynamicVhds + const withMemory = vmSnapshot.suspend_VDI !== 'OpaqueRef:NULL' + // isVhdDifferencing is either undefined or an object + if (isVhdDifferencing !== undefined) { + differencingVhds = Object.values(isVhdDifferencing).filter(t => t).length + dynamicVhds = Object.values(isVhdDifferencing).filter(t => !t).length + if (withMemory) { + // the suspend VDI (memory) is always a dynamic + dynamicVhds -= 1 + } + } return { disks: backup.vhds === undefined @@ -28,9 +40,9 @@ function formatVmBackup(backup) { name_label: backup.vm.name_label, }, - // isVhdDifferencing is either undefined or an object - differencingVhds: isVhdDifferencing && Object.values(isVhdDifferencing).filter(t => t).length, - dynamicVhds: isVhdDifferencing && Object.values(isVhdDifferencing).filter(t => !t).length, + differencingVhds, + dynamicVhds, + withMemory, } } diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 3473f14c263..13ac211dbfb 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -15,6 +15,7 @@ - [Plugins] Loading, or unloading, will respectively enable, or disable, _Auto-load at server start_, this should lead to least surprising behaviors (PR [#7317](https://github.com/vatesfr/xen-orchestra/pull/7317)) - [VM/Advanced] Admin can change VM creator [Forum#7313](https://xcp-ng.org/forum/topic/7313/change-created-by-and-date-information) (PR [#7276](https://github.com/vatesfr/xen-orchestra/pull/7276)) - [Host/Reboot] Confirmation modal to reboot an updated slave host if the master is not [#7059](https://github.com/vatesfr/xen-orchestra/issues/7059) (PR [#7293](https://github.com/vatesfr/xen-orchestra/pull/7293)) +- [Backup/Restore] Show whether the memory was backed up (PR [#7315](https://github.com/vatesfr/xen-orchestra/pull/7315)) ### Bug fixes @@ -32,6 +33,7 @@ - [Backup/Restore] Fix unnecessary pool selector in XO config backup restore modal [Forum#8130](https://xcp-ng.org/forum/topic/8130/xo-configbackup-restore) (PR [#7287](https://github.com/vatesfr/xen-orchestra/pull/7287)) - [File restore] Fix potential race condition in partition mount/unmount (PR [#7312](https://github.com/vatesfr/xen-orchestra/pull/7312)) - [Modal] Fix opened modal not closing when navigating to another route/URL (PR [#7301](https://github.com/vatesfr/xen-orchestra/pull/7301)) +- [Backup/Restore] Don't count memory as a key (i.e. complete) disk [Forum#8212](https://xcp-ng.org/forum/post/69591) (PR [#7315](https://github.com/vatesfr/xen-orchestra/pull/7315)) ### Packages to release diff --git a/packages/xo-web/src/common/render-xo-item.js b/packages/xo-web/src/common/render-xo-item.js index d31bf362e64..1b2f78c2602 100644 --- a/packages/xo-web/src/common/render-xo-item.js +++ b/packages/xo-web/src/common/render-xo-item.js @@ -657,6 +657,7 @@ const xoItemToRender = { {backup.dynamicVhds} {_('backupisKey')}{' '} )} + {backup.withMemory && {_('withMemory')} } {backup.size !== undefined && {formatSize(backup.size)}}{' '}