From nobody Thu May 2 10:16:22 2024 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 1537497864417944.5034777608329; Thu, 20 Sep 2018 19:44:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75361300398F; Fri, 21 Sep 2018 02:44:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F4292010D02; Fri, 21 Sep 2018 02:44:19 +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 6BF6C181A12D; Fri, 21 Sep 2018 02:44:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8L2iDXa008098 for ; Thu, 20 Sep 2018 22:44:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20B667D67B; Fri, 21 Sep 2018 02:44:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BD826266F; Fri, 21 Sep 2018 02:44:10 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE8433081D86; Fri, 21 Sep 2018 02:44:08 +0000 (UTC) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CF7F7A5128C17; Fri, 21 Sep 2018 10:44:04 +0800 (CST) Received: from localhost.localdomain (10.184.157.230) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.399.0; Fri, 21 Sep 2018 10:43:59 +0800 From: Wu Zongyong To: Date: Fri, 21 Sep 2018 10:33:53 +0800 Message-ID: <1537497233-39529-1-git-send-email-cordius.wu@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.157.230] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, ACL 236 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 21 Sep 2018 02:44:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 21 Sep 2018 02:44:09 +0000 (UTC) for IP:'45.249.212.35' DOMAIN:'szxga07-in.huawei.com' HELO:'huawei.com' FROM:'cordius.wu@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.002 (SPF_HELO_PASS, SPF_PASS) 45.249.212.35 szxga07-in.huawei.com 45.249.212.35 szxga07-in.huawei.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: cordius.wu@huawei.com, chenlixin1@huawei.com, wanzongshun@huawei.com, weifuqiang@huawei.com Subject: [libvirt] [PATCH] qemuProcess: update hostdevs before connectting qemu monitor 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 21 Sep 2018 02:44:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In a following case: virsh start $domain service libvirtd stop the guest from within the $domain service libvirtd start Notice that PCI devices which have been assigned to the $domain will still be bound to stub drivers instead rebound to host drivers. In that case the call stack is like below: libvirtd start qemuProcessReconnect qemuProcessStop qemuHostdevReAttachDomainDevices qemuHostdevReAttachPCIDevices virHostdevReAttachPCIDevices qemuHostdevUpdateActiveDomainDevices won't be called because the monitor channel is closed. So host devices in $domain will not be added to either activePCIHostdevs list or inactivePCIHostdev list. And therefore, virHostdevReAttachPCIDevices just neglects these host PCI devices which are bound to stub drivers and don't rebind them to host drivers. This patch fixs that by moving qemuHostdevUpdateActiveDomainDevices before qemuConnectMonitor. Signed-off-by: Wu Zongyong Reviewed-by: John Ferlan --- src/qemu/qemu_process.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f9a01da..d187271 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7783,6 +7783,9 @@ qemuProcessReconnect(void *opaque) * allowReboot in status XML and we need to initialize it. */ qemuProcessPrepareAllowReboot(obj); =20 + if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0) + goto error; + if (priv->qemuCaps && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) retry =3D false; @@ -7794,9 +7797,6 @@ qemuProcessReconnect(void *opaque) if (qemuConnectMonitor(driver, obj, QEMU_ASYNC_JOB_NONE, retry, NULL) = < 0) goto error; =20 - if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0) - goto error; - priv->machineName =3D qemuDomainGetMachineName(obj); if (!priv->machineName) goto error; --=20 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list