Bug 1229666

Summary: machine type capabilities are missing the canonical names of default types
Product: Red Hat Enterprise Linux 7 Reporter: Michal Skrivanek <michal.skrivanek>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.1CC: bmcclain, dyuan, ecohen, gklein, lsurette, michal.skrivanek, mpoledni, mzhan, pstehlik, rbalakri, sbonazzo, snagar, yeylon, ylavi, zhwang, zpeng
Target Milestone: rcKeywords: DevelBlocker, Regression, TestBlocker, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.2.17-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1229396
: 1263317 (view as bug list) Environment:
Last Closed: 2015-11-19 06:40:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1229396    
Bug Blocks: 1154205, 1172230, 1263317    

Description Michal Skrivanek 2015-06-09 11:44:19 UTC
The capabilities do not report the supported machine types for the default ones. When there is the "canonical" attribute libvirt returns only the tag name and the machine type mentioned as "canonical" is not present

I.e. when looking at supported machine types enumerating the tags you fail to see the latest one

qemu-kvm-rhev-2.1.2-23.el7_1.3.x86_64:

/usr/libexec/qemu-kvm -machine help
Supported machines are:
pc                   RHEL 7.1.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.1.0)
pc-i440fx-rhel7.1.0  RHEL 7.1.0 PC (i440FX + PIIX, 1996) (default)
pc-i440fx-rhel7.0.0  RHEL 7.0.0 PC (i440FX + PIIX, 1996)
rhel6.6.0            RHEL 6.6.0 PC
rhel6.5.0            RHEL 6.5.0 PC
rhel6.4.0            RHEL 6.4.0 PC
rhel6.3.0            RHEL 6.3.0 PC
rhel6.2.0            RHEL 6.2.0 PC
rhel6.1.0            RHEL 6.1.0 PC
rhel6.0.0            RHEL 6.0.0 PC
q35                  RHEL-7.1.0 PC (Q35 + ICH9, 2009) (alias of pc-q35-rhel7.1.0)
pc-q35-rhel7.1.0     RHEL-7.1.0 PC (Q35 + ICH9, 2009)
pc-q35-rhel7.0.0     RHEL-7.0.0 PC (Q35 + ICH9, 2009)
none                 empty machine


virsh capabilities returns only these:
      <machine canonical='pc-i440fx-rhel7.1.0' maxCpus='240'>pc</machine>
      <machine maxCpus='240'>rhel6.6.0</machine>
      <machine maxCpus='240'>pc-q35-rhel7.0.0</machine>
      <machine maxCpus='240'>rhel6.4.0</machine>
      <machine canonical='pc-q35-rhel7.1.0' maxCpus='240'>q35</machine>
      <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
      <machine maxCpus='240'>rhel6.2.0</machine>
      <machine maxCpus='240'>rhel6.1.0</machine>
      <machine maxCpus='240'>rhel6.5.0</machine>
      <machine maxCpus='240'>rhel6.0.0</machine>
      <machine maxCpus='240'>rhel6.3.0</machine>


on RHEL 6 there is an extra machine tag for the default option too

Comment 2 Jaroslav Suchanek 2015-06-09 19:28:37 UTC
Jiri, can you please provide more detailed explanation? Thanks.

Comment 3 Jiri Denemark 2015-06-09 22:18:35 UTC
In other words, "/capabilities/guest/arch[@name='x86_64']/machine/text()" XPath no longer provides a complete list of machine types supported by QEMU because some of them are hidden in the "cannonical" attribute. This seems to be a side effect of QMP probing.

The result of "qemu-system-x86_64 -machine ?" is:
    Supported machines are:
    pc                   Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
    pc-i440fx-2.3        Standard PC (i440FX + PIIX, 1996) (default)
    pc-i440fx-2.2        Standard PC (i440FX + PIIX, 1996)
    pc-i440fx-2.1        Standard PC (i440FX + PIIX, 1996)
    pc-i440fx-2.0        Standard PC (i440FX + PIIX, 1996)
    pc-i440fx-1.7        Standard PC (i440FX + PIIX, 1996)
    pc-i440fx-1.6        Standard PC (i440FX + PIIX, 1996)
    pc-i440fx-1.5        Standard PC (i440FX + PIIX, 1996)
    pc-i440fx-1.4        Standard PC (i440FX + PIIX, 1996)
    pc-1.3               Standard PC (i440FX + PIIX, 1996)
    pc-1.2               Standard PC (i440FX + PIIX, 1996)
    pc-1.1               Standard PC (i440FX + PIIX, 1996)
    pc-1.0               Standard PC (i440FX + PIIX, 1996)
    pc-0.15              Standard PC (i440FX + PIIX, 1996)
    pc-0.14              Standard PC (i440FX + PIIX, 1996)
    pc-0.13              Standard PC (i440FX + PIIX, 1996)
    pc-0.12              Standard PC (i440FX + PIIX, 1996)
    pc-0.11              Standard PC (i440FX + PIIX, 1996)
    pc-0.10              Standard PC (i440FX + PIIX, 1996)
    q35                  Standard PC (Q35 + ICH9, 2009) (alias of pc-q35-2.3)
    pc-q35-2.3           Standard PC (Q35 + ICH9, 2009)
    pc-q35-2.2           Standard PC (Q35 + ICH9, 2009)
    pc-q35-2.1           Standard PC (Q35 + ICH9, 2009)
    pc-q35-2.0           Standard PC (Q35 + ICH9, 2009)
    pc-q35-1.7           Standard PC (Q35 + ICH9, 2009)
    pc-q35-1.6           Standard PC (Q35 + ICH9, 2009)
    pc-q35-1.5           Standard PC (Q35 + ICH9, 2009)
    pc-q35-1.4           Standard PC (Q35 + ICH9, 2009)
    isapc                ISA-only PC
    none                 empty machine

The same binary reports the following to "query-machines" QMP command:

    {"return": [
        {"name": "isapc", "cpu-max": 1},
        {"name": "none", "cpu-max": 1},
        {"name": "pc-0.10", "cpu-max": 255},
        {"name": "pc-0.11", "cpu-max": 255},
        {"name": "pc-0.12", "cpu-max": 255},
        {"name": "pc-0.13", "cpu-max": 255}
        {"name": "pc-0.14", "cpu-max": 255},
        {"name": "pc-0.15", "cpu-max": 255},
        {"name": "pc-1.0", "cpu-max": 255},
        {"name": "pc-1.1", "cpu-max": 255},
        {"name": "pc-1.2", "cpu-max": 255},
        {"name": "pc-1.3", "cpu-max": 255},
        {"name": "pc-i440fx-1.4", "cpu-max": 255},
        {"name": "pc-i440fx-1.5", "cpu-max": 255},
        {"name": "pc-i440fx-1.6", "cpu-max": 255},
        {"name": "pc-i440fx-1.7", "cpu-max": 255},
        {"name": "pc-i440fx-2.0", "cpu-max": 255},
        {"name": "pc-i440fx-2.1", "cpu-max": 255},
        {"name": "pc-i440fx-2.2", "cpu-max": 255},
        {"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"},
        {"name": "pc-q35-1.4", "cpu-max": 255},
        {"name": "pc-q35-1.5", "cpu-max": 255},
        {"name": "pc-q35-1.6", "cpu-max": 255},
        {"name": "pc-q35-1.7", "cpu-max": 255},
        {"name": "pc-q35-2.0", "cpu-max": 255},
        {"name": "pc-q35-2.1", "cpu-max": 255},
        {"name": "pc-q35-2.2", "cpu-max": 255},
        {"name": "pc-q35-2.3", "cpu-max": 255, "alias": "q35"},
    ], "id": "libvirt-32"}

You can see that "-machine ?" returns separate lines for "pc" and "pc-i440fx-2.3" (and their "q35" and "pc-q35-2.3" friends) while "query-machines" gives only a single entry describing both "pc-i440fx-2.3" and its "pc" alias).

That said, for QMP probing we actually need to insert two separate entries into our internal machine types array whenever we parse an entry with an alias.

Comment 4 Jiri Denemark 2015-06-18 08:05:50 UTC
This is now fixed upstream by v1.2.16-202-gbeca509:

commit beca509e437b51b68ff42494cc67919d306876ea
Author: Jiri Denemark <jdenemar>
Date:   Fri Jun 12 14:36:51 2015 +0200

    qemu: Report all supported machine types in capabilities
    
    Some machine types are only reported as canonical names for other
    machine types, which make it a bit harder to find what machine types are
    supported by a specific QEMU binary. Ideally, one would just use
    /capabilities/guest/arch[@name='...']/machine/text() XPath to get a list
    of all supported machine types, but it doesn't work right now.
    
    For example, we report
    
        <machine canonical='pc-i440fx-2.3' maxCpus='255'>pc</machine>
    
    in guest capabilities, but the corresponding
    
        <machine maxCpus='255'>pc-i440fx-2.3</machine>
    
    is missing.
    
    This is a result of QMP probing. With "-machine ?" parsing QEMU sends
    us two lines:
    
    pc                   Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
    pc-i440fx-2.3        Standard PC (i440FX + PIIX, 1996) (default)
    
    while query-machines QMP command reports both in the same entry:
    
    {"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"}
    
    Let's make sure we always report separate <machine/> for both the
    canonical name and its alias and using the canonical name as the default
    machine type (i.e., inserting it before its alias) in case is-default is
    true.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1229666
    
    Signed-off-by: Jiri Denemark <jdenemar>

Comment 6 zhenfeng wang 2015-07-07 04:59:53 UTC
Reproduce this bug with libvirt-1.2.15-1.el7.x86_64, couldn't see the default machine type in the capabilities, could only see the canonical machine type

# /usr/libexec/qemu-kvm -machine help
Supported machines are:
pc                   RHEL 7.2.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.2.0)
pc-i440fx-rhel7.2.0  RHEL 7.2.0 PC (i440FX + PIIX, 1996) (default)
pc-i440fx-rhel7.1.0  RHEL 7.1.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.0.0  RHEL 7.0.0 PC (i440FX + PIIX, 1996)

#virsh capabilities

<guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine canonical='pc-i440fx-rhel7.2.0' maxCpus='240'>pc</machine>
      <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
      <machine maxCpus='240'>pc-q35-rhel7.1.0</machine>
      <machine maxCpus='240'>rhel6.3.0</machine>
      <machine canonical='pc-q35-rhel7.2.0' maxCpus='240'>q35</machine>

Verify this bug with   libvirt.x86_64 0:1.2.17-1.el7, could see the default machine type in the capabilities
# /usr/libexec/qemu-kvm -machine help
Supported machines are:
pc                   RHEL 7.2.0 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-rhel7.2.0)
pc-i440fx-rhel7.2.0  RHEL 7.2.0 PC (i440FX + PIIX, 1996) (default)
pc-i440fx-rhel7.1.0  RHEL 7.1.0 PC (i440FX + PIIX, 1996)
pc-i440fx-rhel7.0.0  RHEL 7.0.0 PC (i440FX + PIIX, 1996)
--

 <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine maxCpus='240'>pc-i440fx-rhel7.2.0</machine>
      <machine canonical='pc-i440fx-rhel7.2.0' maxCpus='240'>pc</machine>
      <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
      <machine maxCpus='240'>pc-q35-rhel7.1.0</machine>

According to the upper steps, mark this bug verified

Comment 10 errata-xmlrpc 2015-11-19 06:40:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html