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 9, 2024
1 parent b89959f commit b996390
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 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,12 +137,15 @@ 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
}
vmxml.os = libvirt_bios.remove_bootconfig_items_from_vmos(vmxml.os)
try:
os_attrs = {
"loader": vmxml.os.loader,
"loader_readonly": vmxml.os.loader_readonly,
"loader_type": vmxml.os.loader_type
}
vmxml.os = libvirt_bios.remove_bootconfig_items_from_vmos(vmxml.os)
except LibvirtXMLNotFoundError:
pass
if vmxml.xmltreefile.find('features'):
arch = platform.machine().lower()
if vmxml.features.has_feature('acpi') and 'aarch64' in arch:
Expand Down

0 comments on commit b996390

Please sign in to comment.