// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetUUIDString
970157
func (d *Domain) GetUUIDString() (string, error) {
	var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char)
	cuidPtr := unsafe.Pointer(&cUuid)
	var err C.virError
	result := C.virDomainGetUUIDStringWrapper(d.ptr, (*C.char)(cuidPtr), &err)
	if result != 0 {
		return "", makeError(&err)
	}
	return C.GoString((*C.char)(cuidPtr)), nil
}
1188282
func formatVirtualDiskUUID(uuid string) string {
	uuidwithNoSpace := strings.Replace(uuid, " ", "", -1)
	uuidWithNoHypens := strings.Replace(uuidwithNoSpace, "-", "", -1)
	return strings.ToLower(uuidWithNoHypens)
}
609957
func (d *Domain) GetHostname(flags uint32) (string, error) {
	var err C.virError
	ret := C.virDomainGetHostnameWrapper(d.ptr, C.uint(flags), &err)
	if ret == nil {
		return "", makeError(&err)
	}

	defer C.free(unsafe.Pointer(ret))

	return C.GoString(ret), nil
}
807514
func uuidFromPath(path string) string {
	path = strings.TrimPrefix(path, guiURLPathPrefix)
	uuid := strings.SplitN(path, "/", 2)[0]
	if names.IsValidModel(uuid) {
		return uuid
	}
	return ""
}
1072163
func encodeUUID(src [16]byte) string {
	return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16])
}
1133809
func NewUUID() (string, error) {
	b := make([]byte, 16)
	_, err := randSource.Read(b)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]), nil
}
746484
func (b *builtinUUIDSig) evalString(_ chunk.Row) (d string, isNull bool, err error) {
	return uuid.NewV1().String(), false, nil
}
238756
func GenerateUUID() string {
	buf := make([]byte, 16)
	if _, err := rand.Read(buf); err != nil {
		panic(fmt.Errorf("failed to read random bytes: %v", err))
	}

	return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
		buf[0:4],
		buf[4:6],
		buf[6:8],
		buf[8:10],
		buf[10:16])
}
417210
func (c *Connect) LookupNetworkByUUIDString(uuid string) (*Network, error) {
	cUuid := C.CString(uuid)
	defer C.free(unsafe.Pointer(cUuid))
	var err C.virError
	ptr := C.virNetworkLookupByUUIDStringWrapper(c.ptr, cUuid, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &Network{ptr: ptr}, nil
}
1119001
func IsUUID(input string) error {
	matched, err := regexp.MatchString("^"+UUIDRegex+"$", input)
	if err != nil {
		return err
	}
	if !matched {
		return fmt.Errorf("String '%s' is not a valid UUID", input)
	}
	return nil
}
563200
func (c *Connect) LookupNWFilterByUUIDString(uuid string) (*NWFilter, error) {
	cUuid := C.CString(uuid)
	defer C.free(unsafe.Pointer(cUuid))
	var err C.virError
	ptr := C.virNWFilterLookupByUUIDStringWrapper(c.ptr, cUuid, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &NWFilter{ptr: ptr}, nil
}
984349
func (m *MockCluster) Uuid() string {
	ret := m.ctrl.Call(m, "Uuid")
	ret0, _ := ret[0].(string)
	return ret0
}
463629
func idFromString(s string) (string, error) {
	_, err := uuid.FromString(s)
	if err != nil {
		return "", ErrMalformed
	}

	return s, nil
}
906749
func UUID() string {
	version := byte(4)
	uuid := make([]byte, 16)
	rand.Read(uuid)

	// Set version
	uuid[6] = (uuid[6] & 0x0f) | (version << 4)

	// Set variant
	uuid[8] = (uuid[8] & 0xbf) | 0x80

	buf := make([]byte, 36)
	var dash byte = '-'
	hex.Encode(buf[0:8], uuid[0:4])
	buf[8] = dash
	hex.Encode(buf[9:13], uuid[4:6])
	buf[13] = dash
	hex.Encode(buf[14:18], uuid[6:8])
	buf[18] = dash
	hex.Encode(buf[19:23], uuid[8:10])
	buf[23] = dash
	hex.Encode(buf[24:], uuid[10:])

	return string(buf)
}
663272
func (rh *RequestHistory) UuidIndex(uuid string) int {
	rh.lock.RLock()
	defer rh.lock.RUnlock()

	return rh.uuidIndexNoLock(uuid)
}
958308
func uuid() string {
	f, _ := os.Open(randomSource)
	defer f.Close()
	b := make([]byte, 16)
	f.Read(b)
	return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
}
705558
func NewUUIDv4() (UUID, error) {
	uuid := UUID{}
	_, err := rand.Read([]byte(uuid[:]))
	if err != nil {
		return uuid, err
	}

	uuid.setVersion(UUIDv4)
	uuid.setVariant(UUIDVariantRFC4122)
	return uuid, nil
}