Skip to contentSkip to conversation

simplify creation of kernel irqchip and pit

PATCH In review Glauber Costa 2 participants 4 messages Jul 24, 2009 – Jul 29, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 simplify creation of kernel irqchip and pit

Creation of those devices can be a lot simpler. In particular, if we start by assuming they will be on, and disabling later if anything fails (user request counts as failing here), we can remove two variables that really serves no reason.

---
 qemu-kvm-x86.c |   33 +++++++++++++++-------------
 qemu-kvm.c     |   65 +++++++++++++++++++++++++-------------------------------
 qemu-kvm.h     |    4 ---
 3 files changed, 47 insertions(+), 55 deletions(-)
qemu-kvm-x86.c +18 -15
index 492dbc5..0a42455 100644
@@ -116,24 +116,27 @@ static int kvm_init_identity_map_page(kvm_context_t kvm)
 
 static int kvm_create_pit(kvm_context_t kvm)
 {
+	int r = 0;
 #ifdef KVM_CAP_PIT
-	int r;
 
-	kvm->pit_in_kernel = 0;
-	if (!kvm->no_pit_creation) {
-		r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_PIT);
-		if (r > 0) {
-			r = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT);
-			if (r >= 0)
-				kvm->pit_in_kernel = 1;
-			else {
-				fprintf(stderr, "Create kernel PIC irqchip failed\n");
-				return r;
-			}
-		}
-	}
+    if (!qemu_kvm_pit_in_kernel())
+        return 0;
+
+    r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_PIT);
+    if (r < 0) {
+        goto disable_pit;
+    }
+    r = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT);
+    if (r < 0) {
+        fprintf(stderr, "Create kernel PIC irqchip failed\n");
+        goto disable_pit;
+    }
+
+    return 0;
+disable_pit:
+    kvm->pit_in_kernel = 0;
 #endif
-	return 0;
+    return r;
 }
 
 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
qemu-kvm.c +29 -36

99 lines not on this page · raw message

qemu-kvm.h +0 -4
index b186c9d..5eb1ee5 100644
@@ -55,14 +55,10 @@ struct kvm_context {
 	void *opaque;
 	/// is dirty pages logging enabled for all regions or not
 	int dirty_pages_log_all;
-	/// do not create in-kernel irqchip if set
-	int no_irqchip_creation;
 	/// in-kernel irqchip status
 	int irqchip_in_kernel;
 	/// ioctl to use to inject interrupts
 	int irqchip_inject_ioctl;
-	/// do not create in-kernel pit if set
-	int no_pit_creation;
 	/// in-kernel pit status
 	int pit_in_kernel;
 	/// in-kernel coalesced mmio
Signature · 1 line
1.6.2.2
#1 lore raw
Quoted 5 lines · Glauber Costa

Creation of those devices can be a lot simpler. In particular, if we start by assuming they will be on, and disabling later if anything fails (user request counts as failing here), we can remove two variables that really serves no reason.

The patch introduces mixed indentation. Please stick with one style or another.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
Quoted 9 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

Creation of those devices can be a lot simpler. In particular, if we start by assuming they will be on, and disabling later if anything fails (user request counts as failing here), we can remove two variables that really serves no reason.

The patch introduces mixed indentation. Please stick with one style or another.

Are you willin go "apply" my patch that changes everything to four spaces? If you are, I'm only resending things after that.

Quoted 4 lines
Signature · 2 lines
-- 
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 10 lines · Glauber Costa
Quoted 8 lines · Avi Kivity
Quoted 6 lines · Glauber Costa

Creation of those devices can be a lot simpler. In particular, if we start by assuming they will be on, and disabling later if anything fails (user request counts as failing here), we can remove two variables that really serves no reason.

Quoted 6 lines
Quoted 3 lines

The patch introduces mixed indentation. Please stick with one style or another.

Are you willin go "apply" my patch that changes everything to four spaces? If you are, I'm only resending things after that.

I'll look at it. I'm a bit wary about this, it may produce even brokener indentation. Perhaps a run through indent would help.

Signature · 1 line
error compiling committee.c: too many arguments to function