From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBLrt-0007w1-Sc for qemu-devel@nongnu.org; Mon, 19 Aug 2013 05:35:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBLro-0005qp-6D for qemu-devel@nongnu.org; Mon, 19 Aug 2013 05:35:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBLrn-0005qk-Ub for qemu-devel@nongnu.org; Mon, 19 Aug 2013 05:35:16 -0400 From: Markus Armbruster References: <1376659114-6630-1-git-send-email-armbru@redhat.com> <1376659114-6630-7-git-send-email-armbru@redhat.com> <520F75AB.9020904@suse.de> Date: Mon, 19 Aug 2013 11:35:13 +0200 In-Reply-To: <520F75AB.9020904@suse.de> ("Andreas =?utf-8?Q?F=C3=A4rber=22?= =?utf-8?Q?'s?= message of "Sat, 17 Aug 2013 15:07:55 +0200") Message-ID: <87fvu6dnvy.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 6/7] vl: Set current_machine early List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: aliguori@us.ibm.com, lersek@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com Andreas F=C3=A4rber writes: > Am 16.08.2013 15:18, schrieb armbru@redhat.com: >> From: Markus Armbruster >>=20 >> I'd like to access QEMUMachine from a QEMUMachine init() method, which >> is currently not possible. Instead of passing it as an argument, I >> simply set current_machine earlier. > > We had such a patch for CPU hot-add and decided against doing this. > Currently current_machine !=3D signals that it has been initialized. And Does any code actually depend on this undocumented condition? I found none. > generally we have been trying to get away from accessing globals from > random parts of code. Global state need to be managed with care. Global variables have their place in that. In my experience, the most common kind of carelessness involving global variables is indisciplined *updating* of global state via global variables. Unchanging global state is relatively harmless, and referring to it via global variables is often the easiest and most obvious way to manage such state. > Can't you pass either QEMUMachine or the specific fields needed from PC > code to those SMBIOS functions? You did add a bool argument. Can't see how to do that without passing the machine to QEMUMachine method init(), which involves touching all boards. I doubt that's a good idea, but if you insist, I can do it.