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 e6841a0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lisa/sut_orchestrator/libvirt/ch_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from pathlib import Path
from typing import List, Type

from packaging.version import parse

from lisa import schema
from lisa.environment import Environment
from lisa.feature import Feature
Expand All @@ -18,7 +20,8 @@
get_node_context,
)
from lisa.sut_orchestrator.libvirt.platform import BaseLibvirtPlatform
from lisa.tools import QemuImg
from lisa.tools import Ls, QemuImg
from lisa.util import LisaException
from lisa.util.logger import Logger, filter_ansi_escape

from .. import CLOUD_HYPERVISOR
Expand Down Expand Up @@ -101,7 +104,21 @@ 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 e6841a0

Please sign in to comment.