Merge "Detect image format for qemu-nbd --format"

This commit is contained in:
Zuul 2021-09-23 13:25:33 +00:00 committed by Gerrit Code Review
commit 409fcf8ae1
1 changed files with 8 additions and 1 deletions

View File

@ -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