Skip to content

Commit

Permalink
utils_disk: add function to retrieve partitions by disk path
Browse files Browse the repository at this point in the history
On s390x, ccw disk order might change between boots.

`get_parts_list` therefore might return partitions on `vda` but
on `vdb` after reboot leading to unstable tests.

Add a new function `get_parts_list_by_path` which lists partitions
uniquely by their devno, e.g. `ccw-0.0.0009-part1`.

Signed-off-by: Sebastian Mitterle <[email protected]>
  • Loading branch information
smitterl committed Jul 27, 2023
1 parent 9742b58 commit 7890122
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions virttest/utils_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from virttest import error_context
from virttest import utils_numeric
from virttest import utils_misc
from virttest import remote

PARTITION_TABLE_TYPE_MBR = "msdos"
Expand Down Expand Up @@ -1083,6 +1084,19 @@ def linux_disk_check(session, did):
clean_partition_linux(session, did)


def get_parts_list_by_path(session=None):
"""
Get all partitions as listed on /dev/disk/by-path
"""
err, out = utils_misc.cmd_status_output("ls /dev/disk/by-path",
shell=True, session=session)
if err:
raise exceptions.TestError("Failed to list partitions in /dev/disk/by-path")
r = out.split()
logging.debug("Partitions by path: %s", r)
return r


def get_parts_list(session=None):
"""
Get all partition lists.
Expand Down

0 comments on commit 7890122

Please sign in to comment.