From patchwork Mon Jul 12 19:43:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C5FC07E99 for ; Mon, 12 Jul 2021 19:47:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03E2561279 for ; Mon, 12 Jul 2021 19:47:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03E2561279 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31tO-0004DG-3L for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:47:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31qX-0001Xt-TY; Mon, 12 Jul 2021 15:44:05 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:41873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qO-0002cg-N6; Mon, 12 Jul 2021 15:44:05 -0400 Received: by mail-pg1-x534.google.com with SMTP id s18so19393089pgg.8; Mon, 12 Jul 2021 12:43:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2A7kQXUoJ+TWj8DIjTzUnw/pm573Pm8vxZ6A+s+3A/g=; b=Vrk/JjQ6ViaDM/Tn0je63vU0OQw1mgdiwV6ser0PB385YQSpYA00iAZ4mHeansEqNo EwB0fEcTqqcflHpiWOJlY8T0VyiCqCX2dZR6hTLLeELee1KNnx7LauYatyoFSYGAFtyo /1v2TIcu5Ue3Sulm2X+fFeAhlBLrXy0UxE9sknI0/73b2KeCPwoU0QGfW+176M0zcIIR MxxlmpvBsYKHTGEBlzlZ/4lZcKCni/0YtkeIUiu/BCYNlXlk0zj7/kxhF1zzxj994mxL dQwdJ3tRB+V74WUyBM/hPdBMzXwv6rkIhiheLUcFN2ual/Gvx0mZxrpB4QWMD6U0gI8o Va+A== 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=2A7kQXUoJ+TWj8DIjTzUnw/pm573Pm8vxZ6A+s+3A/g=; b=Q2D+5TNRT3CCiO22eHiQUbqN3LABqUA2xMm/w+H59KTj3oqu6mAsazDZ42VWraOLmN q8dGUPNSWbsBLz3pyNvbrWL4kI4k29dU5BmxbXw0cZQoJpdPv8V/X0wZVdTqEZ2i7bhn 1vfXjJEh2z53RlJKCUh078OSuKGsRAWKY9DG9Dd6YG9tvHE8I1a44OUBK3VVjEEdTFMX XWqZ6+U01WkfoRmNuSAM9R7QRSZOhe1VoZDC38aEOHqFjANJMx12lkAJOunhUnHAwXxu RM/MK0T0SoxbgA982S/82uSiMFFVADRqZKKsLshynaPZR+GzFF3NtYnHQy4gqy3bfTHj EO6A== X-Gm-Message-State: AOAM531sHmtaH+4xEk7/mr6DuHTiBHB0YnLIsgm0NipQ6iDROT36lI4N 4b/UwL2unPlOo/BqQL2f8hG1J/zWLxw= X-Google-Smtp-Source: ABdhPJy/0YAanSfod187FgthtUbs1ddznKVUvIILw8Rh+75aot6bHbK+eF1eXKC1+O2RNRBlXfNEpg== X-Received: by 2002:a65:6088:: with SMTP id t8mr655796pgu.371.1626119035062; Mon, 12 Jul 2021 12:43:55 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:43:54 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 1/7] hw/acpi/memory_hotplug.c: avoid sending MEM_UNPLUG_ERROR if dev->id is NULL Date: Mon, 12 Jul 2021 16:43:33 -0300 Message-Id: <20210712194339.813152-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=danielhb413@gmail.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qapi_event_send_device_unplug_error() deals with @device being NULL by replacing it with an empty string ("") when emitting the event. Aside from the fact that this is a side effect that can be patched someday, there's also the lack of utility that the event brings to listeners, e.g. "a memory unplug error happened somewhere". We're better of not emitting the event if dev->id is NULL. Next patches will introduce a new device unplug error event that is better suited to deal with dev->id NULL scenarios. MEM_UNPLUG_ERROR will continue to be emitted to avoid breaking existing APIs, but it'll be deprecated and removed in the future. Suggested-by: Markus Armbruster Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/acpi/memory_hotplug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index af37889423..e37acb0367 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -177,9 +177,14 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data, /* call pc-dimm unplug cb */ hotplug_handler_unplug(hotplug_ctrl, dev, &local_err); if (local_err) { + const char *error_pretty = error_get_pretty(local_err); + trace_mhp_acpi_pc_dimm_delete_failed(mem_st->selector); - qapi_event_send_mem_unplug_error(dev->id, - error_get_pretty(local_err)); + + if (dev->id) { + qapi_event_send_mem_unplug_error(dev->id, error_pretty); + } + error_free(local_err); break; } From patchwork Mon Jul 12 19:43:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEDB5C07E9C for ; Mon, 12 Jul 2021 19:48:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7018661263 for ; Mon, 12 Jul 2021 19:48:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7018661263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31v7-0008Ex-H7 for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31qZ-0001Zj-4D; Mon, 12 Jul 2021 15:44:07 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:38586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qV-0002fu-UA; Mon, 12 Jul 2021 15:44:06 -0400 Received: by mail-pl1-x631.google.com with SMTP id u3so4678584plf.5; Mon, 12 Jul 2021 12:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E+zrqjzPcvj6sVobiWzNXQ6kmh4zy9EjYGvkxkUwwDM=; b=XU4NN63CfYeuLLQ2kNYNuFznSLbaMRZ1rSPMhpuSTVd+5sbZM5ApiBKh5q7TgDko91 iyMt6z95XAYDNDhyyVJdI45Zx9r7F9NEueWpGSmuJfZ2Bx+heht774M6y6lHO6MQSqpr 4VPbJQoFL0WbCqF9rFTLowKwWSxjtrb0rtMI4f4TsjQqChcFvw3wiPv3pAuw59cURGMt 2tGLJ1oL1LCrwDz/sbjyPVV6wuJXd1cQmE9ZCx6lixcxUTBE1jZdMj1UnNQrompP/LcO rQDdO6dblpQ5Zv6nFFM9f3foTUMfYHAafooVbCKThrvI7rnGNvOO68S/EdISP9rOkkJx Speg== 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=E+zrqjzPcvj6sVobiWzNXQ6kmh4zy9EjYGvkxkUwwDM=; b=Ub8/wl6JYt4g/YKtmbElD+fSxQI9lnYj6kf3BlLhTcBW5vuu/rzSVBOc+O9MHvByIC uex7yn/0vhTNdMZ5HSAn8ZQg7boaXYkOdbUGb7by+C16ddC3jJazTuCSgiFG9I2K0+a9 mbjSZBgQKatWKtionfCh0ZBs2JN2ypAqm/IacbcadxTwSM6FDu4ZHiB3+8QZi+QWWNtp Qxtz573FAJ2pUfNv2JaUX5PHPM5pmd/IzDY8y9DefsHa61TADOFtuJp9wSPrS+qD0Tyb GaiZUz7FxNdlSYaWVuquiuHPj3VWpToVxgMXgPhcMs/GE+uwdo1+9uZxoRvkJMNzzhrT Ni2g== X-Gm-Message-State: AOAM533zMYt38cdU/miJSlzR0NwwBPxULqZR+87PTlS5LZaxJCBYc32j 3Uw1eXrIgAoBgFAy2HlAw0TER3EzU8g= X-Google-Smtp-Source: ABdhPJyaaLe9D6OMfME9JSlN9YNGAck0Y2XSmKUF+BAUJC48ubvUbmdZ3qBpyxI+8oYGXMqJRSrC2w== X-Received: by 2002:a17:90a:a898:: with SMTP id h24mr2729111pjq.208.1626119039506; Mon, 12 Jul 2021 12:43:59 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:43:59 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 2/7] spapr.c: avoid sending MEM_UNPLUG_ERROR if dev->id is NULL Date: Mon, 12 Jul 2021 16:43:34 -0300 Message-Id: <20210712194339.813152-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=danielhb413@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" As done in hw/acpi/memory_hotplug.c, avoid sending qapi_event_send_mem_unplug_error() if dev->id is NULL. Suggested-by: Markus Armbruster Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 81699d4f8b..1611d7ab05 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3688,9 +3688,11 @@ void spapr_memory_unplug_rollback(SpaprMachineState *spapr, DeviceState *dev) * Tell QAPI that something happened and the memory * hotunplug wasn't successful. */ - qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest " - "for device %s", dev->id); - qapi_event_send_mem_unplug_error(dev->id, qapi_error); + if (dev->id) { + qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest " + "for device %s", dev->id); + qapi_event_send_mem_unplug_error(dev->id, qapi_error); + } } /* Callback to be called during DRC release. */ From patchwork Mon Jul 12 19:43:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4C0CC07E9C for ; Mon, 12 Jul 2021 19:46:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 753C261263 for ; Mon, 12 Jul 2021 19:46:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 753C261263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31tG-0003su-Fo for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:46:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31qZ-0001aO-Ah; Mon, 12 Jul 2021 15:44:07 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:36795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qW-0002g3-59; Mon, 12 Jul 2021 15:44:07 -0400 Received: by mail-pf1-x429.google.com with SMTP id 21so17421498pfp.3; Mon, 12 Jul 2021 12:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VLA0QX060RDws9FZs/ls+ZYReQcTzyt4lON8NJNw2CA=; b=GOq6qHBWjG/CUp9JV3tut5LwZOg5bTPEGFPSFaql4nc12Hw9CG5H//xCMFedtdMyJG +XcdCT4qUryS35cGCUVbSPi181FG8yO4SP4BrjudTgf4IcYFlkiPwK418GWLq/6L9Ss6 gcfg1zsJ8Jt4xTfuqCEE4ohADNRuIwXzpLiXYaNKLX/RRpHOtTOGThTU8JtH5Tc+7TXo rC/zTeL69hcSVQLtEkgLEyj7C2OBOPCG19ABkwRjQ8FVkKS0ixuDGLsfhNoOll9kg9VC 8JORH5CRJTYmh7fu4+XL06j4D/y+95zn/c5hBSuYxt0XUBdDs0IMmD0FnAbCOzckGj6q cC4g== 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=VLA0QX060RDws9FZs/ls+ZYReQcTzyt4lON8NJNw2CA=; b=YusikFK8esyTtAagn4Vu061SLZkeuoKYcpAXDN9UrAeC7OuvQR816WwvObxXVY2644 x4btbV92LNYJc7AbjcQScN1fEWTJ7Ex4563/aB2y4ngpsqarIK0T2q5y2vfOeOMQ2bxv CaZxVRr0fQgeWbsMWESPTW5nknfPRjBcjllaRQlSEteQH1JDeY5WjHuJ2/kD/L7hmaEF NoYppKvhJNex71ymfN1vA2tZrLikzHPy62jHg36sJBUWWd4Kg2ne/2+E3AacigJTA8Cl dKrvavX+k6yHzYfUeuK6MFoxT27eXHrbzZvSO/ChpQP6v5uNKTogQ2rWP1fKCQfQAtyU 5S1w== X-Gm-Message-State: AOAM532wtMbmn54CkBP9037BmKi4Z796SR7L+9j4Cqre302PXcI/1tlK LLEw3oRYKyrurSffTPD2SuS89D+rxQ8= X-Google-Smtp-Source: ABdhPJw8AiElCW/ouhIetOdrUtlB073agg0gyBsdbXhASCXX7K92t3EeMrcIFWhfB1qLqZWJpd+D9A== X-Received: by 2002:a63:f64d:: with SMTP id u13mr717515pgj.156.1626119042177; Mon, 12 Jul 2021 12:44:02 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:44:01 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 3/7] spapr_drc.c: do not error_report() when drc->dev->id == NULL Date: Mon, 12 Jul 2021 16:43:35 -0300 Message-Id: <20210712194339.813152-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=danielhb413@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The error_report() call in drc_unisolate_logical() is not considering that drc->dev->id can be NULL, and the underlying functions error_report() calls to do its job (vprintf(), g_strdup_printf() ...) has undefined behavior when trying to handle "%s" with NULL arguments. Besides, there is no utility into reporting that an unknown device was rejected by the guest. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr_drc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index a2f2634601..a4d9496f76 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -167,8 +167,11 @@ static uint32_t drc_unisolate_logical(SpaprDrc *drc) } drc->unplug_requested = false; - error_report("Device hotunplug rejected by the guest " - "for device %s", drc->dev->id); + + if (drc->dev->id) { + error_report("Device hotunplug rejected by the guest " + "for device %s", drc->dev->id); + } /* * TODO: send a QAPI DEVICE_UNPLUG_ERROR event when From patchwork Mon Jul 12 19:43:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B120C07E99 for ; Mon, 12 Jul 2021 19:48:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE61C61206 for ; Mon, 12 Jul 2021 19:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE61C61206 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31v6-0008CA-Qx for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:48:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31qa-0001e7-H4; Mon, 12 Jul 2021 15:44:08 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:37792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qY-0002gx-V1; Mon, 12 Jul 2021 15:44:08 -0400 Received: by mail-pg1-x52c.google.com with SMTP id t9so19405609pgn.4; Mon, 12 Jul 2021 12:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TJ4GKfLNXDxX0M/qFFoXuW2OTTNd91WHgyaBHr9mRvA=; b=gtCJk9483rtTRp6FOQzN/7G/DrtktZRc+zoM1Ls0C6Ki2yiQ75Am8r8pU2WJlOZuFp eQU+S23jHwgmjK5WM+uLESaq97KGftu9JWb5zl/G9gXGRdeE6ioo3p3lR34Ry7OLptfw XDOImrTtmpeJN2yePSgW+nOQ49zkd23j08IhWD7V3TsOvu/6tJAb9JG+YCUGOwC6dNpj xuGv8MI1SqRhFFDMu9llLPzSRv9+iKcbwZxAIiN+6Yu7j5jJh7Ugks3O1xlxjiFVewt2 KPNZps5c6xwCiBk/kgNH7GlD6YHuVyb/MDEWHjly7qa3TcxqxkBQyLIKEFlv3EQEtVxQ hqrg== 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=TJ4GKfLNXDxX0M/qFFoXuW2OTTNd91WHgyaBHr9mRvA=; b=hrjhJGnl8o5WcLHycnB2EOecd59+iuOLE7Jk/UchGaeYcUilA5Ht9SMIT5Iw41Yp3s 6OoV9TY4hQsN38PVkJgPrjvuv8H7uMe2KzVrmq6DxkxtkTjTJ72VuxLFMLmxulb8Awxn 6AZEV9ZGEa89bjWkRQuESNfPYVNkgxAMjOnM3+9RpiQJMMVHb25GGBBT8Uofw6cHQ3xh e4cj1/3SnD25XlCLIqSlXsiwRpRKeNPVb84Fd7m+yEIufEBEJ3Mjt3Ajia9QK3x1Oy0Z uuNfaSnHdhBpxsgSKq3kEnpJ+rKaNWq/V4Kwzil27XEulh7pQRdqCHrHn5kInuD36WNh 757A== X-Gm-Message-State: AOAM533ecwCNbA2KXKbqD2R7C/6Kn50JldPXMJwMHmqbv1VRViKc9OTU dXp2Ta0GiVLU0OkAjg4ojHy6WeiORX0= X-Google-Smtp-Source: ABdhPJz2oT5ZLsmGSguMnnQ0FO3D5+H91kz0XpLG4SmTC+IInVd1z4QeFdIThDiHsDmv9SUcplQOxQ== X-Received: by 2002:a63:ff4b:: with SMTP id s11mr690610pgk.436.1626119045322; Mon, 12 Jul 2021 12:44:05 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:44:05 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 4/7] qapi/qdev.json: fix DEVICE_DELETED parameters doc Date: Mon, 12 Jul 2021 16:43:36 -0300 Message-Id: <20210712194339.813152-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=danielhb413@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Clarify that @device is optional and that 'path' is the device path from QOM. This change follows Markus' suggestion verbatim, provided in full context here: https://lists.gnu.org/archive/html/qemu-devel/2021-07/msg01891.html Suggested-by: Markus Armbruster Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- qapi/qdev.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi/qdev.json b/qapi/qdev.json index b83178220b..d1d3681a50 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -108,9 +108,9 @@ # At this point, it's safe to reuse the specified device ID. Device removal can # be initiated by the guest or by HMP/QMP commands. # -# @device: device name +# @device: the device's ID if it has one # -# @path: device path +# @path: the device's path within the object model # # Since: 1.5 # From patchwork Mon Jul 12 19:43:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D34EC07E99 for ; Mon, 12 Jul 2021 19:48:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3201561263 for ; Mon, 12 Jul 2021 19:48:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3201561263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31vC-0008Sn-Bz for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:48:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31qe-0001jz-H9; Mon, 12 Jul 2021 15:44:13 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:35360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qd-0002k4-1L; Mon, 12 Jul 2021 15:44:12 -0400 Received: by mail-pg1-x534.google.com with SMTP id v7so19407640pgl.2; Mon, 12 Jul 2021 12:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wRfDFV6yTB2ZuXd+VVBhYM2WQzFkI+90BZxZxc0QIw0=; b=qpxtvA9xDey7WszVaV7/wLwJnu6rwnvx/IDi0b3D8FBinUfkRWcLa1/dGw6T3hhzTB VMdLOUNmj9wp0VYBhBFEBIUmhO0sTjsfPNXRPxhA0QN9jm2yD24Cd8b+8lqC2W6X20T4 8kmgXNeDtFLQ3Rj/IrWbp2yLvWSGJyW+fRTib9YtN6EztKS5y4m9MZMgUs5uo4qYJX/n Wlr8vsr4Dd5+TO1AeahCcG8N7OZLpAL5HnnfSLyvlRSoyzqicBiDmVAM6JnzYHTv5Qzw mgmsTux+TAQOwe+qrCkxoUO1hONKyTgVTY7jIhw9cDf9R811TWwhquP5O/33Q7zrCK3U kPvA== 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=wRfDFV6yTB2ZuXd+VVBhYM2WQzFkI+90BZxZxc0QIw0=; b=qJHXWXHZglBnz/I5pef5Dg/tXovT9NmWmIQIxiz1g9NGQLUHEM67v8Bb7kNXaq13ki 2W1LGEC7iY3OKM4720AUeCpnCiHATx5W+hZKeX2LmPOiyYe5CFMsFCkdEGeam+r9zK3d +rDz4s8F/Xn1IMDop8CJY4InECAuwSLzGPAYJE9ur9HOTL9HJiSk7ZY9QpTSKGDeCHY2 5BCp2W+aZBrSfj4k5bWt9PA7q9HJP56yo6wgf+3YguwtsPRFcfvotrHLYuP2JQlPlC+M F7XIQlaj7sPQn51Gi6Zt/j/ojpeN5tojLHvux5IRbEoUvmj4Ga8s3wGwCHRLjsJpXjz3 5UnQ== X-Gm-Message-State: AOAM533W5hp8tYBq0t7nNtxS7+DTO/87lCGDChEIcBSR2j+g2wWFhqbj GSWGV6qblz7Gg+CKsxWaKIWfsDTJ1cE= X-Google-Smtp-Source: ABdhPJw4T8E0W6MHig0LxCOCZ6wGhs5iOe16WOzvRAZm0QsQ24Ck27NAs6lq4FDw+bhNnqeQ/sGbzA== X-Received: by 2002:a63:d80a:: with SMTP id b10mr688159pgh.47.1626119049436; Mon, 12 Jul 2021 12:44:09 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:44:09 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 5/7] qapi/qdev.json: add DEVICE_UNPLUG_ERROR QAPI event Date: Mon, 12 Jul 2021 16:43:37 -0300 Message-Id: <20210712194339.813152-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=danielhb413@gmail.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" At this moment we only provide one event to report a hotunplug error, MEM_UNPLUG_ERROR. As of Linux kernel 5.12 and QEMU 6.0.0, the pseries machine is now able to report unplug errors for other device types, such as CPUs. Instead of creating a (device_type)_UNPLUG_ERROR for each new device, create a generic DEVICE_UNPLUG_ERROR event that can be used by all unplug errors in the future. This event has a similar API as the existing DEVICE_DELETED event, with an extra optional 'msg' parameter that can be used to explain the reason for the error. With this new generic event, MEM_UNPLUG_ERROR is now marked as deprecated. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- docs/system/deprecated.rst | 10 ++++++++++ qapi/machine.json | 6 +++++- qapi/qdev.json | 30 +++++++++++++++++++++++++++++- stubs/qdev.c | 7 +++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 6d438f1c8d..c0c3431ada 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -204,6 +204,16 @@ The ``I7200`` guest CPU relies on the nanoMIPS ISA, which is deprecated (the ISA has never been upstreamed to a compiler toolchain). Therefore this CPU is also deprecated. + +QEMU API (QAPI) events +---------------------- + +``MEM_UNPLUG_ERROR`` (since 6.2) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Use the more generic event ``DEVICE_UNPLUG_ERROR`` instead. + + System emulator machines ------------------------ diff --git a/qapi/machine.json b/qapi/machine.json index c3210ee1fb..a595c753d2 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1271,6 +1271,9 @@ # # @msg: Informative message # +# Features: +# @deprecated: This event is deprecated. Use @DEVICE_UNPLUG_ERROR instead. +# # Since: 2.4 # # Example: @@ -1283,7 +1286,8 @@ # ## { 'event': 'MEM_UNPLUG_ERROR', - 'data': { 'device': 'str', 'msg': 'str' } } + 'data': { 'device': 'str', 'msg': 'str' }, + 'features': ['deprecated'] } ## # @SMPConfiguration: diff --git a/qapi/qdev.json b/qapi/qdev.json index d1d3681a50..52c36c7b9c 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -84,7 +84,9 @@ # This command merely requests that the guest begin the hot removal # process. Completion of the device removal process is signaled with a # DEVICE_DELETED event. Guest reset will automatically complete removal -# for all devices. +# for all devices. If an error in the hot removal process is detected, +# the device will not be removed and a DEVICE_UNPLUG_ERROR event is +# sent. Some errors cannot be detected. # # Since: 0.14 # @@ -124,3 +126,29 @@ ## { 'event': 'DEVICE_DELETED', 'data': { '*device': 'str', 'path': 'str' } } + +## +# @DEVICE_UNPLUG_ERROR: +# +# Emitted when a device hot unplug error occurs. +# +# @device: the device's ID if it has one +# +# @path: the device's path within the object model +# +# @msg: optional informative message +# +# Since: 6.2 +# +# Example: +# +# <- { "event": "DEVICE_UNPLUG_ERROR" +# "data": { "device": "core1", +# "msg": "Device hotunplug rejected by the guest for device core1", +# "path": "/machine/peripheral/core1" }, +# }, +# "timestamp": { "seconds": 1615570772, "microseconds": 202844 } } +# +## +{ 'event': 'DEVICE_UNPLUG_ERROR', + 'data': { '*device': 'str', 'path': 'str' , '*msg': 'str' } } diff --git a/stubs/qdev.c b/stubs/qdev.c index 92e6143134..ffa8f7b59e 100644 --- a/stubs/qdev.c +++ b/stubs/qdev.c @@ -21,3 +21,10 @@ void qapi_event_send_device_deleted(bool has_device, { /* Nothing to do. */ } + +void qapi_event_send_device_unplug_error(bool has_device, const char *device, + const char *path, + bool has_msg, const char *msg) +{ + /* Nothing to do. */ +} From patchwork Mon Jul 12 19:43:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAD4EC07E9A for ; Mon, 12 Jul 2021 19:51:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5260C61245 for ; Mon, 12 Jul 2021 19:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5260C61245 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31xf-0005KC-57 for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:51:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31ql-0001mT-Kq; Mon, 12 Jul 2021 15:44:19 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:35359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qg-0002m4-4t; Mon, 12 Jul 2021 15:44:17 -0400 Received: by mail-pg1-x532.google.com with SMTP id v7so19407784pgl.2; Mon, 12 Jul 2021 12:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nWJxP6xnK+ZBRcXbZa0JA6jsoboZu8/9RIOA+TP2LgU=; b=mbjOvgJJmIoJZ3bEXyp0RW5NNPzuVWn34sZWuA0Xk+mVTZcmbjClKQZOM1tzmPP0Zp pMF25kaX/UeLx00ni6cn+9U7PTQR3nwY+Se/3L78D+5bQthkecL34+DM7xpRj/XPajUS 4oVoKq/IM5zQEgo4Y7vqX8APq6+FdjluALXQBMiJ3A8wNqK7srmldLiDzy7futb/Z5zw Bkbo2AqH8HghNOjeOYVh6sROb8OBfb3q5EjKzfnble4pglthqQRH2N/FcT5i8RZGR7e0 mYLx0zEO7wyAT4P285eBtQLgdKFa8IyKDWDNbQxBpXoqmu6a+dRkDB2oVlT/aUsR/pPA fMuA== 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=nWJxP6xnK+ZBRcXbZa0JA6jsoboZu8/9RIOA+TP2LgU=; b=Rd666QfsGvLQoPec/0srABRmCHPHvnnn1iHlloPtS3HW1zxVU6L1Nf9O4eo6djbLsH cYwsieLTy3+SD2x75bSZxLjcJ1/B4aXBpHSQ9MEPOk8Aulvb46F3ZhthX3RpjQ+XrF6l QNoTaOTkBE9VNSVrMxdGj8Ovvvv5VlkkAeMwcDRbISH5p7yxJzPe5UUVl3aZmBIwoeCh nsrmGGaIIPvqFjmQgXLsGGC24vtW60oGp11Lh29RqdCthkbQ3G+vYh0HCMBFBZqEvfth v/E1NsyFvS2tLW8IsfLgFUFy7NpQRpHoQeBM5XUTY0Dr88La3IwPEZ//f7t0TyXwpg7I Oa0w== X-Gm-Message-State: AOAM532GamLch2oWBU8NKX54Cc1ipIUubSF+zAGHhkiLphEFSm2m06Y5 Bc8xIjQbZFetooSdkXshKkPmqnmR1P4= X-Google-Smtp-Source: ABdhPJxHSEI4DWTLknKCyIUcMEZPeF1jyJr9yz1okCs5uTFU2angOxesxtXOTxM7G9yhbxZ6QNYBKw== X-Received: by 2002:a63:f557:: with SMTP id e23mr682013pgk.55.1626119052223; Mon, 12 Jul 2021 12:44:12 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:44:11 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 6/7] spapr: use DEVICE_UNPLUG_ERROR to report unplug errors Date: Mon, 12 Jul 2021 16:43:38 -0300 Message-Id: <20210712194339.813152-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=danielhb413@gmail.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Linux Kernel 5.12 is now unisolating CPU DRCs in the device_removal error path, signalling that the hotunplug process wasn't successful. This allow us to send a DEVICE_UNPLUG_ERROR in drc_unisolate_logical() to signal this error to the management layer. We also have another error path in spapr_memory_unplug_rollback() for configured LMB DRCs. Kernels older than 5.13 will not unisolate the LMBs in the hotunplug error path, but it will reconfigure them. Let's send the DEVICE_UNPLUG_ERROR event in that code path as well to cover the case of older kernels. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 9 ++++++++- hw/ppc/spapr_drc.c | 17 +++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1611d7ab05..5459f9a7e9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -29,6 +29,7 @@ #include "qemu/datadir.h" #include "qapi/error.h" #include "qapi/qapi-events-machine.h" +#include "qapi/qapi-events-qdev.h" #include "qapi/visitor.h" #include "sysemu/sysemu.h" #include "sysemu/hostmem.h" @@ -3686,13 +3687,19 @@ void spapr_memory_unplug_rollback(SpaprMachineState *spapr, DeviceState *dev) /* * Tell QAPI that something happened and the memory - * hotunplug wasn't successful. + * hotunplug wasn't successful. Keep sending + * MEM_UNPLUG_ERROR even while sending DEVICE_UNPLUG_ERROR + * until the deprecation MEM_UNPLUG_ERROR is due. */ if (dev->id) { qapi_error = g_strdup_printf("Memory hotunplug rejected by the guest " "for device %s", dev->id); qapi_event_send_mem_unplug_error(dev->id, qapi_error); } + + qapi_event_send_device_unplug_error(!!dev->id, dev->id, + dev->canonical_path, + qapi_error != NULL, qapi_error); } /* Callback to be called during DRC release. */ diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index a4d9496f76..a3a15fd2ed 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -17,6 +17,8 @@ #include "hw/ppc/spapr_drc.h" #include "qom/object.h" #include "migration/vmstate.h" +#include "qapi/error.h" +#include "qapi/qapi-events-qdev.h" #include "qapi/visitor.h" #include "qemu/error-report.h" #include "hw/ppc/spapr.h" /* for RTAS return codes */ @@ -160,6 +162,10 @@ static uint32_t drc_unisolate_logical(SpaprDrc *drc) * means that the kernel is refusing the removal. */ if (drc->unplug_requested && drc->dev) { + const char qapi_error_fmt[] = "Device hotunplug rejected by the " + "guest for device %s"; + g_autofree char *qapi_error = NULL; + if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB) { spapr = SPAPR_MACHINE(qdev_get_machine()); @@ -169,14 +175,13 @@ static uint32_t drc_unisolate_logical(SpaprDrc *drc) drc->unplug_requested = false; if (drc->dev->id) { - error_report("Device hotunplug rejected by the guest " - "for device %s", drc->dev->id); + qapi_error = g_strdup_printf(qapi_error_fmt, drc->dev->id); + error_report(qapi_error_fmt, drc->dev->id); } - /* - * TODO: send a QAPI DEVICE_UNPLUG_ERROR event when - * it is implemented. - */ + qapi_event_send_device_unplug_error(!!drc->dev->id, drc->dev->id, + drc->dev->canonical_path, + qapi_error != NULL, qapi_error); } return RTAS_OUT_SUCCESS; /* Nothing to do */ From patchwork Mon Jul 12 19:43:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12372117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDF75C07E99 for ; Mon, 12 Jul 2021 19:53:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7608061245 for ; Mon, 12 Jul 2021 19:53:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7608061245 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m31zT-0000Gu-LL for qemu-devel@archiver.kernel.org; Mon, 12 Jul 2021 15:53:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m31qn-0001nj-Hm; Mon, 12 Jul 2021 15:44:21 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:38451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m31qj-0002oM-F8; Mon, 12 Jul 2021 15:44:19 -0400 Received: by mail-pf1-x435.google.com with SMTP id j9so11729056pfc.5; Mon, 12 Jul 2021 12:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b5RbY7ETO7O1SMcWDdHffidUKoTmEeWM7UscN17SR3A=; b=GCHVbYn8Mjd5oT1ZIWwam7e6gyXf898MHft3lckq0XQwn5K8GhDzJGpxQztRI+kY2y yswKmqeHlpX9nijg7jyF6zie3D8mnp8y6HcaEgz5P2zIWubKjJHYTmDu8MdpOv8Yxf1V qVA6TvzzmQXbjW57G/oADHOKGdacFCcmeCRhWExy+F4+uhalV81HGMri0eY/GGTPCRYQ jgkmcd3POfTZej9RwNnpKGev+/rsF1g31Yg2j2QfjGrUjc6KaiDGT92IVmg+hD23hoe9 01e2l2REfFUKTAjkFDrMtsil34Zd8UPrp2O7mPstX5opj/qPcOQKxq5ywrrVz6Zhhzix mcQg== 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=b5RbY7ETO7O1SMcWDdHffidUKoTmEeWM7UscN17SR3A=; b=GmMsL7KLEuJN9F5vbQenQMqU73OrRNJLfcbJIM5dpRWj5AeM8EsW2M7jeLuDIx+EXb mrVItJ4w75KbP02VdcDXiKnshK8eZOHQoCLUB00YatXhmxnFP3njd4/bsDhtUZIBUwwY FvatNWDySw+oSyZYljnvX29md+8SoRxaA4/196FhwVP2AhEueei+MKtrpSWXOTGC6UyC b8Jz/bxmKzhMtD1cJ+2wy+lTeEplf+eGNjWTlVqWhf0uMZjLs/WurLndzbZq5+0J3Vjf jEAmzHOrfx690XvUgzRTee06gvVud0hWiahS3VqVvq/phBS5aewJzPlDCoQiYY/HcsWK FD/w== X-Gm-Message-State: AOAM533gw/Ef0h33vKiXa0VsICPRcjFubR08nr59iyE1MEnes9jsMRj3 02FVfmVkU0sMBNqifjt0RSyCLJLbJ9s= X-Google-Smtp-Source: ABdhPJzCrjnLY8gOmNHu3xKeDw7ARCwBOMd34docUgHHRsGOWthan5mc9FElE1NPmqckkaCDkJa26Q== X-Received: by 2002:a05:6a00:168a:b029:2fb:6bb0:aba with SMTP id k10-20020a056a00168ab02902fb6bb00abamr686841pfc.32.1626119055758; Mon, 12 Jul 2021 12:44:15 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:a7d9:90df:d3f0:78a8:2eb9]) by smtp.gmail.com with ESMTPSA id e21sm17075088pfc.172.2021.07.12.12.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 12:44:15 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v5 7/7] memory_hotplug.c: send DEVICE_UNPLUG_ERROR in acpi_memory_hotplug_write() Date: Mon, 12 Jul 2021 16:43:39 -0300 Message-Id: <20210712194339.813152-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712194339.813152-1-danielhb413@gmail.com> References: <20210712194339.813152-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=danielhb413@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: "Michael S . Tsirkin" , Daniel Henrique Barboza , armbru@redhat.com, groug@kaod.org, qemu-ppc@nongnu.org, Igor Mammedov , eblake@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" MEM_UNPLUG_ERROR is deprecated since the introduction of DEVICE_UNPLUG_ERROR. Keep emitting both while the deprecation of MEM_UNPLUG_ERROR is pending. CC: Michael S. Tsirkin CC: Igor Mammedov Signed-off-by: Daniel Henrique Barboza Reviewed-by: Greg Kurz --- hw/acpi/memory_hotplug.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index e37acb0367..a0772fe083 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -8,6 +8,7 @@ #include "qapi/error.h" #include "qapi/qapi-events-acpi.h" #include "qapi/qapi-events-machine.h" +#include "qapi/qapi-events-qdev.h" #define MEMORY_SLOTS_NUMBER "MDNR" #define MEMORY_HOTPLUG_IO_REGION "HPMR" @@ -181,10 +182,19 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data, trace_mhp_acpi_pc_dimm_delete_failed(mem_st->selector); + /* + * Send both MEM_UNPLUG_ERROR and DEVICE_UNPLUG_ERROR + * while the deprecation of MEM_UNPLUG_ERROR is + * pending. + */ if (dev->id) { qapi_event_send_mem_unplug_error(dev->id, error_pretty); } + qapi_event_send_device_unplug_error(!!dev->id, dev->id, + dev->canonical_path, + true, error_pretty); + error_free(local_err); break; }