How to create out-of-tree QEMU devices?

匿名 (未验证) 提交于 2019-12-03 02:03:01

问题:

Two possible mechanisms come to mind:

  • IPC like the existing QMP and QAPI
  • QEMU loads a shared library plugin that contains the model

Required capabilities (of course all possible through the C API, but not necessarily IPC APIs):

  • inject interrupts
  • register callbacks for register access
  • modify main memory

Why I want this:

  • use QEMU as a submodule and leave its source untouched
  • additional advantages only present for IPC methods:
    • write the models in any language I want
    • use a non-GPL license for my device

I'm aware of in-tree devices as explained at: How to add a new device in QEMU source code? which are the traditional way of doing things.

What I've found so far:

The closest working piece of code I could find was: https://github.com/texane/vpcie , which serializes PCI on both sides, and sends it through QEMU's TCP API. But this is more inefficient and intrusive, as it requires extra setup on both guest and host.

回答1:

This create out of tree PCI device , it just display device in lspci.. It will ease faster PCI driver implementation as it will act as module, can we extend this to to have similar functionality as edu-pci of QEMU.?

https://github.com/alokprasad/pci-hacking/blob/master/ksrc/virtual_pcinet/virtual_pci.c

/*  */  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include   #define PCI_VENDOR_ID_XTREME        0x15b3 #define PCI_DEVICE_ID_XTREME_VNIC   0x1450  static struct pci_bus *vbus; static struct pci_sysdata *sysdata;  static DEFINE_PCI_DEVICE_TABLE( vpci_dev_table) = {     {PCI_DEVICE(PCI_VENDOR_ID_XTREME, PCI_DEVICE_ID_XTREME_VNIC)},     {0} };  MODULE_DEVICE_TABLE(pci,  vpci_dev_table);  int  vpci_read(struct pci_bus *bus, unsigned int devfn, int where,          int size, u32 *val) {     switch (where) {     case PCI_VENDOR_ID:         *val = PCI_VENDOR_ID_XTREME | PCI_DEVICE_ID_XTREME_VNIC bridge);         pci_remove_bus(vbus);         kfree(sysdata);         vbus = NULL;     } }   static int __init pci_init(void) {     printk( "module loaded");      vpci_bus_init();     return 0; }  static void __exit pci_exit(void) {         printk(KERN_ALERT "unregister PCI Device\n");         pci_unregister_driver(&vpci_vdev_driver); }   module_init(pci_init); module_exit(pci_exit); MODULE_LICENSE("GPL"); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!