From nobody Mon Feb 9 13:01:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1590009166; cv=none; d=zohomail.com; s=zohoarc; b=ORLC+kgcX4i0krHCyb6fkBkAs0slgDCzFXvs6JAa9YnhX6fcJrJ4/5Je+5ghcXzLHf2SRNsnu5EZJP+SPgmcYNRN5shjPCBGejLaKigM3xTT1TdZo6guRXHq4uFgGC+bAumJTt6/P9LMxoClLwhbcUzY4Ae6IoCpGasAx2XFwUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590009166; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HZg+jNXn2hKagSTvB7tClGOq5bCtB0Aca+8y+NS++2A=; b=VcpByMLfmnGtwerTg4dE/OtpuLUTttFXLF53MFOzSHl4oht8FmLiDGLDOHE5QS1YBnInDijE6bQ//2HuD1QyAje2t5G7ckVTQl35VjPVssb6FJ/ObRDE55SPo0yE5N032KEts0+KH3YZ9rVND4zD6oEJ8ArLCHmE0XML7st5jyg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 159000916643970.60231665608433; Wed, 20 May 2020 14:12:46 -0700 (PDT) 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-361-vCGtjbsdNQioBc2-rEFFcA-1; Wed, 20 May 2020 17:12:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3B6118A0765; Wed, 20 May 2020 21:12:32 +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 952A15D9CC; Wed, 20 May 2020 21:12:32 +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 67B711800433; Wed, 20 May 2020 21:12:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04KLCOIA002086 for ; Wed, 20 May 2020 17:12:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5848A1000DA7; Wed, 20 May 2020 21:12:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5376A10D17BF for ; Wed, 20 May 2020 21:12:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 2FE978A5E4C for ; Wed, 20 May 2020 21:12:24 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-SV6LTCSlNo-xPCPB_dTrbg-1; Wed, 20 May 2020 17:12:21 -0400 Received: by mail-qk1-f196.google.com with SMTP id s1so5133538qkf.9 for ; Wed, 20 May 2020 14:12:21 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id z14sm2992031qki.83.2020.05.20.14.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 14:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590009165; 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=HZg+jNXn2hKagSTvB7tClGOq5bCtB0Aca+8y+NS++2A=; b=aoW3Y5WUL7BuOxEkAfp053wQC9NIzLOrg4XR7S4baKqYxURIMylIhBNIMvGeAfTImEQ/N/ i+NePUXyvuS+XsYenZQmN19VRdYH77lK2m/E3asa9L2/W6Esw3bwIe2msUdMEMaDx/LaHo ZDQ9BrcyxzL6CfxVvsFCTEch3tHKBe4= X-MC-Unique: vCGtjbsdNQioBc2-rEFFcA-1 X-MC-Unique: SV6LTCSlNo-xPCPB_dTrbg-1 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=HZg+jNXn2hKagSTvB7tClGOq5bCtB0Aca+8y+NS++2A=; b=cqgWzWC4g1Ris1cK2NbUXgFhMx9OtXXFcZrMJFVRyMwQcH2yz1kGy/0UStaDlg1upe 394aTdKcWfCUW0vAK0YvE4I0+/HdmZyu7ZdUpeNJlGjci/Bwlj4HSz5IqFyz1DcXxVFr 1zsuj0LkbefBvneA/eQtqwygSxduR1B6LYiKnIJrfcOyPhScSoMWkOfGRxWQLcG08rtd smbkEzQKlsJPEq3w9YP9c6H/GXpUtwPYKn++qzNkTjtcsK/N6d1VEkRCOA0we92vTKW9 vT137ec08gOfJKH6HyodVOFEC36gzRvxgwcdGpwjtWdfIYjcM4zMeC1YMsUKUJRv3TuG VI0A== X-Gm-Message-State: AOAM533YYe2HfsFn5UP7n+6bbCo8kryO1Dv4hyYM73LVC6PuYn2q1d90 QOktnxX4qmnryHCZvDhNEbCz57ZY X-Google-Smtp-Source: ABdhPJzb2aGLJjv35No2YEw4ojXYMMZ7YUUHuyUF5GocW/ZRUiv1EnfWhRDsM1RCKnw7LQltEw2suw== X-Received: by 2002:ae9:e319:: with SMTP id v25mr6625678qkf.311.1590009140789; Wed, 20 May 2020 14:12:20 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 08/21] qemu: hotplug: Move the detach of PCI device to the beginning of live hotplug Date: Wed, 20 May 2020 18:11:30 -0300 Message-Id: <20200520211143.2980117-9-danielhb413@gmail.com> In-Reply-To: <20200520211143.2980117-1-danielhb413@gmail.com> References: <20200520211143.2980117-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.14 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 172747b2e2..d88a0922d4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1222,6 +1222,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) @@ -1252,9 +1253,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 @@ -1610,10 +1620,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 @@ -1689,8 +1695,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, info); =20 - qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1); - return -1; } =20 @@ -2929,6 +2933,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'"), @@ -2938,9 +2944,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.26.2