本文整理匯總了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
}