zoukankan      html  css  js  c++  java
  • libvirt获取实际内存的实现

    libvirt获取实际内存的实现

    libvirt可以通过virDomainGetInfo()来得到虚机信息:
       struct virDomainInfo{
           unsigned char     state     : the running state, one of virDomainState
           unsigned long     maxMem     : the maximum memory in KBytes allowed
           unsigned long     memory     : the memory in KBytes used by the domain
           unsigned short     nrVirtCpu     : the number of virtual CPUs for the domain
           unsigned long long     cpuTime     : the CPU time used in nanoseconds
       }

    libvirt获取虚拟机实际内存的实现方法:

    1. 通过libxl_domain_info():provides a way to get the struct libxl_dominfo 
    for a single domain given its domid.
      
        代码里是读取struct libxl_dominfo -> current_memkb
    来得到实际内存,但是从网上搜到的结构体为:
        struct libxl_dominfo {
         uint8_t uuid[16];
         uint32_t domid;
         uint8_t dying:1;
         uint8_t paused:1;
         uint8_t running:1;
         uint64_t max_memkb;
         uint64_t cpu_time;
         uint32_t vcpu_max_id;
         uint32_t vcpu_online;
    };
        xen-unstable提供了这个接口

    2. 通过xenapi: xen_vm_get_record() xen_vm_metrics_get_memory_actual()
     
    3. QEMU: 通过BallonInfo来获取内存
     
       
  • 相关阅读:
    .NET Remoting 应用实例
    EXT.NET 使用总结(3)--动态图表
    2013,2014
    TreeMap put 操作分析
    C#排序算法小结
    高性能的JavaScript--数据访问(1)
    javascript生成对象的三种方法
    Android开发中经常使用的Content-Type简介
    git diff提示filemode发生改变(old mode 100644、new mode 10075)
    UIWebView的使用
  • 原文地址:https://www.cnblogs.com/feisky/p/2264317.html
Copyright © 2011-2022 走看看