{"id":21944972,"url":"https://github.com/alexanderschuetz97/ivshmem4j","last_synced_at":"2026-05-17T00:10:59.700Z","repository":{"id":56185752,"uuid":"268626904","full_name":"AlexanderSchuetz97/Ivshmem4j","owner":"AlexanderSchuetz97","description":"Ivshmem4j is a Java library to use QEMU ivshmem (inter virtual machine shared memory) from a Java application running inside a JVM.","archived":false,"fork":false,"pushed_at":"2022-01-24T22:49:55.000Z","size":251,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-03T17:47:10.598Z","etag":null,"topics":["ivshmem","ivshmem-qemu","java","library","qemu-kvm"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexanderSchuetz97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-01T20:36:42.000Z","updated_at":"2023-04-07T05:31:56.000Z","dependencies_parsed_at":"2022-08-15T14:20:15.689Z","dependency_job_id":null,"html_url":"https://github.com/AlexanderSchuetz97/Ivshmem4j","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderSchuetz97%2FIvshmem4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderSchuetz97%2FIvshmem4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderSchuetz97%2FIvshmem4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderSchuetz97%2FIvshmem4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexanderSchuetz97","download_url":"https://codeload.github.com/AlexanderSchuetz97/Ivshmem4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244982059,"owners_count":20542300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ivshmem","ivshmem-qemu","java","library","qemu-kvm"],"created_at":"2024-11-29T04:17:30.868Z","updated_at":"2025-10-07T15:34:37.564Z","avatar_url":"https://github.com/AlexanderSchuetz97.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ivshmem4j Readme\n\nIvshmem4j is a Java library to use QEMU ivshmem (inter virtual machine shared memory) from a Java application running\ninside a JVM.\n\nThe primary purpose of Ivshmem4j is to facilitate fast communication using ivshmem between applications whose JVM's are\nrunning inside different QEMU virtual machines.\n\nIvshmem4j provides full support for msi/software-interrupts offered by ivshmem-doorbell.\n\n## License\n\nIvshmem4j is released under the GNU Lesser General Public License Version 3. \u003cbr\u003eA copy of the GNU Lesser General Public\nLicense Version 3 can be found in the COPYING file.\u003cbr\u003e\n\n## Maven\n\n````\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.alexanderschuetz97\u003c/groupId\u003e\n    \u003cartifactId\u003eivshmem4j\u003c/artifactId\u003e\n    \u003cversion\u003e1.2\u003c/version\u003e\n\u003c/dependency\u003e\n````\n\n## Supported operating systems\n\n##### Host:\n\n* Linux (amd64/i386)\n\n##### Guest:\n\n* Windows (amd64/i386)\n* Linux (amd64/i386)\n\n##### Limitations of Linux guests:\n\nSince there is no stable linux kernel module to interact with the emulated ivshmem pci device and since its is not possible to receive interrupts without one, interrupts are not supported on Linux guests.\n## Runtime dependencies\n##### Windows guest\n* Ivshmem device driver which is contained in the virtio driver\nhttps://fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/\n(Use version 0.1-161 or later)\n\n* Note: The Windows 7 Ivshmem driver seems broken and will always lead to a BSOD. Only Windows 10 was tested. \nOther versions of Windows may or may not work.\n\n##### Linux host\n* ivshmem-plain\n    * No dependencies required.\n* ivshmem-doorbell\n    * Ivshmem-server (one should come bundled with QEMU, but QEMU recommends not using it for production)\n\n##### Linux guest\n* No dependencies required.\n## How to use Ivshmem4j\n##### Linux Host(ivshmem-plain):\n````\n//Create or open a shared memory file at \"/dev/shm/test\" \n//Behavior for file descriptors that are not on tempfs/ramfs is undefined as Ivshmem4j never calls msync.\n//QEMU ivshmem-plain uses either /dev/shm or hubgelbtfs (not supported by Ivshmem4j)\nIvshmemMemory memory = Ivshmem.plain(\"/dev/shm/test\", 64);\n````\n##### Linux Host (ivshmem-doorbell):\n\n````\n//This requires running a ivshmem-server at \"/tmp/test\" which is part of the QEMU Project.\n//ivshmem-server should already be installed on your system if you use it to run a QEMU VM.\n//The second parameter is how long the \nIvshmemMemory tempClient = Ivshmem.doorbell(\"/tmp/test\", 5000);\n````\n##### Linux Guest (ivshmem-plain and \"ivshmem-doorbell\"):\nSee Limitations of Linux guests.\n````\n// Opens the PCI device file descriptor of the device at bus id 0000:00:0e.0.\n// The Bus ID is configured in QEMU at the host and may be retrieved by parsing the output of lspci and looking for\n// Red Hat, Inc. Inter-VM shared memory (rev 01).\n// Example Output line from lspci:\n// 00:0e.0 RAM memory: Red Hat, Inc. Inter-VM shared memory (rev 01)\n// Hint: make sure the JVM process has permissions to this file. By default only root has.\nIvshmemMemory memory = Ivshmem.plain(\"/sys/bus/pci/devices/0000:00:0e.0/resource2_wc\");\n````\n##### Windows (ivshmem-plain and ivshmem-doorbell):\n\n````\n//Enumerates all Windows Ivshmem devices. QEMU supports multiple shared memories per virtual machine.\nCollection\u003cWindowsIvshmemPCIDevice\u003e devices = Ivshmem.windowsListPCI();\n\nIvshmemMemory memory = null;\nfor (WindowsIvshmemPCIDevice device : devices) {\n    //Print the device size (in bytes) and device name. \n    //The Device name contains the PCI Bus ID which can be set in QEMU.\n    System.out.println(device.getSize() + \" \" + device.getName());\n    try {\n        //Try to open the device.\n        memory = Ivshmem.windowsPCI(device);\n        System.out.println(\"Success!\");\n        break;\n    } catch (IvshmemException exc) {\n        //If a device is already in use by another process the call to open will fail.\n        exc.printStackTrace();\n        continue;\n    }\n}\n````\n\n##### Common (Usage of SharedMemory):\n\nSetup:\n\n````\nIvshmemMemory shmem = //See above\nNativeMemory memory = shmem.getMemory();\n````\n\nWriting:\n\n````\n//Set the entire shared memory to 0.\nmemory.set(0, (byte)0, memory.size());\n//Write \"Hello World!\" to the start of the shared memory.\nmemory.write(0, \"Hello World!\".getBytes());\n\n//Close the shared memory\nmemory.close();\n````\nReading:\n````\n//Buffer big enough to fit \"Hello World!\"\nbyte[] buffer = new byte[12];\n//Read the first 12 bytes from the shared memory back into a buffer.\nmemory.read(0, buffer, 0, 12);\n//Should print Hello World!\nSystem.out.println(new String(buffer));\n\n//Close the shared memory\nmemory.close();\n````\nInterrupts (requires ivshmem-doorbell):\n````\n//Register a new interrupt service routine to listen for all incomming interrupts on vector 0.\nshmem.registerInterruptServiceRoutine(0, new InterruptServiceRoutine() {\n    @Override\n    public void onInterrupt(int vector) {\n        System.out.println(\"Interrupt! Vector: \" + vector);\n    }\n});\n\n//Print out my peer id. A peer id identifies and application when using ivshmem-doorbell.\nSystem.out.println(shmem.getOwnPeerID());\n\n//This needs to be communicated, for example by reserving a special address inside\n//the Shared Memory to communicate this. The Linux host ivshmem-doorbell client may call\n//shmem.getPeers(); to enumerate all connected peers. The Windows QEMU PCI driver does not support this.\nint tempOtherPeerID = 1;\n\n//Send interrupt on interrupt vector 0 to peer id.\nshmem.sendInterrupt(1, 0);\n````","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderschuetz97%2Fivshmem4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexanderschuetz97%2Fivshmem4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderschuetz97%2Fivshmem4j/lists"}