]> xenbits.xensource.com Git - libvirt.git/commit
virsh vol-upload/download disallow negative offset
authorJohn Ferlan <jferlan@redhat.com>
Tue, 15 Jul 2014 12:26:28 +0000 (08:26 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 17 Jul 2014 17:15:12 +0000 (13:15 -0400)
commit570d0f6387038a6d7651b22fd555de603f07ab3b
tree4faeae23abab18431cd0d5126b07400016d67b07
parente00eb2ccfe5936e8ef42f87caf703fdaaee2b57f
virsh vol-upload/download disallow negative offset

https://bugzilla.redhat.com/show_bug.cgi?id=1087104

Commit id 'c6212539' explicitly allowed a negative value to be used for
offset and length as a shorthand for the largest value after commit id
'f18c02ec' modified virStrToLong_ui() to essentially disallow a negative
value.

However, allowing a negative value for offset ONLY worked if the negative
value was -1 since the eventual lseek() does allow a -1 to mean the end
of the file.  Providing other negative values resulted in errors such as:

$ virsh vol-download --pool default qcow3-vol2 /home/vm-images/raw \
  --offset -2 --length -1000
error: cannot download from volume qcow3-vol2
error: Unable to seek /home/vm-images/qcow3-vol2 to 18446744073709551614: Invalid argument

$

Thus, it seems unreasonable to expect or allow a negative value for offset
since the only benefit is to lseek() to the end of the file and then only
take advantage of how the OS would handle such a seek. For the purposes of
upload or download of volume data, that seems to be a no-op.  Therefore,
disallow a negative value for offset.

Additionally, modify the man page for vol-upload and vol-download to provide
more details regarding the valid values for both offset and length.
tools/virsh-volume.c
tools/virsh.pod