From nobody Sun May 12 03:10:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649662421; cv=none; d=zohomail.com; s=zohoarc; b=J6DgiZkiM+bA1cBEyb4ITbM8fNL7TSrkHnBd0WC39XBff+xkTSyf4U1EJt/Gt7cwDky4EC4JGOCmdSmuMkpOV2c3d3nn//VlMIlThUq4F5sY1xAIp78nMa7NgdiXtRYzHWq3VcPDT6FAdpzC0UhgDlzEKhzjW6IrrKbuiIdZq80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649662421; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=svSPRiIJj5OQMGB9sBp6106M6mKIBLMAuI9Igqk3TZw=; b=PTHUaO0Fc1fYlSPfoYnVx6P++96MZGJGmz8W5Hr7kSg2O5IzQPsMEBc6DhdkdneBGysjYwZKa1txYiQZrUqgTN3vCU2cgC2KaD+mf34QNtDUBb+6+nzVMq73KhMNin4aKqZP3i9wVGfqz/J0SwMis+VbInV0o7LPu7I9lRUyGgg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1649662421424869.2934091531426; Mon, 11 Apr 2022 00:33:41 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-98--ZSu6KS1PkerZg50n9fLyQ-1; Mon, 11 Apr 2022 03:33:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E332A803D7C; Mon, 11 Apr 2022 07:33:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EC6EC44AEC; Mon, 11 Apr 2022 07:33:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CB5FA1947BBD; Mon, 11 Apr 2022 07:33:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 81D1B19466DF for ; Mon, 11 Apr 2022 07:33:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6F320C44AEC; Mon, 11 Apr 2022 07:33:30 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10F93C2E00E for ; Mon, 11 Apr 2022 07:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649662420; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=svSPRiIJj5OQMGB9sBp6106M6mKIBLMAuI9Igqk3TZw=; b=Ynd3qLHmjcZ3iCPwkalT7whJhuGdtbbbj1SJbszE1AR8bEZ//ZsqGXqHB2jPWMXdiw5yaU Z/HtXnnUfUhiNuaDneF9i6Ovmbb5QffoyROeO2sUWt/78+2Z7RS3tHN3CHKdsrg5ECJ9uU UAPCiWGDXBo9tKQHdn4eT3hGo44pkPw= X-MC-Unique: -ZSu6KS1PkerZg50n9fLyQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] virsh: fix event registration for single event Date: Mon, 11 Apr 2022 09:33:27 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1649662422938100001 Allocate a larger 'data' array than strictly needed for simplicity and use 'ndata' as the index when filling it to put the single event at the first unused place, instead of at its index in the virshDomainEventCallbacks array. https://bugzilla.redhat.com/show_bug.cgi?id=3D2073887 Fixes: c6bb2746933bbe65877a5f8a8d60e100b0bf8a59 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- tools/virsh-domain-event.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index 1a2f1cb6e0..6dbb64a655 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -915,23 +915,20 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) return false; } =20 - if (eventName) - data =3D g_new0(virshDomEventData, 1); - else - data =3D g_new0(virshDomEventData, G_N_ELEMENTS(virshDomainEventCa= llbacks)); + data =3D g_new0(virshDomEventData, G_N_ELEMENTS(virshDomainEventCallba= cks)); =20 for (i =3D 0; i < G_N_ELEMENTS(virshDomainEventCallbacks); i++) { if (eventName && STRNEQ(eventName, virshDomainEventCallbacks[i].name)) continue; =20 - data[i].event =3D i; - data[i].ctl =3D ctl; - data[i].loop =3D loop; - data[i].count =3D &count; - data[i].timestamp =3D timestamp; - data[i].cb =3D &virshDomainEventCallbacks[i]; - data[i].id =3D -1; + data[ndata].event =3D i; + data[ndata].ctl =3D ctl; + data[ndata].loop =3D loop; + data[ndata].count =3D &count; + data[ndata].timestamp =3D timestamp; + data[ndata].cb =3D &virshDomainEventCallbacks[i]; + data[ndata].id =3D -1; ndata++; } =20 --=20 2.35.1