ia64/xen-unstable

view tools/libxc/xc_io.h @ 2422:2274a0386cc9

bitkeeper revision 1.1159.69.5 (4138e882jA1YaR_OfTfNHe_uT4PDIg)

trivial
author iap10@labyrinth.cl.cam.ac.uk
date Fri Sep 03 21:56:18 2004 +0000 (2004-09-03)
parents 095e969226c4
children 0f827b0e0801 0a4b76b6b5a0
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 IOStream *io;
12 IOStream *info;
13 IOStream *err;
14 char *vmconfig;
15 int vmconfig_n;
16 int (*suspend)(u32 domain, void *data);
17 void *data;
18 } XcIOContext;
20 static inline int xcio_suspend_domain(XcIOContext *ctxt){
21 int err = 0;
23 if(ctxt->suspend){
24 err = ctxt->suspend(ctxt->domain, ctxt->data);
25 } else {
26 err = -EINVAL;
27 }
28 return err;
29 }
31 static inline int xcio_read(XcIOContext *ctxt, void *buf, int n){
32 int rc;
34 rc = IOStream_read(ctxt->io, buf, n);
35 return (rc == n ? 0 : rc);
36 }
38 static inline int xcio_write(XcIOContext *ctxt, void *buf, int n){
39 int rc;
41 rc = IOStream_write(ctxt->io, buf, n);
42 return (rc == n ? 0 : rc);
43 }
45 static inline int xcio_flush(XcIOContext *ctxt){
46 return IOStream_flush(ctxt->io);
47 }
49 extern void xcio_error(XcIOContext *ctxt, const char *msg, ...);
50 extern void xcio_info(XcIOContext *ctxt, const char *msg, ...);
52 #define xcio_perror(_ctxt, _msg...) \
53 xcio_error(_ctxt, "(errno %d %s)" _msg, errno, strerror(errno), ## _msg)
55 #endif /* ! __XC_XC_IO_H__ */