diff mbox series

[v2,4/4] io: Add /dev/fdset/ support to QIOChannelFile

Message ID 20171101142526.1006-5-ross.lagerwall@citrix.com
State New
Headers show
Series QIOChannelFile bug fixes | expand

Commit Message

Ross Lagerwall Nov. 1, 2017, 2:25 p.m. UTC
Add /dev/fdset/ support to QIOChannelFile by calling qemu_open() instead
of open() and qemu_close() instead of close(). There is a subtle
semantic change since qemu_open() automatically sets O_CLOEXEC, but this
doesn't affect any of the users of the function.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
Changed in v2:
* Split into separate patch.

 io/channel-file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Marc-André Lureau Nov. 1, 2017, 6:12 p.m. UTC | #1
On Wed, Nov 1, 2017 at 3:25 PM, Ross Lagerwall
<ross.lagerwall@citrix.com> wrote:
> Add /dev/fdset/ support to QIOChannelFile by calling qemu_open() instead
> of open() and qemu_close() instead of close(). There is a subtle
> semantic change since qemu_open() automatically sets O_CLOEXEC, but this
> doesn't affect any of the users of the function.
>
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
> Changed in v2:
> * Split into separate patch.
>
>  io/channel-file.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/io/channel-file.c b/io/channel-file.c
> index 1f2f710..db948ab 100644
> --- a/io/channel-file.c
> +++ b/io/channel-file.c
> @@ -50,7 +50,7 @@ qio_channel_file_new_path(const char *path,
>
>      ioc = QIO_CHANNEL_FILE(object_new(TYPE_QIO_CHANNEL_FILE));
>
> -    ioc->fd = open(path, flags, mode);
> +    ioc->fd = qemu_open(path, flags, mode);
>      if (ioc->fd < 0) {
>          object_unref(OBJECT(ioc));
>          error_setg_errno(errp, errno,
> @@ -74,7 +74,7 @@ static void qio_channel_file_finalize(Object *obj)
>  {
>      QIOChannelFile *ioc = QIO_CHANNEL_FILE(obj);
>      if (ioc->fd != -1) {
> -        close(ioc->fd);
> +        qemu_close(ioc->fd);
>          ioc->fd = -1;
>      }
>  }
> @@ -173,7 +173,7 @@ static int qio_channel_file_close(QIOChannel *ioc,
>  {
>      QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
>
> -    if (close(fioc->fd) < 0) {
> +    if (qemu_close(fioc->fd) < 0) {
>          error_setg_errno(errp, errno,
>                           "Unable to close file");
>          return -1;
> --
> 2.9.5
>
>
Daniel P. Berrangé Jan. 18, 2018, 1:50 p.m. UTC | #2
On Wed, Nov 01, 2017 at 02:25:26PM +0000, Ross Lagerwall wrote:
> Add /dev/fdset/ support to QIOChannelFile by calling qemu_open() instead
> of open() and qemu_close() instead of close(). There is a subtle
> semantic change since qemu_open() automatically sets O_CLOEXEC, but this
> doesn't affect any of the users of the function.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
> Changed in v2:
> * Split into separate patch.
> 
>  io/channel-file.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

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

Regards,
Daniel
diff mbox series

Patch

diff --git a/io/channel-file.c b/io/channel-file.c
index 1f2f710..db948ab 100644
--- a/io/channel-file.c
+++ b/io/channel-file.c
@@ -50,7 +50,7 @@  qio_channel_file_new_path(const char *path,
 
     ioc = QIO_CHANNEL_FILE(object_new(TYPE_QIO_CHANNEL_FILE));
 
-    ioc->fd = open(path, flags, mode);
+    ioc->fd = qemu_open(path, flags, mode);
     if (ioc->fd < 0) {
         object_unref(OBJECT(ioc));
         error_setg_errno(errp, errno,
@@ -74,7 +74,7 @@  static void qio_channel_file_finalize(Object *obj)
 {
     QIOChannelFile *ioc = QIO_CHANNEL_FILE(obj);
     if (ioc->fd != -1) {
-        close(ioc->fd);
+        qemu_close(ioc->fd);
         ioc->fd = -1;
     }
 }
@@ -173,7 +173,7 @@  static int qio_channel_file_close(QIOChannel *ioc,
 {
     QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
 
-    if (close(fioc->fd) < 0) {
+    if (qemu_close(fioc->fd) < 0) {
         error_setg_errno(errp, errno,
                          "Unable to close file");
         return -1;