vl: avoid closing stdout with 'writeconfig'

'writeconfig' supports output to stdout (with '-'); when that happens,
we must not close stdout, or further command line options that also use
stdout will be impacted. (Although 'writeconfig' was copied from
'readconfig', the latter does not have the problem because it does not
support reading from '-')

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Chen Gang 2014-04-22 09:12:34 +08:00 committed by Michael Tokarev
parent 24c12b7923
commit 7fb8b5d9c4

4
vl.c
View File

@ -3890,7 +3890,9 @@ int main(int argc, char **argv, char **envp)
} }
} }
qemu_config_write(fp); qemu_config_write(fp);
fclose(fp); if (fp != stdout) {
fclose(fp);
}
break; break;
} }
case QEMU_OPTION_qtest: case QEMU_OPTION_qtest: