I'm using libvirt+KVM+Qemu on Ubuntu 11.04. I have some scsi devices like this:

<disk type='file' device='disk'>
  <driver name='qemu' type='raw'/>
  <source file='/var/lib/libvirt/images/shared-01-02-00.img'/>
  <target dev='sda' bus='scsi'/>
  <address type='drive' controller='0' bus='0' unit='0'/>
</disk>

The show up in the virtual machine as e.g. /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0

For my management purposes, I would like to be able to assigned an arbitrary 'serial number' to the virtual devices, which would show up when scsi_id is run on the block device from inside the virtual machine. How can I do that?

link|improve this question

52% accept rate
feedback

1 Answer

up vote 1 down vote accepted

Not sure if this will do exactly what you want, but I was looking over the libvirt docs and found this:

serial
  If present, this specify serial number of virtual hard drive. For example, it may look like <serial>WD-WMAP9A966149</serial>.

http://libvirt.org/formatdomain.html#elementsDisks

So the XML block you have above would become:

<disk type='file' device='disk'>
  <driver name='qemu' type='raw'/>
  <source file='/var/lib/libvirt/images/shared-01-02-00.img'/>
  <target dev='sda' bus='scsi'/>
  <address type='drive' controller='0' bus='0' unit='0'/>
  <serial>some-arbitrary-serial</serial>
</disk>
link|improve this answer
Nice: bit of experimentation required, but with this set, I get the ID passed through in the output of scsi_id when I use the "-p 0x80" flag. Thanks, I feel silly for missing this in the docs :-) – kdt Oct 10 '11 at 9:59
Awesome. Glad it worked. Good to know about the "-p 0x80" flag too. – up_the_irons Oct 10 '11 at 21:11
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.