mirror of https://github.com/xemu-project/xemu.git
virtio-9p-pci: switch to the new API.
Here the virtio-9p-pci is modified for the new API. The device virtio-9p-pci extends virtio-pci. It creates and connects a virtio-9p-device during the init. The properties are not changed. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366708123-19626-3-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
e7303c4303
commit
234a336f9e
|
@ -12,7 +12,6 @@
|
||||||
#include "qemu/thread.h"
|
#include "qemu/thread.h"
|
||||||
#include "block/coroutine.h"
|
#include "block/coroutine.h"
|
||||||
|
|
||||||
|
|
||||||
/* The feature bitmap for virtio 9P */
|
/* The feature bitmap for virtio 9P */
|
||||||
/* The mount point is specified in a config variable */
|
/* The mount point is specified in a config variable */
|
||||||
#define VIRTIO_9P_MOUNT_TAG 0
|
#define VIRTIO_9P_MOUNT_TAG 0
|
||||||
|
|
|
@ -1023,48 +1023,56 @@ static const TypeInfo virtio_rng_info = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_VIRTFS
|
#ifdef CONFIG_VIRTFS
|
||||||
static int virtio_9p_init_pci(PCIDevice *pci_dev)
|
static int virtio_9p_init_pci(VirtIOPCIProxy *vpci_dev)
|
||||||
{
|
{
|
||||||
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
|
V9fsPCIState *dev = VIRTIO_9P_PCI(vpci_dev);
|
||||||
VirtIODevice *vdev;
|
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||||
|
|
||||||
vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
|
qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
|
||||||
vdev->nvectors = proxy->nvectors;
|
if (qdev_init(vdev) < 0) {
|
||||||
virtio_init_pci(proxy, vdev);
|
return -1;
|
||||||
/* make the actual value visible */
|
}
|
||||||
proxy->nvectors = vdev->nvectors;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Property virtio_9p_properties[] = {
|
static Property virtio_9p_pci_properties[] = {
|
||||||
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
|
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
|
||||||
|
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
|
||||||
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
|
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
|
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
|
||||||
DEFINE_VIRTIO_9P_PROPERTIES(VirtIOPCIProxy, fsconf),
|
DEFINE_VIRTIO_9P_PROPERTIES(V9fsPCIState, vdev.fsconf),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static void virtio_9p_class_init(ObjectClass *klass, void *data)
|
static void virtio_9p_pci_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
|
||||||
|
VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
|
||||||
|
|
||||||
k->init = virtio_9p_init_pci;
|
k->init = virtio_9p_init_pci;
|
||||||
k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
|
pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
|
||||||
k->device_id = PCI_DEVICE_ID_VIRTIO_9P;
|
pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_9P;
|
||||||
k->revision = VIRTIO_PCI_ABI_VERSION;
|
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
|
||||||
k->class_id = 0x2;
|
pcidev_k->class_id = 0x2;
|
||||||
dc->props = virtio_9p_properties;
|
dc->props = virtio_9p_pci_properties;
|
||||||
dc->reset = virtio_pci_reset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo virtio_9p_info = {
|
static void virtio_9p_pci_instance_init(Object *obj)
|
||||||
.name = "virtio-9p-pci",
|
{
|
||||||
.parent = TYPE_PCI_DEVICE,
|
V9fsPCIState *dev = VIRTIO_9P_PCI(obj);
|
||||||
.instance_size = sizeof(VirtIOPCIProxy),
|
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_9P);
|
||||||
.class_init = virtio_9p_class_init,
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const TypeInfo virtio_9p_pci_info = {
|
||||||
|
.name = TYPE_VIRTIO_9P_PCI,
|
||||||
|
.parent = TYPE_VIRTIO_PCI,
|
||||||
|
.instance_size = sizeof(V9fsPCIState),
|
||||||
|
.instance_init = virtio_9p_pci_instance_init,
|
||||||
|
.class_init = virtio_9p_pci_class_init,
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* CONFIG_VIRTFS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
|
* virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
|
||||||
|
@ -1590,7 +1598,7 @@ static void virtio_pci_register_types(void)
|
||||||
type_register_static(&virtio_pci_bus_info);
|
type_register_static(&virtio_pci_bus_info);
|
||||||
type_register_static(&virtio_pci_info);
|
type_register_static(&virtio_pci_info);
|
||||||
#ifdef CONFIG_VIRTFS
|
#ifdef CONFIG_VIRTFS
|
||||||
type_register_static(&virtio_9p_info);
|
type_register_static(&virtio_9p_pci_info);
|
||||||
#endif
|
#endif
|
||||||
type_register_static(&virtio_blk_pci_info);
|
type_register_static(&virtio_blk_pci_info);
|
||||||
type_register_static(&virtio_scsi_pci_info);
|
type_register_static(&virtio_scsi_pci_info);
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include "hw/virtio/virtio-balloon.h"
|
#include "hw/virtio/virtio-balloon.h"
|
||||||
#include "hw/virtio/virtio-bus.h"
|
#include "hw/virtio/virtio-bus.h"
|
||||||
#include "hw/virtio/virtio-9p.h"
|
#include "hw/virtio/virtio-9p.h"
|
||||||
|
#ifdef CONFIG_VIRTFS
|
||||||
|
#include "hw/9pfs/virtio-9p.h"
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_VHOST_SCSI
|
#ifdef CONFIG_VHOST_SCSI
|
||||||
#include "hw/virtio/vhost-scsi.h"
|
#include "hw/virtio/vhost-scsi.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,9 +87,6 @@ struct VirtIOPCIProxy {
|
||||||
uint32_t class_code;
|
uint32_t class_code;
|
||||||
uint32_t nvectors;
|
uint32_t nvectors;
|
||||||
uint32_t host_features;
|
uint32_t host_features;
|
||||||
#ifdef CONFIG_VIRTFS
|
|
||||||
V9fsConf fsconf;
|
|
||||||
#endif
|
|
||||||
VirtIORNGConf rng;
|
VirtIORNGConf rng;
|
||||||
bool ioeventfd_disabled;
|
bool ioeventfd_disabled;
|
||||||
bool ioeventfd_started;
|
bool ioeventfd_started;
|
||||||
|
@ -171,6 +171,23 @@ struct VirtIONetPCI {
|
||||||
VirtIONet vdev;
|
VirtIONet vdev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* virtio-9p-pci: This extends VirtioPCIProxy.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_VIRTFS
|
||||||
|
|
||||||
|
#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
|
||||||
|
#define VIRTIO_9P_PCI(obj) \
|
||||||
|
OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
|
||||||
|
|
||||||
|
typedef struct V9fsPCIState {
|
||||||
|
VirtIOPCIProxy parent_obj;
|
||||||
|
V9fsState vdev;
|
||||||
|
} V9fsPCIState;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
|
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
|
||||||
void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
|
void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue