VHD support

Support and general discussion.
User avatar
resle
Posts: 51
Joined: Mon 23 Feb, 2015 8:00 am

Re: VHD support

Post by resle » Mon 04 Jun, 2018 8:25 am

shermanp wrote: That's alright, I've found a way of doing it using the method suggested here. Simple, and doesn't require compile time or run time checking. And since the only purpose is to read/write a one-time footer, performance is hardly an issue either.

I think I've got the VHD footer reading working. The next step is to figure out what I need to store where to get the info into the config file etc. That looks like it's part of the HdSizeDlg stuff. I shall persevere with it...

If I want to implement creating VHD's (which I do), I've discovered another little spanner in the works -- UUID. For whatever reasons, most implementations of UUID generation (in C) appear to use OS calls. So what the heck to do with MinGW? Where's a nice portable C (not C++) library for generating a valid UUID? Or do we just fake it for the purposes of creating a VHD file?

But to those interested, yes, I am making progress. I'm just trying to wrap my head around the wxWidgets stuff.

(As an aside, working with C makes me that much more appreciative of higher level languages!)
Sherman, Sarah, thanks a lot.

I didn't even actually intend this as a "request" (I don't really get the idea of requests, within the scope of something that is being given away for free), just a feature suggestion from some one who uses PCem literally every single day.

I wish I was more familiar with the toolchain and libraries used by you guys so that I could contribute myself, this is definitely one of those things that I would have enjoyed developing!

r.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Mon 04 Jun, 2018 9:56 am

I've been thinking about VHD support for PCem for a while. Having never contributed any code to PCem before, it looked like adding VHD support wouldn't be too difficult, so I finally decided to have a go.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Thu 07 Jun, 2018 9:04 am

A new patch has been posted, now with more VHD creation capabilities.

User avatar
resle
Posts: 51
Joined: Mon 23 Feb, 2015 8:00 am

Re: VHD support

Post by resle » Mon 11 Jun, 2018 10:01 pm

I have tested the newly implemented VHD support in how many scenarios as possible without a hitch. Old VHDs created under Virtualbox and Hyper-V were mounted and operated normally, and vice-versa PCem-made VHDs mount just fine everywhere else.

Great thanks to Sherman, Sarah, and everyone who was involved.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Tue 12 Jun, 2018 4:50 am

resle wrote:
Mon 11 Jun, 2018 10:01 pm
I have tested the newly implemented VHD support in how many scenarios as possible without a hitch. Old VHDs created under Virtualbox and Hyper-V were mounted and operated normally, and vice-versa PCem-made VHDs mount just fine everywhere else.

Great thanks to Sherman, Sarah, and everyone who was involved.
Thanks for testing. No promises, but I've been thinking about how one might implement support for dynamic VHD's. The format itself doesn't look to difficult, it's whether or not I have the skills to implement it that I'm not too sure about...

The other option is to use an external library, but there doesn't appear to be much in the way of a standalone C library. There's a library called libvhdi, but that is labeled 'alpha', and I don't really know how stable and feature complete it is. Also, attempting my own implementation sounds like it could be an interesting problem to solve.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Sat 23 Jun, 2018 7:28 am

Just thought I'd post a quick update.

I have got dynamic VHD support semi-working. Current status is that I can attach a pre-formatted image to PCem as a secondary drive, and copy some files to/from Windows 98.

I have just tried installing Win 98 to a fresh (dynamic) VHD (including formatting).... It did not go well.

Obviously have more work to do yet!

I'll probably release a patch for testing purposes once I've got to the point of being able to install and run an OS to a dynamic VHD.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Wed 27 Jun, 2018 12:02 pm

Coming soon to a PCem near you! (Hopefully... If I don't stuff anything ELSE up...)

DynamicVHD.PNG
DynamicVHD.PNG (139.79 KiB) Viewed 721 times

Oh, and BTW, the VHD file was created by PCem, and Windows 10 mounts it as well.

Up next will be to release a patch in the next day or two, where I can hopefully get some victims—er—"kind volunteers" to help test it.

User avatar
xXLuckyXx
Posts: 59
Joined: Tue 06 Feb, 2018 3:52 pm

Re: VHD support

Post by xXLuckyXx » Wed 27 Jun, 2018 3:53 pm

What is the difference between VHD hard disk and PCem hard disk that we already have?

JosepMa
Posts: 119
Joined: Tue 20 Jun, 2017 6:25 pm

Re: VHD support

Post by JosepMa » Wed 27 Jun, 2018 7:00 pm

@xXLuckyXx : The answer is actually in that screenshot. 20GB disk (as seen by Windows 98 in PCem), sizing around 250MB on physical disk.

Shermanp did already implement fixed-size VHD support (which is almost a raw image with some headers), but he is currently implementing, with success, dynamic-sized disks.

What it means to all of us is that we will have have X amount of virtual hard drives on your disk, and the file sizes will be a lot less than the physical size (assuming a common disk usage, where you don't fill it up)

User avatar
xXLuckyXx
Posts: 59
Joined: Tue 06 Feb, 2018 3:52 pm

Re: VHD support

Post by xXLuckyXx » Wed 27 Jun, 2018 7:17 pm

So it's like VirtualBox. Virtualbox has Fixed size (if it is 20gb it will take 20gb immediately) and Dynamically allocated (it starts with 0mb and it will take more space when more files/applications are added but it won't shrink the size if those files/applications get deleted but it won't take more than allocated - 20gb)

Am I right?

JosepMa
Posts: 119
Joined: Tue 20 Jun, 2017 6:25 pm

Re: VHD support

Post by JosepMa » Wed 27 Jun, 2018 8:28 pm

Correct. VirtualBox supports different disk formats that support dynamic size allocation, including VHD and VDI

User avatar
xXLuckyXx
Posts: 59
Joined: Tue 06 Feb, 2018 3:52 pm

Re: VHD support

Post by xXLuckyXx » Wed 27 Jun, 2018 8:52 pm

But OS in VirtualBox works faster if it has Fixed size. Does that mean PCem will lose some of it's performance when having Dynamically allocated hard disk?

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Wed 27 Jun, 2018 9:30 pm

xXLuckyXx wrote:
Wed 27 Jun, 2018 8:52 pm
But OS in VirtualBox works faster if it has Fixed size. Does that mean PCem will lose some of it's performance when having Dynamically allocated hard disk?
Yes, potentially. But I don't think there will be too much in it. The format stores data in (typically) 2MB blocks. When a read or write occurs, it will, in most cases, be constrained to a single block, and performance should be almost as good as a raw image. There are two areas when performance gets degraded: 1. Read/write across data blocks 2. Write to a sparse (unallocated) block.

I haven't done any benchmarks yet, but my gut feeling is that modern hard disks are faster than any HDD emulated by PCem would have been anyway.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Thu 28 Jun, 2018 2:50 am

So I decided to run ATTO under Windows 98. I don't know how representative it is etc etc, but it hopefully gives some indication of any performance differences between fixed and dynamic disks.

The setup was as follows:
  • All disk images are stored on my Crucial MX100 512GB SSD.
  • The guest OS (Windows 98SE) was running as drive C: using a raw disk image.
  • P166, 128MB RAM
  • Each image was created by PCem, and partitioned and formatted using the tools on the Windows 98 setup CD
  • Each image is an identical size of 4095MB
  • Each test was performed after a guest OS restart. The image to benchmark was attached to Secondary IDE: Master
The results of the two benchmarks are in the image below.
ATTO_Benchmarks.PNG
ATTO_Benchmarks.PNG (90.25 KiB) Viewed 660 times
As can be seen, there appears to be negligible differences between the image formats, at least in the context of this setup and benchmark.

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Mon 09 Jul, 2018 5:34 am

In case anyone in this thread missed it, I have updated my patch in the patches subforum to add support for dynamic VHD's

User avatar
resle
Posts: 51
Joined: Mon 23 Feb, 2015 8:00 am

Re: VHD support

Post by resle » Fri 03 Aug, 2018 3:25 am

shermanp wrote:
Mon 09 Jul, 2018 5:34 am
In case anyone in this thread missed it, I have updated my patch in the patches subforum to add support for dynamic VHD's
Tested as much as I could, and encountered no issues. Fiddled with mounting the pcem-made VHD in Hyper-V machines, or even directly under Windows, and viceversa (VHDs made in Hyper-V mounted under PCem), and all works flawlessly.
Thanks!

shermanp
Posts: 73
Joined: Sat 18 Feb, 2017 2:09 am

Re: VHD support

Post by shermanp » Fri 03 Aug, 2018 3:50 am

resle wrote:
Fri 03 Aug, 2018 3:25 am
Tested as much as I could, and encountered no issues. Fiddled with mounting the pcem-made VHD in Hyper-V machines, or even directly under Windows, and viceversa (VHDs made in Hyper-V mounted under PCem), and all works flawlessly.
Thanks!
Thanks for testing it. Glad to hear that you haven't found any issues so far.

Post Reply