13 ms·
QEMU is great, I'm just annoyed by its UI. I'd much rather have a config file I can point it towards than an endlessly long shell script I can't comfortably use
by solarkraft 4y ago
QEMU is great, I'm just annoyed by its UI. I'd much rather have a config file I can point it towards than an endlessly long shell script I can't comfortably use comments in (maybe this is a criticism of shell scripts in general).
I guess libvirt would be the "docker compose" front-end, but I remember considering that more complex than would be necessary.
I know Proxmox has some QEMU management tools (which I find decent), but they don't seem to be very popular outside of it.
One cool QEMU thing I recently discovered is the microvm machine type (https://qemu.readthedocs.io/en/latest/system/i386/microvm.html https://qemu.readthedocs.io/en/latest/system/i386/microvm.ht...), which enables it to spawn VMs just as quickly as Firecracker!
It would be nicer yet if there was some way to say "give me a shell in this ephemeral VM" like docker does it, but sadly Kata Containers appear to have dropped docker support and I haven't been able to get it to run with the alternative runtimes.
- anthk 4y agoVirt-Manager (and virsh) has option for both config files and scripts creation.
- troutwine 4y ago> I'd much rather have a config file I can point it towards than an endlessly long shell script I can't comfortably use comments in (maybe this is a criticism of shell scripts in general). I end up designing a lot of CLI tools and this is a design problem I run into a lot with my own stuff: how many flags are too many? Introducing a config file works, but now it makes your tool much less feasible to run in a shell script but, like you say, too many flags makes your tool unwieldy to run anyway. The problem is harder if you have a venerable tool that's always been flag heavy. Do you keep lumping flags in or do you steer the community toward the use of a config file? Or a hybrid?
- rcoveson 4y agoOpenVPN's approach is to have every config key imply a valid config file entry and a long-arg. So if you see the line `tun-mtu 1500` in a config file, you know you could use the arg `--tun-mtu 1500` on the command line, and vice versa; if you see somebody use the CLI arg `--proto udp` you know you could put the line in your config file `proto udp`. I think mysqld has a similar approach, though I don't think it's as complete. I'll bet both of those projects would answer that there's no such thing as a tipping point where you tell users to use a config file. They're just two ways of doing the same thing; use whichever makes sense for your deployment.
- troutwine 4y agoThat's an interesting approach.
- nyanpasu64 4y agoThe mpv media player takes a similar approach.
- nerdponx 4y agoSeveral Python tools (Mypy, Black) also use this approach and I like it a lot.
- solarkraft 4y agoI like tools that have 1:1 mappings for config file and command line flags because, as you say, both have advantages and disadvantages.
- nerdponx 4y agoZsh (and to a lesser extent Bash) has support for arrays, which you can use to represent long command line invocations in relative safety. E.g. instead of this sort of madness: #!/bin/sh set -eu # Argh I can't write comments in between lines... just email me if you have q's: nerdponx@mail.example.net exec /usr/sbin/boop \ --enable-foobars \ --this-is-a-really-long-option \ --sound=quack:.:loader=org.example.soundfactory-lib.SoundFactory.wrapped_loader \ --sound=woof:.:loader=net.quibbler.QuibblerWoofMaker \ --jvm-opts='-Xms512M -Xmx1G -Xquux=1234 -Xbootclasspath:.' But you can preserve what's left of your brain cells without switching to a "non-shell" language if you use Zsh, and then you don't have to sweat over shell quoting and parameter expansion either: #!/usr/bin/env zsh # Enable "strict" features for typo-safety emulate zsh setopt err_exit pipe_fail warn_create_global warn_nested_var no_unset boop_args=( # We always want foobars, why isn't this on by default? --enable-foobars # See: https://stackoverflow.com/questions/4973 --this-is-a-really-long-option # Use the good sounds! Please see README for obtaining these deps. --sound=quack:.:loader=org.example.soundfactory-lib.SoundFactory.wrapped_loader --sound=woof:.:loader=net.quibbler.QuibblerWoofMaker # Trust me, don't touch these. --jvm-opts='-Xms512M -Xmx1G -Xquux=1234 -Xbootclasspath:.' ) exec /usr/sbin/boop ${(@)boop_args}
- Groxx 4y agoaaah, that's a great idea for interleaving comments, I'll have to use that! thanks! previously I've done this, which works, but is a bit....... yeah. some command \ `# did you know comments work inside backticks like this?` \ --complex_flag_needing_descriptions=... \ `# literally any ffmpeg flag` \ --lol no now if only shellcheck would support zsh....
- remram 4y agoFor completeness, the other option is: CMD="some command" # Some comment CMD="$CMD --verbose --complex-flag=..." # Other stuff CMD="$CMD --lol=\"no thanks\"" eval $CMD
- 4y ago