Skip to content

Commit e1690ac

Browse files
authored
Merge pull request #8759 from mook-as/macos/vz-default
Make VZ default on macOS
2 parents f10bcec + cc8f5fb commit e1690ac

File tree

15 files changed

+95
-57
lines changed

15 files changed

+95
-57
lines changed

bats/tests/helpers/vm.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ start_container_engine() {
180180
--application.admin-access="$admin_access"
181181
--application.path-management-strategy rcfiles
182182
--virtual-machine.memory-in-gb 6
183-
--experimental.virtual-machine.mount.type="$RD_MOUNT_TYPE"
183+
--virtual-machine.mount.type="$RD_MOUNT_TYPE"
184184
)
185185
fi
186186
if [ "$RD_MOUNT_TYPE" = "9p" ]; then

e2e/preferences.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ test.describe.serial('Main App Test', () => {
154154
await expect(virtualMachine.vz).toBeDisabled();
155155
} else {
156156
await expect(virtualMachine.vz).not.toBeDisabled();
157-
await virtualMachine.vz.click();
157+
await virtualMachine.vz.click({ position: { x: 10, y: 10 } });
158158
await expect(virtualMachine.useRosetta).toBeVisible();
159159

160160
if (os.arch() === 'arm64') {

e2e/rdctl.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ test.describe('Command server', () => {
686686
['experimental.virtual-machine.mount.9p.msize-in-kib', 128],
687687
['experimental.virtual-machine.mount.9p.protocol-version', ProtocolVersion.NINEP2000_L],
688688
['experimental.virtual-machine.mount.9p.security-model', SecurityModel.NONE],
689-
['experimental.virtual-machine.mount.type', MountType.NINEP],
690689
['virtual-machine.memory-in-gb', 10],
690+
['virtual-machine.mount.type', MountType.NINEP],
691691
['virtual-machine.number-cpus', 10],
692692
['virtual-machine.type', VMType.VZ],
693693
['virtual-machine.use-rosetta', true],

pkg/rancher-desktop/assets/specs/command-api.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,14 @@ components:
616616
useRosetta:
617617
type: boolean
618618
x-rd-platforms: [darwin]
619+
mount:
620+
type: object
621+
x-rd-platforms: [darwin, linux]
622+
properties:
623+
type:
624+
type: string
625+
enum: [reverse-sshfs, 9p, virtiofs]
626+
x-rd-usage: how directories are shared; 9p is experimental.
619627
kubernetes:
620628
type: object
621629
properties:
@@ -675,10 +683,6 @@ components:
675683
type: object
676684
x-rd-platforms: [darwin, linux]
677685
properties:
678-
type:
679-
type: string
680-
enum: [reverse-sshfs, 9p, virtiofs]
681-
x-rd-usage: how directories are shared
682686
9p:
683687
type: object
684688
properties:

pkg/rancher-desktop/backend/lima.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken
596596
for (const location of locations) {
597597
const mount: LimaMount = { location, writable: true };
598598

599-
if (this.cfg?.experimental.virtualMachine.mount.type === MountType.NINEP) {
599+
if (this.cfg?.virtualMachine.mount.type === MountType.NINEP) {
600600
const nineP = this.cfg.experimental.virtualMachine.mount['9p'];
601601

602602
mount['9p'] = {
@@ -634,7 +634,7 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken
634634
cpus: this.cfg?.virtualMachine.numberCPUs || 4,
635635
memory: (this.cfg?.virtualMachine.memoryInGB || 4) * 1024 * 1024 * 1024,
636636
mounts: this.getMounts(),
637-
mountType: this.cfg?.experimental.virtualMachine.mount.type,
637+
mountType: this.cfg?.virtualMachine.mount.type,
638638
ssh: { localPort: await this.sshPort },
639639
hostResolver: {
640640
hosts: {
@@ -2154,7 +2154,7 @@ CREDFWD_URL='http://${ SLIRP.HOST_GATEWAY }:${ stateInfo.port }'
21542154
'experimental.virtualMachine.mount.9p.msizeInKib': undefined,
21552155
'experimental.virtualMachine.mount.9p.protocolVersion': undefined,
21562156
'experimental.virtualMachine.mount.9p.securityModel': undefined,
2157-
'experimental.virtualMachine.mount.type': undefined,
2157+
'virtualMachine.mount.type': undefined,
21582158
'experimental.virtualMachine.sshPortForwarder': undefined,
21592159
'virtualMachine.type': undefined,
21602160
'virtualMachine.useRosetta': undefined,

pkg/rancher-desktop/components/MountTypeSelector.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
5555
label: this.t(`virtualMachine.mount.type.options.${ x }.label`),
5656
value: x,
5757
description: this.t(`virtualMachine.mount.type.options.${ x }.description`, {}, true),
58-
experimental: x !== defaultOption, // Mark experimental options
58+
experimental: x === MountType.NINEP,
5959
disabled: x === MountType.VIRTIOFS && this.virtIoFsDisabled,
6060
compatiblePrefs: this.getCompatiblePrefs(x),
6161
};
@@ -65,7 +65,7 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
6565
return 'mountType';
6666
},
6767
ninePSelected(): boolean {
68-
return this.preferences.experimental.virtualMachine.mount.type === MountType.NINEP;
68+
return this.preferences.virtualMachine.mount.type === MountType.NINEP;
6969
},
7070
virtIoFsDisabled(): boolean {
7171
// virtiofs should only be disabled on macOS WITHOUT the possibility to select the VM type VZ. VZ doesn't need to
@@ -124,14 +124,14 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
124124
if (os.platform() === 'darwin') {
125125
switch (mountType) {
126126
case MountType.NINEP:
127-
if (this.preferences.experimental.virtualMachine.type === VMType.VZ) {
127+
if (this.preferences.virtualMachine.type === VMType.VZ) {
128128
compatiblePrefs.push( {
129129
title: VMType.QEMU, navItemName: 'Virtual Machine', tabName: 'emulation',
130130
} );
131131
}
132132
break;
133133
case MountType.VIRTIOFS:
134-
if (this.preferences.experimental.virtualMachine.type === VMType.QEMU) {
134+
if (this.preferences.virtualMachine.type === VMType.QEMU) {
135135
compatiblePrefs.push( {
136136
title: VMType.VZ, navItemName: 'Virtual Machine', tabName: 'emulation',
137137
} );
@@ -153,7 +153,7 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
153153
<rd-fieldset
154154
data-test="mountType"
155155
:legend-text="t('virtualMachine.mount.type.legend')"
156-
:is-locked="isPreferenceLocked('experimental.virtualMachine.mount.type')"
156+
:is-locked="isPreferenceLocked('virtualMachine.mount.type')"
157157
>
158158
<template #default="{ isLocked }">
159159
<radio-group
@@ -170,11 +170,11 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
170170
:key="groupName+'-'+index"
171171
v-tooltip="disabledVirtIoFsTooltip(option.disabled)"
172172
:name="groupName"
173-
:value="preferences.experimental.virtualMachine.mount.type"
173+
:value="preferences.virtualMachine.mount.type"
174174
:val="option.value"
175175
:disabled="option.disabled || isDisabled"
176176
:data-test="option.label"
177-
@input="updateValue('experimental.virtualMachine.mount.type', $event)"
177+
@input="updateValue('virtualMachine.mount.type', $event)"
178178
>
179179
<template #label>
180180
{{ option.label }}
@@ -185,7 +185,7 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
185185
<template #description>
186186
{{ option.description }}
187187
<incompatible-preferences-alert
188-
v-if="option.value === preferences.experimental.virtualMachine.mount.type"
188+
v-if="option.value === preferences.virtualMachine.mount.type"
189189
:compatible-prefs="option.compatiblePrefs"
190190
/>
191191
</template>

pkg/rancher-desktop/components/Preferences/VirtualMachineEmulation.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
8383
8484
switch (vmType) {
8585
case VMType.QEMU:
86-
if (this.preferences.experimental.virtualMachine.mount.type === MountType.VIRTIOFS) {
86+
if (this.preferences.virtualMachine.mount.type === MountType.VIRTIOFS) {
8787
compatiblePrefs.push(
8888
{
8989
title: MountType.REVERSE_SSHFS, navItemName: 'Virtual Machine', tabName: 'volumes',
@@ -94,7 +94,7 @@ export default (Vue as VueConstructor<Vue & VuexBindings>).extend({
9494
}
9595
break;
9696
case VMType.VZ:
97-
if (this.preferences.experimental.virtualMachine.mount.type === MountType.NINEP) {
97+
if (this.preferences.virtualMachine.mount.type === MountType.NINEP) {
9898
compatiblePrefs.push(
9999
{
100100
title: MountType.REVERSE_SSHFS, navItemName: 'Virtual Machine', tabName: 'volumes',

pkg/rancher-desktop/config/__tests__/settingsMigrations.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _ from 'lodash';
22

33
import { updateTable } from '../settingsImpl';
44

5-
import { defaultSettings, VMType } from '@pkg/config/settings';
5+
import { defaultSettings, MountType, VMType } from '@pkg/config/settings';
66

77
describe('settings migrations', () => {
88
describe('step 9', () => {
@@ -90,4 +90,14 @@ describe('settings migrations', () => {
9090
expect(testSettings).toHaveProperty('virtualMachine.useRosetta', true);
9191
});
9292
});
93+
94+
describe('step 15', () => {
95+
it('should migrate experimental.virtualMachine.mount.type to virtualMachine.*', () => {
96+
const testSettings = { experimental: { virtualMachine: { mount: { type: MountType.REVERSE_SSHFS } } } };
97+
98+
updateTable[15](testSettings, false);
99+
expect(testSettings).not.toHaveProperty('experimental.virtualMachine.mount.type');
100+
expect(testSettings).toHaveProperty('virtualMachine.mount.type', MountType.REVERSE_SSHFS);
101+
});
102+
});
93103
});

pkg/rancher-desktop/config/settings.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// This file contains exportable types and constants used for managing preferences
22
// All the actual data and functions are in settingsImpl.ts
33

4+
import os from 'os';
5+
46
import { PathManagementStrategy } from '@pkg/integrations/pathManager';
57
import { RecursivePartial } from '@pkg/utils/typeUtils';
68

7-
export const CURRENT_SETTINGS_VERSION = 15 as const;
9+
export const CURRENT_SETTINGS_VERSION = 16 as const;
810

911
export enum VMType {
1012
QEMU = 'qemu',
@@ -89,9 +91,13 @@ export const defaultSettings = {
8991
memoryInGB: 2,
9092
numberCPUs: 2,
9193
/** can only be set to VMType.VZ on macOS Ventura and later */
92-
type: VMType.QEMU,
94+
type: process.platform === 'darwin' && parseInt(os.release(), 10) >= 23 ? VMType.VZ : VMType.QEMU,
9395
/** can only be used when type is VMType.VZ, and only on aarch64 */
9496
useRosetta: false,
97+
mount: {
98+
// Mount type defaults to virtiofs when using VZ.
99+
type: process.platform === 'darwin' && parseInt(os.release(), 10) >= 23 ? MountType.VIRTIOFS : MountType.REVERSE_SSHFS,
100+
},
95101
},
96102
WSL: { integrations: {} as Record<string, boolean> },
97103
kubernetes: {
@@ -124,7 +130,6 @@ export const defaultSettings = {
124130
kubernetes: { options: { spinkube: false } },
125131
virtualMachine: {
126132
mount: {
127-
type: MountType.REVERSE_SSHFS,
128133
'9p': {
129134
securityModel: SecurityModel.NONE,
130135
protocolVersion: ProtocolVersion.NINEP2000_L,

pkg/rancher-desktop/config/settingsImpl.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ export const updateTable: Record<number, (settings: any, locked : boolean) => vo
504504
_.unset(settings, 'experimental.virtualMachine');
505505
}
506506
},
507+
15: (settings) => {
508+
const replacements: ReplacementDirective[] = [
509+
{ oldPath: 'experimental.virtualMachine.mount.type', newPath: 'virtualMachine.mount.type' },
510+
];
511+
512+
processReplacements(settings, replacements);
513+
},
507514
};
508515

509516
function migrateSettingsToCurrentVersion(settings: Record<string, any>): Settings {

0 commit comments

Comments
 (0)