func (vhostUserBlkDevice *VhostUserBlkDevice) Type() string {
	return VhostUserBlk
}
Type returns the type associated with the vhost-user device
package virtcontainers
import (
	"encoding/hex"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"github.com/go-ini/ini"
	"github.com/sirupsen/logrus"
)
const (
	DeviceVFIO = "vfio"
	DeviceBlock = "block"
	DeviceGeneric = "generic"
)
var sysIOMMUPath = "/sys/kernel/iommu_groups"
var sysDevPrefix = "/sys/dev"
var blockPaths = []string{
	"/dev/sd",    
	"/dev/hd",    
	"/dev/vd",    
	"/dev/ida/",  
}
const (
	vfioPath = "/dev/vfio/"
)
type Device interface {
	attach(hypervisor, *Container) error
	detach(hypervisor) error
	deviceType() string
}
type DeviceInfo struct {
	HostPath string
	ContainerPath string
	DevType string
	Major int64
	Minor int64
	FileMode os.FileMode
	UID uint32
	GID uint32
	Hotplugged bool
	ID string
}
func deviceLogger() *logrus.Entry {
	return virtLog.WithField("subsystem", "device")
}
type VFIODevice struct {
	DeviceType string
	DeviceInfo DeviceInfo
	BDF        string
}
func newVFIODevice(devInfo DeviceInfo) *VFIODevice {
	return &VFIODevice{
		DeviceType: DeviceVFIO,
		DeviceInfo: devInfo,
	}
}
func (device *VFIODevice) attach(h hypervisor, c *Container) error {
	vfioGroup := filepath.Base(device.DeviceInfo.HostPath)
	iommuDevicesPath := filepath.Join(sysIOMMUPath, vfioGroup, "devices")
	deviceFiles, err := ioutil.ReadDir(iommuDevicesPath)
	if err != nil {
		return err
	}
	for _, deviceFile := range deviceFiles {
		deviceBDF, err := getBDF(deviceFile.Name())
		if err != nil {
			return err
		}
		device.BDF = deviceBDF
		if err := h.addDevice(*device, vfioDev); err != nil {
			deviceLogger().WithError(err).Error("Failed to add device")
			return err
		}
		deviceLogger().WithFields(logrus.Fields{
			"device-group": device.DeviceInfo.HostPath,
			"device-type":  "vfio-passthrough",
		}).Info("Device group attached")
	}
	return nil
}
func (device *VFIODevice) detach(h hypervisor) error {
	return nil
}
func (device *VFIODevice) deviceType() string {
	return device.DeviceType
}
type VhostUserDeviceType string
const (
	VhostUserSCSI = "vhost-user-scsi-pci"
	VhostUserNet = "virtio-net-pci"
	VhostUserBlk = "vhost-user-blk-pci"
)
type VhostUserDevice interface {
	Attrs() *VhostUserDeviceAttrs
	Type() string
}
type VhostUserDeviceAttrs struct {
	DeviceType string
	DeviceInfo DeviceInfo
	SocketPath string
	ID         string
}
type VhostUserNetDevice struct {
	VhostUserDeviceAttrs
	MacAddress string
}
func (vhostUserNetDevice *VhostUserNetDevice) Attrs() *VhostUserDeviceAttrs {
	return &vhostUserNetDevice.VhostUserDeviceAttrs
}
func (vhostUserNetDevice *VhostUserNetDevice) Type() string {
	return VhostUserNet
}
type VhostUserSCSIDevice struct {
	VhostUserDeviceAttrs
}
func (vhostUserSCSIDevice *VhostUserSCSIDevice) Attrs() *VhostUserDeviceAttrs {
	return &vhostUserSCSIDevice.VhostUserDeviceAttrs
}
func (vhostUserSCSIDevice *VhostUserSCSIDevice) Type() string {
	return VhostUserSCSI
}
type VhostUserBlkDevice struct {
	VhostUserDeviceAttrs
}
func (vhostUserBlkDevice *VhostUserBlkDevice) Attrs() *VhostUserDeviceAttrs {
	return &vhostUserBlkDevice.VhostUserDeviceAttrs
}