* [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option
@ 2011-11-24 16:04 Chris Webb
2011-11-24 16:41 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Chris Webb @ 2011-11-24 16:04 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Venkateswararao Jujjuri (JV), 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: Parameter 'id' expects an identifier
Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.
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 <chris@arachsys.com>
---
qemu-options.hx | 4 ++--
vl.c | 16 +++++++++++-----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 681eaf1..865e3a2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -588,13 +588,13 @@ DEFHEADING()
DEFHEADING(Virtual File system pass-through options:)
DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
- "-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough|none]\n"
+ "-virtfs local[,id=id],path=path,mount_tag=tag,security_model=[mapped|passthrough|none]\n"
" [,writeout=immediate][,readonly]\n",
QEMU_ARCH_ALL)
STEXI
-@item -virtfs @var{fsdriver},path=@var{path},mount_tag=@var{mount_tag},security_model=@var{security_model}[,writeout=@var{writeout}][,readonly]
+@item -virtfs @var{fsdriver}[,id=@var{id}],path=@var{path},mount_tag=@var{mount_tag},security_model=@var{security_model}[,writeout=@var{writeout}][,readonly]
@findex -virtfs
The general form of a Virtual File system pass-through options are:
diff --git a/vl.c b/vl.c
index f5afed4..b17af09 100644
--- a/vl.c
+++ b/vl.c
@@ -2689,10 +2689,17 @@ int main(int argc, char **argv, char **envp)
"mount_tag=tag.\n");
exit(1);
}
- fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
- qemu_opt_get(opts, "mount_tag"), 1);
+
+ if (qemu_opts_id(opts)) {
+ fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
+ qemu_opts_id(opts), 1);
+ } else {
+ fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
+ qemu_opt_get(opts, "mount_tag"), 1);
+ }
+
if (!fsdev) {
- fprintf(stderr, "duplicate fsdev id: %s\n",
+ fprintf(stderr, "duplicate or invalid fsdev id: %s\n",
qemu_opt_get(opts, "mount_tag"));
exit(1);
}
@@ -2716,8 +2723,7 @@ int main(int argc, char **argv, char **envp)
qemu_opt_get_bool(opts, "readonly", 0));
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
qemu_opt_set(device, "driver", "virtio-9p-pci");
- qemu_opt_set(device, "fsdev",
- qemu_opt_get(opts, "mount_tag"));
+ qemu_opt_set(device, "fsdev", qemu_opts_id(fsdev));
qemu_opt_set(device, "mount_tag",
qemu_opt_get(opts, "mount_tag"));
break;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option
2011-11-24 16:04 [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option Chris Webb
@ 2011-11-24 16:41 ` Peter Maydell
2011-11-24 17:08 ` Chris Webb
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2011-11-24 16:41 UTC (permalink / raw)
To: Chris Webb; +Cc: Anthony Liguori, Venkateswararao Jujjuri (JV), qemu-devel
On 24 November 2011 16:04, Chris Webb <chris@arachsys.com> wrote:
> + if (qemu_opts_id(opts)) {
> + fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
> + qemu_opts_id(opts), 1);
> + } else {
> + fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
> + qemu_opt_get(opts, "mount_tag"), 1);
> + }
The indentation here looks wrong. (scripts/checkpatch.pl will catch
this kind of thing for you).
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option
2011-11-24 16:41 ` Peter Maydell
@ 2011-11-24 17:08 ` Chris Webb
0 siblings, 0 replies; 4+ messages in thread
From: Chris Webb @ 2011-11-24 17:08 UTC (permalink / raw)
To: Peter Maydell; +Cc: Anthony Liguori, Venkateswararao Jujjuri (JV), qemu-devel
Peter Maydell <peter.maydell@linaro.org> writes:
> On 24 November 2011 16:04, Chris Webb <chris@arachsys.com> wrote:
> > + ?? ?? ?? ?? ?? ?? ?? ??if (qemu_opts_id(opts)) {
> > + ?? ?? ?? ?? ?? ?? ?? ?? ??fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
> > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? qemu_opts_id(opts), 1);
> > + ?? ?? ?? ?? ?? ?? ?? ??} else {
> > + ?? ?? ?? ?? ?? ?? ?? ?? ??fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
> > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? qemu_opt_get(opts, "mount_tag"), 1);
> > + ?? ?? ?? ?? ?? ?? ?? ??}
>
> The indentation here looks wrong. (scripts/checkpatch.pl will catch
> this kind of thing for you).
You're quite right; resent a fixed version.
Cheers,
Chris.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option
@ 2017-04-24 14:32 Michael Tokarev
0 siblings, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2017-04-24 14:32 UTC (permalink / raw)
To: qemu-devel, Chris Webb; +Cc: qemu-trivial, Michael Tokarev
From: Chris Webb <chris@arachsys.com>
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 <chris@arachsys.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
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;
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-24 14:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 16:04 [Qemu-devel] [PATCH] virtfs: allow a device id to be specified in the -virtfs option Chris Webb
2011-11-24 16:41 ` Peter Maydell
2011-11-24 17:08 ` Chris Webb
-- strict thread matches above, loose matches on Subject: below --
2017-04-24 14:32 Michael Tokarev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).