2
0

remote.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Remote PCI host device
  3. *
  4. * Unlike PCI host devices that model physical hardware, the purpose
  5. * of this PCI host is to host multi-process QEMU devices.
  6. *
  7. * Multi-process QEMU extends the PCI host of a QEMU machine into a
  8. * remote process. Any PCI device attached to the remote process is
  9. * visible in the QEMU guest. This allows existing QEMU device models
  10. * to be reused in the remote process.
  11. *
  12. * This PCI host is purely a container for PCI devices. It's fake in the
  13. * sense that the guest never sees this PCI host and has no way of
  14. * accessing it. Its job is just to provide the environment that QEMU
  15. * PCI device models need when running in a remote process.
  16. *
  17. * Copyright © 2018, 2021 Oracle and/or its affiliates.
  18. *
  19. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  20. * See the COPYING file in the top-level directory.
  21. *
  22. */
  23. #include "qemu/osdep.h"
  24. #include "hw/pci/pci.h"
  25. #include "hw/pci/pci_host.h"
  26. #include "hw/pci/pcie_host.h"
  27. #include "hw/qdev-properties.h"
  28. #include "hw/pci-host/remote.h"
  29. #include "exec/memory.h"
  30. static const char *remote_pcihost_root_bus_path(PCIHostState *host_bridge,
  31. PCIBus *rootbus)
  32. {
  33. return "0000:00";
  34. }
  35. static void remote_pcihost_realize(DeviceState *dev, Error **errp)
  36. {
  37. PCIHostState *pci = PCI_HOST_BRIDGE(dev);
  38. RemotePCIHost *s = REMOTE_PCIHOST(dev);
  39. pci->bus = pci_root_bus_new(DEVICE(s), "remote-pci",
  40. s->mr_pci_mem, s->mr_sys_io,
  41. 0, TYPE_PCIE_BUS);
  42. }
  43. static void remote_pcihost_class_init(ObjectClass *klass, void *data)
  44. {
  45. DeviceClass *dc = DEVICE_CLASS(klass);
  46. PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
  47. hc->root_bus_path = remote_pcihost_root_bus_path;
  48. dc->realize = remote_pcihost_realize;
  49. dc->user_creatable = false;
  50. set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  51. dc->fw_name = "pci";
  52. }
  53. static const TypeInfo remote_pcihost_info = {
  54. .name = TYPE_REMOTE_PCIHOST,
  55. .parent = TYPE_PCIE_HOST_BRIDGE,
  56. .instance_size = sizeof(RemotePCIHost),
  57. .class_init = remote_pcihost_class_init,
  58. };
  59. static void remote_pcihost_register(void)
  60. {
  61. type_register_static(&remote_pcihost_info);
  62. }
  63. type_init(remote_pcihost_register)