feat: remove old format pci device name checking (#889)

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>
This commit is contained in:
Jack Yu 2026-06-05 11:18:04 +08:00 committed by GitHub
parent 836b04f222
commit b4ea7c8f98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 73 additions and 116 deletions

View File

@ -52,31 +52,21 @@ export default {
} }
const selectedDevices = []; const selectedDevices = [];
const oldFormatDevices = [];
const vmDevices = this.value?.domain?.devices?.hostDevices || []; const vmDevices = this.value?.domain?.devices?.hostDevices || [];
const otherDevices = this.otherDevices(vmDevices).map(({ name }) => name);
const vmDeviceNames = vmDevices.map(({ name }) => name); const vmDeviceNames = vmDevices.map(({ name }) => name);
this.pciDevices.forEach((row) => { this.pciDevices.forEach((row) => {
row.allowDisable = !vmDeviceNames.includes(row.metadata.name); row.allowDisable = !vmDeviceNames.includes(row.metadata.name);
}); });
vmDevices.forEach(({ name, deviceName }) => { vmDevices.forEach(({ name }) => {
const checkName = (deviceName || '').split('/')?.[1]; if (this.enabledDevices.find((device) => device?.metadata?.name === name)) {
if (checkName && name.includes(checkName) && !otherDevices.includes(name)) {
oldFormatDevices.push(name);
} else if (this.enabledDevices.find((device) => device?.metadata?.name === name)) {
selectedDevices.push(name); selectedDevices.push(name);
} }
}); });
if (oldFormatDevices.length > 0) { this.selectedDevices = selectedDevices;
this.oldFormatDevices = oldFormatDevices;
} else {
this.selectedDevices = selectedDevices;
}
}, },
data() { data() {
@ -87,7 +77,6 @@ export default {
selectedDevices: [], selectedDevices: [],
pciDeviceSchema: this.$store.getters['harvester/schemaFor'](HCI.PCI_DEVICE), pciDeviceSchema: this.$store.getters['harvester/schemaFor'](HCI.PCI_DEVICE),
showMatrix: false, showMatrix: false,
oldFormatDevices: [],
}; };
}, },
@ -199,11 +188,6 @@ export default {
}); });
}, },
oldFormatDevicesHTML() {
return this.oldFormatDevices.map((device) => {
return `<li>${ device }</li>`;
}).join('');
},
}, },
methods: { methods: {
@ -227,101 +211,89 @@ export default {
<template> <template>
<div> <div>
<div <div class="row">
v-if="oldFormatDevices.length > 0"
class="row"
>
<div class="col span-12"> <div class="col span-12">
<Banner color="warning"> <Banner color="info">
<p v-clean-html="t('harvester.pci.oldFormatDevices.help', {oldFormatDevicesHTML}, true)" /> <MessageLink
:to="toVGpuDevicesPage"
prefix-label="harvester.pci.howToUseDeviceInVMCreation.prefix"
middle-label="harvester.pci.howToUseDeviceInVMCreation.middle"
suffix-label="harvester.pci.howToUseDeviceInVMCreation.suffix"
/>
</Banner>
<Banner
v-if="selectedDevices.length > 0"
color="info"
>
<t k="harvester.pci.deviceInTheSameHost" />
</Banner> </Banner>
</div> </div>
</div> </div>
<div v-else> <template v-if="enabledDevices.length">
<div class="row"> <div class="row">
<div class="col span-12"> <div class="col span-6">
<Banner color="info"> <LabeledSelect
<MessageLink v-model:value="selectedDevices"
:to="toVGpuDevicesPage" label="Available PCI Devices"
prefix-label="harvester.pci.howToUseDeviceInVMCreation.prefix" searchable
middle-label="harvester.pci.howToUseDeviceInVMCreation.middle" multiple
suffix-label="harvester.pci.howToUseDeviceInVMCreation.suffix" taggable
/> :options="deviceOpts"
</Banner> :mode="mode"
<Banner
v-if="selectedDevices.length > 0"
color="info"
> >
<t k="harvester.pci.deviceInTheSameHost" /> <template #option="option">
</Banner> <span>{{ option.value }} <span class="text-label">({{ option.displayLabel }})</span></span>
</template>
</LabeledSelect>
</div> </div>
</div> </div>
<template v-if="enabledDevices.length"> <div
<div class="row"> v-if="compatibleNodes.length && selectedDevices.length"
<div class="col span-6"> class="row"
<LabeledSelect >
v-model:value="selectedDevices" <div class="col span-12 text-muted">
label="Available PCI Devices" Compatible hosts:
searchable <!-- eslint-disable-next-line vue/no-parsing-error -->
multiple <span
taggable v-for="(node, idx) in compatibleNodes"
:options="deviceOpts" :key="idx"
:mode="mode" >{{ node }}{{ idx < compatibleNodes.length-1 ? ', ' : '' }}</span>
>
<template #option="option">
<span>{{ option.value }} <span class="text-label">({{ option.displayLabel }})</span></span>
</template>
</LabeledSelect>
</div>
</div> </div>
<div </div>
v-if="compatibleNodes.length && selectedDevices.length" <div
class="row" v-else-if="selectedDevices.length"
> class="text-error"
<div class="col span-12 text-muted"> >
Compatible hosts: {{ t('harvester.pci.impossibleSelection') }}
<!-- eslint-disable-next-line vue/no-parsing-error --> </div>
<span <button
v-for="(node, idx) in compatibleNodes" type="button"
:key="idx" class="btn btn-sm role-link pl-0"
>{{ node }}{{ idx < compatibleNodes.length-1 ? ', ' : '' }}</span> @click="e=>{showMatrix = !showMatrix; e.target.blur()}"
</div> >
</div> {{ showMatrix ? t('harvester.pci.hideCompatibility') : t('harvester.pci.showCompatibility') }}
<div </button>
v-else-if="selectedDevices.length" <div
class="text-error" v-if="showMatrix"
> class="row mt-20"
{{ t('harvester.pci.impossibleSelection') }} >
</div>
<button
type="button"
class="btn btn-sm role-link pl-0"
@click="e=>{showMatrix = !showMatrix; e.target.blur()}"
>
{{ showMatrix ? t('harvester.pci.hideCompatibility') : t('harvester.pci.showCompatibility') }}
</button>
<div
v-if="showMatrix"
class="row mt-20"
>
<div class="col span-12">
<CompatibilityMatrix
:enabled-devices="enabledDevices"
:devices-by-node="devicesByNode"
:devices-in-use="devicesInUse"
/>
</div>
</div>
</template>
<div class="row mt-20">
<div class="col span-12"> <div class="col span-12">
<DeviceList <CompatibilityMatrix
:schema="pciDeviceSchema" :enabled-devices="enabledDevices"
:devices="pciDevices" :devices-by-node="devicesByNode"
@submit.prevent :devices-in-use="devicesInUse"
/> />
</div> </div>
</div> </div>
</template>
<div class="row mt-20">
<div class="col span-12">
<DeviceList
:schema="pciDeviceSchema"
:devices="pciDevices"
@submit.prevent
/>
</div>
</div> </div>
</div> </div>
</template> </template>

View File

@ -392,21 +392,6 @@ harvester:
middle: vGPU Devices middle: vGPU Devices
suffix: page. suffix: page.
deviceInTheSameHost: 'You can only select devices on the same host.' deviceInTheSameHost: 'You can only select devices on the same host.'
oldFormatDevices:
help: |-
<p>
The following PCI devices are using the old naming convention and need to be updated in the YAML file:
</p>
<ul>
{oldFormatDevicesHTML}
</ul>
<p>
Please use the following instructions to update the virtual machine:
</p>
<ol>
<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>
<li>Edit the virtual machine, and add the already enabled PCI Device from the list of available PCIDevices, and save and start VM.</li>
</ol>
showCompatibility: Show device compatibility matrix showCompatibility: Show device compatibility matrix
hideCompatibility: Hide device compatibility matrix hideCompatibility: Hide device compatibility matrix
claimError: Error enabling passthrough on {name} claimError: Error enabling passthrough on {name}