From patchwork Thu Dec 29 22:38:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9491637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90F9D62AB7 for ; Thu, 29 Dec 2016 22:38:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DE901FE82 for ; Thu, 29 Dec 2016 22:38:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EE2320649; Thu, 29 Dec 2016 22:38:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01EA81FE82 for ; Thu, 29 Dec 2016 22:38:47 +0000 (UTC) Received: from localhost ([::1]:37606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMjLS-0006ag-4S for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Dec 2016 17:38:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMjLA-0006ab-DG for qemu-devel@nongnu.org; Thu, 29 Dec 2016 17:38:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMjL7-0006Wg-AE for qemu-devel@nongnu.org; Thu, 29 Dec 2016 17:38:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40112) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cMjL7-0006VT-3t for qemu-devel@nongnu.org; Thu, 29 Dec 2016 17:38:25 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D02F93D978; Thu, 29 Dec 2016 22:38:21 +0000 (UTC) Received: from localhost (ovpn-116-4.gru2.redhat.com [10.97.116.4]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBTMcKQ9014242; Thu, 29 Dec 2016 17:38:21 -0500 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 29 Dec 2016 20:38:15 -0200 Message-Id: <20161229223815.13705-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 29 Dec 2016 22:38:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qdev: Make "hotplugged" property read-only X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" , Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The "hotplugged" property is user visible, but it was never meant to be set by the user. There are probably multiple ways to break or crash device code by overriding the property. One example: $ qemu-system-x86_64 -cpu qemu64,hotplugged=true Segmentation fault (core dumped) The DeviceState::hotplugged struct field is set directly by device_initfn(), there's no need to provide a setter for the property. Signed-off-by: Eduardo Habkost --- hw/core/qdev.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 57834423b9..f5989c41cb 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1013,13 +1013,6 @@ static bool device_get_hotplugged(Object *obj, Error **err) return dev->hotplugged; } -static void device_set_hotplugged(Object *obj, bool value, Error **err) -{ - DeviceState *dev = DEVICE(obj); - - dev->hotplugged = value; -} - static void device_initfn(Object *obj) { DeviceState *dev = DEVICE(obj); @@ -1039,7 +1032,7 @@ static void device_initfn(Object *obj) object_property_add_bool(obj, "hotpluggable", device_get_hotpluggable, NULL, NULL); object_property_add_bool(obj, "hotplugged", - device_get_hotplugged, device_set_hotplugged, + device_get_hotplugged, NULL, &error_abort); class = object_get_class(OBJECT(dev));