Skip to content

Commit

Permalink
virtio-scsi: forward scsibus for virtio-scsi-pci.
Browse files Browse the repository at this point in the history
This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Cc: qemu-stable@nongnu.org
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
konrad-fred authored and mdroth committed Aug 12, 2013
1 parent a678b16 commit 1e3043a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions hw/pci/pci-hotplug.c
Expand Up @@ -30,6 +30,8 @@
#include "monitor/monitor.h"
#include "hw/scsi/scsi.h"
#include "hw/virtio/virtio-blk.h"
#include "hw/virtio/virtio-scsi.h"
#include "hw/virtio/virtio-pci.h"
#include "qemu/config-file.h"
#include "sysemu/blockdev.h"
#include "qapi/error.h"
Expand Down Expand Up @@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
{
SCSIBus *scsibus;
SCSIDevice *scsidev;
VirtIOPCIProxy *virtio_proxy;

scsibus = (SCSIBus *)
object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
TYPE_SCSI_BUS);
if (!scsibus) {
error_report("Device is not a SCSI adapter");
return -1;
/*
* Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
* to the virtio-scsi-device.
*/
if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
error_report("Device is not a SCSI adapter");
return -1;
}
virtio_proxy = VIRTIO_PCI(adapter);
adapter = DEVICE(virtio_proxy->bus.vdev);
scsibus = (SCSIBus *)
object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
TYPE_SCSI_BUS);
assert(scsibus);
}

/*
Expand Down

0 comments on commit 1e3043a

Please sign in to comment.