KVM/libguestfs-tools/virt-customize

command available since 2014 included in  which allows to customize virtual machines.

Examples
virt-customize -a rhel7.img \ --edit '/etc/default/grub: s/^GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="nosmt /' \ --run-command 'grub2-mkconfig -o /boot/grub2/grub.cfg'
 * Edit grup Kernel command line

virt-customize -a guest1.img \ --hostname guest1 --timezone Europe/London \ --install gcc