Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to an external snapshot file. #12

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LindirQuenya
Copy link
Member

@LindirQuenya LindirQuenya commented Jan 6, 2023

Improved variant on #11, using a read-only external state file with a read-only disk to achieve complete hash stability. All writes are performed to the in-memory tmpfs, and don't get written back to the state file. The state file can also be compressed, for extra space savings. The QEMU command line should be changed to: qemu-system-i386 -machine pc-i440fx-5.2 -m 128 -net nic,model=virtio-net-pci -net user,hostfwd=tcp:127.0.0.1:22500-:80 -qmp tcp:127.0.0.1:22501,server,nowait -qmp tcp:127.0.0.1:22502,server,nowait -drive file=alpine.qcow2,if=virtio,readonly=on -serial stdio -incoming "exec:7za x -so snapshot.7z" -display none
The corresponding arguments list in services.json would be:

[
  "-machine",
  "pc-i440fx-5.2",
  "-m",
  "128",
  "-net",
  "nic,model=virtio-net-pci",
  "-net",
  "user,hostfwd=tcp:127.0.0.1:22500-:80",
  "-qmp",
  "tcp:127.0.0.1:22501,server,nowait",
  "-qmp",
  "tcp:127.0.0.1:22502,server,nowait",
  "-drive",
  "file=alpine.qcow2,if=virtio,readonly=on",
  "-serial",
  "stdio",
  "-incoming",
  "exec:7za x -so snapshot.7z",
  "-display",
  "none"
]

A built image and snapshot may be found here. Note that Windows will require some extra steps: you'll need to copy 7za.exe to Server, and update QEMU to at least 7.2.0.

I'll mark this as ready for review after I've tested it on Windows.

@LindirQuenya
Copy link
Member Author

LindirQuenya commented Jan 6, 2023

Hm, Windows support doesn't seem to be as good as I thought. No matter what I put into the exec: argument (even things that should be found, like powershell), it always fails with "No such file or directory." Perhaps I will be able to look into this later.

@LindirQuenya
Copy link
Member Author

Here's what I've found so far:

  • The QEMU windows builds need to include GLib's gspawn-win32-helper.exe and gspawn-win32-helper-console.exe.
  • migration/exec.c needs a two-line change, from /bin/sh -cC:\Windows\System32\cmd.exe /c
  • And there might be more, or I might just need to recompile it against my version of GLib.

I'll probably have a bit more time to investigate this evening.

@puigru
Copy link
Collaborator

puigru commented Jan 12, 2023

@LindirQuenya Awesome work on this, it looks like you're almost there. This would be great to have.

P.S. Definitely submit the patch to QEMU when you do.

@puigru
Copy link
Collaborator

puigru commented Jan 12, 2023

Oh, one small thing. Windows may not necessarily be on the C:\ drive. There are specific APIs to get the path to the system folder (a or b, c). That said, if exec'ing looks in PATH, then just cmd.exe should work.

@LindirQuenya
Copy link
Member Author

LindirQuenya commented Jan 15, 2023

With those changes, the patch became a bit more complicated. I'll try to submit it to QEMU tomorrow.

@LindirQuenya
Copy link
Member Author

From my minimal testing of my debug build, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants