Message ID | 1311362154-4409-1-git-send-email-aliguori@us.ibm.com |
---|---|
State | New |
Headers | show |
On Fri, Jul 22, 2011 at 10:15 PM, Anthony Liguori <aliguori@us.ibm.com> wrote: > FS-Freeze only works with Linux. > > Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> ACK except for the unrelated stuff. It's strange how the messages arrive several hours out of order. > --- > Makefile | 2 + > hw/pc.c | 3 +- > qemu-char.c | 36 +++++++++++++++++++++++++ > qemu-config.c | 6 ++++ > qga/guest-agent-commands.c | 63 ++++++++++++++++++++++++++++++++++++------- > 5 files changed, 97 insertions(+), 13 deletions(-) > > diff --git a/Makefile b/Makefile > index f3a03ad..2e3231e 100644 > --- a/Makefile > +++ b/Makefile > @@ -188,6 +188,8 @@ $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc > test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) > test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o > > +test-linux: test-linux.o > + > test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y) > test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o > > diff --git a/hw/pc.c b/hw/pc.c > index a3e8539..2539372 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -548,8 +548,7 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val) > /* LGPL'ed VGA BIOS messages */ > case 0x501: > case 0x502: > - fprintf(stderr, "VGA BIOS panic, line %d\n", val); > - exit(1); > + exit(1 | ((val & 0x7F) << 1)); > case 0x500: > case 0x503: > #ifdef DEBUG_BIOS > diff --git a/qemu-char.c b/qemu-char.c > index fb13b28..8c18653 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -634,6 +634,41 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) > return chr; > } > > +static int handle_fd_param(QemuOpts *opts, const char *key) > +{ > + const char *value; > + > + value = qemu_opt_get(opts, key); > + if (value == NULL) { > + return -1; > + } > + > + if (qemu_isdigit(value[0])) { > + return atoi(value); > + } > + > + return monitor_get_fd(cur_mon, value); > +} > + > +static CharDriverState *qemu_chr_open_fdname(QemuOpts *opts) > +{ > + CharDriverState *chr; > + FDCharDriver *s; > + > + chr = qemu_mallocz(sizeof(CharDriverState)); > + s = qemu_mallocz(sizeof(FDCharDriver)); > + s->fd_in = handle_fd_param(opts, "fdin"); > + s->fd_out = handle_fd_param(opts, "fdout"); > + chr->opaque = s; > + chr->chr_write = fd_chr_write; > + chr->chr_update_read_handler = fd_chr_update_read_handler; > + chr->chr_close = fd_chr_close; > + > + qemu_chr_generic_open(chr); > + > + return chr; > +} > + > static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts) > { > int fd_out; > @@ -2483,6 +2518,7 @@ static const struct { > { .name = "pipe", .open = qemu_chr_open_pipe }, > { .name = "pty", .open = qemu_chr_open_pty }, > { .name = "stdio", .open = qemu_chr_open_stdio }, > + { .name = "fdname", .open = qemu_chr_open_fdname }, > #endif > #ifdef CONFIG_BRLAPI > { .name = "braille", .open = chr_baum_init }, > diff --git a/qemu-config.c b/qemu-config.c > index 93d20c6..ff6730d 100644 > --- a/qemu-config.c > +++ b/qemu-config.c > @@ -157,6 +157,12 @@ static QemuOptsList qemu_chardev_opts = { > },{ > .name = "debug", > .type = QEMU_OPT_NUMBER, > + },{ > + .name = "fdin", > + .type = QEMU_OPT_STRING, > + },{ > + .name = "fdout", > + .type = QEMU_OPT_STRING, > }, > { /* end of list */ } > }, > diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c > index 8c0d67e..e215bd3 100644 > --- a/qga/guest-agent-commands.c > +++ b/qga/guest-agent-commands.c > @@ -10,11 +10,17 @@ > * See the COPYING file in the top-level directory. > */ > > +#if defined(__linux__) > +#define CONFIG_FSFREEZE > +#endif > + > #include <glib.h> > +#if defined(CONFIG_FSFREEZE) > #include <mntent.h> > +#include <linux/fs.h> > +#endif > #include <sys/types.h> > #include <sys/ioctl.h> > -#include <linux/fs.h> > #include "qga/guest-agent-core.h" > #include "qga-qmp-commands.h" > #include "qerror.h" > @@ -22,16 +28,6 @@ > > static GAState *ga_state; > > -static void disable_logging(void) > -{ > - ga_disable_logging(ga_state); > -} > - > -static void enable_logging(void) > -{ > - ga_enable_logging(ga_state); > -} > - > /* Note: in some situations, like with the fsfreeze, logging may be > * temporarilly disabled. if it is necessary that a command be able > * to log for accounting purposes, check ga_logging_enabled() beforehand, > @@ -323,6 +319,17 @@ static void guest_file_init(void) > QTAILQ_INIT(&guest_file_state.filehandles); > } > > +#if defined(CONFIG_FSFREEZE) > +static void disable_logging(void) > +{ > + ga_disable_logging(ga_state); > +} > + > +static void enable_logging(void) > +{ > + ga_enable_logging(ga_state); > +} > + > typedef struct GuestFsfreezeMount { > char *dirname; > char *devtype; > @@ -508,11 +515,45 @@ static void guest_fsfreeze_cleanup(void) > } > } > } > +#else > +/* > + * Return status of freeze/thaw > + */ > +GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err) > +{ > + error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_status"); > + > + return 0; > +} > + > +/* > + * Walk list of mounted file systems in the guest, and freeze the ones which > + * are real local file systems. > + */ > +int64_t qmp_guest_fsfreeze_freeze(Error **err) > +{ > + error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_freeze"); > + > + return 0; > +} > + > +/* > + * Walk list of frozen file systems in the guest, and thaw them. > + */ > +int64_t qmp_guest_fsfreeze_thaw(Error **err) > +{ > + error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_thaw"); > + > + return 0; > +} > +#endif > > /* register init/cleanup routines for stateful command groups */ > void ga_command_state_init(GAState *s, GACommandState *cs) > { > ga_state = s; > +#if defined(CONFIG_FSFREEZE) > ga_command_state_add(cs, guest_fsfreeze_init, guest_fsfreeze_cleanup); > +#endif > ga_command_state_add(cs, guest_file_init, NULL); > } > -- > 1.7.4.1 > >
diff --git a/Makefile b/Makefile index f3a03ad..2e3231e 100644 --- a/Makefile +++ b/Makefile @@ -188,6 +188,8 @@ $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o +test-linux: test-linux.o + test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y) test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o diff --git a/hw/pc.c b/hw/pc.c index a3e8539..2539372 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -548,8 +548,7 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val) /* LGPL'ed VGA BIOS messages */ case 0x501: case 0x502: - fprintf(stderr, "VGA BIOS panic, line %d\n", val); - exit(1); + exit(1 | ((val & 0x7F) << 1)); case 0x500: case 0x503: #ifdef DEBUG_BIOS diff --git a/qemu-char.c b/qemu-char.c index fb13b28..8c18653 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -634,6 +634,41 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) return chr; } +static int handle_fd_param(QemuOpts *opts, const char *key) +{ + const char *value; + + value = qemu_opt_get(opts, key); + if (value == NULL) { + return -1; + } + + if (qemu_isdigit(value[0])) { + return atoi(value); + } + + return monitor_get_fd(cur_mon, value); +} + +static CharDriverState *qemu_chr_open_fdname(QemuOpts *opts) +{ + CharDriverState *chr; + FDCharDriver *s; + + chr = qemu_mallocz(sizeof(CharDriverState)); + s = qemu_mallocz(sizeof(FDCharDriver)); + s->fd_in = handle_fd_param(opts, "fdin"); + s->fd_out = handle_fd_param(opts, "fdout"); + chr->opaque = s; + chr->chr_write = fd_chr_write; + chr->chr_update_read_handler = fd_chr_update_read_handler; + chr->chr_close = fd_chr_close; + + qemu_chr_generic_open(chr); + + return chr; +} + static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts) { int fd_out; @@ -2483,6 +2518,7 @@ static const struct { { .name = "pipe", .open = qemu_chr_open_pipe }, { .name = "pty", .open = qemu_chr_open_pty }, { .name = "stdio", .open = qemu_chr_open_stdio }, + { .name = "fdname", .open = qemu_chr_open_fdname }, #endif #ifdef CONFIG_BRLAPI { .name = "braille", .open = chr_baum_init }, diff --git a/qemu-config.c b/qemu-config.c index 93d20c6..ff6730d 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -157,6 +157,12 @@ static QemuOptsList qemu_chardev_opts = { },{ .name = "debug", .type = QEMU_OPT_NUMBER, + },{ + .name = "fdin", + .type = QEMU_OPT_STRING, + },{ + .name = "fdout", + .type = QEMU_OPT_STRING, }, { /* end of list */ } }, diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c index 8c0d67e..e215bd3 100644 --- a/qga/guest-agent-commands.c +++ b/qga/guest-agent-commands.c @@ -10,11 +10,17 @@ * See the COPYING file in the top-level directory. */ +#if defined(__linux__) +#define CONFIG_FSFREEZE +#endif + #include <glib.h> +#if defined(CONFIG_FSFREEZE) #include <mntent.h> +#include <linux/fs.h> +#endif #include <sys/types.h> #include <sys/ioctl.h> -#include <linux/fs.h> #include "qga/guest-agent-core.h" #include "qga-qmp-commands.h" #include "qerror.h" @@ -22,16 +28,6 @@ static GAState *ga_state; -static void disable_logging(void) -{ - ga_disable_logging(ga_state); -} - -static void enable_logging(void) -{ - ga_enable_logging(ga_state); -} - /* Note: in some situations, like with the fsfreeze, logging may be * temporarilly disabled. if it is necessary that a command be able * to log for accounting purposes, check ga_logging_enabled() beforehand, @@ -323,6 +319,17 @@ static void guest_file_init(void) QTAILQ_INIT(&guest_file_state.filehandles); } +#if defined(CONFIG_FSFREEZE) +static void disable_logging(void) +{ + ga_disable_logging(ga_state); +} + +static void enable_logging(void) +{ + ga_enable_logging(ga_state); +} + typedef struct GuestFsfreezeMount { char *dirname; char *devtype; @@ -508,11 +515,45 @@ static void guest_fsfreeze_cleanup(void) } } } +#else +/* + * Return status of freeze/thaw + */ +GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err) +{ + error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_status"); + + return 0; +} + +/* + * Walk list of mounted file systems in the guest, and freeze the ones which + * are real local file systems. + */ +int64_t qmp_guest_fsfreeze_freeze(Error **err) +{ + error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_freeze"); + + return 0; +} + +/* + * Walk list of frozen file systems in the guest, and thaw them. + */ +int64_t qmp_guest_fsfreeze_thaw(Error **err) +{ + error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_thaw"); + + return 0; +} +#endif /* register init/cleanup routines for stateful command groups */ void ga_command_state_init(GAState *s, GACommandState *cs) { ga_state = s; +#if defined(CONFIG_FSFREEZE) ga_command_state_add(cs, guest_fsfreeze_init, guest_fsfreeze_cleanup); +#endif ga_command_state_add(cs, guest_file_init, NULL); }
FS-Freeze only works with Linux. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- Makefile | 2 + hw/pc.c | 3 +- qemu-char.c | 36 +++++++++++++++++++++++++ qemu-config.c | 6 ++++ qga/guest-agent-commands.c | 63 ++++++++++++++++++++++++++++++++++++------- 5 files changed, 97 insertions(+), 13 deletions(-)