~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to hw/virtio/virtio-bus.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "qemu/osdep.h"
26
26
#include "hw/hw.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"
31
33
 
32
34
/* #define DEBUG_VIRTIO_BUS */
33
35
 
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;
49
53
 
50
54
    DPRINTF("%s: plug device.\n", qbus->name);
51
55
 
52
56
    if (klass->pre_plugged != NULL) {
53
 
        klass->pre_plugged(qbus->parent, errp);
 
57
        klass->pre_plugged(qbus->parent, &local_err);
 
58
        if (local_err) {
 
59
            error_propagate(errp, local_err);
 
60
            return;
 
61
        }
54
62
    }
55
63
 
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,
59
 
                                            errp);
 
67
                                            &local_err);
 
68
    if (local_err) {
 
69
        error_propagate(errp, local_err);
 
70
        return;
 
71
    }
60
72
 
61
73
    if (klass->device_plugged != NULL) {
62
 
        klass->device_plugged(qbus->parent, errp);
 
74
        klass->device_plugged(qbus->parent, &local_err);
 
75
    }
 
76
    if (local_err) {
 
77
        error_propagate(errp, local_err);
 
78
        return;
 
79
    }
 
80
 
 
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);
 
84
    } else {
 
85
        vdev->dma_as = &address_space_memory;
63
86
    }
64
87
}
65
88