feat(xo-web/VM): switch virtualization mode (#3669)

Fixes #2372
This commit is contained in:
Enishowk
2018-11-12 13:57:23 +01:00
committed by Pierre Donias
parent 38084c8199
commit 54bdcc6dd2
5 changed files with 46 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
- [VM] Display VGA and video RAM for PVHVM guests [#3576](https://github.com/vatesfr/xen-orchestra/issues/3576) (PR [#3664](https://github.com/vatesfr/xen-orchestra/pull/3664))
- [Backup NG form] Display a warning to let the user know that the Delta Backup and the Continuous Replication are not supported on XenServer < 6.5 [#3540](https://github.com/vatesfr/xen-orchestra/issues/3540) (PR [#3668](https://github.com/vatesfr/xen-orchestra/pull/3668))
- [Backup NG form] Omit VMs(Simple Backup)/pools(Smart Backup/Resident on) with XenServer < 6.5 from the selection when the Delta Backup mode or the Continuous Replication mode are selected [#3540](https://github.com/vatesfr/xen-orchestra/issues/3540) (PR [#3668](https://github.com/vatesfr/xen-orchestra/pull/3668))
- [VM] Allow to switch the Virtualization mode [#2372](https://github.com/vatesfr/xen-orchestra/issues/2372) (PR [#3669](https://github.com/vatesfr/xen-orchestra/pull/3669))
### Bug fixes

View File

@@ -257,6 +257,18 @@ export default {
},
},
virtualizationMode: {
set (virtualizationMode, vm) {
if (virtualizationMode !== 'pv' && virtualizationMode !== 'hvm') {
throw new Error(`The virtualization mode must be 'pv' or 'hvm'`)
}
return this._set(
'HVM_boot_policy',
virtualizationMode === 'hvm' ? 'Boot order' : ''
)
},
},
coresPerSocket: {
set (coresPerSocket, vm) {
return this._updateObjectMapProperty(vm, 'platform', {

View File

@@ -1023,6 +1023,10 @@ const messages = {
// ----- VM advanced tab -----
vmRemoveButton: 'Remove',
vmConvertToTemplateButton: 'Convert to template',
vmSwitchVirtualizationMode: 'Convert to {mode}',
vmVirtualizationModeModalTitle: 'Change virtualization mode',
vmVirtualizationModeModalBody:
"You must know what you are doing, because it could break your setup (if you didn't install the bootloader in the MBR while switching from PV to HVM, or even worse, in HVM to PV, if you don't have the correct PV args)",
vmShareButton: 'Share',
xenSettingsLabel: 'Xen settings',
guestOsLabel: 'Guest OS',

View File

@@ -1037,6 +1037,16 @@ export const convertVmToTemplate = vm =>
),
}).then(() => _call('vm.convert', { id: resolveId(vm) }), noop)
export const changeVirtualizationMode = vm =>
confirm({
title: _('vmVirtualizationModeModalTitle'),
body: _('vmVirtualizationModeModalBody'),
}).then(() =>
editVm(vm, {
virtualizationMode: vm.virtualizationMode === 'hvm' ? 'pv' : 'hvm',
})
)
export const deleteTemplates = templates =>
confirm({
title: _('templateDeleteModalTitle', { templates: templates.length }),

View File

@@ -23,6 +23,7 @@ import {
osFamily,
} from 'utils'
import {
changeVirtualizationMode,
cloneVm,
convertVmToTemplate,
createVgpu,
@@ -409,7 +410,24 @@ export default class TabAdvanced extends Component {
<tbody>
<tr>
<th>{_('virtualizationMode')}</th>
<td>{_(getVirtualizationModeLabel(vm))}</td>
<td>
{_(getVirtualizationModeLabel(vm))}{' '}
{(vm.virtualizationMode === 'pv' ||
vm.virtualizationMode === 'hvm') && (
<ActionButton
btnStyle='danger'
disabled={vm.power_state !== 'Halted'}
handler={changeVirtualizationMode}
handlerParam={vm}
icon='vm-migrate'
size='small'
>
{_('vmSwitchVirtualizationMode', {
mode: vm.virtualizationMode === 'pv' ? 'HVM' : 'PV',
})}
</ActionButton>
)}
</td>
</tr>
{vm.virtualizationMode === 'pv' && (
<tr>