Commit 83ab7950d23f037a665d17806fc903ca3565510c
1 parent
f99ed40a
Revert r4979 since it breaks the monitor
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5028 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
20 additions
and
16 deletions
console.h
@@ -160,7 +160,6 @@ extern uint8_t _translate_keycode(const int key); | @@ -160,7 +160,6 @@ extern uint8_t _translate_keycode(const int key); | ||
160 | does not need to include console.h */ | 160 | does not need to include console.h */ |
161 | /* monitor.c */ | 161 | /* monitor.c */ |
162 | void monitor_init(CharDriverState *hd, int show_banner); | 162 | void monitor_init(CharDriverState *hd, int show_banner); |
163 | -void monitor_start_input(void); | ||
164 | void term_puts(const char *str); | 163 | void term_puts(const char *str); |
165 | void term_vprintf(const char *fmt, va_list ap); | 164 | void term_vprintf(const char *fmt, va_list ap); |
166 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); | 165 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); |
monitor.c
@@ -76,6 +76,8 @@ static term_cmd_t info_cmds[]; | @@ -76,6 +76,8 @@ static term_cmd_t info_cmds[]; | ||
76 | static uint8_t term_outbuf[1024]; | 76 | static uint8_t term_outbuf[1024]; |
77 | static int term_outbuf_index; | 77 | static int term_outbuf_index; |
78 | 78 | ||
79 | +static void monitor_start_input(void); | ||
80 | + | ||
79 | CPUState *mon_cpu = NULL; | 81 | CPUState *mon_cpu = NULL; |
80 | 82 | ||
81 | void term_flush(void) | 83 | void term_flush(void) |
@@ -2683,13 +2685,15 @@ static void term_read(void *opaque, const uint8_t *buf, int size) | @@ -2683,13 +2685,15 @@ static void term_read(void *opaque, const uint8_t *buf, int size) | ||
2683 | readline_handle_byte(buf[i]); | 2685 | readline_handle_byte(buf[i]); |
2684 | } | 2686 | } |
2685 | 2687 | ||
2688 | +static void monitor_start_input(void); | ||
2689 | + | ||
2686 | static void monitor_handle_command1(void *opaque, const char *cmdline) | 2690 | static void monitor_handle_command1(void *opaque, const char *cmdline) |
2687 | { | 2691 | { |
2688 | monitor_handle_command(cmdline); | 2692 | monitor_handle_command(cmdline); |
2689 | monitor_start_input(); | 2693 | monitor_start_input(); |
2690 | } | 2694 | } |
2691 | 2695 | ||
2692 | -void monitor_start_input(void) | 2696 | +static void monitor_start_input(void) |
2693 | { | 2697 | { |
2694 | readline_start("(qemu) ", 0, monitor_handle_command1, NULL); | 2698 | readline_start("(qemu) ", 0, monitor_handle_command1, NULL); |
2695 | } | 2699 | } |
@@ -2730,6 +2734,8 @@ void monitor_init(CharDriverState *hd, int show_banner) | @@ -2730,6 +2734,8 @@ void monitor_init(CharDriverState *hd, int show_banner) | ||
2730 | hide_banner = !show_banner; | 2734 | hide_banner = !show_banner; |
2731 | 2735 | ||
2732 | qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL); | 2736 | qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL); |
2737 | + | ||
2738 | + readline_start("", 0, monitor_handle_command1, NULL); | ||
2733 | } | 2739 | } |
2734 | 2740 | ||
2735 | /* XXX: use threads ? */ | 2741 | /* XXX: use threads ? */ |
vl.c
@@ -5721,7 +5721,7 @@ static int drive_init(struct drive_opt *arg, int snapshot, | @@ -5721,7 +5721,7 @@ static int drive_init(struct drive_opt *arg, int snapshot, | ||
5721 | bdrv_flags |= BDRV_O_SNAPSHOT; | 5721 | bdrv_flags |= BDRV_O_SNAPSHOT; |
5722 | if (!cache) | 5722 | if (!cache) |
5723 | bdrv_flags |= BDRV_O_DIRECT; | 5723 | bdrv_flags |= BDRV_O_DIRECT; |
5724 | - if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) { | 5724 | + if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0 || qemu_key_check(bdrv, file)) { |
5725 | fprintf(stderr, "qemu: could not open disk image %s\n", | 5725 | fprintf(stderr, "qemu: could not open disk image %s\n", |
5726 | file); | 5726 | file); |
5727 | return -1; | 5727 | return -1; |
@@ -8009,14 +8009,22 @@ int qemu_key_check(BlockDriverState *bs, const char *name) | @@ -8009,14 +8009,22 @@ int qemu_key_check(BlockDriverState *bs, const char *name) | ||
8009 | return -EPERM; | 8009 | return -EPERM; |
8010 | } | 8010 | } |
8011 | 8011 | ||
8012 | +static BlockDriverState *get_bdrv(int index) | ||
8013 | +{ | ||
8014 | + if (index > nb_drives) | ||
8015 | + return NULL; | ||
8016 | + return drives_table[index].bdrv; | ||
8017 | +} | ||
8018 | + | ||
8012 | static void read_passwords(void) | 8019 | static void read_passwords(void) |
8013 | { | 8020 | { |
8014 | BlockDriverState *bs; | 8021 | BlockDriverState *bs; |
8015 | int i; | 8022 | int i; |
8016 | 8023 | ||
8017 | - for(i = 0; i < nb_drives; i++) { | ||
8018 | - bs = drives_table[i].bdrv; | ||
8019 | - qemu_key_check(bs, bdrv_get_device_name(bs)); | 8024 | + for(i = 0; i < 6; i++) { |
8025 | + bs = get_bdrv(i); | ||
8026 | + if (bs) | ||
8027 | + qemu_key_check(bs, bdrv_get_device_name(bs)); | ||
8020 | } | 8028 | } |
8021 | } | 8029 | } |
8022 | 8030 | ||
@@ -8185,7 +8193,6 @@ int main(int argc, char **argv) | @@ -8185,7 +8193,6 @@ int main(int argc, char **argv) | ||
8185 | int optind; | 8193 | int optind; |
8186 | const char *r, *optarg; | 8194 | const char *r, *optarg; |
8187 | CharDriverState *monitor_hd; | 8195 | CharDriverState *monitor_hd; |
8188 | - int has_monitor; | ||
8189 | const char *monitor_device; | 8196 | const char *monitor_device; |
8190 | const char *serial_devices[MAX_SERIAL_PORTS]; | 8197 | const char *serial_devices[MAX_SERIAL_PORTS]; |
8191 | int serial_device_index; | 8198 | int serial_device_index; |
@@ -9055,8 +9062,6 @@ int main(int argc, char **argv) | @@ -9055,8 +9062,6 @@ int main(int argc, char **argv) | ||
9055 | } | 9062 | } |
9056 | 9063 | ||
9057 | /* Maintain compatibility with multiple stdio monitors */ | 9064 | /* Maintain compatibility with multiple stdio monitors */ |
9058 | - | ||
9059 | - has_monitor = 0; | ||
9060 | if (!strcmp(monitor_device,"stdio")) { | 9065 | if (!strcmp(monitor_device,"stdio")) { |
9061 | for (i = 0; i < MAX_SERIAL_PORTS; i++) { | 9066 | for (i = 0; i < MAX_SERIAL_PORTS; i++) { |
9062 | const char *devname = serial_devices[i]; | 9067 | const char *devname = serial_devices[i]; |
@@ -9069,7 +9074,6 @@ int main(int argc, char **argv) | @@ -9069,7 +9074,6 @@ int main(int argc, char **argv) | ||
9069 | break; | 9074 | break; |
9070 | } | 9075 | } |
9071 | } | 9076 | } |
9072 | - has_monitor = 1; | ||
9073 | } | 9077 | } |
9074 | if (monitor_device) { | 9078 | if (monitor_device) { |
9075 | monitor_hd = qemu_chr_open(monitor_device); | 9079 | monitor_hd = qemu_chr_open(monitor_device); |
@@ -9078,7 +9082,6 @@ int main(int argc, char **argv) | @@ -9078,7 +9082,6 @@ int main(int argc, char **argv) | ||
9078 | exit(1); | 9082 | exit(1); |
9079 | } | 9083 | } |
9080 | monitor_init(monitor_hd, !nographic); | 9084 | monitor_init(monitor_hd, !nographic); |
9081 | - has_monitor = 1; | ||
9082 | } | 9085 | } |
9083 | 9086 | ||
9084 | for(i = 0; i < MAX_SERIAL_PORTS; i++) { | 9087 | for(i = 0; i < MAX_SERIAL_PORTS; i++) { |
@@ -9139,16 +9142,12 @@ int main(int argc, char **argv) | @@ -9139,16 +9142,12 @@ int main(int argc, char **argv) | ||
9139 | } | 9142 | } |
9140 | #endif | 9143 | #endif |
9141 | 9144 | ||
9142 | - read_passwords(); | ||
9143 | - | ||
9144 | - if (has_monitor) | ||
9145 | - monitor_start_input(); | ||
9146 | - | ||
9147 | if (loadvm) | 9145 | if (loadvm) |
9148 | do_loadvm(loadvm); | 9146 | do_loadvm(loadvm); |
9149 | 9147 | ||
9150 | { | 9148 | { |
9151 | /* XXX: simplify init */ | 9149 | /* XXX: simplify init */ |
9150 | + read_passwords(); | ||
9152 | if (autostart) { | 9151 | if (autostart) { |
9153 | vm_start(); | 9152 | vm_start(); |
9154 | } | 9153 | } |