[libvirt] A question about scsi controller index

Daniel P. Berrange berrange at redhat.com
Wed Aug 20 08:44:07 UTC 2014


On Wed, Aug 20, 2014 at 02:59:23PM +0800, Wang Rui wrote:
> Hi, all
> 
> I define a VM with a virtio scsi disk and I specify a controller index.
> 
> <disk type='file' device='disk'>
>   <driver name='qemu' type='raw' cache='none' io='native'/>
>   <source file='/mnt/sdb/wangrui/img/sles10_sp3_32_2U-5'/>
>   <target dev='sdb' bus='scsi'/>
>   <address type='drive' controller='10' bus='0' target='0' unit='1'/>
> </disk>
> 
> Controllers 0-10 are created(in virDomainDefAddDiskControllersForType())
> although I have only one scsi disk.
> 
> Are the controllers 0-9 useful for some reason?
> 
> If the user specifies controller='n', it will cost extra time and memory
> for creating controllers from 0 to n-1. It becomes worse if n is a very
> large value (Usually it's the user's wrong configuration). I think if
> controllers from 0 to n-1 are kept for other use , we should better to
> check whether n is meaningless(A very large number is meaningless).
> 
> 
> BTW, I modify this function. Only the specified index controller will be
> created. It seems to work fine.

The controller number is designated as an index into the list of
<controller> elements. So if you specify controller=10, then it
is going to setup a list of 10 <controller> elements. Changing
the code to only setup 1 controller element is just plain wrong,
since the array indexing in the controller list no longer works.

If the user makes a mistake in their config they should just
fix that. Trying to protect against user mistakes like this is
just a waste of time & counterproductive in the long run because
it is affect non-broken configs too.

Regards,
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