Skip to content

Commit

Permalink
vcpu_metrics: handle missing element
Browse files Browse the repository at this point in the history
//os/loader* might not exist on the domain definition leading
to an exception. In this case, skip the step that tries to remove
those attributes.

Signed-off-by: Sebastian Mitterle <[email protected]>
  • Loading branch information
smitterl committed Sep 12, 2024
1 parent b89959f commit 5d96e5a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libvirt/tests/src/cpu/vcpu_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from virttest import virsh

from virttest.libvirt_xml import vm_xml
from virttest.libvirt_xml.xcepts import LibvirtXMLNotFoundError
from virttest.utils_libvirt import libvirt_bios
from virttest.utils_libvirt import libvirt_vmxml

Expand Down Expand Up @@ -136,11 +137,14 @@ def setup_with_unprivileged_user(vm, params, test):
unprivileged_boot_disk_path = os.path.join(unprivileged_boot_disk_path, os.path.basename(first_disk_source))
disk_attrs = {'source': {'attrs': {'file': unprivileged_boot_disk_path}}}
libvirt_vmxml.modify_vm_device(vmxml, 'disk', disk_attrs)
os_attrs = {
"loader": vmxml.os.loader,
"loader_readonly": vmxml.os.loader_readonly,
"loader_type": vmxml.os.loader_type
}
try:
os_attrs = {
"loader": vmxml.os.loader,
"loader_readonly": vmxml.os.loader_readonly,
"loader_type": vmxml.os.loader_type
}
except LibvirtXMLNotFoundError:
pass
vmxml.os = libvirt_bios.remove_bootconfig_items_from_vmos(vmxml.os)
if vmxml.xmltreefile.find('features'):
arch = platform.machine().lower()
Expand Down

0 comments on commit 5d96e5a

Please sign in to comment.