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

[PATCH] tools/golang: Refresh bindings following virtio changes


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 16 Dec 2022 10:49:04 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxx>, "Jan Beulich" <JBeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Wei Liu" <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Fri, 16 Dec 2022 10:49:29 +0000
  • Ironport-data: A9a23:dMHNAqNKAasbecXvrR1tl8FynXyQoLVcMsEvi/4bfWQNrUpw1GRTz GIfCDuOPPrZY2KgfNhzaI/k9hkBvp7UyIc1Tgto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQA+KmU4YoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9SuvzrRC9H5qyo4mpC5wJmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0ux9JkJWq tIiETM2Xx6Yuf6N7OKkdfY506zPLOGzVG8eknRpzDWfBvc6W5HTBa7N4Le03h9p2JoIR6yHI ZNEN3w/N3wsYDUWUrsTILs4kP2lmT/UdDpApUjOjaE2/3LS3Ep6172F3N/9KozQHpQJxx/wS mTu1HrJOQo1NuyklmSZ/kKstrDPkDKncddHfFG/3qEz2wDCroAJMzUNTkeyq/S9jk+4WvpcJ lYS9y5oqrI9nGS0SvHtUhv+p2SL1jYeRt5RHusS+AyLjK3O7G6xFmUCCzJMdtEinMs3XiAxk E+EmcvzAj5iu6HTTmiSnp+Oqii4Iy8SLmkqaioNTA9D6N7myKkRpB/SStdoEIauk8b4Xzr3x li3QDMW3utJy5RRjuPioA6B02nESoX1ohAd7A/wfXr6wDlAZ7WUaZeW9WP3vel/M9PMJrWeh 0Qsl8+b5eEIKJiCki2RXekAdI2UC+a53C702gA2QcR4n9i50zv6JN0LvmkiTKt8GpxcEQIFd nM/ru+4CHV7GHKxJZF6bIuqYyjB5fixTI+1Phw4gzcnX3SQSONl1Hs2DaJz9zq3+KTJrU3YE cnzTCpUJSxGYZmLNRLvLwvn7Zclxzol2UTYTo3hwhKs3NK2PSDKEO5fYQLfPrhlsstoRTk5F P4GZ6O3J+h3CrWiMkE7D6ZNRbz1EZTLLc+v8JEGHgJyCgFnBHsgG5fsLUAJIuRYc1Buvr6Qp BmVAxYIoGcTcFWbcW1mnFg/MuKwNXu+xFpnVRER0aGAhyJ5P93zsP5DKfPav9APrYRe8BK9d NFdE+3oPxiFYm2vF+g1BXUlkLFfSQ==
  • Ironport-hdrordr: A9a23:i2hVjq5yaVB+yEgp/gPXwNnXdLJyesId70hD6qkRc3Fom6mj/K qTdZsgpHzJYUkqKRMdcLy7VpVoIkmxyXcW2+ks1N6ZNWHbUQCTQ72Kg7GC/9ToIVyaytJg
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Fixes: 43ba5202e2ee ("libxl: add support for generic virtio device")
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
CC: Nick Rosbrook <rosbrookn@xxxxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Julien Grall <julien@xxxxxxx>
---
 tools/golang/xenlight/helpers.gen.go | 62 ++++++++++++++++++++++++++++++++++++
 tools/golang/xenlight/types.gen.go   | 17 ++++++++++
 2 files changed, 79 insertions(+)

diff --git a/tools/golang/xenlight/helpers.gen.go 
b/tools/golang/xenlight/helpers.gen.go
index cb1bdf9bdf41..3ac4938858f2 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1722,6 +1722,49 @@ xc.multi_touch_num_contacts = 
C.uint32_t(x.MultiTouchNumContacts)
  return nil
  }
 
+// NewDeviceVirtio returns an instance of DeviceVirtio initialized with 
defaults.
+func NewDeviceVirtio() (*DeviceVirtio, error) {
+var (
+x DeviceVirtio
+xc C.libxl_device_virtio)
+
+C.libxl_device_virtio_init(&xc)
+defer C.libxl_device_virtio_dispose(&xc)
+
+if err := x.fromC(&xc); err != nil {
+return nil, err }
+
+return &x, nil}
+
+func (x *DeviceVirtio) fromC(xc *C.libxl_device_virtio) error {
+ x.BackendDomid = Domid(xc.backend_domid)
+x.BackendDomname = C.GoString(xc.backend_domname)
+x.Type = C.GoString(xc._type)
+x.Transport = VirtioTransport(xc.transport)
+x.Devid = Devid(xc.devid)
+x.Irq = uint32(xc.irq)
+x.Base = uint64(xc.base)
+
+ return nil}
+
+func (x *DeviceVirtio) toC(xc *C.libxl_device_virtio) (err error){defer func(){
+if err != nil{
+C.libxl_device_virtio_dispose(xc)}
+}()
+
+xc.backend_domid = C.libxl_domid(x.BackendDomid)
+if x.BackendDomname != "" {
+xc.backend_domname = C.CString(x.BackendDomname)}
+if x.Type != "" {
+xc._type = C.CString(x.Type)}
+xc.transport = C.libxl_virtio_transport(x.Transport)
+xc.devid = C.libxl_devid(x.Devid)
+xc.irq = C.uint32_t(x.Irq)
+xc.base = C.uint64_t(x.Base)
+
+ return nil
+ }
+
 // NewDeviceDisk returns an instance of DeviceDisk initialized with defaults.
 func NewDeviceDisk() (*DeviceDisk, error) {
 var (
@@ -2855,6 +2898,15 @@ if err := x.Vkbs[i].fromC(&v); err != nil {
 return fmt.Errorf("converting field Vkbs: %v", err) }
 }
 }
+x.Virtios = nil
+if n := int(xc.num_virtios); n > 0 {
+cVirtios := (*[1<<28]C.libxl_device_virtio)(unsafe.Pointer(xc.virtios))[:n:n]
+x.Virtios = make([]DeviceVirtio, n)
+for i, v := range cVirtios {
+if err := x.Virtios[i].fromC(&v); err != nil {
+return fmt.Errorf("converting field Virtios: %v", err) }
+}
+}
 x.Vtpms = nil
 if n := int(xc.num_vtpms); n > 0 {
 cVtpms := (*[1<<28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:n:n]
@@ -3016,6 +3068,16 @@ return fmt.Errorf("converting field Vkbs: %v", err)
 }
 }
 }
+if numVirtios := len(x.Virtios); numVirtios > 0 {
+xc.virtios = 
(*C.libxl_device_virtio)(C.malloc(C.ulong(numVirtios)*C.sizeof_libxl_device_virtio))
+xc.num_virtios = C.int(numVirtios)
+cVirtios := 
(*[1<<28]C.libxl_device_virtio)(unsafe.Pointer(xc.virtios))[:numVirtios:numVirtios]
+for i,v := range x.Virtios {
+if err := v.toC(&cVirtios[i]); err != nil {
+return fmt.Errorf("converting field Virtios: %v", err)
+}
+}
+}
 if numVtpms := len(x.Vtpms); numVtpms > 0 {
 xc.vtpms = 
(*C.libxl_device_vtpm)(C.malloc(C.ulong(numVtpms)*C.sizeof_libxl_device_vtpm))
 xc.num_vtpms = C.int(numVtpms)
diff --git a/tools/golang/xenlight/types.gen.go 
b/tools/golang/xenlight/types.gen.go
index 871576fb0e23..16ce879e3fb7 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -255,6 +255,12 @@ VkbBackendQemu VkbBackend = 1
 VkbBackendLinux VkbBackend = 2
 )
 
+type VirtioTransport int
+const(
+VirtioTransportUnknown VirtioTransport = 0
+VirtioTransportMmio VirtioTransport = 1
+)
+
 type Passthrough int
 const(
 PassthroughDefault Passthrough = 0
@@ -644,6 +650,16 @@ MultiTouchHeight uint32
 MultiTouchNumContacts uint32
 }
 
+type DeviceVirtio struct {
+BackendDomid Domid
+BackendDomname string
+Type string
+Transport VirtioTransport
+Devid Devid
+Irq uint32
+Base uint64
+}
+
 type DeviceDisk struct {
 BackendDomid Domid
 BackendDomname string
@@ -933,6 +949,7 @@ Rdms []DeviceRdm
 Dtdevs []DeviceDtdev
 Vfbs []DeviceVfb
 Vkbs []DeviceVkb
+Virtios []DeviceVirtio
 Vtpms []DeviceVtpm
 P9S []DeviceP9
 Pvcallsifs []DevicePvcallsif
-- 
2.11.0




 


Rackspace

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