Beispiel #1
0
func (conn *VirConnection) LookupStorageVolByPath(name string) (VirStorageVol, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	ptr := C.virStorageVolLookupByPath(conn.ptr, cName)
	if ptr == nil {
		return VirStorageVol{}, errors.New(GetLastError())
	}
	return VirStorageVol{ptr: ptr}, nil
}
Beispiel #2
0
func (c *VirConnection) LookupStorageVolByPath(path string) (VirStorageVol, error) {
	cPath := C.CString(path)
	defer C.free(unsafe.Pointer(cPath))
	ptr := C.virStorageVolLookupByPath(c.ptr, cPath)
	if ptr == nil {
		return VirStorageVol{}, GetLastError()
	}
	return VirStorageVol{ptr: ptr}, nil
}
// LookupStorageVolumeByPath fetches a pointer to a storage volume based on its
// locally (host) unique path.
//"Free" should be used to free the resources after the storage volume object is
// no longer needed.
func (conn Connection) LookupStorageVolumeByPath(path string) (StorageVolume, error) {
	cPath := C.CString(path)
	defer C.free(unsafe.Pointer(cPath))

	conn.log.Printf("looking up storage volume by path = %v...\n", path)
	cVol := C.virStorageVolLookupByPath(conn.virConnect, cPath)

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

	conn.log.Println("volume found")

	vol := StorageVolume{
		log:           conn.log,
		virStorageVol: cVol,
	}

	return vol, nil
}