ia64/xen-unstable

view tools/libxc/xc_io.h @ 4895:24dfd18ea63e

bitkeeper revision 1.1159.258.120 (42848bfe8kMyWWcBA64rq7h7l7AyoA)

Shadow code bug fix (found by Ian) that was breaking refcounts, and subsequently
causing migration problems.
author mafetter@fleming.research
date Fri May 13 11:14:06 2005 +0000 (2005-05-13)
parents b5bf5415d400
children d56c3246d889 18d709f72233
line source
1 #ifndef __XC_XC_IO_H__
2 #define __XC_XC_IO_H__
4 #include <errno.h>
5 #include "xc_private.h"
6 #include "iostream.h"
8 typedef struct XcIOContext {
9 u32 domain;
10 unsigned flags;
11 int resource;
12 IOStream *io;
13 IOStream *info;
14 IOStream *err;
15 char *vmconfig;
16 int vmconfig_n;
17 int (*suspend)(void *data, u32 domain);
18 int (*configure)(void *data, u32 domain, char *vmconfig, int vmconfig_n);
19 void *data;
20 } XcIOContext;
22 static inline int xcio_suspend_domain(XcIOContext *ctxt){
23 int err = 0;
25 if(ctxt->suspend){
26 err = ctxt->suspend(ctxt->data, ctxt->domain);
27 } else {
28 err = -EINVAL;
29 }
30 return err;
31 }
33 static inline int xcio_configure_domain(XcIOContext *ctxt){
34 int err = 0;
36 if(ctxt->configure){
37 err = ctxt->configure(ctxt->data, ctxt->domain, ctxt->vmconfig, ctxt->vmconfig_n);
38 } else {
39 err = -EINVAL;
40 }
41 return err;
42 }
44 static inline int xcio_read(XcIOContext *ctxt, void *buf, int n){
45 int rc;
47 rc = IOStream_read(ctxt->io, buf, n);
48 return (rc == n ? 0 : -1);
49 }
51 static inline int xcio_write(XcIOContext *ctxt, void *buf, int n){
52 int rc;
54 rc = IOStream_write(ctxt->io, buf, n);
55 return (rc == n ? 0 : -1);
56 }
58 static inline int xcio_flush(XcIOContext *ctxt){
59 return IOStream_flush(ctxt->io);
60 }
62 extern void xcio_error(XcIOContext *ctxt, const char *msg, ...);
63 extern void xcio_info(XcIOContext *ctxt, const char *msg, ...);
65 #define xcio_perror(_ctxt, _msg...) \
66 xcio_error(_ctxt, "(errno %d %s)" _msg, errno, strerror(errno), ## _msg)
68 #endif /* ! __XC_XC_IO_H__ */