[libvirt] [RFC] get guest OS infos

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@huawei.com

On Thu, Jun 11, 2015 at 01:51:33PM +0800, 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?
This is normally something the higher level management app will remember and record. For example, RHEV/oVirt store a record of the OS when the guest is first provisioned. In OpenStack we are going to permit the user to set an image property flag to specify the guest OS, using libosinfo terminology http://specs.openstack.org/openstack/nova-specs/specs/liberty/approved/libvi... Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Thu, Jun 11, 2015 at 09:17:30AM +0100, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 01:51:33PM +0800, 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?
This is normally something the higher level management app will remember and record. For example, RHEV/oVirt store a record of the OS when the guest is first provisioned. In OpenStack we are going to permit the user to set an image property flag to specify the guest OS, using libosinfo terminology
http://specs.openstack.org/openstack/nova-specs/specs/liberty/approved/libvi...
One thing I could see us to is to define an official libosinfo metadata schema. eg so there is a standized way to use the libvirt <metadata> element to record the libosinfo operating system for a guest, giving interoperability across different apps. That doesn't really require any coding - just an update in the libosinfo website with some docs about recommendations Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Thu, Jun 11, 2015 at 3:51 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jun 11, 2015 at 09:17:30AM +0100, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 01:51:33PM +0800, 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.
Hello. I wrote a utility a few years ago to detect which OS is running in each qemu VM under libvirt via memory probing. I have not touched the code in a few years. YMMV. http://pastebin.com/m0mfcK8G

On Thu, Jun 11, 2015 at 08:47:12AM -0500, Dennis Jenkins wrote:
On Thu, Jun 11, 2015 at 3:51 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jun 11, 2015 at 09:17:30AM +0100, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 01:51:33PM +0800, 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.
Hello. I wrote a utility a few years ago to detect which OS is running in each qemu VM under libvirt via memory probing. I have not touched the code in a few years. YMMV.
FWIW, you can also use libguestfs to analyse the disk of a libvirt guest while it is running, if you libguestfs' use readonly mode Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 2015/6/11 21:54, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 08:47:12AM -0500, Dennis Jenkins wrote:
On Thu, Jun 11, 2015 at 3:51 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jun 11, 2015 at 09:17:30AM +0100, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 01:51:33PM +0800, 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.
Hello. I wrote a utility a few years ago to detect which OS is running in each qemu VM under libvirt via memory probing. I have not touched the code in a few years. YMMV.
FWIW, you can also use libguestfs to analyse the disk of a libvirt guest while it is running, if you libguestfs' use readonly mode
Regards, Daniel
Great. It seems much better to have Glance and libosinfo together to get guest osinfo, because you don't have to start the guest to get its osinfo, that's attracting. I just have one question: It uses Glance to set os-name, and let libosinfo search its database to get further more infos(I don't know if I'm right here). Is there any possibility that we set a false os-name to image by Glance, for example, the guest is fedora12, but we set it to Ubuntu13 via Glance. and, when would this feature be implemented in Openstack? Thanks. -- Oscar oscar.zhangbo@huawei.com

On Fri, Jun 12, 2015 at 04:56:17PM +0800, zhang bo wrote:
On 2015/6/11 21:54, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 08:47:12AM -0500, Dennis Jenkins wrote:
On Thu, Jun 11, 2015 at 3:51 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jun 11, 2015 at 09:17:30AM +0100, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 01:51:33PM +0800, 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.
Hello. I wrote a utility a few years ago to detect which OS is running in each qemu VM under libvirt via memory probing. I have not touched the code in a few years. YMMV.
FWIW, you can also use libguestfs to analyse the disk of a libvirt guest while it is running, if you libguestfs' use readonly mode
Regards, Daniel
Great. It seems much better to have Glance and libosinfo together to get guest osinfo, because you don't have to start the guest to get its osinfo, that's attracting.
I just have one question: It uses Glance to set os-name, and let libosinfo search its database to get further more infos(I don't know if I'm right here). Is there any possibility that we set a false os-name to image by Glance, for example, the guest is fedora12, but we set it to Ubuntu13 via Glance.
It of course relies on the user setting the correct operating system name for their image. If the user sets this wrong, then the guest may end up getting the wrong hardware config.
and, when would this feature be implemented in Openstack? Thanks.
It is under review https://review.openstack.org/#/q/status:open+project:openstack/nova+branch:m... NB, this only covers configuration of disk & network drivers. In the future we'll extend it to other interesting things Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 2015/6/12 17:05, Daniel P. Berrange wrote:
On Fri, Jun 12, 2015 at 04:56:17PM +0800, zhang bo wrote:
On 2015/6/11 21:54, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 08:47:12AM -0500, Dennis Jenkins wrote:
On Thu, Jun 11, 2015 at 3:51 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
On Thu, Jun 11, 2015 at 09:17:30AM +0100, Daniel P. Berrange wrote:
On Thu, Jun 11, 2015 at 01:51:33PM +0800, zhang bo wrote: > Different OSes have different capabilities and behaviors sometimes. We Great. It seems much better to have Glance and libosinfo together to get guest osinfo, because you don't have to start the guest to get its osinfo, that's attracting.
I just have one question: It uses Glance to set os-name, and let libosinfo search its database to get further more infos(I don't know if I'm right here). Is there any possibility that we set a false os-name to image by Glance, for example, the guest is fedora12, but we set it to Ubuntu13 via Glance.
It of course relies on the user setting the correct operating system name for their image. If the user sets this wrong, then the guest may end up getting the wrong hardware config.
and, when would this feature be implemented in Openstack? Thanks.
It is under review
https://review.openstack.org/#/q/status:open+project:openstack/nova+branch:m...
NB, this only covers configuration of disk & network drivers. In the future we'll extend it to other interesting things
Thank you very much! I'd follow there then. -- Oscar oscar.zhangbo@huawei.com

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
participants (5)
-
Daniel P. Berrange
-
Dennis Jenkins
-
Michal Privoznik
-
Olaf Hering
-
zhang bo