From bf9b70fa99aec30ba18a9421c252f3e9e934e9d7 Mon Sep 17 00:00:00 2001 From: Hu Shuai Date: Fri, 11 Nov 2022 16:32:49 +0800 Subject: [PATCH] partition: wait for 1s between mkpart and mklabel Sometimes it will fail to mkpart just after mklabel, it says that: "Partition(s) 1 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes." Wait a little time can fix this problem. Signed-off-by: Hu Shuai --- virttest/utils_test/libvirt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/virttest/utils_test/libvirt.py b/virttest/utils_test/libvirt.py index a52cd26e01..1f9d5332c3 100644 --- a/virttest/utils_test/libvirt.py +++ b/virttest/utils_test/libvirt.py @@ -799,6 +799,7 @@ def mk_part(disk, size="100M", fs_type='ext4', session=None): pat = r'(?P\d+)\s+(?P\S+)\s+(?P\S+)\s+(?P\S+)\s+' current_parts = [m.groupdict() for m in re.finditer(pat, output)] + time.sleep(1) mkpart_cmd = "parted -s -a optimal %s" % disk if current_label == 'unknown': mkpart_cmd += " mklabel %s" % disk_label @@ -1005,6 +1006,7 @@ def pre_pool(self, pool_name, pool_type, pool_target, emulated_image, if disk_label == 'dos': disk_label = 'msdos' mk_label(device_name, disk_label) + time.sleep(1) # Disk pool does not allow to create volume by virsh command, # so introduce parameter 'pre_disk_vol' to create partition(s) # by 'parted' command, the parameter is a list of partition size,