Skip to contentSkip to conversation

KVM: Cleanup the kvm_print functions and introduce pr_XX wrappers

PATCH Applied Christoffer Dall 2 participants 2 messages Jun 3, 2012 – Jun 6, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 KVM: Cleanup the kvm_print functions and introduce pr_XX wrappers

Introduces a couple of print functions, which are essentially wrappers around standard printk functions, with a KVM: prefix.

Functions introduced or modified are:
- kvm_err(fmt, ...)
- kvm_info(fmt, ...)
- kvm_debug(fmt, ...)
- kvm_pr_unimpl(fmt, ...)
- pr_unimpl(vcpu, fmt, ...) -> vcpu_unimpl(vcpu, fmt, ...)

Applies to kvm-next

Changelog[3]:
- use task_pid_nr wrapper
- corrent cpu -> vcpu
Changelog[2]:
- Added PID to print functions
- Renamed vcpu_pr_unimpl to vcpu_unimpl

---
 arch/x86/kvm/svm.c       |    6 +++--
 arch/x86/kvm/vmx.c       |    2 +-
 arch/x86/kvm/x86.c       |   54 +++++++++++++++++++++++-----------------------
 include/linux/kvm_host.h |   18 ++++++++++-----
 4 files changed, 43 insertions(+), 37 deletions(-)
arch/x86/kvm/svm.c +3 -3
index f75af40..7a41878 100644
@@ -3185,8 +3185,8 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
 		break;
 	case MSR_IA32_DEBUGCTLMSR:
 		if (!boot_cpu_has(X86_FEATURE_LBRV)) {
-			pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n",
-					__func__, data);
+			vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n",
+				    __func__, data);
 			break;
 		}
 		if (data & DEBUGCTL_RESERVED_BITS)
@@ -3205,7 +3205,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
 	case MSR_VM_CR:
 		return svm_set_vm_cr(vcpu, data);
 	case MSR_VM_IGNNE:
-		pr_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
+		vcpu_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
 		break;
 	default:
 		return kvm_set_msr_common(vcpu, ecx, data);
arch/x86/kvm/vmx.c +1 -1
index 32eb588..c6b2d25 100644
@@ -4489,7 +4489,7 @@ static int handle_cr(struct kvm_vcpu *vcpu)
 		break;
 	}
 	vcpu->run->exit_reason = 0;
-	pr_unimpl(vcpu, "unhandled control register: op %d cr %d\n",
+	vcpu_unimpl(vcpu, "unhandled control register: op %d cr %d\n",
 	       (int)(exit_qualification >> 4) & 3, cr);
 	return 0;
 }
arch/x86/kvm/x86.c +27 -27

147 lines not on this page · raw message

include/linux/kvm_host.h +12 -6
index c446435..734e26f 100644
@@ -314,13 +314,19 @@ struct kvm {
 	long tlbs_dirty;
 };
 
-/* The guest did something we don't support. */
-#define pr_unimpl(vcpu, fmt, ...)					\
-	pr_err_ratelimited("kvm: %i: cpu%i " fmt,			\
-			   current->tgid, (vcpu)->vcpu_id , ## __VA_ARGS__)
+#define kvm_err(fmt, ...) \
+	pr_err("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
+#define kvm_info(fmt, ...) \
+	pr_info("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
+#define kvm_debug(fmt, ...) \
+	pr_debug("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
+#define kvm_pr_unimpl(fmt, ...) \
+	pr_err_ratelimited("kvm [%i]: " fmt, \
+			   task_tgid_nr(current), ## __VA_ARGS__)
 
-#define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
-#define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt)
+/* The guest did something we don't support. */
+#define vcpu_unimpl(vcpu, fmt, ...)					\
+	kvm_pr_unimpl("vcpu%i " fmt, (vcpu)->vcpu_id, ## __VA_ARGS__)
 
 static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
 {
Applied
#1 lore raw
Quoted 11 lines · Christoffer Dall

Introduces a couple of print functions, which are essentially wrappers around standard printk functions, with a KVM: prefix.

Functions introduced or modified are:
- kvm_err(fmt, ...)
- kvm_info(fmt, ...)
- kvm_debug(fmt, ...)
- kvm_pr_unimpl(fmt, ...)
- pr_unimpl(vcpu, fmt, ...) -> vcpu_unimpl(vcpu, fmt, ...)

Applies to kvm-next

Thanks, applied.

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