[PATCH 0/8] move softmmu options processing from os-posix.c to vl.c

Michael Tokarev posted 8 patches 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230901101302.3618955-1-mjt@tls.msk.ru
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>
include/qemu/qemu-options.h        |  41 --------
include/sysemu/os-posix.h          |   8 +-
include/sysemu/os-win32.h          |   1 -
os-posix.c                         | 157 +++++++++--------------------
{util => softmmu}/async-teardown.c |   0
softmmu/meson.build                |   1 +
softmmu/vl.c                       |  87 +++++++++++++++-
util/meson.build                   |   1 -
8 files changed, 134 insertions(+), 162 deletions(-)
delete mode 100644 include/qemu/qemu-options.h
rename {util => softmmu}/async-teardown.c (100%)
[PATCH 0/8] move softmmu options processing from os-posix.c to vl.c
Posted by Michael Tokarev 8 months ago
This is the same patchset as the previous RFC,
https://lists.nongnu.org/archive/html/qemu-devel/2023-08/msg02145.html .
----

qemu_init() calls os_parse_cmd_args(), which is obviously a very vl.c-specicic
piece of code.  It looks like when moving vl.c to softmmu/, os-posix.c should've
been moved too (together with os-win32.c).  But there are other functions in
os-posix.c which are used by other parts of the code, eg qemu-nbd or
qemu-storage-daemon both uses parts from there.  The result is rather ugly.
One of the side-effects is that even if system build is disabled, we still
have to compile util/async-teardown.c, since it is used in os-posix.c, - and
this one can not be built on ia64 due to lack of clone syscall.  But qemu-nbd
does not need async-teardown, which is also very softmmu-specific.

This patchset tries to address these defects.  It moves the "bottom half" of
vl.c options processing back into vl.c, effectively undoing commit 59a5264b99434
from 2010.  We do not have many os-specific options, and this move makes
qemu_init() the only function which processes options, all in the single
place, which is, in my opinion, easier to manage.

Before this move, lower-level constructs (chroot, runas) are being exported.

In the end, we have almost no softmmu-related things in os-posix.c, and the
same functionality can be actually used in qemu-storage-daemon or qemu-nbd.
For qemu-nbd, it is now possible to switch to using -runas/-chroot/etc the
same way as qemu-storage-daemon does, instead of having one more abstraction
named qemu_daemon().

Michael Tokarev (8):
  include/sysemu/os-posix.h: move *daemonize* declarations together
  os-posix: create and export os_set_runas()
  os-posix.c: create and export os_set_chroot()
  os-posix.c, softmmu/vl.c: move os_parse_cmd_args() into qemu_init()
  os-posix.c: move code around
  os-posix.c: remove unneeded #includes
  softmmu/vl.c: inline include/qemu/qemu-options.h into vl.c
  util/async-teardown.c: move to softmmu/, only build it when system
    build is requested

 include/qemu/qemu-options.h        |  41 --------
 include/sysemu/os-posix.h          |   8 +-
 include/sysemu/os-win32.h          |   1 -
 os-posix.c                         | 157 +++++++++--------------------
 {util => softmmu}/async-teardown.c |   0
 softmmu/meson.build                |   1 +
 softmmu/vl.c                       |  87 +++++++++++++++-
 util/meson.build                   |   1 -
 8 files changed, 134 insertions(+), 162 deletions(-)
 delete mode 100644 include/qemu/qemu-options.h
 rename {util => softmmu}/async-teardown.c (100%)

-- 
2.39.2
Re: [PATCH 0/8] move softmmu options processing from os-posix.c to vl.c
Posted by Paolo Bonzini 8 months ago
Queued, thanks.

Paolo
Re: [PATCH 0/8] move softmmu options processing from os-posix.c to vl.c
Posted by Eric Blake 7 months, 3 weeks ago
On Fri, Sep 01, 2023 at 11:44:42PM +0200, Paolo Bonzini wrote:
> Queued, thanks.
> 
> Paolo

I also had these on my plate for an upcoming NBD pull request; I'm
fine whichever tree they show up through.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org