qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christophe de Dinechin <dinechin@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-trivial@nongnu.org, "Michael Tokarev" <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org, "Laurent Vivier" <laurent@vivier.eu>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [PATCH 09/10] spice: Put spice functions in a separate load module
Date: Tue, 30 Jun 2020 14:54:52 +0200	[thread overview]
Message-ID: <lyimf8d883.fsf@redhat.com> (raw)
In-Reply-To: <20200629230009.iojnu2gtalpgedxo@sirius.home.kraxel.org>


On 2020-06-30 at 01:00 CEST, Gerd Hoffmann wrote...
>   Hi,
>
>> > If so the more normal approach would be to have a struct defining
>> > a set of callbacks, that can be registered. Or if there's a natural
>> > fit with QOM, then a QOM interface that can then have a QOM object
>> > impl registered as a singleton.
>>
>> That was my second attempt (after the weak symbols). I cleaned it up a bit
>> and put it here: https://github.com/c3d/qemu/commits/spice-vtable.
>
> I think this is the direction we should take.
>
>> What made me switch to the approach in this series is the following
>> considerations:
>>
>> - A vtable is useful if there can be multiple values for a method, e.g. to
>>   implement inheritance, or if you have multiple instances. This is not the
>>   case here.
>
> Well, we'll have two.  The normal functions.  And the stubs.
>
> The stubs are inline functions right now, in include/ui/qemu-spice.h, in
> the !CONFIG_SPICE section.  We can turn them into normal functions, move
> them to some C file.  Let QemuSpiceOpts function pointers point to the
> stubs initially.  When spice initializes (no matter whenever modular or
> not) it'll set QemuSpiceOpts to the normal implementation.

Good idea. I'll do that in the next round.

>
> That way we'll also remove some spice #ifdefs as part of the spice
> modularization effort.
>
> Things like the "using_spice" variable which don't depend on the spice
> shared libraries can also be moved to the new C file with the spice
> stubs.

OK.

>
> I don't think we need to hide QemuSpiceOpts with inline functions like
> qemu_spice_migrate_info().  I would simply use ...
>
> 	struct QemuSpiceOps {
> 		[ ... ]
> 		int (*migrate_info)(...);
> 		[ ... ]
> 	} qemu_spice;
>
> ... then change the ...
>
> 	qemu_spice_migrate_info(...)
>
> .. callsites into ...
>
> 	qemu_spice.migrate_info(...)
>

OK.

>> - Overloading QOM for that purpose looked more confusing than anything else.
>>   It looked like I was mixing unrelated concepts. Maybe that's just me.
>
> Hmm?  Not sure what you mean.  There is no need for QOM here (and I
> can't see anything like that in your spice-vtable branch either).

I was responding to Daniels's earlier comment:

> Or if there's a natural fit with QOM, then a QOM interface that can then
> have a QOM object impl registered as a singleton.

>
>> - The required change with a vtable ends up being more extensive. Instead of
>>   changing a single line to put an entry point in a DSO, you need to create
>>   the vtable, add functions to it, add a register function, etc. I was
>>   looking for an easier and more scalable way.
>
> IMHO it isn't too much overhead, and I find the code is more readable
> that way.

There is certainly very little overhead in that case, since none of the
functions is performance critical.

>
>> - In particular, with a vtable, you cannot take advantage of the syntactic
>>   trick I used here, which is that foo(x) is a shortcut for (*foo)(x).
>>   So for a vtable, you need to manually write wrappers.
>
> See above, I don't think we need wrappers.

Well, so far that's two for two for the vtable approach. So unless someone
else agrees with my arguments for pointer patching, that will be my next
iteration of that series :-)

>
> take care,
>   Gerd


--
Cheers,
Christophe de Dinechin (IRC c3d)



  reply	other threads:[~2020-06-30 12:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 16:42 [PATCH 00/10] RFC: Move SPICE to a load module Christophe de Dinechin
2020-06-26 16:42 ` [PATCH 01/10] modules: Provide macros making it easier to identify module exports Christophe de Dinechin
2020-06-29 10:13   ` Claudio Fontana
2020-06-30 13:48     ` Christophe de Dinechin
2020-06-30  9:38   ` Michael S. Tsirkin
2020-06-30 13:39     ` Christophe de Dinechin
2020-06-26 16:42 ` [PATCH 02/10] minikconf: Pass variables for modules Christophe de Dinechin
2020-06-26 16:43 ` [PATCH 03/10] spice: Make spice a module configuration Christophe de Dinechin
2020-06-26 16:43 ` [PATCH 04/10] spice: Move all the spice-related code in spice-app.so Christophe de Dinechin
2020-06-26 17:20   ` Daniel P. Berrangé
2020-06-29  9:22     ` Christophe de Dinechin
2020-06-29  9:47       ` Daniel P. Berrangé
2020-06-29 23:37   ` Gerd Hoffmann
2020-06-26 16:43 ` [PATCH 05/10] build: Avoid build failure when building drivers as modules Christophe de Dinechin
2020-06-26 17:23   ` Daniel P. Berrangé
2020-06-29 23:26     ` Gerd Hoffmann
2020-06-26 16:43 ` [PATCH 06/10] trivial: Remove extra trailing whitespace Christophe de Dinechin
2020-06-29  9:56   ` Philippe Mathieu-Daudé
2020-06-26 16:43 ` [PATCH 07/10] qxl - FIXME: Build as module Christophe de Dinechin
2020-06-26 16:43 ` [PATCH 08/10] build: Add SPICE_CFLAGS and SPICE_LIBS to relevant files Christophe de Dinechin
2020-06-26 17:26   ` Daniel P. Berrangé
2020-06-29  9:27     ` Christophe de Dinechin
2020-06-29 23:08   ` Gerd Hoffmann
2020-06-30 13:56     ` Christophe de Dinechin
2020-06-26 16:43 ` [PATCH 09/10] spice: Put spice functions in a separate load module Christophe de Dinechin
2020-06-26 17:35   ` Daniel P. Berrangé
2020-06-29 17:19     ` Christophe de Dinechin
2020-06-29 17:30       ` Daniel P. Berrangé
2020-06-29 23:00       ` Gerd Hoffmann
2020-06-30 12:54         ` Christophe de Dinechin [this message]
2020-06-26 16:43 ` [PATCH 10/10] REMOVE: Instrumentation to show the module functions being replaced Christophe de Dinechin
2020-06-26 17:29   ` Daniel P. Berrangé
2020-06-30 12:48     ` Christophe de Dinechin

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=lyimf8d883.fsf@redhat.com \
    --to=dinechin@redhat.com \
    --cc=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=marcandre.lureau@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=rth@twiddle.net \
    /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).