Revision 846e2e49 qemu-char.c
b/qemu-char.c | ||
---|---|---|
841 | 841 |
return chr; |
842 | 842 |
} |
843 | 843 |
|
844 |
static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts) |
|
845 |
{ |
|
846 |
int fd_out; |
|
847 |
|
|
848 |
TFR(fd_out = qemu_open(qemu_opt_get(opts, "path"), |
|
849 |
O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666)); |
|
850 |
if (fd_out < 0) { |
|
851 |
return NULL; |
|
852 |
} |
|
853 |
return qemu_chr_open_fd(-1, fd_out); |
|
854 |
} |
|
855 |
|
|
856 | 844 |
static CharDriverState *qemu_chr_open_pipe(QemuOpts *opts) |
857 | 845 |
{ |
858 | 846 |
int fd_in, fd_out; |
... | ... | |
1989 | 1977 |
return qemu_chr_open_win_file(GetStdHandle(STD_OUTPUT_HANDLE)); |
1990 | 1978 |
} |
1991 | 1979 |
|
1992 |
static CharDriverState *qemu_chr_open_win_file_out(QemuOpts *opts) |
|
1993 |
{ |
|
1994 |
const char *file_out = qemu_opt_get(opts, "path"); |
|
1995 |
HANDLE fd_out; |
|
1996 |
|
|
1997 |
fd_out = CreateFile(file_out, GENERIC_WRITE, FILE_SHARE_READ, NULL, |
|
1998 |
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); |
|
1999 |
if (fd_out == INVALID_HANDLE_VALUE) { |
|
2000 |
return NULL; |
|
2001 |
} |
|
2002 |
|
|
2003 |
return qemu_chr_open_win_file(fd_out); |
|
2004 |
} |
|
2005 |
|
|
2006 | 1980 |
static int win_stdio_write(CharDriverState *chr, const uint8_t *buf, int len) |
2007 | 1981 |
{ |
2008 | 1982 |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); |
... | ... | |
3202 | 3176 |
|
3203 | 3177 |
#endif |
3204 | 3178 |
|
3179 |
static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend, |
|
3180 |
Error **errp) |
|
3181 |
{ |
|
3182 |
const char *path = qemu_opt_get(opts, "path"); |
|
3183 |
|
|
3184 |
if (path == NULL) { |
|
3185 |
error_setg(errp, "chardev: file: no filename given"); |
|
3186 |
return; |
|
3187 |
} |
|
3188 |
backend->file = g_new0(ChardevFile, 1); |
|
3189 |
backend->file->out = g_strdup(path); |
|
3190 |
} |
|
3191 |
|
|
3205 | 3192 |
typedef struct CharDriver { |
3206 | 3193 |
const char *name; |
3207 | 3194 |
/* old, pre qapi */ |
... | ... | |
3770 | 3757 |
register_char_driver("socket", qemu_chr_open_socket); |
3771 | 3758 |
register_char_driver("udp", qemu_chr_open_udp); |
3772 | 3759 |
register_char_driver("memory", qemu_chr_open_ringbuf); |
3760 |
register_char_driver_qapi("file", CHARDEV_BACKEND_KIND_FILE, |
|
3761 |
qemu_chr_parse_file_out); |
|
3773 | 3762 |
#ifdef _WIN32 |
3774 |
register_char_driver("file", qemu_chr_open_win_file_out); |
|
3775 | 3763 |
register_char_driver("pipe", qemu_chr_open_win_pipe); |
3776 | 3764 |
register_char_driver("console", qemu_chr_open_win_con); |
3777 | 3765 |
register_char_driver("serial", qemu_chr_open_win); |
3778 | 3766 |
register_char_driver("stdio", qemu_chr_open_win_stdio); |
3779 | 3767 |
#else |
3780 |
register_char_driver("file", qemu_chr_open_file_out); |
|
3781 | 3768 |
register_char_driver("pipe", qemu_chr_open_pipe); |
3782 | 3769 |
register_char_driver("stdio", qemu_chr_open_stdio); |
3783 | 3770 |
#endif |
Also available in: Unified diff