* [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file
@ 2014-10-29 12:49 arei.gonglei
2014-10-29 12:59 ` Amit Shah
2014-10-29 13:05 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: arei.gonglei @ 2014-10-29 12:49 UTC (permalink / raw)
To: qemu-devel; +Cc: amit.shah, qemu-trivial, Gonglei, weidong.huang, quintela
From: Gonglei <arei.gonglei@huawei.com>
commit abfd9ce3(migration: dump vmstate info as a json
file for static analysis) introduce a new command,
'-dump-vmstate', that takes a filename
as an argument. When executed, QEMU will dump the vmstate information
for the machine type it's invoked with to the file, and quit.
Apparently, it supports one '-dump-vmstate' option,
otherwise, the vmstate_dump_file will be overwritten.
Of course, the resource will be freed when Qemu quit, but The code logic
is not good, it will make Coverity complaining.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
vl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/vl.c b/vl.c
index f6b3546..5ef3af9 100644
--- a/vl.c
+++ b/vl.c
@@ -3746,6 +3746,11 @@ int main(int argc, char **argv, char **envp)
configure_msg(opts);
break;
case QEMU_OPTION_dump_vmstate:
+ if (vmstate_dump_file) {
+ fprintf(stderr, "qemu: only one '-dump-vmstate' "
+ "option may be given\n");
+ exit(1);
+ }
vmstate_dump_file = fopen(optarg, "w");
if (vmstate_dump_file == NULL) {
fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
--
1.7.12.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file
2014-10-29 12:49 [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file arei.gonglei
@ 2014-10-29 12:59 ` Amit Shah
2014-10-29 13:05 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Amit Shah @ 2014-10-29 12:59 UTC (permalink / raw)
To: arei.gonglei; +Cc: qemu-trivial, weidong.huang, qemu-devel, quintela
On (Wed) 29 Oct 2014 [20:49:43], arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> commit abfd9ce3(migration: dump vmstate info as a json
> file for static analysis) introduce a new command,
> '-dump-vmstate', that takes a filename
> as an argument. When executed, QEMU will dump the vmstate information
> for the machine type it's invoked with to the file, and quit.
>
> Apparently, it supports one '-dump-vmstate' option,
> otherwise, the vmstate_dump_file will be overwritten.
Suggested re-wording of this para:
However, only one instance of the -dump-vmstate option is supported.
If more were given, the vmstate_dump_file could be overwritten.
> Of course, the resource will be freed when Qemu quit, but The code logic
> is not good, it will make Coverity complaining.
Suggested re-wording:
This fix also helps silence a Coverity error.
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Thanks,
Amit
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file
2014-10-29 12:49 [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file arei.gonglei
2014-10-29 12:59 ` Amit Shah
@ 2014-10-29 13:05 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2014-10-29 13:05 UTC (permalink / raw)
To: arei.gonglei, qemu-devel; +Cc: amit.shah, qemu-trivial, weidong.huang, quintela
On 10/29/2014 01:49 PM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> commit abfd9ce3(migration: dump vmstate info as a json
> file for static analysis) introduce a new command,
> '-dump-vmstate', that takes a filename
> as an argument. When executed, QEMU will dump the vmstate information
> for the machine type it's invoked with to the file, and quit.
>
> Apparently, it supports one '-dump-vmstate' option,
> otherwise, the vmstate_dump_file will be overwritten.
>
> Of course, the resource will be freed when Qemu quit, but The code logic
> is not good, it will make Coverity complaining.
>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> vl.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/vl.c b/vl.c
> index f6b3546..5ef3af9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3746,6 +3746,11 @@ int main(int argc, char **argv, char **envp)
> configure_msg(opts);
> break;
> case QEMU_OPTION_dump_vmstate:
> + if (vmstate_dump_file) {
> + fprintf(stderr, "qemu: only one '-dump-vmstate' "
> + "option may be given\n");
> + exit(1);
> + }
> vmstate_dump_file = fopen(optarg, "w");
> if (vmstate_dump_file == NULL) {
> fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
>
Applied, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-29 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 12:49 [Qemu-devel] [PATCH] vl.c: Fix Coverity complaining for vmstate_dump_file arei.gonglei
2014-10-29 12:59 ` Amit Shah
2014-10-29 13:05 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).