func (c *VirConnection) DomainDefineXML(xmlConfig string) (VirDomain, error) { cXml := C.CString(string(xmlConfig)) defer C.free(unsafe.Pointer(cXml)) ptr := C.virDomainDefineXML(c.ptr, cXml) if ptr == nil { return VirDomain{}, GetLastError() } return VirDomain{ptr: ptr}, nil }
func (c *VirConnection) DefineXML(xml string) (VirDomain, error) { cXml := C.CString(xml) defer C.free(unsafe.Pointer(cXml)) cDomainPtr := C.virDomainDefineXML(c.ptr, cXml) if cDomainPtr == nil { return VirDomain{}, errors.New(GetLastError()) } return VirDomain{ptr: cDomainPtr}, nil }
func (h *Hypervisor) DefineDomain(xml string) (*Domain, error) { cxml := C.CString(xml) defer C.free(unsafe.Pointer(cxml)) cdomain := C.virDomainDefineXML(h.cptr, cxml) if cdomain == nil { return nil, GetLastError() } domain := &Domain{cdomain} runtime.SetFinalizer(domain, cleanupDomain) return domain, nil }
// DefineDomain defines a domain, but does not start it. This definition is // persistent, until explicitly undefined with Domain.Undefine(). A previous // definition for this domain would be overridden if it already exists. func (conn Connection) DefineDomain(xml string) (Domain, error) { cXML := C.CString(xml) defer C.free(unsafe.Pointer(cXML)) conn.log.Println("defining domain...") cDomain := C.virDomainDefineXML(conn.virConnect, cXML) if cDomain == nil { err := LastError() conn.log.Printf("an error occurred: %v\n", err) return Domain{}, err } conn.log.Println("domain defined") dom := Domain{ log: conn.log, virDomain: cDomain, } return dom, nil }