Created attachment 1424017 [details]
Patch to remove "method=..." if the guest is identified as Debian
Hi, reporting upstream a bug I filed in the Debian BTS, for tracking purposes. Mostly copy/paste.
Description of problem:
I'm trying to fully automatically install virtual machines by means of a
preseed file. I set "--location" to the desired URL and add some
parameters to "--extra-args" to ask debian-installer to run an automated
installation, tell it where to fetch the preseed file, and add some
parameters that I want copied to the installed system's boot
configuration (for example "elevator=noop").
This works almost perfectly, but there one slight problem: for a reason
I don't understand, virt-install adds "method=<contents of --location
option>" to the kernel parameters (qemu's "-append" option), *after* the
contents of "--extra-args".
As stated in its documentation, debian-installer will copy most kernel
parameters found after "--" or "---" to the installed system's boot
configuration (eg. in /etc/default/grub), filtering the ones it thinks
are destined to itself; so if the "--extra-args" option contains "--" or
"---", the "method=..." argument ends up being copied in
/etc/default/grub, which of course is not desired. Obviously,
debian-installer filter doesn't catch it.
Now, I'm not sure what would be the correct fix for this. I see two
- the conservative (and simple) one: modify virt-install to add
"method=..." *before* the contents of "--extra-args", so that if the
latter contains "--" or "---", "method=..." will be positioned before
those, and won't be copied to the installed system's boot configuration.
- the risky one: modify virt-install to not add "method=..." at all;
after re-reading debian-installer's documentation, I didn't see this
parameter mentioned anywhere. Come to think of it, this shouldn't be
needed: virt-install already fetches the kernel and initrd, and passes
them to the VM, so I can't see why debian-installer should need to know
how they were fetched.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Install a Debian guest with virt-install, using --location and --extra-args containing "--" or "---" (example: --extra-args "auto=true url=tftp://autoserver priority=critical --- quiet elevator=noop console=ttyS0,115200n8")
2. Log on new guest
3. Read contents of /etc/default/grub
/etc/default/grub contains a useless kernel parameter "method=...", because virt-install appended it to the contents of --extra-args.
virt-install shouldn't add this parameter, which is completely unneeded, or at least, it should prepend it to --extra-args, not append it, so that if the value of --extra-args contains "--" or "---", debian-installer won't copy it to the bootloader's configuration.
I attached a simple patch, which implements the second solution (remove "method=" altogether if the distribution is detected as "Debian"). It should be tested with other guest distributions though. I believe it should also check if self.name is equal to "Ubuntu", but I'm not sure of what modifications Ubuntu made to debian-installer, and thus, if ubuntu-installer needs (or support) "method=" or not.
Thanks for the patch! However this bug is actually fixed upstream already with some recent rework I did to the code in this area. So I'll close this bug as UPSTREAM, but you might want to ask debian to include your patch into their repos, my work will be hard to backport