simpleDisk() to add qcow2 file
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
c9ccf688c2
commit
bffee3265e
26
xml.go
26
xml.go
|
@ -76,3 +76,29 @@ func addDefaults(d *libvirtxml.Domain, filename string) {
|
||||||
return
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue