mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-26 11:13:40 +00:00
Merge pull request #6076 from zhaojizhuang/reconnect
runtime: add reconnect timeout for vhost user block
This commit is contained in:
@@ -216,7 +216,7 @@ func TestContainerAddDriveDir(t *testing.T) {
|
||||
sandbox := &Sandbox{
|
||||
ctx: context.Background(),
|
||||
id: testSandboxID,
|
||||
devManager: manager.NewDeviceManager(config.VirtioSCSI, false, "", nil),
|
||||
devManager: manager.NewDeviceManager(config.VirtioSCSI, false, "", 0, nil),
|
||||
hypervisor: &mockHypervisor{},
|
||||
agent: &mockAgent{},
|
||||
config: &SandboxConfig{
|
||||
|
@@ -82,7 +82,7 @@ func TestContainerRemoveDrive(t *testing.T) {
|
||||
sandbox := &Sandbox{
|
||||
ctx: context.Background(),
|
||||
id: "sandbox",
|
||||
devManager: manager.NewDeviceManager(config.VirtioSCSI, false, "", nil),
|
||||
devManager: manager.NewDeviceManager(config.VirtioSCSI, false, "", 0, nil),
|
||||
config: &SandboxConfig{},
|
||||
}
|
||||
|
||||
|
@@ -302,6 +302,7 @@ type Param struct {
|
||||
}
|
||||
|
||||
// HypervisorConfig is the hypervisor configuration.
|
||||
// nolint: govet
|
||||
type HypervisorConfig struct {
|
||||
// customAssets is a map of assets.
|
||||
// Each value in that map takes precedence over the configured assets.
|
||||
@@ -387,6 +388,10 @@ type HypervisorConfig struct {
|
||||
// related folders, sockets and device nodes should be.
|
||||
VhostUserStorePath string
|
||||
|
||||
// VhostUserDeviceReconnect is the timeout for reconnecting on non-server spdk sockets
|
||||
// when the remote end goes away. Zero disables reconnecting.
|
||||
VhostUserDeviceReconnect uint32
|
||||
|
||||
// GuestCoredumpPath is the path in host for saving guest memory dump
|
||||
GuestMemoryDumpPath string
|
||||
|
||||
|
@@ -408,7 +408,7 @@ func TestHandleBlockVolume(t *testing.T) {
|
||||
mounts = append(mounts, vMount, bMount, dMount)
|
||||
|
||||
tmpDir := "/vhost/user/dir"
|
||||
dm := manager.NewDeviceManager(config.VirtioBlock, true, tmpDir, devices)
|
||||
dm := manager.NewDeviceManager(config.VirtioBlock, true, tmpDir, 0, devices)
|
||||
|
||||
sConfig := SandboxConfig{}
|
||||
sConfig.HypervisorConfig.BlockDeviceDriver = config.VirtioBlock
|
||||
@@ -466,7 +466,7 @@ func TestAppendDevicesEmptyContainerDeviceList(t *testing.T) {
|
||||
|
||||
c := &Container{
|
||||
sandbox: &Sandbox{
|
||||
devManager: manager.NewDeviceManager("virtio-scsi", false, "", nil),
|
||||
devManager: manager.NewDeviceManager("virtio-scsi", false, "", 0, nil),
|
||||
},
|
||||
devices: ctrDevices,
|
||||
}
|
||||
@@ -499,7 +499,7 @@ func TestAppendDevices(t *testing.T) {
|
||||
|
||||
c := &Container{
|
||||
sandbox: &Sandbox{
|
||||
devManager: manager.NewDeviceManager("virtio-blk", false, "", ctrDevices),
|
||||
devManager: manager.NewDeviceManager("virtio-blk", false, "", 0, ctrDevices),
|
||||
config: sandboxConfig,
|
||||
},
|
||||
}
|
||||
@@ -547,7 +547,7 @@ func TestAppendVhostUserBlkDevices(t *testing.T) {
|
||||
testVhostUserStorePath := "/test/vhost/user/store/path"
|
||||
c := &Container{
|
||||
sandbox: &Sandbox{
|
||||
devManager: manager.NewDeviceManager("virtio-blk", true, testVhostUserStorePath, ctrDevices),
|
||||
devManager: manager.NewDeviceManager("virtio-blk", true, testVhostUserStorePath, 0, ctrDevices),
|
||||
config: sandboxConfig,
|
||||
},
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ func TestSandboxRestore(t *testing.T) {
|
||||
sandbox := Sandbox{
|
||||
id: "test-exp",
|
||||
containers: container,
|
||||
devManager: manager.NewDeviceManager(config.VirtioSCSI, false, "", nil),
|
||||
devManager: manager.NewDeviceManager(config.VirtioSCSI, false, "", 0, nil),
|
||||
hypervisor: &mockHypervisor{},
|
||||
network: network,
|
||||
ctx: context.Background(),
|
||||
|
@@ -112,6 +112,10 @@ const (
|
||||
// related folders, sockets and device nodes should be.
|
||||
VhostUserStorePath = kataAnnotHypervisorPrefix + "vhost_user_store_path"
|
||||
|
||||
// VhostUserDeviceReconnect is a sandbox annotation to specify the timeout for reconnecting on
|
||||
// non-server sockets when the remote end goes away.
|
||||
VhostUserDeviceReconnect = kataAnnotHypervisorPrefix + "vhost_user_reconnect_timeout_sec"
|
||||
|
||||
// GuestHookPath is a sandbox annotation to specify the path within the VM that will be used for 'drop-in' hooks.
|
||||
GuestHookPath = kataAnnotHypervisorPrefix + "guest_hook_path"
|
||||
|
||||
|
@@ -1513,7 +1513,7 @@ func (q *qemu) hotplugAddBlockDevice(ctx context.Context, drive *config.BlockDri
|
||||
}
|
||||
|
||||
func (q *qemu) hotplugAddVhostUserBlkDevice(ctx context.Context, vAttr *config.VhostUserDeviceAttrs, op Operation, devID string) (err error) {
|
||||
err = q.qmpMonitorCh.qmp.ExecuteCharDevUnixSocketAdd(q.qmpMonitorCh.ctx, vAttr.DevID, vAttr.SocketPath, false, false)
|
||||
err = q.qmpMonitorCh.qmp.ExecuteCharDevUnixSocketAdd(q.qmpMonitorCh.ctx, vAttr.DevID, vAttr.SocketPath, false, false, vAttr.ReconnectTime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -600,7 +600,7 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
|
||||
|
||||
s.devManager = deviceManager.NewDeviceManager(sandboxConfig.HypervisorConfig.BlockDeviceDriver,
|
||||
sandboxConfig.HypervisorConfig.EnableVhostUserStore,
|
||||
sandboxConfig.HypervisorConfig.VhostUserStorePath, nil)
|
||||
sandboxConfig.HypervisorConfig.VhostUserStorePath, sandboxConfig.HypervisorConfig.VhostUserDeviceReconnect, nil)
|
||||
|
||||
// Create the sandbox resource controllers.
|
||||
if err := s.createResourceController(); err != nil {
|
||||
|
@@ -30,7 +30,7 @@ func TestSandboxAttachDevicesVhostUserBlk(t *testing.T) {
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
os.RemoveAll(tmpDir)
|
||||
dm := manager.NewDeviceManager(config.VirtioSCSI, true, tmpDir, nil)
|
||||
dm := manager.NewDeviceManager(config.VirtioSCSI, true, tmpDir, 0, nil)
|
||||
|
||||
vhostUserDevNodePath := filepath.Join(tmpDir, "/block/devices/")
|
||||
vhostUserSockPath := filepath.Join(tmpDir, "/block/sockets/")
|
||||
|
@@ -541,7 +541,7 @@ func TestSandboxAttachDevicesVFIO(t *testing.T) {
|
||||
config.SysIOMMUPath = savedIOMMUPath
|
||||
}()
|
||||
|
||||
dm := manager.NewDeviceManager(config.VirtioSCSI, false, "", nil)
|
||||
dm := manager.NewDeviceManager(config.VirtioSCSI, false, "", 0, nil)
|
||||
path := filepath.Join(vfioPath, testFDIOGroup)
|
||||
deviceInfo := config.DeviceInfo{
|
||||
HostPath: path,
|
||||
@@ -1080,7 +1080,7 @@ func TestAttachBlockDevice(t *testing.T) {
|
||||
DevType: "b",
|
||||
}
|
||||
|
||||
dm := manager.NewDeviceManager(config.VirtioBlock, false, "", nil)
|
||||
dm := manager.NewDeviceManager(config.VirtioBlock, false, "", 0, nil)
|
||||
device, err := dm.NewDevice(deviceInfo)
|
||||
assert.Nil(t, err)
|
||||
_, ok := device.(*drivers.BlockDevice)
|
||||
@@ -1136,7 +1136,7 @@ func TestPreAddDevice(t *testing.T) {
|
||||
HypervisorConfig: hConfig,
|
||||
}
|
||||
|
||||
dm := manager.NewDeviceManager(config.VirtioBlock, false, "", nil)
|
||||
dm := manager.NewDeviceManager(config.VirtioBlock, false, "", 0, nil)
|
||||
// create a sandbox first
|
||||
sandbox := &Sandbox{
|
||||
id: testSandboxID,
|
||||
|
Reference in New Issue
Block a user