Fix to issues with kvm.h and g++

Daniel Godás
2008-11-02T22:39:07Z

Hello,

I am writing a kvm-based emulation framework in c++. When I included
<linux/kvm.h> I got the following errors:

/usr/include/linux/kvm.h:89: error: 'struct kvm_run::<anonymous
union>::kvm_io' invalid; an anonymous union can only have non-static
data members
/usr/include/linux/kvm.h:230: error: declaration of '__u64
kvm_dirty_log::<anonymous union>::padding'
/usr/include/linux/kvm.h:227: error: conflicts with previous
declaration '__u32 kvm_dirty_log::padding'
/usr/include/linux/kvm.h:89: error: 'struct kvm_run::<anonymous
union>::kvm_io' invalid; an anonymous union can only have non-static
data members
/usr/include/linux/kvm.h:230: error: declaration of '__u64
kvm_dirty_log::<anonymous union>::padding'
/usr/include/linux/kvm.h:227: error: conflicts with previous
declaration '__u32 kvm_dirty_log::padding'

It looks like nobody uses struct kvm_io nor in kernel or user space.
The same happens with the two padding fields. The following patch
fixes the errors:

diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 44fd7fa..f357d50 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -119,7 +119,7 @@ struct kvm_run {
__u32 error_code;
} ex;
/* KVM_EXIT_IO */
- struct kvm_io {
+ struct {
#define KVM_EXIT_IO_IN 0
#define KVM_EXIT_IO_OUT 1
__u8 direction;
@@ -238,10 +238,10 @@ struct kvm_debug_guest {
/* for KVM_GET_DIRTY_LOG */
struct kvm_dirty_log {
__u32 slot;
- __u32 padding;
+ __u32 padding1;
union {
void __user *dirty_bitmap; /* one bit per page */
- __u64 padding;
+ __u64 padding2;
};
};

Cheers,
Daniel