qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Building QEMU as a Shared Library
@ 2025-02-22 13:36 Saanjh Sengupta
  2025-02-24  9:10 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 29+ messages in thread
From: Saanjh Sengupta @ 2025-02-22 13:36 UTC (permalink / raw)
  To: amir.gonnen@neuroblade.ai, qemu-devel@nongnu.org

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

Hi,

I referred to your mailing chains on suggesting QEMU to be built as a shared library.

Change meson.build to build QEMU as a shared library (with PIC enabled for static libraries)

Could you please suggest what exactly has to be enabled in the meson.build?

I am confused on that front.

Regards
Saanjh Sengupta

[-- Attachment #2: Type: text/html, Size: 843 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread
* Building QEMU as a shared library
@ 2021-12-15  8:18 Amir Gonnen
  2021-12-15  9:45 ` Stefan Hajnoczi
  2021-12-15 10:10 ` Peter Maydell
  0 siblings, 2 replies; 29+ messages in thread
From: Amir Gonnen @ 2021-12-15  8:18 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: peter.maydell@linaro.org, stefanha@redhat.com

[-- Attachment #1: Type: text/plain, Size: 2574 bytes --]

Hi,

Before sending a patch, I would like to check if it's of interest to the community.

My goal is to simulate a mixed architecture system.
Today QEMU strongly assumes that the simulated system is a *single architecture*.
Changing this assumption and supporting mixed architecture in QEMU proved to be
non-trivial and may require significant development effort. Common code such as
TCG and others explicitly include architecture specific header files, for example.

A possible solution, discussed on https://stackoverflow.com/q/63229262/619493 is to
separate the simulation to multiple processes (as done by Xilinx) and to use some form
of Interprocess Communication channel between them.
Such solution has several disadvantages:

- Harder to synchronize simulation between processes
- Performance impact of Interprocess Communication
- Harder to debug, profile and maintain

Instead, I would like to suggest a new approach we use at Neuroblade to achieve this:
Build QEMU as a shared library that can be loaded and used directly in a larger simulation.
Today we build qemu-system-nios2 shared library and load it from qemu-system-x86_64 in order
to simulate an x86_64 system that also consists of multiple nios2 cores.
In our simulation, two independent "main" functions are running on different threads, and
simulation synchronization is reduced to synchronizing threads.

To achieve this, I needed to do the following changes in QEMU:

1. Avoid Glib global context. Use a different context (g_main_context_new) for each QEMU instance.
2. Change meson.build to build QEMU as a shared library (with PIC enabled for static libraries)
3. Define a C API for the library and export it (with a -Wl,--version-script)

These changes seem enough for simulating mixed architecture system on a single process.

If this approach sounds useful, I'll be happy to send patches.
I'd appreciate if you could provide your feedback!

Thanks,
Amir


The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited.

[-- Attachment #2: Type: text/html, Size: 5725 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2025-03-18  9:37 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-22 13:36 Building QEMU as a Shared Library Saanjh Sengupta
2025-02-24  9:10 ` Philippe Mathieu-Daudé
2025-02-25  0:59   ` Pierrick Bouvier
2025-03-04  5:53     ` Saanjh Sengupta
2025-03-04 23:50       ` Pierrick Bouvier
2025-03-11  4:56         ` Saanjh Sengupta
2025-03-11  9:50         ` Saanjh Sengupta
2025-03-11 12:48           ` Saanjh Sengupta
2025-03-11 20:44           ` Pierrick Bouvier
2025-03-12  4:31             ` Saanjh Sengupta
2025-03-12  6:20               ` Pierrick Bouvier
2025-03-13 11:34                 ` Saanjh Sengupta
2025-03-13 14:58                   ` Pierrick Bouvier
2025-03-13 18:41                   ` Alex Bennée
2025-03-18  5:40                     ` Saanjh Sengupta
2025-03-18  8:18                       ` Alex Bennée
2025-03-18  8:45                         ` Saanjh Sengupta
2025-03-18  9:36                           ` Alex Bennée
  -- strict thread matches above, loose matches on Subject: below --
2021-12-15  8:18 Building QEMU as a shared library Amir Gonnen
2021-12-15  9:45 ` Stefan Hajnoczi
2021-12-15 10:29   ` Daniel P. Berrangé
2021-12-15 12:18   ` Amir Gonnen
2021-12-15 13:23     ` Stefan Hajnoczi
2021-12-15 13:39       ` Peter Maydell
2021-12-15 10:10 ` Peter Maydell
2021-12-15 10:16   ` Daniel P. Berrangé
2021-12-23  9:49   ` Philippe Mathieu-Daudé
2021-12-26  7:48     ` Stefan Hajnoczi
2022-01-06 10:40     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).