Exemplo n.º 1
0
 /// <summary>
 /// This function returns block device (disk) stats for block devices attached to the domain. The path parameter is the name of the block device. Get this by calling virDomainGetXMLDesc and finding the target dev='...' attribute within //domain/devices/disk. (For example, "xvda"). Domains may have more than one block device. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.
 /// </summary>
 /// <param name="dom">pointer to the domain object</param>
 /// <param name="path">path to the block device</param>
 /// <param name="stats">block device stats (returned)</param>
 /// <returns>0 in case of success or -1 in case of failure.</returns>
 public static int BlockStats(IntPtr dom, string path, out DomainBlockStatsStruct stats)
 {
     DomainBlockStatsStruct statStruct = new DomainBlockStatsStruct();
     IntPtr statStructPtr = Marshal.AllocHGlobal(Marshal.SizeOf(statStruct));
     Marshal.StructureToPtr(statStruct, statStructPtr, true);
     int result = BlockStats(dom, path, statStructPtr, Marshal.SizeOf(statStruct));
     Marshal.PtrToStructure(statStructPtr, statStruct);
     stats = statStruct;
     Marshal.FreeHGlobal(statStructPtr);
     return result;
 }
Exemplo n.º 2
0
        /// <summary>
        /// This function returns block device (disk) stats for block devices attached to the domain. The path parameter is the name of the block device. Get this by calling virDomainGetXMLDesc and finding the target dev='...' attribute within //domain/devices/disk. (For example, "xvda"). Domains may have more than one block device. To get stats for each you should make multiple calls to this function. Individual fields within the stats structure may be returned as -1, which indicates that the hypervisor does not support that particular statistic.
        /// </summary>
        /// <param name="dom">pointer to the domain object</param>
        /// <param name="path">path to the block device</param>
        /// <param name="stats">block device stats (returned)</param>
        /// <returns>0 in case of success or -1 in case of failure.</returns>
        public static int BlockStats(IntPtr dom, string path, out DomainBlockStatsStruct stats)
        {
            DomainBlockStatsStruct statStruct = new DomainBlockStatsStruct();
            IntPtr statStructPtr = Marshal.AllocHGlobal(Marshal.SizeOf(statStruct));

            Marshal.StructureToPtr(statStruct, statStructPtr, true);
            int result = BlockStats(dom, path, statStructPtr, Marshal.SizeOf(statStruct));

            Marshal.PtrToStructure(statStructPtr, statStruct);
            stats = statStruct;
            Marshal.FreeHGlobal(statStructPtr);
            return(result);
        }