Skip to content

Commit

Permalink
partition: wait for 1s between mkpart and mklabel
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
hs0210 committed Jul 10, 2023
1 parent 7e880ed commit bf9b70f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ def mk_part(disk, size="100M", fs_type='ext4', session=None):
pat = r'(?P<num>\d+)\s+(?P<start>\S+)\s+(?P<end>\S+)\s+(?P<size>\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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bf9b70f

Please sign in to comment.