qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [for-5.0 PATCH] ppc: Make PPCVirtualHypervisor an incomplete type


From: Philippe Mathieu-Daudé
Subject: Re: [for-5.0 PATCH] ppc: Make PPCVirtualHypervisor an incomplete type
Date: Mon, 9 Dec 2019 15:02:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

On 12/9/19 2:28 PM, Greg Kurz wrote:
PPCVirtualHypervisor is an interface instance. It should never be
dereferenced. Drop the dummy type definition for extra safety, which
is the common practice with QOM interfaces.

This "common practice" is also referenced in commit 00ed3da9b5:

    xics: Minor fixes for XICSFabric interface

Interface instances should never be directly dereferenced. So, the common practice is to make them incomplete types to make sure no-one does that.
    XICSFrabric, however, had a dummy type which is less safe.

    We were also using OBJECT_CHECK() where we should have been using
    INTERFACE_CHECK().

This indeed follow the changes from commit aa1b35b975d8:

    qom: make interface types abstract

    Interfaces don't have instance, let's make the interface type really
    abstract to avoid confusion.

Now I can't find guidelines for this. If you don't know about it and use 'git-grep', it is very confusing to see we use structures we never define.

Can we document this use please?

Signed-off-by: Greg Kurz <address@hidden>
---
  target/ppc/cpu.h |    4 ----
  1 file changed, 4 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index e3e82327b723..ab7d07d66047 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1220,10 +1220,6 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);
  PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr);
  PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc);
-struct PPCVirtualHypervisor {
-    Object parent;
-};
-
  struct PPCVirtualHypervisorClass {
      InterfaceClass parent;
      void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);






reply via email to

[Prev in Thread] Current Thread [Next in Thread]