From nobody Sun Nov 24 04:59:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725524640; cv=none; d=zohomail.com; s=zohoarc; b=YlGhXJobjSmjhKoMKRqViiEcXkdG2bcujwaJ5BhDxnmHDorAijHF+NWwSmxXGqDv5/VEJA5iCIMnUtwl2zhI3SvHm3EjV6FLWfYviJeop2UWG0/JnzzexKvwtGB8RUxxr+m/moEF0iLBA5cYeJuxruSWcYIww84NGaAvmNBE2X0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725524640; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P4R+Z9uE2y/WbCCsKGHpbddQSXt1hk+1mrH53ggDBD4=; b=eDg+JLhI6eo31Nuh0MILbBqs91gIB5Kg7Pp3BoMfayPmcgM9jpnCRrJPeOcmuozi4t9qHBFXRZw5Ho3ZN3Vxf0DZCFnvMG2MEiFNJQdn6wAx+LNXiNI2SU/bCFmVgl6pa2bVguWDxVXXdId6Jm8jhllZEdNoMhMLGYBTeVt3NZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725524640108817.190360969517; Thu, 5 Sep 2024 01:24:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sm7lu-00006j-Iv; Thu, 05 Sep 2024 04:23:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sm7ls-00005Y-Hr for qemu-devel@nongnu.org; Thu, 05 Sep 2024 04:23:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sm7ln-0002qM-Fs for qemu-devel@nongnu.org; Thu, 05 Sep 2024 04:23:15 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-hM-wVw9HNnWyXrP91elMrQ-1; Thu, 05 Sep 2024 04:23:07 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-374c35b8e38so248135f8f.2 for ; Thu, 05 Sep 2024 01:23:06 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374bb1ea80csm14603330f8f.73.2024.09.05.01.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 01:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725524588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P4R+Z9uE2y/WbCCsKGHpbddQSXt1hk+1mrH53ggDBD4=; b=Ll8ZDZaR+V/zYmDNmCIrxLArOv5YIZrjNgKOJqwrh9vDHc0mujkfkRiDrp3O3KkDLkxRdU c0Gl50CN6zshkd/AD32/lPtQCCl7vTB4hc64OO/x66MCse0+ODIF+RC0YbBTiCYE+mDoWj d3lucmcEGb1vh9h4eNqXVtOsSFYAd2o= X-MC-Unique: hM-wVw9HNnWyXrP91elMrQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725524585; x=1726129385; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P4R+Z9uE2y/WbCCsKGHpbddQSXt1hk+1mrH53ggDBD4=; b=ELFDcHqK29ktLRJPTN157B/yRkos0YKMyuXIj05ZJIo7BKy7jgFKwVNTHeP8U9q3L5 tKnUMTQk5pUJEBrYdVYxCBgW4Sr19VX5eysLxyUwFJSFMC8i70hw/XVfdnlvoGla+LOv g9S7xgS7Qlf7OWik3B/ihcRJypxCOl58HkTZQOCmFa6dqNMwwAJBPrZZWbMIblTZNkHX snrOAf5dFfyiPiY1RwmD6NBFIIgg0UNooTv0oRTY/neGbNVi4If4PUKgcHUdQNugXG8C DIA7NAWGSKF4XwUzrtqVOjVyBPwSNArsWCHxQwLkBzvHTioAbOAS9S4xSLW6LZxyXpov eJ4Q== X-Gm-Message-State: AOJu0YwT6381BMBsQ2QwFdFNj6ULgfE/0Ao7vJ621NzU9iX0IJ5DTQ/W 6nlRBJ/yXeOJsDoB3yc8FiHOsGy+0BKIdLetRgJW7NC07MfqaIAmoA7in+TFQCY8eBIDgt0blBC inDFyOPUsQOTgKwo08JriL4LT37g/hxj9ADXA7ZfZLgM2lH6jYC3rqWg4xeZytgrBLJs/zfTm7E +KxSqyuey+vnsOc5DKbJoy0u134aI3HtkXYLl37OU= X-Received: by 2002:a5d:5d84:0:b0:375:f59f:221 with SMTP id ffacd0b85a97d-375f59f0293mr4818710f8f.14.1725524584207; Thu, 05 Sep 2024 01:23:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELaAoCEaL0aHM+QzpLAEG9II/yWuw71l/JabWL++5Lfj4BbaDQscjhd4y+6DTqyXSb0D4mQA== X-Received: by 2002:a5d:5d84:0:b0:375:f59f:221 with SMTP id ffacd0b85a97d-375f59f0293mr4818653f8f.14.1725524582574; Thu, 05 Sep 2024 01:23:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: groug@kaod.org Subject: [PATCH] virtio-9p: remove virtfs-proxy-helper Date: Thu, 5 Sep 2024 10:22:59 +0200 Message-ID: <20240905082259.360983-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725524641354116600 Content-Type: text/plain; charset="utf-8" It has been deprecated since 8.1; remove it and suggest using permission ma= pping or virtiofsd. Signed-off-by: Paolo Bonzini Acked-by: Greg Kurz Reviewed-by: Christian Schoenebeck --- MAINTAINERS | 8 - docs/about/deprecated.rst | 23 - docs/about/removed-features.rst | 14 + docs/conf.py | 3 - docs/meson.build | 1 - docs/tools/index.rst | 1 - docs/tools/virtfs-proxy-helper.rst | 75 -- meson.build | 8 - fsdev/qemu-fsdev.h | 1 - fsdev/qemu-fsdev.c | 19 - fsdev/virtfs-proxy-helper.c | 1193 -------------------------- hw/9pfs/9p-proxy.c | 1279 ---------------------------- fsdev/meson.build | 8 - hw/9pfs/meson.build | 1 - meson_options.txt | 2 - qemu-options.hx | 46 - scripts/meson-buildoptions. | 0 scripts/meson-buildoptions.sh | 4 - 18 files changed, 14 insertions(+), 2672 deletions(-) delete mode 100644 docs/tools/virtfs-proxy-helper.rst delete mode 100644 fsdev/virtfs-proxy-helper.c delete mode 100644 hw/9pfs/9p-proxy.c create mode 100644 scripts/meson-buildoptions. diff --git a/MAINTAINERS b/MAINTAINERS index 3584d6a6c6d..13e73987060 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2256,20 +2256,12 @@ S: Maintained W: https://wiki.qemu.org/Documentation/9p F: hw/9pfs/ X: hw/9pfs/xen-9p* -X: hw/9pfs/9p-proxy* F: fsdev/ -X: fsdev/virtfs-proxy-helper.c F: tests/qtest/virtio-9p-test.c F: tests/qtest/libqos/virtio-9p* T: git https://gitlab.com/gkurz/qemu.git 9p-next T: git https://github.com/cschoenebeck/qemu.git 9p.next =20 -virtio-9p-proxy -F: hw/9pfs/9p-proxy* -F: fsdev/virtfs-proxy-helper.c -F: docs/tools/virtfs-proxy-helper.rst -S: Obsolete - virtio-blk M: Stefan Hajnoczi L: qemu-block@nongnu.org diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index be62fa06c29..d45dc4fe62f 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -316,29 +316,6 @@ the addition of volatile memory support, it is now nec= essary to distinguish between persistent and volatile memory backends. As such, memdev is depre= cated in favor of persistent-memdev. =20 -``-fsdev proxy`` and ``-virtfs proxy`` (since 8.1) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The 9p ``proxy`` filesystem backend driver has been deprecated and will be -removed (along with its proxy helper daemon) in a future version of QEMU. = Please -use ``-fsdev local`` or ``-virtfs local`` for using the 9p ``local`` files= ystem -backend, or alternatively consider deploying virtiofsd instead. - -The 9p ``proxy`` backend was originally developed as an alternative to the= 9p -``local`` backend. The idea was to enhance security by dispatching actual = low -level filesystem operations from 9p server (QEMU process) over to a separa= te -process (the virtfs-proxy-helper binary). However this alternative never g= ained -momentum. The proxy backend is much slower than the local backend, hasn't = seen -any development in years, and showed to be less secure, especially due to = the -fact that its helper daemon must be run as root, whereas with the local ba= ckend -QEMU is typically run as unprivileged user and allows to tighten behaviour= by -mapping permissions et al by using its 'mapped' security model option. - -Nowadays it would make sense to reimplement the ``proxy`` backend by using -QEMU's ``vhost`` feature, which would eliminate the high latency costs und= er -which the 9p ``proxy`` backend currently suffers. However as of to date no= body -has indicated plans for such kind of reimplementation unfortunately. - RISC-V 'any' CPU type ``-cpu any`` (since 8.2) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ =20 diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 5ae730d02ae..41d3affabfc 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -517,6 +517,20 @@ The virtio-blk SCSI passthrough feature is a legacy VI= RTIO feature. VIRTIO 1.0 and later do not support it because the virtio-scsi device was introduced = for full SCSI support. Use virtio-scsi instead when SCSI passthrough is requi= red. =20 +``-fsdev proxy`` and ``-virtfs proxy`` (since 9.2) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The 9p ``proxy`` filesystem backend driver was originally developed to +enhance security by dispatching low level filesystem operations from 9p +server (QEMU process) over to a separate process (the virtfs-proxy-helper +binary). However the proxy backend was much slower than the local backend, +didn't see any development in years, and showed to be less secure, +especially due to the fact that its helper daemon must be run as root. + +Use ``local``, possibly mapping permissions et al by using its 'mapped' +security model option, or switch to ``virtiofs``. The virtiofs daemon +``virtiofsd`` uses vhost to eliminate the high latency costs of the 9p +``proxy`` backend. =20 User-mode emulator command line arguments ----------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index 876f6768815..c11a6ead8a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -275,9 +275,6 @@ ('tools/qemu-trace-stap', 'qemu-trace-stap', 'QEMU SystemTap trace tool', [], 1), - ('tools/virtfs-proxy-helper', 'virtfs-proxy-helper', - 'QEMU 9p virtfs proxy filesystem helper', - ['M. Mohan Kumar'], 1), ] man_make_section_directory =3D False =20 diff --git a/docs/meson.build b/docs/meson.build index 322452c8778..3676f81c4d3 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -54,7 +54,6 @@ if build_docs 'qemu-pr-helper.8': (have_tools ? 'man8' : ''), 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''), 'qemu-trace-stap.1': (stap.found() ? 'man1' : ''), - 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''), 'qemu.1': 'man1', 'qemu-block-drivers.7': 'man7', 'qemu-cpu-models.7': 'man7' diff --git a/docs/tools/index.rst b/docs/tools/index.rst index 33ad438e86f..1e88ae48cdc 100644 --- a/docs/tools/index.rst +++ b/docs/tools/index.rst @@ -15,5 +15,4 @@ command line utilities and other standalone programs. qemu-nbd qemu-pr-helper qemu-trace-stap - virtfs-proxy-helper qemu-vmsr-helper diff --git a/docs/tools/virtfs-proxy-helper.rst b/docs/tools/virtfs-proxy-h= elper.rst deleted file mode 100644 index bd310ebb07b..00000000000 --- a/docs/tools/virtfs-proxy-helper.rst +++ /dev/null @@ -1,75 +0,0 @@ -QEMU 9p virtfs proxy filesystem helper -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -Synopsis --------- - -**virtfs-proxy-helper** [*OPTIONS*] - -Description ------------ - -NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be -removed, along with this daemon, in a future version of QEMU! - -Pass-through security model in QEMU 9p server needs root privilege to do -few file operations (like chown, chmod to any mode/uid:gid). There are two -issues in pass-through security model: - -- TOCTTOU vulnerability: Following symbolic links in the server could - provide access to files beyond 9p export path. - -- Running QEMU with root privilege could be a security issue. - -To overcome above issues, following approach is used: A new filesystem -type 'proxy' is introduced. Proxy FS uses chroot + socket combination -for securing the vulnerability known with following symbolic links. -Intention of adding a new filesystem type is to allow qemu to run -in non-root mode, but doing privileged operations using socket IO. - -Proxy helper (a stand alone binary part of qemu) is invoked with -root privileges. Proxy helper chroots into 9p export path and creates -a socket pair or a named socket based on the command line parameter. -QEMU and proxy helper communicate using this socket. QEMU proxy fs -driver sends filesystem request to proxy helper and receives the -response from it. - -The proxy helper is designed so that it can drop root privileges except -for the capabilities needed for doing filesystem operations. - -Options -------- - -The following options are supported: - -.. program:: virtfs-proxy-helper - -.. option:: -h - - Display help and exit - -.. option:: -p, --path PATH - - Path to export for proxy filesystem driver - -.. option:: -f, --fd SOCKET_ID - - Use given file descriptor as socket descriptor for communicating with - qemu proxy fs drier. Usually a helper like libvirt will create - socketpair and pass one of the fds as parameter to this option. - -.. option:: -s, --socket SOCKET_FILE - - Creates named socket file for communicating with qemu proxy fs driver - -.. option:: -u, --uid UID - - uid to give access to named socket file; used in combination with -g. - -.. option:: -g, --gid GID - - gid to give access to named socket file; used in combination with -u. - -.. option:: -n, --nodaemon - - Run as a normal program. By default program will run in daemon mode diff --git a/meson.build b/meson.build index fbda17c987e..56eef434782 100644 --- a/meson.build +++ b/meson.build @@ -2197,13 +2197,6 @@ have_virtfs =3D get_option('virtfs') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() =20 -have_virtfs_proxy_helper =3D get_option('virtfs_proxy_helper') \ - .require(host_os !=3D 'darwin', error_message: 'the virtfs proxy helpe= r is incompatible with macOS') \ - .require(have_virtfs, error_message: 'the virtfs proxy helper requires= that virtfs is enabled') \ - .disable_auto_if(not have_tools) \ - .require(libcap_ng.found(), error_message: 'the virtfs proxy helper re= quires libcap-ng') \ - .allowed() - qga_fsfreeze =3D false qga_fstrim =3D false if host_os =3D=3D 'linux' @@ -4397,7 +4390,6 @@ if have_block summary_info +=3D {'Block whitelist (ro)': get_option('block_drv_ro_whit= elist')} summary_info +=3D {'Use block whitelist in tools': get_option('block_drv= _whitelist_in_tools')} summary_info +=3D {'VirtFS (9P) support': have_virtfs} - summary_info +=3D {'VirtFS (9P) Proxy Helper support (deprecated)': have= _virtfs_proxy_helper} summary_info +=3D {'replication support': config_host_data.get('CONFIG_R= EPLICATION')} summary_info +=3D {'bochs support': get_option('bochs').allowed()} summary_info +=3D {'cloop support': get_option('cloop').allowed()} diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index 52a53977701..731f1406a81 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -18,5 +18,4 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp); FsDriverEntry *get_fsdev_fsentry(char *id); extern FileOperations local_ops; extern FileOperations synth_ops; -extern FileOperations proxy_ops; #endif diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index f5c953a7105..57877dad0a7 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -89,17 +89,6 @@ static FsDriverTable FsDrivers[] =3D { NULL }, }, - { - .name =3D "proxy", - .ops =3D &proxy_ops, - .opts =3D (const char * []) { - COMMON_FS_DRIVER_OPTIONS, - "socket", - "sock_fd", - "writeout", - NULL - }, - }, }; =20 static int validate_opt(void *opaque, const char *name, const char *value, @@ -133,14 +122,6 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp) } =20 if (fsdriver) { - if (strncmp(fsdriver, "proxy", 5) =3D=3D 0) { - warn_report( - "'-fsdev proxy' and '-virtfs proxy' are deprecated, use " - "'local' instead of 'proxy, or consider deploying virtiofs= d " - "as alternative to 9p" - ); - } - for (i =3D 0; i < ARRAY_SIZE(FsDrivers); i++) { if (strcmp(FsDrivers[i].name, fsdriver) =3D=3D 0) { break; diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c deleted file mode 100644 index 144aaf585ad..00000000000 --- a/fsdev/virtfs-proxy-helper.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* - * Helper for QEMU Proxy FS Driver - * Copyright IBM, Corp. 2011 - * - * Authors: - * M. Mohan Kumar - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -/* - * NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be - * removed in a future version of QEMU! - */ - -#include "qemu/osdep.h" -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_LINUX_MAGIC_H -#include -#endif -#include -#include "qemu/sockets.h" -#include "qemu/xattr.h" -#include "9p-iov-marshal.h" -#include "hw/9pfs/9p-proxy.h" -#include "hw/9pfs/9p-util.h" -#include "fsdev/9p-iov-marshal.h" - -#define PROGNAME "virtfs-proxy-helper" - -#ifndef XFS_SUPER_MAGIC -#define XFS_SUPER_MAGIC 0x58465342 -#endif -#ifndef EXT2_SUPER_MAGIC -#define EXT2_SUPER_MAGIC 0xEF53 -#endif -#ifndef REISERFS_SUPER_MAGIC -#define REISERFS_SUPER_MAGIC 0x52654973 -#endif -#ifndef BTRFS_SUPER_MAGIC -#define BTRFS_SUPER_MAGIC 0x9123683E -#endif - -static const struct option helper_opts[] =3D { - {"fd", required_argument, NULL, 'f'}, - {"path", required_argument, NULL, 'p'}, - {"nodaemon", no_argument, NULL, 'n'}, - {"socket", required_argument, NULL, 's'}, - {"uid", required_argument, NULL, 'u'}, - {"gid", required_argument, NULL, 'g'}, - {}, -}; - -static bool is_daemon; -static bool get_version; /* IOC getversion IOCTL supported */ -static char *prog_name; - -static void G_GNUC_PRINTF(2, 3) do_log(int loglevel, const char *format, .= ..) -{ - va_list ap; - - va_start(ap, format); - if (is_daemon) { - vsyslog(LOG_CRIT, format, ap); - } else { - vfprintf(stderr, format, ap); - } - va_end(ap); -} - -static void do_perror(const char *string) -{ - if (is_daemon) { - syslog(LOG_CRIT, "%s:%s", string, strerror(errno)); - } else { - fprintf(stderr, "%s:%s\n", string, strerror(errno)); - } -} - -static int init_capabilities(void) -{ - /* helper needs following capabilities only */ - int cap_list[] =3D { - CAP_CHOWN, - CAP_DAC_OVERRIDE, - CAP_FOWNER, - CAP_FSETID, - CAP_SETGID, - CAP_MKNOD, - CAP_SETUID, - }; - int i; - - capng_clear(CAPNG_SELECT_BOTH); - for (i =3D 0; i < ARRAY_SIZE(cap_list); i++) { - if (capng_update(CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, - cap_list[i]) < 0) { - do_perror("capng_update"); - return -1; - } - } - if (capng_apply(CAPNG_SELECT_BOTH) < 0) { - do_perror("capng_apply"); - return -1; - } - - /* Prepare effective set for setugid. */ - for (i =3D 0; i < ARRAY_SIZE(cap_list); i++) { - if (cap_list[i] =3D=3D CAP_DAC_OVERRIDE) { - continue; - } - - if (capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, - cap_list[i]) < 0) { - do_perror("capng_update"); - return -1; - } - } - return 0; -} - -static int socket_read(int sockfd, void *buff, ssize_t size) -{ - ssize_t retval, total =3D 0; - - while (size) { - retval =3D read(sockfd, buff, size); - if (retval =3D=3D 0) { - return -EIO; - } - if (retval < 0) { - if (errno =3D=3D EINTR) { - continue; - } - return -errno; - } - size -=3D retval; - buff +=3D retval; - total +=3D retval; - } - return total; -} - -static int socket_write(int sockfd, void *buff, ssize_t size) -{ - ssize_t retval, total =3D 0; - - while (size) { - retval =3D write(sockfd, buff, size); - if (retval < 0) { - if (errno =3D=3D EINTR) { - continue; - } - return -errno; - } - size -=3D retval; - buff +=3D retval; - total +=3D retval; - } - return total; -} - -static int read_request(int sockfd, struct iovec *iovec, ProxyHeader *head= er) -{ - int retval; - - /* - * read the request header. - */ - iovec->iov_len =3D 0; - retval =3D socket_read(sockfd, iovec->iov_base, PROXY_HDR_SZ); - if (retval < 0) { - return retval; - } - iovec->iov_len =3D PROXY_HDR_SZ; - retval =3D proxy_unmarshal(iovec, 0, "dd", &header->type, &header->siz= e); - if (retval < 0) { - return retval; - } - /* - * We can't process message.size > PROXY_MAX_IO_SZ. - * Treat it as fatal error - */ - if (header->size > PROXY_MAX_IO_SZ) { - return -ENOBUFS; - } - retval =3D socket_read(sockfd, iovec->iov_base + PROXY_HDR_SZ, header-= >size); - if (retval < 0) { - return retval; - } - iovec->iov_len +=3D header->size; - return 0; -} - -static int send_fd(int sockfd, int fd) -{ - struct msghdr msg; - struct iovec iov; - int retval, data; - struct cmsghdr *cmsg; - union MsgControl msg_control; - - iov.iov_base =3D &data; - iov.iov_len =3D sizeof(data); - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov =3D &iov; - msg.msg_iovlen =3D 1; - /* No ancillary data on error */ - if (fd < 0) { - /* fd is really negative errno if the request failed */ - data =3D fd; - } else { - data =3D V9FS_FD_VALID; - msg.msg_control =3D &msg_control; - msg.msg_controllen =3D sizeof(msg_control); - - cmsg =3D &msg_control.cmsg; - cmsg->cmsg_len =3D CMSG_LEN(sizeof(fd)); - cmsg->cmsg_level =3D SOL_SOCKET; - cmsg->cmsg_type =3D SCM_RIGHTS; - memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); - } - - do { - retval =3D sendmsg(sockfd, &msg, 0); - } while (retval < 0 && errno =3D=3D EINTR); - if (fd >=3D 0) { - close(fd); - } - if (retval < 0) { - return retval; - } - return 0; -} - -static int send_status(int sockfd, struct iovec *iovec, int status) -{ - ProxyHeader header; - int retval, msg_size; - - if (status < 0) { - header.type =3D T_ERROR; - } else { - header.type =3D T_SUCCESS; - } - header.size =3D sizeof(status); - /* - * marshal the return status. We don't check error. - * because we are sure we have enough space for the status - */ - msg_size =3D proxy_marshal(iovec, 0, "ddd", header.type, - header.size, status); - if (msg_size < 0) { - return msg_size; - } - retval =3D socket_write(sockfd, iovec->iov_base, msg_size); - if (retval < 0) { - return retval; - } - return 0; -} - -/* - * from man 7 capabilities, section - * Effect of User ID Changes on Capabilities: - * If the effective user ID is changed from nonzero to 0, then the permitt= ed - * set is copied to the effective set. If the effective user ID is changed - * from 0 to nonzero, then all capabilities are are cleared from the effec= tive - * set. - * - * The setfsuid/setfsgid man pages warn that changing the effective user I= D may - * expose the program to unwanted signals, but this is not true anymore: f= or an - * unprivileged (without CAP_KILL) program to send a signal, the real or - * effective user ID of the sending process must equal the real or saved u= ser - * ID of the target process. Even when dropping privileges, it is enough = to - * keep the saved UID to a "privileged" value and virtfs-proxy-helper won't - * be exposed to signals. So just use setresuid/setresgid. - */ -static int setugid(int uid, int gid, int *suid, int *sgid) -{ - int retval; - - *suid =3D geteuid(); - *sgid =3D getegid(); - - if (setresgid(-1, gid, *sgid) =3D=3D -1) { - return -errno; - } - - if (setresuid(-1, uid, *suid) =3D=3D -1) { - retval =3D -errno; - goto err_sgid; - } - - if (uid =3D=3D 0 && gid =3D=3D 0) { - /* Linux has already copied the permitted set to the effective set= . */ - return 0; - } - - /* - * All capabilities have been cleared from the effective set. However - * we still need DAC_OVERRIDE because we don't change supplementary - * group ids, and hence may be subject to DAC rules. init_capabilities - * left the set of capabilities that we want in libcap-ng's state. - */ - if (capng_apply(CAPNG_SELECT_CAPS) < 0) { - retval =3D -errno; - do_perror("capng_apply"); - goto err_suid; - } - return 0; - -err_suid: - if (setresuid(-1, *suid, *suid) =3D=3D -1) { - abort(); - } -err_sgid: - if (setresgid(-1, *sgid, *sgid) =3D=3D -1) { - abort(); - } - return retval; -} - -/* - * This is used to reset the ugid back with the saved values - * There is nothing much we can do checking error values here. - */ -static void resetugid(int suid, int sgid) -{ - if (setresgid(-1, sgid, sgid) =3D=3D -1) { - abort(); - } - if (setresuid(-1, suid, suid) =3D=3D -1) { - abort(); - } -} - -/* - * Open regular file or directory. Attempts to open any special file are - * rejected. - * - * returns file descriptor or -1 on error - */ -static int open_regular(const char *pathname, int flags, mode_t mode) -{ - int fd; - - fd =3D open(pathname, flags, mode); - if (fd < 0) { - return fd; - } - - if (close_if_special_file(fd) < 0) { - return -1; - } - - return fd; -} - -/* - * send response in two parts - * 1) ProxyHeader - * 2) Response or error status - * This function should be called with marshaled response - * send_response constructs header part and error part only. - * send response sends {ProxyHeader,Response} if the request was success - * otherwise sends {ProxyHeader,error status} - */ -static int send_response(int sock, struct iovec *iovec, int size) -{ - int retval; - ProxyHeader header; - - /* - * If response size exceeds available iovec->iov_len, - * we return ENOBUFS - */ - if (size > PROXY_MAX_IO_SZ) { - size =3D -ENOBUFS; - } - - if (size < 0) { - /* - * In case of error we would not have got the error encoded - * already so encode the error here. - */ - header.type =3D T_ERROR; - header.size =3D sizeof(size); - proxy_marshal(iovec, PROXY_HDR_SZ, "d", size); - } else { - header.type =3D T_SUCCESS; - header.size =3D size; - } - proxy_marshal(iovec, 0, "dd", header.type, header.size); - retval =3D socket_write(sock, iovec->iov_base, header.size + PROXY_HDR= _SZ); - if (retval < 0) { - return retval; - } - return 0; -} - -/* - * gets generation number - * returns -errno on failure and sizeof(generation number) on success - */ -static int do_getversion(struct iovec *iovec, struct iovec *out_iovec) -{ - uint64_t version; - int retval =3D -ENOTTY; -#ifdef FS_IOC_GETVERSION - int fd; - V9fsString path; -#endif - - - /* no need to issue ioctl */ - if (!get_version) { - version =3D 0; - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "q", version); - return retval; - } -#ifdef FS_IOC_GETVERSION - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "s", &path); - if (retval < 0) { - return retval; - } - - fd =3D open(path.data, O_RDONLY); - if (fd < 0) { - retval =3D -errno; - goto err_out; - } - if (ioctl(fd, FS_IOC_GETVERSION, &version) < 0) { - retval =3D -errno; - } else { - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "q", version); - } - close(fd); -err_out: - v9fs_string_free(&path); -#endif - return retval; -} - -static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_io= vec) -{ - int size =3D 0, offset, retval; - V9fsString path, name, xattr; - - v9fs_string_init(&xattr); - v9fs_string_init(&path); - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "ds", &size, &path); - if (retval < 0) { - return retval; - } - offset =3D PROXY_HDR_SZ + retval; - - if (size) { - xattr.data =3D g_malloc(size); - xattr.size =3D size; - } - switch (type) { - case T_LGETXATTR: - v9fs_string_init(&name); - retval =3D proxy_unmarshal(iovec, offset, "s", &name); - if (retval > 0) { - retval =3D lgetxattr(path.data, name.data, xattr.data, size); - if (retval < 0) { - retval =3D -errno; - } else { - xattr.size =3D retval; - } - } - v9fs_string_free(&name); - break; - case T_LLISTXATTR: - retval =3D llistxattr(path.data, xattr.data, size); - if (retval < 0) { - retval =3D -errno; - } else { - xattr.size =3D retval; - } - break; - } - if (retval < 0) { - goto err_out; - } - - if (!size) { - proxy_marshal(out_iovec, PROXY_HDR_SZ, "d", retval); - retval =3D sizeof(retval); - } else { - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &xattr); - } -err_out: - v9fs_string_free(&xattr); - v9fs_string_free(&path); - return retval; -} - -static void stat_to_prstat(ProxyStat *pr_stat, struct stat *stat) -{ - memset(pr_stat, 0, sizeof(*pr_stat)); - pr_stat->st_dev =3D stat->st_dev; - pr_stat->st_ino =3D stat->st_ino; - pr_stat->st_nlink =3D stat->st_nlink; - pr_stat->st_mode =3D stat->st_mode; - pr_stat->st_uid =3D stat->st_uid; - pr_stat->st_gid =3D stat->st_gid; - pr_stat->st_rdev =3D stat->st_rdev; - pr_stat->st_size =3D stat->st_size; - pr_stat->st_blksize =3D stat->st_blksize; - pr_stat->st_blocks =3D stat->st_blocks; - pr_stat->st_atim_sec =3D stat->st_atim.tv_sec; - pr_stat->st_atim_nsec =3D stat->st_atim.tv_nsec; - pr_stat->st_mtim_sec =3D stat->st_mtim.tv_sec; - pr_stat->st_mtim_nsec =3D stat->st_mtim.tv_nsec; - pr_stat->st_ctim_sec =3D stat->st_ctim.tv_sec; - pr_stat->st_ctim_nsec =3D stat->st_ctim.tv_nsec; -} - -static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, struct statfs *stfs) -{ - memset(pr_stfs, 0, sizeof(*pr_stfs)); - pr_stfs->f_type =3D stfs->f_type; - pr_stfs->f_bsize =3D stfs->f_bsize; - pr_stfs->f_blocks =3D stfs->f_blocks; - pr_stfs->f_bfree =3D stfs->f_bfree; - pr_stfs->f_bavail =3D stfs->f_bavail; - pr_stfs->f_files =3D stfs->f_files; - pr_stfs->f_ffree =3D stfs->f_ffree; - pr_stfs->f_fsid[0] =3D stfs->f_fsid.__val[0]; - pr_stfs->f_fsid[1] =3D stfs->f_fsid.__val[1]; - pr_stfs->f_namelen =3D stfs->f_namelen; - pr_stfs->f_frsize =3D stfs->f_frsize; -} - -/* - * Gets stat/statfs information and packs in out_iovec structure - * on success returns number of bytes packed in out_iovec structure - * otherwise returns -errno - */ -static int do_stat(int type, struct iovec *iovec, struct iovec *out_iovec) -{ - int retval; - V9fsString path; - ProxyStat pr_stat; - ProxyStatFS pr_stfs; - struct stat st_buf; - struct statfs stfs_buf; - - v9fs_string_init(&path); - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "s", &path); - if (retval < 0) { - return retval; - } - - switch (type) { - case T_LSTAT: - retval =3D lstat(path.data, &st_buf); - if (retval < 0) { - retval =3D -errno; - } else { - stat_to_prstat(&pr_stat, &st_buf); - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, - "qqqdddqqqqqqqqqq", pr_stat.st_dev, - pr_stat.st_ino, pr_stat.st_nlink, - pr_stat.st_mode, pr_stat.st_uid, - pr_stat.st_gid, pr_stat.st_rdev, - pr_stat.st_size, pr_stat.st_blksize, - pr_stat.st_blocks, - pr_stat.st_atim_sec, pr_stat.st_atim_ns= ec, - pr_stat.st_mtim_sec, pr_stat.st_mtim_ns= ec, - pr_stat.st_ctim_sec, pr_stat.st_ctim_ns= ec); - } - break; - case T_STATFS: - retval =3D statfs(path.data, &stfs_buf); - if (retval < 0) { - retval =3D -errno; - } else { - statfs_to_prstatfs(&pr_stfs, &stfs_buf); - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, - "qqqqqqqqqqq", pr_stfs.f_type, - pr_stfs.f_bsize, pr_stfs.f_blocks, - pr_stfs.f_bfree, pr_stfs.f_bavail, - pr_stfs.f_files, pr_stfs.f_ffree, - pr_stfs.f_fsid[0], pr_stfs.f_fsid[1], - pr_stfs.f_namelen, pr_stfs.f_frsize); - } - break; - } - v9fs_string_free(&path); - return retval; -} - -static int do_readlink(struct iovec *iovec, struct iovec *out_iovec) -{ - char *buffer; - int size, retval; - V9fsString target, path; - - v9fs_string_init(&path); - retval =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &size); - if (retval < 0) { - v9fs_string_free(&path); - return retval; - } - buffer =3D g_malloc(size); - v9fs_string_init(&target); - retval =3D readlink(path.data, buffer, size - 1); - if (retval > 0) { - buffer[retval] =3D '\0'; - v9fs_string_sprintf(&target, "%s", buffer); - retval =3D proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &target); - } else { - retval =3D -errno; - } - g_free(buffer); - v9fs_string_free(&target); - v9fs_string_free(&path); - return retval; -} - -/* - * create other filesystem objects and send 0 on success - * return -errno on error - */ -static int do_create_others(int type, struct iovec *iovec) -{ - dev_t rdev; - int retval =3D 0; - int offset =3D PROXY_HDR_SZ; - V9fsString oldpath, path; - int mode, uid, gid, cur_uid, cur_gid; - - v9fs_string_init(&path); - v9fs_string_init(&oldpath); - - retval =3D proxy_unmarshal(iovec, offset, "dd", &uid, &gid); - if (retval < 0) { - return retval; - } - offset +=3D retval; - retval =3D setugid(uid, gid, &cur_uid, &cur_gid); - if (retval < 0) { - goto unmarshal_err_out; - } - switch (type) { - case T_MKNOD: - retval =3D proxy_unmarshal(iovec, offset, "sdq", &path, &mode, &rd= ev); - if (retval < 0) { - goto err_out; - } - retval =3D mknod(path.data, mode, rdev); - break; - case T_MKDIR: - retval =3D proxy_unmarshal(iovec, offset, "sd", &path, &mode); - if (retval < 0) { - goto err_out; - } - retval =3D g_mkdir(path.data, mode); - break; - case T_SYMLINK: - retval =3D proxy_unmarshal(iovec, offset, "ss", &oldpath, &path); - if (retval < 0) { - goto err_out; - } - retval =3D symlink(oldpath.data, path.data); - break; - } - if (retval < 0) { - retval =3D -errno; - } - -err_out: - resetugid(cur_uid, cur_gid); -unmarshal_err_out: - v9fs_string_free(&path); - v9fs_string_free(&oldpath); - return retval; -} - -/* - * create a file and send fd on success - * return -errno on error - */ -static int do_create(struct iovec *iovec) -{ - int ret; - V9fsString path; - int flags, mode, uid, gid, cur_uid, cur_gid; - - v9fs_string_init(&path); - ret =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "sdddd", - &path, &flags, &mode, &uid, &gid); - if (ret < 0) { - goto unmarshal_err_out; - } - ret =3D setugid(uid, gid, &cur_uid, &cur_gid); - if (ret < 0) { - goto unmarshal_err_out; - } - ret =3D open_regular(path.data, flags, mode); - if (ret < 0) { - ret =3D -errno; - } - - resetugid(cur_uid, cur_gid); -unmarshal_err_out: - v9fs_string_free(&path); - return ret; -} - -/* - * open a file and send fd on success - * return -errno on error - */ -static int do_open(struct iovec *iovec) -{ - int flags, ret; - V9fsString path; - - v9fs_string_init(&path); - ret =3D proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &flags); - if (ret < 0) { - goto err_out; - } - ret =3D open_regular(path.data, flags, 0); - if (ret < 0) { - ret =3D -errno; - } -err_out: - v9fs_string_free(&path); - return ret; -} - -/* create unix domain socket and return the descriptor */ -static int proxy_socket(const char *path, uid_t uid, gid_t gid) -{ - int sock, client; - struct sockaddr_un proxy, qemu; - socklen_t size; - - /* requested socket already exists, refuse to start */ - if (!access(path, F_OK)) { - do_log(LOG_CRIT, "socket already exists\n"); - return -1; - } - - if (strlen(path) >=3D sizeof(proxy.sun_path)) { - do_log(LOG_CRIT, "UNIX domain socket path exceeds %zu characters\n= ", - sizeof(proxy.sun_path)); - return -1; - } - - sock =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) { - do_perror("socket"); - return -1; - } - - /* mask other part of mode bits */ - umask(7); - - proxy.sun_family =3D AF_UNIX; - strcpy(proxy.sun_path, path); - if (bind(sock, (struct sockaddr *)&proxy, - sizeof(struct sockaddr_un)) < 0) { - do_perror("bind"); - goto error; - } - if (chown(proxy.sun_path, uid, gid) < 0) { - do_perror("chown"); - goto error; - } - if (listen(sock, 1) < 0) { - do_perror("listen"); - goto error; - } - - size =3D sizeof(qemu); - client =3D accept(sock, (struct sockaddr *)&qemu, &size); - if (client < 0) { - do_perror("accept"); - goto error; - } - close(sock); - return client; - -error: - close(sock); - return -1; -} - -static void usage(void) -{ - fprintf(stderr, "usage: %s\n" - " -p|--path 9p path to export\n" - " {-f|--fd } socket file descriptor to be u= sed\n" - " {-s|--socket socket file used for communication= \n" - " \t-u|--uid -g|--gid } - uid:gid combination to gi= ve " - " access to this socket\n" - " \tNote: -s & -f can not be used together\n" - " [-n|--nodaemon] Run as a normal program\n", - prog_name); -} - -static int process_reply(int sock, int type, - struct iovec *out_iovec, int retval) -{ - switch (type) { - case T_OPEN: - case T_CREATE: - if (send_fd(sock, retval) < 0) { - return -1; - } - break; - case T_MKNOD: - case T_MKDIR: - case T_SYMLINK: - case T_LINK: - case T_CHMOD: - case T_CHOWN: - case T_TRUNCATE: - case T_UTIME: - case T_RENAME: - case T_REMOVE: - case T_LSETXATTR: - case T_LREMOVEXATTR: - if (send_status(sock, out_iovec, retval) < 0) { - return -1; - } - break; - case T_LSTAT: - case T_STATFS: - case T_READLINK: - case T_LGETXATTR: - case T_LLISTXATTR: - case T_GETVERSION: - if (send_response(sock, out_iovec, retval) < 0) { - return -1; - } - break; - default: - return -1; - break; - } - return 0; -} - -static int process_requests(int sock) -{ - int flags; - int size =3D 0; - int retval =3D 0; - uint64_t offset; - ProxyHeader header; - int mode, uid, gid; - V9fsString name, value; - struct timespec spec[2]; - V9fsString oldpath, path; - struct iovec in_iovec, out_iovec; - - in_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - in_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - out_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - out_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - - while (1) { - /* - * initialize the header type, so that we send - * response to proper request type. - */ - header.type =3D 0; - retval =3D read_request(sock, &in_iovec, &header); - if (retval < 0) { - goto err_out; - } - - switch (header.type) { - case T_OPEN: - retval =3D do_open(&in_iovec); - break; - case T_CREATE: - retval =3D do_create(&in_iovec); - break; - case T_MKNOD: - case T_MKDIR: - case T_SYMLINK: - retval =3D do_create_others(header.type, &in_iovec); - break; - case T_LINK: - v9fs_string_init(&path); - v9fs_string_init(&oldpath); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, - "ss", &oldpath, &path); - if (retval > 0) { - retval =3D link(oldpath.data, path.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&oldpath); - v9fs_string_free(&path); - break; - case T_LSTAT: - case T_STATFS: - retval =3D do_stat(header.type, &in_iovec, &out_iovec); - break; - case T_READLINK: - retval =3D do_readlink(&in_iovec, &out_iovec); - break; - case T_CHMOD: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, - "sd", &path, &mode); - if (retval > 0) { - retval =3D chmod(path.data, mode); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_CHOWN: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sdd", &pa= th, - &uid, &gid); - if (retval > 0) { - retval =3D lchown(path.data, uid, gid); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_TRUNCATE: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sq", - &path, &offset); - if (retval > 0) { - retval =3D truncate(path.data, offset); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_UTIME: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sqqqq", &= path, - &spec[0].tv_sec, &spec[0].tv_nsec, - &spec[1].tv_sec, &spec[1].tv_nsec); - if (retval > 0) { - retval =3D utimensat(AT_FDCWD, path.data, spec, - AT_SYMLINK_NOFOLLOW); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_RENAME: - v9fs_string_init(&path); - v9fs_string_init(&oldpath); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, - "ss", &oldpath, &path); - if (retval > 0) { - retval =3D rename(oldpath.data, path.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&oldpath); - v9fs_string_free(&path); - break; - case T_REMOVE: - v9fs_string_init(&path); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "s", &path= ); - if (retval > 0) { - retval =3D remove(path.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - break; - case T_LGETXATTR: - case T_LLISTXATTR: - retval =3D do_getxattr(header.type, &in_iovec, &out_iovec); - break; - case T_LSETXATTR: - v9fs_string_init(&path); - v9fs_string_init(&name); - v9fs_string_init(&value); - retval =3D proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &= path, - &name, &value, &size, &flags); - if (retval > 0) { - retval =3D lsetxattr(path.data, - name.data, value.data, size, flags); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - v9fs_string_free(&name); - v9fs_string_free(&value); - break; - case T_LREMOVEXATTR: - v9fs_string_init(&path); - v9fs_string_init(&name); - retval =3D proxy_unmarshal(&in_iovec, - PROXY_HDR_SZ, "ss", &path, &name); - if (retval > 0) { - retval =3D lremovexattr(path.data, name.data); - if (retval < 0) { - retval =3D -errno; - } - } - v9fs_string_free(&path); - v9fs_string_free(&name); - break; - case T_GETVERSION: - retval =3D do_getversion(&in_iovec, &out_iovec); - break; - default: - goto err_out; - break; - } - - if (process_reply(sock, header.type, &out_iovec, retval) < 0) { - goto err_out; - } - } -err_out: - g_free(in_iovec.iov_base); - g_free(out_iovec.iov_base); - return -1; -} - -int main(int argc, char **argv) -{ - int sock; - uid_t own_u; - gid_t own_g; - char *rpath =3D NULL; - char *sock_name =3D NULL; - struct stat stbuf; - int c, option_index; -#ifdef FS_IOC_GETVERSION - int retval; - struct statfs st_fs; -#endif - - fprintf(stderr, "NOTE: The 9p 'proxy' backend is deprecated (since " - "QEMU 8.1) and will be removed in a future version of " - "QEMU!\n"); - - prog_name =3D g_path_get_basename(argv[0]); - - is_daemon =3D true; - sock =3D -1; - own_u =3D own_g =3D -1; - while (1) { - option_index =3D 0; - c =3D getopt_long(argc, argv, "p:nh?f:s:u:g:", helper_opts, - &option_index); - if (c =3D=3D -1) { - break; - } - switch (c) { - case 'p': - rpath =3D g_strdup(optarg); - break; - case 'n': - is_daemon =3D false; - break; - case 'f': - sock =3D atoi(optarg); - break; - case 's': - sock_name =3D g_strdup(optarg); - break; - case 'u': - own_u =3D atoi(optarg); - break; - case 'g': - own_g =3D atoi(optarg); - break; - case '?': - case 'h': - default: - usage(); - exit(EXIT_FAILURE); - } - } - - /* Parameter validation */ - if ((sock_name =3D=3D NULL && sock =3D=3D -1) || rpath =3D=3D NULL) { - fprintf(stderr, "socket, socket descriptor or path not specified\n= "); - usage(); - return -1; - } - - if (sock_name && sock !=3D -1) { - fprintf(stderr, "both named socket and socket descriptor specified= \n"); - usage(); - exit(EXIT_FAILURE); - } - - if (sock_name && (own_u =3D=3D -1 || own_g =3D=3D -1)) { - fprintf(stderr, "owner uid:gid not specified, "); - fprintf(stderr, - "owner uid:gid specifies who can access the socket file\n"= ); - usage(); - exit(EXIT_FAILURE); - } - - if (lstat(rpath, &stbuf) < 0) { - fprintf(stderr, "invalid path \"%s\" specified, %s\n", - rpath, strerror(errno)); - exit(EXIT_FAILURE); - } - - if (!S_ISDIR(stbuf.st_mode)) { - fprintf(stderr, "specified path \"%s\" is not directory\n", rpath); - exit(EXIT_FAILURE); - } - - if (is_daemon) { - if (daemon(0, 0) < 0) { - fprintf(stderr, "daemon call failed\n"); - exit(EXIT_FAILURE); - } - openlog(PROGNAME, LOG_PID, LOG_DAEMON); - } - - do_log(LOG_INFO, "Started\n"); - if (sock_name) { - sock =3D proxy_socket(sock_name, own_u, own_g); - if (sock < 0) { - goto error; - } - } - - if (chroot(rpath) < 0) { - do_perror("chroot"); - goto error; - } - if (chdir("/") < 0) { - do_perror("chdir"); - goto error; - } - - get_version =3D false; -#ifdef FS_IOC_GETVERSION - /* check whether underlying FS support IOC_GETVERSION */ - retval =3D statfs("/", &st_fs); - if (!retval) { - switch (st_fs.f_type) { - case EXT2_SUPER_MAGIC: - case BTRFS_SUPER_MAGIC: - case REISERFS_SUPER_MAGIC: - case XFS_SUPER_MAGIC: - get_version =3D true; - break; - } - } -#endif - - umask(0); - if (init_capabilities() < 0) { - goto error; - } - - process_requests(sock); -error: - g_free(rpath); - g_free(sock_name); - do_log(LOG_INFO, "Done\n"); - closelog(); - return 0; -} diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c deleted file mode 100644 index 7aac49ad4ad..00000000000 --- a/hw/9pfs/9p-proxy.c +++ /dev/null @@ -1,1279 +0,0 @@ -/* - * 9p Proxy callback - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * M. Mohan Kumar - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -/* - * Not so fast! You might want to read the 9p developer docs first: - * https://wiki.qemu.org/Documentation/9p - */ - -/* - * NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be - * removed in a future version of QEMU! - */ - -#include "qemu/osdep.h" -#include -#include -#include "9p.h" -#include "qapi/error.h" -#include "qemu/cutils.h" -#include "qemu/error-report.h" -#include "qemu/option.h" -#include "fsdev/qemu-fsdev.h" -#include "9p-proxy.h" - -typedef struct V9fsProxy { - int sockfd; - QemuMutex mutex; - struct iovec in_iovec; - struct iovec out_iovec; -} V9fsProxy; - -/* - * Return received file descriptor on success in *status. - * errno is also returned on *status (which will be < 0) - * return < 0 on transport error. - */ -static int v9fs_receivefd(int sockfd, int *status) -{ - struct iovec iov; - struct msghdr msg; - struct cmsghdr *cmsg; - int retval, data, fd; - union MsgControl msg_control; - - iov.iov_base =3D &data; - iov.iov_len =3D sizeof(data); - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov =3D &iov; - msg.msg_iovlen =3D 1; - msg.msg_control =3D &msg_control; - msg.msg_controllen =3D sizeof(msg_control); - - do { - retval =3D recvmsg(sockfd, &msg, 0); - } while (retval < 0 && errno =3D=3D EINTR); - if (retval <=3D 0) { - return retval; - } - /* - * data is set to V9FS_FD_VALID, if ancillary data is sent. If this - * request doesn't need ancillary data (fd) or an error occurred, - * data is set to negative errno value. - */ - if (data !=3D V9FS_FD_VALID) { - *status =3D data; - return 0; - } - /* - * File descriptor (fd) is sent in the ancillary data. Check if we - * indeed received it. One of the reasons to fail to receive it is if - * we exceeded the maximum number of file descriptors! - */ - for (cmsg =3D CMSG_FIRSTHDR(&msg); cmsg; cmsg =3D CMSG_NXTHDR(&msg, cm= sg)) { - if (cmsg->cmsg_len !=3D CMSG_LEN(sizeof(int)) || - cmsg->cmsg_level !=3D SOL_SOCKET || - cmsg->cmsg_type !=3D SCM_RIGHTS) { - continue; - } - fd =3D *((int *)CMSG_DATA(cmsg)); - *status =3D fd; - return 0; - } - *status =3D -ENFILE; /* Ancillary data sent but not received */ - return 0; -} - -static ssize_t socket_read(int sockfd, void *buff, size_t size) -{ - ssize_t retval, total =3D 0; - - while (size) { - retval =3D read(sockfd, buff, size); - if (retval =3D=3D 0) { - return -EIO; - } - if (retval < 0) { - if (errno =3D=3D EINTR) { - continue; - } - return -errno; - } - size -=3D retval; - buff +=3D retval; - total +=3D retval; - } - return total; -} - -/* Converts proxy_statfs to VFS statfs structure */ -static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs) -{ - memset(stfs, 0, sizeof(*stfs)); - stfs->f_type =3D prstfs->f_type; - stfs->f_bsize =3D prstfs->f_bsize; - stfs->f_blocks =3D prstfs->f_blocks; - stfs->f_bfree =3D prstfs->f_bfree; - stfs->f_bavail =3D prstfs->f_bavail; - stfs->f_files =3D prstfs->f_files; - stfs->f_ffree =3D prstfs->f_ffree; -#ifdef CONFIG_DARWIN - /* f_namelen and f_frsize do not exist on Darwin */ - stfs->f_fsid.val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; - stfs->f_fsid.val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; -#else - stfs->f_fsid.__val[0] =3D prstfs->f_fsid[0] & 0xFFFFFFFFU; - stfs->f_fsid.__val[1] =3D prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; - stfs->f_namelen =3D prstfs->f_namelen; - stfs->f_frsize =3D prstfs->f_frsize; -#endif -} - -/* Converts proxy_stat structure to VFS stat structure */ -static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) -{ - memset(stbuf, 0, sizeof(*stbuf)); - stbuf->st_dev =3D prstat->st_dev; - stbuf->st_ino =3D prstat->st_ino; - stbuf->st_nlink =3D prstat->st_nlink; - stbuf->st_mode =3D prstat->st_mode; - stbuf->st_uid =3D prstat->st_uid; - stbuf->st_gid =3D prstat->st_gid; - stbuf->st_rdev =3D prstat->st_rdev; - stbuf->st_size =3D prstat->st_size; - stbuf->st_blksize =3D prstat->st_blksize; - stbuf->st_blocks =3D prstat->st_blocks; - stbuf->st_atime =3D prstat->st_atim_sec; - stbuf->st_mtime =3D prstat->st_mtim_sec; - stbuf->st_ctime =3D prstat->st_ctim_sec; -#ifdef CONFIG_DARWIN - stbuf->st_atimespec.tv_sec =3D prstat->st_atim_sec; - stbuf->st_mtimespec.tv_sec =3D prstat->st_mtim_sec; - stbuf->st_ctimespec.tv_sec =3D prstat->st_ctim_sec; - stbuf->st_atimespec.tv_nsec =3D prstat->st_atim_nsec; - stbuf->st_mtimespec.tv_nsec =3D prstat->st_mtim_nsec; - stbuf->st_ctimespec.tv_nsec =3D prstat->st_ctim_nsec; -#else - stbuf->st_atim.tv_sec =3D prstat->st_atim_sec; - stbuf->st_mtim.tv_sec =3D prstat->st_mtim_sec; - stbuf->st_ctim.tv_sec =3D prstat->st_ctim_sec; - stbuf->st_atim.tv_nsec =3D prstat->st_atim_nsec; - stbuf->st_mtim.tv_nsec =3D prstat->st_mtim_nsec; - stbuf->st_ctim.tv_nsec =3D prstat->st_ctim_nsec; -#endif -} - -/* - * Response contains two parts - * {header, data} - * header.type =3D=3D T_ERROR, data -> -errno - * header.type =3D=3D T_SUCCESS, data -> response - * size of errno/response is given by header.size - * returns < 0, on transport error. response is - * valid only if status >=3D 0. - */ -static int v9fs_receive_response(V9fsProxy *proxy, int type, - int *status, void *response) -{ - int retval; - ProxyHeader header; - struct iovec *reply =3D &proxy->in_iovec; - - *status =3D 0; - reply->iov_len =3D 0; - retval =3D socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); - if (retval < 0) { - return retval; - } - reply->iov_len =3D PROXY_HDR_SZ; - retval =3D proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); - assert(retval =3D=3D 4 * 2); - /* - * if response size > PROXY_MAX_IO_SZ, read the response but ignore it= and - * return -ENOBUFS - */ - if (header.size > PROXY_MAX_IO_SZ) { - int count; - while (header.size > 0) { - count =3D MIN(PROXY_MAX_IO_SZ, header.size); - count =3D socket_read(proxy->sockfd, reply->iov_base, count); - if (count < 0) { - return count; - } - header.size -=3D count; - } - *status =3D -ENOBUFS; - return 0; - } - - retval =3D socket_read(proxy->sockfd, - reply->iov_base + PROXY_HDR_SZ, header.size); - if (retval < 0) { - return retval; - } - reply->iov_len +=3D header.size; - /* there was an error during processing request */ - if (header.type =3D=3D T_ERROR) { - int ret; - ret =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); - assert(ret =3D=3D 4); - return 0; - } - - switch (type) { - case T_LSTAT: { - ProxyStat prstat; - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, - "qqqdddqqqqqqqqqq", &prstat.st_dev, - &prstat.st_ino, &prstat.st_nlink, - &prstat.st_mode, &prstat.st_uid, - &prstat.st_gid, &prstat.st_rdev, - &prstat.st_size, &prstat.st_blksize, - &prstat.st_blocks, - &prstat.st_atim_sec, &prstat.st_atim_nsec, - &prstat.st_mtim_sec, &prstat.st_mtim_nsec, - &prstat.st_ctim_sec, &prstat.st_ctim_nsec= ); - assert(retval =3D=3D 8 * 3 + 4 * 3 + 8 * 10); - prstat_to_stat(response, &prstat); - break; - } - case T_STATFS: { - ProxyStatFS prstfs; - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, - "qqqqqqqqqqq", &prstfs.f_type, - &prstfs.f_bsize, &prstfs.f_blocks, - &prstfs.f_bfree, &prstfs.f_bavail, - &prstfs.f_files, &prstfs.f_ffree, - &prstfs.f_fsid[0], &prstfs.f_fsid[1], - &prstfs.f_namelen, &prstfs.f_frsize); - assert(retval =3D=3D 8 * 11); - prstatfs_to_statfs(response, &prstfs); - break; - } - case T_READLINK: { - V9fsString target; - v9fs_string_init(&target); - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &target); - strcpy(response, target.data); - v9fs_string_free(&target); - break; - } - case T_LGETXATTR: - case T_LLISTXATTR: { - V9fsString xattr; - v9fs_string_init(&xattr); - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &xattr); - memcpy(response, xattr.data, xattr.size); - v9fs_string_free(&xattr); - break; - } - case T_GETVERSION: - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "q", response); - assert(retval =3D=3D 8); - break; - default: - return -1; - } - if (retval < 0) { - *status =3D retval; - } - return 0; -} - -/* - * return < 0 on transport error. - * *status is valid only if return >=3D 0 - */ -static int v9fs_receive_status(V9fsProxy *proxy, - struct iovec *reply, int *status) -{ - int retval; - ProxyHeader header; - - *status =3D 0; - reply->iov_len =3D 0; - retval =3D socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ); - if (retval < 0) { - return retval; - } - reply->iov_len =3D PROXY_HDR_SZ; - retval =3D proxy_unmarshal(reply, 0, "dd", &header.type, &header.size); - assert(retval =3D=3D 4 * 2); - retval =3D socket_read(proxy->sockfd, - reply->iov_base + PROXY_HDR_SZ, header.size); - if (retval < 0) { - return retval; - } - reply->iov_len +=3D header.size; - retval =3D proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status); - assert(retval =3D=3D 4); - return 0; -} - -/* - * Proxy->header and proxy->request written to socket by QEMU process. - * This request read by proxy helper process - * returns 0 on success and -errno on error - */ -static int v9fs_request(V9fsProxy *proxy, int type, void *response, ...) -{ - dev_t rdev; - va_list ap; - int size =3D 0; - int retval =3D 0; - uint64_t offset; - ProxyHeader header =3D { 0, 0}; - struct timespec spec[2]; - int flags, mode, uid, gid; - V9fsString *name, *value; - V9fsString *path, *oldpath; - struct iovec *iovec =3D NULL, *reply =3D NULL; - - qemu_mutex_lock(&proxy->mutex); - - if (proxy->sockfd =3D=3D -1) { - retval =3D -EIO; - goto err_out; - } - iovec =3D &proxy->out_iovec; - reply =3D &proxy->in_iovec; - va_start(ap, response); - switch (type) { - case T_OPEN: - path =3D va_arg(ap, V9fsString *); - flags =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, flags); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_OPEN; - } - break; - case T_CREATE: - path =3D va_arg(ap, V9fsString *); - flags =3D va_arg(ap, int); - mode =3D va_arg(ap, int); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sdddd", path, - flags, mode, uid, gid); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_CREATE; - } - break; - case T_MKNOD: - path =3D va_arg(ap, V9fsString *); - mode =3D va_arg(ap, int); - rdev =3D va_arg(ap, long int); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ddsdq", - uid, gid, path, mode, rdev); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_MKNOD; - } - break; - case T_MKDIR: - path =3D va_arg(ap, V9fsString *); - mode =3D va_arg(ap, int); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ddsd", - uid, gid, path, mode); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_MKDIR; - } - break; - case T_SYMLINK: - oldpath =3D va_arg(ap, V9fsString *); - path =3D va_arg(ap, V9fsString *); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ddss", - uid, gid, oldpath, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_SYMLINK; - } - break; - case T_LINK: - oldpath =3D va_arg(ap, V9fsString *); - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ss", - oldpath, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LINK; - } - break; - case T_LSTAT: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LSTAT; - } - break; - case T_READLINK: - path =3D va_arg(ap, V9fsString *); - size =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, size); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_READLINK; - } - break; - case T_STATFS: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_STATFS; - } - break; - case T_CHMOD: - path =3D va_arg(ap, V9fsString *); - mode =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, mode); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_CHMOD; - } - break; - case T_CHOWN: - path =3D va_arg(ap, V9fsString *); - uid =3D va_arg(ap, int); - gid =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sdd", path, uid, gi= d); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_CHOWN; - } - break; - case T_TRUNCATE: - path =3D va_arg(ap, V9fsString *); - offset =3D va_arg(ap, uint64_t); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sq", path, offset); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_TRUNCATE; - } - break; - case T_UTIME: - path =3D va_arg(ap, V9fsString *); - spec[0].tv_sec =3D va_arg(ap, long); - spec[0].tv_nsec =3D va_arg(ap, long); - spec[1].tv_sec =3D va_arg(ap, long); - spec[1].tv_nsec =3D va_arg(ap, long); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sqqqq", path, - spec[0].tv_sec, spec[1].tv_nsec, - spec[1].tv_sec, spec[1].tv_nsec); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_UTIME; - } - break; - case T_RENAME: - oldpath =3D va_arg(ap, V9fsString *); - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ss", oldpath, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_RENAME; - } - break; - case T_REMOVE: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_REMOVE; - } - break; - case T_LGETXATTR: - size =3D va_arg(ap, int); - path =3D va_arg(ap, V9fsString *); - name =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, - "dss", size, path, name); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LGETXATTR; - } - break; - case T_LLISTXATTR: - size =3D va_arg(ap, int); - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ds", size, path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LLISTXATTR; - } - break; - case T_LSETXATTR: - path =3D va_arg(ap, V9fsString *); - name =3D va_arg(ap, V9fsString *); - value =3D va_arg(ap, V9fsString *); - size =3D va_arg(ap, int); - flags =3D va_arg(ap, int); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "sssdd", - path, name, value, size, flags); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LSETXATTR; - } - break; - case T_LREMOVEXATTR: - path =3D va_arg(ap, V9fsString *); - name =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "ss", path, name); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_LREMOVEXATTR; - } - break; - case T_GETVERSION: - path =3D va_arg(ap, V9fsString *); - retval =3D proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); - if (retval > 0) { - header.size =3D retval; - header.type =3D T_GETVERSION; - } - break; - default: - error_report("Invalid type %d", type); - retval =3D -EINVAL; - break; - } - va_end(ap); - - if (retval < 0) { - goto err_out; - } - - /* marshal the header details */ - retval =3D proxy_marshal(iovec, 0, "dd", header.type, header.size); - assert(retval =3D=3D 4 * 2); - header.size +=3D PROXY_HDR_SZ; - - retval =3D qemu_write_full(proxy->sockfd, iovec->iov_base, header.size= ); - if (retval !=3D header.size) { - goto close_error; - } - - switch (type) { - case T_OPEN: - case T_CREATE: - /* - * A file descriptor is returned as response for - * T_OPEN,T_CREATE on success - */ - if (v9fs_receivefd(proxy->sockfd, &retval) < 0) { - goto close_error; - } - break; - case T_MKNOD: - case T_MKDIR: - case T_SYMLINK: - case T_LINK: - case T_CHMOD: - case T_CHOWN: - case T_RENAME: - case T_TRUNCATE: - case T_UTIME: - case T_REMOVE: - case T_LSETXATTR: - case T_LREMOVEXATTR: - if (v9fs_receive_status(proxy, reply, &retval) < 0) { - goto close_error; - } - break; - case T_LSTAT: - case T_READLINK: - case T_STATFS: - case T_GETVERSION: - if (v9fs_receive_response(proxy, type, &retval, response) < 0) { - goto close_error; - } - break; - case T_LGETXATTR: - case T_LLISTXATTR: - if (!size) { - if (v9fs_receive_status(proxy, reply, &retval) < 0) { - goto close_error; - } - } else { - if (v9fs_receive_response(proxy, type, &retval, response) < 0)= { - goto close_error; - } - } - break; - } - -err_out: - qemu_mutex_unlock(&proxy->mutex); - return retval; - -close_error: - close(proxy->sockfd); - proxy->sockfd =3D -1; - qemu_mutex_unlock(&proxy->mutex); - return -EIO; -} - -static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *= stbuf) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_LSTAT, stbuf, fs_path); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return retval; -} - -static ssize_t proxy_readlink(FsContext *fs_ctx, V9fsPath *fs_path, - char *buf, size_t bufsz) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_READLINK, buf, fs_path, buf= sz); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return strlen(buf); -} - -static int proxy_close(FsContext *ctx, V9fsFidOpenState *fs) -{ - return close(fs->fd); -} - -static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs) -{ - return closedir(fs->dir.stream); -} - -static int proxy_open(FsContext *ctx, V9fsPath *fs_path, - int flags, V9fsFidOpenState *fs) -{ - fs->fd =3D v9fs_request(ctx->private, T_OPEN, NULL, fs_path, flags); - if (fs->fd < 0) { - errno =3D -fs->fd; - fs->fd =3D -1; - } - return fs->fd; -} - -static int proxy_opendir(FsContext *ctx, - V9fsPath *fs_path, V9fsFidOpenState *fs) -{ - int serrno, fd; - - fs->dir.stream =3D NULL; - fd =3D v9fs_request(ctx->private, T_OPEN, NULL, fs_path, O_DIRECTORY); - if (fd < 0) { - errno =3D -fd; - return -1; - } - fs->dir.stream =3D fdopendir(fd); - if (!fs->dir.stream) { - serrno =3D errno; - close(fd); - errno =3D serrno; - return -1; - } - return 0; -} - -static void proxy_rewinddir(FsContext *ctx, V9fsFidOpenState *fs) -{ - rewinddir(fs->dir.stream); -} - -static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) -{ - return telldir(fs->dir.stream); -} - -static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) -{ - struct dirent *entry; - entry =3D readdir(fs->dir.stream); -#ifdef CONFIG_DARWIN - if (!entry) { - return NULL; - } - int td; - td =3D telldir(fs->dir.stream); - /* If telldir fails, fail the entire readdir call */ - if (td < 0) { - return NULL; - } - entry->d_seekoff =3D td; -#endif - return entry; -} - -static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) -{ - seekdir(fs->dir.stream, off); -} - -static ssize_t proxy_preadv(FsContext *ctx, V9fsFidOpenState *fs, - const struct iovec *iov, - int iovcnt, off_t offset) -{ - ssize_t ret; -#ifdef CONFIG_PREADV - ret =3D preadv(fs->fd, iov, iovcnt, offset); -#else - ret =3D lseek(fs->fd, offset, SEEK_SET); - if (ret >=3D 0) { - ret =3D readv(fs->fd, iov, iovcnt); - } -#endif - return ret; -} - -static ssize_t proxy_pwritev(FsContext *ctx, V9fsFidOpenState *fs, - const struct iovec *iov, - int iovcnt, off_t offset) -{ - ssize_t ret; - -#ifdef CONFIG_PREADV - ret =3D pwritev(fs->fd, iov, iovcnt, offset); -#else - ret =3D lseek(fs->fd, offset, SEEK_SET); - if (ret >=3D 0) { - ret =3D writev(fs->fd, iov, iovcnt); - } -#endif -#ifdef CONFIG_SYNC_FILE_RANGE - if (ret > 0 && ctx->export_flags & V9FS_IMMEDIATE_WRITEOUT) { - /* - * Initiate a writeback. This is not a data integrity sync. - * We want to ensure that we don't leave dirty pages in the cache - * after write when writeout=3Dimmediate is specified. - */ - sync_file_range(fs->fd, offset, ret, - SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRIT= E); - } -#endif - return ret; -} - -static int proxy_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_CHMOD, NULL, fs_path, - credp->fc_mode); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_mknod(FsContext *fs_ctx, V9fsPath *dir_path, - const char *name, FsCred *credp) -{ - int retval; - V9fsString fullname; - - v9fs_string_init(&fullname); - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - - retval =3D v9fs_request(fs_ctx->private, T_MKNOD, NULL, &fullname, - credp->fc_mode, credp->fc_rdev, - credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, - const char *name, FsCred *credp) -{ - int retval; - V9fsString fullname; - - v9fs_string_init(&fullname); - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - - retval =3D v9fs_request(fs_ctx->private, T_MKDIR, NULL, &fullname, - credp->fc_mode, credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_fstat(FsContext *fs_ctx, int fid_type, - V9fsFidOpenState *fs, struct stat *stbuf) -{ - int fd; - - if (fid_type =3D=3D P9_FID_DIR) { - fd =3D dirfd(fs->dir.stream); - } else { - fd =3D fs->fd; - } - return fstat(fd, stbuf); -} - -static int proxy_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *= name, - int flags, FsCred *credp, V9fsFidOpenState *fs) -{ - V9fsString fullname; - - v9fs_string_init(&fullname); - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - - fs->fd =3D v9fs_request(fs_ctx->private, T_CREATE, NULL, &fullname, fl= ags, - credp->fc_mode, credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - if (fs->fd < 0) { - errno =3D -fs->fd; - fs->fd =3D -1; - } - return fs->fd; -} - -static int proxy_symlink(FsContext *fs_ctx, const char *oldpath, - V9fsPath *dir_path, const char *name, FsCred *cre= dp) -{ - int retval; - V9fsString fullname, target; - - v9fs_string_init(&fullname); - v9fs_string_init(&target); - - v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); - v9fs_string_sprintf(&target, "%s", oldpath); - - retval =3D v9fs_request(fs_ctx->private, T_SYMLINK, NULL, &target, &fu= llname, - credp->fc_uid, credp->fc_gid); - v9fs_string_free(&fullname); - v9fs_string_free(&target); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_link(FsContext *ctx, V9fsPath *oldpath, - V9fsPath *dirpath, const char *name) -{ - int retval; - V9fsString newpath; - - v9fs_string_init(&newpath); - v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name); - - retval =3D v9fs_request(ctx->private, T_LINK, NULL, oldpath, &newpath); - v9fs_string_free(&newpath); - if (retval < 0) { - errno =3D -retval; - retval =3D -1; - } - return retval; -} - -static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size) -{ - int retval; - - retval =3D v9fs_request(ctx->private, T_TRUNCATE, NULL, fs_path, size); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return 0; -} - -static int proxy_rename(FsContext *ctx, const char *oldpath, - const char *newpath) -{ - int retval; - V9fsString oldname, newname; - - v9fs_string_init(&oldname); - v9fs_string_init(&newname); - - v9fs_string_sprintf(&oldname, "%s", oldpath); - v9fs_string_sprintf(&newname, "%s", newpath); - retval =3D v9fs_request(ctx->private, T_RENAME, NULL, &oldname, &newna= me); - v9fs_string_free(&oldname); - v9fs_string_free(&newname); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) -{ - int retval; - retval =3D v9fs_request(fs_ctx->private, T_CHOWN, NULL, fs_path, - credp->fc_uid, credp->fc_gid); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_utimensat(FsContext *s, V9fsPath *fs_path, - const struct timespec *buf) -{ - int retval; - retval =3D v9fs_request(s->private, T_UTIME, NULL, fs_path, - buf[0].tv_sec, buf[0].tv_nsec, - buf[1].tv_sec, buf[1].tv_nsec); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_remove(FsContext *ctx, const char *path) -{ - int retval; - V9fsString name; - v9fs_string_init(&name); - v9fs_string_sprintf(&name, "%s", path); - retval =3D v9fs_request(ctx->private, T_REMOVE, NULL, &name); - v9fs_string_free(&name); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_fsync(FsContext *ctx, int fid_type, - V9fsFidOpenState *fs, int datasync) -{ - int fd; - - if (fid_type =3D=3D P9_FID_DIR) { - fd =3D dirfd(fs->dir.stream); - } else { - fd =3D fs->fd; - } - - if (datasync) { - return qemu_fdatasync(fd); - } else { - return fsync(fd); - } -} - -static int proxy_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *st= buf) -{ - int retval; - retval =3D v9fs_request(s->private, T_STATFS, stbuf, fs_path); - if (retval < 0) { - errno =3D -retval; - return -1; - } - return retval; -} - -static ssize_t proxy_lgetxattr(FsContext *ctx, V9fsPath *fs_path, - const char *name, void *value, size_t size) -{ - int retval; - V9fsString xname; - - v9fs_string_init(&xname); - v9fs_string_sprintf(&xname, "%s", name); - retval =3D v9fs_request(ctx->private, T_LGETXATTR, value, size, fs_pat= h, - &xname); - v9fs_string_free(&xname); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static ssize_t proxy_llistxattr(FsContext *ctx, V9fsPath *fs_path, - void *value, size_t size) -{ - int retval; - retval =3D v9fs_request(ctx->private, T_LLISTXATTR, value, size, fs_pa= th); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *= name, - void *value, size_t size, int flags) -{ - int retval; - V9fsString xname, xvalue; - - v9fs_string_init(&xname); - v9fs_string_sprintf(&xname, "%s", name); - - v9fs_string_init(&xvalue); - xvalue.size =3D size; - xvalue.data =3D g_malloc(size); - memcpy(xvalue.data, value, size); - - retval =3D v9fs_request(ctx->private, T_LSETXATTR, value, fs_path, &xn= ame, - &xvalue, size, flags); - v9fs_string_free(&xname); - v9fs_string_free(&xvalue); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_lremovexattr(FsContext *ctx, V9fsPath *fs_path, - const char *name) -{ - int retval; - V9fsString xname; - - v9fs_string_init(&xname); - v9fs_string_sprintf(&xname, "%s", name); - retval =3D v9fs_request(ctx->private, T_LREMOVEXATTR, NULL, fs_path, &= xname); - v9fs_string_free(&xname); - if (retval < 0) { - errno =3D -retval; - } - return retval; -} - -static int proxy_name_to_path(FsContext *ctx, V9fsPath *dir_path, - const char *name, V9fsPath *target) -{ - if (dir_path) { - v9fs_path_sprintf(target, "%s/%s", dir_path->data, name); - } else { - v9fs_path_sprintf(target, "%s", name); - } - return 0; -} - -static int proxy_renameat(FsContext *ctx, V9fsPath *olddir, - const char *old_name, V9fsPath *newdir, - const char *new_name) -{ - int ret; - V9fsString old_full_name, new_full_name; - - v9fs_string_init(&old_full_name); - v9fs_string_init(&new_full_name); - - v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name); - v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name); - - ret =3D proxy_rename(ctx, old_full_name.data, new_full_name.data); - v9fs_string_free(&old_full_name); - v9fs_string_free(&new_full_name); - return ret; -} - -static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir, - const char *name, int flags) -{ - int ret; - V9fsString fullname; - v9fs_string_init(&fullname); - - v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name); - ret =3D proxy_remove(ctx, fullname.data); - v9fs_string_free(&fullname); - - return ret; -} - -static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path, - mode_t st_mode, uint64_t *st_gen) -{ - int err; - - /* Do not try to open special files like device nodes, fifos etc - * we can get fd for regular files and directories only - */ - if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { - errno =3D ENOTTY; - return -1; - } - err =3D v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, path); - if (err < 0) { - errno =3D -err; - err =3D -1; - } - return err; -} - -static int connect_namedsocket(const char *path, Error **errp) -{ - int sockfd; - struct sockaddr_un helper; - - if (strlen(path) >=3D sizeof(helper.sun_path)) { - error_setg(errp, "socket name too long"); - return -1; - } - sockfd =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (sockfd < 0) { - error_setg_errno(errp, errno, "failed to create client socket"); - return -1; - } - strcpy(helper.sun_path, path); - helper.sun_family =3D AF_UNIX; - if (connect(sockfd, (struct sockaddr *)&helper, sizeof(helper)) < 0) { - error_setg_errno(errp, errno, "failed to connect to '%s'", path); - close(sockfd); - return -1; - } - - /* remove the socket for security reasons */ - unlink(path); - return sockfd; -} - -static void error_append_socket_sockfd_hint(Error *const *errp) -{ - error_append_hint(errp, "Either specify socket=3D/some/path where /som= e/path" - " points to a listening AF_UNIX socket or sock_fd=3D= fd" - " where fd is a file descriptor to a connected AF_UN= IX" - " socket\n"); -} - -static int proxy_parse_opts(QemuOpts *opts, FsDriverEntry *fs, Error **err= p) -{ - const char *socket =3D qemu_opt_get(opts, "socket"); - const char *sock_fd =3D qemu_opt_get(opts, "sock_fd"); - - if (!socket && !sock_fd) { - error_setg(errp, "both socket and sock_fd properties are missing"); - error_append_socket_sockfd_hint(errp); - return -1; - } - if (socket && sock_fd) { - error_setg(errp, "both socket and sock_fd properties are set"); - error_append_socket_sockfd_hint(errp); - return -1; - } - if (socket) { - fs->path =3D g_strdup(socket); - fs->export_flags |=3D V9FS_PROXY_SOCK_NAME; - } else { - fs->path =3D g_strdup(sock_fd); - fs->export_flags |=3D V9FS_PROXY_SOCK_FD; - } - return 0; -} - -static int proxy_init(FsContext *ctx, Error **errp) -{ - V9fsProxy *proxy =3D g_new(V9fsProxy, 1); - int sock_id; - - if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { - sock_id =3D connect_namedsocket(ctx->fs_root, errp); - } else { - sock_id =3D atoi(ctx->fs_root); - if (sock_id < 0) { - error_setg(errp, "socket descriptor not initialized"); - } - } - if (sock_id < 0) { - g_free(proxy); - return -1; - } - g_free(ctx->fs_root); - ctx->fs_root =3D NULL; - - proxy->in_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - proxy->in_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - proxy->out_iovec.iov_base =3D g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ); - proxy->out_iovec.iov_len =3D PROXY_MAX_IO_SZ + PROXY_HDR_SZ; - - ctx->private =3D proxy; - proxy->sockfd =3D sock_id; - qemu_mutex_init(&proxy->mutex); - - ctx->export_flags |=3D V9FS_PATHNAME_FSCONTEXT; - ctx->exops.get_st_gen =3D proxy_ioc_getversion; - return 0; -} - -static void proxy_cleanup(FsContext *ctx) -{ - V9fsProxy *proxy =3D ctx->private; - - if (!proxy) { - return; - } - - g_free(proxy->out_iovec.iov_base); - g_free(proxy->in_iovec.iov_base); - if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) { - close(proxy->sockfd); - } - g_free(proxy); -} - -FileOperations proxy_ops =3D { - .parse_opts =3D proxy_parse_opts, - .init =3D proxy_init, - .cleanup =3D proxy_cleanup, - .lstat =3D proxy_lstat, - .readlink =3D proxy_readlink, - .close =3D proxy_close, - .closedir =3D proxy_closedir, - .open =3D proxy_open, - .opendir =3D proxy_opendir, - .rewinddir =3D proxy_rewinddir, - .telldir =3D proxy_telldir, - .readdir =3D proxy_readdir, - .seekdir =3D proxy_seekdir, - .preadv =3D proxy_preadv, - .pwritev =3D proxy_pwritev, - .chmod =3D proxy_chmod, - .mknod =3D proxy_mknod, - .mkdir =3D proxy_mkdir, - .fstat =3D proxy_fstat, - .open2 =3D proxy_open2, - .symlink =3D proxy_symlink, - .link =3D proxy_link, - .truncate =3D proxy_truncate, - .rename =3D proxy_rename, - .chown =3D proxy_chown, - .utimensat =3D proxy_utimensat, - .remove =3D proxy_remove, - .fsync =3D proxy_fsync, - .statfs =3D proxy_statfs, - .lgetxattr =3D proxy_lgetxattr, - .llistxattr =3D proxy_llistxattr, - .lsetxattr =3D proxy_lsetxattr, - .lremovexattr =3D proxy_lremovexattr, - .name_to_path =3D proxy_name_to_path, - .renameat =3D proxy_renameat, - .unlinkat =3D proxy_unlinkat, -}; diff --git a/fsdev/meson.build b/fsdev/meson.build index e20d7255e1e..c751d8cb622 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -8,11 +8,3 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( if host_os in ['linux', 'darwin'] system_ss.add_all(fsdev_ss) endif - -if have_virtfs_proxy_helper - executable('virtfs-proxy-helper', - files('virtfs-proxy-helper.c', '9p-marshal.c', '9p-iov-marsha= l.c'), - dependencies: [qemuutil, libattr, libcap_ng], - install: true, - install_dir: get_option('libexecdir')) -endif diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index f1b62fa8c80..eceffdb81ea 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -2,7 +2,6 @@ fs_ss =3D ss.source_set() fs_ss.add(files( '9p-local.c', '9p-posix-acl.c', - '9p-proxy.c', '9p-synth.c', '9p-xattr-user.c', '9p-xattr.c', diff --git a/meson_options.txt b/meson_options.txt index 0269fa0f16e..f65fead3161 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -301,8 +301,6 @@ option('vhost_user_blk_server', type: 'feature', value:= 'auto', description: 'build vhost-user-blk server') option('virtfs', type: 'feature', value: 'auto', description: 'virtio-9p support') -option('virtfs_proxy_helper', type: 'feature', value: 'auto', - description: 'virtio-9p proxy helper support') option('libvduse', type: 'feature', value: 'auto', description: 'build VDUSE Library') option('vduse_blk_export', type: 'feature', value: 'auto', diff --git a/qemu-options.hx b/qemu-options.hx index d94e2cbbaeb..20a1ce0d43b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1766,29 +1766,18 @@ DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, " [[,throttling.bps-total-max=3Dbm]|[[,throttling.bps-read-max=3Drm][,= throttling.bps-write-max=3Dwm]]]\n" " [[,throttling.iops-total-max=3Dim]|[[,throttling.iops-read-max=3Dirm= ][,throttling.iops-write-max=3Diwm]]]\n" " [[,throttling.iops-size=3Dis]]\n" - "-fsdev proxy,id=3Did,socket=3Dsocket[,writeout=3Dimmediate][,readonly= =3Don]\n" - "-fsdev proxy,id=3Did,sock_fd=3Dsock_fd[,writeout=3Dimmediate][,readon= ly=3Don]\n" "-fsdev synth,id=3Did\n", QEMU_ARCH_ALL) =20 SRST ``-fsdev local,id=3Did,path=3Dpath,security_model=3Dsecurity_model [,write= out=3Dwriteout][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmode] [,throttlin= g.option=3Dvalue[,throttling.option=3Dvalue[,...]]]`` \=20 -``-fsdev proxy,id=3Did,socket=3Dsocket[,writeout=3Dwriteout][,readonly=3Do= n]`` - \ -``-fsdev proxy,id=3Did,sock_fd=3Dsock_fd[,writeout=3Dwriteout][,readonly= =3Don]`` - \ ``-fsdev synth,id=3Did[,readonly=3Don]`` Define a new file system device. Valid options are: =20 ``local`` Accesses to the filesystem are done by QEMU. =20 - ``proxy`` - Accesses to the filesystem are done by virtfs-proxy-helper(1). This - option is deprecated (since QEMU 8.1) and will be removed in a fut= ure - version of QEMU. Use ``local`` instead. - ``synth`` Synthetic filesystem, only used by QTests. =20 @@ -1813,8 +1802,6 @@ SRST security model is same as passthrough except the sever won't report failures if it fails to set file attributes like ownership. Security model is mandatory only for local fsdriver. - Other fsdrivers (like proxy) don't take security model as a - parameter. =20 ``writeout=3Dwriteout`` This is an optional argument. The only supported value is @@ -1827,16 +1814,6 @@ SRST Enables exporting 9p share as a readonly mount for guests. By default read-write access is given. =20 - ``socket=3Dsocket`` - Enables proxy filesystem driver to use passed socket file for - communicating with virtfs-proxy-helper(1). - - ``sock_fd=3Dsock_fd`` - Enables proxy filesystem driver to use passed socket descriptor - for communicating with virtfs-proxy-helper(1). Usually a helper - like libvirt will create socketpair and pass one of the fds as - sock\_fd. - ``fmode=3Dfmode`` Specifies the default mode for newly created files on the host. Works only with security models "mapped-xattr" and @@ -1889,18 +1866,12 @@ ERST DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, "-virtfs local,path=3Dpath,mount_tag=3Dtag,security_model=3Dmapped-xat= tr|mapped-file|passthrough|none\n" " [,id=3Did][,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfm= ode][,dmode=3Ddmode][,multidevs=3Dremap|forbid|warn]\n" - "-virtfs proxy,mount_tag=3Dtag,socket=3Dsocket[,id=3Did][,writeout=3Di= mmediate][,readonly=3Don]\n" - "-virtfs proxy,mount_tag=3Dtag,sock_fd=3Dsock_fd[,id=3Did][,writeout= =3Dimmediate][,readonly=3Don]\n" "-virtfs synth,mount_tag=3Dtag[,id=3Did][,readonly=3Don]\n", QEMU_ARCH_ALL) =20 SRST ``-virtfs local,path=3Dpath,mount_tag=3Dmount_tag ,security_model=3Dsecuri= ty_model[,writeout=3Dwriteout][,readonly=3Don] [,fmode=3Dfmode][,dmode=3Ddm= ode][,multidevs=3Dmultidevs]`` \=20 -``-virtfs proxy,socket=3Dsocket,mount_tag=3Dmount_tag [,writeout=3Dwriteou= t][,readonly=3Don]`` - \=20 -``-virtfs proxy,sock_fd=3Dsock_fd,mount_tag=3Dmount_tag [,writeout=3Dwrite= out][,readonly=3Don]`` - \ ``-virtfs synth,mount_tag=3Dmount_tag`` Define a new virtual filesystem device and expose it to the guest using a virtio-9p-device (a.k.a. 9pfs), which essentially means that a certa= in @@ -1917,11 +1888,6 @@ SRST ``local`` Accesses to the filesystem are done by QEMU. =20 - ``proxy`` - Accesses to the filesystem are done by virtfs-proxy-helper(1). - This option is deprecated (since QEMU 8.1) and will be removed in a - future version of QEMU. Use ``local`` instead. - ``synth`` Synthetic filesystem, only used by QTests. =20 @@ -1946,8 +1912,6 @@ SRST security model is same as passthrough except the sever won't report failures if it fails to set file attributes like ownership. Security model is mandatory only for local fsdriver. - Other fsdrivers (like proxy) don't take security model as a - parameter. =20 ``writeout=3Dwriteout`` This is an optional argument. The only supported value is @@ -1960,16 +1924,6 @@ SRST Enables exporting 9p share as a readonly mount for guests. By default read-write access is given. =20 - ``socket=3Dsocket`` - Enables proxy filesystem driver to use passed socket file for - communicating with virtfs-proxy-helper(1). Usually a helper like - libvirt will create socketpair and pass one of the fds as - sock\_fd. - - ``sock_fd`` - Enables proxy filesystem driver to use passed 'sock\_fd' as the - socket descriptor for interfacing with virtfs-proxy-helper(1). - ``fmode=3Dfmode`` Specifies the default mode for newly created files on the host. Works only with security models "mapped-xattr" and diff --git a/scripts/meson-buildoptions. b/scripts/meson-buildoptions. new file mode 100644 index 00000000000..e69de29bb2d diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index c97079a38c9..19626b7b464 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -206,8 +206,6 @@ meson_options_help() { printf "%s\n" ' vhost-vdpa vhost-vdpa kernel backend support' printf "%s\n" ' virglrenderer virgl rendering support' printf "%s\n" ' virtfs virtio-9p support' - printf "%s\n" ' virtfs-proxy-helper' - printf "%s\n" ' virtio-9p proxy helper support' printf "%s\n" ' vmdk vmdk image format support' printf "%s\n" ' vmnet vmnet.framework network backend support' printf "%s\n" ' vnc VNC server' @@ -533,8 +531,6 @@ _meson_option_parse() { --disable-virglrenderer) printf "%s" -Dvirglrenderer=3Ddisabled ;; --enable-virtfs) printf "%s" -Dvirtfs=3Denabled ;; --disable-virtfs) printf "%s" -Dvirtfs=3Ddisabled ;; - --enable-virtfs-proxy-helper) printf "%s" -Dvirtfs_proxy_helper=3Denab= led ;; - --disable-virtfs-proxy-helper) printf "%s" -Dvirtfs_proxy_helper=3Ddis= abled ;; --enable-vmdk) printf "%s" -Dvmdk=3Denabled ;; --disable-vmdk) printf "%s" -Dvmdk=3Ddisabled ;; --enable-vmnet) printf "%s" -Dvmnet=3Denabled ;; --=20 2.46.0