From nobody Wed Nov 27 07:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1700604673; cv=pass; d=zohomail.com; s=zohoarc; b=e6IaJV8lD9gnmnmsAp1T22u4H5pktdfOcopw9pwO9Is4ydBjP7Om2uObtuDjpHP5w7u5UF0FgWswmlKzdCeSghkDzJ+RjpaFEZ3yAZYhm51v0SqvnqLYQh2acBXCkDrJPVkAhHFxSk8f9y/uNXZX0bgBGME2Djhnuour8Y+9yRE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700604673; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ffYRx7XuJDukcGSWHJ7JKVQ+d8C2usuIHgJipHrngZ4=; b=CzvtmEymgi8u3yydY1cl22FJpJSQWq0ovsh3d2VxIL6MrK6L7NzqnlAbJ9UJ5z2N7qFxr0pmH5JDJYzpRGirS52BO7Aru51I6LNu3c9umn2bsPcW9gNyngpSm7dRco2o7PktQSjJKADNyorhrg7h0IsTqjFEfvseNvuN12CCOQM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1700604672979351.71786867997946; Tue, 21 Nov 2023 14:11:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.638306.994763 (Exim 4.92) (envelope-from ) id 1r5YxH-0007jF-Rl; Tue, 21 Nov 2023 22:10:51 +0000 Received: by outflank-mailman (output) from mailman id 638306.994763; Tue, 21 Nov 2023 22:10:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5YxH-0007j2-NG; Tue, 21 Nov 2023 22:10:51 +0000 Received: by outflank-mailman (input) for mailman id 638306; Tue, 21 Nov 2023 22:10:50 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5YxG-0006PS-Qg for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 22:10:50 +0000 Received: from mx0a-0039f301.pphosted.com (mx0a-0039f301.pphosted.com [148.163.133.242]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d37d086d-88ba-11ee-98e1-6d05b1d4d9a1; Tue, 21 Nov 2023 23:10:49 +0100 (CET) Received: from pps.filterd (m0174679.ppops.net [127.0.0.1]) by mx0a-0039f301.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALJcd1C031085; Tue, 21 Nov 2023 22:10:34 GMT Received: from eur03-am7-obe.outbound.protection.outlook.com (mail-am7eur03lp2233.outbound.protection.outlook.com [104.47.51.233]) by mx0a-0039f301.pphosted.com (PPS) with ESMTPS id 3uh0hhgrv3-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:10:34 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com (2603:10a6:803:31::18) by DU0PR03MB8836.eurprd03.prod.outlook.com (2603:10a6:10:40c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 22:10:28 +0000 Received: from VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822]) by VI1PR03MB3710.eurprd03.prod.outlook.com ([fe80::8e03:368:1fd7:1822%6]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 22:10:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d37d086d-88ba-11ee-98e1-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+oTrug03bO6QMDVE2fZb4n6QkQkiYtc7LUvlIWe6QIW4Q7Morj3kHkdflWv/WRoC1fRSGUeA6PmLyZfchw7sjECTyimw/dfx6eKOoA5mzG8BkJNRSeZXgAyj9dzBs8RKpj66iuzVN0tvs9T5y9xXG23STbeWXmNva+pQp6QW48H1EUC0GD4HGzdYceEJcZcTDDG0mtR4zDPFidDk3ud7LhoFkoazm+hu/4aviKZmly9MXqa/bBdLOAUMJtUxSHLO4Uae8gH8DjjmLmB2nCkdgaRITi5lHcfq1i6pW719RLUU+u2dhXy4xzYBeLATprh64ELMG3V8JRyhdCnVnEk9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ffYRx7XuJDukcGSWHJ7JKVQ+d8C2usuIHgJipHrngZ4=; b=YEtTuGWyIcbvsJ9f0YRazOenepm2HF8GQmFy2d59F/JiyCY8ccDv33vq20lJeSO33rh/rctmuioIrLl+v1Hrvh/yzP4OE3ePJdbo6YHAzRrcCiyuvA2Jh1I06Q3LEzbPLtgPEK0bvV+6ybT+intalSzDibrETMKfcH+tKWOBb7mAUIzrOmDxt3SrhQD83Ixz2LfKIjWJlAnLz/Aunkxq0qKtl6GIoX0zoYCQ3kh/6rDNHJPJvzMtvKSAluodt2fMqdQRSVPK9PZStWDNydhSUFSiXyS+/Ug4CodR9+fKOjj0fzbsRzjfz3BIo7/JAm5cthFyTQPF56QkzUK6JMDmww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ffYRx7XuJDukcGSWHJ7JKVQ+d8C2usuIHgJipHrngZ4=; b=gKASjAqHwMmv0ZXPeRtLBFyp5DC6FQBknfHiNZKoUIzQGWyYnRZa+Pw8YED71UM16CzEY8g9wB4boMhDLfAUe+Kp1q76qRoGontVHfbXF5hu1AKCg9U10D8H+lVrkbLfdBikI1ttjAlH8Dq8fuJCFLNt6blp0HoaK8YodQkiqKDtEcl+HirBTAzXdNNINp6MIz5jJMlbrsSyaAm78P+1A6wQK4wTJiZdXdZP2Mjk3kU03B5YAvYFIKi8MPSr6EwxtqvPMXnOO3xC/eXJ72CQq4OKvqGL1oNe+LzCZeOwVsOrtNMyUxmzX78tJZyTgzFLHOMD8EueMqlRYOUdtc1IAw== From: Volodymyr Babchuk To: "qemu-devel@nongnu.org" CC: David Woodhouse , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , David Woodhouse , Paul Durrant , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Anthony Perard , "open list:X86 Xen CPUs" Subject: [PATCH v2 3/6] xen: xenstore: add possibility to preserve owner Thread-Topic: [PATCH v2 3/6] xen: xenstore: add possibility to preserve owner Thread-Index: AQHaHMeI3Gf8Xs6dHUOphRyadMs2ow== Date: Tue, 21 Nov 2023 22:10:27 +0000 Message-ID: <20231121221023.419901-4-volodymyr_babchuk@epam.com> References: <20231121221023.419901-1-volodymyr_babchuk@epam.com> In-Reply-To: <20231121221023.419901-1-volodymyr_babchuk@epam.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.42.0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB3710:EE_|DU0PR03MB8836:EE_ x-ms-office365-filtering-correlation-id: 0b5b5819-1eae-4f49-92f7-08dbeadeab95 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8SyCokp/FW7dJRKCZQZyv9CgiMYc8TV9VtzrtN8Lg9XgIMamyC6+Yo/2/2xKYRziteRPrYXknLhsoU3of6ssWYlw11O98+Ukb+Dp3VUeDCdvyUxCrPk7ExEz5sv4iltZjYkk7zy4Jppr4yIsTJuAAJSQMIWHiOgv+rUD0lTH4JxpqpEnhhvpyYc7o+YTrvmvmNLWunq6CvOlw4Hpi63/525DfKrOhnc+2nVvFbDxaSSd4/ppquOE5XB5VnJxPZ0HmKaInRNk/rnQ8Dc337Q8SstdmG/pyK6DuEA/sb1Q4lKkdUmx5lfIrYEYgJ2ngDhKJAzsN9tullFhUTTmPBl8HiZ6iUKpQnCb6pCa42emnomi7Urni2C9Cyv8MICim91ersiBLCLQDk/fL0sIs590CE066ZlhckoUAe6TxWKwtwQtBToSMT0dQau3Z32/CUfAzjZpseh+9MYIF/UEPODsiktmut00YV1kWKDvGyNZNF0uS9WY3h5w2CNCF+xnYPnM2pPUVZhfd5P2yB7ExLi7ForBB5v1M8jeAru9kDLe3ooYYFr9/IAEUMqegwvM4zIpWuXV26Gvi5S7ZRz2xub8vQ1uT8rG8ykmXzrW14iE64/+NDQbAmDZ96POAGseZaOY x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB3710.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(41300700001)(86362001)(36756003)(7416002)(5660300002)(2906002)(38070700009)(122000001)(6512007)(2616005)(6506007)(55236004)(6486002)(83380400001)(71200400001)(1076003)(478600001)(26005)(38100700002)(91956017)(66556008)(66446008)(316002)(66946007)(6916009)(64756008)(54906003)(4326008)(8676002)(66476007)(76116006)(8936002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?XUXoy6WLSuy2I/xwBQMOTplQFonOYjE+lTe4Lw0/Hv8WxpzFe3TT8R44l8?= =?iso-8859-1?Q?tBefqDfsdRaCs5rTSTM4Dc21cwj5ASiB/PR5CxiWv/JiAIXXX/nHSqQwSX?= =?iso-8859-1?Q?VQPjWttinkA+qEXxrnnEuJ93tG4QzCdQFEuotTwq18RkXyT5eLx9IIwLlP?= =?iso-8859-1?Q?0cGIr/zi3FTyFMtUwhMZyK4nzWKcyg7VOlXNGw7Dir76/EsLlGF4wMRHJ3?= =?iso-8859-1?Q?wMwb7XZ1dnaSH/SaR3/wgioPRJAC/YFdNTfaIHP9e6WElJhDR9KW1/Pmmh?= =?iso-8859-1?Q?lhsJjwiB400g3tWYP+zD8TwcYBRfOAglpULWc0pdQbYjHbMb/Cx8YYMpq7?= =?iso-8859-1?Q?AzTqZYhuZGcC+ru2hIY4GH39Z5AtDrnw2jbaFTdg3DZISAdRBBOfyX1iRu?= =?iso-8859-1?Q?qDmHcsskmCzDbgq2XmVHVb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bIdUPGQD/XHk22gZTU6Kw5aW7p7/MkyDsHQlWB/wuA9Lu9jsqYQOSDTLv?= =?iso-8859-1?Q?I7f3GRXHP+Oy9YX14SpawBvhUwJzlPQ69AwMm7Zsi/UGdXAdhN9u7CNJ22?= =?iso-8859-1?Q?JH1sfOunSHtRfKveMWr9j9UMYVLz0X6da/ykpOG7VemJlYndRSS8m3naMG?= =?iso-8859-1?Q?QS4GC73AEQ1Gi2ee+fzVnxPPV8GdIYNqkR2lyzIHS39ODvQISz3NFFWXLy?= =?iso-8859-1?Q?wYyTC+Y5sGVZ5U6hsuB0epukWfKr8CTd1skeK/tslRYOzkp/ZzdVP1wqYm?= =?iso-8859-1?Q?4zlxcS0rV17krshRXJcw6T0DZwQLAhWpmXl57h22ug3aNlV0P04T/hiw?= =?iso-8859-1?Q?=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB3710.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b5b5819-1eae-4f49-92f7-08dbeadeab95 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2023 22:10:27.7937 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BEVgIfVgeiTu73ik19OyXyA8m6UD0BdLwEuXVifPPf8sfRMnihbq+VgcI+/RqiL6cWCoOzNPs/RmWKw61WvmxLfgUt0mX+OaSEPZU1zi1ac= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR03MB8836 X-Proofpoint-GUID: W2bYEx-fBJEg5TRa3Y--B4-uviAGyo8_ X-Proofpoint-ORIG-GUID: W2bYEx-fBJEg5TRa3Y--B4-uviAGyo8_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210173 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1700604674048100001 Content-Type: text/plain; charset="utf-8" Add option to preserve owner when creating an entry in Xen Store. This may be needed in cases when Qemu is working as device model in a domain that is Domain-0, e.g. in driver domain. "owner" parameter for qemu_xen_xs_create() function can have special value XS_PRESERVE_OWNER, which will make specific implementation to get original owner of an entry and pass it back to set_permissions() call. Please note, that XenStore inherits permissions, so even if entry is newly created by, it already has the owner set to match owner of entry at previous level. Signed-off-by: Volodymyr Babchuk -- In v2: - Pass transaction to xs_get_permissions() in libxenstore_create() - Added comment before XS_PRESERVE_OWNER defintion - Extended the commit message --- hw/i386/kvm/xen_xenstore.c | 18 ++++++++++++++++++ hw/xen/xen-operations.c | 12 ++++++++++++ include/hw/xen/xen_backend_ops.h | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 6e651960b3..d0fd5d4681 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1595,6 +1595,24 @@ static bool xs_be_create(struct qemu_xs_handle *h, x= s_transaction_t t, return false; } =20 + if (owner =3D=3D XS_PRESERVE_OWNER) { + GList *prev_perms; + char letter; + + err =3D xs_impl_get_perms(h->impl, 0, t, path, &prev_perms); + if (err) { + errno =3D err; + return false; + } + + if (sscanf(prev_perms->data, "%c%u", &letter, &owner) !=3D 2) { + errno =3D EFAULT; + g_list_free_full(prev_perms, g_free); + return false; + } + g_list_free_full(prev_perms, g_free); + } + perms_list =3D g_list_append(perms_list, xs_perm_as_string(XS_PERM_NONE, owner)); perms_list =3D g_list_append(perms_list, diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c index e00983ec44..ae8265635f 100644 --- a/hw/xen/xen-operations.c +++ b/hw/xen/xen-operations.c @@ -300,6 +300,18 @@ static bool libxenstore_create(struct qemu_xs_handle *= h, xs_transaction_t t, return false; } =20 + if (owner =3D=3D XS_PRESERVE_OWNER) { + struct xs_permissions *tmp; + unsigned int num; + + tmp =3D xs_get_permissions(h->xsh, t, path, &num); + if (tmp =3D=3D NULL) { + return false; + } + perms_list[0].id =3D tmp[0].id; + free(tmp); + } + return xs_set_permissions(h->xsh, t, path, perms_list, ARRAY_SIZE(perms_list)); } diff --git a/include/hw/xen/xen_backend_ops.h b/include/hw/xen/xen_backend_= ops.h index 90cca85f52..79021538a3 100644 --- a/include/hw/xen/xen_backend_ops.h +++ b/include/hw/xen/xen_backend_ops.h @@ -266,6 +266,13 @@ typedef uint32_t xs_transaction_t; #define XS_PERM_READ 0x01 #define XS_PERM_WRITE 0x02 =20 +/* + * This is QEMU-specific special value used only by QEMU wrappers + * around XenStore. It can be passed to qemu_xen_xs_create() to + * inherit owner value from higher-level XS entry. + */ +#define XS_PRESERVE_OWNER 0xFFFE + struct xenstore_backend_ops { struct qemu_xs_handle *(*open)(void); void (*close)(struct qemu_xs_handle *h); --=20 2.42.0