25
25
#include "qemu/osdep.h"
27
27
#include "qemu/error-report.h"
28
#include "qapi/error.h"
28
29
#include "hw/qdev.h"
29
30
#include "hw/virtio/virtio-bus.h"
30
31
#include "hw/virtio/virtio.h"
32
#include "exec/address-spaces.h"
32
34
/* #define DEBUG_VIRTIO_BUS */
46
48
VirtioBusState *bus = VIRTIO_BUS(qbus);
47
49
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
48
50
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
51
bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
52
Error *local_err = NULL;
50
54
DPRINTF("%s: plug device.\n", qbus->name);
52
56
if (klass->pre_plugged != NULL) {
53
klass->pre_plugged(qbus->parent, errp);
57
klass->pre_plugged(qbus->parent, &local_err);
59
error_propagate(errp, local_err);
56
64
/* Get the features of the plugged device. */
57
65
assert(vdc->get_features != NULL);
58
66
vdev->host_features = vdc->get_features(vdev, vdev->host_features,
69
error_propagate(errp, local_err);
61
73
if (klass->device_plugged != NULL) {
62
klass->device_plugged(qbus->parent, errp);
74
klass->device_plugged(qbus->parent, &local_err);
77
error_propagate(errp, local_err);
81
if (klass->get_dma_as != NULL && has_iommu) {
82
virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM);
83
vdev->dma_as = klass->get_dma_as(qbus->parent);
85
vdev->dma_as = &address_space_memory;