Beispiel #1
0
func (c *VirConnection) LookupStoragePoolByName(name string) (VirStoragePool, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	ptr := C.virStoragePoolLookupByName(c.ptr, cName)
	if ptr == nil {
		return VirStoragePool{}, GetLastError()
	}
	return VirStoragePool{ptr: ptr}, nil
}
// LookupStoragePoolByName fetches a storage pool based on its unique name.
// "Free" should be used to free the resources after the storage pool object is
// no longer needed.
func (conn Connection) LookupStoragePoolByName(name string) (StoragePool, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))

	conn.log.Printf("looking up storage pool with name = %v\n", name)
	cPool := C.virStoragePoolLookupByName(conn.virConnect, cName)

	if cPool == nil {
		err := LastError()
		conn.log.Printf("an error occurred: %v\n", err)
		return StoragePool{}, err
	}

	conn.log.Println("pool found")

	pool := StoragePool{
		log:            conn.log,
		virStoragePool: cPool,
	}

	return pool, nil
}