Пример #1
0
func (c *VirConnection) LookupByUUIDString(uuid string) (VirDomain, error) {
	cUuid := C.CString(uuid)
	defer C.free(unsafe.Pointer(cUuid))
	ptr := C.virDomainLookupByUUIDString(c.ptr, cUuid)
	if ptr == nil {
		return VirDomain{}, GetLastError()
	}
	return VirDomain{ptr: ptr}, nil
}
Пример #2
0
func (h *Hypervisor) LookupDomainByUUID(uuid string) (*Domain, error) {
	cuuid := C.CString(uuid)
	defer C.free(unsafe.Pointer(cuuid))

	cdomain := C.virDomainLookupByUUIDString(h.cptr, cuuid)
	if cdomain == nil {
		return nil, GetLastError()
	}

	domain := &Domain{cdomain}
	runtime.SetFinalizer(domain, cleanupDomain)

	return domain, nil
}
Пример #3
0
// LookupDomainByUUID tries to lookup a domain on the given hypervisor based on
// its UUID.
func (conn Connection) LookupDomainByUUID(uuid string) (Domain, error) {
	cUUID := C.CString(uuid)
	defer C.free(unsafe.Pointer(cUUID))

	conn.log.Printf("looking up domain with UUID = %v...\n", uuid)
	cDomain := C.virDomainLookupByUUIDString(conn.virConnect, cUUID)
	if cDomain == nil {
		err := LastError()
		conn.log.Printf("an error occurred: %v\n", err)
		return Domain{}, err
	}

	conn.log.Println("domain found")

	dom := Domain{
		log:       conn.log,
		virDomain: cDomain,
	}

	return dom, nil
}