Bug 1075874

Summary: libvirt-cim should ensure to keep/define the <controller> elements
Product: Red Hat Enterprise Linux 7 Reporter: Jincheng Miao <jmiao>
Component: libvirt-cimAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: dyuan, jferlan, mprivozn, mzhan, shyu, ydu
Target Milestone: rcKeywords: Rebase
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-cim-0.6.3-19.el7 Doc Type: Rebase: Bug Fixes and Enhancements
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 10:18:04 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:
Attachments:
Description Flags
This is guest xml
none
This is xml for wbemexec none

Description Jincheng Miao 2014-03-13 05:28:09 UTC
Created attachment 873794 [details]
This is guest xml

Description of problem:

Libvirt-cim should ensure to keep/define the <controller> elements.
Otherwise the domain xml generated by libvirt-cim lacks pci controller,
so that libvirtd will reject the change from cim client.

Version-Release number of selected component (if applicable):
# rpm -q libvirt-cim
libvirt-cim-0.6.3-6.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. define a guest like:

# virsh dumpxml test
<domain type='kvm'>
  <name>test</name>
  <uuid>1536d0ce-e8e8-11e2-9094-5fff350163f4</uuid>
  <memory dumpCore='on' unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='rhel6.4.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='kvm' type='raw' cache='none'/>
      <source file='/tmp/test.img'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </memballoon>
  </devices>
</domain>

2. Then change machine property from 'rhel6.4.0' to 'fedora' using test_machine.xml

# cat test_machine.xml 
<?xml version="1.0" encoding="utf-8" ?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="4711" PROTOCOLVERSION="1.0">
<SIMPLEREQ>
<METHODCALL NAME="ModifySystemSettings">
<LOCALINSTANCEPATH>
 <LOCALNAMESPACEPATH>
  <NAMESPACE NAME="root"></NAMESPACE><NAMESPACE NAME="virt"></NAMESPACE>
 </LOCALNAMESPACEPATH>
 <INSTANCENAME CLASSNAME="KVM_VirtualSystemManagementService">
  <KEYBINDING NAME="CreationClassName"><KEYVALUE VALUETYPE="string">KVM_VirtualSystemManagementService</KEYVALUE></KEYBINDING>
  <KEYBINDING NAME="Name"><KEYVALUE VALUETYPE="string">Management Service</KEYVALUE></KEYBINDING>
  <KEYBINDING NAME="SystemCreationClassName"><KEYVALUE VALUETYPE="string">KVM_HostSystem</KEYVALUE></KEYBINDING>
  <KEYBINDING NAME="SystemName"><KEYVALUE VALUETYPE="string">unknown</KEYVALUE></KEYBINDING>
 </INSTANCENAME>
</LOCALINSTANCEPATH>

<PARAMVALUE NAME="SystemSettings" PARAMTYPE="string">
 <VALUE>
instance of KVM_VirtualSystemSettingData{
 VirtualSystemIdentifier ="test";
 Machine = "fedora";
};
 </VALUE>
</PARAMVALUE>

</METHODCALL>
</SIMPLEREQ>
</MESSAGE>
</CIM>

# wbemexec test_machine.xml 
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="4711" PROTOCOLVERSION="1.0">
<SIMPLERSP>
<METHODRESPONSE NAME="ModifySystemSettings">
<ERROR CODE="1" DESCRIPTION="CIM_ERR_FAILED: Failed to define domain: XML error: No PCI buses available"/>
</METHODRESPONSE>
</SIMPLERSP>
</MESSAGE>
</CIM>

As we see, libvirtd said "No PCI buses available", the request is rejected.
The domain xml libvirt-cim generated (check it from libvirt log) is:
<domain type='kvm'>
  <name>test</name>
  <on_poweroff>destroy</on_poweroff>
  <on_crash>destroy</on_crash>
  <uuid>1536d0ce-e8e8-11e2-9094-5fff350163f4</uuid>
  <clock offset="utc"/>
  <os>
    <type machine="fedora">hvm</type>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
  </features>
  <currentMemory>1048576</currentMemory>
  <memory dumpCore="on">1048576</memory>
  <vcpu>1</vcpu>
  <cputune>
    <shares>0</shares>
  </cputune>
  <devices>
    <disk type="file" device="disk">
      <driver name="kvm" type="raw" cache="none"/>
      <source file="/tmp/test.img"/>
      <target dev="hda" bus="ide"/>
      <readonly/>
      <shareable/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <target dev="hdc" bus="ide"/>
      <readonly/>
    </disk>
    <input type="tablet" bus="usb"/>
    <input type="mouse" bus="ps2"/>
    <serial type="pty">
      <source/>
      <target port="0"/>
    </serial>
    <console type="pty">
      <source/>
      <target port="0"/>
    </console>
    <graphics type="vnc" port="-1" autoport="yes" listen="127.0.0.1" keymap="en-us"/>
    <emulator>/usr/libexec/qemu-kvm</emulator>
  </devices>
</domain>

This xml generated by libvirt-cim lacks pci controller.

Comment 1 Jincheng Miao 2014-03-13 05:29:54 UTC
Created attachment 873795 [details]
This is xml for wbemexec

Comment 2 John Ferlan 2014-03-19 11:36:14 UTC
I posted some code to the upstream libvirt-cim mail list that should resolve this issue, see:

http://www.redhat.com/archives/libvirt-cim/2014-March/msg00052.html

and follow-ups.  It has not yet been reviewed/accepted, but it does work against the upstream head which also has the same problem with the upstream libvirt head.

However, I am on the fence right now as to whether this is a 7.0 blocker or whether it could be added to a 7.0 z-stream.  My primary concern is that the patches to resolve this particular issue touch the same files as just about every other patch since 0.6.3 shipped.  That would mean I either apply 20+ patches to get the RHEL7.0 sources up to date or I create a RHEL only patch set which is a bit more tricky.

Without patch, the RHEL7.0 libvirt-cim would be a "read only" solution - that is it'd be possible to discover/view libvirt-cim managed domains, but attempting to adjust/modify any of those would fail because no <controller> elements are presented in the XML that libvirt-cim generates to create/update the domain.

Comment 4 John Ferlan 2014-05-14 12:03:48 UTC
Patches were committed to upstream libvirt-cim to support controller and controller pool objects.  These could be backported separately or as a whole eventually for a 7.1 release.

Starting with libvirt-cim commit id '4954aa8c9' through commit id '58d6e308'.  Adjustments were also made to 'cimtest' in order account for new type

Comment 10 Shanzhi Yu 2015-07-28 10:31:10 UTC
Verify this bug with libvirt-cim-0.6.3-19.el7.x86_64
Steps as comment 0. 

#  wbemexec test_machine.xml 
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="4711" PROTOCOLVERSION="1.0">
<SIMPLERSP>
<METHODRESPONSE NAME="ModifySystemSettings">
<RETURNVALUE PARAMTYPE="uint32">
<VALUE>
0
</VALUE>
</RETURNVALUE>
</METHODRESPONSE>
</SIMPLERSP>
</MESSAGE>
</CIM>

No error show again. 

And from libvirtd.log 

2015-07-28 10:28:07.014+0000: 14208: debug : virDomainDefineXML:6406 : conn=0x7f5de0001c90, xml=<domain type="kvm">
  <name>test</name>
  <on_poweroff>destroy</on_poweroff>
  <on_crash>destroy</on_crash>
  <uuid>1536d0ce-e8e8-11e2-9094-5fff350163f4</uuid>
  <clock offset="utc"/>
  <os>
    <type arch="x86_64" machine="fedora">hvm</type>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
  </features>
..


So the machine type change to fedora.

Comment 11 errata-xmlrpc 2015-11-19 10:18:04 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-2307.html