From nobody Fri Apr 26 20:33:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575296949; cv=none; d=zohomail.com; s=zohoarc; b=l9Fm8yx/DMXVynbcP7SvWbFyB8pA9WZqhqo5+G1Ki0PlOjI1QZhSr2ph10OBXjqi8Ek9O/nmDPGDA0JfYi+FZS+1wvbOHd3xZ74jEzTCWkfEQIutJCLn7wuH0euphyV6uXNGD+NCTr57l+t0ygxBki+fFxRVmQyUjgwM7ydsGe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575296949; h=Content-Type:Content-Transfer-Encoding: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=fSnS/DYdExV8B7hEh91lOaXMOcu+O/QFhmwyklMU970=; b=fw7CWR2aN1zp3659zznw9v8vbFXZjaxCN/K7EaE+zvXZDvDYG+DgEoZqmRY0zHuTu7HYkcta7r3zGCbilo7nLO80diH7briD/TpgbiIKAxJH68wiKd4XdAbPxcGPNiH/rw7HSm2aL7fD1IJfMnfnLcoOnAAiwbRyOeLeVQ2qQIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575296949071664.3879124310473; Mon, 2 Dec 2019 06:29:09 -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-131-FwdcNsOLNG-XG_XpjuHiRw-1; Mon, 02 Dec 2019 09:27:56 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2535A107ACFC; Mon, 2 Dec 2019 14:27:47 +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 E8A3219C68; Mon, 2 Dec 2019 14:27:46 +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 A7DB218034EC; Mon, 2 Dec 2019 14:27:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB2ERJPJ027462 for ; Mon, 2 Dec 2019 09:27:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 79FD5A4B86; Mon, 2 Dec 2019 14:27:19 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03C4F6764D for ; Mon, 2 Dec 2019 14:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575296947; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=fSnS/DYdExV8B7hEh91lOaXMOcu+O/QFhmwyklMU970=; b=UJAGoXZWVn7dPcRBEGU/OO1Pb52bAXzQFIQ0ejT4/vdg7LpluJ4KRDHukd5cyw3+YkRyk1 6kZWEF/PYexf3xVQpD0OkTe5mhPzqjD/g5NwixOaaxmboN2YPA+nWIqt7uvX8l/bDgodfh S63dHdVrGDxWLg225mt31RysHUL/rSo= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 2 Dec 2019 15:26:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 20/30] qemu: Create NVMe disk in domain namespace 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.84 on 10.5.11.23 X-MC-Unique: FwdcNsOLNG-XG_XpjuHiRw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If a domain has an NVMe disk configured, then we need to create /dev/vfio/* paths in domain's namespace so that qemu can open them. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- src/qemu/qemu_domain.c | 67 ++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7b515b9520..70c4ee8e65 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13430,16 +13430,29 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_= GNUC_UNUSED, { virStorageSourcePtr next; char *dst =3D NULL; + bool hasNVMe =3D false; int ret =3D -1; =20 for (next =3D disk->src; virStorageSourceIsBacking(next); next =3D nex= t->backingStore) { - if (!next->path || !virStorageSourceIsLocalStorage(next)) { - /* Not creating device. Just continue. */ - continue; - } + if (next->type =3D=3D VIR_STORAGE_TYPE_NVME) { + g_autofree char *nvmePath =3D NULL; =20 - if (qemuDomainCreateDevice(next->path, data, false) < 0) - goto cleanup; + hasNVMe =3D true; + + if (!(nvmePath =3D virPCIDeviceAddressGetIOMMUGroupDev(&next->= nvme->pciAddr))) + goto cleanup; + + if (qemuDomainCreateDevice(nvmePath, data, false) < 0) + goto cleanup; + } else { + if (!next->path || !virStorageSourceIsLocalStorage(next)) { + /* Not creating device. Just continue. */ + continue; + } + + if (qemuDomainCreateDevice(next->path, data, false) < 0) + goto cleanup; + } } =20 /* qemu-pr-helper might require access to /dev/mapper/control. */ @@ -13447,6 +13460,10 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg G_G= NUC_UNUSED, qemuDomainCreateDevice(QEMU_DEVICE_MAPPER_CONTROL_PATH, data, true= ) < 0) goto cleanup; =20 + if (hasNVMe && + qemuDomainCreateDevice(QEMU_DEV_VFIO, data, false) < 0) + goto cleanup; + ret =3D 0; cleanup: VIR_FREE(dst); @@ -14461,19 +14478,32 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, virStorageSourcePtr src) { virStorageSourcePtr next; - const char **paths =3D NULL; + char **paths =3D NULL; size_t npaths =3D 0; - char *dmPath =3D NULL; + bool hasNVMe =3D false; + g_autofree char *dmPath =3D NULL; + g_autofree char *vfioPath =3D NULL; int ret =3D -1; =20 for (next =3D src; virStorageSourceIsBacking(next); next =3D next->bac= kingStore) { - if (virStorageSourceIsEmpty(next) || - !virStorageSourceIsLocalStorage(next)) { - /* Not creating device. Just continue. */ - continue; + g_autofree char *tmpPath =3D NULL; + + if (next->type =3D=3D VIR_STORAGE_TYPE_NVME) { + hasNVMe =3D true; + + if (!(tmpPath =3D virPCIDeviceAddressGetIOMMUGroupDev(&next->n= vme->pciAddr))) + goto cleanup; + } else { + if (virStorageSourceIsEmpty(next) || + !virStorageSourceIsLocalStorage(next)) { + /* Not creating device. Just continue. */ + continue; + } + + tmpPath =3D g_strdup(next->path); } =20 - if (VIR_APPEND_ELEMENT_COPY(paths, npaths, next->path) < 0) + if (VIR_APPEND_ELEMENT(paths, npaths, tmpPath) < 0) goto cleanup; } =20 @@ -14484,13 +14514,18 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, goto cleanup; } =20 - if (qemuDomainNamespaceMknodPaths(vm, paths, npaths) < 0) + if (hasNVMe) { + vfioPath =3D g_strdup(QEMU_DEV_VFIO); + if (VIR_APPEND_ELEMENT(paths, npaths, vfioPath) < 0) + goto cleanup; + } + + if (qemuDomainNamespaceMknodPaths(vm, (const char **) paths, npaths) <= 0) goto cleanup; =20 ret =3D 0; cleanup: - VIR_FREE(dmPath); - VIR_FREE(paths); + virStringListFreeCount(paths, npaths); return ret; } =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list