[go學習]libvirt-go中能夠提供的虛機信息

我把libvirt-go源碼中的domain翻了一遍,找到一下全部能夠get到的內容,但是具體每個的get操作我只嘗試了幾個。先mark下吧。每條中的url是libvirt-go對應libvirt的c版本的api文檔,go並沒有文檔,所以需要自己去手動對應。

1.	  虛擬cpu信息:
a)	Extract information about virtual CPUs of domain。
b)	 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetVcpus 
type DomainVcpuInfo struct {
   Number  uint32
   State   int32
   CpuTime uint64
   Cpu     int32
   CpuMap  []bool
}

2.	得到主機名:
a)	func (d *Domain) GetName() (string, error) 
b)	Get the public name for that domain.
c)	 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetName 
3.	 func (d *Domain) GetState() (DomainState, int, error) 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetState 
4.	得到主機Metadata信息:
a)	func (d *Domain) GetMetadata(tipus DomainMetadataType, uri string, flags DomainModificationImpact) (string, error)
b)	 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetMetadata 
5.	 func (d *Domain) GetVcpusFlags(flags DomainVcpuFlags) (int32, error) 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetVcpusFlags 
6.	  虛擬機信息:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetInfo 
type DomainInfo struct {
   State     DomainState // 運行狀態 
   MaxMem    uint64 // 允許的最大內存,KB
   Memory    uint64 // 主機內存,KB //TODO區別??
   NrVirtCpu uint // 虛機虛擬CPU個數
   CpuTime   uint64// CPU使用時間,ns
}

7.	 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInterfaceAddresses 
 type DomainIPAddress struct {
   Type   int
   Addr   string
   Prefix uint
}

type DomainInterface struct {
   Name   string
   Hwaddr string
   Addrs  []DomainIPAddress
}

8.	得到單個主機CPU使用相關的統計信息:
a)	Get statistics relating to CPU usage attributable to a single domain (in contrast to the statistics returned by virNodeGetCPUStats() for all processes on the host).
b)	https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetCPUStats 
type DomainCPUStats struct {
   CpuTimeSet    bool
   CpuTime       uint64
   UserTimeSet   bool
   UserTime      uint64
   SystemTimeSet bool
   SystemTime    uint64
   VcpuTimeSet   bool
   VcpuTime      uint64
}

9.	 得到端口參數:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetInterfaceParameters 
type DomainInterfaceParameters struct {
   BandwidthInAverageSet  bool
   BandwidthInAverage     uint
   BandwidthInPeakSet     bool
   BandwidthInPeak        uint
   BandwidthInBurstSet    bool
   BandwidthInBurst       uint
   BandwidthInFloorSet    bool
   BandwidthInFloor       uint
   BandwidthOutAverageSet bool
   BandwidthOutAverage    uint
   BandwidthOutPeakSet    bool
   BandwidthOutPeak       uint
   BandwidthOutBurstSet   bool
   BandwidthOutBurst      uint
}

10.	塊設備狀態:
 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainBlockStats 
type DomainBlockStats struct {
   RdBytesSet         bool
   RdBytes            int64 //讀取字節數
   RdReqSet           bool
   RdReq              int64// 讀取請求數
   RdTotalTimesSet    bool
   RdTotalTimes       int64 //讀取花費總時間?
   WrBytesSet         bool
   WrBytes            int64 //寫入字節數
   WrReqSet           bool
   WrReq              int64 //寫入需求數
   WrTotalTimesSet    bool
   WrTotalTimes       int64 //寫入花費總時間?
   FlushReqSet        bool
   FlushReq           int64 //刷新請求數
   FlushTotalTimesSet bool
   FlushTotalTimes    int64 //刷新花費總時間
   ErrsSet            bool
   Errs               int64 //出錯次數
}

11.	 端口狀態: https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInterfaceStats 
type DomainInterfaceStats struct {
   RxBytesSet   bool
   RxBytes      int64 // 接收字節數
   RxPacketsSet bool
   RxPackets    int64 //接收包數
   RxErrsSet    bool
   RxErrs       int64 //接收出錯次數
   RxDropSet    bool
   RxDrop       int64 //接收丟棄包數
   TxBytesSet   bool
   TxBytes      int64 //傳輸字節數
   TxPacketsSet bool
   TxPackets    int64 //傳輸包數
   TxErrsSet    bool
   TxErrs       int64 //傳輸出錯次數
   TxDropSet    bool
   TxDrop       int64 //傳輸丟棄包數
}

12.	主機內存策略是啥???:
a)	Api下方有多種內存策略: https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMemoryStats 
type DomainMemoryStat struct {
   Tag int32
   Val uint64
}

13.	得到當前主機的快照:
 https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotCurrent 
type DomainSnapshot struct {
   ptr C.virDomainSnapshotPtr
}

14.	 檢查點???:
https://libvirt.org/html/libvirt-libvirt-domain-checkpoint.html#virDomainCheckpointLookupByName 
type DomainCheckpoint struct {
   ptr C.virDomainCheckpointPtr
}

15.	 塊備份。這個所有方法裏全都是隻作爲輸入,沒有作爲輸出。
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainBlockCopy 
type DomainBlockCopyParameters struct {
   BandwidthSet   bool
   Bandwidth      uint64
   GranularitySet bool
   Granularity    uint
   BufSizeSet     bool
   BufSize        uint64
}

16.	 這個所有方法裏全都是隻作爲輸入,沒有作爲輸出。
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrate3 
type DomainMigrateParameters struct {
   URISet                    bool
   URI                       string
   DestNameSet               bool
   DestName                  string
   DestXMLSet                bool
   DestXML                   string
   PersistXMLSet             bool
   PersistXML                string
   BandwidthSet              bool
   Bandwidth                 uint64
   GraphicsURISet            bool
   GraphicsURI               string
   ListenAddressSet          bool
   ListenAddress             string
   MigrateDisksSet           bool
   MigrateDisks              []string
   DisksPortSet              bool
   DisksPort                 int
   CompressionSet            bool
   Compression               string
   CompressionMTLevelSet     bool
   CompressionMTLevel        int
   CompressionMTThreadsSet   bool
   CompressionMTThreads      int
   CompressionMTDThreadsSet  bool
   CompressionMTDThreads     int
   CompressionXBZRLECacheSet bool
   CompressionXBZRLECache    uint64
   AutoConvergeInitialSet    bool
   AutoConvergeInitial       int
   AutoConvergeIncrementSet  bool
   AutoConvergeIncrement     int
   ParallelConnectionsSet    bool
   ParallelConnections       int
}

17.	Blkio參數???是啥:
 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetBlkioParameters 
type DomainBlkioParameters struct {
   WeightSet          bool
   Weight             uint
   DeviceWeightSet    bool
   DeviceWeight       string
   DeviceReadIopsSet  bool
   DeviceReadIops     string
   DeviceWriteIopsSet bool
   DeviceWriteIops    string
   DeviceReadBpsSet   bool
   DeviceReadBps      string
   DeviceWriteBpsSet  bool
   DeviceWriteBps     string
}

18.	 塊IO可調參數???:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetBlockIoTune 
type DomainBlockIoTuneParameters struct {
   TotalBytesSecSet          bool
   TotalBytesSec             uint64
   ReadBytesSecSet           bool
   ReadBytesSec              uint64
   WriteBytesSecSet          bool
   WriteBytesSec             uint64
   TotalIopsSecSet           bool
   TotalIopsSec              uint64
   ReadIopsSecSet            bool
   ReadIopsSec               uint64
   WriteIopsSecSet           bool
   WriteIopsSec              uint64
   TotalBytesSecMaxSet       bool
   TotalBytesSecMax          uint64
   ReadBytesSecMaxSet        bool
   ReadBytesSecMax           uint64
   WriteBytesSecMaxSet       bool
   WriteBytesSecMax          uint64
   TotalIopsSecMaxSet        bool
   TotalIopsSecMax           uint64
   ReadIopsSecMaxSet         bool
   ReadIopsSecMax            uint64
   WriteIopsSecMaxSet        bool
   WriteIopsSecMax           uint64
   TotalBytesSecMaxLengthSet bool
   TotalBytesSecMaxLength    uint64
   ReadBytesSecMaxLengthSet  bool
   ReadBytesSecMaxLength     uint64
   WriteBytesSecMaxLengthSet bool
   WriteBytesSecMaxLength    uint64
   TotalIopsSecMaxLengthSet  bool
   TotalIopsSecMaxLength     uint64
   ReadIopsSecMaxLengthSet   bool
   ReadIopsSecMaxLength      uint64
   WriteIopsSecMaxLengthSet  bool
   WriteIopsSecMaxLength     uint64
   SizeIopsSecSet            bool
   SizeIopsSec               uint64
   GroupNameSet              bool
   GroupName                 string
}

19.	  請求給定磁盤的塊作業信息:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetBlockJobInfo 
type DomainBlockJobInfo struct {
   Type      DomainBlockJobType
   Bandwidth uint64
   Cur       uint64
   End       uint64
}

20.	 主機控制接口當前狀態的詳細信息: 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetControlInfo 
type DomainControlInfo struct {
   State     DomainControlState //控制狀態,api中可選
   Details   int // 狀態詳細,api中可選
   StateTime uint64 // 當前狀態持續時間
}

21.	 主機後臺作業進度信息: 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo 
type DomainJobInfo struct {
   Type                      DomainJobType// Time is measured in milliseconds
   TimeElapsedSet            bool
   TimeElapsed               uint64 // Always set???
   TimeElapsedNetSet         bool
   TimeElapsedNet            uint64
   TimeRemainingSet          bool
   TimeRemaining             uint64 // 隨type不同而不同
   DowntimeSet               bool
   Downtime                  uint64
   DowntimeNetSet            bool
   DowntimeNet               uint64
   SetupTimeSet              bool
   SetupTime                 uint64
   DataTotalSet              bool
   DataTotal                 uint64
   DataProcessedSet          bool
   DataProcessed             uint64
   DataRemainingSet          bool
   DataRemaining             uint64 //同time remaining,見api
   MemTotalSet               bool
   MemTotal                  uint64
   MemProcessedSet           bool
   MemProcessed              uint64
   MemRemainingSet           bool
   MemRemaining              uint64
   MemConstantSet            bool
   MemConstant               uint64
   MemNormalSet              bool
   MemNormal                 uint64
   MemNormalBytesSet         bool
   MemNormalBytes            uint64
   MemBpsSet                 bool
   MemBps                    uint64
   MemDirtyRateSet           bool
   MemDirtyRate              uint64
   MemPageSizeSet            bool
   MemPageSize               uint64
   MemIterationSet           bool
   MemIteration              uint64
   DiskTotalSet              bool
   DiskTotal                 uint64
   DiskProcessedSet          bool
   DiskProcessed             uint64
   DiskRemainingSet          bool
   DiskRemaining             uint64
   DiskBpsSet                bool
   DiskBps                   uint64
   CompressionCacheSet       bool
   CompressionCache          uint64
   CompressionBytesSet       bool
   CompressionBytes          uint64
   CompressionPagesSet       bool
   CompressionPages          uint64
   CompressionCacheMissesSet bool
   CompressionCacheMisses    uint64
   CompressionOverflowSet    bool
   CompressionOverflow       uint64
   AutoConvergeThrottleSet   bool
   AutoConvergeThrottle      int
   OperationSet              bool
   Operation                 DomainJobOperationType
   MemPostcopyReqsSet        bool
   MemPostcopyReqs           uint64
}

22.	 得到最大物理內存:func (d *Domain) GetMaxMemory() (uint64, error)
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetMaxMemory 
23.	客戶機支持的最大虛擬cpu數量: func (d *Domain) GetMaxVcpus() (uint, error)
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetMaxVcpus 
24.	 得到系統類型:func (d *Domain) GetOSType() (string, error)
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetOSType 
25.	得到內存參數??:
 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetMemoryParameters 
type DomainMemoryParameters struct {
   HardLimitSet     bool
   HardLimit        uint64
   SoftLimitSet     bool
   SoftLimit        uint64
   MinGuaranteeSet  bool
   MinGuarantee     uint64
   SwapHardLimitSet bool
   SwapHardLimit    uint64
}

26.	 得到numa參數??:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetNumaParameters 
type DomainNumaParameters struct {
   NodesetSet bool
   Nodeset    string
   ModeSet    bool
   Mode       DomainNumatuneMemMode
}

27.	 得到所有linux Perf事件:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetPerfEvents 
type DomainPerfEvents struct {
   CmtSet                   bool
   Cmt                      bool
   MbmtSet                  bool
   Mbmt                     bool
   MbmlSet                  bool
   Mbml                     bool
   CacheMissesSet           bool
   CacheMisses              bool
   CacheReferencesSet       bool
   CacheReferences          bool
   InstructionsSet          bool
   Instructions             bool
   CpuCyclesSet             bool
   CpuCycles                bool
   BranchInstructionsSet    bool
   BranchInstructions       bool
   BranchMissesSet          bool
   BranchMisses             bool
   BusCyclesSet             bool
   BusCycles                bool
   StalledCyclesFrontendSet bool
   StalledCyclesFrontend    bool
   StalledCyclesBackendSet  bool
   StalledCyclesBackend     bool
   RefCpuCyclesSet          bool
   RefCpuCycles             bool
   CpuClockSet              bool
   CpuClock                 bool
   TaskClockSet             bool
   TaskClock                bool
   PageFaultsSet            bool
   PageFaults               bool
   ContextSwitchesSet       bool
   ContextSwitches          bool
   CpuMigrationsSet         bool
   CpuMigrations            bool
   PageFaultsMinSet         bool
   PageFaultsMin            bool
   PageFaultsMajSet         bool
   PageFaultsMaj            bool
   AlignmentFaultsSet       bool
   AlignmentFaults          bool
   EmulationFaultsSet       bool
   EmulationFaults          bool
}

28.	 得到調度參數:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetSchedulerParameters 
type DomainSchedulerParameters struct {
   Type              string
   CpuSharesSet      bool
   CpuShares         uint64
   GlobalPeriodSet   bool
   GlobalPeriod      uint64
   GlobalQuotaSet    bool
   GlobalQuota       int64
   VcpuPeriodSet     bool
   VcpuPeriod        uint64
   VcpuQuotaSet      bool
   VcpuQuota         int64
   EmulatorPeriodSet bool
   EmulatorPeriod    uint64
   EmulatorQuotaSet  bool
   EmulatorQuota     int64
   IothreadPeriodSet bool
   IothreadPeriod    uint64
   IothreadQuotaSet  bool
   IothreadQuota     int64
   WeightSet         bool
   Weight            uint
   CapSet            bool
   Cap               uint
   ReservationSet    bool
   Reservation       int64
   LimitSet          bool
   Limit             int64
   SharesSet         bool
   Shares            int
}

29.	 得到安全標籤:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetSecurityLabel 
type SecurityLabel struct {
   Label     string
   Enforcing bool
}

30.	 得到虛機系統時間: func (d *Domain) GetTime(flags uint32) (int64, uint, error)
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetTime 
31.	 獲取指定客戶機和磁盤中每個裝入的文件系統的映射信息列表:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetFSInfo 
type DomainFSInfo struct {
   MountPoint string
   Name       string
   FSType     string
   DevAlias   []string
}

32.	 查詢主機中所有仿真器線程的CPU關聯設置,將其存儲在cpumap中:
a)	Query the CPU affinity setting of all emulator threads of domain, store it in cpumap.
b)	func (d *Domain) GetEmulatorPinInfo(flags DomainModificationImpact) ([]bool, error)
c)	https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetEmulatorPinInfo 
33.	 獲取活動主機的IO線程,包括cpumap信息,以確定iothread在哪個CPU上運行的關聯性:
a)	Fetch IOThreads of an active domain including the cpumap information to determine on which CPU the IOThread has affinity to run
b)	https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetIOThreadInfo 
type DomainIOThreadInfo struct {
   IOThreadID uint
   CpuMap     []bool
}

34.	 查詢主機中所有虛擬CPU的CPU關聯設置,將其存儲在CPU映射中:
a)	Query the CPU affinity setting of all virtual CPUs of domain, store it in cpumaps.
b)	func (d *Domain) GetVcpuPinInfo(flags DomainModificationImpact) ([][]bool, error)
c)	https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetVcpuPinInfo 
35.	從客戶機的角度向客戶機端查詢有關VCPUS的狀態和信息。報告的數據取決於客戶機端實現。:
a)	Queries the guest agent for state and information regarding vCPUs from guest's perspective. The reported data depends on the guest agent implementation.
b)	 https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetGuestVcpus 
type DomainGuestVcpus struct {
   VcpusSet      bool
   Vcpus         []bool
   OnlineSet     bool
   Online        []bool
   OfflinableSet bool
   Offlinable    []bool
}

36.	 得到安加載安全參數信息:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetLaunchSecurityInfo 
type DomainLaunchSecurityParameters struct {
   SEVMeasurementSet bool
   SEVMeasurement    string
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章