[libvirt] cpu flags

Daniel P. Berrange berrange at redhat.com
Wed Sep 17 09:42:00 UTC 2008

On Tue, Sep 16, 2008 at 04:45:09PM -0400, Ben Guthro wrote:
> Hi,
> We're finding that we are going to be needing the cpu flags (as reported 
> in /proc/cpuinfo)
> ..specifically to find out if we are a vmx enabled machine.
> So - off I went looking into this for a patch to submit upstream.
> Unfortunately, I ran into some questions which need answering before I 
> really proceed with this
> It seems to me that this info would best be parsed in src/nodeinfo.c
> This is where other cpuinfo things are parsed...and stored in the 
> nodeinfo struct
> Perhaps we store this as a bitmask encoded int, as defined in 
> /usr/include/asm/cpufeature.h and tack this onto the end of sad struct.
> My concern is that adding to the nodeinfo struct breaks the API - such 
> that the structs will be different sizes between versions.

Indeed - any struct or API in include/libvirt/libvirt.h is immutable
to preserve ABI.

> Also - this seems to be x86 specific. Are we primarily destined for x86? 
> Or would this type of change be unacceptable due to not working on PPC, 
> for example?

No,we need to work on every architecture - KVM for example is ported to
x86, ia64, ppc, and s390, Xen is on arm, x86, ia64. Now the set of flags
will likely be different across each processor - and some may not even
have a concept of flags, but we shouldn't be specifically x86 in API.

I think the most likely place for exposing CPU flags would be in the
capabilities XML format. We do in fact already expose 3 flags there,
PAE, VMX and SVM. 

As John mentions we also need to be careful to specify a naming that is
consistent across OS - though that may be as simple as defining that 
the naming is required to match Linux /proc/cpuinfo standards. The intent
is that if you have the same CPUs in 2 machines, one running Linux and 
the other Solaris then libvirt must report the same names.

|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

More information about the libvir-list mailing list