Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image-info: include the image format #10

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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