mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
qemu-nbd: Shrink image size by specified offset
When --offset is set the apparent device size has to be adjusted accordingly. Otherwise client may request read/write beyond the file end which would fail. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> Message-Id: <8a31654cb182932db78b95aae1e904fc2bd1c465.1475698895.git.tgolembi@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
fbe7e3327a
commit
e424b6550f
1 changed files with 8 additions and 0 deletions
|
@ -901,6 +901,14 @@ int main(int argc, char **argv)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (dev_offset >= fd_size) {
|
||||
error_report("Offset (%lld) has to be smaller than the image size "
|
||||
"(%lld)",
|
||||
(long long int)dev_offset, (long long int)fd_size);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fd_size -= dev_offset;
|
||||
|
||||
if (partition != -1) {
|
||||
ret = find_partition(blk, partition, &dev_offset, &fd_size);
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Reference in a new issue