Merge pull request #19038 from wanyaoqi/automated-cherry-pick-of-#19037-upstream-release-3.11

Automated cherry pick of #19037: fix(host): usb device hotplug
This commit is contained in:
Zexi Li
2023-12-18 17:23:09 +08:00
committed by GitHub
5 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -995,7 +995,7 @@ func (t *SGuestIsolatedDeviceSyncTask) addDevice(dev *desc.SGuestIsolatedDevice)
}
}
opts, err := devObj.GetHotPlugOptions(dev)
opts, err := devObj.GetHotPlugOptions(dev, t.guest.Desc)
if err != nil {
cb(errors.Wrap(err, "GetHotPlugOptions").Error())
return
+1 -1
View File
@@ -520,7 +520,7 @@ func GetNicDeviceModel(name string) string {
}
func generateUsbDeviceOption(usbControllerId string, usb *desc.UsbDevice) string {
cmd := fmt.Sprintf("-device %s,bus=%s.0", usb.DevType, usbControllerId)
cmd := fmt.Sprintf("-device %s,bus=%s.0,id=%s", usb.DevType, usbControllerId, usb.Id)
cmd += desc.OptionsToString(usb.Options)
return cmd
}
@@ -99,7 +99,7 @@ type IDevice interface {
GetMdevId() string
GetNVIDIAVgpuProfile() map[string]string
GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotPlugOption, error)
GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error)
GetHotUnplugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotUnplugOption, error)
// Get extra PCIE information
@@ -639,7 +639,7 @@ func (dev *sBaseDevice) CustomProbe(idx int) error {
return nil
}
func (dev *sBaseDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotPlugOption, error) {
func (dev *sBaseDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error) {
ret := make([]*HotPlugOption, 0)
var masterDevOpt *HotPlugOption
+1 -1
View File
@@ -160,7 +160,7 @@ func (dev *sNVIDIAVgpuDevice) GetQemuId() string {
return "dev_" + dev.mdevId
}
func (dev *sNVIDIAVgpuDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice) ([]*HotPlugOption, error) {
func (dev *sNVIDIAVgpuDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error) {
ret := make([]*HotPlugOption, 0)
var masterDevOpt *HotPlugOption
+3 -1
View File
@@ -121,11 +121,13 @@ func (dev *sUSBDevice) GetPassthroughCmd(index int) string {
return opt
}
func (dev *sUSBDevice) GetHotPlugOptions(*desc.SGuestIsolatedDevice) ([]*HotPlugOption, error) {
func (dev *sUSBDevice) GetHotPlugOptions(isolatedDev *desc.SGuestIsolatedDevice, guestDesc *desc.SGuestDesc) ([]*HotPlugOption, error) {
opts, err := GetUSBDevQemuOptions(dev.dev.GetVendorDeviceId(), dev.dev.Addr)
if err != nil {
return nil, errors.Wrap(err, "GetUSBDevQemuOptions")
}
opts["id"] = isolatedDev.Usb.Id
opts["bus"] = fmt.Sprintf("%s.0", guestDesc.Usb.Id)
return []*HotPlugOption{
{
Device: "usb-host",