Patchwork [V2,15/23] kvm tools: Perform CPU and firmware setup after devices are added

login
register
mail settings
Submitter Matt Evans
Date Dec. 9, 2011, 6:55 a.m.
Message ID <4EE1B0D4.10000@ozlabs.org>
Download mbox | patch
Permalink /patch/130298/
State New
Headers show

Comments

Matt Evans - Dec. 9, 2011, 6:55 a.m.
Currently some devices (in this case kbd, fb, vesa) are initialised after
CPU/firmware setup.  On some platforms (e.g. PPC) kvm__arch_setup_firmware() may
be making a device tree.  Any devices added after this point will be missed!

Tiny refactor of builtin-run.c, moving timer start, firmware setup, cpu init
to occur last.

Signed-off-by: Matt Evans <matt@ozlabs.org>
---
 tools/kvm/builtin-run.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

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

Patch

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 99db522..7491428 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -932,16 +932,6 @@  int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 		virtio_net__init(&net_params);
 	}
 
-	kvm__start_timer(kvm);
-
-	kvm__arch_setup_firmware(kvm);
-
-	for (i = 0; i < nrcpus; i++) {
-		kvm_cpus[i] = kvm_cpu__init(kvm, i);
-		if (!kvm_cpus[i])
-			die("unable to initialize KVM VCPU");
-	}
-
 	kvm__init_ram(kvm);
 
 #ifdef CONFIG_X86
@@ -965,6 +955,20 @@  int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 
 	fb__start();
 
+	/* Device init all done; firmware init must
+	 * come after this (it may set up device trees etc.)
+	 */
+
+	kvm__start_timer(kvm);
+
+	kvm__arch_setup_firmware(kvm);
+
+	for (i = 0; i < nrcpus; i++) {
+		kvm_cpus[i] = kvm_cpu__init(kvm, i);
+		if (!kvm_cpus[i])
+			die("unable to initialize KVM VCPU");
+	}
+
 	thread_pool__init(nr_online_cpus);
 	ioeventfd__start();