From nobody Mon Nov 25 14:30: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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602167673; cv=none; d=zohomail.com; s=zohoarc; b=Wz1a/gU5YFMsA+FpoM1MPPJjKtawJr7pmLaz9EF9fFunyt5UT/jS2HPVPcVSU8hT9CxEqIKak0Hg/Q8didPp6BfQQ/H8/25Qea1m44kp5sB+x40bf5lxkM95UP5S7D3nNDlOqNHeoRItCVT1ax81cDwvC8LNQFv+aQyyQnApjWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602167673; 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; bh=RwhOXdk1RNYeoyI56t6rPb8smjwi1e5EgY5ZQQ04XLs=; b=OMEURakombsQ+aLFvcSH2BWmdBZ35mKdo5Wbkqcve+bXrgr/MuslDaFma63Mwx4PAWDk+zVFohLWGFC1TypI6fwbzgeHAvxufPiWZsa/JNetW5Xl37qMItQJpylUlMCtAXCjRVOQQNgxGmc/s+wnlFZmSo0JTzxJiaQzJXa83zk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= 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 1602167673444831.9160808898415; Thu, 8 Oct 2020 07:34:33 -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-523-Q4_X79fTO1W5H9B4jENBcA-1; Thu, 08 Oct 2020 10:34:28 -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 27C6A108A520; Thu, 8 Oct 2020 14:33:54 +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 D3337838C6; Thu, 8 Oct 2020 14:33:53 +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 837448C7BF; Thu, 8 Oct 2020 14:33:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098EXpBe018234 for ; Thu, 8 Oct 2020 10:33:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9385207A644; Thu, 8 Oct 2020 14:33:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3E89207A815 for ; Thu, 8 Oct 2020 14:33:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41BB81805C56 for ; Thu, 8 Oct 2020 14:33:49 +0000 (UTC) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-qaLvLHlnM-6vXiH1xdHr-Q-1; Thu, 08 Oct 2020 10:33:47 -0400 Received: by mail-wr1-f50.google.com with SMTP id e18so6855026wrw.9 for ; Thu, 08 Oct 2020 07:33:46 -0700 (PDT) Received: from localhost.localdomain (cpc75556-harg6-2-0-cust35.7-1.cable.virginm.net. [86.3.36.36]) by smtp.gmail.com with ESMTPSA id h206sm7795719wmf.47.2020.10.08.07.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 07:33:44 -0700 (PDT) X-MC-Unique: Q4_X79fTO1W5H9B4jENBcA-1 X-MC-Unique: qaLvLHlnM-6vXiH1xdHr-Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RwhOXdk1RNYeoyI56t6rPb8smjwi1e5EgY5ZQQ04XLs=; b=I3rUeVIzTBlXz525y18gm6DAUr1tEkXkMpqHMPFHM1x0A2p67bXQVZMn/9e7VMTFnS 9qmnzo7EZAHK+rKJeDQfd0w+cJNgYGx3PAu4crc2bCnvw6u2CpCJXV3debq1Fg5gJpQz Rck3RDU7tlPrgTplMaqikqgQuzwHDe48cwqiPrRhXDDatjG6SKuD1HRqiIhFxnbvu5/E p8ZR6IRMRzmXtzliXCWtlq6zR7YwoZ9nStBil8wC36yRhZDK8j9FYu6o9y4eCcAyw4U7 dBb8mvtjmn1c+5B40EbJB1zq1q8UYscW76huWYwdBKgJqXDNEsFFV7pMLuLqMSewFBXH xy8Q== X-Gm-Message-State: AOAM533tchoaECPhv1oxmlngLf2grDizFhJqXFa1Xe26kGLjUkK1fEGO KUYvEqln0NkZxLx5R6FlXYiSA/toEuDSpg== X-Google-Smtp-Source: ABdhPJxrN+BuJwhIJjYvPEHLWpRjiq5AaGrCRXMOp6jUxnrAaiN8YE9FxBKxIU2VPerUYRDpuTduaQ== X-Received: by 2002:a5d:5543:: with SMTP id g3mr9838149wrw.154.1602167625615; Thu, 08 Oct 2020 07:33:45 -0700 (PDT) From: Brian Turek To: libvir-list@redhat.com Subject: [libvirt PATCH v4 2/4] qemu: add 'fmode' and 'dmode' options Date: Thu, 8 Oct 2020 15:32:24 +0100 Message-Id: <20201008143225.45428-3-brian.turek@gmail.com> In-Reply-To: <20201008143225.45428-1-brian.turek@gmail.com> References: <20201008143225.45428-1-brian.turek@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Brian Turek 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 Content-Type: text/plain; charset="utf-8" Expose QEMU's 9pfs 'fmode' and 'dmode' options via attributes on the 'filesystem' node in the domain XML. These options control the creation mode of files and directories, respectively, when using accessmode=3Dmapped. Signed-off-by: Brian Turek Reviewed-by: J=C3=A1n Tomko --- docs/schemas/domaincommon.rng | 16 +++++ src/conf/domain_conf.c | 29 +++++++++ src/conf/domain_conf.h | 2 + .../qemuxml2argvdata/virtio-9p-createmode.xml | 58 ++++++++++++++++++ .../virtio-9p-createmode.x86_64-latest.xml | 61 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 6 files changed, 167 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-9p-createmode.xml create mode 100644 tests/qemuxml2xmloutdata/virtio-9p-createmode.x86_64-la= test.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 7d4b105981..a0f0eb5a23 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -26,6 +26,12 @@ =20 + + + 0[0-7]{3}|[0-7]{1,3} + + + @@ -2736,6 +2742,16 @@ + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 51efeb0e42..57ca2152ea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11471,6 +11471,8 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *units =3D NULL; g_autofree char *model =3D NULL; g_autofree char *multidevs =3D NULL; + g_autofree char *fmode =3D NULL; + g_autofree char *dmode =3D NULL; =20 ctxt->node =3D node; =20 @@ -11499,6 +11501,26 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlop= t, def->accessmode =3D VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; } =20 + fmode =3D virXMLPropString(node, "fmode"); + if (fmode) { + if ((virStrToLong_uip(fmode, NULL, 8, &def->fmode) < 0) || + (def->fmode > 0777)) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid fmode: '%s'"), fmode); + goto error; + } + } + + dmode =3D virXMLPropString(node, "dmode"); + if (dmode) { + if ((virStrToLong_uip(dmode, NULL, 8, &def->dmode) < 0) || + (def->dmode > 0777)) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid dmode: '%s'"), dmode); + goto error; + } + } + model =3D virXMLPropString(node, "model"); if (model) { if ((def->model =3D virDomainFSModelTypeFromString(model)) < 0 || @@ -26133,6 +26155,13 @@ virDomainFSDefFormat(virBufferPtr buf, } if (def->multidevs) virBufferAsprintf(buf, " multidevs=3D'%s'", multidevs); + + if (def->fmode) + virBufferAsprintf(buf, " fmode=3D'%04o'", def->fmode); + + if (def->dmode) + virBufferAsprintf(buf, " dmode=3D'%04o'", def->dmode); + virBufferAddLit(buf, ">\n"); =20 virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 450686dfb5..51f70f9dd4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -849,6 +849,8 @@ struct _virDomainFSDef { int wrpolicy; /* enum virDomainFSWrpolicy */ int format; /* virStorageFileFormat */ int model; /* virDomainFSModel */ + unsigned int fmode; + unsigned int dmode; int multidevs; /* virDomainFSMultidevs */ unsigned long long usage; /* in bytes */ virStorageSourcePtr src; diff --git a/tests/qemuxml2argvdata/virtio-9p-createmode.xml b/tests/qemuxm= l2argvdata/virtio-9p-createmode.xml new file mode 100644 index 0000000000..032b22a2da --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-9p-createmode.xml @@ -0,0 +1,58 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/virtio-9p-createmode.x86_64-latest.xm= l b/tests/qemuxml2xmloutdata/virtio-9p-createmode.x86_64-latest.xml new file mode 100644 index 0000000000..7c374ca3a6 --- /dev/null +++ b/tests/qemuxml2xmloutdata/virtio-9p-createmode.x86_64-latest.xml @@ -0,0 +1,61 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 2bf8dd5b14..17cbed97f9 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1496,6 +1496,7 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-q35-4.2", "x86_64"); =20 DO_TEST_CAPS_LATEST("virtio-9p-multidevs"); + DO_TEST_CAPS_LATEST("virtio-9p-createmode"); DO_TEST("downscript", NONE); =20 cleanup: --=20 2.25.1