qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Mikhail Tyutin" <m.tyutin@yadro.com>,
	"Aleksandr Anenkov" <a.anenkov@yadro.com>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>
Subject: Re: [PATCH v9 23/23] plugins: Support C++
Date: Wed, 11 Oct 2023 09:51:12 +0100	[thread overview]
Message-ID: <ZSZiAHtXGOZnZNas@redhat.com> (raw)
In-Reply-To: <20231011070335.14398-24-akihiko.odaki@daynix.com>

On Wed, Oct 11, 2023 at 04:03:09PM +0900, Akihiko Odaki wrote:
> Make qemu-plugin.h consumable for C++ platform.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>  docs/devel/tcg-plugins.rst |  4 ++++
>  meson.build                |  2 +-
>  include/qemu/qemu-plugin.h |  4 ++++
>  tests/plugin/cc.cc         | 16 ++++++++++++++++
>  tests/plugin/meson.build   |  5 +++++
>  tests/tcg/Makefile.target  |  3 +--
>  6 files changed, 31 insertions(+), 3 deletions(-)
>  create mode 100644 tests/plugin/cc.cc
> 
> diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst
> index c9f8b27590..984d8012e9 100644
> --- a/docs/devel/tcg-plugins.rst
> +++ b/docs/devel/tcg-plugins.rst
> @@ -283,6 +283,10 @@ run::
>    160          1      0
>    135          1      0
>  
> +- contrib/plugins/cc.cc
> +
> +A pure test plugin to ensure that the plugin API is compatible with C++.
> +

IMHO we don't need to be adding a test just to prove the
existance of the G_BEGIN_DECLS/G_END_DECLS macros in the
plugin header.

>  - contrib/plugins/hotblocks.c
>  
>  The hotblocks plugin allows you to examine the where hot paths of
> diff --git a/meson.build b/meson.build
> index 9f4c4f2f1e..c289bb8948 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -20,7 +20,7 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
>  
>  cc = meson.get_compiler('c')
>  all_languages = ['c']
> -if targetos == 'windows' and add_languages('cpp', required: false, native: false)
> +if add_languages('cpp', required: false, native: false)
>    all_languages += ['cpp']
>    cxx = meson.get_compiler('cpp')
>  endif

Our goal has been to entirely eliminate C++ from our build system,
even the Windows piece will ideally go away eventually. So I'm
loathe to see us expand where we use C++ again, even if only for
a unit test.

> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
> index 40aae8db68..55f514ca6c 100644
> --- a/include/qemu/qemu-plugin.h
> +++ b/include/qemu/qemu-plugin.h
> @@ -16,6 +16,8 @@
>  #include <stdbool.h>
>  #include <stddef.h>
>  
> +G_BEGIN_DECLS
> +
>  /*
>   * For best performance, build the plugin with -fvisibility=hidden so that
>   * QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with
> @@ -710,4 +712,6 @@ int qemu_plugin_find_register(unsigned int vcpu_index, int file,
>   */
>  int qemu_plugin_read_register(GByteArray *buf, int reg);
>  
> +G_END_DECLS
> +
>  #endif /* QEMU_QEMU_PLUGIN_H */
> diff --git a/tests/plugin/cc.cc b/tests/plugin/cc.cc
> new file mode 100644
> index 0000000000..297a7e4f3f
> --- /dev/null
> +++ b/tests/plugin/cc.cc
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#include <qemu-plugin.h>
> +
> +extern "C" {
> +
> +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
> +
> +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
> +                                           const qemu_info_t *info, int argc,
> +                                           char **argv)
> +{
> +    return 0;
> +}
> +
> +};
> diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build
> index 322cafcdf6..fed14aa0c2 100644
> --- a/tests/plugin/meson.build
> +++ b/tests/plugin/meson.build
> @@ -5,6 +5,11 @@ if get_option('plugins')
>                         include_directories: '../../include/qemu',
>                         dependencies: glib)
>    endforeach
> +  if 'cpp' in all_languages
> +    t += shared_module('cc', files('cc.cc'),
> +                       include_directories: '../../include/qemu',
> +                       dependencies: glib)
> +  endif
>  endif
>  if t.length() > 0
>    alias_target('test-plugins', t)
> diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
> index 462289f47c..66a20d0f2c 100644
> --- a/tests/tcg/Makefile.target
> +++ b/tests/tcg/Makefile.target
> @@ -145,10 +145,9 @@ RUN_TESTS=$(patsubst %,run-%, $(TESTS))
>  
>  # If plugins exist also include those in the tests
>  ifeq ($(CONFIG_PLUGIN),y)
> -PLUGIN_SRC=$(SRC_PATH)/tests/plugin
>  PLUGIN_LIB=../../plugin
>  VPATH+=$(PLUGIN_LIB)
> -PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))
> +PLUGINS=$(notdir $(wildcard $(PLUGIN_LIB)/*.so))
>  
>  # We need to ensure expand the run-plugin-TEST-with-PLUGIN
>  # pre-requistes manually here as we can't use stems to handle it. We
> -- 
> 2.42.0
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2023-10-11  8:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  7:02 [PATCH v9 00/23] plugins: Allow to read registers Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 01/23] target/riscv: Move MISA limits to class Akihiko Odaki
2023-10-11 15:23   ` Alex Bennée
2023-10-12  6:01     ` Akihiko Odaki
2023-10-11 16:04   ` Alex Bennée
2023-10-12 19:10   ` Daniel Henrique Barboza
2023-10-12 21:04     ` Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 02/23] target/riscv: Remove misa_mxl validation Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 03/23] target/riscv: Validate misa_mxl_max only once Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 04/23] gdbstub: Add num_regs member to GDBFeature Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 05/23] gdbstub: Introduce gdb_find_static_feature() Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 06/23] gdbstub: Introduce GDBFeatureBuilder Akihiko Odaki
2023-10-11 15:39   ` Alex Bennée
2023-10-11  7:02 ` [PATCH v9 07/23] target/arm: Use GDBFeature for dynamic XML Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 08/23] target/ppc: " Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 09/23] target/riscv: " Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 10/23] gdbstub: Use GDBFeature for gdb_register_coprocessor Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 11/23] gdbstub: Use GDBFeature for GDBRegisterState Akihiko Odaki
2023-10-11 15:57   ` Alex Bennée
2023-10-11  7:02 ` [PATCH v9 12/23] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb Akihiko Odaki
2023-10-11  7:02 ` [PATCH v9 13/23] gdbstub: Simplify XML lookup Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 14/23] gdbstub: Infer number of core registers from XML Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 15/23] hw/core/cpu: Remove gdb_get_dynamic_xml member Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 16/23] gdbstub: Add members to identify registers to GDBFeature Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 17/23] gdbstub: Expose functions to read registers Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 18/23] cpu: Call plugin hooks only when ready Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 19/23] plugins: Remove an extra parameter Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 20/23] plugins: Use different helpers when reading registers Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 21/23] plugins: Allow to read registers Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 22/23] contrib/plugins: Allow to log registers Akihiko Odaki
2023-10-11  7:03 ` [PATCH v9 23/23] plugins: Support C++ Akihiko Odaki
2023-10-11  8:51   ` Daniel P. Berrangé [this message]
2023-10-11 15:48     ` Akihiko Odaki
2023-10-11 16:21       ` Thomas Huth
2023-10-11 16:42         ` Akihiko Odaki
2023-10-11 16:53           ` Daniel P. Berrangé

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=ZSZiAHtXGOZnZNas@redhat.com \
    --to=berrange@redhat.com \
    --cc=a.anenkov@yadro.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=alex.bennee@linaro.org \
    --cc=erdnaxe@crans.org \
    --cc=m.tyutin@yadro.com \
    --cc=ma.mandourr@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.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).