Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-128951 / 24.10 / If you edit VM to use Custom CPU, then try to switch back to host passthrough it gives error #10296

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/app/pages/vm/vm-edit-form/vm-edit-form.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,43 @@ describe('VmEditFormComponent', () => {
expect(spectator.inject(IxSlideInRef).close).toHaveBeenCalled();
});

it('sends cpu_model as null when CPU Mode is not Custom', async () => {
await form.fillForm({
Name: 'Edited',
Description: 'New description',
'Memory Size': '258 mb',
'CPU Model': 'EPYC',
'CPU Mode': 'Host Passthrough',
'Minimum Memory Size': '257 mb',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith('vm.update', [4, {
autostart: true,
bootloader: VmBootloader.Uefi,
cores: 2,
cpu_mode: VmCpuMode.HostPassthrough,
cpu_model: null,
cpuset: '0-3,8-11',
description: 'New description',
ensure_display_device: true,
hide_from_msr: false,
hyperv_enlightenments: false,
memory: 258,
min_memory: 257,
name: 'Edited',
nodeset: '0-1',
pin_vcpus: false,
shutdown_timeout: 90,
threads: 3,
time: VmTime.Local,
vcpus: 1,
}]);
expect(spectator.inject(IxSlideInRef).close).toHaveBeenCalled();
});

it('updates GPU devices when form is edited and saved', async () => {
await form.fillForm({
GPUs: ['Intel Arc'],
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/vm/vm-edit-form/vm-edit-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class VmEditFormComponent implements OnInit {
};
delete vmPayload.gpus;

if (this.form.controls.cpu_mode.value !== VmCpuMode.Custom) {
vmPayload.cpu_model = null;
}

const gpusIds = this.form.value.gpus;

const pciIdsRequests$ = gpusIds.map((gpu) => {
Expand Down
Loading