Received: from eggs.gnu.org ([2001:4830:134:3::10]:37319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5FZP-00064Y-7k for qemu-devel@nongnu.org; Tue, 24 May 2016 12:52:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5FZL-0001Pf-Ux for qemu-devel@nongnu.org; Tue, 24 May 2016 12:52:39 -0400 References: <1463470536-8981-1-git-send-email-famz@redhat.com> <1463470536-8981-10-git-send-email-famz@redhat.com> From: Max Reitz Message-ID: Date: Tue, 24 May 2016 18:52:23 +0200 MIME-Version: 1.0 In-Reply-To: <1463470536-8981-10-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MA3h7eS85XCULaAONS3Jk5FGwaiK7COn3" Subject: Re: [Qemu-devel] [PATCH v5 09/27] osdep: Introduce qemu_dup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Jeff Cody , Markus Armbruster , Eric Blake , John Snow , qemu-block@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, den@openvz.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MA3h7eS85XCULaAONS3Jk5FGwaiK7COn3 From: Max Reitz To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Jeff Cody , Markus Armbruster , Eric Blake , John Snow , qemu-block@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, den@openvz.org, stefanha@redhat.com Message-ID: Subject: Re: [PATCH v5 09/27] osdep: Introduce qemu_dup References: <1463470536-8981-1-git-send-email-famz@redhat.com> <1463470536-8981-10-git-send-email-famz@redhat.com> In-Reply-To: <1463470536-8981-10-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.05.2016 09:35, Fam Zheng wrote: > This takes care +of > both the CLOEXEC flag and fd-path mapping for image > locking. >=20 > Signed-off-by: Fam Zheng > --- > include/qemu/osdep.h | 1 + > util/osdep.c | 6 ++++++ > 2 files changed, 7 insertions(+) >=20 > diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h > index 81913a7..0e51279 100644 > --- a/include/qemu/osdep.h > +++ b/include/qemu/osdep.h > @@ -266,6 +266,7 @@ int qemu_madvise(void *addr, size_t len, int advice= ); > int qemu_open(const char *name, int flags, ...); > int qemu_close(int fd); > int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); > +int qemu_dup(int fd); > int qemu_unlock_fd(int fd, int64_t start, int64_t len); > =20 > #if defined(__HAIKU__) && defined(__i386__) > diff --git a/util/osdep.c b/util/osdep.c > index 9e5d7fa..966bc32 100644 > --- a/util/osdep.c > +++ b/util/osdep.c > @@ -267,6 +267,12 @@ int qemu_unlock_fd(int fd, int64_t start, int64_t = len) > return qemu_lock_fcntl(fd, start, len, F_UNLCK); > } > =20 > +int qemu_dup(int fd) > +{ > + return qemu_dup_flags(fd, 0); > +} I don't think we have this function on Windows. Maybe you don't need qemu_dup() on Windows, then it would make sense to wrap it in an appropriate #ifndef. Also, I'm not sure how useful it is to return -1 on error with errno being set. Since this is a public function, maybe it makes more sense to return -errno then. Max > + > + > /* > * A variant of write(2) which handles partial write. > * >=20 --MA3h7eS85XCULaAONS3Jk5FGwaiK7COn3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXRIbHAAoJEDuxQgLoOKytF2MH/3CpIFEibuY5i3f7VD3PjnA+ ft+WGaI4akIuiK7twOoGQnqZi3Sv4ELG/IAtbSElOc7P1MCLpbLLozHjGMkoozKA EhKADomn/UxHaTyE+HtN8NZDuiHfm1dscczQgLqUD60JJeqFitrOgSuAbFjP+RUO riXGnmt6/Wp2ov8Vc4iHfZrwx3vu39hkmnnaJ1u1SftRnaFcYDPxm8OD2u+qJfdM SfRXBXyy16KzUoJ+GzqUfTSGVApWDc6I1s0skCMVnB49q+Cw8NCXOME27xOgT6qx 1/TOh8xt5ZkmbmywUsNeAirnTaOmS2ci73BQkt7ICukMinNDd7tH2yy4xzANtEk= =sb3B -----END PGP SIGNATURE----- --MA3h7eS85XCULaAONS3Jk5FGwaiK7COn3--