← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1561246] [NEW] user cannot choose disk bus when attaching volume to instance

 

Public bug reported:

After https://review.openstack.org/#/c/189632/, since the device name
specified by the user is ignored when attaching volumes to a VM, the
user now has no way to configure the disk bus that the volume is
attached to.

Before the change, if user specifies device name like "/dev/hda" then it
will be attached with ide driver, or "/dev/vda" with virtio driver (for
KVM).

Now, the device name is ignored. Instead, the disk bus is determined
first based on the image metadata of the VM instance, and then based on
the device type (e.g. "virtio" for a KVM disk). Note that the former is
based on the VM image metadata, not the volume image metadata. So, if
the VM is booted from an image that uses ide disk bus, then the volume
will also be attached with ide disk bus instead of virtio. If it is
based on the volume image metadata or volume metadata instead, then that
would solve the bug.

We added a temporary hack to mitigate the issue, so that the device name
is not completely ignored:

--- novaa/virt/libvirt/driver.py	2016-03-23 18:40:52.000000000 -0400
+++ novab/virt/libvirt/driver.py	2016-03-23 18:41:40.800635279 -0400
@@ -7278,7 +7278,14 @@

         # NOTE(ndipanov): get_info_from_bdm will generate the new device name
         #                 only when it's actually not set on the bd object
-        block_device_obj.device_name = None
+        if block_device_obj.device_name is not None:
+            if len(block_device_obj.device_name) >= 6 and block_device_obj.device_name[0:5] == '/dev/' and block_device_obj.get('disk_bus') is None:
+                if block_device_obj.device_name[5] == 'v':
+                    block_device_obj.disk_bus = 'virtio'
+                elif block_device_obj.device_name[5] == 'h':
+                    block_device_obj.disk_bus = 'ide'
+            block_device_obj.device_name = None
+
         disk_info = blockinfo.get_info_from_bdm(
             instance, CONF.libvirt.virt_type, image_meta,
             block_device_obj, mapping=instance_info['mapping'])

** Affects: nova
     Importance: Undecided
         Status: New

** Description changed:

  After https://review.openstack.org/#/c/189632/, since the device name
  specified by the user is ignored when attaching volumes to a VM, the
  user now has no way to configure the disk bus that the volume is
  attached to.
  
  Before the change, if user specifies device name like "/dev/hda" then it
  will be attached with ide driver, or "/dev/vda" with virtio driver (for
  KVM).
  
  Now, the device name is ignored. Instead, the disk bus is determined
  first based on the image metadata of the VM instance, and then based on
  the device type (e.g. "virtio" for a KVM disk). Note that the former is
  based on the VM image metadata, not the volume image metadata. So, if
  the VM is booted from an image that uses ide disk bus, then the volume
  will also be attached with ide disk bus instead of virtio. If it is
  based on the volume image metadata or volume metadata instead, then that
  would solve the bug.
  
  We added a temporary hack to mitigate the issue, so that the device name
  is not completely ignored:
  
  --- novaa/virt/libvirt/driver.py	2016-03-23 18:40:52.000000000 -0400
  +++ novab/virt/libvirt/driver.py	2016-03-23 18:41:40.800635279 -0400
  @@ -7278,7 +7278,14 @@
-  
-          # NOTE(ndipanov): get_info_from_bdm will generate the new device name
-          #                 only when it's actually not set on the bd object
+ 
+          # NOTE(ndipanov): get_info_from_bdm will generate the new device name
+          #                 only when it's actually not set on the bd object
  -        block_device_obj.device_name = None
- +        if block_device_obj.device_name is not None:
+ +        if block_device_obj.get('device_name') is not None:
  +            if len(block_device_obj.device_name) >= 6 and block_device_obj.device_name[0:5] == '/dev/' and block_device_obj.get('disk_bus') is None:
  +                if block_device_obj.device_name[5] == 'v':
  +                    block_device_obj.disk_bus = 'virtio'
  +                elif block_device_obj.device_name[5] == 'h':
  +                    block_device_obj.disk_bus = 'ide'
  +            block_device_obj.device_name = None
  +
-          disk_info = blockinfo.get_info_from_bdm(
-              instance, CONF.libvirt.virt_type, image_meta,
-              block_device_obj, mapping=instance_info['mapping'])
+          disk_info = blockinfo.get_info_from_bdm(
+              instance, CONF.libvirt.virt_type, image_meta,
+              block_device_obj, mapping=instance_info['mapping'])

** Description changed:

  After https://review.openstack.org/#/c/189632/, since the device name
  specified by the user is ignored when attaching volumes to a VM, the
  user now has no way to configure the disk bus that the volume is
  attached to.
  
  Before the change, if user specifies device name like "/dev/hda" then it
  will be attached with ide driver, or "/dev/vda" with virtio driver (for
  KVM).
  
  Now, the device name is ignored. Instead, the disk bus is determined
  first based on the image metadata of the VM instance, and then based on
  the device type (e.g. "virtio" for a KVM disk). Note that the former is
  based on the VM image metadata, not the volume image metadata. So, if
  the VM is booted from an image that uses ide disk bus, then the volume
  will also be attached with ide disk bus instead of virtio. If it is
  based on the volume image metadata or volume metadata instead, then that
  would solve the bug.
  
  We added a temporary hack to mitigate the issue, so that the device name
  is not completely ignored:
  
  --- novaa/virt/libvirt/driver.py	2016-03-23 18:40:52.000000000 -0400
  +++ novab/virt/libvirt/driver.py	2016-03-23 18:41:40.800635279 -0400
  @@ -7278,7 +7278,14 @@
  
           # NOTE(ndipanov): get_info_from_bdm will generate the new device name
           #                 only when it's actually not set on the bd object
  -        block_device_obj.device_name = None
- +        if block_device_obj.get('device_name') is not None:
+ +        if block_device_obj.device_name is not None:
  +            if len(block_device_obj.device_name) >= 6 and block_device_obj.device_name[0:5] == '/dev/' and block_device_obj.get('disk_bus') is None:
  +                if block_device_obj.device_name[5] == 'v':
  +                    block_device_obj.disk_bus = 'virtio'
  +                elif block_device_obj.device_name[5] == 'h':
  +                    block_device_obj.disk_bus = 'ide'
  +            block_device_obj.device_name = None
  +
           disk_info = blockinfo.get_info_from_bdm(
               instance, CONF.libvirt.virt_type, image_meta,
               block_device_obj, mapping=instance_info['mapping'])

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1561246

Title:
  user cannot choose disk bus when attaching volume to instance

Status in OpenStack Compute (nova):
  New

Bug description:
  After https://review.openstack.org/#/c/189632/, since the device name
  specified by the user is ignored when attaching volumes to a VM, the
  user now has no way to configure the disk bus that the volume is
  attached to.

  Before the change, if user specifies device name like "/dev/hda" then
  it will be attached with ide driver, or "/dev/vda" with virtio driver
  (for KVM).

  Now, the device name is ignored. Instead, the disk bus is determined
  first based on the image metadata of the VM instance, and then based
  on the device type (e.g. "virtio" for a KVM disk). Note that the
  former is based on the VM image metadata, not the volume image
  metadata. So, if the VM is booted from an image that uses ide disk
  bus, then the volume will also be attached with ide disk bus instead
  of virtio. If it is based on the volume image metadata or volume
  metadata instead, then that would solve the bug.

  We added a temporary hack to mitigate the issue, so that the device
  name is not completely ignored:

  --- novaa/virt/libvirt/driver.py	2016-03-23 18:40:52.000000000 -0400
  +++ novab/virt/libvirt/driver.py	2016-03-23 18:41:40.800635279 -0400
  @@ -7278,7 +7278,14 @@

           # NOTE(ndipanov): get_info_from_bdm will generate the new device name
           #                 only when it's actually not set on the bd object
  -        block_device_obj.device_name = None
  +        if block_device_obj.device_name is not None:
  +            if len(block_device_obj.device_name) >= 6 and block_device_obj.device_name[0:5] == '/dev/' and block_device_obj.get('disk_bus') is None:
  +                if block_device_obj.device_name[5] == 'v':
  +                    block_device_obj.disk_bus = 'virtio'
  +                elif block_device_obj.device_name[5] == 'h':
  +                    block_device_obj.disk_bus = 'ide'
  +            block_device_obj.device_name = None
  +
           disk_info = blockinfo.get_info_from_bdm(
               instance, CONF.libvirt.virt_type, image_meta,
               block_device_obj, mapping=instance_info['mapping'])

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1561246/+subscriptions


Follow ups