Skip to content

Commit

Permalink
incusd/instance/qemu: QEMU device naming consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Somers <[email protected]>
  • Loading branch information
bensmrs authored and stgraber committed Dec 19, 2024
1 parent 0572dc4 commit d1fe2a5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -4765,7 +4765,7 @@ func (d *qemu) addGPUDevConfig(cfg *[]cfgSection, bus *qemuBus, gpuConfig []devi
}

func (d *qemu) addUSBDeviceConfig(usbDev deviceConfig.USBDeviceItem) (monitorHook, error) {
device := map[string]any{
qemuDev := map[string]any{
"id": fmt.Sprintf("%s%s", qemuDeviceIDPrefix, usbDev.DeviceName),
"driver": "usb-host",
"bus": "qemu_usb.0",
Expand All @@ -4782,18 +4782,18 @@ func (d *qemu) addUSBDeviceConfig(usbDev deviceConfig.USBDeviceItem) (monitorHoo

defer func() { _ = f.Close() }()

info, err := m.SendFileWithFDSet(device["id"].(string), f, false)
info, err := m.SendFileWithFDSet(qemuDev["id"].(string), f, false)
if err != nil {
return fmt.Errorf("Failed to send file descriptor: %w", err)
}

revert.Add(func() {
_ = m.RemoveFDFromFDSet(device["id"].(string))
_ = m.RemoveFDFromFDSet(qemuDev["id"].(string))
})

device["hostdevice"] = fmt.Sprintf("/dev/fdset/%d", info.ID)
qemuDev["hostdevice"] = fmt.Sprintf("/dev/fdset/%d", info.ID)

err = m.AddDevice(device)
err = m.AddDevice(qemuDev)
if err != nil {
return fmt.Errorf("Failed to add device: %w", err)
}
Expand Down Expand Up @@ -9134,19 +9134,19 @@ func (d *qemu) setCPUs(monitor *qmp.Monitor, count int) error {

devID := fmt.Sprintf("cpu%d%d%d", cpu.Props.SocketID, cpu.Props.CoreID, cpu.Props.ThreadID)

dev := map[string]any{
qemuDev := map[string]any{
"id": devID,
"driver": cpu.Type,
"core-id": cpu.Props.CoreID,
}

// No such thing as sockets and threads on s390x.
if d.architecture != osarch.ARCH_64BIT_S390_BIG_ENDIAN {
dev["socket-id"] = cpu.Props.SocketID
dev["thread-id"] = cpu.Props.ThreadID
qemuDev["socket-id"] = cpu.Props.SocketID
qemuDev["thread-id"] = cpu.Props.ThreadID
}

err := monitor.AddDevice(dev)
err := monitor.AddDevice(qemuDev)
if err != nil {
return fmt.Errorf("Failed to add device: %w", err)
}
Expand Down

0 comments on commit d1fe2a5

Please sign in to comment.