提交 d4d76824 编写于 作者: A Anthony Liguori

Merge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging

# By Christian Borntraeger (1) and Cornelia Huck (1)
# Via Cornelia Huck
* cohuck/virtio-ccw-upstr:
  virtio-ccw: Wire up virtio-rng.
  virtio-ccw: remove qdev_unparent in unplug routing
......@@ -642,6 +642,30 @@ static int virtio_ccw_scsi_exit(VirtioCcwDevice *dev)
return virtio_ccw_exit(dev);
}
static int virtio_ccw_rng_init(VirtioCcwDevice *dev)
{
VirtIODevice *vdev;
if (dev->rng.rng == NULL) {
dev->rng.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
object_property_add_child(OBJECT(dev), "default-backend",
OBJECT(dev->rng.default_backend), NULL);
object_property_set_link(OBJECT(dev), OBJECT(dev->rng.default_backend),
"rng", NULL);
}
vdev = virtio_rng_init((DeviceState *)dev, &dev->rng);
if (!vdev) {
return -1;
}
return virtio_ccw_device_init(dev, vdev);
}
static int virtio_ccw_rng_exit(VirtioCcwDevice *dev)
{
virtio_rng_exit(dev->vdev);
return virtio_ccw_exit(dev);
}
/* DeviceState to VirtioCcwDevice. Note: used on datapath,
* be careful and test performance if you change this.
*/
......@@ -831,6 +855,41 @@ static const TypeInfo virtio_ccw_scsi = {
.class_init = virtio_ccw_scsi_class_init,
};
static void virtio_ccw_rng_initfn(Object *obj)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(obj);
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->rng.rng, NULL);
}
static Property virtio_ccw_rng_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
DEFINE_PROP_UINT64("max-bytes", VirtioCcwDevice, rng.max_bytes, INT64_MAX),
DEFINE_PROP_UINT32("period", VirtioCcwDevice, rng.period_ms, 1 << 16),
DEFINE_PROP_END_OF_LIST(),
};
static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->init = virtio_ccw_rng_init;
k->exit = virtio_ccw_rng_exit;
dc->reset = virtio_ccw_reset;
dc->props = virtio_ccw_rng_properties;
}
static const TypeInfo virtio_ccw_rng = {
.name = "virtio-rng-ccw",
.parent = TYPE_VIRTIO_CCW_DEVICE,
.instance_size = sizeof(VirtioCcwDevice),
.instance_init = virtio_ccw_rng_initfn,
.class_init = virtio_ccw_rng_class_init,
};
static int virtio_ccw_busdev_init(DeviceState *dev)
{
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
......@@ -865,7 +924,6 @@ static int virtio_ccw_busdev_unplug(DeviceState *dev)
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, 1, 0);
object_unparent(OBJECT(dev));
qdev_free(dev);
return 0;
}
......@@ -954,6 +1012,7 @@ static void virtio_ccw_register(void)
type_register_static(&virtio_ccw_net);
type_register_static(&virtio_ccw_balloon);
type_register_static(&virtio_ccw_scsi);
type_register_static(&virtio_ccw_rng);
type_register_static(&virtual_css_bridge_info);
}
......
......@@ -16,6 +16,7 @@
#include <hw/virtio-net.h>
#include <hw/virtio-serial.h>
#include <hw/virtio-scsi.h>
#include <hw/virtio-rng.h>
#include <hw/virtio-bus.h>
#define VIRTUAL_CSSID 0xfe
......@@ -77,6 +78,7 @@ struct VirtioCcwDevice {
virtio_serial_conf serial;
virtio_net_conf net;
VirtIOSCSIConf scsi;
VirtIORNGConf rng;
VirtioBusState bus;
/* Guest provided values: */
hwaddr indicators;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册