OpenStack Compute (Nova)

get_instance_disk_info uses wrong XML to get disk information

Reported by Alvaro Lopez on 2012-02-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
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.

Alvaro Lopez (aloga) on 2012-02-14
Changed in nova:
assignee: nobody → Alvaro Lopez (aloga)
status: New → In Progress

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) on 2012-02-29
Changed in nova:
milestone: none → essex-4
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-4 → 2012.1
Alvaro Lopez (aloga) on 2013-11-21
tags: added: libvirt xen
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers