Re: [PATCH v5 4/6] block: Convert open calls to qemu_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 07/25/2012 03:22 PM, Eric Blake wrote:
On 07/23/2012 07:08 AM, Corey Bryant wrote:
This patch converts all block layer open calls to qemu_open.

Note that this adds the O_CLOEXEC flag to the changed open paths
when the O_CLOEXEC macro is defined.

Is it actually adding O_CLOEXEC, or just the ability to use O_CLOEXEC?

It is adding O_CLOEXEC in qemu_open() on the open() call (as long as it is defined).


Or is the actual change that the end result is that the fd now has
FD_CLOEXEC set unconditionally, whether by O_CLOEXEC (which the caller
need not pass) or by fcntl()?


The statement in the commit message isn't referring to anything dealing with qemu_dup(). The statement is specifically talking about the open() call in qemu_open(), and the point is to alert folks that old open() calls are now being routed through qemu_open() and likely are using the O_CLOEXEC flag, which is new behavior.

+++ b/block/raw-posix.c
@@ -572,8 +572,8 @@ static int raw_create(const char *filename, QEMUOptionParameter *options)
          options++;
      }

-    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
-              0644);
+    fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
+                   0644);

After all, I don't see O_CLOEXEC used here.


That's right.  qemu_open() adds O_CLOEXEC on the open() call.

      if (fd < 0) {
          result = -errno;
      } else {
@@ -846,7 +846,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
          if ( bsdPath[ 0 ] != '\0' ) {
              strcat(bsdPath,"s0");
              /* some CDs don't have a partition 0 */
-            fd = open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);
+            fd = qemu_open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);

Also, I still stand by my earlier claim that we don't need O_LARGEFILE
here (we should already be configuring for 64-bit off_t by default),
although cleaning that up is probably worth an independent commit.


I have a note to get rid of O_LARGEFILE as a separate follow-on patch.


+++ b/block/vdi.c
@@ -653,8 +653,9 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options)
          options++;
      }

-    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
-              0644);
+    fd = qemu_open(filename,
+                   O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
+                   0644);

Another pointless O_LARGEFILE, and so forth.


Yep.

--
Regards,
Corey


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]