summaryrefslogtreecommitdiffstats
path: root/include/hardware/qemud.h
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2011-08-04 13:52:12 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2011-08-05 10:17:39 -0700
commit39e2630dd95ee8b9dc980fedee88966227811b1b (patch)
treefbd03e7d4e0aa6694aaf8d030be73e629df9d180 /include/hardware/qemud.h
parent4306ca7d446c26752ecd9f724590487d68a27f10 (diff)
downloadhardware_libhardware-39e2630dd95ee8b9dc980fedee88966227811b1b.zip
hardware_libhardware-39e2630dd95ee8b9dc980fedee88966227811b1b.tar.gz
hardware_libhardware-39e2630dd95ee8b9dc980fedee88966227811b1b.tar.bz2
Enable connection to QEMUD via pipe.
With the new model, we will try to connect client via pipe first, and only if the pipe connection is not available we will fall back to the socket connection. Change-Id: I7112ff3cb63e1f82a004b80b9ae579d97e15e029
Diffstat (limited to 'include/hardware/qemud.h')
-rw-r--r--include/hardware/qemud.h55
1 files changed, 32 insertions, 23 deletions
diff --git a/include/hardware/qemud.h b/include/hardware/qemud.h
index 874a32f..5c39f9c 100644
--- a/include/hardware/qemud.h
+++ b/include/hardware/qemud.h
@@ -18,10 +18,12 @@
#define ANDROID_INCLUDE_HARDWARE_QEMUD_H
#include <cutils/sockets.h>
+#include "qemu_pipe.h"
/* the following is helper code that is used by the QEMU-specific
* hardware HAL modules to communicate with the emulator program
- * through the 'qemud' multiplexing daemon.
+ * through the 'qemud' multiplexing daemon, or through the qemud
+ * pipe.
*
* see the documentation comments for details in
* development/emulator/qemud/qemud.c
@@ -64,30 +66,37 @@ qemud_channel_open(const char* name)
int fd;
int namelen = strlen(name);
char answer[2];
+ char pipe_name[256];
- /* connect to qemud control socket */
- fd = socket_local_client( "qemud",
- ANDROID_SOCKET_NAMESPACE_RESERVED,
- SOCK_STREAM );
+ /* First, try to connect to the pipe. */
+ snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", name);
+ fd = qemu_pipe_open(pipe_name);
if (fd < 0) {
- D("no qemud control socket: %s", strerror(errno));
- return -1;
- }
-
- /* send service name to connect */
- if (qemud_fd_write(fd, name, namelen) != namelen) {
- D("can't send service name to qemud: %s",
- strerror(errno));
- close(fd);
- return -1;
- }
-
- /* read answer from daemon */
- if (qemud_fd_read(fd, answer, 2) != 2 ||
- answer[0] != 'O' || answer[1] != 'K') {
- D("cant' connect to %s service through qemud", name);
- close(fd);
- return -1;
+ D("QEMUD pipe is not available for %s: %s", name, strerror(errno));
+ /* If pipe is not available, connect to qemud control socket */
+ fd = socket_local_client( "qemud",
+ ANDROID_SOCKET_NAMESPACE_RESERVED,
+ SOCK_STREAM );
+ if (fd < 0) {
+ D("no qemud control socket: %s", strerror(errno));
+ return -1;
+ }
+
+ /* send service name to connect */
+ if (qemud_fd_write(fd, name, namelen) != namelen) {
+ D("can't send service name to qemud: %s",
+ strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ /* read answer from daemon */
+ if (qemud_fd_read(fd, answer, 2) != 2 ||
+ answer[0] != 'O' || answer[1] != 'K') {
+ D("cant' connect to %s service through qemud", name);
+ close(fd);
+ return -1;
+ }
}
return fd;
}