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

[Xen-devel] [PATCH 9/9] DO NOT APPLY: Sketch constructors, DomainCreateNew


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: George Dunlap <george.dunlap@xxxxxxxxxx>
  • Date: Fri, 27 Dec 2019 16:32:24 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@xxxxxxxxxx; spf=Pass smtp.mailfrom=George.Dunlap@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Fri, 27 Dec 2019 16:33:10 +0000
  • Ironport-sdr: ccg/gV9gATPlXFZbeXyS8kjxGBRHwg8XxtUXYaw2vzDqIscRUUn32Z2mqfRh8a0wgLhAuTEnCH zUN7eRhxHXajS96KfD3kZHVnBh4wK1EocK3XQo9OjdEGQHqJZQmrzptJl/3TEc9X19CW3DoMH6 nw+q59xLa9RR5MK19mSbOCj6Y/iBtRe00gTVAfMUFFgwj1FOEfZeEyTc1zS1sCwtGJOxXOtduG MlI5m4opL+YMSdtcrPPZwu0AQjw7Lsf5Kpp7s4dmQvVCVNHR973h/9MBkzH61Whm+RZxAJ4hPn 3Rc=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This is a sketch of functionality suitable for creating a basic
domain, with a disk and a vif.  DomainConfig, DeviceDisk, and
DeviceNic types are all created using constructor functions, which
initialize them with libxl's defaults.

DomainCreateNew takes the config and calls without any updates.

Obviously some of these will need to be changed it we switch to
passing references to .toC() rather than passing back by value.

The main purpose of this is to allow testing of creating a hard-coded
domain.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
CC: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 66 +++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index f70a4c6d96..91da79bc68 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -1079,3 +1079,69 @@ func (Ctx *Context) PrimaryConsoleGetTty(domid uint32) 
(path string, err error)
        path = C.GoString(cpath)
        return
 }
+
+func NewDomainConfig(t DomainType) (*DomainConfig, error) {
+       var cconfig C.libxl_domain_config
+
+       C.libxl_domain_config_init(&cconfig)
+       C.libxl_domain_build_info_init_type(&cconfig.b_info, 
C.libxl_domain_type(t))
+
+       gconfig := &DomainConfig{}
+       err := gconfig.fromC(&cconfig)
+       if err != nil {
+               return nil, err
+       }
+
+       return gconfig, nil
+}
+
+func NewDeviceDisk() (*DeviceDisk, error) {
+       var ctype C.libxl_device_disk
+
+       C.libxl_device_disk_init(&ctype)
+
+       gtype := &DeviceDisk{}
+       err := gtype.fromC(&ctype)
+
+       if err != nil {
+               return nil, err
+       }
+
+       return gtype, nil
+}
+
+func NewDeviceNic() (*DeviceNic, error) {
+       var ctype C.libxl_device_nic
+
+       C.libxl_device_nic_init(&ctype)
+
+       gtype := &DeviceNic{}
+       err := gtype.fromC(&ctype)
+
+       if err != nil {
+               return nil, err
+       }
+
+       return gtype, nil
+}
+
+// int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
+//                             uint32_t *domid,
+//                             const libxl_asyncop_how *ao_how,
+//                             const libxl_asyncprogress_how *aop_console_how)
+func (Ctx *Context) DomainCreateNew(config *DomainConfig) (Domid, error) {
+       var cdomid C.uint32_t
+       cconfig, err := config.toC()
+       if err != nil {
+               return Domid(0), fmt.Errorf("Converting domain config to C: 
%v", err)
+       }
+       defer C.libxl_domain_config_dispose(&cconfig)
+
+       fmt.Errorf("Calling libxl_domain_create_new")
+       ret := C.libxl_domain_create_new(Ctx.ctx, &cconfig, &cdomid, nil, nil)
+       if ret != 0 {
+               return Domid(0), Error(ret)
+       }
+
+       return Domid(cdomid), nil
+}
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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