From nobody Tue Feb 10 11:56:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155353472662963.61900179000463; Mon, 25 Mar 2019 10:25:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF5EB308FC4D; Mon, 25 Mar 2019 17:25:23 +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 BC8815F9CF; Mon, 25 Mar 2019 17:25:23 +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 7F8EF3FA4E; Mon, 25 Mar 2019 17:25:23 +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 x2PHOiEl029804 for ; Mon, 25 Mar 2019 13:24:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4FB7601A1; Mon, 25 Mar 2019 17:24:44 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-122.phx2.redhat.com [10.3.116.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F05A87B4; Mon, 25 Mar 2019 17:24:44 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Mon, 25 Mar 2019 13:24:25 -0400 Message-Id: <20190325172436.17069-4-laine@laine.org> In-Reply-To: <20190325172436.17069-1-laine@laine.org> References: <20190325172436.17069-1-laine@laine.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 03/14] qemu_hotplug: pull qemuDomainUpdateDeviceList out of qemuDomainDetachDeviceLive 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 25 Mar 2019 17:25:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuDomainDetachDeviceLive() is called from two places in qemu_driver.c, and qemuDomainUpdateDeviceList() is called from the end of qemuDomainDetachDeviceLive(), which is now in qemu_hotplug.c This patch replaces the single call to qemuDomainUpdateDeviceList() with two calls to it immediately after return from qemuDomainDetachDeviceLive(). This is only done if the return from that function is exactly 0, in order to exactly preserve previous behavior. Removing that one call from qemuDomainDetachDeviceList() will permit us to call it from the test driver hotplug test, replacing the separate calls to qemuDomainDetachDeviceDiskLive(), qemuDomainDetachChrDevice(), qemuDomainDetachShmemDevice() and qemuDomainDetachWatchdog(). We want to do this so that part of the common functionality of those three functions (and the rest of the device-specific Detach functions) can be pulled up into qemuDomainDetachDeviceLive() without breaking the test. (This is done in the next patch). NB: Almost certainly this is "not the best place" to call qemuDomainUpdateDeviceList() (actually, it is provably the *wrong* place), since it's purpose is to retrieve an "up to date" list of aliases for all devices from qemu, and if the guest OS hasn't yet processed the detach request, the now-being-removed device may still be on that list. It would arguably be better to instead call qemuDomainUpdateDevicesList() later during the response to the DEVICE_DELETED event for the device. But removing the call from the current point in the detach could have some unforeseen ill effect due to changed timing, so the change to move it into qemuDomainRemove*Device() will be done in a separate patch (in order to make it easily revertible in case it causes a regression). Signed-off-by: Laine Stump --- Change from V1: * Added the big explanation above about why I'm not completely changing behavior by waiting unt after DEVICE_DELETED to call qemuDomainUpdateDeviceList() * Only call qemuDomainUpdateDeviceList() if the Detach function returned *exactly* 0, since there are cases where it could return > 0, and the previous behavior was to not call it in those cases. src/qemu/qemu_driver.c | 14 ++++++++++++-- src/qemu/qemu_hotplug.c | 3 --- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6f5a4224c5..51b434f0d2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8927,8 +8927,14 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr= driver, } =20 if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (qemuDomainDetachDeviceLive(vm, dev_copy, driver, false) < 0) + int rc; + + if ((rc =3D qemuDomainDetachDeviceLive(vm, dev_copy, driver, false= )) < 0) + goto cleanup; + + if (rc =3D=3D 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASY= NC_JOB_NONE) < 0) goto cleanup; + /* * update domain status forcibly because the domain status may be * changed even if we failed to attach the device. For example, @@ -9005,11 +9011,15 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDri= verPtr driver, =20 if (def) { virDomainDeviceDef dev; + int rc; =20 if (virDomainDefFindDevice(def, alias, &dev, true) < 0) goto cleanup; =20 - if (qemuDomainDetachDeviceLive(vm, &dev, driver, true) < 0) + if ((rc =3D qemuDomainDetachDeviceLive(vm, &dev, driver, true)) < = 0) + goto cleanup; + + if (rc =3D=3D 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASY= NC_JOB_NONE) < 0) goto cleanup; } =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 666657758e..b435ea99ac 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6266,9 +6266,6 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, break; } =20 - if (ret =3D=3D 0) - ret =3D qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE= ); - return ret; } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list