From nobody Mon Feb 9 12:11:35 2026 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770303901; cv=none; d=zohomail.com; s=zohoarc; b=dv+N1Q+6tO7lWWaF8Dq1NfE+k0YFhGGj0LZvuvUp27mkbN19E7sYds6uick2go0SmYShRJaasRmsIa6J3mNjFycvWg/CywO9jyE+lNuxFynk1oEpQgmx+1IwAumgRrskuKmrzWtMN97L5MRBbYrHH7bLoDHmlDJFXSMEtToiics= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770303901; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=bLBcGiPBOXumTdPflmcxaDGsBSpC1h1K66eMcPOsNnI=; b=LBsupKD5xwK+ZnWf02pDDX9COVfseenhk+GNyv7Gq69Juof7wckRGcP75WbEiF98X7XMcFOLyd0D2yPgyg2pEOVMpEAHTNQ0CMfz2yvkU4JOB+BSzHVBkXUqTxNs+JkrsEQGlQbAkE5gCbQ0tUaPGSPBL6RyveElhxuntI8H0to= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770303900993428.0791352927188; Thu, 5 Feb 2026 07:05:00 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 79F6741C69; Thu, 5 Feb 2026 10:05:00 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0126C43FBC; Thu, 5 Feb 2026 09:58:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 457D641C69; Thu, 5 Feb 2026 09:57:54 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6FA5041C69 for ; Thu, 5 Feb 2026 09:55:43 -0500 (EST) Received: from mx-prod-mc-05.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-677-Q6xyilAxMQO3HEToxv0QIA-1; Thu, 05 Feb 2026 09:55:41 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 062F91956094 for ; Thu, 5 Feb 2026 14:55:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.3]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5053818003F6 for ; Thu, 5 Feb 2026 14:55:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770303343; 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=bLBcGiPBOXumTdPflmcxaDGsBSpC1h1K66eMcPOsNnI=; b=fqUe1HaBJ4zjRGNujqyuIpr8diR+97kTkRffjuj31R8Xvp85jT6Qi5y6lhcRzBP4jr9/Ys zcR9SuC3ZNppKlemnh6R/zoIS/7MfFLsO/cgDTWopQipSBhtzf3JBiP5JQganmNIPjupqV c/qm6Dei41KQFOGlsmJy1m5ojfmewnU= X-MC-Unique: Q6xyilAxMQO3HEToxv0QIA-1 X-Mimecast-MFC-AGG-ID: Q6xyilAxMQO3HEToxv0QIA_1770303341 To: devel@lists.libvirt.org Subject: [PATCH 09/20] qemu: monitor: Add test validating that 'eventHandlers' are properly sorted Date: Thu, 5 Feb 2026 15:55:17 +0100 Message-ID: <7b223670d624ee2880dc38e319bb6201a66f4601.1770303113.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: D33KsEnH6QzGs4FNdzVmco9co5rEOS2SaWypp3H2uhc_1770303341 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QDAC5DRRHQFM2TTGHPRVN2Q4EQBGFUTW X-Message-ID-Hash: QDAC5DRRHQFM2TTGHPRVN2Q4EQBGFUTW X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770303903551154100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The monitor code uses 'bsearch' to look up the event handler so the event names must be properly listed. Until now only an comment reminded us to do it. Add a test to verify that it is actually sorted properly. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 3 +++ tests/qemumonitorjsontest.c | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 021995f5cc..825508e8f5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -143,6 +143,27 @@ qemuMonitorEventCompare(const void *key, const void *e= lt) } +/** + * qemuMonitorJSONValidateEventHandlers: + * + * Used by 'qemumonitorjsontest' to validate that the 'eventHandlers' array + * is properly sorted to use 'bsearch'. + */ +char * +qemuMonitorJSONValidateEventHandlers(void) +{ + size_t i; + + for (i =3D 1; i < G_N_ELEMENTS(eventHandlers); i++) { + if (strcmp(eventHandlers[i-1].type, eventHandlers[i].type) > -1) + return g_strdup_printf("mis-ordered 'eventHandlers': '%s', '%s= '", + eventHandlers[i-1].type, eventHandlers[= i].type); + } + + return NULL; +} + + static int qemuMonitorJSONIOProcessEvent(qemuMonitor *mon, virJSONValue *obj) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index db9160eb68..8f5434d0df 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -27,6 +27,9 @@ #include "cpu/cpu.h" #include "util/virgic.h" +char * +qemuMonitorJSONValidateEventHandlers(void); + int qemuMonitorJSONIOProcessLine(qemuMonitor *mon, const char *line, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index b3aca6a6c3..9c9b3397ad 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2825,6 +2825,20 @@ testQemuMonitorJSONGetGuestCPU(const void *opaque) } +static int +testEventHandlersOrdering(const void *opaque G_GNUC_UNUSED) +{ + g_autofree char *errmsg =3D NULL; + + if ((errmsg =3D qemuMonitorJSONValidateEventHandlers())) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", errmsg); + return -1; + } + + return 0; +} + + static int mymain(void) { @@ -2848,6 +2862,10 @@ mymain(void) qapiData.schema =3D qapischema_x86_64; + if (virTestRun("'eventHandlers' ordering check", testEventHandlersOrde= ring, + NULL) < 0) + ret =3D -1; + #define DO_TEST(name) \ do { \ testGenericData data =3D { driver.xmlopt, qapiData.schema }; \ --=20 2.53.0