Skip to content

Commit

Permalink
ch_platform: Fix hypervisor setting
Browse files Browse the repository at this point in the history
Libvirt versions greater than 10.2.0, define domain as 'hyperv' or 'kvm'
based on the underlying hypervisor. Set this domain appropriately in
domain's XML after checking libvirt version.

Signed-off-by: Praveen K Paladugu <[email protected]>
  • Loading branch information
praveen-pk committed Dec 20, 2024
1 parent 80b3f90 commit ea81548
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lisa/sut_orchestrator/libvirt/ch_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import secrets
import xml.etree.ElementTree as ET # noqa: N817
from pathlib import Path
from packaging.version import parse
from typing import List, Type

from lisa import schema
Expand All @@ -18,8 +19,9 @@
get_node_context,
)
from lisa.sut_orchestrator.libvirt.platform import BaseLibvirtPlatform
from lisa.tools import QemuImg
from lisa.tools import QemuImg, Ls
from lisa.util.logger import Logger, filter_ansi_escape
from lisa.util import LisaException

from .. import CLOUD_HYPERVISOR
from .console_logger import QemuConsoleLogger
Expand Down Expand Up @@ -101,7 +103,19 @@ def _create_node_domain_xml(
node_context = get_node_context(node)

domain = ET.Element("domain")
domain.attrib["type"] = "ch"

libvirt_version = self._get_libvirt_version()
if parse(libvirt_version) > parse("10.0.2"):
if self.host_node.tools[Ls].path_exists("/dev/mshv", sudo=True):
domain.attrib["type"] = "hyperv"
elif self.host_node.tools[Ls].path_exists("/dev/kvm", sudo=True):
domain.attrib["type"] = "kvm"
else:
raise LisaException("kvm, mshv are the only supported \
hypervsiors. Both are missing on the host")

else:
domain.attrib["type"] = "ch"

name = ET.SubElement(domain, "name")
name.text = node_context.vm_name
Expand Down

0 comments on commit ea81548

Please sign in to comment.