qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v3 2/4] util: introduce qemu_open and qemu_create with error


From: Eric Blake
Subject: Re: [PATCH v3 2/4] util: introduce qemu_open and qemu_create with error reporting
Date: Fri, 24 Jul 2020 09:02:03 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 7/24/20 8:25 AM, Daniel P. Berrangé wrote:
This introduces two new helper metohds

   int qemu_open(const char *name, int flags, Error **errp);
   int qemu_create(const char *name, int flags, mode_t mode, Error **errp);

Note that with this design we no longer require or even accept the
O_CREAT flag. Avoiding overloading the two distinct operations
means we can avoid variable arguments which would prevent 'errp' from
being the last argument. It also gives us a guarantee that the 'mode' is
given when creating files, avoiding a latent security bug.

I like it.


Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
  include/qemu/osdep.h |  6 ++++
  util/osdep.c         | 78 ++++++++++++++++++++++++++++++++++++--------
  2 files changed, 71 insertions(+), 13 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 3a16e58932..ca24ebe211 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -494,7 +494,13 @@ int qemu_madvise(void *addr, size_t len, int advice);
  int qemu_mprotect_rwx(void *addr, size_t size);
  int qemu_mprotect_none(void *addr, size_t size);
+/*
+ * Don't introduce new usage of this function, prefer the following
+ * qemu_open/qemu_create that take a "Error **errp"

s/a /an /

Reviewed-by: Eric Blake <eblake@redhat.com>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]