diff --git a/xml.go b/xml.go index dc856b3..dbfd17d 100644 --- a/xml.go +++ b/xml.go @@ -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) +}