From nobody Sun Feb 8 18:49:34 2026 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=1601636154; cv=none; d=zohomail.com; s=zohoarc; b=NeZJfSknNThW0/SSN8qm36mVDoORWCCalw72V/8eTNmRuygtg4Tx/1cQ3ejW24kgTx43j7veJoZNdFSQDn1ojRp6XEbSPj8vsYk0mZ8nxxz4rTAdLOigIo9XCTJoz3Alo15vYEQdXtMRkotlJAGhsHDIwYn6z6UEzYAvA8jlPkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601636154; 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=7dYsx0RU/KOZYllD+LDRU7XRLM8u2foYc3OqGUfOlDQ=; b=iJPSseH5nEgXhT36862xwBPDm5zWlZJw+PS9eRf3sDJf3HXD18HKRwoMouREKW7IivVtu16ifOVrm2zx80Og4soGr35EEqkTyHWNle+WO2Q0s4Rw5MycusdxXPQMOGaM1Q1WckkANrzwlNW9obl1D4B2B3M6knY0NEEP868tUBk= 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 1601636154100463.65115887618595; Fri, 2 Oct 2020 03:55:54 -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-405-OMdMC_aXOkOTD_KjU4eFxA-1; Fri, 02 Oct 2020 06:55:50 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60619191E2BE; Fri, 2 Oct 2020 10:55:41 +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 354F419C66; Fri, 2 Oct 2020 10:55:41 +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 A617F1826D2D; Fri, 2 Oct 2020 10:55:39 +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 092AtcMi030969 for ; Fri, 2 Oct 2020 06:55:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2048E202348A; Fri, 2 Oct 2020 10:55:38 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B1B8200AF70 for ; Fri, 2 Oct 2020 10:55:38 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.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 01D87101A540 for ; Fri, 2 Oct 2020 10:55:38 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-dVt9S3VHPuyN0LCfN9KABA-1; Fri, 02 Oct 2020 06:55:34 -0400 Received: by mail-wr1-f66.google.com with SMTP id k15so1298406wrn.10 for ; Fri, 02 Oct 2020 03:55:34 -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 c14sm1363083wrm.64.2020.10.02.03.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 03:55:32 -0700 (PDT) X-MC-Unique: OMdMC_aXOkOTD_KjU4eFxA-1 X-MC-Unique: dVt9S3VHPuyN0LCfN9KABA-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=7dYsx0RU/KOZYllD+LDRU7XRLM8u2foYc3OqGUfOlDQ=; b=M87pi+eRADCnO5k1494BUIv4C5zHRT7R9+ZMyJ1SWoDK2M86AzD4ZLMEtsTlwb9vT/ MrGXqvOQojCqBA0M1KMvg/8yqaHZv8XnoSpM8TnttRxoo2/zTbYNZ4M8Xk7uJ0j88j1j ktqm2eF3iXZ4FIDJ7II+64qNIT6pHibPYHcFo61iQFn/dC30B2sVczl37qhUISzF05h4 a6BPoBtuIOlvQQYmnIF/PcWC5NN6x9tx56G6cqn5dOKHck4njh1KTBSC5obxhfq11p0p umk60XOITm/k7DemdUG14QiUEQuILBmw8wWmUvHLV1RBhOQX6ZnM4uGOSy6sjAEgWdYN k3Hw== X-Gm-Message-State: AOAM531ijw6bntmhr0yLYlvAy0noAr8hyK/fZhwgYIxUGvAxocXECMs1 nc+wJ8I4I/K8okP6meEdLKkfsWAdueVTEA== X-Google-Smtp-Source: ABdhPJxM+2b7v1UmwYNk0AQrLp4P4ze3zd9KEzgQandqPhsifIpTUpFqBCfmUAH5DLl0VSFBRBhmmQ== X-Received: by 2002:adf:ef03:: with SMTP id e3mr2265910wro.146.1601636133153; Fri, 02 Oct 2020 03:55:33 -0700 (PDT) From: Brian Turek To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: add support for 'fmode' and 'dmode' options Date: Fri, 2 Oct 2020 11:55:02 +0100 Message-Id: <20201002105504.82121-3-brian.turek@gmail.com> In-Reply-To: <20201002105504.82121-1-brian.turek@gmail.com> References: <20201002105504.82121-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.84 on 10.5.11.23 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. QEMU defaults to creating files with mode 600 and directories with mode 700. Signed-off-by: Brian Turek --- src/conf/domain_conf.c | 27 ++++++++ src/conf/domain_conf.h | 2 + src/qemu/qemu_command.c | 6 ++ src/qemu/qemu_validate.c | 18 ++++++ .../virtio-9p-createmode.x86_64-latest.args | 45 ++++++++++++++ .../qemuxml2argvdata/virtio-9p-createmode.xml | 58 ++++++++++++++++++ .../virtio-9p-createmode.x86_64-latest.xml | 61 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 8 files changed, 218 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-late= st.args 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/src/conf/domain_conf.c b/src/conf/domain_conf.c index b80d7c7c6c..b1f3eb71a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11500,6 +11500,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 @@ -11528,6 +11530,24 @@ 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) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid fmode: '%s'"), fmode); + goto error; + } + } + + dmode =3D virXMLPropString(node, "dmode"); + if (dmode) { + if (virStrToLong_uip(dmode, NULL, 8, &def->dmode) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid dmode: '%s'"), dmode); + goto error; + } + } + model =3D virXMLPropString(node, "model"); if (model) { if ((def->model =3D virDomainFSModelTypeFromString(model)) < 0 || @@ -26226,6 +26246,13 @@ virDomainFSDefFormat(virBufferPtr buf, } if (def->multidevs) virBufferAsprintf(buf, " multidevs=3D'%s'", multidevs); + + if (def->fmode) + virBufferAsprintf(buf, " fmode=3D'%03o'", def->fmode); + + if (def->dmode) + virBufferAsprintf(buf, " dmode=3D'%03o'", def->dmode); + virBufferAddLit(buf, ">\n"); =20 virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9a44315519..0f09f723a9 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/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e9ba81d82f..b16e0279f2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2275,6 +2275,12 @@ qemuBuildFSStr(virDomainFSDefPtr fs) } else if (fs->multidevs =3D=3D VIR_DOMAIN_FS_MULTIDEVS_WARN) { virBufferAddLit(&opt, ",multidevs=3Dwarn"); } + if (fs->fmode) { + virBufferAsprintf(&opt, ",fmode=3D%03o", fs->fmode); + } + if (fs->dmode) { + virBufferAsprintf(&opt, ",dmode=3D%03o", fs->dmode); + } } else if (fs->fsdriver =3D=3D VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE) { /* removed since qemu 4.0.0 see v3.1.0-29-g93aee84f57 */ virBufferAddLit(&opt, "handle"); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index a212605579..4757c55e13 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3530,6 +3530,19 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs, return -1; } =20 + if ((fs->fmode !=3D 0) || (fs->dmode !=3D 0)) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV_CREATEMODE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("fmode and dmode are not supported with this QEM= U binary")); + return -1; + } + if (fs->accessmode !=3D VIR_DOMAIN_FS_ACCESSMODE_MAPPED) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("fmode and dmode must be used with accessmode= =3Dmapped")); + return -1; + } + } + switch ((virDomainFSDriverType) fs->fsdriver) { case VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT: case VIR_DOMAIN_FS_DRIVER_TYPE_PATH: @@ -3591,6 +3604,11 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs, _("virtiofs does not support multidevs")); return -1; } + if ((fs->fmode !=3D 0) || (fs->dmode !=3D 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtiofs does not support fmode and dmode")); + return -1; + } if (qemuValidateDomainDefVirtioFSSharedMemory(def) < 0) return -1; break; diff --git a/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args= b/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args new file mode 100644 index 0000000000..5285968ea3 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args @@ -0,0 +1,45 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-cpu qemu64 \ +-m 214 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-fsdev local,security_model=3Dmapped,fmode=3D644,id=3Dfsdev-fs0,path=3D/ex= port/fs0 \ +-device virtio-9p-pci,id=3Dfs0,fsdev=3Dfsdev-fs0,mount_tag=3Dfs0,bus=3Dpci= .0,addr=3D0x2 \ +-fsdev local,security_model=3Dmapped,dmode=3D755,id=3Dfsdev-fs1,path=3D/ex= port/fs1 \ +-device virtio-9p-pci,id=3Dfs1,fsdev=3Dfsdev-fs1,mount_tag=3Dfs1,bus=3Dpci= .0,addr=3D0x3 \ +-fsdev local,security_model=3Dmapped,fmode=3D644,dmode=3D755,id=3Dfsdev-fs= 2,\ +path=3D/export/fs2 \ +-device virtio-9p-pci,id=3Dfs2,fsdev=3Dfsdev-fs2,mount_tag=3Dfs2,bus=3Dpci= .0,addr=3D0x4 \ +-chardev pty,id=3Dcharserial0 \ +-fsdev local,security_model=3Dmapped,id=3Dfsdev-fs3,path=3D/export/fs2 \ +-device virtio-9p-pci,id=3Dfs3,fsdev=3Dfsdev-fs3,mount_tag=3Dfs3,bus=3Dpci= .0,addr=3D0x5 \ +-device isa-serial,chardev=3Dcharserial0,id=3Dserial0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0xc \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/virtio-9p-createmode.xml b/tests/qemuxm= l2argvdata/virtio-9p-createmode.xml new file mode 100644 index 0000000000..bca9db02ad --- /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..a119c0a9a6 --- /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