[PATCH 2/2] kvm tools: Bring SMP back

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have this currently:

   kvm__init()
      kvm__arch_setup_firmware()
         mptable__init()
            using kvm->nrcpus

   kvm_cpu__init()
      kvm->nrcpus = kvm->cfg.nrcpus

kvm->nrcpus is used in mptable__init() before it is initialized, so
mptable__init() will setup a wrong mp table.

Before:
$ ./lkvm -c 4
$ cat /proc/cpuinfo |grep ^processor|wc -l
1

After:
$ ./lkvm -c 4
$ cat /proc/cpuinfo |grep ^processor|wc -l
4

Signed-off-by: Asias He <asias.hejun@xxxxxxxxx>
---
 tools/kvm/builtin-run.c | 7 -------
 tools/kvm/kvm.c         | 6 ++++++
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 5ddffaa..790b496 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -656,19 +656,12 @@ static int kvm_cmd_run_init(int argc, const char **argv)
 		goto fail;
 	}
 
-
 	r = ioeventfd__init(kvm);
 	if (r < 0) {
 		pr_err("ioeventfd__init() failed with error %d\n", r);
 		goto fail;
 	}
 
-	r = kvm_cpu__init(kvm);
-	if (r < 0) {
-		pr_err("kvm_cpu__init() failed with error %d\n", r);
-		goto fail;
-	}
-
 	r = irq__init(kvm);
 	if (r < 0) {
 		pr_err("irq__init() failed with error %d\n", r);
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index cca2e93..4fdad92 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -248,6 +248,12 @@ int kvm__init(struct kvm *kvm)
 
 	kvm__init_ram(kvm);
 
+	ret = kvm_cpu__init(kvm);
+	if (ret < 0) {
+		pr_err("kvm_cpu__init() failed with error %d\n", ret);
+		goto err_vm_fd;
+	}
+
 	if (!kvm->cfg.firmware_filename) {
 		if (!kvm__load_kernel(kvm, kvm->cfg.kernel_filename,
 				kvm->cfg.initrd_filename, kvm->cfg.real_cmdline, kvm->cfg.vidmode))
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux