qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: asias@redhat.com, nab@linux-iscsi.org,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 7/9] vhost-scsi-pci: new device supporting the tcm_vhost Linux kernel module
Date: Fri, 19 Apr 2013 16:24:18 +0200	[thread overview]
Message-ID: <1366381460-6041-8-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1366381460-6041-1-git-send-email-pbonzini@redhat.com>

From: Nicholas Bellinger <nab@linux-iscsi.org>

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Asias He <asias@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/virtio/virtio-pci.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pci.h | 18 +++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index b362cc8..c1e9a60 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1285,6 +1285,63 @@ static const TypeInfo virtio_scsi_pci_info = {
     .class_init    = virtio_scsi_pci_class_init,
 };
 
+/* vhost-scsi-pci */
+
+#ifdef CONFIG_VHOST_SCSI
+static Property vhost_scsi_pci_properties[] = {
+    DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
+                       DEV_NVECTORS_UNSPECIFIED),
+    DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
+    DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSIPCI, vdev.parent_obj.conf),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static int vhost_scsi_pci_init_pci(VirtIOPCIProxy *vpci_dev)
+{
+    VHostSCSIPCI *dev = VHOST_SCSI_PCI(vpci_dev);
+    DeviceState *vdev = DEVICE(&dev->vdev);
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
+
+    if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
+        vpci_dev->nvectors = vs->conf.num_queues + 3;
+    }
+
+    qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
+    if (qdev_init(vdev) < 0) {
+        return -1;
+    }
+    return 0;
+}
+
+static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
+    PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+    k->init = vhost_scsi_pci_init_pci;
+    dc->props = vhost_scsi_pci_properties;
+    pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+    pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_SCSI;
+    pcidev_k->revision = 0x00;
+    pcidev_k->class_id = PCI_CLASS_STORAGE_SCSI;
+}
+
+static void vhost_scsi_pci_instance_init(Object *obj)
+{
+    VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
+    object_initialize(OBJECT(&dev->vdev), TYPE_VHOST_SCSI);
+    object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+}
+
+static const TypeInfo vhost_scsi_pci_info = {
+    .name          = TYPE_VHOST_SCSI_PCI,
+    .parent        = TYPE_VIRTIO_PCI,
+    .instance_size = sizeof(VHostSCSIPCI),
+    .instance_init = vhost_scsi_pci_instance_init,
+    .class_init    = vhost_scsi_pci_class_init,
+};
+#endif
+
 /* virtio-balloon-pci */
 
 static void balloon_pci_stats_get_all(Object *obj, struct Visitor *v,
@@ -1541,6 +1598,9 @@ static void virtio_pci_register_types(void)
     type_register_static(&virtio_balloon_pci_info);
     type_register_static(&virtio_serial_pci_info);
     type_register_static(&virtio_net_pci_info);
+#ifdef CONFIG_VHOST_SCSI
+    type_register_static(&vhost_scsi_pci_info);
+#endif
 }
 
 type_init(virtio_pci_register_types)
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index aa67561..1b66e46 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -24,6 +24,9 @@
 #include "hw/virtio/virtio-balloon.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-9p.h"
+#ifdef CONFIG_VHOST_SCSI
+#include "hw/virtio/vhost-scsi.h"
+#endif
 
 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
@@ -31,6 +34,7 @@ typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
 typedef struct VirtIOSerialPCI VirtIOSerialPCI;
 typedef struct VirtIONetPCI VirtIONetPCI;
+typedef struct VHostSCSIPCI VHostSCSIPCI;
 
 /* virtio-pci-bus */
 
@@ -104,6 +108,20 @@ struct VirtIOSCSIPCI {
     VirtIOSCSI vdev;
 };
 
+#ifdef CONFIG_VHOST_SCSI
+/*
+ * vhost-scsi-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
+#define VHOST_SCSI_PCI(obj) \
+        OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
+
+struct VHostSCSIPCI {
+    VirtIOPCIProxy parent_obj;
+    VHostSCSI vdev;
+};
+#endif
+
 /*
  * virtio-blk-pci: This extends VirtioPCIProxy.
  */
-- 
1.8.1.4

  parent reply	other threads:[~2013-04-19 14:24 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19 14:24 [Qemu-devel] [PULL 0/9] SCSI updates for 2013-04-13 Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 1/9] scsi: avoid assertion failure on VERIFY command Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 2/9] scsi: VMWare PVSCSI paravirtual device implementation Paolo Bonzini
2013-06-21  3:47   ` Libaiqing
2013-06-21  7:36     ` Paolo Bonzini
2013-06-21 11:44       ` Dmitry Fleytman
2013-06-21 12:00         ` Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 3/9] vhost: Add vhost_commit callback for SeaBIOS ROM region re-mapping Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 4/9] virtio-scsi: create VirtIOSCSICommon Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 5/9] virtio: simplify Makefile conditionals Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module Paolo Bonzini
2013-05-28  7:13   ` Wenchao Xia
2013-05-28  8:01     ` Paolo Bonzini
2013-05-28  8:33       ` Asias He
2013-05-28  9:00         ` Wenchao Xia
2013-05-29  9:05           ` Wenchao Xia
2013-05-29  9:27             ` Asias He
2013-05-29 15:10             ` Badari Pulavarty
2013-05-29 22:17               ` Asias He
2013-05-30  4:29                 ` Nicholas A. Bellinger
2013-05-30  5:36                   ` Nicholas A. Bellinger
2013-05-30 18:00                     ` Badari Pulavarty
2013-06-06 22:53                     ` [Qemu-devel] vhost-scsi and pscsi Badari
2013-05-30  2:09               ` [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module Wenchao Xia
2013-06-19 12:55       ` Libaiqing
2013-06-20  1:33         ` Asias He
2013-06-20  3:22           ` Wenchao Xia
2013-06-20  8:49           ` Libaiqing
2013-06-20  9:38             ` Asias He
2013-06-21 10:16               ` Libaiqing
2013-07-03  3:08                 ` Libaiqing
2013-07-03  3:18                   ` Asias He
2013-07-03  3:23                 ` Asias He
2013-07-03  8:08                   ` Asias He
2013-07-03 12:33                     ` Libaiqing
2013-07-04 11:23                       ` Paolo Bonzini
2013-07-08  0:59                         ` Libaiqing
2013-07-04  7:00                     ` Libaiqing
2013-07-05  0:00                       ` Asias He
2013-07-05  6:52                       ` Asias He
2013-07-05 11:17                         ` Vadim Rozenfeld
2013-07-10  1:50                           ` Asias He
2013-04-19 14:24 ` Paolo Bonzini [this message]
2013-04-19 14:24 ` [Qemu-devel] [PATCH 8/9] vhost-scsi-ccw: " Paolo Bonzini
2013-04-19 14:24 ` [Qemu-devel] [PATCH 9/9] vhost-scsi-s390: " Paolo Bonzini
2013-04-23 23:17 ` [Qemu-devel] [PULL 0/9] SCSI updates for 2013-04-13 Nicholas A. Bellinger
2013-04-24  5:59   ` [Qemu-devel] seabios for qemu 1.5 Gerd Hoffmann
2013-04-24  6:11     ` Amos Kong
2013-05-16  4:46       ` Amos Kong
2013-05-27  6:17         ` Gerd Hoffmann
2013-04-30 16:01     ` Paolo Bonzini
2013-04-24  4:56 ` [Qemu-devel] [PULL 0/9] SCSI updates for 2013-04-13 Stefan Weil
2013-04-24  8:19   ` Paolo Bonzini
2013-04-24 16:56     ` Stefan Weil
2013-04-26  8:40       ` Paolo Bonzini
2013-06-17 21:18 ` Anthony Liguori

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=1366381460-6041-8-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=asias@redhat.com \
    --cc=mst@redhat.com \
    --cc=nab@linux-iscsi.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).