qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Saanjh Sengupta" <saanjhsengupta@outlook.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: "amir.gonnen@neuroblade.ai" <amir.gonnen@neuroblade.ai>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: Building QEMU as a Shared Library
Date: Tue, 4 Mar 2025 15:50:38 -0800	[thread overview]
Message-ID: <67a10cba-5bb8-4dda-a7c7-c7a3637bb1b3@linaro.org> (raw)
In-Reply-To: <SE1SPRMB0015BDAF043E9103B24B9973CCC82@SE1SPRMB0015.KORP216.PROD.OUTLOOK.COM>

Hi Saanjh,

depending what you are trying to achieve exactly, plugins can provide a 
solution. It's convenient and you can stay on top of QEMU upstream, 
without having to create a downstream fork.

We already have plugins for stopping after a given number of 
instructions, or slow down execution of a VM:

# stop after executing 1'000'000 instructions:
$ ./build/qemu-system-x86_64 -plugin 
./build/contrib/plugins/libstoptrigger,icount=1000000 -d plugin

# execute no more than 1'000'000 instructions per second:
$ ./build/qemu-system-x86_64 -plugin 
./build/contrib/plugins/libips.so,ips=1000000 -d plugin

You can see source code associated (./contrib/plugins/stoptrigger.c and 
./contrib/plugins/ips.c), to implement something similar to what you 
want, but based on time.
Would that satisfy your need?

Regards,
Pierrick

On 3/3/25 21:53, Saanjh Sengupta wrote:
> 
> 
> Hi,
> 
> Thank you so much for your inputs. I was able to create the .so file of 
> QEMU.
> 
> Actually, what we are trying is to understand and explore possibilities 
> of Virtual Time Control in QEMU. In short, what I mean to say is an 
> approach via which I can tell QEMU to emulate for XYZ time when the I 
> give a trigger and then pause the emulation by itself after the XYZ time 
> is completed.
> 
> On that front itself, do you have any inputs/ideas regarding the same?
> 
> 
> Regards
> Saanjh Sengupta
> ------------------------------------------------------------------------
> *From:* Pierrick Bouvier <pierrick.bouvier@linaro.org>
> *Sent:* Tuesday, February 25, 2025 6:29:44 AM
> *To:* Philippe Mathieu-Daudé <philmd@linaro.org>; Paolo Bonzini 
> <pbonzini@redhat.com>; Marc-André Lureau <marcandre.lureau@redhat.com>
> *Cc:* amir.gonnen@neuroblade.ai <amir.gonnen@neuroblade.ai>; qemu- 
> devel@nongnu.org <qemu-devel@nongnu.org>; Saanjh Sengupta 
> <saanjhsengupta@outlook.com>
> *Subject:* Re: Building QEMU as a Shared Library
> Hi Saanjh,
> 
> here is a minimal patch that builds one shared library per target (arch,
> mode) where arch is cpu arch, and mode is system or user, and launch
> system-aarch64 through a simple driver:
> 
> https://github.com/pbo-linaro/qemu/commit/ 
> fbb39cc64f77d4bf1e5e50795c75b62735bf5c5f <https://github.com/pbo-linaro/ 
> qemu/commit/fbb39cc64f77d4bf1e5e50795c75b62735bf5c5f>
> 
> With this, it could be possible to create a driver that can execute any
> existing target. It's a sort of single binary for QEMU, but shared
> objects are mandatory, and duplicates all the QEMU state. So there is no
> real benefit compared to having different processes.
> 
> In more, to be able to do concurrent emulations, there are much more
> problems to be solved. QEMU state is correctly kept per target, but all
> other libraries states are shared. There are various issues if you
> launch two emulations at the same time in two threads:
> - glib global context
> - qemu calls exit in many places, which stops the whole process
> - probably other things I didn't explore
> 
> At this point, even though qemu targets can be built as shared objects,
> I would recommend to use different processes, and implement some form on
> IPC to synchronize all this.
> Another possibility is to try to build machines without using the
> existing main, but I'm not sure it's worth all the hassle.
> 
> What are you trying to achieve?
> 
> Regards,
> Pierrick
> 
> On 2/24/25 01:10, Philippe Mathieu-Daudé wrote:
>> Cc'ing our meson experts
>> 
>> On 22/2/25 14:36, Saanjh Sengupta wrote:
>>> 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
>> 
> 


  reply	other threads:[~2025-03-04 23:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67a10cba-5bb8-4dda-a7c7-c7a3637bb1b3@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=amir.gonnen@neuroblade.ai \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=saanjhsengupta@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).