瀏覽代碼

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>
Xu He Jie 14 年之前
父節點
當前提交
db9eae1c49
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      kvm-all.c

+ 2 - 1
kvm-all.c

@@ -740,6 +740,7 @@ int kvm_init(void)
         fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
         fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
                         "your host kernel command line\n");
                         "your host kernel command line\n");
 #endif
 #endif
+        ret = s->vmfd;
         goto err;
         goto err;
     }
     }
 
 
@@ -798,7 +799,7 @@ int kvm_init(void)
 
 
 err:
 err:
     if (s) {
     if (s) {
-        if (s->vmfd != -1) {
+        if (s->vmfd >= 0) {
             close(s->vmfd);
             close(s->vmfd);
         }
         }
         if (s->fd != -1) {
         if (s->fd != -1) {