-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
guest os booting: add hotplug case with boot order element #5222
Conversation
|
Depend on avocado-framework/avocado-vt#3778. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Others LGTM
def prepare_device_xml(vm_xml, device_type): | ||
""" | ||
Prepare the hot-plugged device xml. | ||
:params device_type: the device type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miss vm_xml and return value docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
def check_dumpxml(vmxml, device_type, new_image_path): | ||
""" | ||
Check if the device is plugged and included the boot order element. | ||
:params vmxml: the current guest xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
miss device_type and new_image_path docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Check if the device is plugged and included the boot order element. | ||
:params vmxml: the current guest xml | ||
:params device_type: the device type | ||
:params new_image_path: the disk path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we directly use 'image_path'? I don't quite understand why we need a 'new_' param in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can also directly use 'image_path'.
Prepare the hot-plugged device xml. | ||
:params vm_xml: the instance of VMXML class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz add a blank line between description and params, thx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Check if the device is plugged and included the boot order element. | ||
:params vmxml: the current guest xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz add a blank line between description and params, thx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
check_dumpxml(vmxml, device_type, new_image_path) | ||
|
||
test.log.info(f"STEP4: Hot-unplug the {device_type}.") | ||
virsh.detach_device(vm_name, device_xml.xml, **virsh_dargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to wait for the events to make sure the devices are removed correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's better to wait to avoid the special situation. I've updated it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find the updates about waiting for the events, anything missed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I've added wait_for_event again.
try: | ||
libvirt_vmxml.check_guest_xml_by_xpaths(vmxml, order_xpath) | ||
except exceptions.TestFail as detail: | ||
test.log.debug(f"The device has been detached successfully because {detail}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using 'try-except', it's better to set 'ignore_status' in libvirt_vmxml.check_guest_xml_by_xpaths().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I mainly check that the xpath is not in vmxml. So I used try-except. I think we can't use ignore_status. Could you help to check it again? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you plz explain why you can't use 'ignore_status'? It was designed to avoid raising an exception when not matched. I'm not sure what your problem is, plz show us, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my understanding, we mainly use libvirt_vmxml.check_guest_xml_by_xpaths() to check it the xml is matched. If matched, it will pass. If unmatched, it will fail automatically. Is it right? Here I mainly check the detached xml, and hope it will pass when it unmatches. So I use exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment above
73668cf
to
b999ba0
Compare
check_dumpxml(vmxml, device_type, new_image_path) | ||
|
||
test.log.info(f"STEP4: Hot-unplug the {device_type}.") | ||
virsh.detach_device(vm_name, device_xml.xml, **virsh_dargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find the updates about waiting for the events, anything missed?
if not vm.is_alive(): | ||
virsh.start(vm_name, **virsh_dargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving L84~86 into L90 and deleting these 2 lines? I think we can merge these 2 vm startup steps into one. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've merged the virsh.start in L84~86 before virsh.attach_device and removed the duplicated part in the function prepare_device_xml. I guess this is wat you are meaning. Please have a look again.
hpgs=False) | ||
if not vm.is_alive(): | ||
virsh.start(vm_name, **virsh_dargs) | ||
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not used, please remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
|
||
test.log.info(f"STEP4: Hot-unplug the {device_type}.") | ||
virsh.detach_device(vm_name, device_xml.xml, **virsh_dargs) | ||
time.sleep(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be removed if you update detach-device to wait for the events,right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
for xpath_text in order_xpath: | ||
for boot_attrs in xpath_text['element_attrs']: | ||
if vmxml.xmltreefile.findall(boot_attrs): | ||
test.fail("The device hasn't been detached.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to only check order_xpath? Should it be checked like check_dumpxml() in this script? I wonder if you need to check the devices instead of 'boot attrs'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also updated the function check_dumpxml here to involve the hot-unplugging checking to replace these codes. In the functions, I directly used existed functions to check if the device existed, and also focused on the checking of boot order attributes.
@@ -0,0 +1,20 @@ | |||
- guest_os_booting.boot_order.hotplug: | |||
type = hotplug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meinaLi Can we have a proper name of these files? the current one is too common. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to be much specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. And I've updated it to hotplug_device_with_boot_order.
device_xml, image_path = disk_obj.prepare_disk_obj("file", device_dict) | ||
return device_xml, image_path | ||
|
||
def check_dumpxml(device_type, image_path, hotplug=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'hotplug' is not quite easy to understand in this function, how about using expect,expected or status_error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change it because here hotplug=True means we check the result after hotplugging. False means checking the result after hot-unplugging. So maybe no need to update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @meinaLi , I think I can't agree with it. It is a common checking xml function, so I still think we should just focus on whether we expect the device to exist or not, rather than qualifying it at which test step it is executed. And also, hotplug=False does not directly mean to hotunplug, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing, I've updated it based on what we discussed.
|
||
def check_dumpxml(device_type, image_path, hotplug=True): | ||
""" | ||
Check if the device is plugged and included the boot order element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugged -> existed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above.
""" | ||
Check if the device is existed and included the boot order element. | ||
|
||
:params vmxml: the current guest xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no vmxml, plz remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
This PR mainly implements the hotpluging of disk/usb/filesystem devices with boot order elements. Signed-off-by: Meina Li <[email protected]>
This PR mainly implements the hotpluging of disk/usb/filesystem devices with boot order elements.