KVM: s390: Provide global debug log
authorChristian Borntraeger <borntraeger@de.ibm.com>
Wed, 22 Jul 2015 13:50:58 +0000 (15:50 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Wed, 29 Jul 2015 09:02:36 +0000 (11:02 +0200)
In addition to the per VM debug logs, let's provide a global
one for KVM-wide events, like new guests or fatal errors.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
arch/s390/include/asm/kvm_host.h
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/kvm-s390.h

index 764f91eed1b69c84752532459ea1486e52601070..df4db81254d3b86055bbb4fdb23be9e1f45c071d 100644 (file)
@@ -633,7 +633,6 @@ extern char sie_exit;
 
 static inline void kvm_arch_hardware_disable(void) {}
 static inline void kvm_arch_check_processor_compat(void *rtn) {}
-static inline void kvm_arch_exit(void) {}
 static inline void kvm_arch_sync_events(struct kvm *kvm) {}
 static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
 static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
index 4c1b5cbea1a6a40707bff4bfbae7b3c36d529b4a..762103653a2926ff819256cf3308ddb8ccd9955c 100644 (file)
@@ -127,6 +127,7 @@ unsigned long kvm_s390_fac_list_mask_size(void)
 }
 
 static struct gmap_notifier gmap_notifier;
+debug_info_t *kvm_s390_dbf;
 
 /* Section: not file related */
 int kvm_arch_hardware_enable(void)
@@ -151,10 +152,24 @@ void kvm_arch_hardware_unsetup(void)
 
 int kvm_arch_init(void *opaque)
 {
+       kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long));
+       if (!kvm_s390_dbf)
+               return -ENOMEM;
+
+       if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) {
+               debug_unregister(kvm_s390_dbf);
+               return -ENOMEM;
+       }
+
        /* Register floating interrupt controller interface. */
        return kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
 }
 
+void kvm_arch_exit(void)
+{
+       debug_unregister(kvm_s390_dbf);
+}
+
 /* Section: device related */
 long kvm_arch_dev_ioctl(struct file *filp,
                        unsigned int ioctl, unsigned long arg)
@@ -1100,7 +1115,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
        mutex_init(&kvm->arch.ipte_mutex);
 
        debug_register_view(kvm->arch.dbf, &debug_sprintf_view);
-       VM_EVENT(kvm, 3, "%s", "vm created");
+       VM_EVENT(kvm, 3, "vm created with type %lu", type);
 
        if (type & KVM_VM_S390_UCONTROL) {
                kvm->arch.gmap = NULL;
@@ -1117,6 +1132,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
        kvm->arch.epoch = 0;
 
        spin_lock_init(&kvm->arch.start_stop_lock);
+       KVM_EVENT(3, "vm 0x%p created by pid %u", kvm, current->pid);
 
        return 0;
 out_err:
@@ -1124,6 +1140,7 @@ out_err:
        free_page((unsigned long)kvm->arch.model.fac);
        debug_unregister(kvm->arch.dbf);
        free_page((unsigned long)(kvm->arch.sca));
+       KVM_EVENT(3, "creation of vm failed: %d", rc);
        return rc;
 }
 
@@ -1180,6 +1197,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
                gmap_free(kvm->arch.gmap);
        kvm_s390_destroy_adapters(kvm);
        kvm_s390_clear_float_irqs(kvm);
+       KVM_EVENT(3, "vm 0x%p destroyed", kvm);
 }
 
 /* Section: vcpu related */
index 0ee5db11598baacb87accb936574447788e2c778..c446aabf60d38890b3bcfb46e1eac6ce2f13361a 100644 (file)
@@ -27,6 +27,13 @@ typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);
 #define TDB_FORMAT1            1
 #define IS_ITDB_VALID(vcpu)    ((*(char *)vcpu->arch.sie_block->itdba == TDB_FORMAT1))
 
+extern debug_info_t *kvm_s390_dbf;
+#define KVM_EVENT(d_loglevel, d_string, d_args...)\
+do { \
+       debug_sprintf_event(kvm_s390_dbf, d_loglevel, d_string "\n", \
+         d_args); \
+} while (0)
+
 #define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
 do { \
        debug_sprintf_event(d_kvm->arch.dbf, d_loglevel, d_string "\n", \