Documentation ¶
Index ¶
- Constants
- Variables
- func LayoutFromYaml(newDir, gadgetYaml string, model gadget.Model) (*gadget.LaidOutVolume, error)
- func LayoutMultiVolumeFromYaml(newDir, kernelDir, gadgetYaml string, model gadget.Model) (map[string]*gadget.LaidOutVolume, error)
- func MustLayOutSingleVolumeFromGadget(gadgetRoot, kernelRoot string, model gadget.Model) (*gadget.LaidOutVolume, error)
- func WriteGadgetYaml(newDir, gadgetYaml string) (string, error)
- type ModelCharacteristics
Constants ¶
const ExpectedLUKSEncryptedRaspiDiskVolumeDeviceTraitsJSON = `` /* 2298-byte string literal not displayed */
const ExpectedRaspiDiskVolumeDeviceTraitsJSON = `` /* 2187-byte string literal not displayed */
const ExpectedRaspiDiskVolumeNoSaveDeviceTraitsJSON = `` /* 1705-byte string literal not displayed */
const MockExtraVolumeYAML = `` /* 352-byte string literal not displayed */
const MultiVolumeUC20GadgetYaml = SingleVolumeUC20GadgetYaml + `
foo:
schema: gpt
structure:
- name: barething
type: bare
size: 4096
- name: nofspart
type: A11D2A7C-D82A-4C2F-8A01-1805240E6626
size: 4096
- name: some-filesystem
filesystem: ext4
type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
size: 1G
`
const RaspiSimplifiedNoSaveYaml = `` /* 418-byte string literal not displayed */
from a rpi without the kernel assets or content layout for simplicity's sake and without ubuntu-save
const RaspiSimplifiedYaml = `` /* 557-byte string literal not displayed */
from a rpi without the kernel assets or content layout for simplicity's sake
const RaspiUC18SimplifiedYaml = `` /* 169-byte string literal not displayed */
from UC18 image, for testing the implicit system data partition case
const SingleVolumeClassicWithModesGadgetYaml = `` /* 1599-byte string literal not displayed */
const SingleVolumeUC20GadgetYaml = `` /* 961-byte string literal not displayed */
const UC16YAMLImplicitSystemData = `` /* 408-byte string literal not displayed */
adapted from https://github.com/snapcore/pc-amd64-gadget/blob/16/gadget.yaml but without the content
const VMMultiVolumeUC20DiskTraitsJSON = `` /* 4006-byte string literal not displayed */
const VMSingleVolumeUC20DiskTraitsJSON = `` /* 2477-byte string literal not displayed */
like VMMultiVolumeUC20DiskTraitsJSON but without the foo volume
Variables ¶
var ExpectedLUKSEncryptedRaspiDiskVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", OriginalKernelPath: "/dev/mmcblk0", DiskID: "7c301cbd", Size: 30528 * quantity.SizeMiB, SectorSize: 512, Schema: "dos", StructureEncryption: map[string]gadget.StructureEncryptionParameters{ "ubuntu-data": {Method: gadget.EncryptionLUKS}, "ubuntu-save": {Method: gadget.EncryptionLUKS}, }, Structure: []gadget.DiskStructureDeviceTraits{ expPiSeedStructureTraits, expPiBootStructureTraits, expPiSaveEncStructureTraits, expPiDataEncStructureTraits, }, }
ExpectedLUKSEncryptedRaspiDiskVolumeDeviceTraits is like ExpectedRaspiDiskVolumeDeviceTraits, but it uses the "-enc" suffix for the filesystem labels and has crypto_LUKS as the filesystem types
var ExpectedLUKSEncryptedRaspiMockDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/mmcblk0", DevPath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", DevNum: "179:0", DiskUsableSectorEnd: 30528 * oneMeg / 512, DiskSizeInBytes: 30528 * oneMeg, SectorSizeBytes: 512, DiskSchema: "dos", ID: "7c301cbd", Structure: []disks.Partition{ mockSeedPartition, mockBootPartition, { PartitionUUID: "7c301cbd-03", PartitionType: "83", FilesystemLabel: "ubuntu-save-enc", FilesystemUUID: "1cdd5826-e9de-4d27-83f7-20249e710590", FilesystemType: "crypto_LUKS", Major: 179, Minor: 3, KernelDeviceNode: "/dev/mmcblk0p3", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3", DiskIndex: 3, StartInBytes: (1 + 1200 + 750) * oneMeg, SizeInBytes: 16 * oneMeg, }, { PartitionUUID: "7c301cbd-04", PartitionType: "83", FilesystemLabel: "ubuntu-data-enc", FilesystemUUID: "d7f39661-1da0-48de-8967-ce41343d4345", FilesystemType: "crypto_LUKS", Major: 179, Minor: 4, KernelDeviceNode: "/dev/mmcblk0p4", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4", DiskIndex: 4, StartInBytes: (1 + 1200 + 750 + 16) * oneMeg, SizeInBytes: (30528 - (1 + 1200 + 750 + 16)) * oneMeg, }, }, }
ExpectedLUKSEncryptedRaspiMockDiskMapping is like ExpectedRaspiMockDiskMapping, but it uses the "-enc" suffix for the filesystem labels and has crypto_LUKS as the filesystem types
var ExpectedRaspiDiskVolumeDeviceNoSaveTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", OriginalKernelPath: "/dev/mmcblk0", DiskID: "7c301cbd", Size: 30528 * quantity.SizeMiB, SectorSize: 512, Schema: "dos", StructureEncryption: map[string]gadget.StructureEncryptionParameters{}, Structure: []gadget.DiskStructureDeviceTraits{ expPiSeedStructureTraits, expPiBootStructureTraits, expPiDataNoSaveStructureTraits, }, }
var ExpectedRaspiDiskVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", OriginalKernelPath: "/dev/mmcblk0", DiskID: "7c301cbd", Size: 30528 * quantity.SizeMiB, SectorSize: 512, Schema: "dos", StructureEncryption: map[string]gadget.StructureEncryptionParameters{}, Structure: []gadget.DiskStructureDeviceTraits{ expPiSeedStructureTraits, expPiBootStructureTraits, expPiSaveStructureTraits, expPiDataStructureTraits, }, }
var ExpectedRaspiMockDiskInstallModeMapping = &disks.MockDiskMapping{ DevNode: "/dev/mmcblk0", DevPath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", DevNum: "179:0", DiskUsableSectorEnd: 30528 * oneMeg / 512, DiskSizeInBytes: 30528 * oneMeg, SectorSizeBytes: 512, DiskSchema: "dos", ID: "7c301cbd", Structure: []disks.Partition{ mockSeedPartition, }, }
ExpectedRaspiMockDiskInstallModeMapping is like ExpectedRaspiMockDiskMapping but for fresh install mode image where we only have the ubuntu-seed partition on disk.
var ExpectedRaspiMockDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/mmcblk0", DevPath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", DevNum: "179:0", DiskUsableSectorEnd: 30528 * oneMeg / 512, DiskSizeInBytes: 30528 * oneMeg, SectorSizeBytes: 512, DiskSchema: "dos", ID: "7c301cbd", Structure: []disks.Partition{ mockSeedPartition, mockBootPartition, { PartitionUUID: "7c301cbd-03", PartitionType: "83", FilesystemLabel: "ubuntu-save", FilesystemUUID: "1cdd5826-e9de-4d27-83f7-20249e710590", FilesystemType: "ext4", Major: 179, Minor: 3, KernelDeviceNode: "/dev/mmcblk0p3", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3", DiskIndex: 3, StartInBytes: (1 + 1200 + 750) * oneMeg, SizeInBytes: 16 * oneMeg, }, { PartitionUUID: "7c301cbd-04", PartitionType: "83", FilesystemLabel: "ubuntu-data", FilesystemUUID: "d7f39661-1da0-48de-8967-ce41343d4345", FilesystemType: "ext4", Major: 179, Minor: 4, KernelDeviceNode: "/dev/mmcblk0p4", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4", DiskIndex: 4, StartInBytes: (1 + 1200 + 750 + 16) * oneMeg, SizeInBytes: (30528 - (1 + 1200 + 750 + 16)) * oneMeg, }, }, }
var ExpectedRaspiMockDiskMappingNoSave = &disks.MockDiskMapping{ DevNode: "/dev/mmcblk0", DevPath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", DevNum: "179:0", DiskUsableSectorEnd: 30528 * oneMeg / 512, DiskSizeInBytes: 30528 * oneMeg, SectorSizeBytes: 512, DiskSchema: "dos", ID: "7c301cbd", Structure: []disks.Partition{ mockSeedPartition, mockBootPartition, { PartitionUUID: "7c301cbd-03", PartitionType: "83", FilesystemLabel: "ubuntu-data", FilesystemUUID: "d7f39661-1da0-48de-8967-ce41343d4345", FilesystemType: "ext4", Major: 179, Minor: 3, KernelDeviceNode: "/dev/mmcblk0p3", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3", DiskIndex: 3, StartInBytes: (1 + 1200 + 750) * oneMeg, SizeInBytes: (30528 - (1 + 1200 + 750)) * oneMeg, }, }, }
var ExpectedRaspiUC18DiskVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", OriginalKernelPath: "/dev/mmcblk0", DiskID: "7c301cbd", Size: 32010928128, SectorSize: 512, Schema: "dos", Structure: []gadget.DiskStructureDeviceTraits{ { OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1", OriginalKernelPath: "/dev/mmcblk0p1", PartitionUUID: "7c301cbd-01", PartitionType: "0C", PartitionLabel: "", FilesystemUUID: "23F9-881F", FilesystemLabel: "system-boot", FilesystemType: "vfat", Offset: quantity.OffsetMiB, Size: 256 * quantity.SizeMiB, }, }, }
ExpectedRaspiUC18DiskVolumeDeviceTraits, for testing the implicit system data partition case
var ExpectedRaspiUC18MockDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/mmcblk0", DevPath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0", DevNum: "179:0", DiskUsableSectorEnd: 30528 * oneMeg / 512, DiskSizeInBytes: 30528 * oneMeg, SectorSizeBytes: 512, DiskSchema: "dos", ID: "7c301cbd", Structure: []disks.Partition{ { PartitionUUID: "7c301cbd-01", PartitionType: "0C", FilesystemLabel: "system-boot", FilesystemUUID: "23F9-881F", FilesystemType: "vfat", Major: 179, Minor: 1, KernelDeviceNode: "/dev/mmcblk0p1", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1", DiskIndex: 1, StartInBytes: oneMeg, SizeInBytes: 256 * oneMeg, }, { PartitionUUID: "7c301cbd-02", PartitionType: "83", FilesystemLabel: "writable", FilesystemUUID: "cba2b8b3-c2e4-4e51-9a57-d35041b7bf9a", FilesystemType: "ext4", Major: 179, Minor: 2, KernelDeviceNode: "/dev/mmcblk0p2", KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p2", DiskIndex: 2, StartInBytes: (1 + 256) * oneMeg, SizeInBytes: 32270 * oneMeg, }, }, }
ExpectedRaspiUC18MockDiskMapping, for testing the implicit system data partition case
var MockExtraVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/block/foo", OriginalKernelPath: "/dev/foo", DiskID: "651AC800-B9FB-4B9D-B6D3-A72EB54D9006", SectorSize: 512, Size: 6000 * quantity.SizeMiB, Schema: "gpt", Structure: []gadget.DiskStructureDeviceTraits{ { PartitionLabel: "nofspart", PartitionUUID: "C5A930DF-E86A-4BAE-A4C5-C861353796E6", PartitionType: "EBBEADAF-22C9-E33B-8F5D-0E81686A68CB", OriginalDevicePath: "/sys/block/foo/foo1", OriginalKernelPath: "/dev/foo1", Offset: quantity.OffsetMiB + quantity.OffsetKiB, Size: 4096, }, { PartitionLabel: "some-filesystem", PartitionUUID: "DA2ADBC8-90DF-4B1D-A93F-A92516C12E01", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", OriginalDevicePath: "/sys/block/foo/foo2", OriginalKernelPath: "/dev/foo2", FilesystemLabel: "some-filesystem", FilesystemUUID: "3E3D392C-5D50-4C84-8A6E-09B7A3FEA2C7", FilesystemType: "ext4", Offset: quantity.OffsetMiB + quantity.OffsetKiB + 4096, Size: quantity.SizeGiB, }, }, }
var MockExtraVolumeDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/foo", DevPath: "/sys/block/foo", DevNum: "525:1", DiskUsableSectorEnd: 6000*oneMeg/512 - 34, DiskSizeInBytes: 6000 * oneMeg, SectorSizeBytes: 512, DiskSchema: "gpt", ID: "651AC800-B9FB-4B9D-B6D3-A72EB54D9006", Structure: []disks.Partition{ { PartitionLabel: "nofspart", PartitionUUID: "C5A930DF-E86A-4BAE-A4C5-C861353796E6", PartitionType: "EBBEADAF-22C9-E33B-8F5D-0E81686A68CB", FilesystemType: "", Major: 525, Minor: 2, KernelDeviceNode: "/dev/foo1", KernelDevicePath: "/sys/block/foo/foo1", DiskIndex: 1, StartInBytes: oneMeg + 1024, SizeInBytes: 4096, }, { PartitionLabel: "some-filesystem", PartitionUUID: "DA2ADBC8-90DF-4B1D-A93F-A92516C12E01", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemLabel: "some-filesystem", FilesystemUUID: "3E3D392C-5D50-4C84-8A6E-09B7A3FEA2C7", FilesystemType: "ext4", Major: 525, Minor: 3, KernelDeviceNode: "/dev/foo2", KernelDevicePath: "/sys/block/foo/foo2", DiskIndex: 2, StartInBytes: oneMeg + 1024 + 4096, SizeInBytes: 1024 * oneMeg, }, }, }
var UC16DeviceLayout = gadget.OnDiskVolume{ Structure: []gadget.OnDiskStructure{ { LaidOutStructure: gadget.LaidOutStructure{ VolumeStructure: &gadget.VolumeStructure{ Name: "BIOS Boot", Type: "21686148-6449-6E6F-744E-656564454649", ID: "b2e891ee-b971-4a2b-b874-694bbf9b821a", Size: quantity.SizeMiB, }, StartOffset: quantity.OffsetMiB, }, DiskIndex: 1, Node: "/dev/sda1", Size: quantity.SizeMiB, }, { LaidOutStructure: gadget.LaidOutStructure{ VolumeStructure: &gadget.VolumeStructure{ Name: "EFI System", Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", ID: "a87e9dcb-b1e1-4eab-89cf-1c2fc057b038", Label: "system-boot", Filesystem: "vfat", Size: 52428800, }, StartOffset: 2097152, }, DiskIndex: 2, Node: "/dev/sda2", Size: 52428800, }, { LaidOutStructure: gadget.LaidOutStructure{ VolumeStructure: &gadget.VolumeStructure{ Name: "writable", Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", ID: "cba2b8b3-c2e4-4e51-9a57-d35041b7bf9a", Label: "writable", Filesystem: "ext4", Size: 10682875392, }, StartOffset: 54525952, }, DiskIndex: 3, Node: "/dev/sda3", Size: 10682875392, }, }, ID: "2a9b0671-4597-433b-b3ad-be99950e8c5e", Device: "/dev/sda", Schema: "gpt", Size: 10737418240, UsableSectorsEnd: 20971487, SectorSize: 512, }
uc16 layout from a VM that has an implicit system-data as the third partition
var UC16ImplicitSystemDataDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda", OriginalKernelPath: "/dev/sda", DiskID: "f69dbcfe-1258-4b36-9d1f-817fdeb61aa3", Size: 10737418240, SectorSize: 512, Schema: "gpt", Structure: []gadget.DiskStructureDeviceTraits{ { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1", OriginalKernelPath: "/dev/sda1", PartitionUUID: "420e5a20-b888-42e2-b7df-ced5cbf14517", PartitionType: "21686148-6449-6E6F-744E-656564454649", PartitionLabel: "BIOS\\x20Boot", Offset: quantity.OffsetMiB, Size: quantity.SizeMiB, }, { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2", OriginalKernelPath: "/dev/sda2", PartitionUUID: "fc8626b9-af30-4b3c-83c4-05bed39bb82e", PartitionType: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", PartitionLabel: "EFI\\x20System", FilesystemType: "vfat", FilesystemUUID: "6D21-B3FE", FilesystemLabel: "system-boot", Offset: quantity.OffsetMiB + quantity.OffsetMiB, Size: 50 * quantity.SizeMiB, }, }, }
var UC16ImplicitSystemDataMockDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/sda", DevPath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda", DevNum: "600:1", DiskUsableSectorEnd: 10240*oneMeg/512 - 33, DiskSizeInBytes: 10240 * oneMeg, SectorSizeBytes: 512, DiskSchema: "gpt", ID: "f69dbcfe-1258-4b36-9d1f-817fdeb61aa3", Structure: []disks.Partition{ { KernelDeviceNode: "/dev/sda1", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1", PartitionUUID: "420e5a20-b888-42e2-b7df-ced5cbf14517", PartitionLabel: "BIOS\\x20Boot", PartitionType: "21686148-6449-6E6F-744E-656564454649", StartInBytes: oneMeg, SizeInBytes: oneMeg, Major: 600, Minor: 2, DiskIndex: 1, }, { KernelDeviceNode: "/dev/sda2", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2", PartitionUUID: "fc8626b9-af30-4b3c-83c4-05bed39bb82e", PartitionLabel: "EFI\\x20System", PartitionType: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", FilesystemUUID: "6D21-B3FE", FilesystemLabel: "system-boot", FilesystemType: "vfat", StartInBytes: (1 + 1) * oneMeg, SizeInBytes: 50 * oneMeg, Major: 600, Minor: 3, DiskIndex: 2, }, { KernelDeviceNode: "/dev/sda3", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda3", PartitionUUID: "ade3ba65-7831-fd40-bbe2-e01c9774ed5b", PartitionLabel: "writable", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "cba2b8b3-c2e4-4e51-9a57-d35041b7bf9a", FilesystemLabel: "writable", FilesystemType: "ext4", StartInBytes: (50 + 1 + 1) * oneMeg, SizeInBytes: 10682875392, Major: 600, Minor: 4, DiskIndex: 3, }, }, }
var VMExtraVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb", OriginalKernelPath: "/dev/vdb", DiskID: "86964016-3b5c-477e-9828-24ba9c552d39", Size: 5120 * quantity.SizeMiB, SectorSize: quantity.Size(512), Schema: "gpt", Structure: []gadget.DiskStructureDeviceTraits{ { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb1", OriginalKernelPath: "/dev/vdb1", PartitionUUID: "691d89b6-d4c1-4c08-a060-fc10d98337da", PartitionLabel: "nofspart", PartitionType: "A11D2A7C-D82A-4C2F-8A01-1805240E6626", Offset: quantity.OffsetMiB + 4096, Size: 4096, }, { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb2", OriginalKernelPath: "/dev/vdb2", PartitionUUID: "7a3c051c-eae2-4c36-bed8-1914709ebf4c", PartitionLabel: "some-filesystem", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "afb36b05-3796-4edf-87aa-9f9aa22f9324", FilesystemLabel: "some-filesystem", FilesystemType: "ext4", Offset: quantity.OffsetMiB + 4096 + 4096, Size: quantity.SizeGiB, }, }, }
var VMExtraVolumeDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/vdb", DevPath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb", DevNum: "525:1", DiskUsableSectorEnd: 5120*oneMeg/512 - 34, DiskSizeInBytes: 5120 * oneMeg, SectorSizeBytes: 512, DiskSchema: "gpt", ID: "86964016-3b5c-477e-9828-24ba9c552d39", Structure: []disks.Partition{ { PartitionLabel: "nofspart", PartitionUUID: "691d89b6-d4c1-4c08-a060-fc10d98337da", PartitionType: "A11D2A7C-D82A-4C2F-8A01-1805240E6626", FilesystemType: "", Major: 525, Minor: 2, KernelDeviceNode: "/dev/vdb1", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb1", DiskIndex: 1, StartInBytes: oneMeg + 4096, SizeInBytes: 4096, }, { PartitionLabel: "some-filesystem", PartitionUUID: "7a3c051c-eae2-4c36-bed8-1914709ebf4c", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemLabel: "some-filesystem", FilesystemUUID: "afb36b05-3796-4edf-87aa-9f9aa22f9324", FilesystemType: "ext4", Major: 525, Minor: 3, KernelDeviceNode: "/dev/vdb2", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb2", DiskIndex: 2, StartInBytes: 4096 + oneMeg + 4096, SizeInBytes: 1024 * oneMeg, }, }, }
var VMSystemVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{ OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda", OriginalKernelPath: "/dev/vda", DiskID: "f0eef013-a777-4a27-aaf0-dbb5cf68c2b6", Schema: "gpt", Size: 5120 * quantity.SizeMiB, SectorSize: quantity.Size(512), Structure: []gadget.DiskStructureDeviceTraits{ { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda1", OriginalKernelPath: "/dev/vda1", PartitionUUID: "420e5a20-b888-42e2-b7df-ced5cbf14517", PartitionLabel: "BIOS\\x20Boot", PartitionType: "21686148-6449-6E6F-744E-656564454649", Offset: quantity.OffsetMiB, Size: quantity.SizeMiB, }, { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda2", OriginalKernelPath: "/dev/vda2", PartitionUUID: "4b436628-71ba-43f9-aa12-76b84fe32728", PartitionLabel: "ubuntu-seed", PartitionType: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", FilesystemUUID: "04D6-5AE2", FilesystemLabel: "ubuntu-seed", FilesystemType: "vfat", Offset: (1 + 1) * quantity.OffsetMiB, Size: 1200 * quantity.SizeMiB, }, { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda3", OriginalKernelPath: "/dev/vda3", PartitionUUID: "ade3ba65-7831-fd40-bbe2-e01c9774ed5b", PartitionLabel: "ubuntu-boot", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "5b3e775a-407d-4af7-aa16-b92a8b7507e6", FilesystemLabel: "ubuntu-boot", FilesystemType: "ext4", Offset: (1 + 1 + 1200) * quantity.OffsetMiB, Size: 750 * quantity.SizeMiB, }, { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda4", OriginalKernelPath: "/dev/vda4", PartitionUUID: "f1d01870-194b-8a45-84c0-0d1c90e17d9d", PartitionLabel: "ubuntu-save", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "6766b605-9cd5-47ae-bc48-807c778b9987", FilesystemLabel: "ubuntu-save", FilesystemType: "ext4", Offset: (1 + 1 + 1200 + 750) * quantity.OffsetMiB, Size: 16 * quantity.SizeMiB, }, { OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda5", OriginalKernelPath: "/dev/vda5", PartitionUUID: "4994f0e5-1ead-1a4d-b696-2d8cb1fa980d", PartitionLabel: "ubuntu-data", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "4e29a1e9-526d-48fc-a5c2-4f97e7e011e2", FilesystemLabel: "ubuntu-data", FilesystemType: "ext4", Offset: (1 + 1 + 1200 + 750 + 16) * quantity.OffsetMiB, Size: ((5120*quantity.SizeMiB - 33*512) - (1+1+1200+750+16)*quantity.SizeMiB), }, }, }
var VMSystemVolumeDiskMapping = &disks.MockDiskMapping{ DevNode: "/dev/vda", DevPath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda", DevNum: "600:1", DiskUsableSectorEnd: 5120*oneMeg/512 - 34, DiskSizeInBytes: 5120 * oneMeg, SectorSizeBytes: 512, DiskSchema: "gpt", ID: "f0eef013-a777-4a27-aaf0-dbb5cf68c2b6", Structure: []disks.Partition{ { KernelDeviceNode: "/dev/vda1", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda1", PartitionUUID: "420e5a20-b888-42e2-b7df-ced5cbf14517", PartitionLabel: "BIOS\\x20Boot", PartitionType: "21686148-6449-6E6F-744E-656564454649", StartInBytes: oneMeg, SizeInBytes: oneMeg, Major: 600, Minor: 2, DiskIndex: 1, }, { KernelDeviceNode: "/dev/vda2", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda2", PartitionUUID: "4b436628-71ba-43f9-aa12-76b84fe32728", PartitionLabel: "ubuntu-seed", PartitionType: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", FilesystemUUID: "04D6-5AE2", FilesystemLabel: "ubuntu-seed", FilesystemType: "vfat", StartInBytes: (1 + 1) * oneMeg, SizeInBytes: 1200 * oneMeg, Major: 600, Minor: 3, DiskIndex: 2, }, { KernelDeviceNode: "/dev/vda3", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda3", PartitionUUID: "ade3ba65-7831-fd40-bbe2-e01c9774ed5b", PartitionLabel: "ubuntu-boot", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "5b3e775a-407d-4af7-aa16-b92a8b7507e6", FilesystemLabel: "ubuntu-boot", FilesystemType: "ext4", StartInBytes: (1200 + 1 + 1) * oneMeg, SizeInBytes: 750 * oneMeg, Major: 600, Minor: 4, DiskIndex: 3, }, { KernelDeviceNode: "/dev/vda4", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda4", PartitionUUID: "f1d01870-194b-8a45-84c0-0d1c90e17d9d", PartitionLabel: "ubuntu-save", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "6766b605-9cd5-47ae-bc48-807c778b9987", FilesystemLabel: "ubuntu-save", FilesystemType: "ext4", StartInBytes: (1200 + 1 + 1 + 750) * oneMeg, SizeInBytes: 16 * oneMeg, Major: 600, Minor: 5, DiskIndex: 4, }, { KernelDeviceNode: "/dev/vda5", KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda5", PartitionUUID: "4994f0e5-1ead-1a4d-b696-2d8cb1fa980d", PartitionLabel: "ubuntu-data", PartitionType: "0FC63DAF-8483-4772-8E79-3D69D8477DE4", FilesystemUUID: "4e29a1e9-526d-48fc-a5c2-4f97e7e011e2", FilesystemLabel: "ubuntu-data", FilesystemType: "ext4", StartInBytes: (1200 + 1 + 1 + 750 + 16) * oneMeg, SizeInBytes: ((5120*oneMeg - 33*512) - (1+1+1200+750+16)*oneMeg), Major: 600, Minor: 6, DiskIndex: 5, }, }, }
Functions ¶
func LayoutFromYaml ¶
LayoutFromYaml returns a LaidOutVolume for the given gadget.yaml string. It currently only supports gadget.yaml's with a single volume in them. An empty directory to use to create a gadget.yaml file should be provided, such as c.MkDir() in tests.
func LayoutMultiVolumeFromYaml ¶
func LayoutMultiVolumeFromYaml(newDir, kernelDir, gadgetYaml string, model gadget.Model) (map[string]*gadget.LaidOutVolume, error)
LayoutMultiVolumeFromYaml returns all LaidOutVolumes for the given gadget.yaml string and works for either single or multiple volume gadget.yaml's. An empty directory to use to create a gadget.yaml file should be provided, such as c.MkDir() in tests.
func MustLayOutSingleVolumeFromGadget ¶
func MustLayOutSingleVolumeFromGadget(gadgetRoot, kernelRoot string, model gadget.Model) (*gadget.LaidOutVolume, error)
MustLayOutSingleVolumeFromGadget takes a gadget rootdir and lays out the partitions as specified. This function does not handle multiple volumes and is meant for test helpers only. For runtime users, with multiple volumes handled by choosing the ubuntu-* role volume, see LaidOutVolumesFromGadget
func WriteGadgetYaml ¶
Types ¶
type ModelCharacteristics ¶
func (*ModelCharacteristics) Classic ¶
func (m *ModelCharacteristics) Classic() bool
func (*ModelCharacteristics) Grade ¶
func (m *ModelCharacteristics) Grade() asserts.ModelGrade