Implementation of libvirt to obtain the actual memory

Source: Internet
Author: User
Implementation of libvirt to obtain the actual memory

Libvirt can use virdomaingetinfo () to obtain VM information:
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 nr1_cpu: the number of virtual CPUs for the domain
Unsigned long cputime: the CPU time used in nanoseconds
}

Libvirt:

1. Use libxl_domain_info (): provides a way to get the struct libxl_dominfo
For a single domain given its domid.

CodeRead struct libxl_dominfo-> current_memkb
To obtain the actual memory, but the structure found on the internet is:
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 provides this interface

2. Use xenapi: xen_vm_get_record () xen_vm_metrics_get_memory_actual ()
 
3. qemu: Obtain memory through balloninfo
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.