From db7280e653da1d7eb5b3a345ee22a93ceb1e3710 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Fri, 17 Sep 2021 11:03:15 +1200 Subject: [PATCH] Detect image format for qemu-nbd --format qemu-nbd will error when the image format is raw unless there is an explicit --format raw argument provided. This change adds format detection for raw and qcow2 using qemu-img info. Any other image type will depend on qemu-nbd auto-detection. Blueprint: whole-disk-default Change-Id: I628abc4cb8c46c3b2e5bfd3cd16bb6d5cc95fabe --- scripts/tripleo-mount-image | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/tripleo-mount-image b/scripts/tripleo-mount-image index b3590b09b..4c1686cec 100755 --- a/scripts/tripleo-mount-image +++ b/scripts/tripleo-mount-image @@ -92,7 +92,14 @@ remove_device () { mount_image() { set -x - qemu-nbd --connect $NBD_DEVICE $IMAGE_FILE + if qemu-img info --output json $IMAGE_FILE |grep '"format": "raw"' ; then + image_format='--format raw' + elif qemu-img info --output json $IMAGE_FILE |grep '"format": "qcow2"' ; then + image_format='--format qcow2' + else + image_format='' + fi + qemu-nbd $image_format --connect $NBD_DEVICE $IMAGE_FILE # search for the vg volume group, this is automatic in some environments vgscan