本文整理汇总了Golang中novmm/platform.Vm.NewBoundEventFd方法的典型用法代码示例。如果您正苦于以下问题:Golang Vm.NewBoundEventFd方法的具体用法?Golang Vm.NewBoundEventFd怎么用?Golang Vm.NewBoundEventFd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类novmm/platform.Vm
的用法示例。
在下文中一共展示了Vm.NewBoundEventFd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: save
func (cache *IoCache) save(
vm *platform.Vm,
addr platform.Paddr,
handler *IoHandler,
ioevent IoEvent,
offset uint64) error {
// Do we have sufficient hits?
if cache.hits[addr] < 100 {
return nil
}
// Bind an eventfd.
// Note that we pass in the exactly address here,
// not the address associated with the IOHandler.
boundfd, err := vm.NewBoundEventFd(
addr,
ioevent.Size(),
cache.is_pio,
true,
ioevent.GetData())
if err != nil || boundfd == nil {
return err
}
// Create a fake event.
// This is because the real event will actually
// reach into the vcpu registers to get the data.
fake_event := &WriteIoEvent{ioevent.Size(), ioevent.GetData()}
// Run our function.
go func(ioevent IoEvent) {
for {
// Wait for the next event.
_, err := boundfd.Wait()
if err != nil {
break
}
// Call our function.
// We keep handling this device the same
// way until it tells us to stop by returning
// anything other than the SaveIO error.
err = handler.queue.Submit(ioevent, offset)
if err != SaveIO {
break
}
}
// Finished with the eventfd.
boundfd.Close()
}(fake_event)
// Success.
return nil
}