diff options
| author | Jeff Carr <[email protected]> | 2024-10-18 20:22:37 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-18 20:22:37 -0500 |
| commit | 70a506bc5941df1c4a7b46ec1288011ceb70ddd3 (patch) | |
| tree | f00b5778cf8515b448ba79385d401b402f420040 /xml.go | |
| parent | 8a2502c61bbff1f2d16afa2beadb14507afe5d7c (diff) | |
simple ethernet mac settings
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'xml.go')
| -rw-r--r-- | xml.go | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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) } } |
