mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-08 00:44:25 +01:00
qemu: add vhost-user-fs-pci device instead of 9p
When enable_virtio_fs is true, add a vhost-user-fs-pci for the kataShared volume instead of 9p. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -36,6 +36,9 @@ const (
|
||||
|
||||
//VhostUserBlk represents a block vhostuser device type
|
||||
VhostUserBlk = "vhost-user-blk-pci"
|
||||
|
||||
//VhostUserFS represents a virtio-fs vhostuser device type
|
||||
VhostUserFS = "vhost-user-fs-pci"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -182,6 +185,9 @@ type VhostUserDeviceAttrs struct {
|
||||
|
||||
// MacAddress is only meaningful for vhost user net device
|
||||
MacAddress string
|
||||
|
||||
// These are only meaningful for vhost user fs devices
|
||||
Tag string
|
||||
}
|
||||
|
||||
// GetHostPathFunc is function pointer used to mock GetHostPath in tests.
|
||||
|
||||
65
virtcontainers/device/drivers/vhost_user_fs.go
Normal file
65
virtcontainers/device/drivers/vhost_user_fs.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// Copyright (C) 2019 Red Hat, Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package drivers
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||
"github.com/kata-containers/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
// VhostUserFSDevice is a virtio-fs vhost-user device
|
||||
type VhostUserFSDevice struct {
|
||||
*GenericDevice
|
||||
config.VhostUserDeviceAttrs
|
||||
}
|
||||
|
||||
// Device interface
|
||||
|
||||
func (device *VhostUserFSDevice) Attach(devReceiver api.DeviceReceiver) (err error) {
|
||||
skip, err := device.bumpAttachCount(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skip {
|
||||
return nil
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
device.bumpAttachCount(false)
|
||||
}
|
||||
}()
|
||||
|
||||
// generate a unique ID to be used for hypervisor commandline fields
|
||||
randBytes, err := utils.GenerateRandomBytes(8)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
id := hex.EncodeToString(randBytes)
|
||||
|
||||
device.DevID = id
|
||||
device.Type = device.DeviceType()
|
||||
|
||||
return devReceiver.AppendDevice(device)
|
||||
}
|
||||
|
||||
func (device *VhostUserFSDevice) Detach(devReceiver api.DeviceReceiver) error {
|
||||
_, err := device.bumpAttachCount(false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (device *VhostUserFSDevice) DeviceType() config.DeviceType {
|
||||
return config.VhostUserFS
|
||||
}
|
||||
|
||||
// GetDeviceInfo returns device information that the device is created based on
|
||||
func (device *VhostUserFSDevice) GetDeviceInfo() interface{} {
|
||||
device.Type = device.DeviceType()
|
||||
return &device.VhostUserDeviceAttrs
|
||||
}
|
||||
Reference in New Issue
Block a user