-
Notifications
You must be signed in to change notification settings - Fork 4
/
helpers.go
32 lines (27 loc) · 843 Bytes
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package hardware
import (
pb_types "github.com/0xef53/kvmrun/api/types"
"github.com/0xef53/kvmrun/internal/pci"
)
func pciDeviceToProto(dev *pci.Device) *pb_types.PCIDevice {
return &pb_types.PCIDevice{
Addr: dev.String(),
Driver: dev.CurrentDriver(),
Enabled: dev.Enabled(),
Multifunction: dev.HasMultifunctionFeature(),
Class: dev.Class(),
Vendor: uint32(dev.Vendor()),
Device: uint32(dev.Device()),
ClassName: dev.ClassName(),
SubclassName: dev.SubclassName(),
VendorName: dev.VendorName(),
DeviceName: dev.DeviceName(),
}
}
func pciDeviceListToProto(devices []*pci.Device) []*pb_types.PCIDevice {
protos := make([]*pb_types.PCIDevice, 0, len(devices))
for _, dev := range devices {
protos = append(protos, pciDeviceToProto(dev))
}
return protos
}