[Bug 280098] 9pfs panics on qemu+kvm

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 02 Jul 2024 20:40:20 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280098

--- Comment #2 from Danilo Egea Gondolfo <danilo@FreeBSD.org> ---
Ok, I think I get it (kind of).

This patch will do the trick. But I'm not very familiar with the virtio
infrastructure yet so I'd like some feedback:

---
diff --git a/sys/dev/virtio/p9fs/virtio_p9fs.c
b/sys/dev/virtio/p9fs/virtio_p9fs.c
index aa174d3bd5b..3b849e26246 100644
--- a/sys/dev/virtio/p9fs/virtio_p9fs.c
+++ b/sys/dev/virtio/p9fs/virtio_p9fs.c
@@ -320,6 +320,7 @@ vt9p_attach(device_t dev)
        struct sysctl_oid *tree;
        struct vt9p_softc *chan;
        char *mount_tag;
+       char *mount_tag_p;
        int error;
        uint16_t mount_tag_len;

@@ -352,9 +353,12 @@ vt9p_attach(device_t dev)
        mount_tag = malloc(mount_tag_len + 1, M_P9FS_MNTTAG,
            M_WAITOK | M_ZERO);

-       virtio_read_device_config(dev,
-           offsetof(struct virtio_9pnet_config, mount_tag),
-           mount_tag, mount_tag_len);
+       mount_tag_p = mount_tag;
+       for (int i = 0; i < mount_tag_len; i++, mount_tag_p++) {
+               virtio_read_device_config(dev,
+                       offsetof(struct virtio_9pnet_config, mount_tag) + i,
+                       mount_tag_p, 1);
+       }

        device_printf(dev, "Mount tag: %s\n", mount_tag);

---

With this patch I get

virtio_p9fs0: <VirtIO 9P Transport> on virtio_pci7
virtio_p9fs0: Mount tag: config


root@freebsd:~ # mount -t p9fs config /mnt
root@freebsd:~ # ls /mnt/
agent-mounts.json       agent.crt               files                  
lxd-agent               server.crt              udev
agent.conf              agent.key               install.sh              nics   
                systemd
root@freebsd:~ # mount
/dev/da0p2 on / (ufs, local, synchronous, soft-updates, journaled soft-updates)
devfs on /dev (devfs)
/dev/da0p1 on /boot/efi (msdosfs, local)
config on /mnt (p9fs, local)

-- 
You are receiving this mail because:
You are the assignee for the bug.