Files
xen/tools/libxc/xc_io.h
T
mjw@wray-m-3.hpl.hp.com 4ab333591a bitkeeper revision 1.1062.3.2 (40f29f095EmGaaKsbz1zoQ1AZH6dQw)
Integrating save/migrate handling with xfrd.
Add suspend callback to save.
2004-07-12 14:24:09 +00:00

59 lines
1.2 KiB
C

#ifndef __XC_XC_IO_H__
#define __XC_XC_IO_H__
#include <errno.h>
#include "xc_private.h"
#include "iostream.h"
typedef struct XcIOContext {
u32 domain;
unsigned flags;
IOStream *io;
IOStream *info;
IOStream *err;
char *vmconfig;
int vmconfig_n;
int (*suspend)(u32 domain, void *data);
void *data;
} XcIOContext;
static inline int xcio_suspend_domain(XcIOContext *ctxt){
int err = 0;
if(ctxt->suspend){
err = ctxt->suspend(ctxt->domain, ctxt->data);
} else {
err = -EINVAL;
}
return err;
}
static inline int xcio_read(XcIOContext *ctxt, void *buf, int n){
int rc;
rc = IOStream_read(ctxt->io, buf, n);
return (rc == n ? 0 : rc);
}
static inline int xcio_write(XcIOContext *ctxt, void *buf, int n){
int rc;
rc = IOStream_write(ctxt->io, buf, n);
return (rc == n ? 0 : rc);
}
static inline int xcio_flush(XcIOContext *ctxt){
return IOStream_flush(ctxt->io);
}
extern void xcio_error(XcIOContext *ctxt, const char *msg, ...);
extern void xcio_info(XcIOContext *ctxt, const char *msg, ...);
#define xcio_perror(_ctxt, _msg...) \
xcio_error(_ctxt, "(errno %d %s)" _msg, errno, strerror(errno), ## _msg)
#endif /* ! __XC_XC_IO_H__ */