From nobody Mon Nov 25 14:40:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602167686; cv=none; d=zohomail.com; s=zohoarc; b=ES/1nMGekE+PjiswhWNoNvCsQsseixbs4sM5JusbRrnlrBvfvzA7+K5ux+yMC77eE5lQqBWcCQhdZEe7OQYLLD2VEryHjR87eqxVcP6FesYUpO85oTNDUr41k2OW9iiBZAcQ8xT5cCEyhrFu2gNAEVNZyfyksmcec+NmOAI/LMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602167686; 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=zzPWVD7FI0wvTxZ8Cm2UZ+FK+4Y5pvKYZZxSdQ6Z/Q8=; b=Mv0S4j0Q2TiaMSvG/iV6AkRxgeazgzigV8PPgn6y91OGNcAIi8s9Q9H2RBUnUmV1h5Xtnt9K11J4cD2AUyAmMnXuFHwMvnCAExRyngczawro9V/CnjZAJKkh/eLbhuwCB3Cw1IyWb7CcAuADhKs6UOyrTLtU9uI/4FZvWIk63pY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602167686807394.5064834258801; Thu, 8 Oct 2020 07:34:46 -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-568-hy_CWXdsP52aq42pTtGZZw-1; Thu, 08 Oct 2020 10:34:42 -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 957318C350F; Thu, 8 Oct 2020 14:33:56 +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 5FF8C19930; Thu, 8 Oct 2020 14:33:56 +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 EF1951832FC2; Thu, 8 Oct 2020 14:33:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098EXrHL018249 for ; Thu, 8 Oct 2020 10:33:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C22110AF436; Thu, 8 Oct 2020 14:33:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27C8310AF428 for ; Thu, 8 Oct 2020 14:33:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 10BD189FEFE for ; Thu, 8 Oct 2020 14:33:53 +0000 (UTC) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-sAsTpOY-NJ6mWg-5MtOw2g-1; Thu, 08 Oct 2020 10:33:50 -0400 Received: by mail-wr1-f45.google.com with SMTP id n18so6882395wrs.5 for ; Thu, 08 Oct 2020 07:33:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 07:33:48 -0700 (PDT) X-MC-Unique: hy_CWXdsP52aq42pTtGZZw-1 X-MC-Unique: sAsTpOY-NJ6mWg-5MtOw2g-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=zzPWVD7FI0wvTxZ8Cm2UZ+FK+4Y5pvKYZZxSdQ6Z/Q8=; b=cT6bOjbzHw+vzMsPBQ5ZeuSGtO7CjsBvkN7ZgqJPE8lakLDm4wOrITG4ElPAaKgAt2 BqFGzqcbxoJiWNdvjLkLnOeuIqGCleW6xGwhjKr2Wq0aSIa2o0GUf2RcsaM5h1tzQV4e /Z9VSkPiPywFpYLhHs6HrAyicEC5jINWIBzgBFqV8v7hyZV/LHh4VJ9QZ/zBY7O7TLng ryHXabjX7JfnXa84DJ+N6N7oxhM7PzjL2M5ziYRlflY8hKCFV51U3HnVBGpQ0o20havv S/XlivwAU6epUVBnFkR4dt71Rb6GD4e/YHak53GQd79xh9pBqB9Vtgrm/d2h16hP3RjN AWcQ== X-Gm-Message-State: AOAM533V0E0n40sgk7j+nMH4aIjo/PU7DQQJ2D9dZTkAcFz6+TJEJT0Y q0eOGZUPBHpUBv+mWZVCC9pA5uyEeGpJvg== X-Google-Smtp-Source: ABdhPJzu9/yyy58OGsGnozeFXXBJC6s/ZZa/puL4mYDjtu8CX5Nae1+K1RXc0v9YGH85vYI1jlvAWA== X-Received: by 2002:adf:e54b:: with SMTP id z11mr177969wrm.128.1602167628931; Thu, 08 Oct 2020 07:33:48 -0700 (PDT) From: Brian Turek To: libvir-list@redhat.com Subject: [libvirt PATCH v4 3/4] qemu: add support for 'fmode' and 'dmode' Date: Thu, 8 Oct 2020 15:32:25 +0100 Message-Id: <20201008143225.45428-4-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.3 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" Add logic to validate and then pass through 'fmode' and 'dmode' to the QEMU call. Signed-off-by: Brian Turek Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 6 +++ src/qemu/qemu_validate.c | 18 ++++++++ .../virtio-9p-createmode.x86_64-latest.args | 46 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 4 files changed, 71 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-late= st.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9519861e92..6ec34c8690 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%04o", fs->fmode); + } + if (fs->dmode) { + virBufferAsprintf(&opt, ",dmode=3D%04o", 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..601d4d272e --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-9p-createmode.x86_64-latest.args @@ -0,0 +1,46 @@ +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,memory-backend=3Dp= c.ram \ +-cpu qemu64 \ +-m 214 \ +-object memory-backend-ram,id=3Dpc.ram,size=3D224395264 \ +-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=3D0644,id=3Dfsdev-fs0,path=3D/e= xport/fs0 \ +-device virtio-9p-pci,id=3Dfs0,fsdev=3Dfsdev-fs0,mount_tag=3Dfs0,bus=3Dpci= .0,addr=3D0x2 \ +-fsdev local,security_model=3Dmapped,dmode=3D0755,id=3Dfsdev-fs1,path=3D/e= xport/fs1 \ +-device virtio-9p-pci,id=3Dfs1,fsdev=3Dfsdev-fs1,mount_tag=3Dfs1,bus=3Dpci= .0,addr=3D0x3 \ +-fsdev local,security_model=3Dmapped,fmode=3D0640,dmode=3D0750,id=3Dfsdev-= fs2,\ +path=3D/export/fs2 \ +-device virtio-9p-pci,id=3Dfs2,fsdev=3Dfsdev-fs2,mount_tag=3Dfs2,bus=3Dpci= .0,addr=3D0x4 \ +-fsdev local,security_model=3Dmapped,id=3Dfsdev-fs3,path=3D/export/fs3 \ +-device virtio-9p-pci,id=3Dfs3,fsdev=3Dfsdev-fs3,mount_tag=3Dfs3,bus=3Dpci= .0,addr=3D0x5 \ +-chardev pty,id=3Dcharserial0 \ +-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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 49567326d4..0bc8d529c3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3376,6 +3376,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"); =20 if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); --=20 2.25.1