From nobody Fri Apr 19 12:01:11 2024 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578581464; cv=none; d=zohomail.com; s=zohoarc; b=TSPipEoUAk128as2a7LtZ3V1ou25ub6OImhZovo2v8q5+feLW2C8Ubk+TUNbARVlkMrUuaruzs7+kFb5M3Hu8yChv39feF8UPW+FRQLsiA26ZpgyrDVFfSPZUFHEWBA072jK9IuA0Z+fcNkSlwmbF9zhgn70bwXcE9ubgWMREsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578581464; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IKuN2SBCWpTNH7uWhwwj8b8qlB39Ga5LXzEb6KeFU+0=; b=I4ZuSVZgLwcsY9O3umPIyU+j8bJeEk/leUP1diwDdkgOOLbvfPRp3wrb8rzqMAIwk5jab2iXYzp7Gcs8QXzh/fnx+DOEr8VAz9mvrgR8NtjutJ4ix2XvqunJqaG0cahg0fPB6uh2UG5cvFh1wOwtxirixKcbTBUVxI1aWc1mpVE= 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=pass 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 1578581464855826.3409766315447; Thu, 9 Jan 2020 06:51:04 -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-161-xdlUw4otN-GyJsIv-2FTvA-1; Thu, 09 Jan 2020 09:51:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A9BA477; Thu, 9 Jan 2020 14:50:55 +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 14FEC8060C; Thu, 9 Jan 2020 14:50:54 +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 C320E503BD; Thu, 9 Jan 2020 14:50:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 009EopYW006381 for ; Thu, 9 Jan 2020 09:50:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id E846A5C241; Thu, 9 Jan 2020 14:50:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCB9C5C28D for ; Thu, 9 Jan 2020 14:50:48 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 44B47101B92; Thu, 9 Jan 2020 15:50:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578581462; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IKuN2SBCWpTNH7uWhwwj8b8qlB39Ga5LXzEb6KeFU+0=; b=R+/KTbRbhDLxKc3Xd5S2Z5ohwPOxZzdi6WQQHF5bJj4u+UC5hjCnysVEZX932Vf0GnPzR8 1t5pQz97sx02FF/0lLFCLDkecthsCTukAB92N6Ts5Yt15z5/SlDEuYg1HHXGg/wjXLv+nS 5kkBHPyisiBBtHpxvhluh6XlN9nGFgk= From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 9 Jan 2020 15:50:46 +0100 Message-Id: <24cfc22a690378b6a9aac89bd173811b49e71596.1578581446.git.jdenemar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Don't use NULL path from qemuDomainGetHostdevPath 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.11 X-MC-Unique: xdlUw4otN-GyJsIv-2FTvA-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" Commit v5.10.0-290-g3a4787a301 refactored qemuDomainGetHostdevPath to return a single path rather than an array of paths. When the function is called on a missing device, it will now return NULL in @path rather than a NULL array with zero items and the callers need to be adapted properly. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/qemu/qemu_cgroup.c | 32 ++++++++++++++++++-------------- src/qemu/qemu_domain.c | 9 +++++---- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 2bcc0527f6..45701b4c6e 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -426,13 +426,15 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm, if (qemuDomainGetHostdevPath(dev, &path, &perms) < 0) return -1; =20 - VIR_DEBUG("Cgroup allow %s perms=3D%d", path, perms); - rv =3D virCgroupAllowDevicePath(priv->cgroup, path, perms, false); - virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, - virCgroupGetDevicePermsString(perms), - rv); - if (rv < 0) - return -1; + if (path) { + VIR_DEBUG("Cgroup allow %s perms=3D%d", path, perms); + rv =3D virCgroupAllowDevicePath(priv->cgroup, path, perms, false); + virDomainAuditCgroupPath(vm, priv->cgroup, "allow", path, + virCgroupGetDevicePermsString(perms), + rv); + if (rv < 0) + return -1; + } =20 if (qemuHostdevNeedsVFIO(dev)) { VIR_DEBUG("Cgroup allow %s perms=3D%d", QEMU_DEV_VFIO, VIR_CGROUP_= DEVICE_RW); @@ -473,13 +475,15 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm, if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) return -1; =20 - VIR_DEBUG("Cgroup deny %s", path); - rv =3D virCgroupDenyDevicePath(priv->cgroup, path, - VIR_CGROUP_DEVICE_RWM, false); - virDomainAuditCgroupPath(vm, priv->cgroup, - "deny", path, "rwm", rv); - if (rv < 0) - return -1; + if (path) { + VIR_DEBUG("Cgroup deny %s", path); + rv =3D virCgroupDenyDevicePath(priv->cgroup, path, + VIR_CGROUP_DEVICE_RWM, false); + virDomainAuditCgroupPath(vm, priv->cgroup, + "deny", path, "rwm", rv); + if (rv < 0) + return -1; + } =20 if (qemuHostdevNeedsVFIO(dev) && !qemuDomainNeedsVFIO(vm->def)) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 24e84a5966..1f358544ab 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -14001,7 +14001,8 @@ qemuDomainNeedsVFIO(const virDomainDef *def) * * For given device @dev fetch its host path and store it at * @path. Optionally, caller can get @perms on the path (e.g. - * rw/ro). + * rw/ro). When called on a missing device, the function will return succe= ss + * and store NULL at @path. * * The caller is responsible for freeing the @path when no longer * needed. @@ -14625,7 +14626,7 @@ qemuDomainSetupHostdev(virQEMUDriverConfigPtr cfg G= _GNUC_UNUSED, if (qemuDomainGetHostdevPath(dev, &path, NULL) < 0) return -1; =20 - if (qemuDomainCreateDevice(path, data, false) < 0) + if (path && qemuDomainCreateDevice(path, data, false) < 0) return -1; =20 if (qemuHostdevNeedsVFIO(dev) && @@ -15688,7 +15689,7 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm, if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) return -1; =20 - if (qemuDomainNamespaceMknodPath(vm, path) < 0) + if (path && qemuDomainNamespaceMknodPath(vm, path) < 0) return -1; =20 if (qemuHostdevNeedsVFIO(hostdev) && @@ -15720,7 +15721,7 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr = vm, if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0) return -1; =20 - if (qemuDomainNamespaceUnlinkPath(vm, path) < 0) + if (path && qemuDomainNamespaceUnlinkPath(vm, path) < 0) return -1; =20 if (qemuHostdevNeedsVFIO(hostdev) && --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list