From: Chen Gang <gang.chen.5...@gmail.com>

'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.5...@gmail.com>
Reviewed-by: Eric Blake <ebl...@redhat.com>
Signed-off-by: Michael Tokarev <m...@tls.msk.ru>
---
 vl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index 773649f..236f95e 100644
--- a/vl.c
+++ b/vl.c
@@ -3890,7 +3890,9 @@ int main(int argc, char **argv, char **envp)
                         }
                     }
                     qemu_config_write(fp);
-                    fclose(fp);
+                    if (fp != stdout) {
+                        fclose(fp);
+                    }
                     break;
                 }
             case QEMU_OPTION_qtest:
-- 
1.7.10.4


Reply via email to