| 1 | |
| 2 | |
| 3 | package guestos |
| 4 | |
| 5 | import ( |
| 6 | "context" |
| 7 | "errors" |
| 8 | "io" |
| 9 | "os" |
| 10 | "path/filepath" |
| 11 | |
| 12 | "github.com/google/uuid" |
| 13 | ) |
| 14 | |
| 15 | func windowsHostStorage(context.Context, uuid.UUID, windowsHostStorageRequest) (windowsHostStorageState, error) { |
| 16 | return windowsHostStorageState{}, errors.New("Windows 客机存储迁移需要 Windows Hyper-V 主机") |
| 17 | } |
| 18 | |
| 19 | func WindowsPrivateStoragePaths() []string { return nil } |
| 20 | |
| 21 | func prepareWindowsStorageDisk(context.Context, string, string) error { return nil } |
| 22 | |
| 23 | func RepairWindowsHostManager(context.Context, string, string, io.Writer, io.Writer) error { |
| 24 | return errors.New("Windows 系统助手需要在原 Windows 主机上恢复") |
| 25 | } |
| 26 | |
| 27 | func replaceWindowsStorageProfile(path string, data []byte) error { |
| 28 | file, err := os.CreateTemp(filepath.Dir(path), ".windows-storage-*") |
| 29 | if err != nil { |
| 30 | return err |
| 31 | } |
| 32 | defer os.Remove(file.Name()) |
| 33 | _, err = file.Write(data) |
| 34 | if err == nil { |
| 35 | err = file.Sync() |
| 36 | } |
| 37 | if err = errors.Join(err, file.Close()); err != nil { |
| 38 | return err |
| 39 | } |
| 40 | return os.Rename(file.Name(), path) |
| 41 | } |