]> xenbits.xensource.com Git - libvirt.git/commitdiff
virfile: add comment about the use of SEEK_END in virFileDiskCopy
authorClaudio Fontana <cfontana@suse.de>
Fri, 6 May 2022 13:10:50 +0000 (15:10 +0200)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 6 May 2022 14:34:30 +0000 (15:34 +0100)
Signed-off-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virfile.c

index df16ea5d1e74df331dcef3387281b8099ee6a724..e4522b5f672a99cde127a7c7e7b818e258078608 100644 (file)
@@ -4741,6 +4741,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"));