diff mbox series

[v6,1/4] Add NVMM accelerator: configure and build logic

Message ID 20210331200800.24168-2-reinoud@NetBSD.org
State New
Headers show
Series Implements the NetBSD Virtual Machine Monitor accelerator | expand

Commit Message

Reinoud Zandijk March 31, 2021, 8:07 p.m. UTC
Signed-off-by: Reinoud Zandijk <reinoud@NetBSD.org>
Signed-off-by: Kamil Rytarowski <kamil@NetBSD.org>

---
 accel/Kconfig     |  3 +++
 configure         | 12 +++++++++---
 meson.build       | 23 ++++++++++++++++++++---
 meson_options.txt |  2 ++
 qemu-options.hx   |  8 ++++----
 5 files changed, 38 insertions(+), 10 deletions(-)

Comments

Paolo Bonzini April 1, 2021, 8:28 a.m. UTC | #1
On 31/03/21 22:07, Reinoud Zandijk wrote:
> Signed-off-by: Reinoud Zandijk <reinoud@NetBSD.org>
> Signed-off-by: Kamil Rytarowski <kamil@NetBSD.org>

Incorrect order for the S-o-b headers, you should be last.

> ---
> @@ -886,7 +887,7 @@ for opt do
>     ;;
>     --python=*) python="$optarg" ; explicit_python=yes
>     ;;
> -  --sphinx-build=*) sphinx_build="$optarg"
> +  --sphinx-build-3.8-3.8=*) sphinx_build="$optarg"

Oops. :)  Another occurrence later.

> diff --git a/meson.build b/meson.build
> index c6f4b0cf5e..e33face775 100644
> --- a/meson.build
> +++ b/meson.build

The meson.build parts can be simplified by applying this patch:

diff --git a/meson.build b/meson.build
index e33face775..c4600a46a6 100644
--- a/meson.build
+++ b/meson.build
@@ -171,7 +171,7 @@ version_res = []
  coref = []
  iokit = []
  emulator_link_args = []
-nvmm = []
+nvmm = not_found
  hvf = not_found
  if targetos == 'windows'
    socket = cc.find_library('ws2_32')
@@ -197,12 +197,6 @@ elif targetos == 'openbsd'
      # Disable OpenBSD W^X if available
      emulator_link_args = 
cc.get_supported_link_arguments('-Wl,-z,wxneeded')
    endif
-elif targetos == 'netbsd'
-  if not get_option('nvmm').disabled()
-    if cc.has_header('nvmm.h')
-      nvmm = cc.find_library('nvmm')
-    endif
-  endif
  endif

  accelerators = []
@@ -235,8 +229,11 @@ if not get_option('hax').disabled()
      accelerators += 'CONFIG_HAX'
    endif
  endif
-if not get_option('nvmm').disabled()
+if targetos == 'netbsd'
    if cc.has_header('nvmm.h', required: get_option('nvmm'))
+    nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
+  endif
+  if nvmm.found()
      accelerators += 'CONFIG_NVMM'
    endif
  endif
@@ -2242,7 +2239,7 @@ foreach target : target_dirs
        'name': 'qemu-system-' + target_name,
        'gui': false,
        'sources': files('softmmu/main.c'),
-      'dependencies': [nvmm]
+      'dependencies': []
      }]
      if targetos == 'windows' and (sdl.found() or gtk.found())
        execs += [{


> @@ -607,7 +623,7 @@ if have_system and not get_option('curses').disabled()
>         has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
>       endif
>       if has_curses_h
> -      curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
> +      curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw', 'curses'])
>         foreach curses_libname : curses_libname_list
>           libcurses = cc.find_library(curses_libname,
>                                       required: false,
> @@ -625,7 +641,7 @@ if have_system and not get_option('curses').disabled()
>       endif
>     endif
>     if not get_option('iconv').disabled()
> -    foreach link_args : [ ['-liconv'], [] ]
> +    foreach link_args : [ [], ['-liconv'] ]
>         # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
>         # We need to use libiconv if available because mixing libiconv's headers with
>         # the system libc does not work.

Independent changes, should be posted separately.

> @@ -2226,7 +2242,7 @@ foreach target : target_dirs
>         'name': 'qemu-system-' + target_name,
>         'gui': false,
>         'sources': files('softmmu/main.c'),
> -      'dependencies': []
> +      'dependencies': [nvmm]
>       }]
>       if targetos == 'windows' and (sdl.found() or gtk.found())
>         execs += [{

Not needed yet, should be added together with the nvmm sources to the 
sourceset.

Paolo
Reinoud Zandijk April 1, 2021, 12:17 p.m. UTC | #2
Hi Paolo,

thanks for the review!

On Thu, Apr 01, 2021 at 10:28:19AM +0200, Paolo Bonzini wrote:
> On 31/03/21 22:07, Reinoud Zandijk wrote:
> > Signed-off-by: Reinoud Zandijk <reinoud@NetBSD.org>
> > Signed-off-by: Kamil Rytarowski <kamil@NetBSD.org>
> 
> Incorrect order for the S-o-b headers, you should be last.

Oops? there is a prescribed order in those? Will change the order!

> > ---
> > @@ -886,7 +887,7 @@ for opt do
> >     ;;
> >     --python=*) python="$optarg" ; explicit_python=yes
> >     ;;
> > -  --sphinx-build=*) sphinx_build="$optarg"
> > +  --sphinx-build-3.8-3.8=*) sphinx_build="$optarg"
> 
> Oops. :)  Another occurrence later.

Ai ai ai, a different patch krept in! In pkgsrc all patches on a single file
are normally combined and thus they krept in!

> > diff --git a/meson.build b/meson.build
> > index c6f4b0cf5e..e33face775 100644
> > --- a/meson.build
> > +++ b/meson.build
> 
> The meson.build parts can be simplified by applying this patch:
> 
> diff --git a/meson.build b/meson.build

Thanks! Will try it out and add to the patch.

> > @@ -625,7 +641,7 @@ if have_system and not get_option('curses').disabled()
> >       endif
> >     endif
> >     if not get_option('iconv').disabled()
> > -    foreach link_args : [ ['-liconv'], [] ]
> > +    foreach link_args : [ [], ['-liconv'] ]
> >         # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
> >         # We need to use libiconv if available because mixing libiconv's headers with
> >         # the system libc does not work.
> 
> Independent changes, should be posted separately.

Yep, those shouldn't be in this patchset indeed, see above.

Will try to fix it and go for version 7 soon.

Is there a way for `qemu format-patch' to preserve the comments made in the
previous run? It would be handy if it would paste in the old patchset's
comments in the new patchset :)

Reinoud
Paolo Bonzini April 1, 2021, 12:44 p.m. UTC | #3
On 01/04/21 14:17, Reinoud Zandijk wrote:
> Hi Paolo,
> 
> thanks for the review!
> 
> On Thu, Apr 01, 2021 at 10:28:19AM +0200, Paolo Bonzini wrote:
>> On 31/03/21 22:07, Reinoud Zandijk wrote:
>>> Signed-off-by: Reinoud Zandijk <reinoud@NetBSD.org>
>>> Signed-off-by: Kamil Rytarowski <kamil@NetBSD.org>
>>
>> Incorrect order for the S-o-b headers, you should be last.
> 
> Oops? there is a prescribed order in those? Will change the order!

The second got the patch from the first, the third from the second etc.

> Will try to fix it and go for version 7 soon.
> 
> Is there a way for `qemu format-patch' to preserve the comments made in the
> previous run? It would be handy if it would paste in the old patchset's
> comments in the new patchset :)

Hmm, not sure what you mean.  There is "git notes".

Paolo
diff mbox series

Patch

diff --git a/accel/Kconfig b/accel/Kconfig
index 461104c771..8bdedb7d15 100644
--- a/accel/Kconfig
+++ b/accel/Kconfig
@@ -1,6 +1,9 @@ 
 config WHPX
     bool
 
+config NVMM
+    bool
+
 config HAX
     bool
 
diff --git a/configure b/configure
index 535e6a9269..0d4e6dd521 100755
--- a/configure
+++ b/configure
@@ -352,6 +352,7 @@  kvm="auto"
 hax="auto"
 hvf="auto"
 whpx="auto"
+nvmm="auto"
 rdma="$default_feature"
 pvrdma="$default_feature"
 gprof="no"
@@ -886,7 +887,7 @@  for opt do
   ;;
   --python=*) python="$optarg" ; explicit_python=yes
   ;;
-  --sphinx-build=*) sphinx_build="$optarg"
+  --sphinx-build-3.8-3.8=*) sphinx_build="$optarg"
   ;;
   --skip-meson) skip_meson=yes
   ;;
@@ -1107,6 +1108,10 @@  for opt do
   ;;
   --enable-hvf) hvf="enabled"
   ;;
+  --disable-nvmm) nvmm="disabled"
+  ;;
+  --enable-nvmm) nvmm="enabled"
+  ;;
   --disable-whpx) whpx="disabled"
   ;;
   --enable-whpx) whpx="enabled"
@@ -1727,7 +1732,7 @@  Advanced options (experts only):
   --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
   --make=MAKE              use specified make [$make]
   --python=PYTHON          use specified python [$python]
-  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
+  --sphinx-build-3.8-3.8=SPHINX    use specified sphinx-build-3.8-3.8 [$sphinx_build]
   --meson=MESON            use specified meson [$meson]
   --ninja=NINJA            use specified ninja [$ninja]
   --smbd=SMBD              use specified smbd [$smbd]
@@ -1848,6 +1853,7 @@  disabled with --disable-FEATURE, default is enabled if available
   kvm             KVM acceleration support
   hax             HAX acceleration support
   hvf             Hypervisor.framework acceleration support
+  nvmm            NVMM acceleration support
   whpx            Windows Hypervisor Platform acceleration support
   rdma            Enable RDMA-based migration
   pvrdma          Enable PVRDMA support
@@ -6410,7 +6416,7 @@  NINJA=$ninja $meson setup \
         -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
         -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
         -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
-        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
+        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
         -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
         -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
         -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
diff --git a/meson.build b/meson.build
index c6f4b0cf5e..e33face775 100644
--- a/meson.build
+++ b/meson.build
@@ -87,6 +87,7 @@  if cpu in ['x86', 'x86_64']
   accelerator_targets += {
     'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
     'CONFIG_HVF': ['x86_64-softmmu'],
+    'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
     'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
   }
 endif
@@ -170,6 +171,7 @@  version_res = []
 coref = []
 iokit = []
 emulator_link_args = []
+nvmm = []
 hvf = not_found
 if targetos == 'windows'
   socket = cc.find_library('ws2_32')
@@ -195,6 +197,12 @@  elif targetos == 'openbsd'
     # Disable OpenBSD W^X if available
     emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
   endif
+elif targetos == 'netbsd'
+  if not get_option('nvmm').disabled()
+    if cc.has_header('nvmm.h')
+      nvmm = cc.find_library('nvmm')
+    endif
+  endif
 endif
 
 accelerators = []
@@ -227,6 +235,11 @@  if not get_option('hax').disabled()
     accelerators += 'CONFIG_HAX'
   endif
 endif
+if not get_option('nvmm').disabled()
+  if cc.has_header('nvmm.h', required: get_option('nvmm'))
+    accelerators += 'CONFIG_NVMM'
+  endif
+endif
 
 tcg_arch = config_host['ARCH']
 if not get_option('tcg').disabled()
@@ -271,6 +284,9 @@  endif
 if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
   error('HVF not available on this platform')
 endif
+if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
+  error('NVMM not available on this platform')
+endif
 if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
   error('WHPX not available on this platform')
 endif
@@ -607,7 +623,7 @@  if have_system and not get_option('curses').disabled()
       has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
     endif
     if has_curses_h
-      curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
+      curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw', 'curses'])
       foreach curses_libname : curses_libname_list
         libcurses = cc.find_library(curses_libname,
                                     required: false,
@@ -625,7 +641,7 @@  if have_system and not get_option('curses').disabled()
     endif
   endif
   if not get_option('iconv').disabled()
-    foreach link_args : [ ['-liconv'], [] ]
+    foreach link_args : [ [], ['-liconv'] ]
       # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
       # We need to use libiconv if available because mixing libiconv's headers with
       # the system libc does not work.
@@ -2226,7 +2242,7 @@  foreach target : target_dirs
       'name': 'qemu-system-' + target_name,
       'gui': false,
       'sources': files('softmmu/main.c'),
-      'dependencies': []
+      'dependencies': [nvmm]
     }]
     if targetos == 'windows' and (sdl.found() or gtk.found())
       execs += [{
@@ -2576,6 +2592,7 @@  if have_system
   summary_info += {'HAX support':       config_all.has_key('CONFIG_HAX')}
   summary_info += {'HVF support':       config_all.has_key('CONFIG_HVF')}
   summary_info += {'WHPX support':      config_all.has_key('CONFIG_WHPX')}
+  summary_info += {'NVMM support':      config_all.has_key('CONFIG_NVMM')}
   summary_info += {'Xen support':       config_host.has_key('CONFIG_XEN_BACKEND')}
   if config_host.has_key('CONFIG_XEN_BACKEND')
     summary_info += {'xen ctrl version':  config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
diff --git a/meson_options.txt b/meson_options.txt
index 9734019995..91034420a1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -33,6 +33,8 @@  option('whpx', type: 'feature', value: 'auto',
        description: 'WHPX acceleration support')
 option('hvf', type: 'feature', value: 'auto',
        description: 'HVF acceleration support')
+option('nvmm', type: 'feature', value: 'auto',
+       description: 'NVMM acceleration support')
 option('xen', type: 'feature', value: 'auto',
        description: 'Xen backend support')
 option('xen_pci_passthrough', type: 'feature', value: 'auto',
diff --git a/qemu-options.hx b/qemu-options.hx
index fd21002bd6..dadf11fae9 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -26,7 +26,7 @@  DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
     "-machine [type=]name[,prop[=value][,...]]\n"
     "                selects emulated machine ('-machine help' for list)\n"
     "                property accel=accel1[:accel2[:...]] selects accelerator\n"
-    "                supported accelerators are kvm, xen, hax, hvf, whpx or tcg (default: tcg)\n"
+    "                supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg)\n"
     "                vmport=on|off|auto controls emulation of vmport (default: auto)\n"
     "                dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
     "                mem-merge=on|off controls memory merge support (default: on)\n"
@@ -58,7 +58,7 @@  SRST
 
     ``accel=accels1[:accels2[:...]]``
         This is used to enable an accelerator. Depending on the target
-        architecture, kvm, xen, hax, hvf, whpx or tcg can be available.
+        architecture, kvm, xen, hax, hvf, nvmm, whpx or tcg can be available.
         By default, tcg is used. If there is more than one accelerator
         specified, the next one is used if the previous one fails to
         initialize.
@@ -135,7 +135,7 @@  ERST
 
 DEF("accel", HAS_ARG, QEMU_OPTION_accel,
     "-accel [accel=]accelerator[,prop[=value][,...]]\n"
-    "                select accelerator (kvm, xen, hax, hvf, whpx or tcg; use 'help' for a list)\n"
+    "                select accelerator (kvm, xen, hax, hvf, nvmm, whpx or tcg; use 'help' for a list)\n"
     "                igd-passthru=on|off (enable Xen integrated Intel graphics passthrough, default=off)\n"
     "                kernel-irqchip=on|off|split controls accelerated irqchip support (default=on)\n"
     "                kvm-shadow-mem=size of KVM shadow MMU in bytes\n"
@@ -145,7 +145,7 @@  DEF("accel", HAS_ARG, QEMU_OPTION_accel,
 SRST
 ``-accel name[,prop=value[,...]]``
     This is used to enable an accelerator. Depending on the target
-    architecture, kvm, xen, hax, hvf, whpx or tcg can be available. By
+    architecture, kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By
     default, tcg is used. If there is more than one accelerator
     specified, the next one is used if the previous one fails to
     initialize.