未验证 提交 87029d18 编写于 作者: D dzhengfy 提交者: GitHub

Merge pull request #2829 from qiankehan/wait_event

virtual_disks: Apply wait_remove_event for disk hot unplug
...@@ -359,7 +359,7 @@ def run(test, params, env): ...@@ -359,7 +359,7 @@ def run(test, params, env):
find_attach_disk(not status_error) find_attach_disk(not status_error)
# Detach disk # Detach disk
cmd_result = virsh.detach_disk(vm_name, disk_target) cmd_result = virsh.detach_disk(vm_name, disk_target, wait_remove_event=True)
libvirt.check_exit_status(cmd_result, status_error) libvirt.check_exit_status(cmd_result, status_error)
# Check disk inside the VM # Check disk inside the VM
......
...@@ -954,13 +954,13 @@ def run(test, params, env): ...@@ -954,13 +954,13 @@ def run(test, params, env):
# Detach the device. # Detach the device.
if attach_device: if attach_device:
xml_file = libvirt.create_disk_xml(params) xml_file = libvirt.create_disk_xml(params)
ret = virsh.detach_device(vm_name, xml_file) ret = virsh.detach_device(vm_name, xml_file, wait_remove_event=True)
libvirt.check_exit_status(ret) libvirt.check_exit_status(ret)
if additional_guest: if additional_guest:
ret = virsh.detach_device(guest_name, xml_file) ret = virsh.detach_device(guest_name, xml_file, wait_remove_event=True)
libvirt.check_exit_status(ret) libvirt.check_exit_status(ret)
elif attach_disk: elif attach_disk:
ret = virsh.detach_disk(vm_name, targetdev) ret = virsh.detach_disk(vm_name, targetdev, wait_remove_event=True)
libvirt.check_exit_status(ret) libvirt.check_exit_status(ret)
# Check disk in vm after detachment. # Check disk in vm after detachment.
......
...@@ -332,7 +332,7 @@ def run(test, params, env): ...@@ -332,7 +332,7 @@ def run(test, params, env):
if not check_in_vm(vm, device_target, old_parts): if not check_in_vm(vm, device_target, old_parts):
test.fail("Check encryption disk in VM failed") test.fail("Check encryption disk in VM failed")
result = virsh.detach_device(vm_name, disk_xml.xml, result = virsh.detach_device(vm_name, disk_xml.xml,
debug=True) debug=True, wait_remove_event=True)
libvirt.check_exit_status(result) libvirt.check_exit_status(result)
else: else:
if not check_in_vm(vm, device_target, old_parts): if not check_in_vm(vm, device_target, old_parts):
......
...@@ -262,7 +262,7 @@ def run(test, params, env): ...@@ -262,7 +262,7 @@ def run(test, params, env):
if start_vm and not default_pool: if start_vm and not default_pool:
if gluster_disk: if gluster_disk:
ret = virsh.detach_device(vm_name, custom_disk.xml, ret = virsh.detach_device(vm_name, custom_disk.xml,
flagstr=attach_option, dargs=virsh_dargs) flagstr=attach_option, dargs=virsh_dargs, wait_remove_event=True)
libvirt.check_exit_status(ret) libvirt.check_exit_status(ret)
finally: finally:
......
...@@ -1884,7 +1884,8 @@ def run(test, params, env): ...@@ -1884,7 +1884,8 @@ def run(test, params, env):
if devices[i] == "cdrom": if devices[i] == "cdrom":
dt_options = "--config" dt_options = "--config"
ret = virsh.detach_disk(vm_name, device_targets[i], ret = virsh.detach_disk(vm_name, device_targets[i],
dt_options, **virsh_dargs) dt_options, wait_remove_event=True,
**virsh_dargs)
disk_detach_error = False disk_detach_error = False
if len(device_attach_error) > i: if len(device_attach_error) > i:
disk_detach_error = "yes" == device_attach_error[i] disk_detach_error = "yes" == device_attach_error[i]
...@@ -1933,7 +1934,7 @@ def run(test, params, env): ...@@ -1933,7 +1934,7 @@ def run(test, params, env):
for counter in range(0, iteration_times): for counter in range(0, iteration_times):
logging.info("Begin to execute attach or detach %d operations", counter) logging.info("Begin to execute attach or detach %d operations", counter)
ret = virsh.detach_device(vm_name, disks_xml[0].xml, ret = virsh.detach_device(vm_name, disks_xml[0].xml,
flagstr=attach_option, debug=True) flagstr=attach_option, debug=True, wait_remove_event=True)
libvirt.check_exit_status(ret) libvirt.check_exit_status(ret)
# Sleep 10 seconds to let VM really cleanup devices. # Sleep 10 seconds to let VM really cleanup devices.
time.sleep(10) time.sleep(10)
...@@ -1952,7 +1953,7 @@ def run(test, params, env): ...@@ -1952,7 +1953,7 @@ def run(test, params, env):
if device_attach_error[i] == "yes": if device_attach_error[i] == "yes":
continue continue
ret = virsh.detach_device(vm_name, disks_xml[i].xml, ret = virsh.detach_device(vm_name, disks_xml[i].xml,
flagstr=attach_option, **virsh_dargs) flagstr=attach_option, wait_remove_event=True, **virsh_dargs)
os.remove(disks_xml[i].xml) os.remove(disks_xml[i].xml)
libvirt.check_exit_status(ret) libvirt.check_exit_status(ret)
......
...@@ -258,7 +258,7 @@ def run(test, params, env): ...@@ -258,7 +258,7 @@ def run(test, params, env):
# Unplug disk. # Unplug disk.
if hotplug_disk: if hotplug_disk:
result = virsh.detach_device(vm_name, disk_xml.xml, result = virsh.detach_device(vm_name, disk_xml.xml,
ignore_status=True, debug=True) ignore_status=True, debug=True, wait_remove_event=True)
libvirt.check_exit_status(result, status_error) libvirt.check_exit_status(result, status_error)
finally: finally:
# Clean up backend storage and TLS # Clean up backend storage and TLS
......
...@@ -234,7 +234,7 @@ def run(test, params, env): ...@@ -234,7 +234,7 @@ def run(test, params, env):
new_part = new_parts[0] new_part = new_parts[0]
check_pr_cmds(vm, new_part) check_pr_cmds(vm, new_part)
result = virsh.detach_device(vm_name, disk_xml.xml, result = virsh.detach_device(vm_name, disk_xml.xml,
ignore_status=True, debug=True) ignore_status=True, debug=True, wait_remove_event=True)
libvirt.check_exit_status(result) libvirt.check_exit_status(result)
except virt_vm.VMStartError as e: except virt_vm.VMStartError as e:
test.fail("VM failed to start." test.fail("VM failed to start."
......
...@@ -231,7 +231,7 @@ def run(test, params, env): ...@@ -231,7 +231,7 @@ def run(test, params, env):
# Detach the disk from vm # Detach the disk from vm
result = virsh.detach_device(vm_name, disk_xml.xml, result = virsh.detach_device(vm_name, disk_xml.xml,
flagstr=attach_options, flagstr=attach_options,
ignore_status=True, debug=True) ignore_status=True, debug=True, wait_remove_event=True)
libvirt.check_exit_status(result, status_error) libvirt.check_exit_status(result, status_error)
# Check the detached disk in vm # Check the detached disk in vm
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册