Bug 795093

Summary: [libvirt] missing 'source file' attribute when passing 'optional' param in xml
Product: Red Hat Enterprise Linux 6 Reporter: Haim <hateya>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 6.3CC: abaron, acathrow, crobinso, dallan, danken, dyuan, ewarszaw, hateya, ilvovsky, mgoldboi, mzhan, rwu, veillard, weizhan, whuang, xen-maint, yeylon
Target Milestone: rcKeywords: TestBlocker
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.10-3.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:48:33 UTC Type: ---
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
libvirt logs none

Description Haim 2012-02-19 10:22:44 UTC
Description of problem:

missing 'source dev' attribute when passing 'optional' param in XML with regardless wither source-dev exists or not. 

xml:

<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <serial></serial>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>

log (vdsm):

Thread-221::ERROR::2012-02-19 09:59:17,807::utils::399::vm.Vm::(collect) vmId=`2aed27de-bc3f-40cb-85b3-1839f8e38279`::Stats function failed: <AdvancedStatsFunction _sampleDiskLatency at 0x207a7a0>
Traceback (most recent call last):
  File "/usr/share/vdsm/utils.py", line 395, in collect
    statsFunction()
  File "/usr/share/vdsm/utils.py", line 272, in __call__
    retValue = self._function(*args, **kwargs)
  File "/usr/share/vdsm/libvirtvm.py", line 158, in _sampleDiskLatency
    diskLatency[vmDrive.name] = stats[vmDrive.alias]
AttributeError: 'Drive' object has no attribute 'alias'

Comment 1 Haim 2012-02-19 12:02:26 UTC
Created attachment 564175 [details]
libvirt logs

attached libvirt log contains starting of new vm with cd attached

Comment 3 Dan Kenigsberg 2012-02-22 08:50:14 UTC
domain was started with

<disk device="cdrom" snapshot="no" type="file">
	<source file="/rhev/data-center/2319b7ff-09f6-488c-83c4-aa78139db3b4/019d4b6f-5450-4eb6-80ee-c63ea062de49/images/11111111-1111-1111-1111-111111111111/en_windows_7_enterprise_x64_dvd_x15-70749.iso" startupPolicy="optional"/>
	<target bus="ide" dev="hdc"/>
	<serial></serial>
</disk>

the source file is accessible on the nfs mount. However, libvirt claims

2012-02-19 11:54:41.779+0000: 22269: debug : qemuDomainCheckDiskPresence:1634 : Dropping disk 'hdc' on domain 'xtream-vm-001' (UUID 'f9ea04b0-1a1e-4793-870f-b3b1f8b6c6e4') due to inaccessible source '/rhev/data-center/2319b7ff-09f6-488c-83c4-aa78139db3b4/019d4b6f-5450-4eb6-80ee-c63ea062de49/images/11111111-1111-1111-1111-111111111111/en_windows_7_enterprise_x64_dvd_x15-70749.iso'

and drops the "file" attribute from the <source> element.

If startupPolicy="optional" is dropped, the domain starts up fine.

libvirt-0.9.9-1.fc16.x86_64

Comment 4 Dan Kenigsberg 2012-02-22 08:58:08 UTC
note also that libvirt's behaviour is inconsistent with the case of starting with an empty cdrom. There, the <source> element is completely dropped from XMLDesc().

Comment 10 Jiri Denemark 2012-02-23 11:26:55 UTC
*** Bug 796637 has been marked as a duplicate of this bug. ***

Comment 13 weizhang 2012-02-29 06:59:46 UTC
Verify pass on
libvirt-0.9.10-3.el6.x86_64
qemu-kvm-0.12.1.2-2.232.el6.x86_64
kernel-2.6.32-225.el6.x86_64

When cdrom image exists, start guest and dump running domain xml
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/cdrom.img' startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>

when cdrom image does not exist, start guest and dump running domain xml
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>

Comment 15 errata-xmlrpc 2012-06-20 06:48:33 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.

http://rhn.redhat.com/errata/RHSA-2012-0748.html