virtio: fixes

virtio feature negotiation rework
 
 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJX3D/+AAoJECgfDbjSjVRpAh0H/0OprEm1SrXWFMTlMwdtnl/0
 b22PEyIzkaXu4eRLotxvAbN9KArc4cVUxx/sZ0t24OjLR9IxzD6Ffukndr0TSAia
 KZM8QAACD4nMVd7ITw0qyv6twO8juTPgB76BddBLJN16kKWkEQr7Ouh++Kl2xguY
 YKSzTT+DQRQxKQzojZVHCinReX75F2KfUgnUlL9SXZfSs8lSSFQpasLELc59iDG0
 lSWyWWJYSfC9DEkivYeigsnrAYVwA9SvbBwGJUlemKafOPwO12gLGezb9JTAvQtQ
 3Lctp0FGPnoc38P+T6B4uuDjqCvRGj1CU2yBeLHZ6nsFnoFAGb0PzfAA6ejmJCY=
 =/97N
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

virtio: fixes

virtio feature negotiation rework

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Fri 16 Sep 2016 19:54:54 BST
# gpg:                using RSA key 0x281F0DB8D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream:
  MAINTAINERS: add virtio-* tests
  virtio-bus: Plug devices after features are negotiated

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

# Conflicts:
#	MAINTAINERS
This commit is contained in:
Peter Maydell 2016-09-19 11:23:20 +01:00
commit 0f2fa73ba0
6 changed files with 69 additions and 28 deletions

View file

@ -1261,6 +1261,16 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f)
return 0;
}
static void virtio_ccw_pre_plugged(DeviceState *d, Error **errp)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
if (dev->max_rev >= 1) {
virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1);
}
}
/* This is called by virtio-bus just after the device is plugged. */
static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
{
@ -1270,6 +1280,10 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
SubchDev *sch = ccw_dev->sch;
int n = virtio_get_num_queues(vdev);
if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
dev->max_rev = 0;
}
if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) {
error_setg(errp, "The number of virtqueues %d "
"exceeds ccw limit %d", n,
@ -1283,25 +1297,11 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
if (dev->max_rev >= 1) {
virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1);
}
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
d->hotplugged, 1);
}
static void virtio_ccw_post_plugged(DeviceState *d, Error **errp)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
if (!virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1)) {
/* A backend didn't support modern virtio. */
dev->max_rev = 0;
}
}
static void virtio_ccw_device_unplugged(DeviceState *d)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
@ -1593,8 +1593,8 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data)
k->load_queue = virtio_ccw_load_queue;
k->save_config = virtio_ccw_save_config;
k->load_config = virtio_ccw_load_config;
k->pre_plugged = virtio_ccw_pre_plugged;
k->device_plugged = virtio_ccw_device_plugged;
k->post_plugged = virtio_ccw_post_plugged;
k->device_unplugged = virtio_ccw_device_unplugged;
k->ioeventfd_started = virtio_ccw_ioeventfd_started;
k->ioeventfd_set_started = virtio_ccw_ioeventfd_set_started;