virtio-pci-bus: introduce virtio-pci-bus.
Introduce virtio-pci-bus, which extends virtio-bus. It is used with virtio-pci transport device. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
		
							parent
							
								
									8e05db9234
								
							
						
					
					
						commit
						0a2acf5eb3
					
				@ -31,6 +31,7 @@
 | 
				
			|||||||
#include "sysemu/blockdev.h"
 | 
					#include "sysemu/blockdev.h"
 | 
				
			||||||
#include "virtio-pci.h"
 | 
					#include "virtio-pci.h"
 | 
				
			||||||
#include "qemu/range.h"
 | 
					#include "qemu/range.h"
 | 
				
			||||||
 | 
					#include "virtio-bus.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* from Linux's linux/virtio_pci.h */
 | 
					/* from Linux's linux/virtio_pci.h */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1311,6 +1312,41 @@ static const TypeInfo virtio_scsi_info = {
 | 
				
			|||||||
    .class_init    = virtio_scsi_class_init,
 | 
					    .class_init    = virtio_scsi_class_init,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* virtio-pci-bus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    DeviceState *qdev = DEVICE(dev);
 | 
				
			||||||
 | 
					    BusState *qbus;
 | 
				
			||||||
 | 
					    qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_PCI_BUS, qdev, NULL);
 | 
				
			||||||
 | 
					    qbus = BUS(bus);
 | 
				
			||||||
 | 
					    qbus->allow_hotplug = 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void virtio_pci_bus_class_init(ObjectClass *klass, void *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    BusClass *bus_class = BUS_CLASS(klass);
 | 
				
			||||||
 | 
					    VirtioBusClass *k = VIRTIO_BUS_CLASS(klass);
 | 
				
			||||||
 | 
					    bus_class->max_dev = 1;
 | 
				
			||||||
 | 
					    k->notify = virtio_pci_notify;
 | 
				
			||||||
 | 
					    k->save_config = virtio_pci_save_config;
 | 
				
			||||||
 | 
					    k->load_config = virtio_pci_load_config;
 | 
				
			||||||
 | 
					    k->save_queue = virtio_pci_save_queue;
 | 
				
			||||||
 | 
					    k->load_queue = virtio_pci_load_queue;
 | 
				
			||||||
 | 
					    k->get_features = virtio_pci_get_features;
 | 
				
			||||||
 | 
					    k->query_guest_notifiers = virtio_pci_query_guest_notifiers;
 | 
				
			||||||
 | 
					    k->set_host_notifier = virtio_pci_set_host_notifier;
 | 
				
			||||||
 | 
					    k->set_guest_notifiers = virtio_pci_set_guest_notifiers;
 | 
				
			||||||
 | 
					    k->vmstate_change = virtio_pci_vmstate_change;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const TypeInfo virtio_pci_bus_info = {
 | 
				
			||||||
 | 
					    .name          = TYPE_VIRTIO_PCI_BUS,
 | 
				
			||||||
 | 
					    .parent        = TYPE_VIRTIO_BUS,
 | 
				
			||||||
 | 
					    .instance_size = sizeof(VirtioPCIBusState),
 | 
				
			||||||
 | 
					    .class_init    = virtio_pci_bus_class_init,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void virtio_pci_register_types(void)
 | 
					static void virtio_pci_register_types(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    type_register_static(&virtio_blk_info);
 | 
					    type_register_static(&virtio_blk_info);
 | 
				
			||||||
@ -1319,6 +1355,7 @@ static void virtio_pci_register_types(void)
 | 
				
			|||||||
    type_register_static(&virtio_balloon_info);
 | 
					    type_register_static(&virtio_balloon_info);
 | 
				
			||||||
    type_register_static(&virtio_scsi_info);
 | 
					    type_register_static(&virtio_scsi_info);
 | 
				
			||||||
    type_register_static(&virtio_rng_info);
 | 
					    type_register_static(&virtio_rng_info);
 | 
				
			||||||
 | 
					    type_register_static(&virtio_pci_bus_info);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type_init(virtio_pci_register_types)
 | 
					type_init(virtio_pci_register_types)
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,20 @@
 | 
				
			|||||||
#include "virtio-rng.h"
 | 
					#include "virtio-rng.h"
 | 
				
			||||||
#include "virtio-serial.h"
 | 
					#include "virtio-serial.h"
 | 
				
			||||||
#include "virtio-scsi.h"
 | 
					#include "virtio-scsi.h"
 | 
				
			||||||
 | 
					#include "virtio-bus.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* virtio-pci-bus */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct VirtioBusState VirtioPCIBusState;
 | 
				
			||||||
 | 
					typedef struct VirtioBusClass VirtioPCIBusClass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
 | 
				
			||||||
 | 
					#define VIRTIO_PCI_BUS(obj) \
 | 
				
			||||||
 | 
					        OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
 | 
				
			||||||
 | 
					#define VIRTIO_PCI_BUS_GET_CLASS(obj) \
 | 
				
			||||||
 | 
					        OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
 | 
				
			||||||
 | 
					#define VIRTIO_PCI_BUS_CLASS(klass) \
 | 
				
			||||||
 | 
					        OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Performance improves when virtqueue kick processing is decoupled from the
 | 
					/* Performance improves when virtqueue kick processing is decoupled from the
 | 
				
			||||||
 * vcpu thread using ioeventfd for some devices. */
 | 
					 * vcpu thread using ioeventfd for some devices. */
 | 
				
			||||||
@ -58,6 +72,7 @@ typedef struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
 | 
					void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
 | 
				
			||||||
void virtio_pci_reset(DeviceState *d);
 | 
					void virtio_pci_reset(DeviceState *d);
 | 
				
			||||||
 | 
					void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Virtio ABI version, if we increment this, we break the guest driver. */
 | 
					/* Virtio ABI version, if we increment this, we break the guest driver. */
 | 
				
			||||||
#define VIRTIO_PCI_ABI_VERSION          0
 | 
					#define VIRTIO_PCI_ABI_VERSION          0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user