From patchwork Fri Jun 4 20:03:52 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: 12300669 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,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 318F2C4743C for ; Fri, 4 Jun 2021 20:05:52 +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 BBA636115B for ; Fri, 4 Jun 2021 20:05:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBA636115B 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]:36782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpG4k-0007In-Qm for qemu-devel@archiver.kernel.org; Fri, 04 Jun 2021 16:05:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpG3C-0005Bj-2N; Fri, 04 Jun 2021 16:04:14 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:33769) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpG3A-0000Qx-0l; Fri, 04 Jun 2021 16:04:13 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id 5so5613863qvk.0; Fri, 04 Jun 2021 13:04:11 -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=A0fEYqYijgmXe2Xcovc9mpgjPFbwuu7scsqLtKvxj5A=; b=brPulBsaSfnPKERT8adhepBjWsHHFK8eGGzko4i71gE1Pu8hg/j2R/PheOqwnYNDva iQbSdEi64D2sLK183QCz1n48DXlvIb0f2qo9cFPv7NiDuAHHWNiWOvghckyYo3RUKiq8 yzQ/q0kZo2V2ko+GUvja1DezlJNjWYmlKBcNTefIjFd6s95bMyTkgThk7ncAXMHSEznL VXX5oCzhOrpQejG7LkZ6ObOuYR+9pGCbglrsmXx63ceERfZEQXZ+wsbYb1qVGWBvygmd fWnUfVz49bE7LTY9Wj8xyAxBQdQUiPKbBLN+4sBwNLNBsDspO7JDIVskJR4O2Om0nzrL ZpAA== 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=A0fEYqYijgmXe2Xcovc9mpgjPFbwuu7scsqLtKvxj5A=; b=pOJXiL6sTXyixQUGMpE61TNOqgYJzfP9h63ztaLbHLL/IO6mvYIN+rXENdCUdt3/LC /oLRoPmg39R15fa/HtKasEXP+MHAqjfHU0L4Ggmj9N1y9N1fbM/lF9lxSUo5zTz8APr0 VwX3v3zEXhRLaiX4YQueDeEJDRA6rccav6fOQicbDXLXRnmodPcCkvCfBAVNXyCUv2HT 19E10EbamCa4vBf0gkF+AVukUL/yh1pFOhT5vKlVyMevyNWer/RB+ZKBkPv5S3vJ1txq AjQv7r/PqRXsX6GVjtOCib5CSYkZ8W3cRENSrH/KdcoxqTTiGrxJ37cHkOapb/oiDWlc 9tUQ== X-Gm-Message-State: AOAM532E+xZgbTou7ukKwPs13qGQXNGjig3xiw4BDnexXpy7k5TfBy9i pfX3ZD0GgkvrgFq1gyFY7IKOzzdFU7V9XQ== X-Google-Smtp-Source: ABdhPJxyArMo6RKkhOmc1lvf0Td6EuJFO1DxEymLRHqsUHpbEAV0G+8Zva+QthaNa2nQgq7aJA8WJA== X-Received: by 2002:a0c:d409:: with SMTP id t9mr6525197qvh.18.1622837050515; Fri, 04 Jun 2021 13:04:10 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7c6:b390:9cad:b272:426b:6a0]) by smtp.gmail.com with ESMTPSA id f19sm4765011qkg.70.2021.06.04.13.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 13:04:10 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] qapi/machine.json: add DEVICE_UNPLUG_ERROR QAPI event Date: Fri, 4 Jun 2021 17:03:52 -0300 Message-Id: <20210604200353.1206897-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604200353.1206897-1-danielhb413@gmail.com> References: <20210604200353.1206897-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf2f.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: armbru@redhat.com, Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, 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. Signed-off-by: Daniel Henrique Barboza Reviewed-by: David Gibson Reviewed-by: Eric Blake --- qapi/machine.json | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/qapi/machine.json b/qapi/machine.json index 58a9c86b36..f0c7e56be0 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1274,3 +1274,26 @@ ## { 'event': 'MEM_UNPLUG_ERROR', 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @DEVICE_UNPLUG_ERROR: +# +# Emitted when a device hot unplug error occurs. +# +# @device: device name +# +# @msg: Informative message +# +# Since: 6.1 +# +# Example: +# +# <- { "event": "DEVICE_UNPLUG_ERROR" +# "data": { "device": "dimm1", +# "msg": "Memory hotunplug rejected by the guest for device dimm1" +# }, +# "timestamp": { "seconds": 1615570772, "microseconds": 202844 } } +# +## +{ 'event': 'DEVICE_UNPLUG_ERROR', + 'data': { 'device': 'str', 'msg': 'str' } } From patchwork Fri Jun 4 20:03:53 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: 12300671 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,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 2BC27C4743D for ; Fri, 4 Jun 2021 20:06:24 +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 D499B613F8 for ; Fri, 4 Jun 2021 20:06:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D499B613F8 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]:38018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpG5H-0008Fd-0V for qemu-devel@archiver.kernel.org; Fri, 04 Jun 2021 16:06:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpG3D-0005EE-Tf; Fri, 04 Jun 2021 16:04:15 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:38555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpG3C-0000Sq-6w; Fri, 04 Jun 2021 16:04:15 -0400 Received: by mail-qv1-xf32.google.com with SMTP id d7so3311418qvo.5; Fri, 04 Jun 2021 13:04: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=fubNt4vIGj8rn9Wilds9sxVsuW1S33RuN/p7GDbl1JU=; b=poDRT9ewH457boxorUmkxofj50gLl6Z4YaSJi3zQjmQPA3AWyvaa90W8UFDOVt07Dv YcvAPPa3tFyKac/NYkE3BKKKm0gyavccooCekaLLn6egfGFFt2I3Tupp/f+siO8LnGjs PTBth3Rhk9YVOyIAqeqnQ31bj/riQbSfuZlMb3j+06BlCa3P4eCpk3x/tW2jLrkMI5MN Hl95hWV+KZD+GMWrbtu0Tjeb2gkzAeaYfUhATElAHnK0h9tDlNZk0cyNDkK61sg+IVxB u7yZ+VpiWGwTJkk0tH1IroBUVp6HperUbwXPU/bg/ViLwdcjJVjJlccwp+Kj4Ub7Q1rA HvDw== 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=fubNt4vIGj8rn9Wilds9sxVsuW1S33RuN/p7GDbl1JU=; b=XmOt01WWoXzCCjOgmLSqSm0BfRjBLC53QGrrlihXF4hQKll92+LT54OZHcg6+LAV6W SeZfCwKDJZnXNO5VNH/5Uq4C1nlo4QFckpGE+77qsHA1eiz8x+Hn5lR0KRRzkx5TnNyk YWp5hGlq9DCWaEXstAZVTDQTtgdCNkrp/46F3fEl4roKbLao6pao+xekN/wHEHKZEAZW ocUu4IHJqET6FOxBelmHRE394Dfqz02Fcabkr1/9YYM6uNmqKTJBbWPRT8ueUgaPh83f HanZ0Vms2J//E/3sPIbW22bFSTGA/WQoVcl3YS0NXpQEt+JNocCbR3k+iLORu+25/AsS x4sA== X-Gm-Message-State: AOAM530cVdPnvgk+lbIv9yL3BbXOOMB/isbuTiTJ+8SsSt2kEC7i2CPZ TUKY8BqOFMIgQrRmi1ITnA9YyEMO9CnFJg== X-Google-Smtp-Source: ABdhPJwyALJknxoFYdccWORcbCoftQoC/55/IYi7BlSGvCVQt/wbksmy6BJTF5cog/rmGA2Xw/6/0A== X-Received: by 2002:a05:6214:18d0:: with SMTP id cy16mr6507376qvb.29.1622837052852; Fri, 04 Jun 2021 13:04:12 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7c6:b390:9cad:b272:426b:6a0]) by smtp.gmail.com with ESMTPSA id f19sm4765011qkg.70.2021.06.04.13.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 13:04:12 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] spapr: use DEVICE_UNPLUG_ERROR to report unplug errors Date: Fri, 4 Jun 2021 17:03:53 -0300 Message-Id: <20210604200353.1206897-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604200353.1206897-1-danielhb413@gmail.com> References: <20210604200353.1206897-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf32.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: armbru@redhat.com, Daniel Henrique Barboza , qemu-ppc@nongnu.org, groug@kaod.org, 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: David Gibson --- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_drc.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c23bcc4490..29aa2f467d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3639,7 +3639,7 @@ void spapr_memory_unplug_rollback(SpaprMachineState *spapr, DeviceState *dev) */ 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, qapi_error); } /* Callback to be called during DRC release. */ diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index a2f2634601..0e1a8733bc 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-machine.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()); @@ -167,13 +173,10 @@ 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); + error_report(qapi_error_fmt, drc->dev->id); - /* - * TODO: send a QAPI DEVICE_UNPLUG_ERROR event when - * it is implemented. - */ + qapi_error = g_strdup_printf(qapi_error_fmt, drc->dev->id); + qapi_event_send_device_unplug_error(drc->dev->id, qapi_error); } return RTAS_OUT_SUCCESS; /* Nothing to do */