Skip to content

Commit

Permalink
kvm-test: set cloud-config disk after real disks
Browse files Browse the repository at this point in the history
Ensure that the disks used for installation are passed to kvm first
and not the disk with cloud-config/autoinstall data. Sometimes
curtin will put paths to disk in the fstab like:

    /dev/disk/by-path/pci-000n-xxxx/by-uuid/UUID

and when we reboot without the cloud-config disk the path to the
install disk will change since the number of pci devices connected
to the machine has technically changed. We can make this a little more
stable by letting the cloud-config drive be the last drive attached.
  • Loading branch information
Chris-Peterson444 committed Sep 12, 2024
1 parent 6727905 commit b005a69
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions scripts/kvm-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,21 +577,6 @@ def install(ctx):
kvm.append('-nographic')
appends.append('console=ttyS0')

if ctx.args.cloud_config is not None or ctx.args.cloud_config_default:
if ctx.args.cloud_config is not None:
ctx.cloudconfig = ctx.args.cloud_config.read()
kvm.extend(drive(create_seed(ctx.cloudconfig, tempdir), 'raw'))
if ctx.args.autoinstall is None:
# Let's inspect the yaml and check if there is an autoinstall
# section.
autoinstall = "autoinstall" in yaml.safe_load(ctx.cloudconfig)
else:
autoinstall = ctx.args.autoinstall

if autoinstall:
appends.append('autoinstall')


if ctx.args.update:
appends.append('subiquity-channel=' + ctx.args.update)

Expand All @@ -608,6 +593,20 @@ def install(ctx):
disksize = ctx.args.disksize or ctx.default_disk_size
run(f'qemu-img create -f qcow2 {ctx.target} {disksize}')

if ctx.args.cloud_config is not None or ctx.args.cloud_config_default:
if ctx.args.cloud_config is not None:
ctx.cloudconfig = ctx.args.cloud_config.read()
kvm.extend(drive(create_seed(ctx.cloudconfig, tempdir), 'raw'))
if ctx.args.autoinstall is None:
# Let's inspect the yaml and check if there is an autoinstall
# section.
autoinstall = "autoinstall" in yaml.safe_load(ctx.cloudconfig)
else:
autoinstall = ctx.args.autoinstall

if autoinstall:
appends.append('autoinstall')

if len(appends) > 0:
with mounter(iso, mntdir):
# if we're passing kernel args, we need to manually specify
Expand Down

0 comments on commit b005a69

Please sign in to comment.