From nobody Fri May 17 08:24:59 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=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697726302; cv=none; d=zohomail.com; s=zohoarc; b=UBuY90iMKpe2IMS/u/bCU21sIxZaI6n3IxnA6/4jREmlNpEs7t8ZeTaYs9nCSBNCHIpknW1x6oiMmY7SJL5A0RMG0omArbEKgIhgQtsBPBs2FKGlencaTF8JT59QsWbCYv3FmsugSfWXwoRvnpqsQf1AEMKy8HXcS2V3Ibb/yMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697726302; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JdCojfzzX26aPzWCUN0wcN7YP7J0BT2FO8BeOe06UDU=; b=l6qrtq+EyTwSFSRHVwf4FooBpstCO/j/xzlMh+5Xz9nW8LfdE7FKQTWhKlNczEuaEaqePzdYA+hDQfamDFnzGK/nq8lT/q1Ctc77EQH+kN5e9pTSNHnwI5bXh08pfYfSqfFgsPXYrd+EpEpzFqf5Hr+m0j8DnpNphSOBkYfZxXo= 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=fail header.from= (p=quarantine dis=quarantine) 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 1697726302728785.3781696149609; Thu, 19 Oct 2023 07:38:22 -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-516-RxLo_psGNRmpdv6ndl4erw-1; Thu, 19 Oct 2023 10:38:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 879F98995B7; Thu, 19 Oct 2023 14:37:57 +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 4AE808CEF; Thu, 19 Oct 2023 14:37:55 +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 AAF1B1946A70; Thu, 19 Oct 2023 14:37:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8C0E61946A5E for ; Thu, 19 Oct 2023 14:36:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 73C98111D782; Thu, 19 Oct 2023 14:36:20 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C17E1121320 for ; Thu, 19 Oct 2023 14:36:20 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 469A18EB36E for ; Thu, 19 Oct 2023 14:36:19 +0000 (UTC) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-koX_yH4bPsCMOT-zRXfy0g-1; Thu, 19 Oct 2023 10:36:12 -0400 Received: from [130.117.225.1] (helo=dev003.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtTsw-009VrQ-14; Thu, 19 Oct 2023 16:20:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697726301; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=JdCojfzzX26aPzWCUN0wcN7YP7J0BT2FO8BeOe06UDU=; b=AoWugrH6IVvRhNpXcMrZl8GXwnsl5A7JLAGFHd71ZC28dyQCncpKl6HOn/tz1IwTPEWD4f EMhjdGIRlGTO7m53n78b3NlesenkIoKScjwPa6T5oMd5/roSNQXx4lgAuZQNI8UfLg+Y2f MlXA5sVZojN5+7k9/JeVQ6jNxnyjpP4= X-MC-Unique: RxLo_psGNRmpdv6ndl4erw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: koX_yH4bPsCMOT-zRXfy0g-1 From: Fima Shevrin To: libvir-list@redhat.com Subject: [PATCH] Send event on persistent config modification Date: Thu, 19 Oct 2023 17:20:36 +0300 Message-Id: <20231019142036.273724-1-efim.shevrin@virtuozzo.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: , Cc: efim.shevrin@virtuozzo.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: virtuozzo.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697726303475100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Currently, libvirt doesn't send events when devices are attached, detached or updated. Thus, any services that listen to events are unaware of the change to persistent config. Signed-off-by: Fima Shevrin Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 43d96739d5..86da8da777 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7209,6 +7209,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObj *vm, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; + virObjectEvent *event =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; g_autoptr(virDomainDeviceDef) devConf =3D NULL; @@ -7292,6 +7293,12 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObj *vm, return -1; =20 virDomainObjAssignDef(vm, &vmdef, false, NULL); + + /* Event sending if persistent config has changed */ + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_DEFINED, + VIR_DOMAIN_EVENT_DEFINED= _UPDATED); + virObjectEventStateQueue(driver->domainEventState, event); } =20 return 0; @@ -7348,6 +7355,7 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, virQEMUDriver *driver =3D dom->conn->privateData; virDomainObj *vm =3D NULL; qemuDomainObjPrivate *priv; + virObjectEvent *event =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; g_autoptr(virDomainDeviceDef) dev_config =3D NULL; g_autoptr(virDomainDeviceDef) dev_live =3D NULL; @@ -7419,8 +7427,16 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom, /* Finally, if no error until here, we can save config. */ if (flags & VIR_DOMAIN_AFFECT_CONFIG) { ret =3D virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir); - if (!ret) + if (!ret) { virDomainObjAssignDef(vm, &vmdef, false, NULL); + + /* Event sending if persistent config has changed */ + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_DEFI= NED, + VIR_DOMAIN_EVENT_DEFI= NED_UPDATED); + + virObjectEventStateQueue(driver->domainEventState, event); + } } =20 endjob: @@ -7438,6 +7454,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *dr= iver, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; + virObjectEvent *event =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; g_autoptr(virDomainDeviceDef) dev_config =3D NULL; g_autoptr(virDomainDeviceDef) dev_live =3D NULL; @@ -7495,6 +7512,12 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *d= river, return -1; =20 virDomainObjAssignDef(vm, &vmdef, false, NULL); + + /* Event sending if persistent config has changed */ + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_DEFINED, + VIR_DOMAIN_EVENT_DEFINED= _UPDATED); + virObjectEventStateQueue(driver->domainEventState, event); } =20 return 0; --=20 2.39.3