From nobody Sun Feb 8 19:24:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554451069811324.3189934846613; Fri, 5 Apr 2019 00:57:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36FA930024AD; Fri, 5 Apr 2019 07:57:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3D9A1001DF9; Fri, 5 Apr 2019 07:57:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C408C41F3D; Fri, 5 Apr 2019 07:57:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x357vigs002769 for ; Fri, 5 Apr 2019 03:57:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8DDEF605CF; Fri, 5 Apr 2019 07:57:44 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E45E4605AF for ; Fri, 5 Apr 2019 07:57:43 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 5 Apr 2019 09:57:36 +0200 Message-Id: <479f19fd3a1b97d6c2ebef85e140f31e19b1a8d9.1554450927.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] qemuDomainAttachDeviceLive: Rework event emitting X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 05 Apr 2019 07:57:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some devices that we want to emit event for do not have an alias. Rework event emitting to make code more generic. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7e5bbc3cc9..6eabcfce18 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7838,15 +7838,15 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, virDomainDeviceDefPtr dev, virQEMUDriverPtr driver) { + virObjectEventPtr event =3D NULL; int ret =3D -1; - const char *alias =3D NULL; =20 switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_DISK: qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL); ret =3D qemuDomainAttachDeviceDiskLive(driver, vm, dev); if (!ret) { - alias =3D dev->data.disk->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.di= sk->info.alias); dev->data.disk =3D NULL; } break; @@ -7854,7 +7854,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_CONTROLLER: ret =3D qemuDomainAttachControllerDevice(driver, vm, dev->data.con= troller); if (!ret) { - alias =3D dev->data.controller->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.co= ntroller->info.alias); dev->data.controller =3D NULL; } break; @@ -7870,7 +7870,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, qemuDomainObjCheckNetTaint(driver, vm, dev->data.net, NULL); ret =3D qemuDomainAttachNetDevice(driver, vm, dev->data.net); if (!ret) { - alias =3D dev->data.net->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.ne= t->info.alias); dev->data.net =3D NULL; } break; @@ -7880,7 +7880,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainAttachHostDevice(driver, vm, dev->data.hostdev); if (!ret) { - alias =3D dev->data.hostdev->info->alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.ho= stdev->info->alias); dev->data.hostdev =3D NULL; } break; @@ -7889,7 +7889,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainAttachRedirdevDevice(driver, vm, dev->data.redirdev); if (!ret) { - alias =3D dev->data.redirdev->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.re= dirdev->info.alias); dev->data.redirdev =3D NULL; } break; @@ -7898,7 +7898,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainAttachChrDevice(driver, vm, dev->data.chr); if (!ret) { - alias =3D dev->data.chr->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.ch= r->info.alias); dev->data.chr =3D NULL; } break; @@ -7907,7 +7907,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainAttachRNGDevice(driver, vm, dev->data.rng); if (!ret) { - alias =3D dev->data.rng->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.rn= g->info.alias); dev->data.rng =3D NULL; } break; @@ -7924,7 +7924,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainAttachShmemDevice(driver, vm, dev->data.shmem); if (!ret) { - alias =3D dev->data.shmem->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.sh= mem->info.alias); dev->data.shmem =3D NULL; } break; @@ -7933,7 +7933,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ret =3D qemuDomainAttachWatchdog(driver, vm, dev->data.watchdog); if (!ret) { - alias =3D dev->data.watchdog->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.wa= tchdog->info.alias); dev->data.watchdog =3D NULL; } break; @@ -7941,7 +7941,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_INPUT: ret =3D qemuDomainAttachInputDevice(driver, vm, dev->data.input); if (ret =3D=3D 0) { - alias =3D dev->data.input->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.in= put->info.alias); dev->data.input =3D NULL; } break; @@ -7949,7 +7949,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_VSOCK: ret =3D qemuDomainAttachVsockDevice(driver, vm, dev->data.vsock); if (ret =3D=3D 0) { - alias =3D dev->data.vsock->info.alias; + event =3D virDomainEventDeviceAddedNewFromObj(vm, dev->data.vs= ock->info.alias); dev->data.vsock =3D NULL; } break; @@ -7973,14 +7973,10 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, break; } =20 - if (alias) { - /* queue the event before the alias has a chance to get freed - * if the domain disappears while qemuDomainUpdateDeviceList - * is in monitor */ - virObjectEventPtr event; - event =3D virDomainEventDeviceAddedNewFromObj(vm, alias); - virObjectEventStateQueue(driver->domainEventState, event); - } + /* queue the event before the alias has a chance to get freed + * if the domain disappears while qemuDomainUpdateDeviceList + * is in monitor */ + virObjectEventStateQueue(driver->domainEventState, event); =20 if (ret =3D=3D 0) ret =3D qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE= ); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list