func (d *VirDomain) GetMetadata(tipus int, uri string, flags uint32) (string, error) { var cUri *C.char if uri != "" { cUri = C.CString(uri) defer C.free(unsafe.Pointer(cUri)) } result := C.virDomainGetMetadata(d.ptr, C.int(tipus), cUri, C.uint(flags)) if result == nil { return "", GetLastError() } defer C.free(unsafe.Pointer(result)) return C.GoString(result), nil }
// Metadata retrieves the appropriate domain element given by "type". func (dom Domain) Metadata(typ DomainMetadataType, xmlns string, impact DomainModificationImpact) (string, error) { cXMLNS := C.CString(xmlns) defer C.free(unsafe.Pointer(cXMLNS)) dom.log.Printf("reading domain metadata (type = %v, namespace = %v, impact = %v)...\n", typ, xmlns, impact) cMetadata := C.virDomainGetMetadata(dom.virDomain, C.int(typ), cXMLNS, C.uint(impact)) if cMetadata == nil { err := LastError() dom.log.Printf("an error occurred: %v\n", err) return "", err } defer C.free(unsafe.Pointer(cMetadata)) metadata := C.GoString(cMetadata) dom.log.Printf("metadata XML length: %v runes\n", utf8.RuneCountInString(metadata)) return metadata, nil }