From be9389c62c6b7b2ecb5ea7cf7ffefc80a2d31210 Mon Sep 17 00:00:00 2001
From: Brett Holman <bholman.devel@gmail.com>
Date: Mon, 14 Mar 2022 16:00:47 +0100
Subject: [PATCH] Work around bug in LXD VM detection (#1325)

On kernels >=5.10, LXD starts qemu with kvm and hv_passthrough.
This causes `systemd-detect-virt` to identify the host as "qemu", rather than "kvm".

Cloud-init treats emulated (TCG) virtualization the same way as virtualized (KVM).
If systemd (see issue #22709) decides to report this as something other than
kvm/qemu, we'll need to extend our list of accepted types to include that as well.

https://github.com/systemd/systemd/issues/22709
---
 cloudinit/sources/DataSourceLXD.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/cloudinit/sources/DataSourceLXD.py
+++ b/cloudinit/sources/DataSourceLXD.py
@@ -71,7 +71,10 @@ def generate_fallback_network_config() -
                 err,
             )
             return network_v1
-        if virt_type.strip() == "kvm":  # instance.type VIRTUAL-MACHINE
+        if virt_type.strip() in (
+            "kvm",
+            "qemu",
+        ):  # instance.type VIRTUAL-MACHINE
             arch = util.system_info()["uname"][4]
             if arch == "ppc64le":
                 network_v1["config"][0]["name"] = "enp0s5"
