From nobody Sun Feb 8 14:10:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580402750148750.353672572568; Thu, 30 Jan 2020 08:45:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-retZHaOdOL6A7aYrcJxoLw-1; Thu, 30 Jan 2020 11:45:40 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13A448010EA; Thu, 30 Jan 2020 16:45:31 +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 DEAA35C296; Thu, 30 Jan 2020 16:45:30 +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 8AF3B87A92; Thu, 30 Jan 2020 16:45:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UGj7YI031946 for ; Thu, 30 Jan 2020 11:45:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46657F8A0C; Thu, 30 Jan 2020 16:45:07 +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 425E5F8A0B for ; Thu, 30 Jan 2020 16:45:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD97F8EB445 for ; Thu, 30 Jan 2020 16:45:06 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-hf5qRXxSMga1PndpePaopA-1; Thu, 30 Jan 2020 11:45:03 -0500 Received: by mail-qt1-f195.google.com with SMTP id l19so2968122qtq.8 for ; Thu, 30 Jan 2020 08:45:03 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:c177:887c:ce1b:6a44:15ec]) by smtp.gmail.com with ESMTPSA id 135sm3007157qkj.55.2020.01.30.08.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 08:45:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580402749; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=q5fV4qJJd7w09/HfvNaFfmICerhmJC4hcR0vOYo/1Pk=; b=YGZZ0J5E2C+oAeEHaVQb8xysZ3xCPbeeCszxsKXmzumxQttOGsPOM5oLfXOAM2zOymXfm4 ESE6fSRwTlVaQSNhDd9DlIDcbb7mXZgKEwr23+JSh3+LimJSnajtQrAdzfhvSfh4gS2DKD QnjqHGkMlQ5hgGfcsN5e3ZDofzwuFLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tMrE8KeJtgBob97U9OoONlCvd2WzDcrrxkMhR+lzHDo=; b=VyzPS1Gs0ni2DlLRZYULGTsZI6ezq3BUtr3mmQ8zcosqaV5lIA07m7yfTKhN8J2d1c pdcwFMq26dQgUUeQk4hx1KB93sJSGkFtt1L89PsBfH22OZUEbPMWHsj2Gl1S5m8LnAcP lw+phdaZMNJLIrIwRChXmz5FVj1IHiwhLFXNR/Bc5XKqtcjmtDF6Vqow2AbGsUhadZVc EfKGSNY9LuMVMGA34ql51utjez+QcbbhdFh5svGyhaUQ4DV6dDPduG3aH4vy3aelddNK Zh1JDr8rXVtcKgH2+pHi8Da+QASyADNM+TlKb9Vph1Lvo1tgGHFGbxkhj7j32lu/5okE KSyA== X-Gm-Message-State: APjAAAW2izoYtv16QuziEF0AwP9TdKAr8S8sM6Wak2vB/jjzn0JlEBUT y/d+UmdrIn8fl+fAeGbsEolUiy++s+o= X-Google-Smtp-Source: APXvYqyplPZLuePhAwgEsLH54v54F1Ws69VCEG75GFZrQmRkw4gpWLfAUM4A+tR4HTRUiaP0lih+Uw== X-Received: by 2002:ac8:86b:: with SMTP id x40mr5855032qth.366.1580402702484; Thu, 30 Jan 2020 08:45:02 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 08/21] qemu: hotplug: Move the detach of PCI device to the beginning of live hotplug Date: Thu, 30 Jan 2020 13:44:20 -0300 Message-Id: <20200130164433.2694119-9-danielhb413@gmail.com> In-Reply-To: <20200130164433.2694119-1-danielhb413@gmail.com> References: <20200130164433.2694119-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: hf5qRXxSMga1PndpePaopA-1 X-MC-Unique: retZHaOdOL6A7aYrcJxoLw-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 00UGj7YI031946 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , sbhat@linux.ibm.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat The hostdevices are the only devices which have dependencies outside of themselves such that, other functions of the PCI card should also have been detached from host driver before attempting the hotplug. This patch moves the detach to the beginning of the hotplug so that the following patch can detach all functions first before attempting to hotplug any. We don't need to move the detach for net devices using SRIOV as all SRIOV devices are single function devices and can be independently detached as usual. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_hotplug.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8e5625fb8d..688171c7b2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1205,6 +1205,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, g_autofree char *netdev_name =3D NULL; g_autoptr(virConnect) conn =3D NULL; virErrorPtr save_err =3D NULL; + virDomainHostdevDefPtr hostdev =3D NULL; =20 /* preallocate new slot for device */ if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) @@ -1235,9 +1236,18 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, * as a hostdev (the hostdev code will reach over into the * netdev-specific code as appropriate), then also added to * the nets list (see cleanup:) if successful. + * + * qemuDomainAttachHostDevice uses a connection to resolve + * a SCSI hostdev secret, which is not this case, so pass NULL. */ - ret =3D qemuDomainAttachHostDevice(driver, vm, - virDomainNetGetActualHostdev(net)= ); + hostdev =3D virDomainNetGetActualHostdev(net); + if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, + hostdev, priv->qemuCaps) = < 0) + goto cleanup; + + if ((ret =3D qemuDomainAttachHostDevice(driver, vm, hostdev)) < 0) + qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev,= 1); + goto cleanup; } =20 @@ -1593,10 +1603,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr drive= r, if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) return -1; =20 - if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, - hostdev, priv->qemuCaps) < 0) - return -1; - /* this could have been changed by qemuHostdevPreparePCIDevices */ backend =3D hostdev->source.subsys.u.pci.backend; =20 @@ -1674,8 +1680,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, info); =20 - qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1); - return -1; } =20 @@ -2905,6 +2909,8 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("hotplug is not supported for hostdev mode '%s'"), @@ -2914,9 +2920,15 @@ qemuDomainAttachHostDevice(virQEMUDriverPtr driver, =20 switch (hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (qemuDomainAttachHostPCIDevice(driver, vm, - hostdev) < 0) + if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def, + hostdev, priv->qemuCaps) = < 0) return -1; + + if (qemuDomainAttachHostPCIDevice(driver, vm, hostdev) < 0) { + qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev,= 1); + return -1; + } + break; =20 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: --=20 2.24.1