From nobody Fri May 17 09:38:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629317041437771.7369298070209; Wed, 18 Aug 2021 13:04:01 -0700 (PDT) Received: from localhost ([::1]:57202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGRn6-0007oh-9N for importer@patchew.org; Wed, 18 Aug 2021 16:04:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRSE-0007tO-N8 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:42:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRSD-00073Y-4M for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:42:26 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-8RJVJO5aMxe1MKU3GM7lkA-1; Wed, 18 Aug 2021 15:42:23 -0400 Received: by mail-qv1-f71.google.com with SMTP id f10-20020a0ccc8a0000b02903521ac3b9d7so2915403qvl.15 for ; Wed, 18 Aug 2021 12:42:23 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id y185sm419779qkb.36.2021.08.18.12.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 12:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629315744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=56KQolnKGhiF1X+C5PY8YNpm/K8e5udbyrIkFGZ9ayw=; b=SzQVXgKgO00UAqe0RGf+WkY6f44WjAyln89nWnjFRbH5Zz7o8usGV9kIlW78AisLee0Eoi 0yZ6RphWdyHzROLSVNFtF//jXogQZ7CrCJUQRweGUsrUkVnnJ0L7JfXbjBV1LFveQG+L9z r5MTH42ike2E7F6gTz/wJ5WLsOIjQuk= X-MC-Unique: 8RJVJO5aMxe1MKU3GM7lkA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=56KQolnKGhiF1X+C5PY8YNpm/K8e5udbyrIkFGZ9ayw=; b=Vha984P9L9oidjJlwZPjsNMTFSW7phAvgIxvih+gaGTaLUAf5+aYLqEcvSseNpLuiP ziCtvxOUSdH2UlUHFJIMQmMTOGKQbLsTObHOkcVN3lh4x8KYcajK96kDi9PNvcivkTLu 2pQX/2MT2OVz/baDlmlhVQpkoDXvmok0xC/Z6p+VC886Zxf8XS+GpAu8nMK2XYy9ibWW o4GWlhIfjMUoVYVmlsH33yF3CsaojyEL/UTcKaoZNAUoLENOBx3hFmpq8VnwYsY4N/vM nxqNyJzvpPRqqo6VbkfkEjWHno13JZR15UUrLRdz2LA8o5w7+fSeyDrVy+VDsjmoA0hv UZxw== X-Gm-Message-State: AOAM531EqhAccziamVAhCnfe190RCCUQTfCoH7v/E15iYStmIRIZKZB7 zJmjzdgut89+HJtfb1iNeQLEgvOH8ICxcn+Iim9CVv+akSkcKX7hi8nV6PF7BdtS2vaWCAejZm0 5RU2Q3XGHv9j60XsChoM8DhYmcPYmdI6f74Se+SXvir5qdDeFG2ApqdY2qJiepda0 X-Received: by 2002:a0c:be8e:: with SMTP id n14mr10562051qvi.16.1629315741667; Wed, 18 Aug 2021 12:42:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhde8yPF6N71nrn82egvrOCufhMvZbHj+IR6201SHmIb+NlLdoyv6vLTOdgPsefjNrx/GUXA== X-Received: by 2002:a0c:be8e:: with SMTP id n14mr10562023qvi.16.1629315741430; Wed, 18 Aug 2021 12:42:21 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 1/4] qdev-monitor: Trace qdev creation Date: Wed, 18 Aug 2021 15:42:14 -0400 Message-Id: <20210818194217.110451-2-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210818194217.110451-1-peterx@redhat.com> References: <20210818194217.110451-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S . Tsirkin" , Jason Wang , Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Eric Auger , Alex Williamson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629317042287100001 Content-Type: text/plain; charset="utf-8" Add a tracepoint for creations of qdev. This can be used to see what devic= es are created under the hood, along with the ordering of their creation. Signed-off-by: Peter Xu --- softmmu/qdev-monitor.c | 2 ++ softmmu/trace-events | 3 +++ 2 files changed, 5 insertions(+) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 721dec2d82..8602164082 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -40,6 +40,7 @@ #include "qemu/cutils.h" #include "hw/qdev-properties.h" #include "hw/clock.h" +#include "trace.h" =20 /* * Aliases were a bad idea from the start. Let's keep them @@ -674,6 +675,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **er= rp) dev->opts =3D NULL; goto err_del_dev; } + trace_qdev_device_add(driver, qemu_opts_id(opts)); return dev; =20 err_del_dev: diff --git a/softmmu/trace-events b/softmmu/trace-events index 7b278590a0..fad85e9d5c 100644 --- a/softmmu/trace-events +++ b/softmmu/trace-events @@ -29,3 +29,6 @@ runstate_set(int current_state, const char *current_state= _str, int new_state, co system_wakeup_request(int reason) "reason=3D%d" qemu_system_shutdown_request(int reason) "reason=3D%d" qemu_system_powerdown_request(void) "" + +# qdev-monitor.c +qdev_device_add(const char *driver, const char *id) "driver '%s' id '%s'" --=20 2.31.1 From nobody Fri May 17 09:38:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629316442389663.7302245038417; Wed, 18 Aug 2021 12:54:02 -0700 (PDT) Received: from localhost ([::1]:58588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGRdR-0006VV-BH for importer@patchew.org; Wed, 18 Aug 2021 15:54:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRT6-00022x-CV for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:43:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22560) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRT4-0007Xq-IX for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:43:20 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-GvXrjdE4Mh6U4E79WglMBQ-1; Wed, 18 Aug 2021 15:43:16 -0400 Received: by mail-qv1-f70.google.com with SMTP id ay14-20020a056214048eb0290357469934easo2955929qvb.8 for ; Wed, 18 Aug 2021 12:43:16 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id d20sm431530qkl.13.2021.08.18.12.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 12:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629315797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WggCVnnM9tjRutsX+jdTEs2ZOjZTGEHbCJiY34rSwe8=; b=N25Ozgja3uBIUsxnfjGJnAmunk5FMteH1nSbfefaa/ctljNha8m3I3BjZf1fbiLL9SNY1u HgRczSkeG8nNrDg+tEYAqiGUozq3GzJZHoh0ooi8aCtT8rYpBFDAobTvpA4MoQoJqhWpkv MVV4lg0YqYNVmsnS0NdoUeMWMhdCJ5k= X-MC-Unique: GvXrjdE4Mh6U4E79WglMBQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WggCVnnM9tjRutsX+jdTEs2ZOjZTGEHbCJiY34rSwe8=; b=QrU1Twx/QX5AnUkO2Ic3wERVDmX9aXjHbh6oFEWcs3MVC0qHPkrw4GQMkAkrcNKOWb djH7UXlt+XreJb2ogxoG3sv4fQNF/jTH9yvlHzMYy6xurdswWPyWKXuWWtdxfeIL9cSA PK3CEyxvwQ74KDmMneCG3QghzCXhhJgZ+l+b56AurUACdL9Uj2jgbv8HoLjg5C6T5X/Z 42K7p78rsqzm2OFh+7Q4s+GqMl/u7lHc5JFNyuo7htB9nFOx4zRtKFbFUx7zWy39dUO3 4j2Ra6LAe+O3cFpHnvoluOuiVulmnYFZNiyWTRi3rxiPhNCvaEEnqBWKubrf/KuFDYpS j7mw== X-Gm-Message-State: AOAM531mozSJVuCFEzLM+NWUL3s0lggLJF/1G8F/8s8qIkblTnCaYMHu c4CdwmkPvqBDnBKSnqNLff+GvS0DKakJO37qKM3tppd2NLic3Fxwduf/T9vAi5XTeaLMXxbEcU4 pKgz8vMEpvqgz5vjKYUhwPwF3zfJ5j7KWjNAkJIFIjbXVkQQiuL8VL/v/CjI/W1kp X-Received: by 2002:a05:622a:612:: with SMTP id z18mr9586550qta.330.1629315796006; Wed, 18 Aug 2021 12:43:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNfT5ZIM6EGf/Epzf62McW0pSL7d/TPwqPnW9VBcQDD1okHVYw878rArem/tja6qhlAI0zRQ== X-Received: by 2002:a05:622a:612:: with SMTP id z18mr9586524qta.330.1629315795680; Wed, 18 Aug 2021 12:43:15 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 2/4] qemu-config: Allow in-place sorting of QemuOptsList Date: Wed, 18 Aug 2021 15:43:13 -0400 Message-Id: <20210818194313.110892-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210818194217.110451-1-peterx@redhat.com> References: <20210818194217.110451-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S . Tsirkin" , Jason Wang , Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Eric Auger , Alex Williamson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629316444099100001 Content-Type: text/plain; charset="utf-8" Add the helper qemu_sort_opts() to allow in-place sorting of QemuOptsList. = The function can be specified in the form defined as qemu_opts_pri_fn(), where = it takes a QemuOpts pointer and generates a number showing the priority of this QemuOpts entry. Signed-off-by: Peter Xu --- include/qemu/config-file.h | 4 ++++ util/qemu-config.c | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h index f605423321..ce50a72985 100644 --- a/include/qemu/config-file.h +++ b/include/qemu/config-file.h @@ -3,8 +3,12 @@ =20 typedef void QEMUConfigCB(const char *group, QDict *qdict, void *opaque, E= rror **errp); =20 +/* Returns the priority for a QemuOpts */ +typedef int (*qemu_opts_pri_fn)(QemuOpts *opt); + void qemu_load_module_for_opts(const char *group); QemuOptsList *qemu_find_opts(const char *group); +void qemu_sort_opts(const char *group, qemu_opts_pri_fn fn); QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); QemuOpts *qemu_find_opts_singleton(const char *group); =20 diff --git a/util/qemu-config.c b/util/qemu-config.c index 436ab63b16..e882dc948b 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -7,6 +7,7 @@ #include "qapi/qmp/qlist.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qemu/option_int.h" #include "qemu/config-file.h" =20 static QemuOptsList *vm_config_groups[48]; @@ -41,6 +42,53 @@ QemuOptsList *qemu_find_opts(const char *group) return ret; } =20 +struct QemuOptsSortEntry { + QemuOpts *opts; + int priority; +} __attribute__ ((__aligned__(sizeof(void *)))); +typedef struct QemuOptsSortEntry QemuOptsSortEntry; + +static int qemu_opts_cmp_fn(const void *opts_1, const void *opts_2) +{ + QemuOptsSortEntry *entry1, *entry2; + + entry1 =3D (QemuOptsSortEntry *)opts_1; + entry2 =3D (QemuOptsSortEntry *)opts_2; + + return entry1->priority - entry2->priority; +} + +void qemu_sort_opts(const char *group, qemu_opts_pri_fn fn) +{ + QemuOptsSortEntry *entries, *entry; + QemuOpts *opts, *next_opts; + int i =3D 0, count =3D 0; + QemuOptsList *list; + + list =3D find_list(vm_config_groups, group, &error_abort); + + QTAILQ_FOREACH(opts, &list->head, next) { + count++; + } + + entries =3D g_new0(QemuOptsSortEntry, count); + QTAILQ_FOREACH_SAFE(opts, &list->head, next, next_opts) { + entry =3D &entries[i++]; + entry->opts =3D opts; + entry->priority =3D fn(opts); + /* Temporarily remove them; will add them back later */ + QTAILQ_REMOVE(&list->head, opts, next); + } + + qsort(entries, count, sizeof(QemuOptsSortEntry), qemu_opts_cmp_fn); + + for (i =3D 0; i < count; i++) { + QTAILQ_INSERT_TAIL(&list->head, entries[i].opts, next); + } + + g_free(entries); +} + QemuOpts *qemu_find_opts_singleton(const char *group) { QemuOptsList *list; --=20 2.31.1 From nobody Fri May 17 09:38:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318233002961.9323939500636; Wed, 18 Aug 2021 13:23:53 -0700 (PDT) Received: from localhost ([::1]:49190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS6J-0006nn-NJ for importer@patchew.org; Wed, 18 Aug 2021 16:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRTA-0002Fh-3I for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:43:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRT8-0007Zt-JW for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:43:23 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-mBkiJzPoPnWIW1TQdLHOBA-1; Wed, 18 Aug 2021 15:43:21 -0400 Received: by mail-qt1-f198.google.com with SMTP id o22-20020ac872d60000b029029817302575so1467008qtp.10 for ; Wed, 18 Aug 2021 12:43:20 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id j185sm437905qkf.28.2021.08.18.12.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 12:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629315802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WTxYsdQgG6JOcUELqB0QiB8wIJX8I+i741hrNBaimoA=; b=OQHH9TEusDTT5M2lxJDCsBVdnTc37AcPEZt6wZfOqayOWQ22Xoh37x+9RSIH0OaswIcV7v 3xjQPtcxEBSbH+r2AIhEy1fOqiR3yFN/wxZ4+i7nV6+MQxzCj6DgX5z3Y3SjjTcTC0MD/T U/9E/tA+xP0yyZnx6X/eT1P7HPyRLAE= X-MC-Unique: mBkiJzPoPnWIW1TQdLHOBA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WTxYsdQgG6JOcUELqB0QiB8wIJX8I+i741hrNBaimoA=; b=TSU4YgURfCP58P+P1swfjHxtjtLLiRu7JDA1o0h4ErG7f41qQD8dUuuSlP+tlY+rqd WkRYrwC9SKzo5lEl+Fsq03Ifs5THPk50XmgeHQ+/gRBvBjRBgXasrIl+xr63IKv0mU4Y yX16H614UKiw+nMXiddjIjeE8R5N7tfPuGPIDfH5b8f/GsF0bYa29BzKwVL9fLacyGOO Ck2RyYYRltHFk69kqHWPbqsmX7KifO1fVYkkKWttrKh5jSUqGkuZMBWgdNui0j8Xn6sM qocaP79zl2u3Ca2nWFDxvmbd4c7JxKLr4r6B/wLeHnT3P2OcXJHo9mlOUaU/xffsAfAJ KBNA== X-Gm-Message-State: AOAM5314dk5gEWo34rZxNSzG20NivXQf6oZ0Y8NptyUpedV+kncx8YPU m+1FV5RjiXc8apbXZdRSJRMCGDaGmZFBLDJLZRd9E+7SiZZVs6HGHax5iXgr7G4qyuLiB95qZ9M PaQpFr5e83EwFYKM5TrMavYHUfX4zIgqQXtS0ihPoEb/h5ZrWa/LP1wnY2oFbkrOG X-Received: by 2002:a37:66d1:: with SMTP id a200mr10855110qkc.440.1629315798442; Wed, 18 Aug 2021 12:43:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxp8XMlxzVOA3srZ9ILhBA6rFUw144C7qTzgaztk9fowyn+G8to8fbq+sjebZzoF25LSXL8w== X-Received: by 2002:a37:66d1:: with SMTP id a200mr10855082qkc.440.1629315798209; Wed, 18 Aug 2021 12:43:18 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 3/4] qdev: Export qdev_get_device_class() Date: Wed, 18 Aug 2021 15:43:16 -0400 Message-Id: <20210818194316.110942-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210818194217.110451-1-peterx@redhat.com> References: <20210818194217.110451-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S . Tsirkin" , Jason Wang , Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Eric Auger , Alex Williamson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629318234642100001 Content-Type: text/plain; charset="utf-8" It'll be used outside the current source file. Signed-off-by: Peter Xu --- include/monitor/qdev.h | 2 ++ softmmu/qdev-monitor.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index eaa947d73a..a783ad35b9 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -2,12 +2,14 @@ #define MONITOR_QDEV_H =20 /*** monitor commands ***/ +#include "hw/qdev-core.h" =20 void hmp_info_qtree(Monitor *mon, const QDict *qdict); void hmp_info_qdm(Monitor *mon, const QDict *qdict); void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp); =20 int qdev_device_help(QemuOpts *opts); +DeviceClass *qdev_get_device_class(const char **driver, Error **errp); DeviceState *qdev_device_add(QemuOpts *opts, Error **errp); void qdev_set_id(DeviceState *dev, const char *id); =20 diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 8602164082..610745467c 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -220,7 +220,7 @@ static const char *find_typename_by_alias(const char *a= lias) return NULL; } =20 -static DeviceClass *qdev_get_device_class(const char **driver, Error **err= p) +DeviceClass *qdev_get_device_class(const char **driver, Error **errp) { ObjectClass *oc; DeviceClass *dc; --=20 2.31.1 From nobody Fri May 17 09:38:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318406366467.6678730781846; Wed, 18 Aug 2021 13:26:46 -0700 (PDT) Received: from localhost ([::1]:57728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS97-00045X-3U for importer@patchew.org; Wed, 18 Aug 2021 16:26:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRTB-0002Lq-KH for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:43:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGRTA-0007ar-3C for qemu-devel@nongnu.org; Wed, 18 Aug 2021 15:43:25 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-GLiHe7eIPUG9RvEHm_MmGw-1; Wed, 18 Aug 2021 15:43:22 -0400 Received: by mail-qv1-f70.google.com with SMTP id u6-20020ad448660000b02903500bf28866so2885386qvy.23 for ; Wed, 18 Aug 2021 12:43:22 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id i16sm428063qtq.52.2021.08.18.12.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 12:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629315803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vjs/U9oiIIzIPYNfJJvQsKifLLyb4W5UUkK1KU3o24Q=; b=ZaNby2xzI7+wfbCQeGL5fG+1MVY24I7uFwKOU2b4/gcGBSvNpIMrSX00rFv1WAAX5PgxRu /84ijcSBiUArC35xTfKGQT+P92huZZquZaiTd/8MdEvWy+p18ok/GoN+rFN2NfiIQDLL+q oPHUvVRQlIG4ucsZMzlKiv4cQ6M5mNQ= X-MC-Unique: GLiHe7eIPUG9RvEHm_MmGw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vjs/U9oiIIzIPYNfJJvQsKifLLyb4W5UUkK1KU3o24Q=; b=m7bJgoDH98Nx+dpiN1P6IXs9O24pv0eFzXb1TZu4NeZiRrEAptjrSPhu/eFf13/yxI /PSzX/iSuivb7oQYU1lc9vbK22nKrHq0+2ViwmossFGG9D9v0eV9OEvMbPak+6AAg1nh XPr5p3aeZgotseeUIpaCpvztlZWWbxAj59GpGdKpsjfhvvdYD3WiwkiKPOqtA2aEf7m0 V++PCvytqYu1COxmYD3dxmKArUT698+pMQW9m5zldrAGtcEwFoqAV1MrqYMbMVmExFSk W5IAoMb6siN0sxReRaJobn8xH4cKglUyMRBTaEh0oDxbLsnw1+ukPNKO0qP9EKZM94um npPg== X-Gm-Message-State: AOAM531QET+FWo5tNlJ+pu7NI95aE4f4YTKJ+vuWM5MW1gzxrKjyvVW2 JeofauZafCoOntSzFqA2K+CpLQxKtq4EJOoEl0pRsazAGuRNF4iDVwyUNDQJ/tCQY73j69bJyBT Tgqp6VIlyoeRlewgHvyaVnmrquz4RKygl/vev5VgPcKpJXaiA1Fx3W6mbYhBZmoqC X-Received: by 2002:ac8:7c52:: with SMTP id o18mr9198345qtv.290.1629315801846; Wed, 18 Aug 2021 12:43:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH0dtZoBvjDPrbC83cbmuOKtJ2uyV/+Su/eL/hIeEsTCS9Dc2+qpYsSCkpVEB+lCC0IpCp3Q== X-Received: by 2002:ac8:7c52:: with SMTP id o18mr9198313qtv.290.1629315801535; Wed, 18 Aug 2021 12:43:21 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH 4/4] vl: Prioritize realizations of devices Date: Wed, 18 Aug 2021 15:43:18 -0400 Message-Id: <20210818194318.110993-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210818194217.110451-1-peterx@redhat.com> References: <20210818194217.110451-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S . Tsirkin" , Jason Wang , Markus Armbruster , peterx@redhat.com, "Dr . David Alan Gilbert" , Eric Auger , Alex Williamson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629318406987100001 Content-Type: text/plain; charset="utf-8" QEMU creates -device objects in order as specified by the user's cmdline. However that ordering may not be the ideal order. For example, some platfo= rm devices (vIOMMUs) may want to be created earlier than most of the rest devices (e.g., vfio-pci, virtio). This patch orders the QemuOptsList of '-device's so they'll be sorted first before kicking off the device realizations. This will allow the device realization code to be able to use APIs like pci_device_iommu_address_space= () correctly, because those functions rely on the platfrom devices being reali= zed. Now we rely on vmsd->priority which is defined as MigrationPriority to prov= ide the ordering, as either VM init and migration completes will need such an ordering. In the future we can move that priority information out of vmsd. Signed-off-by: Peter Xu --- softmmu/vl.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/softmmu/vl.c b/softmmu/vl.c index 5ca11e7469..3a30dfe27d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -126,6 +126,7 @@ #include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" #include "qemu/guest-random.h" +#include "migration/vmstate.h" =20 #include "config-host.h" =20 @@ -2627,6 +2628,35 @@ static void qemu_init_board(void) } } =20 +/* Return the priority of the device option; zero is the default priority = */ +static int qemu_opts_device_priority(QemuOpts *opts) +{ + const char *driver; + DeviceClass *dc; + + driver =3D qemu_opt_get(opts, "driver"); + if (!driver) { + return 0; + } + + dc =3D qdev_get_device_class(&driver, NULL); + if (!dc) { + return 0; + } + + if (!dc->vmsd) { + return 0; + } + + /* + * Currently we rely on vmsd priority because that's solving the same + * problem for device realization ordering but just for migration. In= the + * future, we can move it out of vmsd, but that's not urgently needed. + * Return the negative of it so it'll be sorted with descendant order. + */ + return -dc->vmsd->priority; +} + static void qemu_create_cli_devices(void) { soundhw_init(); @@ -2642,6 +2672,11 @@ static void qemu_create_cli_devices(void) =20 /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); + /* + * Sort all the -device parameters; e.g., platform devices like vIOMMU + * should be initialized earlier. + */ + qemu_sort_opts("device", qemu_opts_device_priority); qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, &error_fatal); rom_reset_order_override(); --=20 2.31.1