예제 #1
0
func (d *VirDomain) GetXMLDesc(flags uint32) (string, error) {
	result := C.virDomainGetXMLDesc(d.ptr, C.uint(flags))
	if result == nil {
		return "", errors.New(GetLastError())
	}
	xml := C.GoString(result)
	C.free(unsafe.Pointer(result))
	return xml, nil
}
예제 #2
0
func (d *VirDomain) GetXMLDesc() (string, error) {
	result := C.virDomainGetXMLDesc(d.ptr, C.VIR_DOMAIN_XML_SECURE)
	if result == nil {
		return "", errors.New(GetLastError())
	}
	xml := C.GoString(result)
	C.free(unsafe.Pointer(result))
	return xml, nil
}
예제 #3
0
func (d *Domain) ToXml(flags uint16) (string, error) {
	result := C.virDomainGetXMLDesc(d.cptr, C.uint(flags))
	if result == nil {
		return "", GetLastError()
	}

	xml := C.GoString(result)
	defer C.free(unsafe.Pointer(result))

	return xml, nil
}
예제 #4
0
// XML provides an XML description of the domain. The description may be reused
// later to relaunch the domain with CreateXML().
func (dom Domain) XML(typ DomainXMLFlag) (string, error) {
	dom.log.Printf("reading domain XML (flags = %v)...\n", typ)
	cXML := C.virDomainGetXMLDesc(dom.virDomain, C.uint(typ))
	if cXML == nil {
		err := LastError()
		dom.log.Printf("an error occurred: %v\n", err)
		return "", err
	}
	defer C.free(unsafe.Pointer(cXML))

	xml := C.GoString(cXML)
	dom.log.Printf("XML length: %v runes\n", utf8.RuneCountInString(xml))

	return xml, nil
}