From patchwork Fri Oct 12 12:47:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10638645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A050917E1 for ; Fri, 12 Oct 2018 12:48:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 852D229753 for ; Fri, 12 Oct 2018 12:48:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F5B12932E; Fri, 12 Oct 2018 12:48:12 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 E02B8205F7 for ; Fri, 12 Oct 2018 12:48:11 +0000 (UTC) Received: from localhost ([::1]:40381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAwrT-0004Sj-8Z for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Oct 2018 08:48:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAwqS-0003mg-0b for qemu-devel@nongnu.org; Fri, 12 Oct 2018 08:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAwqN-00048V-Va for qemu-devel@nongnu.org; Fri, 12 Oct 2018 08:47:07 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]:42818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAwqN-00046x-Md for qemu-devel@nongnu.org; Fri, 12 Oct 2018 08:47:03 -0400 Received: by mail-wr1-f45.google.com with SMTP id g15-v6so13297016wru.9 for ; Fri, 12 Oct 2018 05:47:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=RTqRFK2aPSrxNPshyXojsA37vvvWl4QZX8isKX6268g=; b=iDzXSUT7hvzas0ekSqP7yuypBmCIABmnCsAbtXunvNWfJNrJD9MDue5/brFU3hpqrn WVAfgjqOdrWNf4UM2LqEEM9I/1axYE7uRS1PC++dki5shUJaR1/qCsI2gHGuaR2rV0s4 ji21W8vfBkla5buSo304zL5I0PZcgAQN5MKpK9782qQEpuV8GRmbmKj9TnHWXCoctJPp dESKHEqa4FNhVKeAveL9+ugMi55YM9W31vv66JZUR1it5twQo9KttCTVjHw1Thw33xQ0 +gDBKMlbGOJjvo4sdlcLNwpNS5QVVZ05bwRTJtKS4Ld6Vr38k9BNhTX1F/Gonw/hXd1h xmQw== X-Gm-Message-State: ABuFfoj4h81i9y42Tv+qnhrEUdsBXKydThAT0dzgYyovu/9n5lSydUWr VuvjgeoRbs1Q1FQ/hoz4ONbJ/Q== X-Google-Smtp-Source: ACcGV602PhBvUyVtS65KX4uvUShSqbiizvknWsNASm+oF9JDp/D0mvHbFNFimZy7gUClM97p0Fyxag== X-Received: by 2002:a5d:51c7:: with SMTP id n7-v6mr5118067wrv.121.1539348422648; Fri, 12 Oct 2018 05:47:02 -0700 (PDT) Received: from [192.168.2.33] (62.red-88-24-165.staticip.rima-tde.net. [88.24.165.62]) by smtp.gmail.com with ESMTPSA id 130-v6sm1405644wmn.7.2018.10.12.05.47.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 05:47:01 -0700 (PDT) To: QEMU Developers , Eduardo Habkost , Thomas Huth , Peter Maydell From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Message-ID: Date: Fri, 12 Oct 2018 14:47:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.45 Subject: [Qemu-devel] QOM: Can devices having link properties be user-creatable? 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: Mao Zhongyi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP While looking at Mao's series (https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg02519.html) I wondered if devices having link properties can be user-creatable. Using the following patch (I don't think this is correct to put qdev code into qobject, but I used this as PoC): -- >8 -- prop->child = child; --- I get: $ aarch64-softmmu/qemu-system-aarch64 -M virt qemu-system-aarch64: warning: Device type 'bus' is user_creatable (linked property: 'parent_bus') qemu-system-aarch64: warning: Device type 'qemu:memory-region' is user_creatable (linked property: 'memory') qemu-system-aarch64: warning: Device type 'bus' is user_creatable (linked property: 'parent_bus') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'unnamed-gpio-out[0]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'unnamed-gpio-out[1]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'unnamed-gpio-out[2]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'unnamed-gpio-out[3]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'gicv3-maintenance-interrupt[0]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'pmu-interrupt[0]') qemu-system-aarch64: warning: Device type 'qemu:memory-region' is user_creatable (linked property: 'secure-memory') qemu-system-aarch64: warning: Device type 'bus' is user_creatable (linked property: 'parent_bus') qemu-system-aarch64: warning: Device type 'bus' is user_creatable (linked property: 'parent_bus') qemu-system-aarch64: warning: Device type 'bus' is user_creatable (linked property: 'parent_bus') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'sysbus-irq[0]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'sysbus-irq[1]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'sysbus-irq[2]') qemu-system-aarch64: warning: Device type 'irq' is user_creatable (linked property: 'sysbus-irq[3]') Are we incorrectly using user_creatable = true in those devices/ Am I missing something? Thanks, Phil. diff --git a/qom/object.c b/qom/object.c index 547dcf97c3..2dd3a25531 100644 --- a/qom/object.c +++ b/qom/object.c @@ -16,4 +16,5 @@ #include "qom/object_interfaces.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" #include "qapi/visitor.h" #include "qapi/string-input-visitor.h" @@ -1662,4 +1663,11 @@ void object_property_add_link(Object *obj, const char *name, gchar *full_type; ObjectProperty *op; + ObjectClass *klass = object_get_class(obj); + + if (klass && object_dynamic_cast(obj, TYPE_DEVICE) && + DEVICE_CLASS(klass)->user_creatable == false) { + warn_report("Device type '%s' is user_creatable " + "(linked property: '%s')", type, name); + }