[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 20/24] virtio-pci: proxy for virtio-pmem
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [PATCH v4 20/24] virtio-pci: proxy for virtio-pmem |
Date: |
Wed, 26 Sep 2018 11:42:15 +0200 |
From: Pankaj Gupta <address@hidden>
We need a proxy device for virtio-pmem.
Reviewed-by: David Gibson <address@hidden>
Signed-off-by: Pankaj Gupta <address@hidden>
[ split up patches ]
Signed-off-by: David Hildenbrand <address@hidden>
---
hw/virtio/virtio-pci.c | 41 +++++++++++++++++++++++++++++++++++++++++
hw/virtio/virtio-pci.h | 14 ++++++++++++++
include/hw/pci/pci.h | 1 +
3 files changed, 56 insertions(+)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 3a01fe90f0..dcfcefc1b5 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2521,6 +2521,46 @@ static const TypeInfo virtio_rng_pci_info = {
.class_init = virtio_rng_pci_class_init,
};
+/* virtio-pmem-pci */
+
+static void virtio_pmem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+ VirtIOPMEMPCI *vpmem = VIRTIO_PMEM_PCI(vpci_dev);
+ DeviceState *vdev = DEVICE(&vpmem->vdev);
+
+ qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
+ object_property_set_bool(OBJECT(vdev), true, "realized", errp);
+}
+
+static void virtio_pmem_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->realize = virtio_pmem_pci_realize;
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+ pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_PMEM;
+ pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
+ pcidev_k->class_id = PCI_CLASS_OTHERS;
+}
+
+static void virtio_pmem_pci_instance_init(Object *obj)
+{
+ VirtIOPMEMPCI *dev = VIRTIO_PMEM_PCI(obj);
+
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VIRTIO_PMEM);
+}
+
+static const TypeInfo virtio_pmem_pci_info = {
+ .name = TYPE_VIRTIO_PMEM_PCI,
+ .parent = TYPE_VIRTIO_PCI,
+ .instance_size = sizeof(VirtIOPMEMPCI),
+ .instance_init = virtio_pmem_pci_instance_init,
+ .class_init = virtio_pmem_pci_class_init,
+};
+
/* virtio-input-pci */
static Property virtio_input_pci_properties[] = {
@@ -2714,6 +2754,7 @@ 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);
+ type_register_static(&virtio_pmem_pci_info);
#ifdef CONFIG_VHOST_SCSI
type_register_static(&vhost_scsi_pci_info);
#endif
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index 813082b0d7..fe74fcad3f 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -19,6 +19,7 @@
#include "hw/virtio/virtio-blk.h"
#include "hw/virtio/virtio-net.h"
#include "hw/virtio/virtio-rng.h"
+#include "hw/virtio/virtio-pmem.h"
#include "hw/virtio/virtio-serial.h"
#include "hw/virtio/virtio-scsi.h"
#include "hw/virtio/virtio-balloon.h"
@@ -57,6 +58,7 @@ typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
typedef struct VirtIOGPUPCI VirtIOGPUPCI;
typedef struct VHostVSockPCI VHostVSockPCI;
typedef struct VirtIOCryptoPCI VirtIOCryptoPCI;
+typedef struct VirtIOPMEMPCI VirtIOPMEMPCI;
/* virtio-pci-bus */
@@ -274,6 +276,18 @@ struct VirtIOBlkPCI {
VirtIOBlock vdev;
};
+/*
+ * virtio-pmem-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_PMEM_PCI "virtio-pmem-pci"
+#define VIRTIO_PMEM_PCI(obj) \
+ OBJECT_CHECK(VirtIOPMEMPCI, (obj), TYPE_VIRTIO_PMEM_PCI)
+
+struct VirtIOPMEMPCI {
+ VirtIOPCIProxy parent_obj;
+ VirtIOPMEM vdev;
+};
+
/*
* virtio-balloon-pci: This extends VirtioPCIProxy.
*/
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index e6514bba23..44ae4c95d1 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -85,6 +85,7 @@ extern bool pci_available;
#define PCI_DEVICE_ID_VIRTIO_RNG 0x1005
#define PCI_DEVICE_ID_VIRTIO_9P 0x1009
#define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
+#define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013
#define PCI_VENDOR_ID_REDHAT 0x1b36
#define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
--
2.17.1
- [Qemu-devel] [PATCH v4 10/24] memory-device: factor out get_memory_region() from pc-dimm, (continued)
- [Qemu-devel] [PATCH v4 10/24] memory-device: factor out get_memory_region() from pc-dimm, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 11/24] memory-device: drop get_region_size(), David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 12/24] memory-device: add device class function set_addr(), David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 13/24] memory-device: complete factoring out pre_plug handling, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 14/24] memory-device: complete factoring out plug handling, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 15/24] memory-device: complete factoring out unplug handling, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 16/24] memory-device: trace when pre_assigning/assigning/unassigning addresses, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 17/24] memory-device: add class function get_device_id(), David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 18/24] qdev: hotplug: provide do_unplug handler, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 19/24] virtio-pmem: prototype, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 20/24] virtio-pci: proxy for virtio-pmem,
David Hildenbrand <=
- [Qemu-devel] [PATCH v4 22/24] numa: handle virtio-pmem in NUMA stats, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 21/24] hmp: handle virtio-pmem when printing memory device infos, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 23/24] virtio-pmem: hotplug support functions, David Hildenbrand, 2018/09/26
- [Qemu-devel] [PATCH v4 24/24] pc: support for virtio-pmem, David Hildenbrand, 2018/09/26