From nobody Sat Apr 20 07:55:16 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559832433; cv=none; d=zoho.com; s=zohoarc; b=afArM0UN/CKnszsXWxPtUjwN5r44YP6tc/Z4qvR2bV+7VDWywvQTMpTVeEyurlyn+dLtRT/VpLJHF4/uPq9V7IEo8MUu00BhKqbjRKP0wrAkek9e7g2N4EqU0RfQ1ScvCnMob/T8nv5ZP2jZOkNm0QxJScCwM6SWbNZyT1g4NMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559832433; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=UZufKAdn6pYS1sghHxnX4CmhQwM+9RL4ABTS1+OQVBU=; b=V7Yw+eRf671GDYczDFzqms0FiAlBSjV6+Gz7i1yWVdLr3tKo/tTiHbKCv9pENoOz4BO5v87XV2QUPHSPiSlAHBSEtgoGwl87dZUu4wjPboC/o+CWZ95uxYmR7VqT2MXnnSzHDuUmYOh/h/blVbzbgh7jxuE3pWzwlpLHLiG7DUg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559832433915568.5052013555088; Thu, 6 Jun 2019 07:47:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E64C7A3B71; Thu, 6 Jun 2019 14:46:27 +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 0838710ABD88; Thu, 6 Jun 2019 14:46:19 +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 93133E162; Thu, 6 Jun 2019 14:46:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x56EiVlj029241 for ; Thu, 6 Jun 2019 10:44:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C5D25C676; Thu, 6 Jun 2019 14:44:31 +0000 (UTC) Received: from localhost (dhcp-192-191.str.redhat.com [10.33.192.191]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6D285F7DE; Thu, 6 Jun 2019 14:44:26 +0000 (UTC) From: Cornelia Huck To: Alex Williamson Date: Thu, 6 Jun 2019 16:44:17 +0200 Message-Id: <20190606144417.1824-2-cohuck@redhat.com> In-Reply-To: <20190606144417.1824-1-cohuck@redhat.com> References: <20190606144417.1824-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Tony Krowiak , kvm@vger.kernel.org, libvir-list@redhat.com, Cornelia Huck , Halil Pasic Subject: [libvirt] [PATCH RFC 1/1] allow to specify additional config data 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 06 Jun 2019 14:46:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a rough implementation for vfio-ap. Signed-off-by: Cornelia Huck --- mdevctl.libexec | 25 ++++++++++++++++++++++ mdevctl.sbin | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/mdevctl.libexec b/mdevctl.libexec index 804166b5086d..cc0546142924 100755 --- a/mdevctl.libexec +++ b/mdevctl.libexec @@ -54,6 +54,19 @@ wait_for_supported_types () { fi } =20 +# configure vfio-ap devices +configure_ap_devices() { + list=3D"`echo "${config[$1]}" | sed 's/,/ /'`" + [ -z "$list" ] && return + for a in $list; do + echo "$a" > "$supported_types/${config[mdev_type]}/devices/$uuid/$= 2" + if [ $? -ne 0 ]; then + echo "Error writing '$a' to '$uuid/$2'" >&2 + exit 1 + fi + done +} + case ${1} in start-mdev|stop-mdev) if [ $# -ne 2 ]; then @@ -148,6 +161,18 @@ case ${cmd} in echo "Error creating mdev type ${config[mdev_type]} on $parent= " >&2 exit 1 fi + + # some types may specify additional config data + case ${config[mdev_type]} in + vfio_ap-passthrough) + configure_ap_devices ap_adapters assign_adapter + configure_ap_devices ap_domains assign_domain + configure_ap_devices ap_control_domains assign_control_dom= ain + # TODO: is assigning idempotent? Should we unwind on error? + ;; + *) + ;; + esac ;; =20 add-mdev) diff --git a/mdevctl.sbin b/mdevctl.sbin index 276cf6ddc817..eb5ee0091879 100755 --- a/mdevctl.sbin +++ b/mdevctl.sbin @@ -33,6 +33,8 @@ usage() { echo "set-start : change mdev start policy, if no option sp= ecified," >&2 echo " system default policy is used" >&2 echo " options: [--auto] [--manual]" >&2 + echo "set-additional-config {fmt...}: supply additional co= nfiguration" >&2 + echo "show-additional-config-format : prints the format ex= pected by the device" >&2 echo "list-all: list all possible mdev types supported in the system" = >&2 echo "list-available: list all mdev types currently available" >&2 echo "list-mdevs: list currently configured mdevs" >&2 @@ -48,7 +50,7 @@ while (($# > 0)); do --manual) config[start]=3Dmanual ;; - start-mdev|stop-mdev|remove-mdev|set-start) + start-mdev|stop-mdev|remove-mdev|set-start|show-additional-config-= format) [ $# -ne 2 ] && usage cmd=3D$1 uuid=3D$2 @@ -67,6 +69,14 @@ while (($# > 0)); do cmd=3D$1 break ;; + set-additional-config) + [ $# -le 2 ] && usage + cmd=3D$1 + uuid=3D$2 + shift 2 + addtl_config=3D"$*" + break + ;; *) usage ;; @@ -114,6 +124,50 @@ case ${cmd} in fi ;; =20 + set-additional-config) + file=3D$(find $persist_base -name $uuid -type f) + if [ -w "$file" ]; then + read_config "$file" + if [ ${config[start]} =3D=3D "auto" ]; then + systemctl stop mdev@$uuid.service + fi + # FIXME: validate input! + for i in $addtl_config; do + key=3D"`echo "$i" | cut -d '=3D' -f 1`" + value=3D"`echo "$i" | cut -d '=3D' -f 2-`" + if grep -q ^$key $file; then + if [ -z "$value" ]; then + sed -i "s/^$key=3D.*//g" $file + else + sed -i "s/^$key=3D.*/$key=3D$value/g" $file + fi + else + echo "$i" >> "$file" + fi + done + if [ ${config[start]} =3D=3D "auto" ]; then + systemctl start mdev@$uuid.service + fi + else + exit 1 + fi + ;; + + show-additional-config-format) + file=3D$(find $persist_base -name $uuid -type f) + read_config "$file" + case ${config[mdev_type]} in + vfio_ap-passthrough) + echo "ap_adapters=3D" + echo "ap_domains=3D" + echo "ap_control_domains=3D" + ;; + *) + echo "no additional configuration defined" + ;; + esac + ;; + list-mdevs) for mdev in $(find $mdev_base/ -maxdepth 1 -mindepth 1 -type l); do uuid=3D$(basename $mdev) --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list