[libvirt RFCv6 06/27] virfile: add comment about the use of SEEK_END in virFileDiskCopy

Claudio Fontana posted 27 patches 3 years, 9 months ago
There is a newer version of this series
[libvirt RFCv6 06/27] virfile: add comment about the use of SEEK_END in virFileDiskCopy
Posted by Claudio Fontana 3 years, 9 months ago
Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
 src/util/virfile.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 87d3e53819..64d7f6948b 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -4758,6 +4758,10 @@ virFileDiskCopy(int disk_fd, const char *disk_path, int remote_fd, const char *r
     if (!p.isBlockDev && p.isDirect) {
         off_t off;
         if (p.isWrite) {
+            /*
+             * note: for write we do not only check that disk_fd is seekable,
+             * we also want to know that the file is empty, so we need SEEK_END.
+             */
             if ((off = lseek(disk_fd, 0, SEEK_END)) != 0) {
                 virReportSystemError(off < 0 ? errno : EINVAL, "%s",
                                      _("O_DIRECT write needs empty seekable file"));
-- 
2.35.3
Re: [libvirt RFCv6 06/27] virfile: add comment about the use of SEEK_END in virFileDiskCopy
Posted by Daniel P. Berrangé 3 years, 9 months ago
On Thu, May 05, 2022 at 02:52:20PM +0200, Claudio Fontana wrote:
> Signed-off-by: Claudio Fontana <cfontana@suse.de>
> ---
>  src/util/virfile.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|