From cd7993d38fd4dd736a17d526b03386388b5d447f Mon Sep 17 00:00:00 2001 From: smit-gardhariya Date: Wed, 8 Jan 2025 13:52:26 +0530 Subject: [PATCH] libvirt: Start default network and Capture libvirtd log Capture journalctl log of libvirtd unit when libvirt domain creation fails. Also read the libvirt log file. Start the network using virsh cli before creating node Signed-off-by: Smit Gardhariya --- lisa/sut_orchestrator/libvirt/platform.py | 7 +++++++ lisa/sut_orchestrator/libvirt/transformers.py | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lisa/sut_orchestrator/libvirt/platform.py b/lisa/sut_orchestrator/libvirt/platform.py index 2946385686..65ab433cc8 100644 --- a/lisa/sut_orchestrator/libvirt/platform.py +++ b/lisa/sut_orchestrator/libvirt/platform.py @@ -28,6 +28,7 @@ from lisa.platform_ import Platform from lisa.sut_orchestrator.libvirt.libvirt_device_pool import LibvirtDevicePool from lisa.tools import ( + Cat, Chmod, Chown, Cp, @@ -406,6 +407,12 @@ def _deploy_nodes(self, environment: Environment, log: Logger) -> None: ): self._delete_nodes(environment, log) + self._log.debug("Capturing libvirtd log from host...") + journalctl = self.host_node.tools[Journalctl] + journalctl.logs_for_unit(unit_name="libvirtd", sudo=True) + cat = self.host_node.tools[Cat] + cat.read(file="/var/log/libvirt/libvirtd.log", sudo=True) + raise ex # Pre-determine all the nodes' properties, including the name of all the resouces diff --git a/lisa/sut_orchestrator/libvirt/transformers.py b/lisa/sut_orchestrator/libvirt/transformers.py index 99cb2cc0a3..690710bbbb 100644 --- a/lisa/sut_orchestrator/libvirt/transformers.py +++ b/lisa/sut_orchestrator/libvirt/transformers.py @@ -561,6 +561,18 @@ def _install_libvirt(runbook: schema.TypedSchema, node: Node, log: Logger) -> No log.info("Enabled libvirtd and virtnetworkd services") node.reboot(time_out=900) _wait_for_libvirtd(node) + if isinstance(node.os, CBLMariner): + # Some time we have seen 'default' nw of libvirt is not started + # start it in that case and mark it auto-start + node.execute( + cmd="virsh net-start default", + sudo=True, + ) + node.execute( + cmd="virsh net-autostart default", + sudo=True, + ) + log.info("Marked 'default' libvirt network as auto-start") def _wait_for_libvirtd(node: Node) -> None: