nova does not correctly support HW_DISK_BUS=sata or usb for kvm/qemu

Bug #1759420 reported by sean mooney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
sean mooney

Bug Description

Description
===========
The hw_disk_bus image metadata key
https://github.com/openstack/glance/blob/master/etc/metadefs/compute-libvirt-image.json#L13-L27
allows users to specify the bus to which guest hard disk images are attched for libvirt instances.

The valid values of hw_disk_bus are ["scsi","virtio","uml","xen","ide","usb","fdc","sata"]

The libvirt driver also defieds the list of valid buses per virt_type
here https://github.com/openstack/nova/blob/ef0ce4d692d28a7f5a0079e24acdbfe7d2767e8b/nova/virt/libvirt/blockinfo.py#L199-L206

   valid_bus = {
        'qemu': ['virtio', 'scsi', 'ide', 'usb', 'fdc', 'sata'],
        'kvm': ['virtio', 'scsi', 'ide', 'usb', 'fdc', 'sata'],
        'xen': ['xen', 'ide'],
        'uml': ['uml'],
        'lxc': ['lxc'],
        'parallels': ['ide', 'scsi']
        }

when setting this key to sata or usb instead of having the disk attached to the requested bus
the disk is attached to the scsi bus instead.

this is because in nova/virt/libvirt/blockinfo.py we map form the disk bus to a prefix
in get_dev_prefix_for_disk_bus
https://github.com/openstack/nova/blob/ef0ce4d692d28a7f5a0079e24acdbfe7d2767e8b/nova/virt/libvirt/blockinfo.py#L124-L143

then later we guess what the correct bus is from the prefix in get_disk_bus_for_disk_dev
https://github.com/openstack/nova/blob/ef0ce4d692d28a7f5a0079e24acdbfe7d2767e8b/nova/virt/libvirt/blockinfo.py#L297-L304

this mapping form disk bus to prefix is lossy as as sata/scsi and usb are all mapped to the sd prefix. so when we guess in get_disk_bus_for_disk_dev for kvm that resutin the incorrect value for images with hw_disk_bus=sata or hw_disk_bus=usb.

Steps to reproduce
==================
run devstack with default setting
source openrc

set hw_disk_bus=sata on image
e.g. openstack image set --property hw_disk_bus=sata my-image

boot a vm with that image
run virsh dumpxml on instance and check the disk bus.

Expected result
===============
instance boots and disk bus used matches hw_disk_bus image metadata value.
e.g. sata

Actual result
=============
instnace boots and disk bus used is scsi

Environment
===========
1. Exact version of OpenStack you are running. See the following
  stable/pike but this is present in master and has been an issue for 5 years
  since https://github.com/openstack/nova/commit/7be531fe9462f2b07d4a1abf6687f649d1dfbb89#diff-2701504299cd384f46791e08f1849defR293
incorrectly called get_disk_bus_for_disk_dev instead of useing the disk_bus varible.

2. Which hypervisor did you use?
   Libvirt + KVM

2. Which storage type did you use?
   default local image backend for nova.

3. Which networking type did you use?
   Neutron with OpenVSwitch.
   not related to this issue.

Tags: libvirt
Revision history for this message
sean mooney (sean-k-mooney) wrote :

it will be a few days before i get a change to work on this but ill try to submit a patch next week.

Changed in nova:
assignee: nobody → sean mooney (sean-k-mooney)
description: updated
melanie witt (melwitt)
tags: added: libvirt
Changed in nova:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/584999

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/587615

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by sean mooney (<email address hidden>) on branch: master
Review: https://review.openstack.org/587615
Reason: squashed this into followup patch.

Revision history for this message
Jay Pipes (jaypipes) wrote :

What are the actual ramifications of the bus being set to 'scsi', Sean? Does that mean the disks are not at all usable by the guest?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/584999
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=1ba150fa5233ebeacdc02e89b2e83a1a6861bc19
Submitter: Zuul
Branch: master

commit 1ba150fa5233ebeacdc02e89b2e83a1a6861bc19
Author: Sean Mooney <email address hidden>
Date: Tue Jul 31 21:22:52 2018 +0100

    libvirt: fix disk_bus handling for root disk

    - The hw_disk_bus image metadata key allows users
      to specify the bus to which guest hard disk
      images are attached for libvirt instances.

    - In commit 7be531fe9462f2b07d4a1abf6687f649d1dfbb89
      the libvirt disk mappings were refactored. As
      part of that change a lossy conversion was introduced
      which resulted in multiple disk buses being mapped
      to the same block device prefix.

    - As a result of this lossy mapping hw_disk_bus=sata
      and hw_disk_bus=usb were mapped to the same prefix
      as scsi "sd". this resulted in the request to use
      sata or usb root disk being ignored.

    - This change fixes handling of the root
      disk device bus selection in libvirt blockinfo.py
      by using the disk bus provided instead of inferring
      it from the block device name.

    - This change adds a new unit test to
      assert the correct handeling
      of the hw_disk_bus image metadata key
      in the libvirt driver.

    Change-Id: I63836f461507f4924dc8f3491ef518a4ce4d32f9
    Closes-Bug: 1759420

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 19.0.0.0rc1

This issue was fixed in the openstack/nova 19.0.0.0rc1 release candidate.

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.