[PATCH v2 19/58] hvf: Move HVFState typedef to hvf.h

Eduardo Habkost posted 58 patches 5 years, 5 months ago
There is a newer version of this series
[PATCH v2 19/58] hvf: Move HVFState typedef to hvf.h
Posted by Eduardo Habkost 5 years, 5 months ago
Move typedef closer to the type check macros, to make it easier
to convert the code to OBJECT_DEFINE_TYPE() in the future.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2: none

---
Cc: Cameron Esfahani <dirty@apple.com>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
 include/sysemu/hvf.h       | 1 +
 target/i386/hvf/hvf-i386.h | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
index d3bed80ea8..760d6c79a2 100644
--- a/include/sysemu/hvf.h
+++ b/include/sysemu/hvf.h
@@ -35,6 +35,7 @@ void hvf_vcpu_destroy(CPUState *);
 
 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
 
+typedef struct HVFState HVFState;
 #define HVF_STATE(obj) \
     OBJECT_CHECK(HVFState, (obj), TYPE_HVF_ACCEL)
 
diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h
index ef20c73eca..e0edffd077 100644
--- a/target/i386/hvf/hvf-i386.h
+++ b/target/i386/hvf/hvf-i386.h
@@ -57,13 +57,13 @@ typedef struct hvf_vcpu_caps {
     uint64_t vmx_cap_preemption_timer;
 } hvf_vcpu_caps;
 
-typedef struct HVFState {
+struct HVFState {
     AccelState parent;
     hvf_slot slots[32];
     int num_slots;
 
     hvf_vcpu_caps *hvf_caps;
-} HVFState;
+};
 extern HVFState *hvf_state;
 
 void hvf_set_phys_mem(MemoryRegionSection *, bool);
-- 
2.26.2


Re: [PATCH v2 19/58] hvf: Move HVFState typedef to hvf.h
Posted by Roman Bolshakov 5 years, 5 months ago
On Wed, Aug 19, 2020 at 08:11:57PM -0400, Eduardo Habkost wrote:
> Move typedef closer to the type check macros, to make it easier
> to convert the code to OBJECT_DEFINE_TYPE() in the future.
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2: none
> 
> ---
> Cc: Cameron Esfahani <dirty@apple.com>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  include/sysemu/hvf.h       | 1 +
>  target/i386/hvf/hvf-i386.h | 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
> index d3bed80ea8..760d6c79a2 100644
> --- a/include/sysemu/hvf.h
> +++ b/include/sysemu/hvf.h
> @@ -35,6 +35,7 @@ void hvf_vcpu_destroy(CPUState *);
>  
>  #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
>  
> +typedef struct HVFState HVFState;

Forward declaration of HVFState is missed before the typedef.

>  #define HVF_STATE(obj) \
>      OBJECT_CHECK(HVFState, (obj), TYPE_HVF_ACCEL)
>  
> diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h
> index ef20c73eca..e0edffd077 100644
> --- a/target/i386/hvf/hvf-i386.h
> +++ b/target/i386/hvf/hvf-i386.h
> @@ -57,13 +57,13 @@ typedef struct hvf_vcpu_caps {
>      uint64_t vmx_cap_preemption_timer;
>  } hvf_vcpu_caps;
>  
> -typedef struct HVFState {
> +struct HVFState {
>      AccelState parent;
>      hvf_slot slots[32];
>      int num_slots;
>  
>      hvf_vcpu_caps *hvf_caps;
> -} HVFState;
> +};
>  extern HVFState *hvf_state;
>  
>  void hvf_set_phys_mem(MemoryRegionSection *, bool);
> -- 
> 2.26.2
> 

Re: [PATCH v2 19/58] hvf: Move HVFState typedef to hvf.h
Posted by Eduardo Habkost 5 years, 5 months ago
On Fri, Aug 21, 2020 at 02:23:55PM +0300, Roman Bolshakov wrote:
> On Wed, Aug 19, 2020 at 08:11:57PM -0400, Eduardo Habkost wrote:
> > Move typedef closer to the type check macros, to make it easier
> > to convert the code to OBJECT_DEFINE_TYPE() in the future.
> > 
> > Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > Changes v1 -> v2: none
> > 
> > ---
> > Cc: Cameron Esfahani <dirty@apple.com>
> > Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Richard Henderson <rth@twiddle.net>
> > Cc: Eduardo Habkost <ehabkost@redhat.com>
> > Cc: qemu-devel@nongnu.org
> > ---
> >  include/sysemu/hvf.h       | 1 +
> >  target/i386/hvf/hvf-i386.h | 4 ++--
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
> > index d3bed80ea8..760d6c79a2 100644
> > --- a/include/sysemu/hvf.h
> > +++ b/include/sysemu/hvf.h
> > @@ -35,6 +35,7 @@ void hvf_vcpu_destroy(CPUState *);
> >  
> >  #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
> >  
> > +typedef struct HVFState HVFState;
> 
> Forward declaration of HVFState is missed before the typedef.

Why is that an issue?

-- 
Eduardo


Re: [PATCH v2 19/58] hvf: Move HVFState typedef to hvf.h
Posted by Roman Bolshakov 5 years, 5 months ago
On Wed, Aug 19, 2020 at 08:11:57PM -0400, Eduardo Habkost wrote:
> Move typedef closer to the type check macros, to make it easier
> to convert the code to OBJECT_DEFINE_TYPE() in the future.
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2: none
> 
> ---
> Cc: Cameron Esfahani <dirty@apple.com>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  include/sysemu/hvf.h       | 1 +
>  target/i386/hvf/hvf-i386.h | 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
> index d3bed80ea8..760d6c79a2 100644
> --- a/include/sysemu/hvf.h
> +++ b/include/sysemu/hvf.h
> @@ -35,6 +35,7 @@ void hvf_vcpu_destroy(CPUState *);
>  
>  #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
>  
> +typedef struct HVFState HVFState;
>  #define HVF_STATE(obj) \
>      OBJECT_CHECK(HVFState, (obj), TYPE_HVF_ACCEL)
>  
> diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h
> index ef20c73eca..e0edffd077 100644
> --- a/target/i386/hvf/hvf-i386.h
> +++ b/target/i386/hvf/hvf-i386.h
> @@ -57,13 +57,13 @@ typedef struct hvf_vcpu_caps {
>      uint64_t vmx_cap_preemption_timer;
>  } hvf_vcpu_caps;
>  
> -typedef struct HVFState {
> +struct HVFState {
>      AccelState parent;
>      hvf_slot slots[32];
>      int num_slots;
>  
>      hvf_vcpu_caps *hvf_caps;
> -} HVFState;
> +};
>  extern HVFState *hvf_state;
>  
>  void hvf_set_phys_mem(MemoryRegionSection *, bool);
> -- 
> 2.26.2
> 

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>

But it seems the accel misuses QOM as pointed out in the other thread.
I also don't see a place where HVF_STATE is invoked... ah, you're
replacing it later in "Use DECLARE_*CHECKER* macros".

Thanks,
Roman