On 10/30/2015 11:54 PM, Eduardo Habkost wrote:
On Fri, Oct 30, 2015 at 01:56:01PM +0800, Xiao Guangrong wrote:
There are three places use the some logic to get the page size on
the file path or file fd

This patch introduces qemu_file_get_page_size() to unify the code

Signed-off-by: Xiao Guangrong <guangrong.x...@linux.intel.com>
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 914cef5..ad94c5a 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -360,6 +360,22 @@ static size_t fd_getpagesize(int fd)
      return getpagesize();

+size_t qemu_file_get_page_size(const char *path)
+    size_t size = 0;
+    int fd = qemu_open(path, O_RDONLY);
+    if (fd < 0) {
+        fprintf(stderr, "Could not open %s.\n", path);
+        goto exit;

Have you considered using a Error** argument here?


But it looks it a good way to detect error by check if Error
is NULL. Will use it. :)

To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to