Commit cf5b888d authored by Nikos Skalkotos's avatar Nikos Skalkotos

Merge branch 'hotfix-0.20.2'

parents d7d7934f ab872807
2016-11-10, v0.20.2
* Fix a bug where the disk was truncated to the size of the image file
if the used disk template was "file" or "sharedfile"
* Make image copying work when using userspace disk URIs
2016-10-4, v0.20.1
* Fix a "no properly formatted MD5 checksum lines found" bug in
snf-image-update-helper
snf-image-update-helper
2016-10-3, v0.20
* Add support for NetworkManager in CofigureNetwork configuration task
......
__version__ = "0.20.1"
__version__ = "0.20.2"
......@@ -31,6 +31,7 @@ KVM="kvm"
MD5SUM="md5sum"
BLOCKDEV="blockdev"
DD="dd"
QEMU_NBD="qemu-nbd"
# Temporary use stderr as monitoring file descriptor.
# `create' will overwrite this
......@@ -234,6 +235,43 @@ losetup_disk() {
fi
}
map_uri() {
# Use qemu-nbd to map a URI to a block device
local disk bdev max i rc
disk="$1"
# FIXME: we probably need to check if NBD is compiled as a module.
modprobe nbd # just to be on the safe side
if [ -f /sys/module/nbd/parameters/nbds_max ]; then
max=$(cat /sys/module/nbd/parameters/nbds_max)
else
log_error "NBD module is not loaded correctly"
exit 1
fi
for ((i=0; i<max; i++)); do
set +e
$QEMU_NBD -c "/dev/nbd$i" "$disk"
rc=$?
set -e
if [ $rc -eq 0 ]; then
add_cleanup $QEMU_NBD -d "/dev/nbd$i"
break
else
log_warning "Unable to map \`$disk' to /dev/nbd$i"
fi
done
if [ $i -eq $max ]; then
log_error "Could not find suitable NBD device to map: \`$disk'"
exit 1
fi
echo "/dev/nbd$i"
}
find_disk() {
local idx path uri
......@@ -245,10 +283,11 @@ find_disk() {
# Here we check if we have a valid disk path (block device or regular file)
if [ -b "$path" -o -f "$path" ]; then
echo $path
# Otherwise we choose the userspace URI and
# hope that snf-image can handle it
elif [ -n "$uri" ]; then
echo $uri
#TODO: Mapping a userspace disk URI to a block device is not the best
# thing to do, but until we implement another way to copy the content
# of the image into the VM's disk this must be done.
map_uri $uri
else
log_error "Disk information not exported by Ganeti"
exit 1
......
......@@ -170,9 +170,9 @@ if [ "$BACKEND_TYPE" = "local" ]; then
# Deploying an image file on a target block device is a streaming copy
# operation. Enable the direct I/O flag on the output fd to avoid polluting
# the host cache with useless data.
$monitor $DD bs=4M if="$image_file" of="$target" oflag=direct iflag=fullblock
$monitor $DD bs=4M if="$image_file" of="$target" oflag=direct iflag=fullblock conv=notrunc
else
$image_cmd | $monitor $DD bs=4M of="$target" oflag=direct iflag=fullblock
$image_cmd | $monitor $DD bs=4M of="$target" oflag=direct iflag=fullblock conv=notrunc
fi
report_info "Image copy finished."
......
m4_define([devflow_version], [0.20.1])
m4_define([devflow_version], [0.20.2])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment