[libvirt] [RFC] get guest OS infos

zhang bo oscar.zhangbo at huawei.com
Thu Jun 11 05:51:33 UTC 2015


Different OSes have different capabilities and behaviors sometimes. We have to distinguish them then. 

For example, our clients want to send NMI interrupts to certain guests(eg.Linux distributions), but not others(eg.Windows guests).
They want to acquire the list below:
  guest1: RHEL 7
  guest2: RHEL 7
  guest3: Ubuntu 12
  guest4: Ubuntu 13
  guest5: Windows 7
  ......

AFAIK, neither libvirt nor openstack, nor qemu, have such capbility of showing these guest OS infos.
Libvirt now supports to show host capabilities and driver capability, but not an individual guest OS's capibility. We may refer to 
http://libvirt.org/formatdomaincaps.html for more information.

So, what's your opinion on adding such feature in libvirt and qemu? 

-----------------------------------------------------------------------
The solution I can see is:
1 add a new qga command in qemu agent, 'guest-get-osinfo', which gets the os infos by qemu-agent inside the guest.
  { 'command': 'guest-get-osinfo',
  'returns': ['GuestOSInfo'] }

  { 'struct': 'GuestOSInfo',
    'data': {'distribution': 'GuestOSDistribution',
             'version': 'int',
             'arch': 'GuestOSArchType'} }
  an example Json result:
  {"return":
    {"distribution": "RHEL",
     "version": "7",
     "arch": "x86_64"
    }
  }

2 add new helper APIs for that qga command in libvirt.
  qemuAgentGetOSInfo()
3 When the guest starts up and its qemu-agent is running, call qemuAgentGetOSINfo() in libvirt.
4 set the osinfo, which is got at step 3, into the guest's status and config file.
  <domainCapabilities>
    <path>/usr/bin/qemu-system-x86_64</path>
    <domain>kvm</domain>
    <machine>pc-i440fx-2.1</machine>
    <arch>x86_64</arch>
    <distribution>
      <type>RHEL</type>
      <version>7</version>
    </distribution>
    
  ...
 </domainCapabilities>

  This feature is added into the xml node 'domainCapabilities' here. If there's any other better choice, please let me know.
  



-- 
Oscar    
oscar.zhangbo at huawei.com  




More information about the libvir-list mailing list