From 7a99e1b1d875727ac89aebe79bc8a6229b5900fa Mon Sep 17 00:00:00 2001 From: Chenli Wei Date: Thu, 8 Sep 2022 01:30:03 +0800 Subject: [PATCH] misc: refine upgrade script There is some issue when use upgrade to update some old xml version to release_3.1, this patch modify the upgrade script to fix these issue. Tracked-On: #6690 Signed-off-by: Chenli Wei --- misc/config_tools/scenario_config/upgrader.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/misc/config_tools/scenario_config/upgrader.py b/misc/config_tools/scenario_config/upgrader.py index ca2c4ae16..dbc646676 100755 --- a/misc/config_tools/scenario_config/upgrader.py +++ b/misc/config_tools/scenario_config/upgrader.py @@ -316,14 +316,15 @@ class VirtioDevices(object): interface_name = network.xpath("./interface_name")[0].text if network.xpath("./interface_name") else None self.networks.append((virtio_framework, interface_name)) - if virtio_device_node.xpath("./input")[0].text is not None: - for input in virtio_device_node.xpath("./input"): - self.inputs.append((None, input.text)) - else: - for input in virtio_device_node.xpath("./input"): - backend_device_file = input.xpath("./backend_device_file")[0].text if input.xpath("./backend_device_file") else None - id = input.xpath("./id")[0].text if input.xpath("./id") else None - self.inputs.append((backend_device_file, id)) + if len(virtio_device_node.xpath("./input")) > 0: + if virtio_device_node.xpath("./input")[0].text is not None: + for input in virtio_device_node.xpath("./input"): + self.inputs.append((None, input.text)) + else: + for input in virtio_device_node.xpath("./input"): + backend_device_file = input.xpath("./backend_device_file")[0].text if input.xpath("./backend_device_file") else None + id = input.xpath("./id")[0].text if input.xpath("./id") else None + self.inputs.append((backend_device_file, id)) for console in virtio_device_node.xpath("./console"): self.console_encoding(console)