diff --git a/qemu-config.c b/qemu-config.c
index 6075c20..fe4837d 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -285,6 +285,9 @@ void qemu_config_write(FILE *fp)
     int i;
 
     fprintf(fp, "# qemu config file\n\n");
+    fprintf(fp, "# legacy options:\n# ");
+    qemu_opt_legacy_print(fp);
+    fprintf(fp, "\n\n");
     for (i = 0; lists[i] != NULL; i++) {
         data.list = lists[i];
         qemu_opts_foreach(data.list, config_write_opts, &data, 0);
diff --git a/qemu-option.c b/qemu-option.c
index 49efd39..4d1453c 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -819,3 +819,20 @@ int qemu_opts_foreach(QemuOptsList *list,
qemu_opts_loopfunc func, void *opaque,
     }
     return rc;
 }
+
+static char legacy_options[8192];
+
+void qemu_opt_legacy_add(const char *opt, const char *optarg)
+{
+    strncat(legacy_options, " -", 8192);
+    strncat(legacy_options, opt, 8192);
+    if (optarg) {
+	strncat(legacy_options, " ", 8192);
+	strncat(legacy_options, optarg, 8192);
+    }
+}
+
+void qemu_opt_legacy_print(FILE *file)
+{
+    fprintf(file, "%s", legacy_options);
+}
diff --git a/qemu-option.h b/qemu-option.h
index 666b666..5a8cb61 100644
--- a/qemu-option.h
+++ b/qemu-option.h
@@ -124,4 +124,7 @@ int qemu_opts_print(QemuOpts *opts, void *dummy);
 int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void
*opaque,
                       int abort_on_failure);
 
+void qemu_opt_legacy_add(const char *opt, const char *optarg);
+void qemu_opt_legacy_print(FILE *file);
+
 #endif
diff --git a/vl.c b/vl.c
index b090022..44f8fed 100644
--- a/vl.c
+++ b/vl.c
@@ -4887,6 +4887,7 @@ int main(int argc, char **argv, char **envp)
 
             switch(popt->index) {
             case QEMU_OPTION_M:
+	        qemu_opt_legacy_add("M", optarg);
                 machine = find_machine(optarg);
                 if (!machine) {
                     QEMUMachine *m;
@@ -4903,6 +4904,7 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_cpu:
+	        qemu_opt_legacy_add("cpu", optarg);
                 /* hw initialization will check this */
                 if (*optarg == '?') {
 /* XXX: implement xxx_cpu_list for targets that still miss it */
@@ -4915,6 +4917,7 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_initrd:
+	        qemu_opt_legacy_add("initrd", optarg);
                 initrd_filename = optarg;
                 break;
             case QEMU_OPTION_hda:
@@ -4951,6 +4954,7 @@ int main(int argc, char **argv, char **envp)
                 drive_add(optarg, PFLASH_ALIAS);
                 break;
             case QEMU_OPTION_snapshot:
+	        qemu_opt_legacy_add("snapshot", NULL);
                 snapshot = 1;
                 break;
             case QEMU_OPTION_hdachs:
@@ -5003,6 +5007,7 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_numa:
+	        qemu_opt_legacy_add("numa", optarg);
                 if (nb_numa_nodes >= MAX_NODES) {
                     fprintf(stderr, "qemu: too many NUMA nodes\n");
                     exit(1);
@@ -5010,26 +5015,32 @@ int main(int argc, char **argv, char **envp)
                 numa_add(optarg);
                 break;
             case QEMU_OPTION_nographic:
+	        qemu_opt_legacy_add("nographic", NULL);
                 display_type = DT_NOGRAPHIC;
                 break;
 #ifdef CONFIG_CURSES
             case QEMU_OPTION_curses:
+	        qemu_opt_legacy_add("curses", NULL);
                 display_type = DT_CURSES;
                 break;
 #endif
             case QEMU_OPTION_portrait:
+	        qemu_opt_legacy_add("portrait", NULL);
                 graphic_rotate = 1;
                 break;
             case QEMU_OPTION_kernel:
+	        qemu_opt_legacy_add("kernel", optarg);
                 kernel_filename = optarg;
                 break;
             case QEMU_OPTION_append:
+	        qemu_opt_legacy_add("append", optarg);
                 kernel_cmdline = optarg;
                 break;
             case QEMU_OPTION_cdrom:
                 drive_add(optarg, CDROM_ALIAS);
                 break;
             case QEMU_OPTION_boot:
+	        qemu_opt_legacy_add("boot", optarg);
                 {
                     static const char * const params[] = {
                         "order", "once", "menu", NULL
@@ -5084,6 +5095,7 @@ int main(int argc, char **argv, char **envp)
                 break;
 #ifdef TARGET_I386
             case QEMU_OPTION_no_fd_bootchk:
+	        qemu_opt_legacy_add("no-fd-bootchk", NULL);
                 fd_bootchk = 0;
                 break;
 #endif
@@ -5099,23 +5111,28 @@ int main(int argc, char **argv, char **envp)
                 break;
 #ifdef CONFIG_SLIRP
             case QEMU_OPTION_tftp:
+	        qemu_opt_legacy_add("tftp", optarg);
                 legacy_tftp_prefix = optarg;
                 break;
             case QEMU_OPTION_bootp:
+	        qemu_opt_legacy_add("bootp", optarg);
                 legacy_bootp_filename = optarg;
                 break;
 #ifndef _WIN32
             case QEMU_OPTION_smb:
+	        qemu_opt_legacy_add("smb", optarg);
                 if (net_slirp_smb(optarg) < 0)
                     exit(1);
                 break;
 #endif
             case QEMU_OPTION_redir:
+	        qemu_opt_legacy_add("redir", optarg);
                 if (net_slirp_redir(optarg) < 0)
                     exit(1);
                 break;
 #endif
             case QEMU_OPTION_bt:
+	        qemu_opt_legacy_add("bt", optarg);
                 add_device_config(DEV_BT, optarg);
                 break;
 #ifdef HAS_AUDIO
@@ -5124,6 +5141,7 @@ int main(int argc, char **argv, char **envp)
                 exit (0);
                 break;
             case QEMU_OPTION_soundhw:
+	        qemu_opt_legacy_add("soundhw", optarg);
                 select_soundhw (optarg);
                 break;
 #endif
@@ -5135,6 +5153,7 @@ int main(int argc, char **argv, char **envp)
                 exit(0);
                 break;
             case QEMU_OPTION_m: {
+	        qemu_opt_legacy_add("m", optarg);
                 uint64_t value;
                 char *ptr;
 
@@ -5164,6 +5183,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             }
             case QEMU_OPTION_d:
+	        qemu_opt_legacy_add("d", optarg);
                 {
                     int mask;
                     const CPULogItem *item;
@@ -5180,32 +5200,41 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_s:
+	        qemu_opt_legacy_add("s", NULL);
                 gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT;
                 break;
             case QEMU_OPTION_gdb:
+	        qemu_opt_legacy_add("gdb", optarg);
                 gdbstub_dev = optarg;
                 break;
             case QEMU_OPTION_L:
+	        qemu_opt_legacy_add("L", optarg);
                 data_dir = optarg;
                 break;
             case QEMU_OPTION_bios:
+	        qemu_opt_legacy_add("bios", optarg);
                 bios_name = optarg;
                 break;
             case QEMU_OPTION_singlestep:
+	        qemu_opt_legacy_add("singlestep", NULL);
                 singlestep = 1;
                 break;
             case QEMU_OPTION_S:
+	        qemu_opt_legacy_add("S", NULL);
                 autostart = 0;
                 break;
 #ifndef _WIN32
 	    case QEMU_OPTION_k:
+	        qemu_opt_legacy_add("k", optarg);
 		keyboard_layout = optarg;
 		break;
 #endif
             case QEMU_OPTION_localtime:
+	        qemu_opt_legacy_add("localtime", NULL);
                 rtc_utc = 0;
                 break;
             case QEMU_OPTION_vga:
+	        qemu_opt_legacy_add("vga", optarg);
                 select_vgahw (optarg);
                 break;
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
@@ -5245,6 +5274,7 @@ int main(int argc, char **argv, char **envp)
                 break;
 #endif
             case QEMU_OPTION_echr:
+	        qemu_opt_legacy_add("echr", optarg);
                 {
                     char *r;
                     term_escape_char = strtol(optarg, &r, 0);
@@ -5253,6 +5283,7 @@ int main(int argc, char **argv, char **envp)
                     break;
                 }
             case QEMU_OPTION_monitor:
+	        qemu_opt_legacy_add("monitor", optarg);
                 if (monitor_device_index >= MAX_MONITOR_DEVICES) {
                     fprintf(stderr, "qemu: too many monitor devices
\n");
