github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/persist/api/device.go (about) 1 // Copyright (c) 2016 Intel Corporation 2 // Copyright (c) 2019 Huawei Corporation 3 // 4 // SPDX-License-Identifier: Apache-2.0 5 // 6 7 package persistapi 8 9 import vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types" 10 11 // ============= sandbox level resources ============= 12 13 // BlockDrive represents a block storage drive which may be used in case the storage 14 // driver has an underlying block storage device. 15 type BlockDrive struct { 16 // File is the path to the disk-image/device which will be used with this drive 17 File string 18 19 // Format of the drive 20 Format string 21 22 // ID is used to identify this drive in the hypervisor options. 23 ID string 24 25 // Index assigned to the drive. In case of virtio-scsi, this is used as SCSI LUN index 26 Index int 27 28 // MmioAddr is used to identify the slot at which the drive is attached (order?). 29 MmioAddr string 30 31 // PCIPath is the PCI path used to identify the slot at which the drive is attached. 32 PCIPath vcTypes.PciPath 33 34 // SCSI Address of the block device, in case the device is attached using SCSI driver 35 // SCSI address is in the format SCSI-Id:LUN 36 SCSIAddr string 37 38 // NvdimmID is the nvdimm id inside the VM 39 NvdimmID string 40 41 // VirtPath at which the device appears inside the VM, outside of the container mount namespace 42 VirtPath string 43 44 // DevNo 45 DevNo string 46 47 // Pmem enabled persistent memory. Use File as backing file 48 // for a nvdimm device in the guest. 49 Pmem bool 50 } 51 52 // VFIODev represents a VFIO drive used for hotplugging 53 type VFIODev struct { 54 // ID is used to identify this drive in the hypervisor options. 55 ID string 56 57 // Type of VFIO device 58 Type uint32 59 60 // BDF (Bus:Device.Function) of the PCI address 61 BDF string 62 63 // Sysfsdev of VFIO mediated device 64 SysfsDev string 65 } 66 67 // VhostUserDeviceAttrs represents data shared by most vhost-user devices 68 type VhostUserDeviceAttrs struct { 69 DevID string 70 SocketPath string 71 Type string 72 73 // MacAddress is only meaningful for vhost user net device 74 MacAddress string 75 76 // PCIPath is the PCI path used to identify the slot at which the drive is attached. 77 // It is only meaningful for vhost user block devices 78 PCIPath vcTypes.PciPath 79 80 // Block index of the device if assigned 81 Index int 82 } 83 84 // DeviceState is sandbox level resource which represents host devices 85 // plugged to hypervisor, one Device can be shared among containers in POD 86 // Refs: virtcontainers/device/drivers/generic.go:GenericDevice 87 type DeviceState struct { 88 ID string 89 90 // Type is used to specify driver type 91 // Refs: virtcontainers/device/config/config.go:DeviceType 92 Type string 93 94 RefCount uint 95 AttachCount uint 96 97 // Type of device: c, b, u or p 98 // c , u - character(unbuffered) 99 // p - FIFO 100 // b - block(buffered) special file 101 // More info in mknod(1). 102 DevType string 103 104 // Major, minor numbers for device. 105 Major int64 106 Minor int64 107 108 // ColdPlug specifies whether the device must be cold plugged (true) 109 // or hot plugged (false). 110 ColdPlug bool 111 112 // DriverOptions is specific options for each device driver 113 // for example, for BlockDevice, we can set DriverOptions["blockDriver"]="virtio-blk" 114 DriverOptions map[string]string 115 116 // ============ device driver specific data =========== 117 // BlockDrive is specific for block device driver 118 BlockDrive *BlockDrive `json:",omitempty"` 119 120 // VFIODev is specific VFIO device driver 121 VFIODevs []*VFIODev `json:",omitempty"` 122 123 // VhostUserDeviceAttrs is specific for vhost-user device driver 124 VhostUserDev *VhostUserDeviceAttrs `json:",omitempty"` 125 // ============ end device driver specific data =========== 126 }