diff options
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -323,6 +323,11 @@ int qdev_unplug(DeviceState *dev) } assert(dev->info->unplug != NULL); + if (dev->ref != 0) { + qerror_report(QERR_DEVICE_IN_USE, dev->id?:""); + return -1; + } + qdev_hot_removed = true; return dev->info->unplug(dev); @@ -962,3 +967,14 @@ char* qdev_get_fw_dev_path(DeviceState *dev) return strdup(path); } + +void qdev_ref(DeviceState *dev) +{ + dev->ref++; +} + +void qdev_unref(DeviceState *dev) +{ + g_assert(dev->ref > 0); + dev->ref--; +} |