Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
// 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
}