[libvirt] [RFC PATCH] qemu: Shorten SCSI hostdev alias to avoid QEMU failure

Daniel P. Berrange berrange at redhat.com
Mon Jul 22 09:58:46 UTC 2013


On Fri, Jul 12, 2013 at 05:13:56PM +0200, Viktor Mihajlovski wrote:
> The alias for hostdevs of type SCSI can be too long for QEMU if
> larger LUNs are encountered. Here's a real life example:
> 
>     <hostdev mode='subsystem' type='scsi' managed='no'>
>       <source>
>         <adapter name='scsi_host0'/>
>         <address bus='0' target='19' unit='1088634913'/>
>       </source>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </hostdev>
> 
> this results in a too long drive id, resulting in QEMU yelling
> 
> Property 'scsi-generic.drive' can't find value 'drive-hostdev-scsi_host0-0-19-1088634913'
> 
> This commit changes the alias back to the default hostdev$(index)
> scheme.
> 
> Signed-off-by: Viktor Mihajlovski <mihajlov at linux.vnet.ibm.com>
> ---
> 
> Actually this is highlighting a larger issue. Apparently QEMU ids
> are limited to a length of 32 bytes. This means that SCSI based
> drives are also in danger to exceed this limit.
> We should consider to use a drive index for controller-attached
> disks for alias generation instead of the verbose
> drive-$bustype-$busaddress schema.

Urgh that sucks. I had no idea QEMU would impose such an arbitrary
length limitation for something like this.

> 
>  src/qemu/qemu_command.c                            |   10 +---------
>  .../qemuxml2argv-hostdev-scsi-boot.args            |    4 ++--
>  .../qemuxml2argv-hostdev-scsi-lsi.args             |    4 ++--
>  .../qemuxml2argv-hostdev-scsi-readonly.args        |    4 ++--
>  .../qemuxml2argv-hostdev-scsi-virtio-scsi.args     |    4 ++--
>  5 files changed, 9 insertions(+), 17 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 879aed8..8c8bef2 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -818,16 +818,8 @@ qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr hostdev
>          }
>      }
>  
> -    if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
> -        if (virAsprintf(&hostdev->info->alias, "hostdev-%s-%d-%d-%d",
> -                        hostdev->source.subsys.u.scsi.adapter,
> -                        hostdev->source.subsys.u.scsi.bus,
> -                        hostdev->source.subsys.u.scsi.target,
> -                        hostdev->source.subsys.u.scsi.unit) < 0)
> -            return -1;
> -    } else if (virAsprintf(&hostdev->info->alias, "hostdev%d", idx) < 0) {
> +    if (virAsprintf(&hostdev->info->alias, "hostdev%d", idx) < 0)
>          return -1;
> -    }
>  
>      return 0;
>  }

ACK

There's no back compatibility issues, since we store the aliases for running
guests in the state XML. Thus this will only affect newly launched guests

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list