diff options
| author | Jeff Carr <[email protected]> | 2024-10-18 08:18:11 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-18 08:18:11 -0500 |
| commit | bffee3265ee37633c7b9e3cf4ddfad3d0e9ee6b1 (patch) | |
| tree | 87fc3b9d927b2077291df289928887e1d13218e7 /xml.go | |
| parent | c9ccf688c27749dfbab31004b6258dbb759962b2 (diff) | |
simpleDisk() to add qcow2 file
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'xml.go')
| -rw-r--r-- | xml.go | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -76,3 +76,29 @@ func addDefaults(d *libvirtxml.Domain, filename string) { return } } + +func simpleDisk(domcfg *libvirtxml.Domain, filename string) { + // Clear out the existing disks (if any) + domcfg.Devices.Disks = nil + + // Define a new disk with "mynew.qcow2" + newDisk := libvirtxml.DomainDisk{ + Device: "disk", + Driver: &libvirtxml.DomainDiskDriver{ + Name: "qemu", + Type: "qcow2", + }, + Source: &libvirtxml.DomainDiskSource{ + File: &libvirtxml.DomainDiskSourceFile{ + File: filename, + }, + }, + Target: &libvirtxml.DomainDiskTarget{ + Dev: "vda", + Bus: "virtio", + }, + } + + // Add the new disk to the domain configuration + domcfg.Devices.Disks = append(domcfg.Devices.Disks, newDisk) +} |
