Skip to content

Commit 193e0d5

Browse files
committed
feat: remove old format pci device name checking
when implementing the first version pci device passthrough, we didn't have our own device plugin, then resource name was changed after upgrade. Right now, we already have our own device plugin, which we can control resource name by our ourselves. So, we can remove old mechanism. Signed-off-by: Jack Yu <jack.yu@suse.com>
1 parent 5f5ce29 commit 193e0d5

2 files changed

Lines changed: 73 additions & 116 deletions

File tree

pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachinePciDevices/index.vue

Lines changed: 73 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,21 @@ export default {
5252
}
5353
5454
const selectedDevices = [];
55-
const oldFormatDevices = [];
5655
5756
const vmDevices = this.value?.domain?.devices?.hostDevices || [];
58-
const otherDevices = this.otherDevices(vmDevices).map(({ name }) => name);
5957
const vmDeviceNames = vmDevices.map(({ name }) => name);
6058
6159
this.pciDevices.forEach((row) => {
6260
row.allowDisable = !vmDeviceNames.includes(row.metadata.name);
6361
});
6462
65-
vmDevices.forEach(({ name, deviceName }) => {
66-
const checkName = (deviceName || '').split('/')?.[1];
67-
68-
if (checkName && name.includes(checkName) && !otherDevices.includes(name)) {
69-
oldFormatDevices.push(name);
70-
} else if (this.enabledDevices.find((device) => device?.metadata?.name === name)) {
63+
vmDevices.forEach(({ name }) => {
64+
if (this.enabledDevices.find((device) => device?.metadata?.name === name)) {
7165
selectedDevices.push(name);
7266
}
7367
});
7468
75-
if (oldFormatDevices.length > 0) {
76-
this.oldFormatDevices = oldFormatDevices;
77-
} else {
78-
this.selectedDevices = selectedDevices;
79-
}
69+
this.selectedDevices = selectedDevices;
8070
},
8171
8272
data() {
@@ -87,7 +77,6 @@ export default {
8777
selectedDevices: [],
8878
pciDeviceSchema: this.$store.getters['harvester/schemaFor'](HCI.PCI_DEVICE),
8979
showMatrix: false,
90-
oldFormatDevices: [],
9180
};
9281
},
9382
@@ -199,11 +188,6 @@ export default {
199188
});
200189
},
201190
202-
oldFormatDevicesHTML() {
203-
return this.oldFormatDevices.map((device) => {
204-
return `<li>${ device }</li>`;
205-
}).join('');
206-
},
207191
},
208192
209193
methods: {
@@ -227,101 +211,89 @@ export default {
227211
228212
<template>
229213
<div>
230-
<div
231-
v-if="oldFormatDevices.length > 0"
232-
class="row"
233-
>
214+
<div class="row">
234215
<div class="col span-12">
235-
<Banner color="warning">
236-
<p v-clean-html="t('harvester.pci.oldFormatDevices.help', {oldFormatDevicesHTML}, true)" />
216+
<Banner color="info">
217+
<MessageLink
218+
:to="toVGpuDevicesPage"
219+
prefix-label="harvester.pci.howToUseDeviceInVMCreation.prefix"
220+
middle-label="harvester.pci.howToUseDeviceInVMCreation.middle"
221+
suffix-label="harvester.pci.howToUseDeviceInVMCreation.suffix"
222+
/>
223+
</Banner>
224+
<Banner
225+
v-if="selectedDevices.length > 0"
226+
color="info"
227+
>
228+
<t k="harvester.pci.deviceInTheSameHost" />
237229
</Banner>
238230
</div>
239231
</div>
240-
<div v-else>
232+
<template v-if="enabledDevices.length">
241233
<div class="row">
242-
<div class="col span-12">
243-
<Banner color="info">
244-
<MessageLink
245-
:to="toVGpuDevicesPage"
246-
prefix-label="harvester.pci.howToUseDeviceInVMCreation.prefix"
247-
middle-label="harvester.pci.howToUseDeviceInVMCreation.middle"
248-
suffix-label="harvester.pci.howToUseDeviceInVMCreation.suffix"
249-
/>
250-
</Banner>
251-
<Banner
252-
v-if="selectedDevices.length > 0"
253-
color="info"
234+
<div class="col span-6">
235+
<LabeledSelect
236+
v-model:value="selectedDevices"
237+
label="Available PCI Devices"
238+
searchable
239+
multiple
240+
taggable
241+
:options="deviceOpts"
242+
:mode="mode"
254243
>
255-
<t k="harvester.pci.deviceInTheSameHost" />
256-
</Banner>
244+
<template #option="option">
245+
<span>{{ option.value }} <span class="text-label">({{ option.displayLabel }})</span></span>
246+
</template>
247+
</LabeledSelect>
257248
</div>
258249
</div>
259-
<template v-if="enabledDevices.length">
260-
<div class="row">
261-
<div class="col span-6">
262-
<LabeledSelect
263-
v-model:value="selectedDevices"
264-
label="Available PCI Devices"
265-
searchable
266-
multiple
267-
taggable
268-
:options="deviceOpts"
269-
:mode="mode"
270-
>
271-
<template #option="option">
272-
<span>{{ option.value }} <span class="text-label">({{ option.displayLabel }})</span></span>
273-
</template>
274-
</LabeledSelect>
275-
</div>
276-
</div>
277-
<div
278-
v-if="compatibleNodes.length && selectedDevices.length"
279-
class="row"
280-
>
281-
<div class="col span-12 text-muted">
282-
Compatible hosts:
283-
<!-- eslint-disable-next-line vue/no-parsing-error -->
284-
<span
285-
v-for="(node, idx) in compatibleNodes"
286-
:key="idx"
287-
>{{ node }}{{ idx < compatibleNodes.length-1 ? ', ' : '' }}</span>
288-
</div>
250+
<div
251+
v-if="compatibleNodes.length && selectedDevices.length"
252+
class="row"
253+
>
254+
<div class="col span-12 text-muted">
255+
Compatible hosts:
256+
<!-- eslint-disable-next-line vue/no-parsing-error -->
257+
<span
258+
v-for="(node, idx) in compatibleNodes"
259+
:key="idx"
260+
>{{ node }}{{ idx < compatibleNodes.length-1 ? ', ' : '' }}</span>
289261
</div>
290-
<div
291-
v-else-if="selectedDevices.length"
292-
class="text-error"
293-
>
294-
{{ t('harvester.pci.impossibleSelection') }}
295-
</div>
296-
<button
297-
type="button"
298-
class="btn btn-sm role-link pl-0"
299-
@click="e=>{showMatrix = !showMatrix; e.target.blur()}"
300-
>
301-
{{ showMatrix ? t('harvester.pci.hideCompatibility') : t('harvester.pci.showCompatibility') }}
302-
</button>
303-
<div
304-
v-if="showMatrix"
305-
class="row mt-20"
306-
>
307-
<div class="col span-12">
308-
<CompatibilityMatrix
309-
:enabled-devices="enabledDevices"
310-
:devices-by-node="devicesByNode"
311-
:devices-in-use="devicesInUse"
312-
/>
313-
</div>
314-
</div>
315-
</template>
316-
<div class="row mt-20">
262+
</div>
263+
<div
264+
v-else-if="selectedDevices.length"
265+
class="text-error"
266+
>
267+
{{ t('harvester.pci.impossibleSelection') }}
268+
</div>
269+
<button
270+
type="button"
271+
class="btn btn-sm role-link pl-0"
272+
@click="e=>{showMatrix = !showMatrix; e.target.blur()}"
273+
>
274+
{{ showMatrix ? t('harvester.pci.hideCompatibility') : t('harvester.pci.showCompatibility') }}
275+
</button>
276+
<div
277+
v-if="showMatrix"
278+
class="row mt-20"
279+
>
317280
<div class="col span-12">
318-
<DeviceList
319-
:schema="pciDeviceSchema"
320-
:devices="pciDevices"
321-
@submit.prevent
281+
<CompatibilityMatrix
282+
:enabled-devices="enabledDevices"
283+
:devices-by-node="devicesByNode"
284+
:devices-in-use="devicesInUse"
322285
/>
323286
</div>
324287
</div>
288+
</template>
289+
<div class="row mt-20">
290+
<div class="col span-12">
291+
<DeviceList
292+
:schema="pciDeviceSchema"
293+
:devices="pciDevices"
294+
@submit.prevent
295+
/>
296+
</div>
325297
</div>
326298
</div>
327299
</template>

pkg/harvester/l10n/en-us.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,6 @@ harvester:
391391
middle: vGPU Devices
392392
suffix: page.
393393
deviceInTheSameHost: 'You can only select devices on the same host.'
394-
oldFormatDevices:
395-
help: |-
396-
<p>
397-
The following PCI devices are using the old naming convention and need to be updated in the YAML file:
398-
</p>
399-
<ul>
400-
{oldFormatDevicesHTML}
401-
</ul>
402-
<p>
403-
Please use the following instructions to update the virtual machine:
404-
</p>
405-
<ol>
406-
<li>Stop the virtual machine, edit the virtual machine YAML, and remove the <Code>hostDevices</Code> section, and save virtual machine the changes to the YAML file.</li>
407-
<li>Edit the virtual machine, and add the already enabled PCI Device from the list of available PCIDevices, and save and start VM.</li>
408-
</ol>
409394
showCompatibility: Show device compatibility matrix
410395
hideCompatibility: Hide device compatibility matrix
411396
claimError: Error enabling passthrough on {name}

0 commit comments

Comments
 (0)