From nobody Fri May 3 12:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) client-ip=209.85.128.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1600602261; cv=none; d=zohomail.com; s=zohoarc; b=C8Wx2v0G0xIm3aECYXukt/htzaizRnBiTEzlw6oVwdzWvw63zI05S/8AYLc/CwsEYlJBQLPBesfW52p12amlb3yGcsXz+BDQ1SoA6MVM/Dbr0lvfYwg6vD4EC7vyIVkOCjxSjN5/1lOT2IWjHs/P0r4fuWCUGZacTqo7lXNX/5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600602261; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vFhP//g2kZUXZ+MAEt2Ablmdm9itVCJ1RZ3mPAAaqKM=; b=RT9in20D48mJ5tpK6mxCpj7qA5mLZH9a45FgB/GfsHkRytDml2sJICdEu8wJQXv8NOsIabbwKj1tLGIXTu919JUyWZKUytnyonVApWPtSomK3FwnLPwooJ38w8B0gpUivT8rqr2fx+0m8b5sjvlHpQh/K3pvQzYEZ9UF6mXvOjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.zohomail.com with SMTPS id 1600602261896407.2546195143917; Sun, 20 Sep 2020 04:44:21 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id a9so9807180wmm.2 for ; Sun, 20 Sep 2020 04:44:21 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (65.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.65]) by smtp.gmail.com with ESMTPSA id e18sm16415708wra.36.2020.09.20.04.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 04:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vFhP//g2kZUXZ+MAEt2Ablmdm9itVCJ1RZ3mPAAaqKM=; b=W7bIt4F4z6IiBy9m/LcKPgpOqz7FrN9GBpJuve00BFY9kXUb/mLfbBgoPvG81e+e1I PnmN8xdfVYhfolnL/Au7or3VYohzuyU+qgU61oKMiOuiLvML1lLLR1YrG8RyVOxhKkUD At2U1VxKyw0DDkZ3K8+6cgJOlgUg4G4X4ttSbnF28kWiWKEx5DCrAF0R6pwz7R/ksdxO R49LnJb7/kTrQSjtAggbyHcuKbCIapvd4GrEf6Jg/ZC7K9SP2Q6n0s35YN62z1rYuoYc YS7B1susGSIfY5Cjvl4LUE8YHWRaLM1Az0/VQh5o+hB66bh9DtXZa5BUW2dgmMDXj/bb 3X+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vFhP//g2kZUXZ+MAEt2Ablmdm9itVCJ1RZ3mPAAaqKM=; b=CyRdFrPkV2BsA148bmXDhpthPjd0a8wKqiafcCJz/7egVDTBzfstzApxsi/hDSZN0f GHfcfqDU/Sv8IUsrAz42iGMXk7KREqcfm/siuzf6lx2TytY4H70pfWSOpWdI7iwYTQbm CvGc9TVY6VhUlL06omuWM39Q60f8yq05ZtoHhd6UpZMLd9NVr2oAuw8vBBAJEX/XJoYg DUgYz594YUs1aFSWbE1gZjRBVsHFp7jdTivVfr1nU7eyj/rem05tHyMFKzKb/v3ikq4/ 7K8ibvMfLQWvzqhYMD9ac3WJ5ccQ1Y//kpod1cdgQTU6OfeC/YgvOhH48ixrGpDGSBCO EY+w== X-Gm-Message-State: AOAM531UYBoKiFbzN8spUGOekvVmqjLS6S0rUtAHzOtxLeLdUO+DXb/j qFtJkn3h7Z3udmYHF7aWjUo= X-Google-Smtp-Source: ABdhPJyz0j5G6/Jn6raiSm4b4XBR2XD5rdMCO5YiUU0gweX8qLMIBsSFUJ0cLbs1Gh97QejA8lUIOw== X-Received: by 2002:a1c:9c4b:: with SMTP id f72mr24727724wme.188.1600602260050; Sun, 20 Sep 2020 04:44:20 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , Anthony Perard , Stefano Stabellini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Paul Durrant , Marcel Apfelbaum , "Michael S. Tsirkin" , xen-devel@lists.xenproject.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] qdev: Document qbus_realize() and qbus_unrealize() Date: Sun, 20 Sep 2020 13:44:15 +0200 Message-Id: <20200920114416.353277-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200920114416.353277-1-f4bug@amsat.org> References: <20200920114416.353277-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Add some documentation for the qbus_realize() and qbus_unrealize() functions introduced in commit 9940b2cfbc0. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/qdev-core.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index e025ba9653f..02ac1c50b7f 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -675,7 +675,19 @@ typedef int (qdev_walkerfn)(DeviceState *dev, void *op= aque); void qbus_create_inplace(void *bus, size_t size, const char *typename, DeviceState *parent, const char *name); BusState *qbus_create(const char *typename, DeviceState *parent, const cha= r *name); +/** + * qbus_realize: Realize a bus + * @bus: bus to realize + * @errp: pointer to error object + * + * On success, return true. + * On failure, store an error through @errp and return false. + */ bool qbus_realize(BusState *bus, Error **errp); +/** + * qbus_realize: Unrealize a bus + * @bus: bus to unrealize + */ void qbus_unrealize(BusState *bus); =20 /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion, --=20 2.26.2 From nobody Fri May 3 12:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) client-ip=209.85.128.68; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f68.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1600602263; cv=none; d=zohomail.com; s=zohoarc; b=Pm+7xxgk+HCgCt9+NNS2hbE25wx+sw7hTVrZV8VaLsy7f0XeoglzN6NTd1zUu+ekUHo66nxJXe0RSlB2eBzHB1YlkvyXcyvR08H6R9Zm06qVVVHx+XRld4ywtL7RGFbjnKhCDtmLPW8aQZ9AtoZm/YYkVmIty1uDr3kekxzgEuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600602263; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fDZhs8OFrfrf0ft3+p7SBZ8r0XClNoxh4cVoI6p7qzo=; b=GQWiaNSyWJ9Ho/9xhXcdo68yXN104s6ZotrgDVAbKVJ4/XUcPOh0LzO9OX5ADV6z5p/i4Ic5cZoaqR/YzHK2u2l0YtSsTGu4QWh1lsbCiAa8TE4FFglTwmEb9Ay4SexB1AfhEdUJk0G74oDvctnhdTMqtA+iyb7XTntPh6PcU58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.68 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.zohomail.com with SMTPS id 1600602263460858.3491067335965; Sun, 20 Sep 2020 04:44:23 -0700 (PDT) Received: by mail-wm1-f68.google.com with SMTP id e17so9449422wme.0 for ; Sun, 20 Sep 2020 04:44:22 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (65.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.65]) by smtp.gmail.com with ESMTPSA id e18sm16415708wra.36.2020.09.20.04.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 04:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fDZhs8OFrfrf0ft3+p7SBZ8r0XClNoxh4cVoI6p7qzo=; b=bJoXXiW1EZOomSQyJVoxt8zqTE0ZRs7sW5oOl31UvpYvuYjQTqmKNJ6VVr03VEsG95 jqmF8m18GbJsy7BvsFRpkozw3KO2Veo0eqZI9/QzW2c6ltfQeIEF5x41M6KCjAjOx5yS Bcm9jpAwZm2Byp4gtJB0bmngB/sSeZpL72ckcNU3AazBLvm/WP3mCtzatAR3AUqe6KkY UdKhWkHNEy3XbfH4J73ANDeqVTNMNEhPp3zUeQnZ0JEyyrRQCXIGmHtduOuL/SSIS6IK KOOvHdnKzKIxOFunTx9R9S43rCk/S/az2ewbHhbRJ5e5cQ/7VIYVl4Y9grShrrmw+HcA xVNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=fDZhs8OFrfrf0ft3+p7SBZ8r0XClNoxh4cVoI6p7qzo=; b=Xp0p6sbPzdfNHP/doIk3+mxkwf4GRahzS49Gcn9d+2wCagmCGpWw+1zRZ2KUcw8YmE fpD8fxoJdK92Ym+R6PxaEgexpGiKpRJqal0DnqmXxyuq5qG7UpKw/bwmeeVqigx9BLiF OAKjQAXchZnZkHyKDsKcfLhlu6V8eWBK3pZofJjsF8YuxZnRG5j/mb/MTqOfEoydIo2u pxRh4zljPpwwLuLwLyy11KMq+ySHDPv3i8maLvdDeIPslf+aYBwCX3DyfngNWV2oroFo qzFklaCtTkobLoHfWnFX+vaJfuDVuK+KwnVdn1TMiihSCA0IP2IldrBw2kecZGtxxmT9 gCVg== X-Gm-Message-State: AOAM532uUGN+OtvqNIL6oIjfR8AiJ7UpsO5YXRqNAr16pVpYBPAZ3LfM BYTU05lsliv/CxIXEtZYbuXbM11YeNs= X-Google-Smtp-Source: ABdhPJypuqaFdVNqHvBqpI9crdclAyxoTwFQkqDzODv3j/C3VX/NRNCq6A2dZPfYNEJ99K9Jv5UuUA== X-Received: by 2002:a1c:80d7:: with SMTP id b206mr24808459wmd.161.1600602261568; Sun, 20 Sep 2020 04:44:21 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , Anthony Perard , Stefano Stabellini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Paul Durrant , Marcel Apfelbaum , "Michael S. Tsirkin" , xen-devel@lists.xenproject.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/2] qdev: Let BusRealize() return a boolean value to indicate error Date: Sun, 20 Sep 2020 13:44:16 +0200 Message-Id: <20200920114416.353277-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200920114416.353277-1-f4bug@amsat.org> References: <20200920114416.353277-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Commit 9940b2cfbc0 introduced qdev_realize() and qbus_realize() with the ability to return a boolean value if an error occured, thus the caller does not need to check if the Error* pointer is set. Provide the same ability to the BusRealize type. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Paul Durrant Reviewed-by: Richard Henderson --- include/hw/qdev-core.h | 14 +++++++++++++- hw/hyperv/vmbus.c | 5 +++-- hw/nubus/nubus-bus.c | 5 +++-- hw/pci/pci.c | 12 +++++++++--- hw/xen/xen-bus.c | 5 +++-- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 02ac1c50b7f..eecfe794a71 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -32,7 +32,19 @@ typedef enum DeviceCategory { typedef void (*DeviceRealize)(DeviceState *dev, Error **errp); typedef void (*DeviceUnrealize)(DeviceState *dev); typedef void (*DeviceReset)(DeviceState *dev); -typedef void (*BusRealize)(BusState *bus, Error **errp); +/** + * BusRealize: Realize @bus. + * @bus: bus to realize + * @errp: pointer to error object + * + * On success, return true. + * On failure, store an error through @errp and return false. + */ +typedef bool (*BusRealize)(BusState *bus, Error **errp); +/** + * BusUnrealize: Unrealize @bus. + * @bus: bus to unrealize + */ typedef void (*BusUnrealize)(BusState *bus); =20 /** diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index 6ef895bc352..8a0452b2464 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -2487,7 +2487,7 @@ static const TypeInfo vmbus_dev_type_info =3D { .instance_init =3D vmbus_dev_instance_init, }; =20 -static void vmbus_realize(BusState *bus, Error **errp) +static bool vmbus_realize(BusState *bus, Error **errp) { int ret =3D 0; Error *local_err =3D NULL; @@ -2519,7 +2519,7 @@ static void vmbus_realize(BusState *bus, Error **errp) goto clear_event_notifier; } =20 - return; + return true; =20 clear_event_notifier: event_notifier_cleanup(&vmbus->notifier); @@ -2528,6 +2528,7 @@ remove_msg_handler: error_out: qemu_mutex_destroy(&vmbus->rx_queue_lock); error_propagate(errp, local_err); + return false; } =20 static void vmbus_unrealize(BusState *bus) diff --git a/hw/nubus/nubus-bus.c b/hw/nubus/nubus-bus.c index 942a6d5342d..d20d9c0f72c 100644 --- a/hw/nubus/nubus-bus.c +++ b/hw/nubus/nubus-bus.c @@ -65,12 +65,13 @@ static const MemoryRegionOps nubus_super_slot_ops =3D { }, }; =20 -static void nubus_realize(BusState *bus, Error **errp) +static bool nubus_realize(BusState *bus, Error **errp) { if (!nubus_find()) { error_setg(errp, "at most one %s device is permitted", TYPE_NUBUS_= BUS); - return; + return false; } + return true; } =20 static void nubus_init(Object *obj) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index de0fae10ab9..f535ebac847 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -115,7 +115,7 @@ static void pcibus_machine_done(Notifier *notifier, voi= d *data) } } =20 -static void pci_bus_realize(BusState *qbus, Error **errp) +static bool pci_bus_realize(BusState *qbus, Error **errp) { PCIBus *bus =3D PCI_BUS(qbus); =20 @@ -123,13 +123,17 @@ static void pci_bus_realize(BusState *qbus, Error **e= rrp) qemu_add_machine_init_done_notifier(&bus->machine_done); =20 vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_pcibus, bus); + + return true; } =20 -static void pcie_bus_realize(BusState *qbus, Error **errp) +static bool pcie_bus_realize(BusState *qbus, Error **errp) { PCIBus *bus =3D PCI_BUS(qbus); =20 - pci_bus_realize(qbus, errp); + if (!pci_bus_realize(qbus, errp)) { + return false; + } =20 /* * A PCI-E bus can support extended config space if it's the root @@ -144,6 +148,8 @@ static void pcie_bus_realize(BusState *qbus, Error **er= rp) bus->flags |=3D PCI_BUS_EXTENDED_CONFIG_SPACE; } } + + return true; } =20 static void pci_bus_unrealize(BusState *qbus) diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 9ce1c9540b9..d7ef5d05e37 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -444,7 +444,7 @@ static void xen_bus_unrealize(BusState *bus) } } =20 -static void xen_bus_realize(BusState *bus, Error **errp) +static bool xen_bus_realize(BusState *bus, Error **errp) { XenBus *xenbus =3D XEN_BUS(bus); unsigned int domid; @@ -478,10 +478,11 @@ static void xen_bus_realize(BusState *bus, Error **er= rp) "failed to set up enumeration watch: "); } =20 - return; + return true; =20 fail: xen_bus_unrealize(bus); + return false; } =20 static void xen_bus_unplug_request(HotplugHandler *hotplug, --=20 2.26.2