[libvirt] [RFC] get guest OS infos

Michal Privoznik mprivozn at redhat.com
Thu Jun 11 08:34:49 UTC 2015


On 11.06.2015 07:51, zhang bo wrote:
> 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 is not going to fly. Firstly, domain capabilities are not on
per-domain basis. So while one domain may run RHEL-7 which supports NMI,
the other (running the same hypervisor) may run a different OS which
does not support NMI. Secondly, domain capabilities are designed to be
consulted prior to constructing domain XML to expose which devices are
supported. Thirdly, guest os detection falls out of libvirt scope. It's
an upper layer that creates and installs new guests. Therefore it's the
layer who is responsible for making such decisions.

Michal




More information about the libvir-list mailing list