[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] golang/xenlight: add DeviceUsbdevAdd/Remove wrappers



Add DeviceUsbdevAdd and DeviceUsbdevRemove as wrappers for
libxl_device_usbdev_add and libxl_device_usbdev_remove.

Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 34 +++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index c94b046667..2d45d2bd48 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -1136,3 +1136,37 @@ func (Ctx *Context) DevicePciRemove(domid Domid, pci 
*DevicePci) error {
 
        return nil
 }
+
+// DeviceUsbdevAdd adds a USB device to a domain.
+func (Ctx *Context) DeviceUsbdevAdd(domid Domid, usbdev *DeviceUsbdev) error {
+       var cusbdev C.libxl_device_usbdev
+
+       if err := usbdev.toC(&cusbdev); err != nil {
+               return err
+       }
+       defer C.libxl_device_usbdev_dispose(&cusbdev)
+
+       ret := C.libxl_device_usbdev_add(Ctx.ctx, C.uint32_t(domid), &cusbdev, 
nil)
+       if ret != 0 {
+               return Error(ret)
+       }
+
+       return nil
+}
+
+// DeviceUsbdevRemove removes a USB device from a domain.
+func (Ctx *Context) DeviceUsbdevRemove(domid Domid, usbdev *DeviceUsbdev) 
error {
+       var cusbdev C.libxl_device_usbdev
+
+       if err := usbdev.toC(&cusbdev); err != nil {
+               return err
+       }
+       defer C.libxl_device_usbdev_dispose(&cusbdev)
+
+       ret := C.libxl_device_usbdev_remove(Ctx.ctx, C.uint32_t(domid), 
&cusbdev, nil)
+       if ret != 0 {
+               return Error(ret)
+       }
+
+       return nil
+}
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.