2 * Vhost vsock PCI Bindings
4 * Copyright 2015 Red Hat, Inc.
7 * Stefan Hajnoczi <stefanha@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or
10 * (at your option) any later version. See the COPYING file in the
11 * top-level directory.
14 #include "qemu/osdep.h"
16 #include "virtio-pci.h"
17 #include "hw/qdev-properties.h"
18 #include "hw/virtio/vhost-vsock.h"
19 #include "qemu/module.h"
21 typedef struct VHostVSockPCI VHostVSockPCI
;
24 * vhost-vsock-pci: This extends VirtioPCIProxy.
26 #define TYPE_VHOST_VSOCK_PCI "vhost-vsock-pci-base"
27 #define VHOST_VSOCK_PCI(obj) \
28 OBJECT_CHECK(VHostVSockPCI, (obj), TYPE_VHOST_VSOCK_PCI)
30 struct VHostVSockPCI
{
31 VirtIOPCIProxy parent_obj
;
37 static Property vhost_vsock_pci_properties
[] = {
38 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy
, nvectors
, 3),
39 DEFINE_PROP_END_OF_LIST(),
42 static void vhost_vsock_pci_realize(VirtIOPCIProxy
*vpci_dev
, Error
**errp
)
44 VHostVSockPCI
*dev
= VHOST_VSOCK_PCI(vpci_dev
);
45 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
47 qdev_set_parent_bus(vdev
, BUS(&vpci_dev
->bus
));
48 object_property_set_bool(OBJECT(vdev
), true, "realized", errp
);
51 static void vhost_vsock_pci_class_init(ObjectClass
*klass
, void *data
)
53 DeviceClass
*dc
= DEVICE_CLASS(klass
);
54 VirtioPCIClass
*k
= VIRTIO_PCI_CLASS(klass
);
55 PCIDeviceClass
*pcidev_k
= PCI_DEVICE_CLASS(klass
);
56 k
->realize
= vhost_vsock_pci_realize
;
57 set_bit(DEVICE_CATEGORY_MISC
, dc
->categories
);
58 device_class_set_props(dc
, vhost_vsock_pci_properties
);
59 pcidev_k
->vendor_id
= PCI_VENDOR_ID_REDHAT_QUMRANET
;
60 pcidev_k
->device_id
= PCI_DEVICE_ID_VIRTIO_VSOCK
;
61 pcidev_k
->revision
= 0x00;
62 pcidev_k
->class_id
= PCI_CLASS_COMMUNICATION_OTHER
;
65 static void vhost_vsock_pci_instance_init(Object
*obj
)
67 VHostVSockPCI
*dev
= VHOST_VSOCK_PCI(obj
);
69 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
73 static const VirtioPCIDeviceTypeInfo vhost_vsock_pci_info
= {
74 .base_name
= TYPE_VHOST_VSOCK_PCI
,
75 .generic_name
= "vhost-vsock-pci",
76 .transitional_name
= "vhost-vsock-pci-transitional",
77 .non_transitional_name
= "vhost-vsock-pci-non-transitional",
78 .instance_size
= sizeof(VHostVSockPCI
),
79 .instance_init
= vhost_vsock_pci_instance_init
,
80 .class_init
= vhost_vsock_pci_class_init
,
83 static void virtio_pci_vhost_register(void)
85 virtio_pci_types_register(&vhost_vsock_pci_info
);
88 type_init(virtio_pci_vhost_register
)