qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "KONRAD Frédéric" <fred.konrad@greensocs.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
	mark.burton@greensocs.com, qemu-devel@nongnu.org,
	"Paolo Bonzini (supporter:SCSI)" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 04/10] virtio-scsi: add the virtio-scsi device.
Date: Thu, 21 Mar 2013 13:44:19 +0100	[thread overview]
Message-ID: <514B00A3.2030000@greensocs.com> (raw)
In-Reply-To: <20130321131256.366805d3@gondolin>

On 21/03/2013 13:12, Cornelia Huck wrote:
> On Wed, 20 Mar 2013 15:07:37 +0100
> fred.konrad@greensocs.com wrote:
>
>> From: KONRAD Frederic <fred.konrad@greensocs.com>
>>
>> Create virtio-scsi which extends virtio-device, so it can be connected on
>> virtio-bus.
>>
>> Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
>> ---
>>   hw/virtio-scsi.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
>>   hw/virtio-scsi.h |  5 ++++
>>   2 files changed, 85 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
>> index 08fcb80..ca9ceb1 100644
>> --- a/hw/virtio-scsi.c
>> +++ b/hw/virtio-scsi.c
>> @@ -17,6 +17,7 @@
>>   #include "qemu/error-report.h"
>>   #include <hw/scsi.h>
>>   #include <hw/scsi-defs.h>
>> +#include "hw/virtio-bus.h"
>>
>>   #define VIRTIO_SCSI_VQ_SIZE     128
>>   #define VIRTIO_SCSI_CDB_SIZE    32
>> @@ -686,15 +687,30 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = {
>>       .load_request = virtio_scsi_load_request,
>>   };
>>
>> -VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
>> +static VirtIODevice *virtio_scsi_common_init(DeviceState *dev,
>> +                                             VirtIOSCSIConf *proxyconf,
>> +                                             VirtIOSCSI **ps)
>>   {
>> -    VirtIOSCSI *s;
>> +    VirtIOSCSI *s = *ps;
>>       static int virtio_scsi_id;
>>       int i;
>>
>> -    s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI,
>> -                                         sizeof(VirtIOSCSIConfig),
>> -                                         sizeof(VirtIOSCSI));
>> +    /*
>> +     * We have two cases here: the old virtio-net-pci device, and the
>> +     * refactored virtio-net.
> Confusing comment: Neither is this dealing with virtio-net, nor do we
> have only virtio-net-pci :)
oops, sorry for that.. I copied the comment from virtio-net and forgot 
to change the name :).

Note that it is removed in the step 09/10.

Thanks,
Fred
>
>> +     */
>> +
>> +    if (s == NULL) {
>> +        /* virtio-scsi-pci */
>> +        s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI,
>> +                                             sizeof(VirtIOSCSIConfig),
>> +                                             sizeof(VirtIOSCSI));
>> +    } else {
>> +        /* virtio-scsi */
>> +        virtio_init(VIRTIO_DEVICE(s), "virtio-scsi", VIRTIO_ID_SCSI,
>> +                    sizeof(VirtIOSCSIConfig));
>> +    }
>> +
>>       s->cmd_vqs = g_malloc0(proxyconf->num_queues * sizeof(VirtQueue *));
>>
>>       s->qdev = dev;
>> @@ -726,6 +742,12 @@ VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
>>       return &s->vdev;
>>   }
>>
>> +VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
>> +{
>> +    VirtIOSCSI *s = NULL;
>> +    return virtio_scsi_common_init(dev, proxyconf, &s);
>> +}
>> +
>>   void virtio_scsi_exit(VirtIODevice *vdev)
>>   {
>>       VirtIOSCSI *s = (VirtIOSCSI *)vdev;
>> @@ -733,3 +755,56 @@ void virtio_scsi_exit(VirtIODevice *vdev)
>>       g_free(s->cmd_vqs);
>>       virtio_cleanup(vdev);
>>   }
>> +
>> +static int virtio_scsi_device_init(VirtIODevice *vdev)
>> +{
>> +    DeviceState *qdev = DEVICE(vdev);
>> +    VirtIOSCSI *s = VIRTIO_SCSI(vdev);
>> +    if (virtio_scsi_common_init(qdev, &(s->conf), &s) == NULL) {
>> +        return -1;
>> +    }
>> +    return 0;
>> +}
>> +
>> +static int virtio_scsi_device_exit(DeviceState *qdev)
>> +{
>> +    VirtIOSCSI *s = VIRTIO_SCSI(qdev);
>> +    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
>> +
>> +    unregister_savevm(qdev, "virtio-scsi", s);
>> +    g_free(s->cmd_vqs);
>> +    virtio_common_cleanup(vdev);
>> +    return 0;
>> +}
>> +
>> +static Property virtio_scsi_properties[] = {
>> +    DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSI, conf),
>> +    DEFINE_PROP_END_OF_LIST(),
>> +};
>> +
>> +static void virtio_scsi_class_init(ObjectClass *klass, void *data)
>> +{
>> +    DeviceClass *dc = DEVICE_CLASS(klass);
>> +    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
>> +    dc->exit = virtio_scsi_device_exit;
>> +    dc->props = virtio_scsi_properties;
>> +    vdc->init = virtio_scsi_device_init;
>> +    vdc->get_config = virtio_scsi_get_config;
>> +    vdc->set_config = virtio_scsi_set_config;
>> +    vdc->get_features = virtio_scsi_get_features;
>> +    vdc->reset = virtio_scsi_reset;
>> +}
>> +
>> +static const TypeInfo virtio_scsi_info = {
>> +    .name = TYPE_VIRTIO_SCSI,
>> +    .parent = TYPE_VIRTIO_DEVICE,
>> +    .instance_size = sizeof(VirtIOSCSI),
>> +    .class_init = virtio_scsi_class_init,
>> +};
>> +
>> +static void virtio_register_types(void)
>> +{
>> +    type_register_static(&virtio_scsi_info);
>> +}
>> +
>> +type_init(virtio_register_types)
>> diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
>> index 536c4c3..9ff639e 100644
>> --- a/hw/virtio-scsi.h
>> +++ b/hw/virtio-scsi.h
>> @@ -18,6 +18,11 @@
>>   #include "hw/pci/pci.h"
>>   #include "hw/scsi.h"
>>
>> +#define TYPE_VIRTIO_SCSI "virtio-scsi"
>> +#define VIRTIO_SCSI(obj) \
>> +        OBJECT_CHECK(VirtIOSCSI, (obj), TYPE_VIRTIO_SCSI)
>> +
>> +
>>   /* The ID for virtio_scsi */
>>   #define VIRTIO_ID_SCSI  8
>>

  reply	other threads:[~2013-03-21 12:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 14:07 [Qemu-devel] [PATCH v4 00/10] virtio-scsi refactoring fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 01/10] virtio-scsi: don't use pointer for configuration fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 02/10] virtio-scsi: allocate cmd_vqs array separately fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 03/10] virtio-scsi: moving host_features from properties to transport properties fred.konrad
2013-03-21 12:10   ` Cornelia Huck
2013-03-21 12:42     ` KONRAD Frédéric
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 04/10] virtio-scsi: add the virtio-scsi device fred.konrad
2013-03-21 12:12   ` Cornelia Huck
2013-03-21 12:44     ` KONRAD Frédéric [this message]
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 05/10] virtio-scsi-pci: switch to new API fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 06/10] virtio-scsi-s390: switch to the " fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 07/10] virtio-scsi-ccw: switch to " fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 08/10] virtio-scsi: cleanup: use QOM casts fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 09/10] virtio-scsi: cleanup: init and exit functions fred.konrad
2013-03-20 14:07 ` [Qemu-devel] [PATCH v4 10/10] virtio-scsi: cleanup: remove qdev field fred.konrad
2013-03-20 15:54 ` [Qemu-devel] [PATCH v4 00/10] virtio-scsi refactoring Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=514B00A3.2030000@greensocs.com \
    --to=fred.konrad@greensocs.com \
    --cc=aliguori@us.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=mark.burton@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).