From nobody Mon Sep 8 21:40:31 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 1738081779254768.4066415298263; Tue, 28 Jan 2025 08:29:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id AB90F1794; Tue, 28 Jan 2025 11:29:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1A17D1B39; Tue, 28 Jan 2025 11:28:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3E9C91645; Tue, 28 Jan 2025 11:28:28 -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 BF6A51794 for ; Tue, 28 Jan 2025 11:28:27 -0500 (EST) Received: from mx-prod-mc-01.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-6-2syzjg62OTSLzJUbaCl1Xg-1; Tue, 28 Jan 2025 11:28:24 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B67E41956059 for ; Tue, 28 Jan 2025 16:28:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E659D19560AA for ; Tue, 28 Jan 2025 16:28:22 +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=1738081706; 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=fYTwxF3P8XOt4+l7wPvGTj+iC1iEJlZRqoSbQJj1ZVk=; b=FM1a4xN+vfIDwRTiElW5Jd3MA631OFbnF6YLkvnfW21/SorCrJ+m65KJuhwe+sBxEV6SSr Y97fuTrWPKq3XpKr609cmFMRgS8rlXNPc3/YQYkYwYiPJvhGRtRspCTq4FsIC7BeF7RVGi CDilPtmdeSamoqV0tuW7a1AsVzQ7Q+A= X-MC-Unique: 2syzjg62OTSLzJUbaCl1Xg-1 X-Mimecast-MFC-AGG-ID: 2syzjg62OTSLzJUbaCl1Xg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 01/15] qemu: Handle quirks of 'device' field of BLOCK_IO_ERROR event in monitor code Date: Tue, 28 Jan 2025 17:28:05 +0100 Message-ID: <98dcfc71adae75ff59f9086bd7b8eef0279c900d.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GBm716flFCttZfCjz5qUIv64c_kWyXhXQRGb6q4mShY_1738081703 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KKOCIBUUOMRZXPU4ZGCZAP6U3BBBL7WI X-Message-ID-Hash: KKOCIBUUOMRZXPU4ZGCZAP6U3BBBL7WI 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: 1738081779827019000 Content-Type: text/plain; charset="utf-8" BLOCK_IO_ERROR's 'device' field is an empty string in case when it isn't applicable as it was originally mandatory in the qemu API docs. Move the logic that convert's empty string back to NULL from 'qemuProcessHandleIOError()' to 'qemuMonitorJSONHandleIOError()' This also fixes a hypothetical NULL-dereference if qemu would indeed report an IO error without the 'device' field present. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_monitor_json.c | 9 ++++++++- src/qemu/qemu_process.c | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9f417d27c6..5ca76d2d80 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -708,8 +708,15 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSON= Value *data) action =3D "ignore"; } - if ((device =3D virJSONValueObjectGetString(data, "device")) =3D=3D NU= LL) + if ((device =3D virJSONValueObjectGetString(data, "device")) =3D=3D NU= LL) { VIR_WARN("missing device in disk io error event"); + } else { + /* 'device' was documented as mandatory in the qemu event, but lat= er became + * optional, in which case an empty string is sent by qemu. Conver= t it back + * to NULL */ + if (*device =3D=3D '\0') + device =3D NULL; + } nodename =3D virJSONValueObjectGetString(data, "node-name"); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 34a755a49a..edcd8ac3a8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -840,9 +840,6 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virObjectLock(vm); priv =3D QEMU_DOMAIN_PRIVATE(vm); - if (*diskAlias =3D=3D '\0') - diskAlias =3D NULL; - if (diskAlias) disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL= ); else if (nodename) --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081758893994.3397706236767; Tue, 28 Jan 2025 08:29:18 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 47A4D1838; Tue, 28 Jan 2025 11:29:18 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C68D6191A; Tue, 28 Jan 2025 11:28:31 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B2C9A1645; Tue, 28 Jan 2025 11:28:27 -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 3C4D21794 for ; Tue, 28 Jan 2025 11:28:27 -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-45-kzsiBfeFMrO4CO00s-N6qA-1; Tue, 28 Jan 2025 11:28:25 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 0112118009C1 for ; Tue, 28 Jan 2025 16:28:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3869419560AA for ; Tue, 28 Jan 2025 16:28:23 +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=1738081706; 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=au/SYPeiqFhj51othNo7riwZDh/uXJnXJk7ds8qRuWc=; b=Lniyme7YpXlsFeKkoHkHQGPfwHykFhhWxdDZ+fa3JykagW3LVbPvvanEm0/yiduoJ3awIN QFrrUciLeOuAN7tSIdVfs1Ly3ktee5g/wu7FabBBcWNs7xqMsS95wixm86m6bQCFtJ24uB HWgv92lub1KIHcj26kpfw2/8ZABpRJk= X-MC-Unique: kzsiBfeFMrO4CO00s-N6qA-1 X-Mimecast-MFC-AGG-ID: kzsiBfeFMrO4CO00s-N6qA From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 02/15] qemu: Rename 'diskAlias' to 'device' in qemu IO error event handling Date: Tue, 28 Jan 2025 17:28:06 +0100 Message-ID: <565d3fede50aee2a1fd4fae9928dec69083095c8.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Sa5szQxGerFu1SyjfZ7m4qLPu6XQ5rR4KDEcQSshc04_1738081705 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CVAUH36S3OZH6X544RO3EZWKNBKBJ3GQ X-Message-ID-Hash: CVAUH36S3OZH6X544RO3EZWKNBKBJ3GQ 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: 1738081759652019000 Content-Type: text/plain; charset="utf-8" The field is named 'device' in the event so unify our naming. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor.h | 4 ++-- src/qemu/qemu_process.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e0b1bf1d37..1227298a45 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1127,7 +1127,7 @@ qemuMonitorEmitWatchdog(qemuMonitor *mon, int action) void qemuMonitorEmitIOError(qemuMonitor *mon, - const char *diskAlias, + const char *device, const char *nodename, int action, const char *reason) @@ -1135,7 +1135,7 @@ qemuMonitorEmitIOError(qemuMonitor *mon, VIR_DEBUG("mon=3D%p", mon); QEMU_MONITOR_CALLBACK(mon, domainIOError, mon->vm, - diskAlias, nodename, action, reason); + device, nodename, action, reason); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c74892c4dc..3ec8e7227f 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -206,7 +206,7 @@ typedef void (*qemuMonitorDomainWatchdogCallback)(qemuM= onitor *mon, int action); typedef void (*qemuMonitorDomainIOErrorCallback)(qemuMonitor *mon, virDomainObj *vm, - const char *diskAlias, + const char *device, const char *nodename, int action, const char *reason); @@ -450,7 +450,7 @@ void qemuMonitorEmitResume(qemuMonitor *mon); void qemuMonitorEmitRTCChange(qemuMonitor *mon, long long offset); void qemuMonitorEmitWatchdog(qemuMonitor *mon, int action); void qemuMonitorEmitIOError(qemuMonitor *mon, - const char *diskAlias, + const char *device, const char *nodename, int action, const char *reason); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index edcd8ac3a8..c2a5361b79 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -824,7 +824,7 @@ qemuProcessHandleWatchdog(qemuMonitor *mon G_GNUC_UNUSE= D, static void qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virDomainObj *vm, - const char *diskAlias, + const char *device, const char *nodename, int action, const char *reason) @@ -840,8 +840,8 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virObjectLock(vm); priv =3D QEMU_DOMAIN_PRIVATE(vm); - if (diskAlias) - disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL= ); + if (device) + disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, device, NULL); else if (nodename) disk =3D qemuDomainDiskLookupByNodename(vm->def, NULL, nodename, N= ULL); else --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081798770899.6164970570045; Tue, 28 Jan 2025 08:29:58 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 24A7917DA; Tue, 28 Jan 2025 11:29:58 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BDAD11808; Tue, 28 Jan 2025 11:28:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3FD8917E5; Tue, 28 Jan 2025 11:28:30 -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 BABCD1799 for ; Tue, 28 Jan 2025 11:28:29 -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-65-0du8yug9OXOUFgKxqy9iEw-1; Tue, 28 Jan 2025 11:28:27 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 575301800373 for ; Tue, 28 Jan 2025 16:28:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8791919560AA for ; Tue, 28 Jan 2025 16:28:25 +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=1738081709; 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=cUP/ujkfPLGr7OovqejREa7ixRKeeSL5Hj53w/2Yd/U=; b=FWXXnpDl8dGyRlO7V8CseIKiF4mQ2GrCSkRJNtZcU7INRKawge7pzuMGV2haCrAmzY58M8 Fay3gAMusbuGYStLhgL5+UlqvtJByK0jhC9IPU6K0nGz7jcUmbHxrpTLzbECBgjY3lAs/0 /Yy+n6mP9jfhLffblHc/At9N8kCHawg= X-MC-Unique: 0du8yug9OXOUFgKxqy9iEw-1 X-Mimecast-MFC-AGG-ID: 0du8yug9OXOUFgKxqy9iEw From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 03/15] qemuProcessHandleIOError: Rename local variables Date: Tue, 28 Jan 2025 17:28:07 +0100 Message-ID: <877753789dbf9b7a90d14b2fa81e631f4df30499.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tQ-h9OoQPQ5357B45_eryV_Od2PERgsRrh9R6Lt1Cv4_1738081706 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6JTSIEDFI6RLUVJ67QJVVK554FNDI2NP X-Message-ID-Hash: 6JTSIEDFI6RLUVJ67QJVVK554FNDI2NP 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: 1738081800047019000 Content-Type: text/plain; charset="utf-8" Prefix the helper variables used to supply data to the event by 'event'. Declare them with the default value of an empty string rather than doing it later. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c2a5361b79..aaf718e552 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -833,8 +833,8 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virObjectEvent *ioErrorEvent =3D NULL; virObjectEvent *ioErrorEvent2 =3D NULL; virObjectEvent *lifecycleEvent =3D NULL; - const char *srcPath; - const char *devAlias; + const char *eventPath =3D ""; + const char *eventAlias =3D ""; virDomainDiskDef *disk; virObjectLock(vm); @@ -848,15 +848,12 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUS= ED, disk =3D NULL; if (disk) { - srcPath =3D virDomainDiskGetSource(disk); - devAlias =3D disk->info.alias; - } else { - srcPath =3D ""; - devAlias =3D ""; + eventPath =3D virDomainDiskGetSource(disk); + eventAlias =3D disk->info.alias; } - ioErrorEvent =3D virDomainEventIOErrorNewFromObj(vm, srcPath, devAlias= , action); - ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, srcPath, d= evAlias, action, reason); + ioErrorEvent =3D virDomainEventIOErrorNewFromObj(vm, eventPath, eventA= lias, action); + ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, eventPath,= eventAlias, action, reason); if (action =3D=3D VIR_DOMAIN_EVENT_IO_ERROR_PAUSE && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081828800927.3551037290908; Tue, 28 Jan 2025 08:30:28 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 185B31807; Tue, 28 Jan 2025 11:30:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 32A641AA9; Tue, 28 Jan 2025 11:28:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8609717AC; Tue, 28 Jan 2025 11:28:36 -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 3D2D417AC for ; Tue, 28 Jan 2025 11:28:30 -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-343-RvgDdt7zMJWl1NW_uYi7yg-1; Tue, 28 Jan 2025 11:28:28 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 95A5419560A1 for ; Tue, 28 Jan 2025 16:28:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CD6D119560AA for ; Tue, 28 Jan 2025 16:28:26 +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=1738081709; 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=XL96JJudpM6AgXIJHwl2R0bijf8skwAP6748ILSdPMk=; b=JvI2BWKOp5OymIQcc7UCGHIsURXMWbmBy8uoGyRO4Dqda+R4xnDBQSfUE1iXWlGES+mWP9 Cpfll2bD2RmE59AJrZbDB4LIrLUN37JSw4eGYwn0d4gsjBWBlJw2U5SeVtV52gr72j4Wjd y1AxSDrfNEv8HRRvlx26f/ddZkZxX8I= X-MC-Unique: RvgDdt7zMJWl1NW_uYi7yg-1 X-Mimecast-MFC-AGG-ID: RvgDdt7zMJWl1NW_uYi7yg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 04/15] qemuMonitorJSONHandleIOError: Do not munge 'reason' field of IO error event Date: Tue, 28 Jan 2025 17:28:08 +0100 Message-ID: <734264ac52de116fca65674d0aeee21ac50888cb.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: wNpzuKXflgbm52h1UdPGNbgebmYv_n8E2hL4bDOCTCo_1738081707 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PNN3TVE2GUR2T3RV2MQVFMECZKY3D5AB X-Message-ID-Hash: PNN3TVE2GUR2T3RV2MQVFMECZKY3D5AB 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: 1738081830355019000 Content-Type: text/plain; charset="utf-8" Leave the interpretation of the event to 'qemuProcessHandleIOError()' which will create it's own variant of the messages for the user-facing libvirt events. qemuMonitorJSONHandleIOError() will pass through the raw data it got from qemu. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_monitor.c | 3 ++- src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 12 ++++++------ src/qemu/qemu_process.c | 9 +++++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 1227298a45..cae7dc6bf5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1130,12 +1130,13 @@ qemuMonitorEmitIOError(qemuMonitor *mon, const char *device, const char *nodename, int action, + bool nospace, const char *reason) { VIR_DEBUG("mon=3D%p", mon); QEMU_MONITOR_CALLBACK(mon, domainIOError, mon->vm, - device, nodename, action, reason); + device, nodename, action, nospace, reason); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 3ec8e7227f..c1aa36fe83 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -209,6 +209,7 @@ typedef void (*qemuMonitorDomainIOErrorCallback)(qemuMo= nitor *mon, const char *device, const char *nodename, int action, + bool nospace, const char *reason); typedef void (*qemuMonitorDomainGraphicsCallback)(qemuMonitor *mon, virDomainObj *vm, @@ -453,6 +454,7 @@ void qemuMonitorEmitIOError(qemuMonitor *mon, const char *device, const char *nodename, int action, + bool nospace, const char *reason); void qemuMonitorEmitGraphics(qemuMonitor *mon, int phase, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5ca76d2d80..db232cee78 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -695,8 +695,8 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONV= alue *data) const char *device; const char *nodename; const char *action; - const char *reason =3D ""; - bool nospc =3D false; + const char *reason; + bool nospace =3D false; int actionID; /* Throughout here we try our best to carry on upon errors, @@ -719,16 +719,16 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSO= NValue *data) } nodename =3D virJSONValueObjectGetString(data, "node-name"); - - if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) =3D=3D 0 && = nospc) - reason =3D "enospc"; + reason =3D virJSONValueObjectGetString(data, "reason"); + /* 'nospace' flag is relevant only when true */ + ignore_value(virJSONValueObjectGetBoolean(data, "nospace", &nospace)); if ((actionID =3D qemuMonitorIOErrorActionTypeFromString(action)) < 0)= { VIR_WARN("unknown disk io error action '%s'", action); actionID =3D VIR_DOMAIN_EVENT_IO_ERROR_NONE; } - qemuMonitorEmitIOError(mon, device, nodename, actionID, reason); + qemuMonitorEmitIOError(mon, device, nodename, actionID, nospace, reaso= n); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index aaf718e552..80a73643f0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -827,7 +827,8 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, const char *device, const char *nodename, int action, - const char *reason) + bool nospace, + const char *reason G_GNUC_UNUSED) { qemuDomainObjPrivate *priv; virObjectEvent *ioErrorEvent =3D NULL; @@ -835,6 +836,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virObjectEvent *lifecycleEvent =3D NULL; const char *eventPath =3D ""; const char *eventAlias =3D ""; + const char *eventReason =3D ""; virDomainDiskDef *disk; virObjectLock(vm); @@ -852,8 +854,11 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSE= D, eventAlias =3D disk->info.alias; } + if (nospace) + eventReason =3D "enospc"; + ioErrorEvent =3D virDomainEventIOErrorNewFromObj(vm, eventPath, eventA= lias, action); - ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, eventPath,= eventAlias, action, reason); + ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, eventPath,= eventAlias, action, eventReason); if (action =3D=3D VIR_DOMAIN_EVENT_IO_ERROR_PAUSE && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081847192259.01962641241005; Tue, 28 Jan 2025 08:30:47 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E1B42180F; Tue, 28 Jan 2025 11:30:46 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1AA841B76; Tue, 28 Jan 2025 11:28:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C8B2F1859; Tue, 28 Jan 2025 11:28: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 69AA3187C for ; Tue, 28 Jan 2025 11:28:31 -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-336-R10AmYIiPsKhyPt4duGmzQ-1; Tue, 28 Jan 2025 11:28:29 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 E1AB418018A5 for ; Tue, 28 Jan 2025 16:28:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1C99219560BC for ; Tue, 28 Jan 2025 16:28:27 +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=1738081711; 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=iLacrI0FjFsUIKLM+MwYd+fkSiNxlBGi7m+vIXSjmoQ=; b=iiM9E50dOsB4YGyyhwJpcsjTqn5F4cexXZaHjVBrbuncxRsejz+t1wDBHNyjgpD2Zp5uVj rempLralNG9sjdpTnbmdWEpl9dncZQpoempJXKezfYIr7CmqWjSBC2113C1Jp3C+NEFhKu tHU7rWXDRwpKRG5SexcHUbQonlfOJf4= X-MC-Unique: R10AmYIiPsKhyPt4duGmzQ-1 X-Mimecast-MFC-AGG-ID: R10AmYIiPsKhyPt4duGmzQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 05/15] qemuProcessHandleIOError: Prefer lookup by node name Date: Tue, 28 Jan 2025 17:28:09 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vkjyOo7C-LYOU4vivrKU9u48IHcuNFF_35KlJWILIDs_1738081709 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LWV5YMJOLVHHERQCKZTNDU2VC4B2Y2S6 X-Message-ID-Hash: LWV5YMJOLVHHERQCKZTNDU2VC4B2Y2S6 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: 1738081848370019000 Content-Type: text/plain; charset="utf-8" When qemu reports a node name for an I/O error we should prefer the lookup by node name instead as it gives us the path to the specific image which caused the error instead of the top level image path. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 80a73643f0..1849f68634 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -837,22 +837,26 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUS= ED, const char *eventPath =3D ""; const char *eventAlias =3D ""; const char *eventReason =3D ""; - virDomainDiskDef *disk; + virDomainDiskDef *disk =3D NULL; + virStorageSource *src =3D NULL; virObjectLock(vm); priv =3D QEMU_DOMAIN_PRIVATE(vm); - if (device) + if (nodename) + disk =3D qemuDomainDiskLookupByNodename(vm->def, priv->backup, nod= ename, &src); + + if (!disk) disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, device, NULL); - else if (nodename) - disk =3D qemuDomainDiskLookupByNodename(vm->def, NULL, nodename, N= ULL); - else - disk =3D NULL; - if (disk) { - eventPath =3D virDomainDiskGetSource(disk); + if (!src && disk) + src =3D disk->src; + + if (disk) eventAlias =3D disk->info.alias; - } + + if (src && src->path) + eventPath =3D src->path; if (nospace) eventReason =3D "enospc"; --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081877434635.3570250036119; Tue, 28 Jan 2025 08:31:17 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 805E01799; Tue, 28 Jan 2025 11:31:14 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EEF191816; Tue, 28 Jan 2025 11:28:50 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A758717C4; Tue, 28 Jan 2025 11:28:46 -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 A662B17C4 for ; Tue, 28 Jan 2025 11:28:32 -0500 (EST) Received: from mx-prod-mc-03.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-548-z9sFy1qnPWqXFmeLlOKdqQ-1; Tue, 28 Jan 2025 11:28:31 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B3B51956062 for ; Tue, 28 Jan 2025 16:28:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6384419560AA for ; Tue, 28 Jan 2025 16:28:29 +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=1738081712; 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=EGNsgowI+DX6mqGS3lJW8FhtsIJtuCZv2Apvelmgb7M=; b=AMo9crANONioRzXU0vvVRoEwZLes885XUXVZwriCUTs2RKM6pKv3RJjsIhiNbAWRfAtPOd iXJzwTce17/w38z/llb4Ti+xiRXLhtuRhzy/PRk+IsZQxxI23fJA5Dg9O7yl32QOF9e0xV 4f8dSbbcAjoiOPJgB0n7iF+k4OL95W8= X-MC-Unique: z9sFy1qnPWqXFmeLlOKdqQ-1 X-Mimecast-MFC-AGG-ID: z9sFy1qnPWqXFmeLlOKdqQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 06/15] qemuMonitorJSONHandleIOError: Propagate new 'qom-path' field Date: Tue, 28 Jan 2025 17:28:10 +0100 Message-ID: <3b4a8ed8d4372821833908d5379fc7d3e9d11e31.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ozq0L_scNgcAB3mRuOFEDuaOl_hKcDpMho3NRWF3Nt8_1738081710 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HROEAM7WHEQEZ7ZMNEKMXE33XD7FQBSA X-Message-ID-Hash: HROEAM7WHEQEZ7ZMNEKMXE33XD7FQBSA 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: 1738081878728019000 Content-Type: text/plain; charset="utf-8" QEMU commit v9.1.0-1065-ge67b7aef7c added 'qom-path' as an optional field for the BLOCK_IO_ERROR event. Extract and propagate it as an alternative to lookup via 'node-name' and 'device' (alias). Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_monitor.c | 3 ++- src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 4 +++- src/qemu/qemu_process.c | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index cae7dc6bf5..830ecbad1c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1128,6 +1128,7 @@ qemuMonitorEmitWatchdog(qemuMonitor *mon, int action) void qemuMonitorEmitIOError(qemuMonitor *mon, const char *device, + const char *qompath, const char *nodename, int action, bool nospace, @@ -1136,7 +1137,7 @@ qemuMonitorEmitIOError(qemuMonitor *mon, VIR_DEBUG("mon=3D%p", mon); QEMU_MONITOR_CALLBACK(mon, domainIOError, mon->vm, - device, nodename, action, nospace, reason); + device, qompath, nodename, action, nospace, reas= on); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c1aa36fe83..072f452e79 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -207,6 +207,7 @@ typedef void (*qemuMonitorDomainWatchdogCallback)(qemuM= onitor *mon, typedef void (*qemuMonitorDomainIOErrorCallback)(qemuMonitor *mon, virDomainObj *vm, const char *device, + const char *qompath, const char *nodename, int action, bool nospace, @@ -452,6 +453,7 @@ void qemuMonitorEmitRTCChange(qemuMonitor *mon, long lo= ng offset); void qemuMonitorEmitWatchdog(qemuMonitor *mon, int action); void qemuMonitorEmitIOError(qemuMonitor *mon, const char *device, + const char *qompath, const char *nodename, int action, bool nospace, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index db232cee78..890d9b7dfd 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -693,6 +693,7 @@ static void qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONValue *data) { const char *device; + const char *qompath; const char *nodename; const char *action; const char *reason; @@ -718,6 +719,7 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONV= alue *data) device =3D NULL; } + qompath =3D virJSONValueObjectGetString(data, "qom-path"); nodename =3D virJSONValueObjectGetString(data, "node-name"); reason =3D virJSONValueObjectGetString(data, "reason"); /* 'nospace' flag is relevant only when true */ @@ -728,7 +730,7 @@ qemuMonitorJSONHandleIOError(qemuMonitor *mon, virJSONV= alue *data) actionID =3D VIR_DOMAIN_EVENT_IO_ERROR_NONE; } - qemuMonitorEmitIOError(mon, device, nodename, actionID, nospace, reaso= n); + qemuMonitorEmitIOError(mon, device, qompath, nodename, actionID, nospa= ce, reason); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1849f68634..4497d089d0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -825,6 +825,7 @@ static void qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, virDomainObj *vm, const char *device, + const char *qompath, const char *nodename, int action, bool nospace, @@ -847,7 +848,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, disk =3D qemuDomainDiskLookupByNodename(vm->def, priv->backup, nod= ename, &src); if (!disk) - disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, device, NULL); + disk =3D qemuProcessFindDomainDiskByAliasOrQOM(vm, device, qompath= ); if (!src && disk) src =3D disk->src; --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081895670565.7890021417634; Tue, 28 Jan 2025 08:31:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 781B21810; Tue, 28 Jan 2025 11:31:34 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9B57F1713; Tue, 28 Jan 2025 11:28:53 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id AEF4617A5; Tue, 28 Jan 2025 11:28:47 -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 F141317EF for ; Tue, 28 Jan 2025 11:28:34 -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-556-gF1JzTGIPoeGtvZYyLkIng-1; Tue, 28 Jan 2025 11:28:32 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 72EB31955DDF for ; Tue, 28 Jan 2025 16:28:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A107619560AA for ; Tue, 28 Jan 2025 16:28:30 +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=1738081714; 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=htjsQhwyiBznDZijXrkUevoVj2qDu8XyyJYjaeD+oBY=; b=UPxsqZMRQrM6IGmDcugpUOBouoFRFQniC2AMVSta6SI2l/YZphWdBT15mWX+915hdFka1G LQ1Dp7gaCvyRi8DePdsRStvsP1kwN/jRUvpEQ/9ENExG8hAoZK3273fuBSFPSSoaYBMhKA GNn9q1LrDPbXl+vZEl0MoeJf0iGrCjw= X-MC-Unique: gF1JzTGIPoeGtvZYyLkIng-1 X-Mimecast-MFC-AGG-ID: gF1JzTGIPoeGtvZYyLkIng From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 07/15] virStorageSource: Add fields for storing last I/O error message Date: Tue, 28 Jan 2025 17:28:11 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: v7uDcvUe-58Vh7StZoK8hPyW-4vvHoeTIJKfOD2w4c0_1738081711 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BSTOE5EYBXHQ3CJIG3BTVC3ZL3AZAVKW X-Message-ID-Hash: BSTOE5EYBXHQ3CJIG3BTVC3ZL3AZAVKW 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: 1738081897352019000 Content-Type: text/plain; charset="utf-8" Hypervisors may report a I/O error message (unstable; for human use) to libvirt. In order to store it with the appropriate virStorageSource so that it can be later queried we need to add fields to virStorageSource to store the timestamp and message. The message is deliberately not copied via virStorageSourceCopy. The messages are also not serialized to the status XML as losing them on a daemon restart as they're likely to be stale anyways. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/storage_source_conf.c | 5 +++++ src/conf/storage_source_conf.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 2b658dd485..ca956a1b7c 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -917,6 +917,8 @@ virStorageSourceCopy(const virStorageSource *src, def->nfs_uid =3D src->nfs_uid; def->nfs_gid =3D src->nfs_gid; + /* 'ioerror_timestamp' and 'ioerror_message' are deliberately not copi= ed */ + return g_steal_pointer(&def); } @@ -1203,6 +1205,9 @@ virStorageSourceClear(virStorageSource *def) g_clear_pointer(&def->fdtuple, g_object_unref); + VIR_FREE(def->ioerror_timestamp); + VIR_FREE(def->ioerror_message); + /* clear everything except the class header as the object APIs * will break otherwise */ memset((char *) def + sizeof(def->parent), 0, diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 9463722518..e6cbb93c06 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -445,6 +445,12 @@ struct _virStorageSource { * to do this decision. */ bool seclabelSkipRemember; + + /* Last instance of hypervisor originated I/O error message and timest= amp. + * The error stored here is not designed to be stable. The message + * is also not copied via virStorageSourceCopy */ + char *ioerror_timestamp; + char *ioerror_message; }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref); --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081917503474.7940099697672; Tue, 28 Jan 2025 08:31:57 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A6881BA3; Tue, 28 Jan 2025 11:31:53 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9DCAD14B9; Tue, 28 Jan 2025 11:28:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C54C31811; Tue, 28 Jan 2025 11:28:48 -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 7141F1B43 for ; Tue, 28 Jan 2025 11:28:36 -0500 (EST) Received: from mx-prod-mc-03.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-564-4o77ugVhNGGn_sqOtL1LPg-1; Tue, 28 Jan 2025 11:28:33 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B8D6619560B9 for ; Tue, 28 Jan 2025 16:28:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E7D1A19560AA for ; Tue, 28 Jan 2025 16:28:31 +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=1738081716; 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=SLPP7sH5WMuC97OqDk+df1ENkLHdlNbbbJc3yXS1VWU=; b=XuZwgQrZqqzs9UAIRrEcy7TAEPJJ35gi7oAVSyJicD8BCqIrOEdAsiROy/M5sYYAGM3pLP W7kbGdWyALZl9AR+XVnDg5i7x+IIeePKjZONGMIcZed2REYkj/SsroY5NO5bXsdpOH8hIv V4w1csBP3TF8Z0s9lZDSZRjePtHNS1E= X-MC-Unique: 4o77ugVhNGGn_sqOtL1LPg-1 X-Mimecast-MFC-AGG-ID: 4o77ugVhNGGn_sqOtL1LPg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 08/15] qemuProcessHandleIOError: Populate I/O error reason to virStorageSource Date: Tue, 28 Jan 2025 17:28:12 +0100 Message-ID: <7c70b034787d371444e6c5455bb9a0122261b2ac.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -PETgtcnK44cHwmrPeAKMZgU74g-B1IAGRwq-dbv14I_1738081712 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5SDMA4YOH6GZIUFG2KIWOAK6TELBPEAO X-Message-ID-Hash: 5SDMA4YOH6GZIUFG2KIWOAK6TELBPEAO 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: 1738081923140019000 Content-Type: text/plain; charset="utf-8" Record the last I/O error reason and timestamp which happened with the corresponding virStorageSource struct. This will later allow querying the last error e.g. via the virDomainGetMessages() API. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4497d089d0..d73c52542b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -840,6 +840,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, const char *eventReason =3D ""; virDomainDiskDef *disk =3D NULL; virStorageSource *src =3D NULL; + g_autofree char *timestamp =3D NULL; virObjectLock(vm); priv =3D QEMU_DOMAIN_PRIVATE(vm); @@ -865,6 +866,15 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSE= D, ioErrorEvent =3D virDomainEventIOErrorNewFromObj(vm, eventPath, eventA= lias, action); ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, eventPath,= eventAlias, action, eventReason); + if ((timestamp =3D virTimeStringNow()) !=3D NULL) { + if (src) { + g_free(src->ioerror_timestamp); + g_free(src->ioerror_message); + src->ioerror_timestamp =3D g_steal_pointer(×tamp); + src->ioerror_message =3D g_strdup(reason); + } + } + if (action =3D=3D VIR_DOMAIN_EVENT_IO_ERROR_PAUSE && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { VIR_WARN("Transitioned guest %s to paused state due to IO error", = vm->def->name); --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 173808193237026.613042196882702; Tue, 28 Jan 2025 08:32:12 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 96B761BB8; Tue, 28 Jan 2025 11:32:11 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 843B11B59; Tue, 28 Jan 2025 11:28:58 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4F7F717B3; Tue, 28 Jan 2025 11:28:49 -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 7DB76179D for ; Tue, 28 Jan 2025 11:28:36 -0500 (EST) Received: from mx-prod-mc-01.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-596-MjNZ9NWzPCm-83cpVqj7TQ-1; Tue, 28 Jan 2025 11:28:34 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0BBA719560B2 for ; Tue, 28 Jan 2025 16:28:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3997F19560AA for ; Tue, 28 Jan 2025 16:28:32 +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=1738081716; 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=mckh0vAdW3dpBz34AJbN1Ah0Z0MHV5UOHD1MAzynb9U=; b=NhzZYgPMCr68NE/yQ/dvPpEvIjF26QbAsCd5dHdS/ECvEMlDd/xtWoTPzUr6a2l4Ur59i8 tLSeKl27J4rX3J153bLxaKUFrzAerZvfuEwovJjgHBanMzXB440noMOJ9k+jIVU/Tc/b7h GuZi+4JodI/Jn86+hd9CcvSWaJezWFw= X-MC-Unique: MjNZ9NWzPCm-83cpVqj7TQ-1 X-Mimecast-MFC-AGG-ID: MjNZ9NWzPCm-83cpVqj7TQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 09/15] qemuProcessHandleIOError: Log IO errors in the VM log file Date: Tue, 28 Jan 2025 17:28:13 +0100 Message-ID: <08aec9030cff058772a156763aafd06ef30ce37d.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gLPiShF0UUMx8kwhpKCOKuuxF2SMZXpSboAOz6fSuw0_1738081714 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: AJM4B2KRFVCAZS2JNXYSVEUR67LYF3PC X-Message-ID-Hash: AJM4B2KRFVCAZS2JNXYSVEUR67LYF3PC 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: 1738081933301019000 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d73c52542b..e9342287ab 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -829,7 +829,7 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, const char *nodename, int action, bool nospace, - const char *reason G_GNUC_UNUSED) + const char *reason) { qemuDomainObjPrivate *priv; virObjectEvent *ioErrorEvent =3D NULL; @@ -867,6 +867,9 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, eventPath,= eventAlias, action, eventReason); 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(eventAlias), NULLSTR= (nodename), NULLSTR(reason)); + if (src) { g_free(src->ioerror_timestamp); g_free(src->ioerror_message); --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081953399150.6586421136526; Tue, 28 Jan 2025 08:32:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 33BC01BA0; Tue, 28 Jan 2025 11:32:33 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D19DA1B2F; Tue, 28 Jan 2025 11:29:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C952A17A4; Tue, 28 Jan 2025 11:28:49 -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 E26C217A7 for ; Tue, 28 Jan 2025 11:28:37 -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-567-SH37bAoyMsOAkl7GyD92Kg-1; Tue, 28 Jan 2025 11:28:36 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 5843A1801883 for ; Tue, 28 Jan 2025 16:28:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 80F8319560AA for ; Tue, 28 Jan 2025 16:28:34 +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=1738081717; 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=eX0AScE23tVIhYnnfQUsYeLa9OyUa4z1rPqJkwRKDU4=; b=IJdLNcc6yozSQiGdi4mTM6A9PvXBVup9nI1+RR21mw+qCiGCDLAnDQwVBCMcwxQadjceff 3ca7NVPcuFMhx6+nfuA0tV9p5269LPicHwYJwPgzXEGe6ES3U8MkgLpjlL6wsulEp+7Jwb wI8EDnXLmIrfpu9KbmN9S9zlIa4dGrA= X-MC-Unique: SH37bAoyMsOAkl7GyD92Kg-1 X-Mimecast-MFC-AGG-ID: SH37bAoyMsOAkl7GyD92Kg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 10/15] libxlDomainGetMessages: Add existing flags to 'virCheckFlags' Date: Tue, 28 Jan 2025 17:28:14 +0100 Message-ID: <3f03a9d45f3b4e210009ffda21eed12ccb438080.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oFPmlmqy0l33qBbMO0QaB6h7ayoKiobWvPIkBHszn-M_1738081715 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QNCCNWH6MAIXVDUQXXQG2V27C2GGSMUX X-Message-ID-Hash: QNCCNWH6MAIXVDUQXXQG2V27C2GGSMUX 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: 1738081955590019000 Content-Type: text/plain; charset="utf-8" The two VIR_DOMAIN_MESSAGE_* flags were not listed in the virCheckFlags check in 'libxl' but were present in 'test' and 'qemu' driver impls. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 494b1ad9bc..058fee0706 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6578,7 +6578,8 @@ libxlDomainGetMessages(virDomainPtr dom, virDomainObj *vm =3D NULL; int ret =3D -1; - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION | + VIR_DOMAIN_MESSAGE_TAINTING, -1); if (!(vm =3D libxlDomObjFromDomain(dom))) return -1; --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738082080540496.03426147210905; Tue, 28 Jan 2025 08:34:40 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E830A16C3; Tue, 28 Jan 2025 11:32:54 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EEABE1BAA; Tue, 28 Jan 2025 11:29:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1F1301B9A; Tue, 28 Jan 2025 11:28:59 -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 151BE180D for ; Tue, 28 Jan 2025 11:28:39 -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-612-BF2kUv6-Pyi1Sz1Ay2sDXg-1; Tue, 28 Jan 2025 11:28:37 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 A80491801888 for ; Tue, 28 Jan 2025 16:28:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DCDA919560AA for ; Tue, 28 Jan 2025 16:28:35 +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=1738081718; 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=81gjZTFW7drY9m5wTEZyZXrUe8YimZo8IRMMNoM/+Xc=; b=KOPrrFErRGj2BPTubD3mFhJ5+5NyAZSneC9UfS0EHAfQokt2bBjt4JVHXcmt4dCyOjNz65 teTk66rPDvZb/VJHhG/r1IDneqc0AIJfgyLojZ2BRxlhioDNiTSellBG3wMQVAIOJOcN9t sibBaRPq99xogrFCNkuM3MvkvWTMB/U= X-MC-Unique: BF2kUv6-Pyi1Sz1Ay2sDXg-1 X-Mimecast-MFC-AGG-ID: BF2kUv6-Pyi1Sz1Ay2sDXg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 11/15] virDomainObjGetMessages: Refactor using GPtrArray Date: Tue, 28 Jan 2025 17:28:15 +0100 Message-ID: <778590ccf6ace38f70c2f7eebabca2a23f189bd1.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: TcoFAAzqoI8tUjpcMxGOH_2pVqF6P8L4o1Z_4Zrk0tc_1738081716 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EYAVNJUKUUFPQWV4SUT2L34GZPL3FJRL X-Message-ID-Hash: EYAVNJUKUUFPQWV4SUT2L34GZPL3FJRL 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: 1738082082450019000 Content-Type: text/plain; charset="utf-8" Simplify the function especially by rewriting it using GPtrArray to construct the string list, especially for the upcoming case when the number of added elements will not be known beforehand and when hypervisor specific data will be added. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 36 +++++++----------------------------- src/conf/domain_conf.h | 4 ++-- src/libxl/libxl_driver.c | 9 ++++++++- src/qemu/qemu_driver.c | 9 ++++++++- src/test/test_driver.c | 9 ++++++++- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 45c2cd09f1..00d486e774 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31685,53 +31685,31 @@ virHostdevIsPCIDevice(const virDomainHostdevDef *= hostdev) /** * virDomainObjGetMessages: * @vm: domain object - * @msgs: pointer to a variable to store messages + * @m: GPtrArray to be filled with messages * @flags: zero or more virDomainMessageType flags - * - * Returns number of messages stored in @msgs, -1 otherwise. */ -int +void virDomainObjGetMessages(virDomainObj *vm, - char ***msgs, + GPtrArray *m, unsigned int flags) { size_t i =3D 0; - size_t n =3D 0; - int nmsgs =3D 0; - int rv =3D -1; - - *msgs =3D NULL; if (!flags || (flags & VIR_DOMAIN_MESSAGE_TAINTING)) { - nmsgs +=3D __builtin_popcount(vm->taint); - *msgs =3D g_renew(char *, *msgs, nmsgs+1); - for (i =3D 0; i < VIR_DOMAIN_TAINT_LAST; i++) { if (vm->taint & (1 << i)) { - (*msgs)[n++] =3D g_strdup_printf( - _("tainted: %1$s"), - _(virDomainTaintMessageTypeToString(i))); + g_ptr_array_add(m, g_strdup_printf(_("tainted: %1$s"), + _(virDomainTaintMessage= TypeToString(i)))); } } } if (!flags || (flags & VIR_DOMAIN_MESSAGE_DEPRECATION)) { - nmsgs +=3D vm->ndeprecations; - *msgs =3D g_renew(char *, *msgs, nmsgs+1); - for (i =3D 0; i < vm->ndeprecations; i++) { - (*msgs)[n++] =3D g_strdup_printf( - _("deprecated configuration: %1$s"), - vm->deprecations[i]); + g_ptr_array_add(m, g_strdup_printf(_("deprecated configuration= : %1$s"), + vm->deprecations[i])); } } - - if (*msgs) - (*msgs)[nmsgs] =3D NULL; - - rv =3D nmsgs; - - return rv; } bool diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ba1a495764..e996d3c0de 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4588,9 +4588,9 @@ bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); -int +void virDomainObjGetMessages(virDomainObj *vm, - char ***msgs, + GPtrArray *m, unsigned int flags); bool diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 058fee0706..426c2b4278 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6575,6 +6575,7 @@ libxlDomainGetMessages(virDomainPtr dom, char ***msgs, unsigned int flags) { + g_autoptr(GPtrArray) m =3D g_ptr_array_new_with_free_func(g_free); virDomainObj *vm =3D NULL; int ret =3D -1; @@ -6587,7 +6588,13 @@ libxlDomainGetMessages(virDomainPtr dom, if (virDomainGetMessagesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - ret =3D virDomainObjGetMessages(vm, msgs, flags); + virDomainObjGetMessages(vm, m, flags); + + ret =3D m->len; + if (m->len > 0) { + g_ptr_array_add(m, NULL); + *msgs =3D (char **) g_ptr_array_steal(m, NULL); + } cleanup: virDomainObjEndAPI(&vm); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a1fc61bae2..8327e7079c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19818,6 +19818,7 @@ qemuDomainGetMessages(virDomainPtr dom, char ***msgs, unsigned int flags) { + g_autoptr(GPtrArray) m =3D g_ptr_array_new_with_free_func(g_free); virDomainObj *vm =3D NULL; int rv =3D -1; @@ -19830,7 +19831,13 @@ qemuDomainGetMessages(virDomainPtr dom, if (virDomainGetMessagesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - rv =3D virDomainObjGetMessages(vm, msgs, flags); + virDomainObjGetMessages(vm, m, flags); + + rv =3D m->len; + if (m->len > 0) { + g_ptr_array_add(m, NULL); + *msgs =3D (char **) g_ptr_array_steal(m, NULL); + } cleanup: virDomainObjEndAPI(&vm); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index f1cefb5c50..a10ec3bc41 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9522,6 +9522,7 @@ testDomainGetMessages(virDomainPtr dom, char ***msgs, unsigned int flags) { + g_autoptr(GPtrArray) m =3D g_ptr_array_new_with_free_func(g_free); virDomainObj *vm =3D NULL; int rv =3D -1; @@ -9531,7 +9532,13 @@ testDomainGetMessages(virDomainPtr dom, if (!(vm =3D testDomObjFromDomain(dom))) return -1; - rv =3D virDomainObjGetMessages(vm, msgs, flags); + virDomainObjGetMessages(vm, m, flags); + + rv =3D m->len; + if (m->len > 0) { + g_ptr_array_add(m, NULL); + *msgs =3D (char **) g_ptr_array_steal(m, NULL); + } virDomainObjEndAPI(&vm); return rv; --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 17380820173331011.2998484335319; Tue, 28 Jan 2025 08:33:37 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 45A101C34; Tue, 28 Jan 2025 11:33:35 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5C5BA1B57; Tue, 28 Jan 2025 11:29:09 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 341901B27; Tue, 28 Jan 2025 11:29:00 -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 8CADF1843 for ; Tue, 28 Jan 2025 11:28:40 -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-678-HAuGiKTNOTWenY-zwqB4mw-1; Tue, 28 Jan 2025 11:28:38 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 EE7B71800266 for ; Tue, 28 Jan 2025 16:28:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2EB2B19560AA for ; Tue, 28 Jan 2025 16:28:36 +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=1738081720; 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=zZRZ579wmvTNCfLkhx3qpFvSV2AssVfhL4sa7mwCuxg=; b=ChtiqmIAbBnvBawT2s4jc9O4EbcSJenQgyvZ8kYtUDdjF6Srl/gUi23maIfAzYLzQ/jTqw 9ko6GomP1uQSfIDIx5mMerK2KWnDp6GcivE3qrskafM+6HojhC4A2GpKm3CyB3Q6zrhAFp 1tJq06+6pkASOfppwmwHoIYZaN6pVxk= X-MC-Unique: HAuGiKTNOTWenY-zwqB4mw-1 X-Mimecast-MFC-AGG-ID: HAuGiKTNOTWenY-zwqB4mw From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 12/15] virDomainGetMessages: Introduce VIR_DOMAIN_MESSAGE_IOERRORS Date: Tue, 28 Jan 2025 17:28:16 +0100 Message-ID: <84415f9a2c87c6c7c4deba30623075b81c7d48cd.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3y4gLb2M2bqKdiApNF4Y8NFj-dfBVjyNefnV8Dci7Gs_1738081718 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: K7HG5OWD2HFYTEDVS6E6UKINH6RZ5IJU X-Message-ID-Hash: K7HG5OWD2HFYTEDVS6E6UKINH6RZ5IJU 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: 1738082023913019000 Content-Type: text/plain; charset="utf-8" Report any stored I/O error messages reported by the hypervisor when reporting messages of a domain. As the I/O error may be already stale we report also the timestamp when it was recorded. Example message: I/O error: disk=3D'vda', index=3D'1', path=3D'/dev/mapper/errdev0', timest= amp=3D'2025-01-28 15:47:52.776+0000', message'Input/output error' Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 3 ++ src/conf/domain_conf.c | 50 ++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 5 ++++ src/libvirt_private.syms | 1 + src/libxl/libxl_driver.c | 3 +- src/qemu/qemu_driver.c | 15 +++++++++- src/test/test_driver.c | 3 +- 7 files changed, 77 insertions(+), 3 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 74016c6c46..9e9016cfe7 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6520,6 +6520,9 @@ int virDomainAuthorizedSSHKeysSet(virDomainPtr domain, typedef enum { VIR_DOMAIN_MESSAGE_DEPRECATION =3D (1 << 0), /* (Since: 7.1.0) */ VIR_DOMAIN_MESSAGE_TAINTING =3D (1 << 1), /* (Since: 7.1.0) */ + VIR_DOMAIN_MESSAGE_IOERRORS =3D (1 << 2), /* Report available stored I= /O + errors messages for disk im= ages + (Since: 11.1.0) */ } virDomainMessageType; int virDomainGetMessages(virDomainPtr domain, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 00d486e774..548bc82308 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31682,6 +31682,47 @@ virHostdevIsPCIDevice(const virDomainHostdevDef *h= ostdev) } +static void +virDomainObjGetMessagesIOErrorsSrc(virStorageSource *src, + const char *diskdst, + GPtrArray *m) +{ + if (!src || + !src->ioerror_message) + return; + + g_ptr_array_add(m, g_strdup_printf(_("I/O error: disk=3D'%1$s', index= =3D'%2$d', path=3D'%3$s', timestamp=3D'%4$s', message'%5$s'"), + NULLSTR_MINUS(diskdst), + src->id, + NULLSTR_MINUS(src->path), + src->ioerror_timestamp, + src->ioerror_message)); +} + + +void +virDomainObjGetMessagesIOErrorsChain(virStorageSource *src, + const char *diskdst, + GPtrArray *m) +{ + virStorageSource *n; + + for (n =3D src; n; n =3D n->backingStore) { + virDomainObjGetMessagesIOErrorsSrc(n, diskdst, m); + virDomainObjGetMessagesIOErrorsSrc(n->dataFileStore, diskdst, m); + } +} + + +static void +virDomainObjGetMessagesIOErrorsDisk(virDomainDiskDef *disk, + GPtrArray *m) +{ + virDomainObjGetMessagesIOErrorsChain(disk->src, disk->dst, m); + virDomainObjGetMessagesIOErrorsChain(disk->mirror, disk->dst, m); +} + + /** * virDomainObjGetMessages: * @vm: domain object @@ -31710,6 +31751,15 @@ virDomainObjGetMessages(virDomainObj *vm, vm->deprecations[i])); } } + + if (!flags || (flags & VIR_DOMAIN_MESSAGE_IOERRORS)) { + if (vm->def->os.loader) + virDomainObjGetMessagesIOErrorsChain(vm->def->os.loader->nvram= , NULL, m); + + for (i =3D 0; i < vm->def->ndisks; i++) + virDomainObjGetMessagesIOErrorsDisk(vm->def->disks[i], m); + } + } bool diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e996d3c0de..e51c74b6d1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4588,6 +4588,11 @@ bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); +void +virDomainObjGetMessagesIOErrorsChain(virStorageSource *src, + const char *diskdst, + GPtrArray *m); + void virDomainObjGetMessages(virDomainObj *vm, GPtrArray *m, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2fe0a07944..406e6583a3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -592,6 +592,7 @@ virDomainObjEndAPI; virDomainObjFormat; virDomainObjGetDefs; virDomainObjGetMessages; +virDomainObjGetMessagesIOErrorsChain; virDomainObjGetMetadata; virDomainObjGetOneDef; virDomainObjGetOneDefState; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 426c2b4278..a76545c9ff 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6580,7 +6580,8 @@ libxlDomainGetMessages(virDomainPtr dom, int ret =3D -1; virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION | - VIR_DOMAIN_MESSAGE_TAINTING, -1); + VIR_DOMAIN_MESSAGE_TAINTING | + VIR_DOMAIN_MESSAGE_IOERRORS, -1); if (!(vm =3D libxlDomObjFromDomain(dom))) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8327e7079c..50733a5b3a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19821,9 +19821,11 @@ qemuDomainGetMessages(virDomainPtr dom, g_autoptr(GPtrArray) m =3D g_ptr_array_new_with_free_func(g_free); virDomainObj *vm =3D NULL; int rv =3D -1; + qemuDomainObjPrivate *priv; virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION | - VIR_DOMAIN_MESSAGE_TAINTING, -1); + VIR_DOMAIN_MESSAGE_TAINTING | + VIR_DOMAIN_MESSAGE_IOERRORS, -1); if (!(vm =3D qemuDomainObjFromDomain(dom))) return -1; @@ -19831,8 +19833,19 @@ qemuDomainGetMessages(virDomainPtr dom, if (virDomainGetMessagesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; + priv =3D vm->privateData; + virDomainObjGetMessages(vm, m, flags); + if (priv->backup) { + size_t i; + + for (i =3D 0; i < priv->backup->ndisks; i++) + virDomainObjGetMessagesIOErrorsChain(priv->backup->disks[i].st= ore, + priv->backup->disks[i].na= me, + m); + } + rv =3D m->len; if (m->len > 0) { g_ptr_array_add(m, NULL); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index a10ec3bc41..6f18b2b2c8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9527,7 +9527,8 @@ testDomainGetMessages(virDomainPtr dom, int rv =3D -1; virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION | - VIR_DOMAIN_MESSAGE_TAINTING, -1); + VIR_DOMAIN_MESSAGE_TAINTING | + VIR_DOMAIN_MESSAGE_IOERRORS, -1); if (!(vm =3D testDomObjFromDomain(dom))) return -1; --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738081993658807.9274785784279; Tue, 28 Jan 2025 08:33:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B75F51BA0; Tue, 28 Jan 2025 11:33:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C38151B97; Tue, 28 Jan 2025 11:29:06 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C813A188F; Tue, 28 Jan 2025 11:28:59 -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 820591B6F for ; Tue, 28 Jan 2025 11:28:41 -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-665-wdDkdIMRM0e15WMv_0Kuvw-1; Tue, 28 Jan 2025 11:28:40 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 3EF161800361 for ; Tue, 28 Jan 2025 16:28:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6F1EB19560AA for ; Tue, 28 Jan 2025 16:28:38 +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=1738081721; 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=MKPWbj3yFWc1n+ploj8PUmYXbbnXXU94ghEzToSHO3o=; b=he0+WFZkiMkQXatjZQl6j27igGeuoypF5RhJZpNFxH9aUDeWMDETrsuFnfoSzcR+KaMVLb Gsfj+9aY8isF0YrCaKzN9olFCHpY636mykjaI0ZoRk2Zg1hJ3KvDnJgQ9UXovkUjS8gPlW O1r5YEVgEur7/hVK5vpjn639neaEodY= X-MC-Unique: wdDkdIMRM0e15WMv_0Kuvw-1 X-Mimecast-MFC-AGG-ID: wdDkdIMRM0e15WMv_0Kuvw From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 13/15] include: libvirt-domain: Reword documentation for @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON Date: Tue, 28 Jan 2025 17:28:17 +0100 Message-ID: <2c602f7416cbf09879aabf17cecdfc6c29f6d645.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2AY78P4gUkgelqxm87hYP2wS9Wyjpb809cL0XuUWu24_1738081719 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KPB2R7VQQ3E7QBELKSUWRMP6QMKBYJ4F X-Message-ID-Hash: KPB2R7VQQ3E7QBELKSUWRMP6QMKBYJ4F 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: 1738081995934019000 Content-Type: text/plain; charset="utf-8" Emphasise that it's an enumeration and convert the possibilities to a list of values with explanation. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 9e9016cfe7..941e67aab1 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4805,11 +4805,13 @@ typedef void (*virConnectDomainEventIOErrorCallback= )(virConnectPtr conn, * The callback signature to use when registering for an event of type * VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON with virConnectDomainEventRegisterA= ny() * - * 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. + * Although @reason is a string, it is considered to be an enumeration of = the + * following values: + * + * - "" (empty string): unknown I/O error reason + * - "enospc": The I/O error is known to be caused by an ENOSPC condition = in + * the host. Resizing the disk source to be larger will allow = the + * guest to be resumed as if nothing happened. * * Since: 0.8.1 */ --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738082035396398.030483120064; Tue, 28 Jan 2025 08:33:55 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9D8991C31; Tue, 28 Jan 2025 11:33:54 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 519EA188F; Tue, 28 Jan 2025 11:29:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 471911802; Tue, 28 Jan 2025 11:29:00 -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 267201AF4 for ; Tue, 28 Jan 2025 11:28:43 -0500 (EST) Received: from mx-prod-mc-01.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-122-HNTkS2QWNES4bCymtEYLBg-1; Tue, 28 Jan 2025 11:28:41 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 85FFA19560B8 for ; Tue, 28 Jan 2025 16:28:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B3B1019560AA for ; Tue, 28 Jan 2025 16:28:39 +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=1738081722; 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=hpalaE2JRH9irMKv3OE9Cm5oY9UKPV9I4rm2VXWLq18=; b=S2Gof3ToxsDAtZRvR4X4zWDdevRF7x29CL7l2CoOvJ1C08dxBXHfRUdRwxpQEvcHsJOK6k mmwMEk7e2F4I/Apx3Sqt9MwCM/lmJVr2QopK+25B2GJ1O4b8QYoYhKKgC8H43GlWVo81RZ 4Ilg9krXUD1iQ/I5OJcFrGCqBCBwNu4= X-MC-Unique: HNTkS2QWNES4bCymtEYLBg-1 X-Mimecast-MFC-AGG-ID: HNTkS2QWNES4bCymtEYLBg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 14/15] include: libvirt-domain: Add 'hypervisor-message' @reason of VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON Date: Tue, 28 Jan 2025 17:28:18 +0100 Message-ID: <0206940a21d7dc7d8a6209c504fff6beed012ada.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WH5lsvT8V3tye574C0u_MIrvcMeTmaG7NDT-XrCIAus_1738081720 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XRDUXMFAA2POHXBRNCZJUPVK7W5QQOBK X-Message-ID-Hash: XRDUXMFAA2POHXBRNCZJUPVK7W5QQOBK 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: 1738082036481019000 Content-Type: text/plain; charset="utf-8" In case when the hypervisor does report the reason for the I/O error as an unstable string to display to users we can add a @reason possibility for the I/O error event noting that the error is available. Add 'hypervisor-message' as a reason enumeration value and document it to instruct users to look at the logs or virDomainGetMessages(). The resulting event looks like: event 'io-error' for domain 'cd': /dev/mapper/errdev0 (virtio-disk0) repor= t due to hypervisor-message Users then can look at the virDomainGetMessages() API: I/O error: disk=3D'vda', index=3D'1', path=3D'/dev/mapper/errdev0', timest= amp=3D'2025-01-28 15:47:52.776+0000', message'Input/output error' Or at the VM log file: 2025-01-28 15:47:52.776+0000: IO error device=3D'virtio-disk0' node-name= =3D'libvirt-1-storage' reason=3D'Input/output error' Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 4 ++++ src/qemu/qemu_process.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 941e67aab1..2615d7b76a 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4812,6 +4812,10 @@ typedef void (*virConnectDomainEventIOErrorCallback)= (virConnectPtr conn, * - "enospc": The I/O error is known to be caused by an ENOSPC condition = in * the host. Resizing the disk source to be larger will allow = the * guest to be resumed as if nothing happened. + * - "hypervisor-message": The hypervisor reported a string description of= the + * I/O error. The errors are usually logged into t= he + * domain log file or the last instance of the err= or + * string can be queried via virDomainGetMessages(= ). * * Since: 0.8.1 */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e9342287ab..cf6e0517ef 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -862,6 +862,8 @@ qemuProcessHandleIOError(qemuMonitor *mon G_GNUC_UNUSED, if (nospace) eventReason =3D "enospc"; + else if (reason) + eventReason =3D "hypervisor-message"; ioErrorEvent =3D virDomainEventIOErrorNewFromObj(vm, eventPath, eventA= lias, action); ioErrorEvent2 =3D virDomainEventIOErrorReasonNewFromObj(vm, eventPath,= eventAlias, action, eventReason); --=20 2.48.1 From nobody Mon Sep 8 21:40:31 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 1738082061564314.97426013582583; Tue, 28 Jan 2025 08:34:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9E25A1788; Tue, 28 Jan 2025 11:34:19 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0C3D61A3C; Tue, 28 Jan 2025 11:29:15 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id CE4B7187E; Tue, 28 Jan 2025 11:29:00 -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 51DC11B2F for ; Tue, 28 Jan 2025 11:28:44 -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-601-eRMAjxZuP9qMvuMGy63jQQ-1; Tue, 28 Jan 2025 11:28:42 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 D3BF818009B8 for ; Tue, 28 Jan 2025 16:28:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07A7F19560AA for ; Tue, 28 Jan 2025 16:28:40 +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=1738081724; 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=naw0FdL3SVqLKZOY1t452/JxELpYZ0EyNU3eOLeWJhU=; b=TQ4Zp889u6uU3a0ZdiEahsL8SHNiho6UYbWZzPgFZbRuDP50N1/hEwt9EIOMiwrIuoCCcR Rhwcbhu+oZTFHksEw6gxxA/qyWcEXvvBNHpWuG2exOpMpTWKtQ9BVxtrqjcTpcYjXlFsMV phDLRrJeFe2aTglNta/Ub09aT2dhchg= X-MC-Unique: eRMAjxZuP9qMvuMGy63jQQ-1 X-Mimecast-MFC-AGG-ID: eRMAjxZuP9qMvuMGy63jQQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v2 15/15] NEWS: Mention preserving I/O error messages for qemu VMs Date: Tue, 28 Jan 2025 17:28:19 +0100 Message-ID: <1329122364605950836c4a35018cf2346f2ca33c.1738081457.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WvRTkXfHik-L2GWbBXBjUHWZsHbq6r6QyOtU4jhc7CM_1738081721 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: N3THBDONF4C6YTN72EDTKXYA7TTSPQXN X-Message-ID-Hash: N3THBDONF4C6YTN72EDTKXYA7TTSPQXN 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: 1738082072855019000 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 5eae2706b7..452754a190 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -35,6 +35,12 @@ v11.1.0 (unreleased) * **Improvements** + * qemu: I/O error messages can be queried via ``virDomainGetMessages()`` + + The qemu hypervisor driver now preserves the last I/O error message al= ong + with the timestamp when it was recorded and preserves it to be queried= via + ``virDomainGetMessages()``. + * **Bug fixes** --=20 2.48.1