From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NxjZQ-0003RR-RM for qemu-devel@nongnu.org; Fri, 02 Apr 2010 12:18:08 -0400 Received: from [140.186.70.92] (port=39315 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxjZP-0003QU-NJ for qemu-devel@nongnu.org; Fri, 02 Apr 2010 12:18:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NxjZO-0004xR-8H for qemu-devel@nongnu.org; Fri, 02 Apr 2010 12:18:07 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:64287) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NxjZO-0004xG-3o for qemu-devel@nongnu.org; Fri, 02 Apr 2010 12:18:06 -0400 Received: by pwi6 with SMTP id 6so1738986pwi.4 for ; Fri, 02 Apr 2010 09:18:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4BB61610.40106@redhat.com> References: <1270219540-30027-1-git-send-email-pbonzini@redhat.com> <4BB60BB9.2050301@codemonkey.ws> <4BB610A7.8010006@redhat.com> <4BB61610.40106@redhat.com> Date: Fri, 2 Apr 2010 19:18:04 +0300 Message-ID: Subject: Re: [Qemu-devel] [PATCH] provide opaque CPUState to files that are compiled once From: Blue Swirl Content-Type: text/plain; charset=UTF-8 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On 4/2/10, Paolo Bonzini wrote: > > > > > > > qemu-kvm.h references CPUState and includes cpu.h, so with the latest > > > changes all files that include qemu-kvm.h break, even if they don't > require > > > qemu-kvm.h. With this patch they instead get the opaque definition via > > > hw/hw.h (which includes cpu-common.h), and qemu-kvm.h can avoid > including > > > cpu.h. > > > > > > > This is why I added #ifndef NEED_CPU_H to kvm.h. > > > > Yes, but adding NEED_CPU_H everywhere is just as bad, or worse. I fully agree that devices should not use NEED_CPU_H. > > > > > Another example is the new apic.h file created by Blue Swirl. It > > > references CPUState. It includes apic_get_irq_delivered, so I placed > > > apic_set_irq_delivered there too. But apic_set_irq_delivered is used by > > > i8259.c which is compiled once. > > > > > > > But i8259.c is compiled per target, grep Makefile.target? > > > > Hmm, that was something else, but apic.h was it. :-) As a concrete example, qemu-kvm's apic.c and ours differ w.r.t. CPUState use only in kvm_save/load_lapic. But these functions could just as easily take APICState* as their parameter and the need to pass CPUState is gone.