Replace virsh.managedsave() with vm.managedsave() for console handling#6830
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughTwo test files in the memory devices lifecycle suite were modified to replace direct virsh CLI invocations with VM object method calls: Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip Flake8 can be used to improve the quality of Python code reviews.Flake8 is a Python linter that wraps PyFlakes, pycodestyle and Ned Batchelder's McCabe script. To configure Flake8, add a '.flake8' or 'setup.cfg' file to your project root. See Flake8 Documentation for more details. |
This change replaces direct virsh.managedsave() calls with the VM instance method vm.managedsave() in memory related lifecycle tests. The new approach inherently manages the guest's serial console connection during state saving, eliminating potential connection timeouts when reattaching to the console during guest reboot. Signed-off-by: Liang Cong <lcong@redhat.com>
15c6b9c to
75d191c
Compare
| check_dimm_mem_device_xml( | ||
| {init_alias_name: init_xpath_list, plug_alias_name: plug_xpath_list}) | ||
|
|
||
| virsh.managedsave(vm_name, **virsh_dargs) |
There was a problem hiding this comment.
Hi, I checked the managedsave function in libvirt_vm.py.
def managedsave(self):
"""
Managed save of VM's state
"""
if self.is_dead():
raise virt_vm.VMStatusError("Cannot save a VM that is %s" % self.state())
LOG.debug("Managed saving VM %s" % self.name)
result = virsh.managedsave(self.name, uri=self.connect_uri)
if result.exit_status:
raise virt_vm.VMError(
"Managed save VM failed.\n" "Detail: %s." % result.stderr_text
)
if self.is_alive():
raise virt_vm.VMStatusError("VM not shut off after managed save")
self.cleanup_serial_console()
There is no option for debug. For the virsh object. its debug option is default to false
`class VirshBase(propcan.PropCanBase):
"""
Base Class storing libvirt Connection & state to a host
"""
__slots__ = ("uri", "ignore_status", "debug", "virsh_exec", "readonly")
def __init__(self, *args, **dargs):
"""
Initialize instance with virsh_exec always set to something
"""
init_dict = dict(*args, **dargs)
init_dict["virsh_exec"] = init_dict.get("virsh_exec", VIRSH_EXEC)
init_dict["uri"] = init_dict.get("uri", None)
init_dict["debug"] = init_dict.get("debug", False)
init_dict["ignore_status"] = init_dict.get("ignore_status", False)
init_dict["readonly"] = init_dict.get("readonly", False)
super(VirshBase, self).__init__(init_dict)
`
In the original code, virsh_dargs = {"debug": True, "ignore_status": False}. How can we replace virsh.managedsave to vm.managedsave while enabling debug?
There was a problem hiding this comment.
for vm.managedsave(), we don't need any parameter.
There was a problem hiding this comment.
Yes. There is no way to enable debug. Do we need to add a parameter to vm.managedsave in avocado-vt?
There was a problem hiding this comment.
Not very necessary, vm.managedsave() handles error scenarios, I think that's enough.
This change replaces direct virsh.managedsave() calls with the VM instance method
vm.managedsave() in memory related lifecycle tests. The new approach inherently
manages the guest's serial console connection during state saving, eliminating potential connection timeouts when reattaching to the console during guest reboot.
Test results:
(1/2) type_specific.io-github-autotest-libvirt.memory.devices.virtio_mem.lifecycle.all_requested_and_address.nodemask_pagesize.4k: STARTED
(1/2) type_specific.io-github-autotest-libvirt.memory.devices.virtio_mem.lifecycle.all_requested_and_address.nodemask_pagesize.4k: PASS (206.91 s)
(2/2) type_specific.io-github-autotest-libvirt.memory.devices.virtio_mem.lifecycle.part_requested_and_no_address.nodemask_pagesize.4k: STARTED
(2/2) type_specific.io-github-autotest-libvirt.memory.devices.virtio_mem.lifecycle.part_requested_and_no_address.nodemask_pagesize.4k: PASS (210.23 s)
(1/2) type_specific.io-github-autotest-libvirt.memory.devices.dimm.lifecycle.no_address.nodemask_pagesize.4k: STARTED
(1/2) type_specific.io-github-autotest-libvirt.memory.devices.dimm.lifecycle.no_address.nodemask_pagesize.4k: PASS (163.69 s)
(2/2) type_specific.io-github-autotest-libvirt.memory.devices.dimm.lifecycle.slot_base.nodemask_pagesize.4k: STARTED
(2/2) type_specific.io-github-autotest-libvirt.memory.devices.dimm.lifecycle.slot_base.nodemask_pagesize.4k: PASS (180.50 s)
Summary by CodeRabbit