[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] scsi bus: introduce hotplug() and hot_unplu
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] scsi bus: introduce hotplug() and hot_unplug() interfaces for SCSI bus |
Date: |
Wed, 20 Jun 2012 15:10:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 |
Am 20.06.2012 08:47, schrieb Cong Meng:
> Add two interfaces hotplug() and hot_unplug() to scsi bus info.
> The embody scsi bus can implement these two interfaces to signal the HBA
> driver
> of guest kernel to add/remove the scsi device in question.
>
> Signed-off-by: Cong Meng <address@hidden>
> Signed-off-by: Sen Wang <address@hidden>
> ---
> hw/scsi-bus.c | 16 +++++++++++++++-
> hw/scsi.h | 2 ++
> 2 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
> index dbdb99c..cc3ec75 100644
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -177,6 +177,10 @@ static int scsi_qdev_init(DeviceState *qdev)
> dev);
> }
>
> + if (bus->info->hotplug) {
> + bus->info->hotplug(bus, dev);
Tab.
> + }
> +
> err:
> return rc;
> }
> @@ -1539,6 +1543,16 @@ static int get_scsi_requests(QEMUFile *f, void *pv,
> size_t size)
> return 0;
> }
>
> +static int scsi_qdev_unplug(DeviceState *qdev)
> +{
> + SCSIDevice *dev = SCSI_DEVICE(qdev);
> + SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
Since the tabs need to be fixed anyway, I would suggest to avoid using
DO_UPCAST() with QOM types:
SCSIBus *bus = SCSI_BUS(qdev->parent_bus);
Also I'd like to raise the question towards Paolo and Anthony whether we
might want to start naming new functions like this one
scsi_device_unplug() to avoid the "qdev"? In this case sticking to
"qdev" provides symmetry so there's good reasons for both approaches.
> +
> + if (bus->info->hot_unplug)
> + bus->info->hot_unplug(bus, dev);
Tab. It seems your editor converts all 8-space indents, please check the
second patch.
Otherwise looks okay from my side.
Andreas
> + return qdev_simple_unplug_cb(qdev);
> +}
> +
> const VMStateInfo vmstate_info_scsi_requests = {
> .name = "scsi-requests",
> .get = get_scsi_requests,
> @@ -1575,7 +1589,7 @@ static void scsi_device_class_init(ObjectClass *klass,
> void *data)
> DeviceClass *k = DEVICE_CLASS(klass);
> k->bus_info = &scsi_bus_info;
> k->init = scsi_qdev_init;
> - k->unplug = qdev_simple_unplug_cb;
> + k->unplug = scsi_qdev_unplug;
> k->exit = scsi_qdev_exit;
> }
>
> diff --git a/hw/scsi.h b/hw/scsi.h
> index 2eb66f7..5768071 100644
> --- a/hw/scsi.h
> +++ b/hw/scsi.h
> @@ -130,6 +130,8 @@ struct SCSIBusInfo {
> void (*transfer_data)(SCSIRequest *req, uint32_t arg);
> void (*complete)(SCSIRequest *req, uint32_t arg, size_t resid);
> void (*cancel)(SCSIRequest *req);
> + void (*hotplug)(SCSIBus *bus, SCSIDevice *dev);
> + void (*hot_unplug)(SCSIBus *bus, SCSIDevice *dev);
> QEMUSGList *(*get_sg_list)(SCSIRequest *req);
>
> void (*save_request)(QEMUFile *f, SCSIRequest *req);
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg