From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNcxz-0008W0-5G for qemu-devel@nongnu.org; Mon, 25 Jan 2016 03:57:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNcxv-0008EJ-SK for qemu-devel@nongnu.org; Mon, 25 Jan 2016 03:57:43 -0500 Received: from e28smtp03.in.ibm.com ([125.16.236.3]:52282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNcxv-0008Dz-6o for qemu-devel@nongnu.org; Mon, 25 Jan 2016 03:57:39 -0500 Received: from localhost by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Jan 2016 14:27:33 +0530 Date: Mon, 25 Jan 2016 14:27:25 +0530 From: Bharata B Rao Message-ID: <20160125085725.GA17443@in.ibm.com> References: <1452236119-24452-1-git-send-email-bharata@linux.vnet.ibm.com> <1452236119-24452-2-git-send-email-bharata@linux.vnet.ibm.com> <20160123134722.GI3869@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160123134722.GI3869@thinpad.lan.raisama.net> Subject: Re: [Qemu-devel] [PATCH v6 01/11] machine: Don't allow CPU toplogies with partially filled cores Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au On Sat, Jan 23, 2016 at 11:47:22AM -0200, Eduardo Habkost wrote: > On Fri, Jan 08, 2016 at 12:25:09PM +0530, Bharata B Rao wrote: > > Prevent guests from booting with CPU topologies that have partially > > filled CPU cores or can result in partially filled CPU cores after > > CPU hotplug like > > > > -smp 15,sockets=1,cores=4,threads=4,maxcpus=16 or > > -smp 15,sockets=1,cores=4,threads=4,maxcpus=17. > > > > This is enforced by introducing MachineClass::validate_smp_config() > > that gets called from generic SMP parsing code. Machine type versions > > that don't want to enforce this can override this method. > > > > TODO: Only sPAPR and PC changes are done in this patch, other archs > > will be touched after there is agreement on this approach. > > > > Signed-off-by: Bharata B Rao > > --- > > hw/core/machine.c | 20 ++++++++++++++++++++ > > hw/i386/pc_piix.c | 7 +++++++ > > hw/i386/pc_q35.c | 7 +++++++ > > hw/ppc/spapr.c | 7 +++++++ > > include/hw/boards.h | 1 + > > vl.c | 4 ++++ > > 6 files changed, 46 insertions(+) > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c > > index c46ddc7..b66c101 100644 > > --- a/hw/core/machine.c > > +++ b/hw/core/machine.c > > @@ -336,6 +336,25 @@ static void machine_init_notify(Notifier *notifier, void *data) > > foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); > > } > > > > +static int validate_smp_config_generic(int smp_cpus, int max_cpus, > > + int smp_threads) > > Please make it use a Error** parameter to return error > information, and let the caller decide what to do with the error > message. One day the mc->validate_smp_config() call may be moved > inside a function that returns error information using Error** > and needs to propagate it to the caller. Sure, will make this change. I see that not all target archs use machine type versions and even if they do it will not be a one-line changer (as shown for i386 and sPAPR in this patch) for them to override mc->validate_smp_config() for older versions. So am I expected to change .class_init routine for all these archs by setting mc->validate_smp_config() to a NOP validate_smp_config() so that the default validate_smp_config() defined for TYPE_MACHINE is overridden ? In order to preserve the existing behaviour with CPU topology for all args, it appears that such a change would be necessary, but I am not sure how to test all of them. Will just a compile test do ? Regards, Bharata.