qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] kvm_init didn't set return value after create vm failed
@ 2011-10-26 10:19 Xu He Jie
  2011-10-26 11:03 ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Xu He Jie @ 2011-10-26 10:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Xu He Jie

kvm_init didn't set return value after create vm failed.

And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be < -1, 
so change the check of vmfd at label 'err'.

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
---
 kvm-all.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index e7faf5c..70edb39 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -739,6 +739,7 @@ int kvm_init(void)
         fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
                         "your host kernel command line\n");
 #endif
+        ret = -errno;
         goto err;
     }
 
@@ -797,7 +798,7 @@ int kvm_init(void)
 
 err:
     if (s) {
-        if (s->vmfd != -1) {
+        if (s->vmfd >= 0) {
             close(s->vmfd);
         }
         if (s->fd != -1) {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm_init didn't set return value after create vm failed
  2011-10-26 10:19 [Qemu-devel] [PATCH] kvm_init didn't set return value after create vm failed Xu He Jie
@ 2011-10-26 11:03 ` Jan Kiszka
  2011-10-26 11:09   ` Xu He Jie
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2011-10-26 11:03 UTC (permalink / raw)
  To: Xu He Jie; +Cc: qemu-devel

On 2011-10-26 12:19, Xu He Jie wrote:
> kvm_init didn't set return value after create vm failed.
> 
> And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be < -1, 
> so change the check of vmfd at label 'err'.
> 
> Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
> ---
>  kvm-all.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index e7faf5c..70edb39 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -739,6 +739,7 @@ int kvm_init(void)
>          fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
>                          "your host kernel command line\n");
>  #endif
> +        ret = -errno;

kvm_ioctl returns -errno while that fprintf may overwrite it. Just set
ret to s->vmfd.

>          goto err;
>      }
>  
> @@ -797,7 +798,7 @@ int kvm_init(void)
>  
>  err:
>      if (s) {
> -        if (s->vmfd != -1) {
> +        if (s->vmfd >= 0) {
>              close(s->vmfd);
>          }
>          if (s->fd != -1) {

That looks correct.

The patch will probably flow via uq/master, so you should address Avi
and Marcelo with v2.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm_init didn't set return value after create vm failed
  2011-10-26 11:03 ` Jan Kiszka
@ 2011-10-26 11:09   ` Xu He Jie
  0 siblings, 0 replies; 3+ messages in thread
From: Xu He Jie @ 2011-10-26 11:09 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel

于 2011年10月26日 19:03, Jan Kiszka 写道:
> On 2011-10-26 12:19, Xu He Jie wrote:
>> kvm_init didn't set return value after create vm failed.
>>
>> And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be<  -1,
>> so change the check of vmfd at label 'err'.
>>
>> Signed-off-by: Xu He Jie<xuhj@linux.vnet.ibm.com>
>> ---
>>   kvm-all.c |    3 ++-
>>   1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/kvm-all.c b/kvm-all.c
>> index e7faf5c..70edb39 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -739,6 +739,7 @@ int kvm_init(void)
>>           fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
>>                           "your host kernel command line\n");
>>   #endif
>> +        ret = -errno;
> kvm_ioctl returns -errno while that fprintf may overwrite it. Just set
> ret to s->vmfd.
ok.
>
>>           goto err;
>>       }
>>
>> @@ -797,7 +798,7 @@ int kvm_init(void)
>>
>>   err:
>>       if (s) {
>> -        if (s->vmfd != -1) {
>> +        if (s->vmfd>= 0) {
>>               close(s->vmfd);
>>           }
>>           if (s->fd != -1) {
> That looks correct.
>
> The patch will probably flow via uq/master, so you should address Avi
> and Marcelo with v2.
>
> Thanks,
> Jan
>
Thanks,
Xu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-26 13:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-26 10:19 [Qemu-devel] [PATCH] kvm_init didn't set return value after create vm failed Xu He Jie
2011-10-26 11:03 ` Jan Kiszka
2011-10-26 11:09   ` Xu He Jie

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).