summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorXu He Jie <xuhj@linux.vnet.ibm.com>2011-10-27 10:15:13 +0800
committerAnthony Liguori <aliguori@us.ibm.com>2011-11-01 16:52:05 -0500
commitdb9eae1c49fe2766a7709d7b2c4cdfcd91b9c25b (patch)
tree7dc7a880cf25f5d996fa268ac07df09cd83179f9
parent3a26360d1df3c3519a45636ec2189429d3df0ecb (diff)
downloadfocaccia-qemu-db9eae1c49fe2766a7709d7b2c4cdfcd91b9c25b.tar.gz
focaccia-qemu-db9eae1c49fe2766a7709d7b2c4cdfcd91b9c25b.zip
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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--kvm-all.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kvm-all.c b/kvm-all.c
index c09ddf7ac5..4c466d6aba 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -740,6 +740,7 @@ int kvm_init(void)
         fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
                         "your host kernel command line\n");
 #endif
+        ret = s->vmfd;
         goto err;
     }
 
@@ -798,7 +799,7 @@ int kvm_init(void)
 
 err:
     if (s) {
-        if (s->vmfd != -1) {
+        if (s->vmfd >= 0) {
             close(s->vmfd);
         }
         if (s->fd != -1) {