[PATCH v3 02/10] qemu-kvm: Use machine options to configure qemu-kvm defaults

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

 



Upstream is moving towards this mechanism, so start using it in qemu-kvm
already to configure the specific defaults: kvm enabled on, just like
in-kernel irqchips.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 hw/pc_piix.c |    7 +++++++
 kvm-all.c    |    8 ++++++++
 vl.c         |    9 ++-------
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 778c70e..234859b 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -388,6 +388,7 @@ static QEMUMachine pc_machine_v1_1 = {
     .init = pc_init_pci,
     .max_cpus = 255,
     .is_default = 1,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
 };
 
 static QEMUMachine pc_machine_v1_0 = {
@@ -425,6 +426,7 @@ static QEMUMachine pc_machine_v0_14 = {
     .desc = "Standard PC",
     .init = pc_init_pci,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "qxl",
@@ -465,6 +467,7 @@ static QEMUMachine pc_machine_v0_13 = {
     .desc = "Standard PC",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-9p-pci",
@@ -517,6 +520,7 @@ static QEMUMachine pc_machine_v0_12 = {
     .desc = "Standard PC",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-serial-pci",
@@ -573,6 +577,7 @@ static QEMUMachine pc_machine_v0_11 = {
     .desc = "Standard PC, qemu 0.11",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-blk-pci",
@@ -637,6 +642,7 @@ static QEMUMachine pc_machine_v0_10 = {
     .desc = "Standard PC, qemu 0.10",
     .init = pc_init_pci_no_kvmclock,
     .max_cpus = 255,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "virtio-blk-pci",
@@ -713,6 +719,7 @@ static QEMUMachine isapc_machine = {
     .desc = "ISA-only PC",
     .init = pc_init_isa,
     .max_cpus = 1,
+    .default_machine_opts = "accel=kvm,kernel_irqchip=on",
     .compat_props = (GlobalProperty[]) {
         {
             .driver   = "pc-sysfw",
diff --git a/kvm-all.c b/kvm-all.c
index 888245d..4bcda06 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -882,6 +882,7 @@ int kvm_init(void)
     const KVMCapabilityInfo *missing_cap;
     int ret;
     int i;
+    QemuOptsList *list;
 
     s = g_malloc0(sizeof(KVMState));
 
@@ -968,6 +969,13 @@ int kvm_init(void)
     s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
 #endif
 
+    list = qemu_find_opts("machine");
+    if (!QTAILQ_EMPTY(&list->head) &&
+        !qemu_opt_get_bool(QTAILQ_FIRST(&list->head),
+                           "kernel_irqchip", false)) {
+        kvm_irqchip = 0;
+    }
+
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
diff --git a/vl.c b/vl.c
index dddf212..124cff1 100644
--- a/vl.c
+++ b/vl.c
@@ -2113,13 +2113,8 @@ static int configure_accelerator(void)
     }
 
     if (p == NULL) {
-#ifdef CONFIG_KVM_OPTIONS
-        /* Use the default "accelerator", kvm */
-        p = "kvm";
-#else
         /* Use the default "accelerator", tcg */
         p = "tcg";
-#endif
     }
 
     while (!accel_initialised && *p != '\0') {
@@ -2978,12 +2973,12 @@ int main(int argc, char **argv, char **envp)
                 break;
 	    case QEMU_OPTION_no_kvm:
                 olist = qemu_find_opts("machine");
-                qemu_opts_reset(olist);
                 qemu_opts_parse(olist, "accel=tcg", 0);
                 break;
 #ifdef CONFIG_KVM_OPTIONS
 	    case QEMU_OPTION_no_kvm_irqchip: {
-		kvm_irqchip = 0;
+                olist = qemu_find_opts("machine");
+                qemu_opts_parse(olist, "kernel_irqchip=off", 0);
 		break;
 	    }
 	    case QEMU_OPTION_no_kvm_pit: {
-- 
1.7.3.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