예제 #1
0
func (p *VirStoragePool) GetXMLDesc(flags uint32) (string, error) {
	result := C.virStoragePoolGetXMLDesc(p.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
// XML fetches an XML document describing all aspects of the storage pool. This
// is suitable for later feeding back into the
// "<Connection>.CreateStoragePool" method.
func (pool StoragePool) XML(flags StorageXMLFlag) (string, error) {
	pool.log.Printf("reading storage pool XML (flags = %v)...\n", flags)
	cXML := C.virStoragePoolGetXMLDesc(pool.virStoragePool, C.uint(flags))

	if cXML == nil {
		err := LastError()
		pool.log.Printf("an error occurred: %v\n", err)
		return "", err
	}
	defer C.free(unsafe.Pointer(cXML))

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

	return xml, nil
}