From nobody Mon Sep 8 21:39:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737736453241443.0625336391669; Fri, 24 Jan 2025 08:34:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4FD189CC; Fri, 24 Jan 2025 11:34:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 684B01560; Fri, 24 Jan 2025 11:33:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2E74B15E5; Fri, 24 Jan 2025 11:33:38 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1F8151637 for ; Fri, 24 Jan 2025 11:33:30 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-smk3zX2SMiK85TZfEVU2iQ-1; Fri, 24 Jan 2025 11:33:28 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2854D1ACF5FC for ; Fri, 24 Jan 2025 16:33:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A03D1800344 for ; Fri, 24 Jan 2025 16:33:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737736409; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1P+RBHfSI7Cs3TgVNSTIuk4egB6ik+FQczEfU5WT1Jg=; b=J5D7/KTZt/W5bmNK2AA6b1sVfgVrSCpoTSsTLzj0PiLKIlU37u82CPbx0euC8VArowHTxz aWzpCjbIVHv/sgOCUgRzNaQYMy/eseHkosySM+mEtYtt7HDV0r3O3b2XqECexkjS5bdERa KIlckIFbPdfGLBIi1/XzW62WwPhv4Sw= X-MC-Unique: smk3zX2SMiK85TZfEVU2iQ-1 X-Mimecast-MFC-AGG-ID: smk3zX2SMiK85TZfEVU2iQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 1/5] qemuProcessHandleIOError: Refactor to extract 'priv' instead of 'driver' Date: Fri, 24 Jan 2025 17:33:02 +0100 Message-ID: <8ca9ac385f1507a2cd83eb85b2b2ef9d6f3fb9ea.1737736288.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7HLWmxcjESFjUE2ViRvYkxN8NoxHRXSlI5NdgJSO7SU_1737736407 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Q5YYNGTEM24A7E5XSGGLXZGCGAR6MZ6E X-Message-ID-Hash: Q5YYNGTEM24A7E5XSGGLXZGCGAR6MZ6E X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737736453963019100 Content-Type: text/plain; charset="utf-8" The VM private data will be used in a sub-sequent patch. To minimize churn, refactor the function before changing the logic. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6db48b0e7b..34a755a49a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -829,7 +829,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, int action, const char *reason) { - virQEMUDriver *driver; + qemuDomainObjPrivate *priv; virObjectEvent *ioErrorEvent =3D NULL; virObjectEvent *ioErrorEvent2 =3D NULL; virObjectEvent *lifecycleEvent =3D NULL; @@ -838,7 +838,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virDomainDiskDef *disk; virObjectLock(vm); - driver =3D QEMU_DOMAIN_PRIVATE(vm)->driver; + priv =3D QEMU_DOMAIN_PRIVATE(vm); if (*diskAlias =3D=3D '\0') diskAlias =3D NULL; @@ -863,7 +863,6 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, if (action =3D=3D VIR_DOMAIN_EVENT_IO_ERROR_PAUSE && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { - qemuDomainObjPrivate *priv =3D vm->privateData; VIR_WARN("Transitioned guest %s to paused state due to IO error", = vm->def->name); if (priv->signalIOError) @@ -875,7 +874,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, VIR_DOMAIN_EVENT_SUSPEND= ED_IOERROR); VIR_FREE(priv->lockState); - if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lock= State) < 0) + if (virDomainLockProcessPause(priv->driver->lockManager, vm, &priv= ->lockState) < 0) VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); @@ -883,9 +882,9 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, } virObjectUnlock(vm); - virObjectEventStateQueue(driver->domainEventState, ioErrorEvent); - virObjectEventStateQueue(driver->domainEventState, ioErrorEvent2); - virObjectEventStateQueue(driver->domainEventState, lifecycleEvent); + virObjectEventStateQueue(priv->driver->domainEventState, ioErrorEvent); + virObjectEventStateQueue(priv->driver->domainEventState, ioErrorEvent2= ); + virObjectEventStateQueue(priv->driver->domainEventState, lifecycleEven= t); } --=20 2.48.1 From nobody Mon Sep 8 21:39:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737736923711303.6105059028381; Fri, 24 Jan 2025 08:42:03 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A2A9F157C; Fri, 24 Jan 2025 11:42:02 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A405A12CD; Fri, 24 Jan 2025 11:41:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C19E7124D; Fri, 24 Jan 2025 11:41:39 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 44AD2110A for ; Fri, 24 Jan 2025 11:41:39 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-lhILSn9APC6A_zbMrk0TCQ-1; Fri, 24 Jan 2025 11:41:37 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 737831BF17F1 for ; Fri, 24 Jan 2025 16:33:13 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A41A31800344 for ; Fri, 24 Jan 2025 16:33:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737736899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S6s3xnRNyXaqX9LkJr+/8XR1bNP9TUJSKRd8yW9wYBs=; b=Mqq2LIENFkEyQ3y1zxGcNbdf5QVIhi06sCbQqNVoB8V+lVp6SjYkMqtFV3CcqSCJQR3D8k 2pSnAdT1V7X387k2M7saNYRxqecgw3JDF1ye4C63ZJJZBMOfgyd5UCiXBOkMD3hBTSqH92 7/9C03jMk3GlgM4WiJirErc6m4A4tec= X-MC-Unique: lhILSn9APC6A_zbMrk0TCQ-1 X-Mimecast-MFC-AGG-ID: lhILSn9APC6A_zbMrk0TCQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 2/5] qemuProcessHandleIOError: Fix logic for lookup of disk Date: Fri, 24 Jan 2025 17:33:03 +0100 Message-ID: <8a48a9f4b213e831a074b09513744a936d5ca045.1737736288.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rAF2pXVPSskwdSUmStAWlC0tjDlDPZbDXeROgZB_toE_1737736896 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RSEWFMALCEBAYLPQBVYLTMRVA7QY7UGE X-Message-ID-Hash: RSEWFMALCEBAYLPQBVYLTMRVA7QY7UGE X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737736950107019100 Content-Type: text/plain; charset="utf-8" There are two bugs in the current disk lookup code in qemuProcessHandleIOError: 1) The QOM name isn't matched qemuProcessFindDomainDiskByAliasOrQOM() We pass NULL as the second argument, but the diskAlias argument can be the QOM path for e.g. virtio disks. This means that the IO error event doesn't actually contain the disk information: event 'io-error' for domain 'cd': () report due to other: Input/outpu= t error rather than: event 'io-error' for domain 'cd': /dev/mapper/errdev0 (virtio-disk0) r= eport due to other: Input/output error 2) nodenames are not preferred We now do everything based on node names, which also allow you to pinpoint a image within the backing chain. With the current code the path would always refer to the top image rather than the actual image causing the problem. This patch fixes both issues by re-ordering the lookup to prefer nodenames and selecting the image path based on the node name and also populates the third argument of qemuProcessFindDomainDiskByAliasOrQOM(). Signed-off-by: Peter Krempa --- src/qemu/qemu_process.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 34a755a49a..95d0a40f84 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -833,9 +833,9 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virObjectEvent *ioErrorEvent =3D NULL; virObjectEvent *ioErrorEvent2 =3D NULL; virObjectEvent *lifecycleEvent =3D NULL; - const char *srcPath; - const char *devAlias; - virDomainDiskDef *disk; + virStorageSource *errsrc =3D NULL; + const char *srcPath =3D ""; + const char *devAlias =3D ""; virObjectLock(vm); priv =3D QEMU_DOMAIN_PRIVATE(vm); @@ -843,19 +843,21 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUS= ED, if (*diskAlias =3D=3D '\0') diskAlias =3D NULL; - if (diskAlias) - disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL= ); - else if (nodename) - disk =3D qemuDomainDiskLookupByNodename(vm->def, NULL, nodename, N= ULL); - else - disk =3D NULL; + if (nodename) { + virDomainDiskDef *disk =3D qemuDomainDiskLookupByNodename(vm->def,= priv->backup, nodename, &errsrc); - if (disk) { - srcPath =3D virDomainDiskGetSource(disk); - devAlias =3D disk->info.alias; - } else { - srcPath =3D ""; - devAlias =3D ""; + if (errsrc->path) + srcPath =3D errsrc->path; + + if (disk) + devAlias =3D disk->info.alias; + } else if (diskAlias) { + virDomainDiskDef *disk =3D qemuProcessFindDomainDiskByAliasOrQOM(v= m, diskAlias, diskAlias); + + if (disk) { + srcPath =3D virDomainDiskGetSource(disk); + devAlias =3D disk->info.alias; + } } ioErrorEvent =3D virDomainEventIOErrorNewFromObj(vm, srcPath, devAlias= , action); --=20 2.48.1 From nobody Mon Sep 8 21:39:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737736419561782.0619936237728; Fri, 24 Jan 2025 08:33:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9012F1556; Fri, 24 Jan 2025 11:33:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 94B37156E; Fri, 24 Jan 2025 11:33:21 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7438412D5; Fri, 24 Jan 2025 11:33:18 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F34DF12B0 for ; Fri, 24 Jan 2025 11:33:17 -0500 (EST) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-XyZ-AuS7Ptyu3I6mz1rtBQ-1; Fri, 24 Jan 2025 11:33:16 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6DC91B9BF39 for ; Fri, 24 Jan 2025 16:33:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 095D71800358 for ; Fri, 24 Jan 2025 16:33:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737736397; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zc+tB4R6TEX4nh+/o+OmzaxPCMkAz5okaOUYatA41xY=; b=gxTnKdZhMgzSTodLXvFcTvZiAZHY7xZteWo2/6d1s2V4PZbaFXksmRb/hrHMazf/HmqWUv BDw5ehxCuuBhfuL6nu5aVIMlxSrCkyZi4EJHCXlm5xhbXK5mG+kD0Ps/3CjaFSwdCH8eX3 sIW6VF71CC86ig5Ox5soEgXffHoGZgs= X-MC-Unique: XyZ-AuS7Ptyu3I6mz1rtBQ-1 X-Mimecast-MFC-AGG-ID: XyZ-AuS7Ptyu3I6mz1rtBQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 3/5] API: Document more possibilities for @reason field of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON event Date: Fri, 24 Jan 2025 17:33:04 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: KVh0E_s3lHvKxiqJQ0-99mDDUvJJhIRF251Jy-sJeVw_1737736395 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UZOOYGP2SHRVIA7FDG5XUW55A7AJFGC6 X-Message-ID-Hash: UZOOYGP2SHRVIA7FDG5XUW55A7AJFGC6 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737736421831019100 Content-Type: text/plain; charset="utf-8" The VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON event allows @reason to be reported to the user, but currently we only report 'enospc'. Extend the documentation so that we allow the passthrough of the verbatim error, prefixed by 'other: ' in order to prevent collisions and note that users must not attempt to parse them. Signed-off-by: Peter Krempa --- include/libvirt/libvirt-domain.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 2a4b81f4df..e031b23547 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4790,8 +4790,12 @@ typedef void (*virConnectDomainEventIOErrorCallback)= (virConnectPtr conn, * If the I/O error is known to be caused by an ENOSPC condition in * the host (where resizing the disk to be larger will allow the guest * to be resumed as if nothing happened), @reason will be "enospc". - * Otherwise, @reason will be "", although future strings may be added - * if determination of other error types becomes possible. + * + * Otherwise, if the hypervisor reported an error @reason will be the verb= atim + * error message from hypervisor prefixed by "other: ". Note that this err= or + * may not be stable and thus is only really usable for human use. In case + * when the hypervisor doesn't report the error @reason will be an empty s= tring + * "". * * Since: 0.8.1 */ --=20 2.48.1 From nobody Mon Sep 8 21:39:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737736436605850.9837576607753; Fri, 24 Jan 2025 08:33:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 98ADE1627; Fri, 24 Jan 2025 11:33:55 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 55E8B158D; Fri, 24 Jan 2025 11:33:25 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B8DEF1598; Fri, 24 Jan 2025 11:33:21 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3BF2A12B0 for ; Fri, 24 Jan 2025 11:33:21 -0500 (EST) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-R2QMqDq8MeeusyU9K_0hDA-1; Fri, 24 Jan 2025 11:33:17 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 387AE1B9BF3F for ; Fri, 24 Jan 2025 16:33:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C4301800344 for ; Fri, 24 Jan 2025 16:33:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737736400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E7dtyHux1lvL2LaDcAI2uZmR9+HcQ3/TvCzqLGRtqtQ=; b=eG2wrXEQ6PSTAkQwiDio7yasFTGgpuvzDvrLdM3MAXqo/v0HAnbie7oiyX2jV5EkdRqOKT VVY0Q9T8Mt7Kbuu0M6m7tkK9nBR20abd1+F2X24aRauPwP+TQsz5GDkI7wtDbFi5Ft3Of8 0uarAbUODEfglHlPcQlk1J3zW5KeZWs= X-MC-Unique: R2QMqDq8MeeusyU9K_0hDA-1 X-Mimecast-MFC-AGG-ID: R2QMqDq8MeeusyU9K_0hDA From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 4/5] qemu: monitor: Plumb in disk IO error message passthrough to VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON Date: Fri, 24 Jan 2025 17:33:05 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1DvOzRlPG_6tMNb_DSAhMn-qpaMKxtFp28FX-nOGe4I_1737736396 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: W6YXHFLQBOL565THD45TM3CXSQU7PLOV X-Message-ID-Hash: W6YXHFLQBOL565THD45TM3CXSQU7PLOV X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737736437893019100 Content-Type: text/plain; charset="utf-8" Pass the generic error message from qemu to the event so that users can possibly use the information. As documented the error is prefixed with "other: " to prevent collisions with already documented values in our API. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9f417d27c6..6de34b03bb 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -695,7 +695,7 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONV= alue *data) const char *device; const char *nodename; const char *action; - const char *reason =3D ""; + g_autofree char *reason =3D NULL; bool nospc =3D false; int actionID; @@ -713,14 +713,27 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSO= NValue *data) nodename =3D virJSONValueObjectGetString(data, "node-name"); - if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) =3D=3D 0 && = nospc) - reason =3D "enospc"; + if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) =3D=3D 0 && = nospc) { + reason =3D g_strdup("enospc"); + } else { + /* For any unknown error we prefix the qemu-originating error with= 'other: ' + * so that applications can use that to filter them from errors we + * define in our API */ + const char *qemureason; + + if ((qemureason =3D virJSONValueObjectGetString(data, "reason"))) { + reason =3D g_strdup_printf("other: %s", qemureason); + } + } if ((actionID =3D qemuMonitorIOErrorActionTypeFromString(action)) < 0)= { VIR_WARN("unknown disk io error action '%s'", action); actionID =3D VIR_DOMAIN_EVENT_IO_ERROR_NONE; } + if (!reason) + reason =3D g_strdup(""); + qemuMonitorEmitIOError(mon, device, nodename, actionID, reason); } --=20 2.48.1 From nobody Mon Sep 8 21:39:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737736567914351.71378813333854; Fri, 24 Jan 2025 08:36:07 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0990B12B6; Fri, 24 Jan 2025 11:36:07 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C7ACA128E; Fri, 24 Jan 2025 11:35:48 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 62CB8C5D; Fri, 24 Jan 2025 11:35:46 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A351A9CC for ; Fri, 24 Jan 2025 11:35:43 -0500 (EST) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-H89FzqAtNU2N00s-434RCQ-1; Fri, 24 Jan 2025 11:35:28 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9639318E10E6 for ; Fri, 24 Jan 2025 16:33:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE8521800348 for ; Fri, 24 Jan 2025 16:33:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737736543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m8pzZ/REGZgkFiOMZpww3lDWLRFXPSv5b47l5wZmh+s=; b=RTSvfPD/On8H76i7P25LLyyC0TwVwMFKx1HOgazJtNdcYGtNgOS0CPvylNbFYhZ+SMuXL8 vBSBYPQCFlAO9mvcbSsiRbzKLmEgfuEq9crC5iR7Y7T88PLuXeN5A2tlntomEoQ0sEx4Vo jU/6iXfiaYPyT0ejgCT0TsosxFx6Qy0= X-MC-Unique: H89FzqAtNU2N00s-434RCQ-1 X-Mimecast-MFC-AGG-ID: H89FzqAtNU2N00s-434RCQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 5/5] qemuProcessHandleIOError: Log IO errors in the VM log file Date: Fri, 24 Jan 2025 17:33:06 +0100 Message-ID: <9e45d32d2043bdfc76af0b2c6c60da4863c8a1a0.1737736288.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gGl7GAt3b71dZn0pMZsuGwVQ_qi5uigBUxOugtLw_fs_1737736528 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6K34YWZIEP4SUTMY42O5QO6RVGHSYTNQ X-Message-ID-Hash: 6K34YWZIEP4SUTMY42O5QO6RVGHSYTNQ X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737736570489019100 Content-Type: text/plain; charset="utf-8" Add a log entry to the VM log file for every time we receive an IO error event from qemu. The log entry is as follows: 2025-01-24 16:03:28.928+0000: IO error device=3D'virtio-disk0' node-name= =3D'libvirt-1-storage' reason=3D'other: Input/output error' Signed-off-by: Peter Krempa --- src/qemu/qemu_process.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 95d0a40f84..e813c11f7e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -836,6 +836,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virStorageSource *errsrc =3D NULL; const char *srcPath =3D ""; const char *devAlias =3D ""; + g_autofree char *timestamp =3D NULL; virObjectLock(vm); priv =3D QEMU_DOMAIN_PRIVATE(vm); @@ -884,6 +885,11 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSE= D, } virObjectUnlock(vm); + if ((timestamp =3D virTimeStringNow()) !=3D NULL) { + qemuDomainLogAppendMessage(priv->driver, vm, "%s: IO error device= =3D'%s' node-name=3D'%s' reason=3D'%s'\n", + timestamp, NULLSTR(devAlias), NULLSTR(n= odename), NULLSTR(reason)); + } + virObjectEventStateQueue(priv->driver->domainEventState, ioErrorEvent); virObjectEventStateQueue(priv->driver->domainEventState, ioErrorEvent2= ); virObjectEventStateQueue(priv->driver->domainEventState, lifecycleEven= t); --=20 2.48.1