diff options
| author | Christian Schoenebeck <qemu_oss@crudebyte.com> | 2025-01-03 12:33:40 +0100 |
|---|---|---|
| committer | Christian Schoenebeck <qemu_oss@crudebyte.com> | 2025-02-06 17:10:46 +0100 |
| commit | 9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed (patch) | |
| tree | 4512485ce20a7de796bdecbc55c675254105a1ed /hw/9pfs/9p.c | |
| parent | a2f17bd40b3d302f6c1ddf0da75d2343966e0a3f (diff) | |
| download | focaccia-qemu-9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed.tar.gz focaccia-qemu-9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed.zip | |
9pfs: improve v9fs_open() tracing
Improve tracing of 9p 'Topen' request type by showing open() flags as human-readable text. E.g. trace output: v9fs_open tag 0 id 12 fid 2 mode 100352 would become: v9fs_open tag=0 id=12 fid=2 mode=100352(RDONLY|NONBLOCK|DIRECTORY| TMPFILE|NDELAY) Therefor add a new utility function qemu_open_flags_tostr() that converts numeric open() flags from host's native O_* flag constants to a string presentation. 9p2000.L and 9p2000.u protocol variants use different numeric 'mode' constants for 'Topen' requests. Instead of writing string conversion code for both protocol variants, use the already existing conversion functions that convert the mode flags from respective protocol constants to host's native open() numeric flag constants and pass that result to the new string conversion function qemu_open_flags_tostr(). Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <E1tTgDR-000oRr-9g@kylie.crudebyte.com>
Diffstat (limited to 'hw/9pfs/9p.c')
| -rw-r--r-- | hw/9pfs/9p.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 6f24c1abb3..7cad2bce62 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2008,6 +2008,7 @@ static void coroutine_fn v9fs_open(void *opaque) V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; + g_autofree char *trace_oflags = NULL; if (s->proto_version == V9FS_PROTO_2000L) { err = pdu_unmarshal(pdu, offset, "dd", &fid, &mode); @@ -2019,7 +2020,13 @@ static void coroutine_fn v9fs_open(void *opaque) if (err < 0) { goto out_nofid; } - trace_v9fs_open(pdu->tag, pdu->id, fid, mode); + if (trace_event_get_state_backends(TRACE_V9FS_OPEN)) { + trace_oflags = qemu_open_flags_tostr( + (s->proto_version == V9FS_PROTO_2000L) ? + dotl_to_open_flags(mode) : omode_to_uflags(mode) + ); + trace_v9fs_open(pdu->tag, pdu->id, fid, mode, trace_oflags); + } fidp = get_fid(pdu, fid); if (fidp == NULL) { |