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