get_instance_disk_info uses wrong XML to get disk information

Bug #929427 reported by Alvaro Lopez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Alvaro Lopez

Bug Description

Hi there.

In nova/virt/libvirt/connection.py, the get_instance_disk_info method from LibvirtConnection parses the XML returned by virt_dom.XMLDesc. In this XML document, the devices are as follow:

     <devices>
        <disk type='file' device='disk'>
          <driver name='file'/>
          <source file='/srv/nova/instances/instance-00000019/disk'/>
          <target dev='sda' bus='scsi'/>
        </disk>

but the code expects that driver_name has a "type" attribute, containing the type of the driver used (i.e. qcow2, raw). Therefore, if somebody is using raw images instead of cow nova-compute throws an exception, because get_instance_disk_info assumes that the image is qcow and tries to get the backing file (that indeed does not exist for raw images):

    2012-02-09 11:06:51,407 CRITICAL nova [-] list index out of range
    (nova): TRACE: Traceback (most recent call last):
    (nova): TRACE: File "/usr/bin/nova-compute", line 49, in <module>
    (nova): TRACE: service.wait()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/service.py", line 414, in wait
    (nova): TRACE: _launcher.wait()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/service.py", line 134, in wait
    (nova): TRACE: service.wait()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 166, in wait
    (nova): TRACE: return self._exit_event.wait()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/eventlet/event.py", line 116, in wait
    (nova): TRACE: return hubs.get_hub().switch()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 177, in switch
    (nova): TRACE: return self.greenlet.switch()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 192, in main
    (nova): TRACE: result = function(*args, **kwargs)
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/service.py", line 104, in run_server
    (nova): TRACE: server.start()
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/service.py", line 176, in start
    (nova): TRACE: self.manager.update_available_resource(ctxt)
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 2187, in update_available_resour
ce
    (nova): TRACE: self.driver.update_available_resource(context, self.host)
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/virt/libvirt/connection.py", line 1642, in update_availabl
e_resource
    (nova): TRACE: 'disk_available_least': self.get_disk_available_least()}
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/virt/libvirt/connection.py", line 2002, in get_disk_availa
ble_least
    (nova): TRACE: disk_infos = utils.loads(self.get_instance_disk_info(i_name))
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/virt/libvirt/connection.py", line 1976, in get_instance_di
sk_info
    (nova): TRACE: backing_file = libvirt_utils.get_disk_backing_file(path)
    (nova): TRACE: File "/usr/lib/python2.7/dist-packages/nova/virt/libvirt/utils.py", line 106, in get_disk_backing_file
    (nova): TRACE: backing_file = os.path.basename(backing_file[0])
    (nova): TRACE: IndexError: list index out of range

I've tested it using libvirt + Xen and using cow and raw images. I do now know if this is the case for other hypervisors, since I do not know the format of the XML returned by libvirt in such cases, but I assume that this should be the
same.

Tags: libvirt xen
Alvaro Lopez (aloga)
Changed in nova:
assignee: nobody → Alvaro Lopez (aloga)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/4189
Committed: http://github.com/openstack/nova/commit/d1bc92fdbd3aa42b15beeb5eaf2987365247cfa2
Submitter: Jenkins
Branch: master

commit d1bc92fdbd3aa42b15beeb5eaf2987365247cfa2
Author: Alvaro Lopez Garcia <email address hidden>
Date: Wed Feb 15 11:47:28 2012 +0100

    Fix bug 929427

    We ensure that we are getting the info from a QCOW2 image, not anything
    else.

    Change-Id: I8b6bd504da8d52bb9902c917360f0465f9002551

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → essex-4
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: essex-4 → 2012.1
Alvaro Lopez (aloga)
tags: added: libvirt xen
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.