From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNlBl-0004Ob-Ml for qemu-devel@nongnu.org; Thu, 14 Jul 2016 14:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNlBh-0001ac-7p for qemu-devel@nongnu.org; Thu, 14 Jul 2016 14:16:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNlBh-0001aW-2A for qemu-devel@nongnu.org; Thu, 14 Jul 2016 14:16:41 -0400 From: Bandan Das References: <1468515285-173356-1-git-send-email-imammedo@redhat.com> <1468515285-173356-5-git-send-email-imammedo@redhat.com> <20160714175453.GZ3727@thinpad.lan.raisama.net> Date: Thu, 14 Jul 2016 14:16:39 -0400 In-Reply-To: <20160714175453.GZ3727@thinpad.lan.raisama.net> (Eduardo Habkost's message of "Thu, 14 Jul 2016 14:54:53 -0300") Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 04/16] pc: forbid BSP removal List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Igor Mammedov , qemu-devel@nongnu.org, pkrempa@redhat.com, mst@redhat.com, eduardo.otubo@profitbricks.com Eduardo Habkost writes: > On Thu, Jul 14, 2016 at 06:54:33PM +0200, Igor Mammedov wrote: >> BSP is assumed to always present in QEMU code, so >> untile that assumptions are gone, deny removal request. >> In another words QEMU won't support BSP hot-unplug. >> >> Signed-off-by: Igor Mammedov >> --- >> hw/i386/pc.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/hw/i386/pc.c b/hw/i386/pc.c >> index 5a67f15..33c5f97 100644 >> --- a/hw/i386/pc.c >> +++ b/hw/i386/pc.c >> @@ -1751,10 +1751,17 @@ out: >> static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, >> DeviceState *dev, Error **errp) >> { >> + int idx; >> HotplugHandlerClass *hhc; >> Error *local_err = NULL; >> PCMachineState *pcms = PC_MACHINE(hotplug_dev); >> >> + pc_find_cpu_slot(pcms, CPU(dev), &idx); > > Looks fragile: if one day we create any TYPE_CPU object that is > not in possible_cpus array, idx is undefined. I suggest > initializing idx to -1 above. Or just let pc_find_cpu_slot universally set it to -1 since this series assumes that -1 means index isn't valid. > I can change it when committing, if that's OK for you. > > >> + if (idx == 0) { >> + error_setg(&local_err, "1st CPU (BSP) is unpluggable"); >> + goto out; >> + } >> + >> hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); >> hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); >> >> -- >> 2.7.4 >>