Message ID | 7f03220c9db0a377cd26c0c96d8a10981ec47282.1586727061.git.rosbrookn@ainfosec.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | More wrappers for xenlight Go package | expand |
> On Apr 12, 2020, at 11:02 PM, Nick Rosbrook <rosbrookn@gmail.com> wrote: > > Add DevicePciAdd and DevicePciRemove as wrappers for > libxl_device_pci_add and libxl_device_pci remove. > > Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com> For 4.14, we should really look at adding functions to the IDL so that all this can be auto-generated. Reviewed-by: George Dunlap <george.dunlap@citrix.com>
On Thu, Apr 23, 2020 at 6:22 AM George Dunlap <George.Dunlap@citrix.com> wrote: > > > > > On Apr 12, 2020, at 11:02 PM, Nick Rosbrook <rosbrookn@gmail.com> wrote: > > > > Add DevicePciAdd and DevicePciRemove as wrappers for > > libxl_device_pci_add and libxl_device_pci remove. > > > > Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com> > > For 4.14, we should really look at adding functions to the IDL so that all this can be auto-generated. Agreed, there is obvious repetition here. > Reviewed-by: George Dunlap <george.dunlap@citrix.com> Thanks! -NR
diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index a56f913b81..c94b046667 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -1102,3 +1102,37 @@ func (Ctx *Context) DeviceNicRemove(domid Domid, nic *DeviceNic) error { return nil } + +// DevicePciAdd is used to passthrough a PCI device to a domain. +func (Ctx *Context) DevicePciAdd(domid Domid, pci *DevicePci) error { + var cpci C.libxl_device_pci + + if err := pci.toC(&cpci); err != nil { + return err + } + defer C.libxl_device_pci_dispose(&cpci) + + ret := C.libxl_device_pci_add(Ctx.ctx, C.uint32_t(domid), &cpci, nil) + if ret != 0 { + return Error(ret) + } + + return nil +} + +// DevicePciRemove removes a PCI device from a domain. +func (Ctx *Context) DevicePciRemove(domid Domid, pci *DevicePci) error { + var cpci C.libxl_device_pci + + if err := pci.toC(&cpci); err != nil { + return err + } + defer C.libxl_device_pci_dispose(&cpci) + + ret := C.libxl_device_pci_remove(Ctx.ctx, C.uint32_t(domid), &cpci, nil) + if ret != 0 { + return Error(ret) + } + + return nil +}
Add DevicePciAdd and DevicePciRemove as wrappers for libxl_device_pci_add and libxl_device_pci remove. Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com> --- tools/golang/xenlight/xenlight.go | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)