Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ch libvirt #3562

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions lisa/sut_orchestrator/libvirt/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,9 @@ def _get_libvirt_version(self) -> str:
if self.host_node:
result = self.host_node.execute("libvirtd --version", shell=True).stdout
result = filter_ansi_escape(result)
# Libvirtd returns version info as "libvirtd (libvirt) 10.8.0"
# From the return value, only return the version info
result = result.split()[-1]
return result

def _get_vmm_version(self) -> str:
Expand Down
7 changes: 5 additions & 2 deletions lisa/sut_orchestrator/libvirt/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ def _install_libvirt(runbook: schema.TypedSchema, node: Node, log: Logger) -> No

if isinstance(node.os, Ubuntu):
node.execute("systemctl disable apparmor", shell=True, sudo=True)
node.execute("systemctl enable libvirtd", shell=True, sudo=True)
node.reboot(time_out=900)
if isinstance(node.os, CBLMariner):
# After reboot, libvirtd service is in failed state and needs to
Expand All @@ -571,7 +570,11 @@ def _install_libvirt(runbook: schema.TypedSchema, node: Node, log: Logger) -> No
libvirt_version = libvirt_installer._get_version()
log.info(f"Already installed! libvirt version: {libvirt_version}")
_fix_mariner_installation(node=node)
node.reboot(time_out=900)

node.execute("systemctl enable libvirtd", shell=True, sudo=True)
node.execute("systemctl enable virtnetworkd", shell=True, sudo=True)
log.info("Enabled libvirtd and virtnetworkd services")
node.reboot(time_out=900)


# Some fixes to the libvirt installation on Mariner.
Expand Down
Loading