本文整理汇总了Golang中novmm/platform.Vm.VcpuInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang Vm.VcpuInfo方法的具体用法?Golang Vm.VcpuInfo怎么用?Golang Vm.VcpuInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类novmm/platform.Vm
的用法示例。
在下文中一共展示了Vm.VcpuInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SaveState
func SaveState(vm *platform.Vm, model *machine.Model) (State, error) {
// Pause the vm.
// NOTE: Our model will also be stopped automatically
// with model.DeviceInfo() below, but we manually pause
// the Vcpus here in order to ensure they are completely
// stopped prior to saving all device state.
err := vm.Pause(false)
if err != nil {
return State{}, err
}
defer vm.Unpause(false)
// Grab our vcpu states.
vcpus, err := vm.VcpuInfo()
if err != nil {
return State{}, err
}
// Grab our devices.
// NOTE: This should block until devices have
// actually quiesed (finished processing outstanding
// requests generated by the VCPUs).
devices, err := model.DeviceInfo(vm)
if err != nil {
return State{}, err
}
// Done.
return State{Vcpus: vcpus, Devices: devices}, nil
}