Skip to content

Commit

Permalink
image-info: include the image format
Browse files Browse the repository at this point in the history
Use qemu-img to query the image format and include that in the report.

Signed-off-by: Tom Gundersen <[email protected]>
  • Loading branch information
teg authored and larskarlitski committed Sep 30, 2019
1 parent bf3d7fc commit e43955a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/image-info
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def subprocess_check_output(argv, parse_fn=None):
return parse_fn(output) if parse_fn else output


def read_image_format(device):
qemu = subprocess_check_output(["qemu-img", "info", "--output=json", device], json.loads)
return qemu["format"]


def read_partition_table(device):
sfdisk = subprocess_check_output(["sfdisk", "--json", device], json.loads)
ptable = sfdisk["partitiontable"]
Expand Down Expand Up @@ -84,6 +89,7 @@ def read_bls_conf(filename):

report = {}
with nbd_connect(image) as device:
report["image-format"] = read_image_format(image)
report["bootloader"] = read_bootloader_type(device)
report["partition_table"], report["partitions"] = read_partition_table(device)

Expand Down

0 comments on commit e43955a

Please sign in to comment.