From nobody Mon May 6 23:55:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149304445586867.87527603648698; Mon, 24 Apr 2017 07:34:15 -0700 (PDT) Received: from localhost ([::1]:44464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2f49-0001NB-KD for importer@patchew.org; Mon, 24 Apr 2017 10:34:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2f3F-0000zp-F0 for qemu-devel@nongnu.org; Mon, 24 Apr 2017 10:33:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2f3B-0003OZ-6G for qemu-devel@nongnu.org; Mon, 24 Apr 2017 10:33:17 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:57769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2f3A-0003Jg-Uk; Mon, 24 Apr 2017 10:33:13 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id A811942007; Mon, 24 Apr 2017 17:33:02 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with SMTP id 461B440F; Mon, 24 Apr 2017 17:33:02 +0300 (MSK) Received: (nullmailer pid 20615 invoked by uid 1000); Mon, 24 Apr 2017 14:33:02 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, Chris Webb Date: Mon, 24 Apr 2017 17:32:54 +0300 Message-Id: <20170424143254.20569-1-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Michael Tokarev Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Chris Webb When using a virtfs root filesystem, the mount_tag needs to be set to /dev/root. This can be done long-hand as -fsdev local,id=3Droot,path=3D/path/to/rootfs,... -device virtio-9p-pci,fsdev=3Droot,mount_tag=3D/dev/root but the -virtfs shortcut cannot be used as it hard-codes the device identif= ier to match the mount_tag, and device identifiers may not contain '/': $ qemu-system-x86_64 -virtfs local,path=3D/foo,mount_tag=3D/dev/root,secu= rity_model=3Dpassthrough qemu-system-x86_64: -virtfs local,path=3D/foo,mount_tag=3D/dev/root,secur= ity_model=3Dpassthrough: duplicate fsdev id: /dev/root To support this case using -virtfs, we allow the device identifier to be specified explicitly when the mount_tag is not suitable: -virtfs local,id=3Droot,path=3D/path/to/rootfs,mount_tag=3D/dev/root,... Signed-off-by: Chris Webb Signed-off-by: Michael Tokarev --- mjt: ported to current code, simplified a bit using ?: operator. This is a patch from 2011, https://lists.gnu.org/archive/html/qemu-devel/2011-11/msg03083.html qemu-options.hx | 2 +- vl.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index d7da182df4..968161ab25 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -863,7 +863,7 @@ ETEXI =20 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, "-virtfs local,path=3Dpath,mount_tag=3Dtag,security_model=3D[mapped-xa= ttr|mapped-file|passthrough|none]\n" - " [,writeout=3Dimmediate][,readonly][,socket=3Dsocket|sock_fd= =3Dsock_fd]\n", + " [,id=3Did][,writeout=3Dimmediate][,readonly][,socket=3Dsocket= |sock_fd=3Dsock_fd]\n", QEMU_ARCH_ALL) =20 STEXI diff --git a/vl.c b/vl.c index 0b4ed5241c..d1da43ee4c 100644 --- a/vl.c +++ b/vl.c @@ -3521,10 +3521,11 @@ int main(int argc, char **argv, char **envp) exit(1); } fsdev =3D qemu_opts_create(qemu_find_opts("fsdev"), + qemu_opts_id(opts) ?: qemu_opt_get(opts, "mount_tag"), 1, NULL); if (!fsdev) { - error_report("duplicate fsdev id: %s", + error_report("duplicate or invalid fsdev id: %s", qemu_opt_get(opts, "mount_tag")); exit(1); } @@ -3562,7 +3563,7 @@ int main(int argc, char **argv, char **envp) &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abo= rt); qemu_opt_set(device, "fsdev", - qemu_opt_get(opts, "mount_tag"), &error_abort= ); + qemu_opts_id(fsdev), &error_abort); qemu_opt_set(device, "mount_tag", qemu_opt_get(opts, "mount_tag"), &error_abort= ); break; --=20 2.11.0