2
0

hotplug.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Hotplug handler interface.
  3. *
  4. * Copyright (c) 2014 Red Hat Inc.
  5. *
  6. * Authors:
  7. * Igor Mammedov <imammedo@redhat.com>,
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #include "hw/hotplug.h"
  13. #include "qemu/module.h"
  14. void hotplug_handler_plug(HotplugHandler *plug_handler,
  15. DeviceState *plugged_dev,
  16. Error **errp)
  17. {
  18. HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
  19. if (hdc->plug) {
  20. hdc->plug(plug_handler, plugged_dev, errp);
  21. }
  22. }
  23. void hotplug_handler_unplug(HotplugHandler *plug_handler,
  24. DeviceState *plugged_dev,
  25. Error **errp)
  26. {
  27. HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
  28. if (hdc->unplug) {
  29. hdc->unplug(plug_handler, plugged_dev, errp);
  30. }
  31. }
  32. static const TypeInfo hotplug_handler_info = {
  33. .name = TYPE_HOTPLUG_HANDLER,
  34. .parent = TYPE_INTERFACE,
  35. .class_size = sizeof(HotplugHandlerClass),
  36. };
  37. static void hotplug_handler_register_types(void)
  38. {
  39. type_register_static(&hotplug_handler_info);
  40. }
  41. type_init(hotplug_handler_register_types)