From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH kvm-unit-tests 2/4] Introduce a C++ wrapper for the kvm APIs Date: Mon, 29 Nov 2010 00:28:47 +0200 Message-ID: <20101128222847.GA19081@redhat.com> References: <1290595933-13122-1-git-send-email-avi@redhat.com> <1290595933-13122-3-git-send-email-avi@redhat.com> <50DD1E97-0ECD-41E6-B6F8-1D78AA4A4876@suse.de> <4CED2416.1040102@codemonkey.ws> <20101128122737.GC11685@redhat.com> <4CF2D1F2.8030309@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Graf , Avi Kivity , Marcelo Tosatti , kvm@vger.kernel.org To: Anthony Liguori Return-path: Received: from mx1.redhat.com ([209.132.183.28]:62351 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752055Ab0K1W3K (ORCPT ); Sun, 28 Nov 2010 17:29:10 -0500 Content-Disposition: inline In-Reply-To: <4CF2D1F2.8030309@codemonkey.ws> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Nov 28, 2010 at 04:04:34PM -0600, Anthony Liguori wrote: > >To create an object on the stack, you must have the class definition in > >a public header and a public constructor/destructor. > >This is exactly the same in C. > > It's really more of a design statement than a statement about C++ vs. C. > > In qdev today, we mix object initialization with a user-exposed > factory. This means that you cannot do something simple like: > > struct i440fx { > struct piix3 piix; > }; > > void i440fx_init(struct i440fx_init *obj) { > piix3_init(&obj->piix); > } > > But rather need to use ugly factory functions with all sorts of > DO_UPCAST. This is really unfriendly especially for writing test > cases. Yes, I agree. Just moving memory allocation out of there will fix most of the ugliness. -- MST