Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
94 user(s) are online (55 user(s) are browsing Forums)

Members: 1
Guests: 93

vintagewatches, more...

Support us!

Headlines

 
  Register To Post  

QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@All
Soo, after derfs with help of modern AI magic created Virtio9PFS-handler : https://github.com/derfsss/Virtio9PFS-handler (so you have ability to use shared directories and not the sucky fat-stick-way where you need to reboot always to see changes), and after smarkusg confirmed that it works on linux and macos, i tried to make it work on windows too, with pegasos2 emulation, just to realize that it has no -virtfs (p9) used for those shares..

First idea was to use WSL2 build, which i did, just to realize that because of layers in between it's still visibly slower than native win32 build of qemu. So no go.

Then doing some research to find out that there were some unofficial patches to make virtfs working on native windows targets too, but for older versions of qemu. So i took latest 10.2.1, and started applying those patches, firstly some older ones, then newer ones, but of course conflicts and stuff, but in the end succeeded, and TADAM:

(click open in new window for full size):
Resized Image


And it indeed works! Everything ultra fast, everything immediately refreshes and can be seen in realtime. Speed awesome, just gigabytes per second, and i can forget now as a bad dream this fat32-ugly way.

So thanks to derfs (and of course those AIs who can help us now), to smarkusg for tests, and for somebody's patches for win32.

PS. The funny thing is, once i made it all work, i found out that on github there is one man who is doing exactly the same, and made ready to use builds with integrated virtfs-p9 patches, damn! But at least i spent a day for learning purposes about qemu :)

@derfs
You may want to change readme saying that for windows you need unofficial builds with virtfs support, which can be found on: https://github.com/arixmkii/qcw/tags , or patches from https://github.com/arixmkii/qcw/tree/main/patches/qemu can be applied manually when building qemu from sources.

Line for running same as smarkusg show:

-fsdev local,security_model=mapped,id=fsdev0,path=D:\SHARED -device virtio-9p-pci-non-transitional,id=fs0,fsdev=fsdev0,mount_tag=SHARED


simple
-virtfs local,path=D:\SHARED,mount_tag=SHARED,security_model=mapped
didn't work.. So seems transitional, legacy didnt works , while modern VirtIO 1.0 works for pegasos2?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1e
It's great that you managed to get it running on Windows and shared all the information on how to do it – congratulations

Regarding Pegasos2. There is an entry in README...
"Pegasos2 (modern VirtIO) is implemented but not yet validated. Use at your own risk."
I would also like to add that Virtio9PFS-handler requires AmigaOS 4.1 FE U3.
I checked it out of curiosity to remake the AmigaOS 4.1 FE installation CD disc for AmigaOne and QEMU containing Virtio9PFS-handler. It didn't work.
I installed a clean system and updated from U1. .. It worked with U3.


EDIT:
My mistake was the Virtio SCSI driver, not the Virtio9PFS-handler.
Sorry for the mistake – I deleted the unnecessary entry.


Edited by smarkusg on 2026/3/6 13:57:44
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@smarkusg
Can you on linux/macos copy amiga executable to os4 to shared dir, and then, do "protect" on this file to set executable bit ? For me it dind't and says "unknown paket type", and i had to copy it to ram: to make protect work and mark file as executable

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1e
Of course you can't set Amiga protection bits on non-Amiga filesystems the same way you can't set Unix protection bits on FAT because there's no place to store it. But I wonder how are the protection bits stored on the install ISO? Maybe there's a mapping to Unix bits that's stored in RockRidge extensions? But even with that you may get problems on Windows where you don't even have Unix bits on a Windows filesystem.

Go to top
Re: QEMU dla Windows z działającymi -virtfs ! (tak!)
Quite a regular
Quite a regular


See User information
@kas1e
I checked on macOS.
The files I move to “shared” are created with executable bits (all attributes).
Host (macOS) I am unable to change the “bits” for the native file system for AOS, and it is not set.
“mapped-xattr: Some of the file attributes like uid, gid, mode bits and link target are stored as file attributes. This is probably the most reliable and secure option”
https://wiki.qemu.org/Documentation/9psetup

Resized Image

EDIT:
@balaton I already wrote about this. I didn't notice. I'm leaving the post for screenshots.

Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@all

Found it. Situation are:

On fat-usb stick it works (i mean protect +e) because fat.handler seems simple silently ignore error, instead of return error, so you can set protect, but then, of course, it didn't saves, didn't survive reboot, etc.

Then, i made a test by copy any file with executable bit set to the SHARED directory via new handler, and +e bit survive reboot ! So that mean it saves for sure on this FS.

After some tinkering, find out that it saves in Windows NTFS Alternate Data Stream named user.virtfs.mode alongside the file, see:

Get-Content "D:\shared\test2.txt" -Stream "user.virtfs.mode" -Encoding Byte
253
129


253 = 0xFD, 129 = 0x81

The ADS content 0xFD 0x81 = 0x81FD = S_IFREG | 0775 — the x bit is present exactly where expected. For test.txt (where protect +e failed), no user.virtfs.mode ADS exists at all — QEMU has nowhere to store the mode, and the 9P Setattr request fails.

So, asked AI to create simple script which via powershell set set the necessary fields if they not present, or change them if present, and tadam, see:

root@DESKTOP-E507GTH:/mnt/d/shared# python3 protect.py test3.txt +e
  
(no existing ADSusing default mode 0x81B6)
test3.txtset +(mode=0x81FF)
root@DESKTOP-E507GTH:/mnt/d/shared# python3 protect.py test3.txt -e
test3.txtcleared -(mode=0x81B6)
root@DESKTOP-E507GTH:/mnt/d/shared# python3 protect.py test3.txt +e
test3.txtset +(mode=0x81FF)
root@DESKTOP-E507GTH:/mnt/d/shared# python3 protect.py test3.txt +e
test3.txtset +(mode=0x81FF)
root@DESKTOP-E507GTH:/mnt/d/shared#


And it works. I can see how bit sets/changes from OS4 side in realtime, yeahoo !! I even made small C tool which now just doing same, and can be running from windwos/wsl/whatever.

Now, while now i can easy do after any os4 compile call of this script/tool over binary to make it be +e , but probably fix in the Handler still need it to make "protect" command to work. All we need is in fuse_ops.c:

static int v9p_chmod(const char *pathmode_t mode)
{
    
struct V9PHandler *g_handler;
    
uint32 fid;

    
int32 err walk_to(hpath, &fid);
    if (
err)
        return (int)
err;

    
/* Read current mode to preserve file type bits (S_IFREG etc) */
    
struct P9Stat p9st;
    
err P9_Getattr(hfidP9_GETATTR_BASIC, &p9st);
    if (
err) {
        
P9_Clunk(hfid);
        
FidPool_Free(h->fid_poolfid);
        return (int)
err;
    }

    
/* Keep file type bits, replace only permission bits */
    
uint32 new_mode = (p9st.mode 0xFFFFF000) | ((uint32)mode 0x00000FFF);

    
struct P9Iattr attr;
    
memset(&attr0sizeof(attr));
    
attr.valid P9_SETATTR_MODE;
    
attr.mode  new_mode;

    
err P9_Setattr(hfid, &attr);
    
P9_Clunk(hfid);
    
FidPool_Free(h->fid_poolfid);
    return (int)
err;
}


And register callback in V9P_FillOperations with "ops->chmod = v9p_chmod;", then qemu when recieve P9_Setattr with P9_SETATTR_MODE create user.virtfs.mode AD (if there none), and if there any, just refresh with new data.

I.e. currently in handler "ops->chmod = NULL", and this mean:

Even if file with ADS, protect +e mean "packet request type unknown", and file without ADS, the same "packet request type unknown" too.

EDIT: fixed code a bit for new function, and tested: yes, everything works !

ps. if anyone need it can share both python script and C code to set amiga protect bit from windows size.


@Derfs
Created BZ with path need it
https://github.com/derfsss/Virtio9PFS-handler/issues/1

Once you will have time plz apply this one as well as changes for readme about virtfs on windows and stuff. Thanks a bunch !


Edited by kas1e on 2026/3/7 6:34:56
Edited by kas1e on 2026/3/7 6:45:41
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Not too shy to talk
Not too shy to talk


See User information

Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@derfs
Thanks ! Tested all fine !

Small note about this :

Quote:

On Windows, the -virtfs shorthand may not work. Use the explicit -fsdev + -device syntax instead:

-fsdev local,security_model=mapped-xattr,id=fsdev0,path=D:\SHARED
-device virtio-9p-pci-non-transitional,id=fs0,fsdev=fsdev0,mount_tag=SHARED


As i understand now, -virtfs issue is not windows related, but pegasos2 related in whole (same issue smarkusg have on linux and macos). I.e. -vritfs mean legacy mode, while -fsdev seems "modern" one (at least that how i understand it). Can't be sure but that mean some changes in pegasos2 way need to be done for legacy support (not big deal of course, as it works like it works, but nothing is perfect as always:) )

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1e
I don't know virtio but I doubt -virtfs would be legacy. According to the docs smarkusg linked (which seem quite outdated but maybe still there's some truth in it) it should be the same as -device virtio-9p-pci which should support both legacy and modern but maybe the driver need to do something to switch it to modern mode or is that the default?

Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1e
You also fixed a bug that I hadn't noticed before.
I always copy files with AmigaShell or Mycommander.
Today, when I tried to move the entire program in Workbench (moving the icon to the SHARED disk), I got an error.
Resized Image
After updating to “0.4.0-beta,” the error no longer appears.
I checked on PEG2 Linux and macOS.
Thank you.

Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1eQuote:
As i understand now, -virtfs issue is not windows related, but pegasos2 related in whole (same issue smarkusg have on linux and macos). I.e. -vritfs mean legacy mode, while -fsdev seems "modern" one (at least that how i understand it). Can't be sure but that mean some changes in pegasos2 way need to be done for legacy support (not big deal of course, as it works like it works, but nothing is perfect as always:) )

If I understand the documentation correctly, this should currently be enforced.
As @balton wrote, -device virtio-9p-pci should work in automatic negotiation mode. For now, the driver is in BETA and may be improved.


Edited by smarkusg on 2026/3/8 7:15:40
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@All
After i have full use of this stuff (and this really, really dramatic improve speed and feel of qemu when you do code with), i am start to curious : can't we have this to be "bootable" ? I mean, if +e bit survives on NTFS, we then can not have any img files , but instead just install on partition (like it can be done with winuae as well too) and so - see system files from windows too (which quite helpfull as well)..

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1e
Virtfs root works with Linux guest as mentioned in the docs linked before but to boot from it you probably need the kernel to recognise it as a bootable partition and without a partition table that may be difficult. If you can set the root device somehow to boot from that may work. But virtio-scsi should also have similar speed and that should work better as it emulates whole disk with partitions.

Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@balaton
Quote:

But virtio-scsi should also have similar speed and that should work better as it emulates whole disk with partitions.

I may talk bull, but as far as i see virtio-scsi its the same "img" file, just which i can see as real partition in the qemu. But what i want is to have just directory "System:" on windows, in which installed files of os4 can be seen as regular files (just like now in SHARED: with virtio-fs.handler).

ps. to be honest i not fully understand for now difference between having os4.img as it were done before, and scsi.img. Is is give any benefits ? I mean in both ways it's .img file which i need to partition and install on. Or i miss some major point ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Quite a regular
Quite a regular


See User information
@kas1e
No, that's the point. Image file is like a disk on which you have partitions and virtio-9p is like a network share that you mount. When the kernel boots it reads RDB from disks and looks for a boot partition which it can find with an image and virtio-scsi where the virtio-scsi driver is just like a disk driver otherwise everything is like on real machine with disks but what happens with a virio-9p driver? How does it know which share to mount and how does the kernel know it should boot from that when there's no RDB with partitions and a bootable flag anywhere? With Linux the 9p client is in kernel and there are options to tell it to mount and look for the root filesystem on a 9p share. But is there something similar in AmigaOS kernel or could just a virtio-9p driver provide that? A 9p driver may have an otion to tell it to mount a share but how do you tell the AmigaOS kernel that it should boot from that device if it has no RDB?

The difference between an emulated IDE and virtio-scsi is not in the image file, that's the same but emulated IDE goes through IO and interrupts which is slower than virtio that uses shared memory to communicate with QEMU with less emulation overhead.

Go to top
Re: QEMU for Windows with working -virtfs ! (yes!)
Home away from home
Home away from home


See User information
@kas1e
Quote:
ps. to be honest i not fully understand for now difference between having os4.img as it were done before, and scsi.img. Is is give any benefits ?
Should make next to no difference with old file systems like SFS as they can't take advantage of drivers supporting NCQ or similar (nearly all SCSI drivers, nvme.device, virtscsi.device, ...) as they are only doing a single device I/O and wait for completion before starting the next device I/O command.
Other file systems could be much faster on such devices, but I don't know if NGFS or filesysbox.library based file systems (NTFS-3G and several other FUSE file system ports) use multiple, parallel device I/O commands.

For booting AmigaOS from a 9PFS handler support for the 'e' protection bit isn't enough, additionally at least the 's' protection bit is required. Ideally all 16 AmigaOS protection bits should be supported, as well as the UID and GID numbers.
What you could do is using a small image file boot partition and put something like
Set Echo OFF
FailAT 15
Mount SHARED
:
IF 
EXISTS SHARED:
   
Assign SYSSHARED:
   
Assign CSYS:C
   Assign S
SYS:S
   
... (repeat for all default system assigns)
   
Execute S:Startup-Sequence
   QUIT
ENDIF
at the beginng of the Startup-Sequence.
That way most of the OS is loaded from the 9PFS mounted directory.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )



Polls
Running AmigaOS 4 on?
AmigaOne SE/XE or microA1 12% (26)
Pegasos2 3% (8)
X5000 22% (48)
X1000 14% (30)
A1222 8% (19)
Sam 440/460 18% (40)
Classic PowerPC Amiga 2% (6)
WinUAE emulation 7% (16)
Qemu emulation 9% (21)
Total Votes: 214
The poll closed at 2025/12/1 12:00
8 Comments


Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project