From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A9A26458F4; Tue, 3 Sep 2024 11:12:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3CC814042C; Tue, 3 Sep 2024 11:12:34 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 9A4BD402D0 for ; Tue, 3 Sep 2024 11:12:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725354751; x=1756890751; h=message-id:date:subject:from:to:references:in-reply-to: content-transfer-encoding:mime-version; bh=3aeei82QthieZTr7oHfo6ivc5gGdDjB7gOsKxBuQFH8=; b=N8zw3GFJ23N28GVP2gP0PX+lwW4Ox0MHwLivZnLUw4jviuDmfOKJnhrw FOftV7q9vp14JOBMsQZ6bPp9rwHZ66Yggz3SYci+//g1PcvnKABzbJ2S1 pHKLoVecSCKqcDlI+lHRMUWwi617o6irLGKOKvXndzwA6/HB0ALjQH34q 1aJhP2oOu2fs0PUjVlR52r8C7EHZ4yKkQHqY1fANbV9WX/x8qvkEATBnr FsiZFhGQTCv+ZJqAXuPMaWh6HxjNWsvlHEQq8T18DQx0ibRnID6IOtTsc qwUkWOSHQG4sDNQtJ4BmjXTotOdhNY519Esn2j7coMnpWy8tU9fFb7kJT Q==; X-CSE-ConnectionGUID: pg5wlWDCTHu3peUZrT+h5Q== X-CSE-MsgGUID: tH6IVnFlQ2SV/6L7ctFI2w== X-IronPort-AV: E=McAfee;i="6700,10204,11183"; a="23507115" X-IronPort-AV: E=Sophos;i="6.10,198,1719903600"; d="scan'208";a="23507115" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2024 02:12:30 -0700 X-CSE-ConnectionGUID: 679AyPMfQmy3Q85FBn9TCw== X-CSE-MsgGUID: MSO839U5Q0yikdqB8ivmKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,198,1719903600"; d="scan'208";a="65202456" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 03 Sep 2024 02:12:30 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 02:12:29 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 3 Sep 2024 02:12:29 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Tue, 3 Sep 2024 02:12:29 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.177) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 3 Sep 2024 02:12:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=urzIyvG9y0vVYcErQNOBOisSTqjp3dFVtzTLpmQH+egNXcQ/JCrRIGP0kd3rvivLy2BKE5LAzbB0JK9zbvWymcVg5Alln84iVlPGG81lS15d5os5OHwOJ6JHClZofU6UjM8pwN4JMh5e9C+E1+b8glNAs1wOqCYEEaaXkE0/bUe/WojUAahp9d7W/FhyD0k92iCXwT3stfT2p+B8RkGIGr4wNZb8faQjTnByyP24DxKE2V/WIhK3K8Lk1ibkv61uATNnjZ0vmbil4bpWp+++eu3klwPHTn2Dmw/b6pqeCkBV2XT1WtM9QLEC+qx4K7li5OS9pRpj+u9h3bVzBZgMFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6SlqYSgvVjNnjwJ4xBNo8ta2gM5jWfYMboKAB/T2w3E=; b=Gb47ng2upXldMD16HaknAKRKCzZzqgtXbyRfD2j99Vi/XcrcVKsubAhDj2REn7GVyFdgeSg2a/Edd22Pv9Rsks5AQeX1WBF/WlvvGQIhqaFvXb9EqadE/o9QJDMQnQq9R+3+DV+lhHMrhJLlmKtqGxY9oh/Fv2K9VCgDKdTQc7HRXE7ujHPrqJJwjn1ZNbVHVGjDftBVPBfWxqT/qh4yFxrTpLD9E2auOABnzMLGCTVFBjYF2F1uYuZ+Y2USzVwMn1Otx0AD6VaOGsanp/SlXve5R8zPjg/XieZYIBbUpg0ttxZVYveIVaEZr/KmZOYQDuErsZgH83/SYskt9UcP3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH7PR11MB6498.namprd11.prod.outlook.com (2603:10b6:510:1f1::21) by SA0PR11MB4542.namprd11.prod.outlook.com (2603:10b6:806:9f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.26; Tue, 3 Sep 2024 09:12:21 +0000 Received: from PH7PR11MB6498.namprd11.prod.outlook.com ([fe80::999a:425d:a211:5d30]) by PH7PR11MB6498.namprd11.prod.outlook.com ([fe80::999a:425d:a211:5d30%6]) with mapi id 15.20.7918.024; Tue, 3 Sep 2024 09:12:21 +0000 Message-ID: Date: Tue, 3 Sep 2024 11:11:50 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/1] usertools/devbind: allow changing UID/GID for VFIO From: "Burakov, Anatoly" To: , Robin Jarry References: <4cd0282dabfa59e715028ecf255468529655b487.1725285449.git.anatoly.burakov@intel.com> Content-Language: en-US In-Reply-To: <4cd0282dabfa59e715028ecf255468529655b487.1725285449.git.anatoly.burakov@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DU7P191CA0016.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:54e::26) To DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR11MB6498:EE_|SA0PR11MB4542:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a5796a2-2dd1-49db-45d9-08dccbf87d52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?cTFUM2JkUHdtRk1Oc1IrMVNDUnVxUzZxQ0lpaWMvMEZmVFpYOVNTQ2hsTUNm?= =?utf-8?B?ajRLRVM5QUtPNDdmdG9LVHpCSGhxSnY0TisrL3pSdjVSY3BCWXlHY3k2SnlD?= =?utf-8?B?eGxETEF0K1VBem5VdHlRNUQ5ZU1rNFc3bnV1LzB1bnE5d1o3dzc4a0xIQUk4?= =?utf-8?B?dEZVUHJlK1N0ZSs1anFwQXh0cHE5YVZPV21qV0VBbzhGOH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a3hhL2tqTCt6WWhNTUZKbWlPMW1k?= =?utf-8?B?RmZzT0RpTHZhZkJCNnc4b0N2RmlnMkp2ZWRkUW1uWjZSWFJyUTA4Z2pjS2JL?= =?utf-8?B?VE5lZnU2a0hHVkJJRXF4VzgzR1dnU1JyajVNcVNGa2N6OHpabjRaNFJobjlt?= =?utf-8?B?aUlTQmovRG1XTERCSVk2MEs3elVQTWc1dTlBaFIrOHptd1F4R2g1aXBSRUlI?= =?utf-8?B?VFVLMk85MVlPVDd5T3YvUE12Y0k4aW1nQ3U4dk1yS241Q1hDb3l1MnNzT0VQ?= =?utf-8?B?NzdiNHNEUGhubU1ScVU5d1I2YlRsQlArZWZjdjVQc0gxQkhCbnVSbDZ5RDZn?= =?utf-8?B?ZW4rZTB6bHRydHhCRUkxWXF5bjZKazh6Uk5MeWpPa3dkZUxuUEdDZFo2ajdo?= =?utf-8?B?QWJmOWhYTmRLcmsvMjcwWWJCMUtYc016RFNUM0ZXN2ZwMGZFZzIrdzg0Z3Bw?= =?utf-8?B?WjFEMmtUam9pOURmamdIWk5tdFJxd1RwZS9hZGtGVkgydnVvMWdQMnZoeEpJ?= =?utf-8?B?VjQvd01zdWdCeDN4QSsvUEthMFEzWWhpWExWcUY5aC9EKzN5czJ6cEdlR0dE?= =?utf-8?B?ZkNsajVWUzNyd3MrWlBIc3pISnlpQkdSSHo0R2ErOXZkNi9ZYXlJYVRLdEZK?= =?utf-8?B?RncwTGVDVjJVWU91NG5XNkptOTBwUUp2MmNBSWFET0tYS3JOcHRLdjZyNG4v?= =?utf-8?B?ZjRXdk1FNlFGcllOOUpNQT09?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR11MB6498.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam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kwdHBJTFE2NE1MUlpDYkE0ZmhjOFVRQ1dHS3VXazhH?= =?utf-8?B?YmN4WitRdkRmbHA2am8zR1VwMy9uRWpESDU1V0NJTi9KejNXODl4Y0haak9o?= =?utf-8?B?SlBPZGpDa0lPWHVUR29ZMmRQRUNjV0FIcENtQTA5S1JCOVhEbGM4cVZ3VnBZ?= =?utf-8?B?K0tjUHlYNXNRbzJsdGVYOW5pTW1MNVpyWCtxNXg2Sk54c1hTS2FUU2NnUVJP?= =?utf-8?B?NFhISWtIeEJsZXROYXExY3FCeFpxRUNQTE5ZM3FxVm9xWENnRmFsVUFxV293?= =?utf-8?B?TzB6a2Q1blZBSVgwZU9TazlSdFlHUnFqaC9qODNNcnZRTm5VRFVic3RKQVkx?= =?utf-8?B?eWZSVCtNN0RUcGVoK2Z1MVh6Q2ZIMmRlWGdKWmxVcU5ZYStTdUhMbEUvcWVr?= =?utf-8?B?aVE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5a5796a2-2dd1-49db-45d9-08dccbf87d52 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB6502.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 09:12:21.7241 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SHD03Hgm9oSw6tdd7aBccbyMqWd3Yv8HlxNhjj1PEEIGv6+avvMejtZjPETIxEOCVGGplLtVpA5lq7mf1SnwszXxGqPdWgXJeRrFZB8+Eho= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4542 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 9/2/2024 3:57 PM, Anatoly Burakov wrote: > Currently, when binding a device to VFIO, the UID/GID for the device will > always stay as system default (`root`). Yet, when running DPDK as non-root > user, one has to change the UID/GID of the device to match the user's > UID/GID to use the device. > > This patch adds an option to `dpdk-devbind.py` to change the UID/GID of > the device when binding it to VFIO. > > Signed-off-by: Anatoly Burakov > --- > > +def own_one(dev_id, uid, gid): > + """Set the IOMMU group ownership for a device""" > + # find IOMMU group for a particular device > + iommu_grp_base_path = os.path.join("/sys/bus/pci/devices", dev_id, "iommu_group") > + try: > + iommu_grp = os.path.basename(os.readlink(iommu_grp_base_path)) > + # we found IOMMU group, now find the device > + dev_path = os.path.join("/dev/vfio", iommu_grp) > + # set the ownership > + _uid = pwd.getpwnam(uid).pw_uid if uid else -1 > + _gid = grp.getgrnam(gid).gr_gid if gid else -1 > + os.chown(dev_path, _uid, _gid) > + except OSError as err: > + sys.exit(f"Error: failed to read IOMMU group for {dev_id}: {err}") On another thought, perhaps sys.exit() here is a bit too drastic... Will replace with error message in v2 -- Thanks, Anatoly