aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c9
-rw-r--r--monitor.c27
-rw-r--r--qemu-img.c5
-rw-r--r--vl.h1
4 files changed, 39 insertions, 3 deletions
diff --git a/block.c b/block.c
index fdaba4bcaf..9aebaa0a4e 100644
--- a/block.c
+++ b/block.c
@@ -868,9 +868,12 @@ void bdrv_info(void)
term_printf(" locked=%d", bs->locked);
}
if (bs->drv) {
- term_printf(" file=%s", bs->filename);
- if (bs->backing_file[0] != '\0')
- term_printf(" backing_file=%s", bs->backing_file);
+ term_printf(" file=");
+ term_print_filename(bs->filename);
+ if (bs->backing_file[0] != '\0') {
+ term_printf(" backing_file=");
+ term_print_filename(bs->backing_file);
+ }
term_printf(" ro=%d", bs->read_only);
term_printf(" drv=%s", bs->drv->format_name);
if (bs->encrypted)
diff --git a/monitor.c b/monitor.c
index f2a2417ddd..d553ce6077 100644
--- a/monitor.c
+++ b/monitor.c
@@ -106,6 +106,33 @@ void term_printf(const char *fmt, ...)
va_end(ap);
}
+void term_print_filename(const char *filename)
+{
+ int i;
+
+ for (i = 0; filename[i]; i++) {
+ switch (filename[i]) {
+ case ' ':
+ case '"':
+ case '\\':
+ term_printf("\\%c", filename[i]);
+ break;
+ case '\t':
+ term_printf("\\t");
+ break;
+ case '\r':
+ term_printf("\\r");
+ break;
+ case '\n':
+ term_printf("\\n");
+ break;
+ default:
+ term_printf("%c", filename[i]);
+ break;
+ }
+ }
+}
+
static int monitor_fprintf(FILE *stream, const char *fmt, ...)
{
va_list ap;
diff --git a/qemu-img.c b/qemu-img.c
index 8b8da05652..23a698db73 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -113,6 +113,11 @@ void term_printf(const char *fmt, ...)
va_end(ap);
}
+void term_print_filename(const char *filename)
+{
+ term_printf(filename);
+}
+
void __attribute__((noreturn)) error(const char *fmt, ...)
{
va_list ap;
diff --git a/vl.h b/vl.h
index 52957f6246..5f13dcd7db 100644
--- a/vl.h
+++ b/vl.h
@@ -1318,6 +1318,7 @@ void monitor_init(CharDriverState *hd, int show_banner);
void term_puts(const char *str);
void term_vprintf(const char *fmt, va_list ap);
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
+void term_print_filename(const char *filename);
void term_flush(void);
void term_print_help(void);
void monitor_readline(const char *prompt, int is_password,