summaryrefslogtreecommitdiff
path: root/xml.go
diff options
context:
space:
mode:
Diffstat (limited to 'xml.go')
-rw-r--r--xml.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/xml.go b/xml.go
index 37cc01e..3fc012f 100644
--- a/xml.go
+++ b/xml.go
@@ -97,12 +97,14 @@ func setSimpleDisk(domcfg *libvirtxml.Domain, filename string) {
domcfg.Devices.Disks = append(domcfg.Devices.Disks, newDisk)
}
-func showMacs(domcfg *libvirtxml.Domain) []string {
+func getMacs(domcfg *libvirtxml.Domain) []string {
var macs []string
// Iterate over the network interfaces and print the MAC addresses
for _, iface := range domcfg.Devices.Interfaces {
if iface.MAC != nil {
- fmt.Printf("Interface: %s, MAC Address: %s\n", iface.Target.Dev, iface.MAC.Address)
+ // iface.MAC.Address = "aa:bb:aa:bb:aa:ff"
+ fmt.Printf("MAC Address: %+v\n", iface.MAC)
+ // fmt.Printf("Interface: %s, MAC Address: %s\n", iface.Target.Dev, iface.MAC.Address)
macs = append(macs, iface.MAC.Address)
} else {
fmt.Printf("Interface: %s, MAC Address: not available\n", iface.Target.Dev)
@@ -111,10 +113,14 @@ func showMacs(domcfg *libvirtxml.Domain) []string {
return macs
}
-func setMacs(domcfg *libvirtxml.Domain, mac string, brname string) {
+// removes all the ethernet interfaces
+func clearEthernet(domcfg *libvirtxml.Domain) {
// Clear out the existing disks (if any)
domcfg.Devices.Interfaces = nil
+}
+// add a new ethernet interface with mac assigned to bridge name
+func addEthernet(domcfg *libvirtxml.Domain, mac string, brname string) {
// Define a new disk with "mynew.qcow2"
newNet := libvirtxml.DomainInterface{
MAC: &libvirtxml.DomainInterfaceMAC{
@@ -140,6 +146,7 @@ func setRandomMacs(domcfg *libvirtxml.Domain) {
domcfg.Devices.Interfaces[i].MAC = newMac
// fmt.Printf("Disk Source %s\n", name)
- fmt.Printf("mac addr %s\n", x.MAC)
+ // fmt.Printf("mac addr %+v\n", x.MAC)
+ fmt.Printf("mac addr %s\n", x.MAC.Address)
}
}