aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-15 15:51:35 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-15 15:51:35 +0000
commit03ff3ca30f29f422ebfd10d2bee1393efb4d4f7a (patch)
treea910207407d9f3b1de0c0cd95299c7fe72065675 /osdep.c
parentDefine a few structures instead of including a file, add "static" (diff)
downloadqemu-kvm-03ff3ca30f29f422ebfd10d2bee1393efb4d4f7a.tar.gz
qemu-kvm-03ff3ca30f29f422ebfd10d2bee1393efb4d4f7a.tar.bz2
qemu-kvm-03ff3ca30f29f422ebfd10d2bee1393efb4d4f7a.zip
Use common objects for qemu-img and qemu-nbd
Right now, we sprinkle #if defined(QEMU_IMG) && defined(QEMU_NBD) all over the code. It's ugly and causes us to have to build multiple object files for linking against qemu and the tools. This patch introduces a new file, qemu-tool.c which contains enough for qemu-img, qemu-nbd, and QEMU to all share the same objects. This also required getting qemu-nbd to be a bit more Windows friendly. I also changed the Windows block-raw to use normal IO instead of overlapping IO since we don't actually do AIO yet on Windows. I changed the various #if 0's to #if WIN32_AIO to make it easier for someone to eventually fix AIO on Windows. After this patch, there are no longer any #ifdef's related to qemu-img and qemu-nbd. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5226 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'osdep.c')
-rw-r--r--osdep.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/osdep.c b/osdep.c
index a49efba01..683aad0f0 100644
--- a/osdep.c
+++ b/osdep.c
@@ -45,6 +45,8 @@
#include <malloc.h>
#endif
+#include "qemu_socket.h"
+
#if defined(_WIN32)
void *qemu_memalign(size_t alignment, size_t size)
{
@@ -283,3 +285,28 @@ int qemu_gettimeofday(qemu_timeval *tp)
return 0;
}
#endif /* _WIN32 */
+
+
+#ifdef _WIN32
+void socket_set_nonblock(int fd)
+{
+ unsigned long opt = 1;
+ ioctlsocket(fd, FIONBIO, &opt);
+}
+
+int inet_aton(const char *cp, struct in_addr *ia)
+{
+ uint32_t addr = inet_addr(cp);
+ if (addr == 0xffffffff)
+ return 0;
+ ia->s_addr = addr;
+ return 1;
+}
+#else
+void socket_set_nonblock(int fd)
+{
+ int f;
+ f = fcntl(fd, F_GETFL);
+ fcntl(fd, F_SETFL, f | O_NONBLOCK);
+}
+#endif