Currently qemu-binfmt-conf.sh does a number of strange things.
1. --systemd requires an argument - the CPU type to register,
while --debian (which is actually --binfmt-support) does not
accept such an argument, so it is not possible to specify which
CPU(s) to register for debian.
2. Why this "ALL" at all?
3. it just ignores extra command-line arguments. It would be
logical to specify which CPUs to register (multiple!) as the
additional arguments.
4. Even if a CPU is explicitly requested, it does not register
anything if this CPU is of the same family as host one. But
this is wrong, since quite often it *is* desirable to do this
registration, - like, when running in i386 when the system is
not capable of running x86-64 binaries, and countless other
examples
5. It ignores errors
6. It ignores wrong command line arguments
Fix this, and simplify things a bit.
1. Stop accepting an argument for --systemd. With getopt_long,
this argument, if given, will be returned as a non-optional
parameter so compatibility with current version is preserved.
2. Accept optional arguments and generate registration for the
given CPUs only. In case no extra arguments are given, register
for all supportd CPUs except of the same family as host.
3. Recognze "ALL" "CPU" to keep compatibility with current version
(but do not document it).
4. Warn but perform registration anyway if a cpu of the same family
has been requested.
5. In help text, use --debian and --systemd as alternatives to each
other, to make it clear the two can not be used at the same time.
6. Tiny optimization of eval expression.
7. Fold the list of supported CPUs to fit in 80 columns.
8. Exit with non-zero code in case registration fails or the command
line is wrong.
9. Remove explicit checking for writability of various things.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
scripts/qemu-binfmt-conf.sh | 89 +++++++++++++++++--------------------
1 file changed, 40 insertions(+), 49 deletions(-)