From nobody Thu May 2 06:08:29 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 1516786665390635.3561690720234; Wed, 24 Jan 2018 01:37:45 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 25C305FD67; Wed, 24 Jan 2018 09:37:44 +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 165A57C8B0; Wed, 24 Jan 2018 09:37:43 +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 5FCB018033DA; Wed, 24 Jan 2018 09:37:41 +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 w0O9bdVK012330 for ; Wed, 24 Jan 2018 04:37:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 953747F625; Wed, 24 Jan 2018 09:37:39 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id D90617F642; Wed, 24 Jan 2018 09:37:32 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 24 Jan 2018 10:37:25 +0100 Message-Id: <88e669981f153cda66bd5032229b6b4fa087abf3.1516786645.git.mprivozn@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: raybar@knights.ucf.edu Subject: [libvirt] [PATCH] virUSBDeviceNew: Construct vroot path properly 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 24 Jan 2018 09:37:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When starting an LXC container, the /dev entries are created under temp root (/var/run/libvirt/lxc/$name.dev), relabelled and then the root is pivoted. However, when it comes to USB devices which keep path to the device in the structure we need a way to override the default /dev/usb/... path because we want to work with the one under temp root. That's what @vroot argument is for in virUSBDeviceNew. However, what is being passed there is: vroot =3D /var/run/libvirt/lxc/lxc_0.dev/bus/usb Therefore, constructed path is wrong: dev->path =3D //var/run/libvirt/lxc/lxc_0.dev/bus/usb//dev/bus/usb/002/002 Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/util/virusb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util/virusb.c b/src/util/virusb.c index 6359235ff..f06639eec 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -343,9 +343,13 @@ virUSBDeviceNew(unsigned int bus, virUSBDeviceFree(dev); return NULL; } - if (virAsprintf(&dev->path, "%s" USB_DEVFS "%03d/%03d", - vroot ? vroot : "", - dev->bus, dev->dev) < 0) { + + if ((vroot && + virAsprintf(&dev->path, "%s/%03d/%03d", + vroot, dev->bus, dev->dev) < 0) || + (!vroot && + virAsprintf(&dev->path, USB_DEVFS "%03d/%03d", + dev->bus, dev->dev) < 0)) { virUSBDeviceFree(dev); return NULL; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list