block_device_mapping_v2.disk_bus allows invalid values

Bug #1876301 reported by Lee Yarwood
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Lee Yarwood
Stein
In Progress
Medium
Unassigned
Train
Fix Released
Medium
Lee Yarwood
Ussuri
Fix Released
Medium
Unassigned

Bug Description

Description
===========

There is no validation of the provided disk_bus in the API, with libvirt this eventually leads to the driver and hypervisor eventually ignoring the requested disk_bus and defaulting to virtio.

Steps to reproduce
==================

A common mistake for users to make is to request a virtio-scsi disk_bus:

$ nova boot --flavor 2 --block-device id=a37d4630-fbc0-4b8e-91a0-18346f907830,source=image,dest=volume,size=1,bus=virtio-scsi,bootindex=0 --nic net-name=private test

Expected result
===============

This should be rejected as this is not a supported disk_bus, instead scsi should be used.

Actual result
=============

The value is ignored and the instance defaults to a virtio bus.

Environment
===========
1. Exact version of OpenStack you are running. See the following
  list for all releases: http://docs.openstack.org/releases/

   master

2. Which hypervisor did you use?
   (For example: Libvirt + KVM, Libvirt + XEN, Hyper-V, PowerKVM, ...)
   What's the version of that?

   Libvirt + KVM

2. Which storage type did you use?
   (For example: Ceph, LVM, GPFS, ...)
   What's the version of that?

   N/A

3. Which networking type did you use?
   (For example: nova-network, Neutron with OpenVSwitch, ...)

   N/A

Logs & Configs
==============

$ nova boot --flavor 2 --block-device id=a37d4630-fbc0-4b8e-91a0-18346f907830,source=image,dest=volume,size=1,bus=virtio-scsi,bootindex=0 --nic net-name=private test
[..]
$ sudo virsh domblklist 45bee4d4-1092-4829-9d98-d32337eb6caf
 Target Source
-----------------------------------------------------------------------------------------------------------------
 vda /opt/stack/data/nova/mnt/896fb15da6036b68a917322e72ebfe57/volume-f866cbb6-b793-4c89-a7e2-b3e0c6f4c2e7

Tags: libvirt
Lee Yarwood (lyarwood)
Changed in nova:
importance: Undecided → Medium
assignee: nobody → Lee Yarwood (lyarwood)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/724842

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.opendev.org/724842
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5913bd889f9d3dfc8d154415e666c821054c229d
Submitter: Zuul
Branch: master

commit 5913bd889f9d3dfc8d154415e666c821054c229d
Author: Lee Yarwood <email address hidden>
Date: Fri May 1 14:20:04 2020 +0100

    compute: Validate a BDMs disk_bus when provided

    Previously disk_bus values were never validated and could easily end up
    being ignored by the underlying virt driver and hypervisor.

    For example, a common mistake made by users is to request a virtio-scsi
    disk_bus when using the libvirt virt driver. This however isn't a valid
    bus and is ignored, defaulting back to the virtio (virtio-blk) bus.

    This change adds a simple validation in the compute API using the
    potential disk_bus values provided by the DiskBus field class as used
    when validating the hw_*_bus image properties.

    Closes-Bug: #1876301
    Change-Id: I77b28b9cc8f99b159f628f4655d85ff305a71db8

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/744550

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/744552

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/744554

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

Reviewed: https://review.opendev.org/744550
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=fb31ae430a2e4f8869e77e31ea0d6a9478f6aa61
Submitter: Zuul
Branch: stable/ussuri

commit fb31ae430a2e4f8869e77e31ea0d6a9478f6aa61
Author: Lee Yarwood <email address hidden>
Date: Fri May 1 14:20:04 2020 +0100

    compute: Validate a BDMs disk_bus when provided

    Previously disk_bus values were never validated and could easily end up
    being ignored by the underlying virt driver and hypervisor.

    For example, a common mistake made by users is to request a virtio-scsi
    disk_bus when using the libvirt virt driver. This however isn't a valid
    bus and is ignored, defaulting back to the virtio (virtio-blk) bus.

    This change adds a simple validation in the compute API using the
    potential disk_bus values provided by the DiskBus field class as used
    when validating the hw_*_bus image properties.

    Closes-Bug: #1876301
    Change-Id: I77b28b9cc8f99b159f628f4655d85ff305a71db8
    (cherry picked from commit 5913bd889f9d3dfc8d154415e666c821054c229d)

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

Reviewed: https://review.opendev.org/744552
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=bbc562c572f328cc6ffa9cdbff83ae64672fe5b8
Submitter: Zuul
Branch: stable/train

commit bbc562c572f328cc6ffa9cdbff83ae64672fe5b8
Author: Lee Yarwood <email address hidden>
Date: Fri May 1 14:20:04 2020 +0100

    compute: Validate a BDMs disk_bus when provided

    Previously disk_bus values were never validated and could easily end up
    being ignored by the underlying virt driver and hypervisor.

    For example, a common mistake made by users is to request a virtio-scsi
    disk_bus when using the libvirt virt driver. This however isn't a valid
    bus and is ignored, defaulting back to the virtio (virtio-blk) bus.

    This change adds a simple validation in the compute API using the
    potential disk_bus values provided by the DiskBus field class as used
    when validating the hw_*_bus image properties.

    Conflicts:
        nova/tests/unit/compute/test_compute_api.py

    NOTE(lyarwood): Conflict as If9c459a9a0aa752c478949e4240286cbdb146494 is
    not present in stable/train. test_validate_bdm_disk_bus is also updated
    as Ib31ba2cbff0ebb22503172d8801b6e0c3d2aa68a is not present in
    stable/train.

    Closes-Bug: #1876301
    Change-Id: I77b28b9cc8f99b159f628f4655d85ff305a71db8
    (cherry picked from commit 5913bd889f9d3dfc8d154415e666c821054c229d)
    (cherry picked from commit fb31ae430a2e4f8869e77e31ea0d6a9478f6aa61)

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

Change abandoned by "Elod Illes <email address hidden>" on branch: stable/stein
Review: https://review.opendev.org/c/openstack/nova/+/744554
Reason: This branch transitioned to End of Life for this project, open patches needs to be closed to be able to delete the branch.

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.