persist: save/load GuestMemoryHotplugProbe

Support saving/loading `GuestMemoryHotplugProbe` from sandbox state.

Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
This commit is contained in:
Wei Zhang 2019-05-09 14:39:04 +08:00
parent 4c192139cf
commit 297097779e
3 changed files with 16 additions and 20 deletions

View File

@ -591,8 +591,8 @@ func statusContainer(sandbox *Sandbox, containerID string) (ContainerStatus, err
if !running {
virtLog.WithFields(logrus.Fields{
"state": container.state.State,
"process pid": container.process.Pid}).
"state": container.state.State,
"pid": container.process.Pid}).
Info("container isn't running")
if err := container.stop(); err != nil {
return ContainerStatus{}, err

View File

@ -237,34 +237,28 @@ func (dm *deviceManager) LoadDevices(devStates []persistapi.DeviceState) {
defer dm.Unlock()
for _, ds := range devStates {
var dev api.Device
switch config.DeviceType(ds.Type) {
case config.DeviceGeneric:
dev := &drivers.GenericDevice{}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
dev = &drivers.GenericDevice{}
case config.DeviceBlock:
dev := &drivers.BlockDevice{}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
dev = &drivers.BlockDevice{}
case config.DeviceVFIO:
dev := &drivers.VFIODevice{}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
dev = &drivers.VFIODevice{}
case config.VhostUserSCSI:
dev := &drivers.VhostUserSCSIDevice{}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
dev = &drivers.VhostUserSCSIDevice{}
case config.VhostUserBlk:
dev := &drivers.VhostUserBlkDevice{}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
dev = &drivers.VhostUserBlkDevice{}
case config.VhostUserNet:
dev := &drivers.VhostUserNetDevice{}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
dev = &drivers.VhostUserNetDevice{}
default:
deviceLogger().WithField("device-type", ds.Type).Warning("unrecognized device type is detected")
// continue the for loop
continue
}
dev.Load(ds)
dm.devices[dev.DeviceID()] = dev
}
}

View File

@ -31,6 +31,7 @@ func (s *Sandbox) dumpVersion(ss *persistapi.SandboxState) {
func (s *Sandbox) dumpState(ss *persistapi.SandboxState, cs map[string]persistapi.ContainerState) {
ss.SandboxContainer = s.id
ss.GuestMemoryBlockSizeMB = s.state.GuestMemoryBlockSizeMB
ss.GuestMemoryHotplugProbe = s.state.GuestMemoryHotplugProbe
ss.State = string(s.state.State)
ss.CgroupPath = s.state.CgroupPath
@ -122,6 +123,7 @@ func (s *Sandbox) loadState(ss persistapi.SandboxState) {
s.state.BlockIndex = ss.HypervisorState.BlockIndex
s.state.State = types.StateString(ss.State)
s.state.CgroupPath = ss.CgroupPath
s.state.GuestMemoryHotplugProbe = ss.GuestMemoryHotplugProbe
}
func (s *Sandbox) loadDevices(devStates []persistapi.DeviceState) {