From patchwork Mon Apr 24 14:32:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 9696569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 044206037F for ; Mon, 24 Apr 2017 14:34:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E98F32819A for ; Mon, 24 Apr 2017 14:34:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE74A2835B; Mon, 24 Apr 2017 14:34:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 365492819A for ; Mon, 24 Apr 2017 14:34:03 +0000 (UTC) Received: from localhost ([::1]:44459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2f3y-000103-G5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Apr 2017 10:34:02 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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=root,path=/path/to/rootfs,... -device virtio-9p-pci,fsdev=root,mount_tag=/dev/root but the -virtfs shortcut cannot be used as it hard-codes the device identifier to match the mount_tag, and device identifiers may not contain '/': $ qemu-system-x86_64 -virtfs local,path=/foo,mount_tag=/dev/root,security_model=passthrough qemu-system-x86_64: -virtfs local,path=/foo,mount_tag=/dev/root,security_model=passthrough: 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=root,path=/path/to/rootfs,mount_tag=/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 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, "-virtfs local,path=path,mount_tag=tag,security_model=[mapped-xattr|mapped-file|passthrough|none]\n" - " [,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd]\n", + " [,id=id][,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd]\n", QEMU_ARCH_ALL) 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 = 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_abort); 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;