From nobody Fri Apr 26 05:38:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1633438130; cv=none; d=zohomail.com; s=zohoarc; b=jhEVgIpKWWZXhm9JnD36RJEG4hdBZeXXmwdjjWtfnsJlEdOoD446W3Uee0KTMx+9mZhkqmlyecGeUEC1BBYQede7Tg+oycHMbA9Sv3g5XPYiQlkX+6oCfwlSz8V7qeD6BScpU2XBTxJE/OjkT9cd+Kyzm7+UUlzp4/fpy0sShwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633438130; 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=/G2Zc7SFefYvDQlGSwcxvyjR6YHMAhwJmUsd3/1YsO4=; b=DK/IeqNOQevlp92JUijN4HQ1t22xksAGNurn0Kjqc6ydrCyHPAZHQ8bfO3V25nrvUxxrih4x2hdv87quNHOyk3/5XKx4k9LS8yIeesJuhMQNA0d2T+SW7WzYDGMbAywpe7FetSsVgf+OIBGBN6DaQpOkZiRZe5T7zCJCcAFMCaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1633438130283475.81331457713065; Tue, 5 Oct 2021 05:48:50 -0700 (PDT) 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-360-Aq0BrPpqMvGZQXao7gariA-1; Tue, 05 Oct 2021 08:48:47 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31A9710168EF; Tue, 5 Oct 2021 12:48:39 +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 DF5BD9AA4A; Tue, 5 Oct 2021 12:48:35 +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 0DA914EA29; Tue, 5 Oct 2021 12:48:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 195CmGN8003927 for ; Tue, 5 Oct 2021 08:48:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4376660BD8; Tue, 5 Oct 2021 12:48:16 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.247.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3F57652AE for ; Tue, 5 Oct 2021 12:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633438129; 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=/G2Zc7SFefYvDQlGSwcxvyjR6YHMAhwJmUsd3/1YsO4=; b=S5lXdJJEbWayiGc3Z/97DTFpsWBc2ppdNKvMZymuEhb/xIj/q9M32JzEf4ZJ8fHVhlLLdy tIwPnJuaH6l6AzV5N6kE4kaERzwbZGrdtJ6A4ZSsdws4hKlPXgsYdulqFA3Ai41H/6fWRu Ndm+c1ImthLgl4oqSyza4nD9DDHmF3c= X-MC-Unique: Aq0BrPpqMvGZQXao7gariA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Check if unpriv_sgio is already set before trying to set it Date: Tue, 5 Oct 2021 14:47:59 +0200 Message-Id: <61c9cb75b696c95ca39b8fccd255e7a512a83031.1633438079.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633438132703100001 Content-Type: text/plain; charset="utf-8" In case when libvirt runs inside a restricted container it may not have enough permissions to modify unpriv_sgio. However, it may have been set beforehand by sysadmin or an orchestration tool. Therefore, let's check whether the currently set value is the one we want and if it is refrain from writing to the file. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2010306 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_conf.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 916a3d36ee..0451bc70ac 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1878,9 +1878,17 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev) * whitelist is enabled. But if requesting unfiltered access, always = call * virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_s= gio. */ - if ((virFileExists(sysfs_path) || val =3D=3D 1) && - virSetDeviceUnprivSGIO(path, NULL, val) < 0) - return -1; + if (virFileExists(sysfs_path) || val =3D=3D 1) { + int curr_val; + + if (virGetDeviceUnprivSGIO(path, NULL, &curr_val) < 0) + return -1; + + if (curr_val !=3D val && + virSetDeviceUnprivSGIO(path, NULL, val) < 0) { + return -1; + } + } =20 return 0; } --=20 2.32.0