From 46fd17054548b15b3b8a5991492f5f0dc37957d4 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Thu, 22 Dec 2016 11:12:38 +0800 Subject: cryptodev: introduce a new is_used property This property is used to Tag the cryptodev backend is used by virtio-crypto or not. Making cryptodev can't be hot unplugged when it's in use. Cleanup resources when cryptodev is finalized. Signed-off-by: Gonglei Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-crypto.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw/virtio/virtio-crypto.c') diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index f872c87cb9..6318fcf01b 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -799,6 +799,7 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp) } virtio_crypto_init_config(vdev); + cryptodev_backend_set_used(vcrypto->cryptodev, true); } static void virtio_crypto_device_unrealize(DeviceState *dev, Error **errp) @@ -818,6 +819,7 @@ static void virtio_crypto_device_unrealize(DeviceState *dev, Error **errp) g_free(vcrypto->vqs); virtio_cleanup(vdev); + cryptodev_backend_set_used(vcrypto->cryptodev, false); } static const VMStateDescription vmstate_virtio_crypto = { -- cgit v1.2.3