diff mbox

[trivial,v2] vl: avoid closing stdout with 'writeconfig'

Message ID 5355C202.9040603@gmail.com
State New
Headers show

Commit Message

Chen Gang April 22, 2014, 1:12 a.m. UTC
'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>
---
 vl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Tokarev April 24, 2014, 3:14 p.m. UTC | #1
22.04.2014 05:12, Chen Gang wrotr:
> '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 '-')

Thanks, applied to -trivial.

/mjt
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 9975e5a..215467f 100644
--- a/vl.c
+++ b/vl.c
@@ -3855,7 +3855,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: