mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 16:57:18 +00:00
qemu: support vfio pass x-pci-vendor-id and x-pci-device-id pass
since some vendor id like 1ded can not be identified by virtio-pci driver, so need to pass a specified vendor id to qemu. Fixes: #1894 Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
parent
2cf4189244
commit
50e263d943
@ -167,6 +167,12 @@ type VFIODev struct {
|
|||||||
|
|
||||||
// sysfsdev of VFIO mediated device
|
// sysfsdev of VFIO mediated device
|
||||||
SysfsDev string
|
SysfsDev string
|
||||||
|
|
||||||
|
// VendorID specifies vendor id
|
||||||
|
VendorID string
|
||||||
|
|
||||||
|
// DeviceID specifies device id
|
||||||
|
DeviceID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// RNGDev represents a random number generator device
|
// RNGDev represents a random number generator device
|
||||||
|
@ -79,8 +79,16 @@ func (endpoint *PhysicalEndpoint) Attach(h hypervisor) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use device manager as general device management entrance
|
// TODO: use device manager as general device management entrance
|
||||||
|
var vendorID, deviceID string
|
||||||
|
if splits := strings.Split(endpoint.VendorDeviceID, " "); len(splits) == 2 {
|
||||||
|
vendorID = splits[0]
|
||||||
|
deviceID = splits[1]
|
||||||
|
}
|
||||||
|
|
||||||
d := config.VFIODev{
|
d := config.VFIODev{
|
||||||
BDF: endpoint.BDF,
|
BDF: endpoint.BDF,
|
||||||
|
VendorID: vendorID,
|
||||||
|
DeviceID: deviceID,
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.addDevice(d, vfioDev)
|
return h.addDevice(d, vfioDev)
|
||||||
|
@ -1172,7 +1172,7 @@ func (q *qemu) hotplugNetDevice(endpoint Endpoint, op operation) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if machine.Type == QemuCCWVirtio {
|
if machine.Type == QemuCCWVirtio {
|
||||||
return q.qmpMonitorCh.qmp.ExecuteNetCCWDeviceAdd(q.qmpMonitorCh.ctx, tap.Name, devID, endpoint.HardwareAddr(), addr, bridge.ID, int(q.config.NumVCPUs))
|
return q.qmpMonitorCh.qmp.ExecuteNetCCWDeviceAdd(q.qmpMonitorCh.ctx, tap.Name, devID, endpoint.HardwareAddr(), bridge.ID, int(q.config.NumVCPUs))
|
||||||
}
|
}
|
||||||
return q.qmpMonitorCh.qmp.ExecuteNetPCIDeviceAdd(q.qmpMonitorCh.ctx, tap.Name, devID, endpoint.HardwareAddr(), addr, bridge.ID, romFile, int(q.config.NumVCPUs), defaultDisableModern)
|
return q.qmpMonitorCh.qmp.ExecuteNetPCIDeviceAdd(q.qmpMonitorCh.ctx, tap.Name, devID, endpoint.HardwareAddr(), addr, bridge.ID, romFile, int(q.config.NumVCPUs), defaultDisableModern)
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,9 @@ func (q *qemuArchBase) appendVFIODevice(devices []govmmQemu.Device, vfioDev conf
|
|||||||
|
|
||||||
devices = append(devices,
|
devices = append(devices,
|
||||||
govmmQemu.VFIODevice{
|
govmmQemu.VFIODevice{
|
||||||
BDF: vfioDev.BDF,
|
BDF: vfioDev.BDF,
|
||||||
|
VendorID: vfioDev.VendorID,
|
||||||
|
DeviceID: vfioDev.DeviceID,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -419,6 +419,28 @@ func TestQemuArchBaseAppendVFIODevice(t *testing.T) {
|
|||||||
testQemuArchBaseAppend(t, vfDevice, expectedOut)
|
testQemuArchBaseAppend(t, vfDevice, expectedOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQemuArchBaseAppendVFIODeviceWithVendorDeviceID(t *testing.T) {
|
||||||
|
bdf := "02:10.1"
|
||||||
|
vendorID := "0x1234"
|
||||||
|
deviceID := "0x5678"
|
||||||
|
|
||||||
|
expectedOut := []govmmQemu.Device{
|
||||||
|
govmmQemu.VFIODevice{
|
||||||
|
BDF: bdf,
|
||||||
|
VendorID: vendorID,
|
||||||
|
DeviceID: deviceID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vfDevice := config.VFIODev{
|
||||||
|
BDF: bdf,
|
||||||
|
VendorID: vendorID,
|
||||||
|
DeviceID: deviceID,
|
||||||
|
}
|
||||||
|
|
||||||
|
testQemuArchBaseAppend(t, vfDevice, expectedOut)
|
||||||
|
}
|
||||||
|
|
||||||
func TestQemuArchBaseAppendSCSIController(t *testing.T) {
|
func TestQemuArchBaseAppendSCSIController(t *testing.T) {
|
||||||
var devices []govmmQemu.Device
|
var devices []govmmQemu.Device
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
Loading…
Reference in New Issue
Block a user