Exemplo n.º 1
0
func (v *VirStorageVol) GetInfo() (VirStorageVolInfo, error) {
	vi := VirStorageVolInfo{}
	var ptr C.virStorageVolInfo
	result := C.virStorageVolGetInfo(v.ptr, (*C.virStorageVolInfo)(unsafe.Pointer(&ptr)))
	if result == -1 {
		return vi, GetLastError()
	}
	vi.ptr = ptr
	return vi, nil
}
Exemplo n.º 2
0
// InfoCapacity fetches volatile information about the storage volume:
// current capacity.
func (vol StorageVolume) InfoCapacity() (uint64, error) {
	var cInfo C.virStorageVolInfo

	vol.log.Println("reading storage volume capacity...")
	cRet := C.virStorageVolGetInfo(vol.virStorageVol, &cInfo)
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		vol.log.Printf("an error occurred: %v\n", err)
		return 0, err
	}

	capacity := uint64(cInfo.capacity)
	vol.log.Printf("capacity: %v\n", capacity)

	return capacity, nil
}
Exemplo n.º 3
0
// InfoAllocation fetches volatile information about the storage volume:
// current allocation.
func (vol StorageVolume) InfoAllocation() (uint64, error) {
	var cInfo C.virStorageVolInfo

	vol.log.Println("reading storage volume allocation...")
	cRet := C.virStorageVolGetInfo(vol.virStorageVol, &cInfo)
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		vol.log.Printf("an error occurred: %v\n", err)
		return 0, err
	}

	allocation := uint64(cInfo.allocation)
	vol.log.Printf("allocation: %v\n", allocation)

	return allocation, nil
}
Exemplo n.º 4
0
// InfoType fetches volatile information about the storage volume:
// current type.
func (vol StorageVolume) InfoType() (StorageVolumeType, error) {
	var cInfo C.virStorageVolInfo

	vol.log.Println("reading storage volume type...")
	cRet := C.virStorageVolGetInfo(vol.virStorageVol, &cInfo)
	ret := int32(cRet)

	if ret == -1 {
		err := LastError()
		vol.log.Printf("an error occurred: %v\n", err)
		return 0, err
	}

	typ := StorageVolumeType(cInfo._type)
	vol.log.Printf("type: %v\n", typ)

	return typ, nil
}