aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2010-03-15 09:13:30 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:15:53 -0400
commit6ce5a090a9a0ea4266a2cad058c69e2f27201e11 (patch)
treeae8223dc3c73309fb34890b735bb4a0d75caafdc /virt/kvm/kvm_main.c
parent31299944584fd62df8b0cfa30ad2c56f445b8cf2 (diff)
KVM: coalesced_mmio: fix kvm_coalesced_mmio_init()'s error handling
kvm_coalesced_mmio_init() keeps to hold the addresses of a coalesced mmio ring page and dev even after it has freed them. Also, if this function fails, though it might be rare, it seems to be suggesting the system's serious state: so we'd better stop the works following the kvm_creat_vm(). This patch clears these problems. We move the coalesced mmio's initialization out of kvm_create_vm(). This seems to be natural because it includes a registration which can be done only when vm is successfully created. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 0db6dfcc8420..55a5d4804499 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -422,9 +422,6 @@ static struct kvm *kvm_create_vm(void)
422 spin_lock(&kvm_lock); 422 spin_lock(&kvm_lock);
423 list_add(&kvm->vm_list, &vm_list); 423 list_add(&kvm->vm_list, &vm_list);
424 spin_unlock(&kvm_lock); 424 spin_unlock(&kvm_lock);
425#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
426 kvm_coalesced_mmio_init(kvm);
427#endif
428out: 425out:
429 return kvm; 426 return kvm;
430 427
@@ -1753,12 +1750,19 @@ static struct file_operations kvm_vm_fops = {
1753 1750
1754static int kvm_dev_ioctl_create_vm(void) 1751static int kvm_dev_ioctl_create_vm(void)
1755{ 1752{
1756 int fd; 1753 int fd, r;
1757 struct kvm *kvm; 1754 struct kvm *kvm;
1758 1755
1759 kvm = kvm_create_vm(); 1756 kvm = kvm_create_vm();
1760 if (IS_ERR(kvm)) 1757 if (IS_ERR(kvm))
1761 return PTR_ERR(kvm); 1758 return PTR_ERR(kvm);
1759#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
1760 r = kvm_coalesced_mmio_init(kvm);
1761 if (r < 0) {
1762 kvm_put_kvm(kvm);
1763 return r;
1764 }
1765#endif
1762 fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, O_RDWR); 1766 fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, O_RDWR);
1763 if (fd < 0) 1767 if (fd < 0)
1764 kvm_put_kvm(kvm); 1768 kvm_put_kvm(kvm);