-
Notifications
You must be signed in to change notification settings - Fork 48
cache sync options #447
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
base: main
Are you sure you want to change the base?
cache sync options #447
Changes from all commits
6ac25da
51edc9d
13e1760
22cd5ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,6 +210,19 @@ See https://cloudinit.readthedocs.io/en/latest/reference/datasources/nocloud.htm | |
| - `path`: the absolute path to the disk image file or block device. | ||
| - `type`: the backing type. Use `image` (default) for a disk image file, or `dev` to attach a host block device (for example, /dev/disk1 or /dev/disk1s1). Attaching a block device may require root privileges; use with care. | ||
| - `deviceId`: `/dev/disk/by-id/` identifier to use for this device. | ||
| - `cache`: disk image caching mode (only for `type=image`, not supported for block devices). Valid values: | ||
| - `automatic` (default): allows the virtualization framework to automatically determine whether to enable data caching | ||
| - `cached`: enables data caching | ||
| - `uncached`: disables data caching | ||
| - `sync`: synchronization mode. Valid values differ by backing type: | ||
| - For disk images (`type=image`): | ||
| - `full`: synchronizes data to the permanent storage | ||
| - `fsync` (default): synchronizes data using the system's best-effort synchronization mode | ||
| - `none`: disables data synchronization | ||
| - For block devices (`type=dev`): | ||
| - `full` (default): synchronizes data to the permanent storage | ||
| - `none`: disables data synchronization | ||
| - Note: `fsync` is not supported for block devices | ||
|
|
||
| #### Example | ||
|
|
||
|
|
@@ -223,12 +236,27 @@ Attach a host block device instead (may require root privileges): | |
| --device virtio-blk,path=/dev/disk2,type=dev | ||
| ``` | ||
|
|
||
| Block device with sync mode disabled for maximum performance: | ||
| ``` | ||
| --device virtio-blk,path=/dev/disk2,type=dev,sync=none | ||
| ``` | ||
|
|
||
| For ephemeral VMs where data persistence is not critical (maximize performance): | ||
| ``` | ||
| --device virtio-blk,path=/Users/virtuser/vfkit.img,cache=cached,sync=none | ||
| ``` | ||
|
|
||
| For database or critical workloads (maximize data safety): | ||
| ``` | ||
| --device virtio-blk,path=/Users/virtuser/vfkit.img,cache=uncached,sync=full | ||
| ``` | ||
|
Comment on lines
+239
to
+252
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a language to the new fenced examples. These blocks are the ones currently tripping markdownlint Also applies to: 295-302, 337-349 🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 240-240: Fenced code blocks should have a language specified (MD040, fenced-code-language) [warning] 245-245: Fenced code blocks should have a language specified (MD040, fenced-code-language) [warning] 250-250: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||
|
|
||
| To also provide the cloud-init configuration you can add an additional virtio-blk device backed by an image containing the cloud-init configuration files | ||
| ``` | ||
| --device virtio-blk,path=/Users/virtuser/cloudinit.img | ||
| ``` | ||
|
|
||
| If you prefer to use the automatic ISO creation | ||
| If you prefer to use the automatic ISO creation | ||
| ``` | ||
| --cloud-init /Users/virtuser/user-data,/Users/virtuser/meta-data | ||
| ``` | ||
|
|
@@ -241,7 +269,21 @@ If you prefer to use the automatic ISO creation | |
| The `--device nvme` option adds a NVMe device to the virtual machine. The disk is backed by an image file on the host machine. This file is a raw image file. | ||
|
|
||
| #### Arguments | ||
| - `path`: the absolute path to the disk image file. | ||
| - `path`: the absolute path to the disk image file or block device. | ||
| - `type`: the backing type. Use `image` (default) for a disk image file, or `dev` to attach a host block device. Attaching a block device may require root privileges; use with care. | ||
|
Comment on lines
+272
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the NVMe and USB prose to mention block-device backends. These new Also applies to: 313-314 🤖 Prompt for AI Agents |
||
| - `cache`: disk image caching mode (only for `type=image`, not supported for block devices). Valid values: | ||
| - `automatic` (default): allows the virtualization framework to automatically determine whether to enable data caching | ||
| - `cached`: enables data caching | ||
| - `uncached`: disables data caching | ||
| - `sync`: synchronization mode. Valid values differ by backing type: | ||
| - For disk images (`type=image`): | ||
| - `full`: synchronizes data to the permanent storage | ||
| - `fsync` (default): synchronizes data using the system's best-effort synchronization mode | ||
| - `none`: disables data synchronization | ||
| - For block devices (`type=dev`): | ||
| - `full` (default): synchronizes data to the permanent storage | ||
| - `none`: disables data synchronization | ||
| - Note: `fsync` is not supported for block devices | ||
|
|
||
| #### Example | ||
|
|
||
|
|
@@ -250,6 +292,16 @@ This adds a NVMe device to the VM which will be backed by the disk image at `/Us | |
| --device nvme,path=/Users/virtuser/image.img | ||
| ``` | ||
|
|
||
| For high-performance ephemeral storage: | ||
| ``` | ||
| --device nvme,path=/Users/virtuser/image.img,cache=cached,sync=none | ||
| ``` | ||
|
|
||
| For database or critical workloads: | ||
| ``` | ||
| --device nvme,path=/Users/virtuser/image.img,cache=uncached,sync=full | ||
| ``` | ||
|
|
||
|
|
||
| ### USB Mass Storage | ||
|
|
||
|
|
@@ -258,8 +310,22 @@ This adds a NVMe device to the VM which will be backed by the disk image at `/Us | |
| The `--device usb-mass-storage` option adds a USB mass storage device to the virtual machine. The disk is backed by an image file on the host machine. This file is a raw image file or an ISO image. | ||
|
|
||
| #### Arguments | ||
| - `path`: the absolute path to the disk image file. | ||
| - `path`: the absolute path to the disk image file or block device. | ||
| - `type`: the backing type. Use `image` (default) for a disk image file, or `dev` to attach a host block device. Attaching a block device may require root privileges; use with care. | ||
| - `readonly`: if specified the device will be read only. | ||
| - `cache`: disk image caching mode (only for `type=image`, not supported for block devices). Valid values: | ||
| - `automatic` (default): allows the virtualization framework to automatically determine whether to enable data caching | ||
| - `cached`: enables data caching | ||
| - `uncached`: disables data caching | ||
| - `sync`: synchronization mode. Valid values differ by backing type: | ||
| - For disk images (`type=image`): | ||
| - `full`: synchronizes data to the permanent storage | ||
| - `fsync` (default): synchronizes data using the system's best-effort synchronization mode | ||
| - `none`: disables data synchronization | ||
| - For block devices (`type=dev`): | ||
| - `full` (default): synchronizes data to the permanent storage | ||
| - `none`: disables data synchronization | ||
| - Note: `fsync` is not supported for block devices | ||
|
|
||
| #### Example | ||
|
|
||
|
|
@@ -268,6 +334,21 @@ This adds a read only USB mass storage device to the VM which will be backed by | |
| --device usb-mass-storage,path=/Users/virtuser/distro.iso,readonly | ||
| ``` | ||
|
|
||
| For a read-only device with caching enabled: | ||
| ``` | ||
| --device usb-mass-storage,path=/Users/virtuser/distro.iso,readonly,cache=cached | ||
| ``` | ||
|
|
||
| For a writable device with full data safety: | ||
| ``` | ||
| --device usb-mass-storage,path=/Users/virtuser/data.img,cache=uncached,sync=full | ||
| ``` | ||
|
|
||
| When using a block device, you can specify the sync mode (cache is not supported): | ||
| ``` | ||
| --device usb-mass-storage,path=/dev/disk2,type=dev,sync=none | ||
| ``` | ||
|
|
||
| ### Network Block Device | ||
|
|
||
| #### Description | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -645,6 +645,17 @@ func (dev *VirtioBlk) ToCmdLine() ([]string, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (dev *VirtioBlk) validate() error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // First validate the disk storage config (cache/sync mode constraints) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err := dev.DiskStorageConfig.validate(); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Skip qcow2 check for block devices (they can't be qcow2 format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if dev.Type == DiskBackendBlockDevice { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+648
to
+656
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the block-device fast path from skipping required-path validation. This early return means One small way to preserve the old validation behavior func (dev *VirtioBlk) validate() error {
// First validate the disk storage config (cache/sync mode constraints)
if err := dev.DiskStorageConfig.validate(); err != nil {
return err
}
+ if dev.ImagePath == "" {
+ return fmt.Errorf("virtio-blk devices need the path to a disk image or block device")
+ }
// Skip qcow2 check for block devices (they can't be qcow2 format)
if dev.Type == DiskBackendBlockDevice {
return nil
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Then check for qcow2 images (only for disk image files) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| imgPath := dev.ImagePath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| file, err := os.Open(imgPath) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -930,10 +941,57 @@ func (typ DiskBackendType) IsValid() bool { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // DiskImageCachingMode describes the disk image caching mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // See: https://developer.apple.com/documentation/virtualization/vzdiskimagecachingmode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type DiskImageCachingMode string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // CachingModeAutomatic allows the virtualization framework to automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // determine whether to enable data caching. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CachingModeAutomatic DiskImageCachingMode = "automatic" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // CachingModeCached enables data caching. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CachingModeCached DiskImageCachingMode = "cached" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // CachingModeUncached disables data caching. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CachingModeUncached DiskImageCachingMode = "uncached" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (mode DiskImageCachingMode) IsValid() bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case CachingModeAutomatic, CachingModeCached, CachingModeUncached, "": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // DiskImageSynchronizationMode describes the disk image synchronization mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // See: https://developer.apple.com/documentation/virtualization/vzdiskimagesynchronizationmode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type DiskImageSynchronizationMode string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SyncModeFull synchronizes data to the permanent storage holding the disk image. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SyncModeFull DiskImageSynchronizationMode = "full" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SyncModeFsync synchronizes data to the drive using the system's best-effort synchronization mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SyncModeFsync DiskImageSynchronizationMode = "fsync" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // SyncModeNone disables data synchronization with the permanent storage. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SyncModeNone DiskImageSynchronizationMode = "none" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (mode DiskImageSynchronizationMode) IsValid() bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case SyncModeFull, SyncModeFsync, SyncModeNone, "": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type DiskStorageConfig struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StorageConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImagePath string `json:"imagePath,omitempty"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Type DiskBackendType `json:"type,omitempty"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ImagePath string `json:"imagePath,omitempty"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Type DiskBackendType `json:"type,omitempty"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CachingMode DiskImageCachingMode `json:"cachingMode,omitempty"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SynchronizationMode DiskImageSynchronizationMode `json:"synchronizationMode,omitempty"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type NetworkBlockStorageConfig struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -955,6 +1013,15 @@ func (config *DiskStorageConfig) ToCmdLine() ([]string, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.ReadOnly { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value += ",readonly" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.CachingMode != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value += fmt.Sprintf(",cache=%s", string(config.CachingMode)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.SynchronizationMode != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value += fmt.Sprintf(",sync=%s", string(config.SynchronizationMode)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return []string{"--device", value}, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -974,10 +1041,37 @@ func (config *DiskStorageConfig) FromOptions(options []option) error { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unexpected value for virtio-blk 'readonly' option: %s", option.value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.ReadOnly = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "cache": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode := DiskImageCachingMode(option.value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !mode.IsValid() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unexpected value for disk 'cache' option: %s (valid values: automatic, cached, uncached)", option.value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.CachingMode = mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "sync": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mode := DiskImageSynchronizationMode(option.value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !mode.IsValid() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unexpected value for disk 'sync' option: %s (valid values: full, fsync, none)", option.value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.SynchronizationMode = mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1044
to
+1055
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reject explicit empty Because Minimal fix case "cache":
+ if option.value == "" {
+ return fmt.Errorf("disk 'cache' option requires a value")
+ }
mode := DiskImageCachingMode(option.value)
if !mode.IsValid() {
return fmt.Errorf("unexpected value for disk 'cache' option: %s (valid values: automatic, cached, uncached)", option.value)
}
config.CachingMode = mode
case "sync":
+ if option.value == "" {
+ return fmt.Errorf("disk 'sync' option requires a value")
+ }
mode := DiskImageSynchronizationMode(option.value)
if !mode.IsValid() {
return fmt.Errorf("unexpected value for disk 'sync' option: %s (valid values: full, fsync, none)", option.value)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unknown option for %s devices: %s", config.DevName, option.key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return config.validate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (config *DiskStorageConfig) validate() error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Validate options for block devices (type=dev) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.Type == DiskBackendBlockDevice { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Cache mode is not supported for block devices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.CachingMode != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("cache mode is not supported for block devices (type=dev)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Block devices only support 'full' and 'none' sync modes, not 'fsync' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.SynchronizationMode == SyncModeFsync { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("sync mode 'fsync' is not supported for block devices (type=dev), use 'full' or 'none'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documented cache default does not match the current implementation.
These sections say image-backed disks default to
automatic, butpkg/vf/virtio.gocurrently maps an omitted cache mode tocached. Either documentcachedas the current backward-compatible default, or initializeCachingModeAutomaticwhen the option is omitted so the runtime behavior matches the docs.Also applies to: 274-286, 316-328
🤖 Prompt for AI Agents