|
|
9ae3a8 |
From eb8c85b01be23beabb2b61e8b32a7e20ca0fea17 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 31 Jul 2013 14:03:22 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 01/28] osdep: add qemu_get_local_state_pathname()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1375279407-13573-2-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 52863
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 1/6] osdep: add qemu_get_local_state_pathname()
|
|
|
9ae3a8 |
Bugzilla: 964304
|
|
|
9ae3a8 |
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This function returns ${prefix}/var/RELATIVE_PATHNAME on POSIX-y systems,
|
|
|
9ae3a8 |
and <CSIDL_COMMON_APPDATA>/RELATIVE_PATHNAME on Win32.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
http://msdn.microsoft.com/en-us/library/bb762494.aspx
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
[...] This folder is used for application data that is not user
|
|
|
9ae3a8 |
specific. For example, an application can store a spell-check
|
|
|
9ae3a8 |
dictionary, a database of clip art, or a log file in the
|
|
|
9ae3a8 |
CSIDL_COMMON_APPDATA folder. [...]
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
(cherry picked from commit e2ea3515a9d2d747f91dadf361afcbeb57a71500)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/qemu/osdep.h | 11 +++++++++++
|
|
|
9ae3a8 |
util/oslib-posix.c | 9 +++++++++
|
|
|
9ae3a8 |
util/oslib-win32.c | 22 ++++++++++++++++++++++
|
|
|
9ae3a8 |
3 files changed, 42 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/qemu/osdep.h | 11 +++++++++++
|
|
|
9ae3a8 |
util/oslib-posix.c | 9 +++++++++
|
|
|
9ae3a8 |
util/oslib-win32.c | 22 ++++++++++++++++++++++
|
|
|
9ae3a8 |
3 files changed, 42 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
|
|
|
9ae3a8 |
index 57d7b1f..26136f1 100644
|
|
|
9ae3a8 |
--- a/include/qemu/osdep.h
|
|
|
9ae3a8 |
+++ b/include/qemu/osdep.h
|
|
|
9ae3a8 |
@@ -204,4 +204,15 @@ const char *qemu_get_version(void);
|
|
|
9ae3a8 |
void fips_set_state(bool requested);
|
|
|
9ae3a8 |
bool fips_get_state(void);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+/* Return a dynamically allocated pathname denoting a file or directory that is
|
|
|
9ae3a8 |
+ * appropriate for storing local state.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * @relative_pathname need not start with a directory separator; one will be
|
|
|
9ae3a8 |
+ * added automatically.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * The caller is responsible for releasing the value returned with g_free()
|
|
|
9ae3a8 |
+ * after use.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+char *qemu_get_local_state_pathname(const char *relative_pathname);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
|
|
|
9ae3a8 |
index 631a1de..3dc8b1b 100644
|
|
|
9ae3a8 |
--- a/util/oslib-posix.c
|
|
|
9ae3a8 |
+++ b/util/oslib-posix.c
|
|
|
9ae3a8 |
@@ -47,6 +47,8 @@ extern int daemon(int, int);
|
|
|
9ae3a8 |
# define QEMU_VMALLOC_ALIGN getpagesize()
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+#include <glib/gprintf.h>
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
#include "config-host.h"
|
|
|
9ae3a8 |
#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
#include "trace.h"
|
|
|
9ae3a8 |
@@ -232,3 +234,10 @@ int qemu_utimens(const char *path, const struct timespec *times)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
return utimes(path, &tv[0]);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+char *
|
|
|
9ae3a8 |
+qemu_get_local_state_pathname(const char *relative_pathname)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR,
|
|
|
9ae3a8 |
+ relative_pathname);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
|
|
|
9ae3a8 |
index df2ecbd..961fbf5 100644
|
|
|
9ae3a8 |
--- a/util/oslib-win32.c
|
|
|
9ae3a8 |
+++ b/util/oslib-win32.c
|
|
|
9ae3a8 |
@@ -26,12 +26,17 @@
|
|
|
9ae3a8 |
* THE SOFTWARE.
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
#include <windows.h>
|
|
|
9ae3a8 |
+#include <glib.h>
|
|
|
9ae3a8 |
+#include <stdlib.h>
|
|
|
9ae3a8 |
#include "config-host.h"
|
|
|
9ae3a8 |
#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
#include "qemu/main-loop.h"
|
|
|
9ae3a8 |
#include "trace.h"
|
|
|
9ae3a8 |
#include "qemu/sockets.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+/* this must come after including "trace.h" */
|
|
|
9ae3a8 |
+#include <shlobj.h>
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
void *qemu_oom_check(void *ptr)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
if (ptr == NULL) {
|
|
|
9ae3a8 |
@@ -160,3 +165,20 @@ int qemu_get_thread_id(void)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
return GetCurrentThreadId();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+char *
|
|
|
9ae3a8 |
+qemu_get_local_state_pathname(const char *relative_pathname)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ HRESULT result;
|
|
|
9ae3a8 |
+ char base_path[MAX_PATH+1] = "";
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ result = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL,
|
|
|
9ae3a8 |
+ /* SHGFP_TYPE_CURRENT */ 0, base_path);
|
|
|
9ae3a8 |
+ if (result != S_OK) {
|
|
|
9ae3a8 |
+ /* misconfigured environment */
|
|
|
9ae3a8 |
+ g_critical("CSIDL_COMMON_APPDATA unavailable: %ld", (long)result);
|
|
|
9ae3a8 |
+ abort();
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", base_path,
|
|
|
9ae3a8 |
+ relative_pathname);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|