Skip to content

ds-identify: detect LXD for VMs launched from host with > 5.10 kernel#1370

Merged
holmanb merged 2 commits into
canonical:mainfrom
blackboxsw:ds-id-lxd-vm-qemu
Apr 6, 2022
Merged

ds-identify: detect LXD for VMs launched from host with > 5.10 kernel#1370
holmanb merged 2 commits into
canonical:mainfrom
blackboxsw:ds-id-lxd-vm-qemu

Conversation

@blackboxsw
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw commented Apr 6, 2022

Proposed Commit Message

Launching KVM instances from a host system with > 5.10 kernel results
in LXC passing `hv_passthrough` to the kvm instance being launched.
Systemd < 251 will incorrectly detect the CPU in this case as
"qemu" instead of "kvm".

ds-identify needs to properly interpret systems with
sytemd-detect-virt="qemu"  and /sys/class/dmi/id/board_name="LXD"

This functionality can be dropped once systemd 251 support is
available on all supported distributions.

LP: #1968085

Additional Context

systemd/systemd#22709

Test Steps

From a jammy host:

$ lxc profile show jammy-vm
config: {}
description: Default LXD profile for jammy VMs
devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: jammy-vm

$ lxc launch ubuntu-daily:jammy --vm --profile jammy-vm test-jammy
$ lxc exec test-jammy -- systemd-detect-virt
qemu
$ lxc stop test-jammy
$ lxc config set test-jammy security.devlxd=false
$ lxc start test-jammy
$ lxc exec test-jammy -- DEBUG_LEVEL=2 DI_LOG=stderr /usr/lib/cloud-init/ds-identify --force
# Ensure "no datasource detected"
$ lxc exec test-jammy -- add-apt-repository ppa:cloud-init-dev/daily
$ lxc exec test-jammy -- apt install cloud-init
$ lxc exec test-jammy -- DEBUG_LEVEL=2 DI_LOG=stderr /usr/lib/cloud-init/ds-identify --force
"Found single datasource: LXD"

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

Launching KVM instances from a host system with > 5.10 kernel results
in LXC passing `hv_passthrough` to the kvm instance being launched.
Systemd < 251 will incorrectly detect the CPU in this case as
"qemu" instead of "kvm".

ds-identify needs to properly interpret systems with
sytemd-detect-virt="qemu"  and /sys/class/dmi/id/board_name="LXD"

This functionality can be dropped once systemd 251 support is
available.

LP: #1968085
@holmanb
Copy link
Copy Markdown
Member

holmanb commented Apr 6, 2022

This functionality can be dropped once systemd 251 support is
available.

I don't think this is true, is it? There may be distros/releases out there that might be stuck on a kernel version > 5.10 with a systemd version < 250 for quite some time. Without auditing all supported distros I don't think we can drop this check as soon as 251 is available.

Also I see a format issue that will likely fail on CI shortly (line length).

@blackboxsw
Copy link
Copy Markdown
Collaborator Author

blackboxsw commented Apr 6, 2022

This functionality can be dropped once systemd 251 support is
available.

I don't think this is true, is it? There may be distros/releases out there that might be stuck on a kernel version > 5.10 with a systemd version < 250 for quite some time. Without auditing all supported distros I don't think we can drop this check as soon as 251 is available.

Also I see a format issue that will likely fail on CI shortly (line length).

Fixed and updated both PR "Proposed Commit Message" in this description and the test_ds_identify docstr awaiting CI pass before we can merge.

@holmanb holmanb merged commit e3307e4 into canonical:main Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants