From nobody Fri Apr 19 18:19:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1631204140; cv=none; d=zohomail.com; s=zohoarc; b=I/hopE6t1YS/1QNZg6QzRn/8z+wU2Aq8oedtCJCYXOkQa4z6DJGed9nukIzjuCeaOWvaIOE+RVfekZSDJ6nuZpF3moFPJ/8qZ5nYvnxft6OLIMmxTcKFha++WW2GqJVyjOLPyxmMNjPkRy65P6hNPZZieAXv1eJ4qqKOUyVZHqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204140; h=Content-Type:Content-Transfer-Encoding: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; bh=z3Mlo8V7o5pAesjuLbN/QvWhs1dBs+uMF4Oq2ijSJiI=; b=k7LsdE9d+mN6E+bCmkr75hNvEMuPCVhemaSH7obiWHq6O2292GIoC4f67MBIZUbdSnzkXlVYWpLeedreHCLr0co7O7nUjHuP5MJqaLAk0HIOgYJA3JtlZs9yGgBLMhfTQ8mtGSmB04JRcvmpiBTfFfYEGP/Ew66SDvlcDQ8R6hA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631204140243511.52620341642285; Thu, 9 Sep 2021 09:15:40 -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-123-o7pNzAO-PziaiHKx2PF2Eg-1; Thu, 09 Sep 2021 12:15:37 -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 1799018DB8AB; Thu, 9 Sep 2021 16:15:31 +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 85FCA5C25D; Thu, 9 Sep 2021 16:15:30 +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 8EF8E4E58F; Thu, 9 Sep 2021 16:15:29 +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 189GDS6R009984 for ; Thu, 9 Sep 2021 12:13:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5369D4180; Thu, 9 Sep 2021 16:13:28 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D0153E08 for ; Thu, 9 Sep 2021 16:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204139; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=z3Mlo8V7o5pAesjuLbN/QvWhs1dBs+uMF4Oq2ijSJiI=; b=jDGtaNeaCV78VZ0jpsnfIBkXBuC7o7ZmD8FalC0CKWcS+JhWfoK3fK9cyU8fQV1VjOssvs zWR7k0WUFQmT+ICHuHnBHEHZHWdcNeBUgIV5CrGAdn4No7UtGzTHdunGq/fCOsCT7EfaEp SdXaKpOcdz5wi78/bVy+5hOwW3PpDG4= X-MC-Unique: o7pNzAO-PziaiHKx2PF2Eg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 1/7] conf: extract appid validation to virDomainDefResourceAppidValidate Date: Thu, 9 Sep 2021 18:13:17 +0200 Message-Id: <093c9897f08dfb924b35cf6aed6a97c96400516e.1631203909.git.phrdina@redhat.com> In-Reply-To: References: 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: 1631204141981100001 Content-Type: text/plain; charset="utf-8" This will be needed by future patches adding appid API to allow changing it for running VMs. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- src/conf/domain_validate.c | 42 +++++++++++++++++++++++--------------- src/conf/domain_validate.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1bc62c364d..3ab864bbeb 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -58,29 +58,37 @@ virDomainDefBootValidate(const virDomainDef *def) #define APPID_LEN_MIN 1 #define APPID_LEN_MAX 128 =20 +int +virDomainDefResourceAppidValidate(const char *appid) +{ + int len; + + if (!virStringIsPrintable(appid)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Fibre Channel 'appid' is not a printable string"= )); + return -1; + } + + len =3D strlen(appid); + if (len < APPID_LEN_MIN || len > APPID_LEN_MAX) { + virReportError(VIR_ERR_INVALID_ARG, + _("Fibre Channel 'appid' string length must be betw= een [%d, %d]"), + APPID_LEN_MIN, APPID_LEN_MAX); + return -1; + } + + return 0; +} + + static int virDomainDefResourceValidate(const virDomainDef *def) { if (!def->resource) return 0; =20 - if (def->resource->appid) { - int len; - - if (!virStringIsPrintable(def->resource->appid)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Fibre Channel 'appid' is not a printable str= ing")); - return -1; - } - - len =3D strlen(def->resource->appid); - if (len < APPID_LEN_MIN || len > APPID_LEN_MAX) { - virReportError(VIR_ERR_INVALID_ARG, - _("Fibre Channel 'appid' string length must be = between [%d, %d]"), - APPID_LEN_MIN, APPID_LEN_MAX); - return -1; - } - } + if (def->resource->appid) + return virDomainDefResourceAppidValidate(def->resource->appid); =20 return 0; } diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 430d61fd3c..02fc16b17d 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -42,3 +42,5 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *= dev, int virDomainDiskDefValidateSource(const virStorageSource *src); =20 int virDomainDiskDefSourceLUNValidate(const virStorageSource *src); + +int virDomainDefResourceAppidValidate(const char *appid); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2778fe7f8f..d1f5dc2080 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -765,6 +765,7 @@ virDomainConfVMNWFilterTeardown; =20 # conf/domain_validate.h virDomainActualNetDefValidate; +virDomainDefResourceAppidValidate; virDomainDefValidate; virDomainDeviceValidateAliasForHotplug; virDomainDiskDefSourceLUNValidate; --=20 2.31.1 From nobody Fri Apr 19 18:19:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1631204629; cv=none; d=zohomail.com; s=zohoarc; b=aqhveIKLQg8BCJ9PGgTFiReoRnvS6babUI8IBl2kVnXqzHGWm5qK8nV3bvi9hrm4Sr4/fn3IS0iYLvi5g01PpaYYj1g10IM8lgkYDrI/4JXcrvEY4aHAgYGZtFlhQL0GdUpCnCdLmKxkCllLoMwc7cGqAljRs1vz4xfqJg1hyUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204629; h=Content-Type:Content-Transfer-Encoding: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; bh=hwJxd7sQbvfYTuTeopclpJ2kbpTD5VDu8dqdX7g/1QU=; b=PKNhhUEXoTh19PsBClV9ICCYKRKiqkZRBhcgbFkQqvVx1LW8nOFBukTiK62M3ryQboA5APGB6SfwfCcL72z1/SfL9gAuco6xThnISawzODsP4sG9bZG+DdCSAhC6ixH8EyOvgE4kiipM1pMwgi5lsrYteboM99iGdOjD+TUB14U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631204629983841.2670375412695; Thu, 9 Sep 2021 09:23:49 -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-489-2FeNpwZVOIWJXtHGUkrmVQ-1; Thu, 09 Sep 2021 12:23:47 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77E081089667; Thu, 9 Sep 2021 16:22:35 +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 0F52010074EF; Thu, 9 Sep 2021 16:22: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 613541800FE4; Thu, 9 Sep 2021 16:22:33 +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 189GDTVT009991 for ; Thu, 9 Sep 2021 12:13:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3214E1981F; Thu, 9 Sep 2021 16:13:29 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id A69114180 for ; Thu, 9 Sep 2021 16:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204628; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hwJxd7sQbvfYTuTeopclpJ2kbpTD5VDu8dqdX7g/1QU=; b=HkftYWjagzjuwC1Lkpu622LCMq7QSua+GL+wJPXG71lh+mCzLBwMAAb7VpCNkp8yI9JQX1 7YqV1xDQqQhsAQsVvVBe9OhC/upJ/5+E6w5YyNvV2SUiyKDDSEXXb5PeHcz1N+Lv02HmHF kbiL9YuRIgFU7bzMpEddNRT4VvWmD8s= X-MC-Unique: 2FeNpwZVOIWJXtHGUkrmVQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 2/7] cgroup: extract setting fibre channel appid into virCgroupSetFCAppid Date: Thu, 9 Sep 2021 18:13:18 +0200 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1631204631068100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/qemu/qemu_cgroup.c | 17 +---------------- src/util/vircgroup.c | 24 ++++++++++++++++++++++++ src/util/vircgroup.h | 3 +++ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d1f5dc2080..8bb349e7da 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1957,6 +1957,7 @@ virCgroupSetCpusetCpus; virCgroupSetCpusetMemoryMigrate; virCgroupSetCpusetMems; virCgroupSetCpuShares; +virCgroupSetFCAppid; virCgroupSetFreezerState; virCgroupSetMemory; virCgroupSetMemoryHardLimit; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 6d4a82b3cd..9eec9db65c 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -908,27 +908,12 @@ static int qemuSetupCgroupAppid(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; - int inode =3D -1; - const char *path =3D "/sys/class/fc/fc_udev_device/appid_store"; - g_autofree char *appid =3D NULL; virDomainResourceDef *resource =3D vm->def->resource; =20 if (!resource || !resource->appid) return 0; =20 - inode =3D virCgroupGetInode(priv->cgroup); - if (inode < 0) - return -1; - - appid =3D g_strdup_printf("%X:%s", inode, resource->appid); - - if (virFileWriteStr(path, appid, 0) < 0) { - virReportSystemError(errno, - _("Unable to write '%s' to '%s'"), appid, pat= h); - return -1; - } - - return 0; + return virCgroupSetFCAppid(priv->cgroup, resource->appid); } =20 =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 37b63a2e2d..ad0ee20862 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -4012,3 +4012,27 @@ virCgroupGetCpuPeriodQuota(virCgroup *cgroup, unsign= ed long long *period, =20 return 0; } + + +int +virCgroupSetFCAppid(virCgroup *group, + const char *appid) +{ + int inode =3D -1; + const char *path =3D "/sys/class/fc/fc_udev_device/appid_store"; + g_autofree char *vmid =3D NULL; + + inode =3D virCgroupGetInode(group); + if (inode < 0) + return -1; + + vmid =3D g_strdup_printf("%X:%s", inode, appid); + + if (virFileWriteStr(path, vmid, 0) < 0) { + virReportSystemError(errno, + _("Unable to write '%s' to '%s'"), vmid, path= ); + return -1; + } + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 690f09465c..a69b435b71 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -285,3 +285,6 @@ int virCgroupHasEmptyTasks(virCgroup *cgroup, int contr= oller); bool virCgroupControllerAvailable(int controller); =20 int virCgroupGetInode(virCgroup *cgroup); + +int virCgroupSetFCAppid(virCgroup *group, + const char *appid); --=20 2.31.1 From nobody Fri Apr 19 18:19:50 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=1631204231; cv=none; d=zohomail.com; s=zohoarc; b=DcQ7OmrjRCs0huTKYwI4VypOebk/X+/jHp39wm6ihqJyvMgrUFE2mAg1hflcZwvaCsFXrRtN20bCcYZ+3xqd0/D4o6juBLHW7igS3Z0fDoFqfQ6FO90fzRmPG7n6S+Hw3HYIhtZgA6OFPsn8A6y1uFt/219aZsbMygNTu3GdoQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204231; h=Content-Type:Content-Transfer-Encoding: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; bh=hstTmQKq251D5LAWKjM/r1qyS1DyCIU3FJTQ2P9nK1I=; b=kKcqF/wjgzrrdnsgSUBfmZgjTqVfj8neH07DOfwgSSkzphuI6SeXf1mHaf+QjZd757K3qJxxBQZX+q5VBgEzDkiR5g0m6Z42JqgLu7H0YC8RZntF5ZHhERhhx/cuRKLwZ/Rh6kN/Md5MifihT6wWCPC6Mi3xQA9p8BmuqqzfLMY= 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 1631204231344633.7686938286772; Thu, 9 Sep 2021 09:17:11 -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-460-gbIY8u05M9mwpBBPF-Ogig-1; Thu, 09 Sep 2021 12:17:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E1F55074C; Thu, 9 Sep 2021 16:17:03 +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 0C6732C00F; Thu, 9 Sep 2021 16:17:03 +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 CE83C4EA2A; Thu, 9 Sep 2021 16:17:02 +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 189GDULk010001 for ; Thu, 9 Sep 2021 12:13:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11E1B1981F; Thu, 9 Sep 2021 16:13:30 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8510A4180 for ; Thu, 9 Sep 2021 16:13:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204230; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hstTmQKq251D5LAWKjM/r1qyS1DyCIU3FJTQ2P9nK1I=; b=YKFQwk0ztH33FUd+euOi96+TE9EUoqbtPktBF6TcDFcLdm6cTvuupZ2AysRI4fsGKsad7Q 5FiGXHhfKXZX1rH5cX23qmVnXOFgD/8mZ/hdY0WwcOncjoIpdwDS4CISQaH1eOSRyqjXsV Bxk631G5sdZN73Ahp13XlB7j/7bMYys= X-MC-Unique: gbIY8u05M9mwpBBPF-Ogig-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 3/7] virCgroupSetFCAppid: properly handle when appid is NULL Date: Thu, 9 Sep 2021 18:13:19 +0200 Message-Id: <18ae3decd5daf1057c70bd5c693b8f8d920cad8b.1631203909.git.phrdina@redhat.com> In-Reply-To: References: 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.11 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: 1631204233598100001 Content-Type: text/plain; charset="utf-8" With introduction of live changes of appid we should also support removal of the appid from VM. This is done by writing empty appid part to appid_store file. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- src/util/vircgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index ad0ee20862..9470ab061d 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -4026,7 +4026,7 @@ virCgroupSetFCAppid(virCgroup *group, if (inode < 0) return -1; =20 - vmid =3D g_strdup_printf("%X:%s", inode, appid); + vmid =3D g_strdup_printf("%X:%s", inode, appid ? appid : ""); =20 if (virFileWriteStr(path, vmid, 0) < 0) { virReportSystemError(errno, --=20 2.31.1 From nobody Fri Apr 19 18:19:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1631204236; cv=none; d=zohomail.com; s=zohoarc; b=cVMz+r3ERFEuE9Ie/06fxzLZKG5CT4g8gipN/wyB22fDhR6gkMgg9uSKonlViYnayM5qkUvOxE55X3Mq5U1zD/qChNuhgo0g4gAdXfpdsJxlFe+d5dPrHoYt4+6g4yyEbY/PNOmgtitohcKT/bb1iqUEhatGE91F5PkiPZ3TSiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204236; h=Content-Type:Content-Transfer-Encoding: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; bh=zpp5rsVlbw8WFSs0lzfPhl485dZOVqJciRUhFilZsms=; b=ZTY4mG2zKpGwjHmeg8m6YE6Nt3rdUXTcuex2sBdYCjDrwtczYVIkA9T5o4NOljyUovrkIuf/X8a6SPR9r3qr4h22KfVKB2mGstGG75clRAkMLXUXn4UCywKCy4ywdBLxkZNq8iz885Kme3+torCO4Ombe0jkQLxBqP13s4+6Hbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631204236427170.13716223409017; Thu, 9 Sep 2021 09:17:16 -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-455-Al_afa1IMsWueoSaGeicJg-1; Thu, 09 Sep 2021 12:17:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D3D41006AA5; Thu, 9 Sep 2021 16:17:06 +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 3DE536A910; Thu, 9 Sep 2021 16:17:06 +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 0AB4A1801241; Thu, 9 Sep 2021 16:17:06 +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 189GDU5o010009 for ; Thu, 9 Sep 2021 12:13:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id E42D74180; Thu, 9 Sep 2021 16:13:30 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 646A753E08 for ; Thu, 9 Sep 2021 16:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204235; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zpp5rsVlbw8WFSs0lzfPhl485dZOVqJciRUhFilZsms=; b=YJzZn1dp2zxPqcFT3dfMfFgA7JF8ZCLRTHrFq2iikaEDoADVa9nHiZael+nf98OavN6IKM pvipSc5UDprZ8wsa357JQSvA3ZIvVpAOwF3cP+j8qoE/8pbY/vIYqswrr06ysOBXZly4zp M4XGAl8D5sxgks3crwdOtkxJBPJvcnE= X-MC-Unique: Al_afa1IMsWueoSaGeicJg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 4/7] src: introduce virDomainSetFibreChannelAppid API Date: Thu, 9 Sep 2021 18:13:20 +0200 Message-Id: <266eff68d09492dcb5e6795894136b2a64488898.1631203909.git.phrdina@redhat.com> In-Reply-To: References: 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.15 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: 1631204238219100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 6 +++++ src/libvirt-domain.c | 44 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 55 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 7ef8ac51e5..4f7b88ef61 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5153,4 +5153,8 @@ int virDomainStartDirtyRateCalc(virDomainPtr domain, int seconds, unsigned int flags); =20 +int virDomainSetFibreChannelAppid(virDomainPtr domain, + const char *appid, + unsigned int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index d642af8a37..e6b1ceb3ce 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1412,6 +1412,11 @@ typedef int =20 typedef struct _virHypervisorDriver virHypervisorDriver; =20 +typedef int +(*virDrvDomainSetFibreChannelAppid)(virDomainPtr domain, + const char *appid, + unsigned int flags); + /** * _virHypervisorDriver: * @@ -1676,4 +1681,5 @@ struct _virHypervisorDriver { virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; virDrvDomainGetMessages domainGetMessages; virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; + virDrvDomainSetFibreChannelAppid domainSetFibreChannelAppid; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index a8a386e839..f3e6854a39 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13229,3 +13229,47 @@ virDomainStartDirtyRateCalc(virDomainPtr domain, virDispatchError(conn); return -1; } + + +/** + * virDomainSetFibreChannelAppid: + * @domain: a domain object + * @appid: user provided appid string + * @flags: extra flags + * + * Set the Fibre Channel APPID. Accepts only printable characters + * and maximal length is 128 characters. To remove the APPID use + * NULL as @appid value. + * + * Returns 0 in case of success, -1 otherwise. + */ +int +virDomainSetFibreChannelAppid(virDomainPtr domain, + const char *appid, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "appid=3D%s, flags=3D0x%x", appid, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainSetFibreChannelAppid) { + int ret; + ret =3D conn->driver->domainSetFibreChannelAppid(domain, appid, fl= ags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 3a5fa7cb09..912b421632 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -900,6 +900,7 @@ LIBVIRT_7.7.0 { global: virNWFilterDefineXMLFlags; virNetworkDefineXMLFlags; + virDomainSetFibreChannelAppid; } LIBVIRT_7.3.0; =20 # .... define new API here using predicted next version number .... --=20 2.31.1 From nobody Fri Apr 19 18:19:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1631204151; cv=none; d=zohomail.com; s=zohoarc; b=Hp7QnSBA1QWlmsW8C3VO58iKK9MGcIDAfRex5Y/jXZLDjJ+x8MPgMhf7kvuSrKfPO1GOr9U2dIRZAYBVlSxeJzN4ey7Jp7pT7gzwjQDnZ4VJIFYCdhLgvL3zts3T4oDz8UiAMBapAuY7Kbh3OyndKsmJIXff01Da88aK1ev+nU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204151; h=Content-Type:Content-Transfer-Encoding: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; bh=1JD+CK4zZK7X5pp/DsmIUmY5jLq++zw3HOFWWjfmqVM=; b=Q5BewjGh236grrjU6hFQatENmgbK8zHXQ6SLVB6XwN8OC2AIpQpeJuMUf6e1z74wjx8I25pcNkE/IJifG6WYPWGm7hg4v4tzR4ib28Flh4atpGLvRGpNf1CwtSNQSsSa6mR8umI2Ii6uhZ5XV3JqY44Ozi9BXJZ0mIwpPvlejqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631204151353938.5322808254431; Thu, 9 Sep 2021 09:15:51 -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-387-juD_dQGZPt2fnABlY-ZgaA-1; Thu, 09 Sep 2021 12:15:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30D491006AA4; Thu, 9 Sep 2021 16:15: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 0F56060C82; Thu, 9 Sep 2021 16:15:39 +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 D127D4EA29; Thu, 9 Sep 2021 16:15:38 +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 189GDVbN010016 for ; Thu, 9 Sep 2021 12:13:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3ECE1981F; Thu, 9 Sep 2021 16:13:31 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 439D44180 for ; Thu, 9 Sep 2021 16:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204150; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1JD+CK4zZK7X5pp/DsmIUmY5jLq++zw3HOFWWjfmqVM=; b=YrUusUFtnG5iguVim8u70QB7RB2kDgQFKJcEvQ4hbjEGZ88owySHVLgnnbUXhFjoww9gsn JCZLghlnT7+L/LrKYOLXRs0x9Rc1dMZwEBH9kQGC9edZtu+DRBxKnZ5wqAeyFdjE7CF4Ox Z7DnIcvGS8DWE5ugaVRdFkll44bu6qM= X-MC-Unique: juD_dQGZPt2fnABlY-ZgaA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 5/7] remote: add RPC support for the virDomainSetFibreChannelAppid API Date: Thu, 9 Sep 2021 18:13:21 +0200 Message-Id: <72c5226bda8fae97c51fb67532e5804116c253a7.1631203909.git.phrdina@redhat.com> In-Reply-To: References: 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.12 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: 1631204152635100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 14 +++++++++++++- src/remote_protocol-structs | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index b64a86af63..55a0b79f95 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8539,6 +8539,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainAuthorizedSSHKeysSet =3D remoteDomainAuthorizedSSHKeysSet, /* 6= .10.0 */ .domainGetMessages =3D remoteDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ + .domainSetFibreChannelAppid =3D remoteDomainSetFibreChannelAppid, /* 7= .7.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index df1b126b0c..0a64504d45 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3854,6 +3854,12 @@ struct remote_domain_start_dirty_rate_calc_args { unsigned int flags; }; =20 +struct remote_domain_set_fibre_channel_appid_args { + remote_nonnull_domain dom; + remote_string appid; + unsigned int flags; +}; + =20 /*----- Protocol. -----*/ =20 @@ -6818,5 +6824,11 @@ enum remote_procedure { * @acl: network:write * @acl: network:save */ - REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS =3D 432 + REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS =3D 432, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_SET_FIBRE_CHANNEL_APPID =3D 433 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index dad83361fa..731cad112c 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3206,6 +3206,11 @@ struct remote_domain_start_dirty_rate_calc_args { int seconds; u_int flags; }; +struct remote_domain_set_fibre_channel_appid_args { + remote_nonnull_domain dom; + remote_string appid; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3639,4 +3644,5 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_CREATE =3D 430, REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS =3D 431, REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS =3D 432, + REMOTE_PROC_DOMAIN_SET_FIBRE_CHANNEL_APPID =3D 433, }; --=20 2.31.1 From nobody Fri Apr 19 18:19:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1631204236; cv=none; d=zohomail.com; s=zohoarc; b=gjvijhuqzOTVcmLDZUEDAPZAWx+N+ZF8FTvkW7MtJD93XDZS9ZQ7RJzGAq4HJzvpRdsmRzuVkBMAaenaiRmHlGzcNr+hVDTqExN3POsaAN5FXLVzrXOkr9xU0Yj3yXdrvAztjnTavPOmfkAU2ymSrSoLM4u94Gpz/q9vOAKhdGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204236; h=Content-Type:Content-Transfer-Encoding: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; bh=H2E6+gdGphYXk2RGYMUuYQX5IKGYRtKwUz9I1vQBgJE=; b=StvZkj0yOOt829tFwYxSAiG4tvYVjQTwHHykXBA0h3xYgHeVSOk3bA//sqR6k+JT1CJID8UYDACCuem2kwVAdHe+tJDbf1g9aOlusFaR6nFHPhOEljKKNN3v0RdqGzZHIQUlcfF2pnLsmv3VMZpd4kT6VFsZkZCSPE4M8E46eAU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631204236963177.20110641879592; Thu, 9 Sep 2021 09:17:16 -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-277-x7EI7umHPOKgPkUQbKmetQ-1; Thu, 09 Sep 2021 12:17:14 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D565418DB8A7; Thu, 9 Sep 2021 16:17:08 +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 BA1AB1B5C1; Thu, 9 Sep 2021 16:17:08 +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 8A5661805989; Thu, 9 Sep 2021 16:17:08 +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 189GDWKR010029 for ; Thu, 9 Sep 2021 12:13:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id A26591981F; Thu, 9 Sep 2021 16:13:32 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22EBE4180 for ; Thu, 9 Sep 2021 16:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204235; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=H2E6+gdGphYXk2RGYMUuYQX5IKGYRtKwUz9I1vQBgJE=; b=gAWl6JSZF5oCzq0SEkfLSoM1t6CXvlHDAA/sGeKVT0SXcvKhvXeU7jE1t6mRlovZ6ydBn0 v5mlug1+CvVbfomQdyjRtCx4cJFySXmcGPT4LrMu0YM/EITQtrohIOzoc+wbmAOd20wHby QsxEyiGXruowqSYQz7D6nrjtT9tGbQ0= X-MC-Unique: x7EI7umHPOKgPkUQbKmetQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 6/7] qemu: implement virDomainSetFibreChannelAppid API Date: Thu, 9 Sep 2021 18:13:22 +0200 Message-Id: <1bf212d7e9726680faba685d4c25efb028f0e18d.1631203909.git.phrdina@redhat.com> In-Reply-To: References: 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.13 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: 1631204238209100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bd41ddbc3c..872dedeafe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20428,6 +20428,80 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, } =20 =20 +static void +qemuDomainUpdateFibreChannelAppid(virDomainDef *def, + const char *appid) +{ + if (!def->resource) { + def->resource =3D g_new0(virDomainResourceDef, 1); + } else { + g_free(def->resource->appid); + } + + def->resource->appid =3D g_strdup(appid); +} + + +static int +qemuDomainSetFibreChannelAppid(virDomainPtr dom, + const char *appid, + unsigned int flags) +{ + virQEMUDriver *driver =3D dom->conn->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainObj *vm =3D NULL; + virDomainDef *def =3D NULL; + virDomainDef *persistentDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (appid && virDomainDefResourceAppidValidate(appid) < 0) + return -1; + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + goto cleanup; + + if (virDomainSetFibreChannelAppidEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + goto endjob; + + if (def) { + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (virCgroupSetFCAppid(priv->cgroup, appid) < 0) + goto endjob; + + qemuDomainUpdateFibreChannelAppid(def, appid); + + if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) + goto endjob; + } + + if (persistentDef) { + qemuDomainUpdateFibreChannelAppid(persistentDef, appid); + + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) + goto endjob; + } + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -20671,6 +20745,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainAuthorizedSSHKeysSet =3D qemuDomainAuthorizedSSHKeysSet, /* 6.1= 0.0 */ .domainGetMessages =3D qemuDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ + .domainSetFibreChannelAppid =3D qemuDomainSetFibreChannelAppid, /* 7.7= .0 */ }; =20 =20 --=20 2.31.1 From nobody Fri Apr 19 18:19:50 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=1631204627; cv=none; d=zohomail.com; s=zohoarc; b=RNnMVg/WVEOMivxBM1DMm9yFuPyod6SqCR/wpw3H1RBWDmVF5jxdJz5a9OvEAz2qPZSmHeNlRur0sSuUgnIStmkt+bjd/8Zh2JDCEhDtx1mtXx95GCtWdIpKEK/4YqdlyEp1b1zrttVW1751gFE2NGXXPOhc3eB0aKBCOnolqMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631204627; h=Content-Type:Content-Transfer-Encoding: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; bh=wLbRlf3Ibe/AEwytGqzB7Y/GbcfVfla04uAm3ftsYTg=; b=NTUHLwTBxQzyDnnx8iJWMqWOq/qeBa0lW9TaKcwSutNPuthvgFQA64bUey5Mr//9vLcIh2bMfHtGxVuJSLAtiaIr9aDt4IT0FqF3tpwpYUIM7Rih5iYGkZ1RzCKSoDHmfnUNmkJoXGfeVfd3J8JivAJm3d7K4EPh7JsYmjwnG48= 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 1631204627142561.2136656283625; Thu, 9 Sep 2021 09:23:47 -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-480-hUb7kbSyOAGNrOhxiW58VA-1; Thu, 09 Sep 2021 12:23:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D887310919C4; Thu, 9 Sep 2021 16:22:42 +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 B9DA660C04; Thu, 9 Sep 2021 16:22:42 +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 8B4F21800FE4; Thu, 9 Sep 2021 16:22:42 +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 189GDXSs010036 for ; Thu, 9 Sep 2021 12:13:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8109E1981F; Thu, 9 Sep 2021 16:13:33 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 011F84180 for ; Thu, 9 Sep 2021 16:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204626; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wLbRlf3Ibe/AEwytGqzB7Y/GbcfVfla04uAm3ftsYTg=; b=XVVj3g3DbAudrdOjtcTOCAC0L1dnQ8BUKjQFldpLbaUqUuBiKs79XQ6/B5rRS/5f3FxlNY ZKGe5+92FLkmyfs2XE/zz2B+vnyM9273w4UIAOBQbXz47NScrUzLXCpKcrdzQS70uAtuya h+I8BjEGsj7grPI4bsEM0hVs1LpMvXI= X-MC-Unique: hUb7kbSyOAGNrOhxiW58VA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [RFC REPOST 7/7] tools: introduce virsh setappid command Date: Thu, 9 Sep 2021 18:13:23 +0200 Message-Id: <02d427f968e71f876fd16afd52637b7e9fc52dc5.1631203909.git.phrdina@redhat.com> In-Reply-To: References: 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.12 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: 1631204628619100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 14 +++++++++ tools/virsh-domain.c | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 9561b3f59d..36fc94808d 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -4515,6 +4515,20 @@ Output the IP address and port number for the VNC di= splay. If the information is not available the processes will provide an exit code of 1. =20 =20 +setappid +-------- + +**Syntax:** + +:: + + setappid domain appid + +Set the Fibre Channel appid string for domain that is used to create VMID = to +tag the traffic. Accepts only printable characters and maximal length is 1= 28 +characters. To remove the appid from VM don't pass any appid. + + DEVICE COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e5bd1fdd75..07d9c7f954 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -14070,6 +14070,65 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd = *cmd) } =20 =20 +/* + * "setappid" command + */ +static const vshCmdInfo info_setappid[] =3D { + {.name =3D "help", + .data =3D N_("Set domain Fibre Channel appid") + }, + {.name =3D "desc", + .data =3D N_("Set the Fibre Channel appid string for domain that is " + "used to create VMID to tag the traffic. Accepts only " + "printable characters and maximal length is 128 characters= . " + "To remove the appid from VM don't pass any appid.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_setappid[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + VIRSH_COMMON_OPT_DOMAIN_CONFIG, + VIRSH_COMMON_OPT_DOMAIN_LIVE, + VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name =3D "appid", + .type =3D VSH_OT_STRING, + .help =3D N_("User provided appid string"), + }, + {.name =3D NULL} +}; + +static bool +cmdSetAppid(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + bool config =3D vshCommandOptBool(cmd, "config"); + bool live =3D vshCommandOptBool(cmd, "live"); + bool current =3D vshCommandOptBool(cmd, "current"); + const char *appid =3D NULL; + unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; + + VSH_EXCLUSIVE_OPTIONS_VAR(current, live); + VSH_EXCLUSIVE_OPTIONS_VAR(current, config); + + if (config) + flags |=3D VIR_DOMAIN_AFFECT_CONFIG; + if (live) + flags |=3D VIR_DOMAIN_AFFECT_LIVE; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "appid", &appid) < 0) + return false; + + if (virDomainSetFibreChannelAppid(dom, (char *)appid, flags) < 0) + return false; + + return true; +} + + const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", .handler =3D cmdAttachDevice, @@ -14715,5 +14774,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_domdirtyrate_calc, .flags =3D 0 }, + {.name =3D "setappid", + .handler =3D cmdSetAppid, + .opts =3D opts_setappid, + .info =3D info_setappid, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.31.1