Patchwork [ANNOUNCE,Call-For-Testing] Release 0.12.0-rc1 of QEMU

login
register
mail settings
Submitter Gerd Hoffmann
Date Dec. 10, 2009, 9:22 a.m.
Message ID <4B20BDD0.5060901@redhat.com>
Download mbox | patch
Permalink /patch/40789/
State New
Headers show

Comments

Gerd Hoffmann - Dec. 10, 2009, 9:22 a.m.
On 12/09/09 17:56, Daniel P. Berrange wrote:
> There's a small bug in SCSI drive hotplug where QEMU is not assigning
> unique block device names when you leave the name unspecified
>
> $ /home/berrange/usr/qemu-0.12/bin/qemu -vnc :1 -monitor stdio -device lsi
> QEMU 0.11.91 monitor - type 'help' for more information
> (qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> OK bus 0, unit 0
> (qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> OK bus 0, unit 1
> (qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> OK bus 0, unit 2
> (qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> OK bus 0, unit 3
> (qemu) info block
> ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
> floppy0: type=floppy removable=1 locked=0 [not inserted]
> sd0: type=floppy removable=1 locked=0 [not inserted]
> scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw encrypted=0
> scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw encrypted=0
> scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw encrypted=0
> scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 drv=raw encrypted=0
> (qemu)
>
> Notice they are all 'scsi0-hd0', instead of scsi0-hd1, scsi0-hd2, etc

Fix attached.

Note that the whole auto-naming only works reliable if you limit 
yourself to a single scsi bus (in any qemu version out there).  I 
strongly recommend to simply name the drives yourself using id=<name>. 
Works in 0.12 and IIRC in 0.11 too.

cheers,
   Gerd
From bd87046b51df2c15e5017e79155045a4e2b7f83b Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Thu, 10 Dec 2009 10:13:59 +0100
Subject: [PATCH] scsi drive hotplug

---
 hw/pci-hotplug.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Daniel P. Berrange - Dec. 10, 2009, 12:16 p.m.
On Thu, Dec 10, 2009 at 10:22:24AM +0100, Gerd Hoffmann wrote:
> On 12/09/09 17:56, Daniel P. Berrange wrote:
> >There's a small bug in SCSI drive hotplug where QEMU is not assigning
> >unique block device names when you leave the name unspecified
> >
> >$ /home/berrange/usr/qemu-0.12/bin/qemu -vnc :1 -monitor stdio -device lsi
> >QEMU 0.11.91 monitor - type 'help' for more information
> >(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> >OK bus 0, unit 0
> >(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> >OK bus 0, unit 1
> >(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> >OK bus 0, unit 2
> >(qemu) drive_add 0:0:4  file=/home/berrange/mcdboot.img,if=scsi
> >OK bus 0, unit 3
> >(qemu) info block
> >ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
> >floppy0: type=floppy removable=1 locked=0 [not inserted]
> >sd0: type=floppy removable=1 locked=0 [not inserted]
> >scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 
> >drv=raw encrypted=0
> >scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 
> >drv=raw encrypted=0
> >scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 
> >drv=raw encrypted=0
> >scsi0-hd0: type=hd removable=0 file=/home/berrange/mcdboot.img ro=1 
> >drv=raw encrypted=0
> >(qemu)
> >
> >Notice they are all 'scsi0-hd0', instead of scsi0-hd1, scsi0-hd2, etc
> 
> Fix attached.
> 
> Note that the whole auto-naming only works reliable if you limit 
> yourself to a single scsi bus (in any qemu version out there).  I 
> strongly recommend to simply name the drives yourself using id=<name>. 
> Works in 0.12 and IIRC in 0.11 too.

Yes we are going to start explicitly naming all the QEMU devices
that libvirt creates. I just want this fix for existing released
libvirt which doesn't name devices.


Regards,
Daniel

Patch

diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 7e5c51d..9e8e6ed 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -93,6 +93,7 @@  static int scsi_hot_add(DeviceState *adapter, DriveInfo *dinfo, int printinfo)
      */
     dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);
     scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo, dinfo->unit);
+    dinfo->unit = scsidev->id;
 
     if (printinfo)
         qemu_error("OK bus %d, unit %d\n", scsibus->busnr, scsidev->id);