[Qemu-devel] [PATCH for-2.10] kvm: Print MSR information if KVM_SET_MSRS failed

Eduardo Habkost posted 1 patch 8 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170309193117.24885-1-ehabkost@redhat.com
Test checkpatch passed
Test docker passed
target/i386/kvm.c | 6 ++++++
1 file changed, 6 insertions(+)
[Qemu-devel] [PATCH for-2.10] kvm: Print MSR information if KVM_SET_MSRS failed
Posted by Eduardo Habkost 8 years, 8 months ago
When a KVM_SET_MSRS ioctl() fails, it is difficult to find out
which MSR caused the problem. Print an error message for
debugging, before we trigger the (ret == cpu->kvm_msr_buf->nmsrs)
assert.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/kvm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 887a81268f..3a874e4717 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -1807,6 +1807,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
         return ret;
     }
 
+    if (ret < cpu->kvm_msr_buf->nmsrs) {
+        struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret];
+        error_report("error: failed to set MSR 0x%" PRIx32 " to 0x%" PRIx64,
+                     (uint32_t)e->index, (uint64_t)e->data);
+    }
+
     assert(ret == cpu->kvm_msr_buf->nmsrs);
     return 0;
 }
-- 
2.11.0.259.g40922b1


Re: [Qemu-devel] [PATCH for-2.10] kvm: Print MSR information if KVM_SET_MSRS failed
Posted by Dr. David Alan Gilbert 8 years, 8 months ago
* Eduardo Habkost (ehabkost@redhat.com) wrote:
> When a KVM_SET_MSRS ioctl() fails, it is difficult to find out
> which MSR caused the problem. Print an error message for
> debugging, before we trigger the (ret == cpu->kvm_msr_buf->nmsrs)
> assert.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  target/i386/kvm.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index 887a81268f..3a874e4717 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -1807,6 +1807,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
>          return ret;
>      }
>  
> +    if (ret < cpu->kvm_msr_buf->nmsrs) {
> +        struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret];
> +        error_report("error: failed to set MSR 0x%" PRIx32 " to 0x%" PRIx64,
> +                     (uint32_t)e->index, (uint64_t)e->data);
> +    }
> +

Yes, I'd thought about doing the same; had you considered adding it on the get
as well?

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Dave

>      assert(ret == cpu->kvm_msr_buf->nmsrs);
>      return 0;
>  }
> -- 
> 2.11.0.259.g40922b1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH for-2.10] kvm: Print MSR information if KVM_SET_MSRS failed
Posted by Eduardo Habkost 8 years, 8 months ago
On Thu, Mar 09, 2017 at 07:34:15PM +0000, Dr. David Alan Gilbert wrote:
> * Eduardo Habkost (ehabkost@redhat.com) wrote:
> > When a KVM_SET_MSRS ioctl() fails, it is difficult to find out
> > which MSR caused the problem. Print an error message for
> > debugging, before we trigger the (ret == cpu->kvm_msr_buf->nmsrs)
> > assert.
> > 
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  target/i386/kvm.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> > index 887a81268f..3a874e4717 100644
> > --- a/target/i386/kvm.c
> > +++ b/target/i386/kvm.c
> > @@ -1807,6 +1807,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
> >          return ret;
> >      }
> >  
> > +    if (ret < cpu->kvm_msr_buf->nmsrs) {
> > +        struct kvm_msr_entry *e = &cpu->kvm_msr_buf->entries[ret];
> > +        error_report("error: failed to set MSR 0x%" PRIx32 " to 0x%" PRIx64,
> > +                     (uint32_t)e->index, (uint64_t)e->data);
> > +    }
> > +
> 
> Yes, I'd thought about doing the same;

Actually, I forgot to add:

Suggested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

as it was your idea. :)


>                                        had you considered adding it on the get
> as well?

I don't remember hitting the kvm_get_msrs() assert(), so I didn't
consider doing it.

But it looks useful, I will submit a separate patch.

> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Thanks!

> 
> Dave
> 
> >      assert(ret == cpu->kvm_msr_buf->nmsrs);
> >      return 0;
> >  }
> > -- 
> > 2.11.0.259.g40922b1
> > 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

-- 
Eduardo