}
kvm->cfg.vmlinux_filename = find_vmlinux();
+ kvm->vmlinux = kvm->cfg.vmlinux_filename;
if (kvm->cfg.nrcpus == 0)
kvm->cfg.nrcpus = nr_online_cpus;
if (!kvm->cfg.vnc && !kvm->cfg.sdl)
kvm->cfg.vidmode = -1;
- r = term_init(kvm);
- if (r < 0) {
- pr_err("term_init() failed with error %d\n", r);
- goto fail;
- }
+ memset(real_cmdline, 0, sizeof(real_cmdline));
+ kvm__arch_set_cmdline(real_cmdline, kvm->cfg.vnc || kvm->cfg.sdl);
+
+ if (strlen(real_cmdline) > 0)
+ strcat(real_cmdline, " ");
+
+ if (kvm->cfg.kernel_cmdline)
+ strlcat(real_cmdline, kvm->cfg.kernel_cmdline, sizeof(real_cmdline));
if (!kvm->cfg.guest_name) {
if (kvm->cfg.custom_rootfs) {
}
}
+ if (!kvm->cfg.using_rootfs && !kvm->cfg.disk_image[0].filename && !kvm->cfg.initrd_filename) {
+ char tmp[PATH_MAX];
+
+ kvm_setup_create_new(kvm->cfg.custom_rootfs_name);
+ kvm_setup_resolv(kvm->cfg.custom_rootfs_name);
+
+ snprintf(tmp, PATH_MAX, "%s%s", kvm__get_dir(), "default");
+ if (virtio_9p__register(kvm, tmp, "/dev/root") < 0)
+ die("Unable to initialize virtio 9p");
+ if (virtio_9p__register(kvm, "/", "hostfs") < 0)
+ die("Unable to initialize virtio 9p");
+ kvm->cfg.using_rootfs = kvm->cfg.custom_rootfs = 1;
+ }
+
+ if (kvm->cfg.using_rootfs) {
+ strcat(real_cmdline, " root=/dev/root rw rootflags=rw,trans=virtio,version=9p2000.L rootfstype=9p");
+ if (kvm->cfg.custom_rootfs) {
+ kvm_run_set_sandbox();
+
+ strcat(real_cmdline, " init=/virt/init");
+
+ if (!kvm->cfg.no_dhcp)
+ strcat(real_cmdline, " ip=dhcp");
+ if (kvm_setup_guest_init())
+ die("Failed to setup init for guest.");
+ }
+ } else if (!strstr(real_cmdline, "root=")) {
+ strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline));
+ }
+
+ kvm->cfg.real_cmdline = real_cmdline;
+
+ printf(" # %s run -k %s -m %Lu -c %d --name %s\n", KVM_BINARY_NAME,
+ kvm->cfg.kernel_filename, kvm->cfg.ram_size / 1024 / 1024, kvm->cfg.nrcpus, kvm->cfg.guest_name);
+
r = kvm__init(kvm);
if (r)
goto fail;
+ r = term_init(kvm);
+ if (r < 0) {
+ pr_err("term_init() failed with error %d\n", r);
+ goto fail;
+ }
+
+
r = ioeventfd__init(kvm);
if (r < 0) {
pr_err("ioeventfd__init() failed with error %d\n", r);
goto fail;
}
- memset(real_cmdline, 0, sizeof(real_cmdline));
- kvm__arch_set_cmdline(real_cmdline, kvm->cfg.vnc || kvm->cfg.sdl);
-
- if (strlen(real_cmdline) > 0)
- strcat(real_cmdline, " ");
-
- if (kvm->cfg.kernel_cmdline)
- strlcat(real_cmdline, kvm->cfg.kernel_cmdline, sizeof(real_cmdline));
-
- if (!kvm->cfg.using_rootfs && !kvm->cfg.disk_image[0].filename && !kvm->cfg.initrd_filename) {
- char tmp[PATH_MAX];
-
- kvm_setup_create_new(kvm->cfg.custom_rootfs_name);
- kvm_setup_resolv(kvm->cfg.custom_rootfs_name);
-
- snprintf(tmp, PATH_MAX, "%s%s", kvm__get_dir(), "default");
- if (virtio_9p__register(kvm, tmp, "/dev/root") < 0)
- die("Unable to initialize virtio 9p");
- if (virtio_9p__register(kvm, "/", "hostfs") < 0)
- die("Unable to initialize virtio 9p");
- kvm->cfg.using_rootfs = kvm->cfg.custom_rootfs = 1;
- }
-
- if (kvm->cfg.using_rootfs) {
- strcat(real_cmdline, " root=/dev/root rw rootflags=rw,trans=virtio,version=9p2000.L rootfstype=9p");
- if (kvm->cfg.custom_rootfs) {
- kvm_run_set_sandbox();
-
- strcat(real_cmdline, " init=/virt/init");
-
- if (!kvm->cfg.no_dhcp)
- strcat(real_cmdline, " ip=dhcp");
- if (kvm_setup_guest_init())
- die("Failed to setup init for guest.");
- }
- } else if (!strstr(real_cmdline, "root=")) {
- strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline));
- }
-
r = disk_image__init(kvm);
if (r < 0) {
pr_err("disk_image__init() failed with error %d\n", r);
goto fail;
}
- printf(" # %s run -k %s -m %Lu -c %d --name %s\n", KVM_BINARY_NAME,
- kvm->cfg.kernel_filename, kvm->cfg.ram_size / 1024 / 1024, kvm->cfg.nrcpus, kvm->cfg.guest_name);
-
- if (!kvm->cfg.firmware_filename) {
- if (!kvm__load_kernel(kvm, kvm->cfg.kernel_filename,
- kvm->cfg.initrd_filename, real_cmdline, kvm->cfg.vidmode))
- die("unable to load kernel %s", kvm->cfg.kernel_filename);
-
- kvm->vmlinux = kvm->cfg.vmlinux_filename;
- r = symbol_init(kvm);
- if (r < 0)
- pr_debug("symbol_init() failed with error %d\n", r);
- }
+ r = symbol_init(kvm);
+ if (r < 0)
+ pr_debug("symbol_init() failed with error %d\n", r);
ioport__setup_arch();
goto fail;
}
- if (kvm->cfg.firmware_filename) {
- if (!kvm__load_firmware(kvm, kvm->cfg.firmware_filename))
- die("unable to load firmware image %s: %s", kvm->cfg.firmware_filename, strerror(errno));
- } else {
- kvm__arch_setup_firmware(kvm);
- if (r < 0) {
- pr_err("kvm__arch_setup_firmware() failed with error %d\n", r);
- goto fail;
- }
- }
-
r = thread_pool__init(kvm);
if (r < 0) {
pr_err("thread_pool__init() failed with error %d\n", r);