示例#1
0
文件: libvirt.go 项目: juito/hyper
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
}