From f42091a2ce37f54bb8ad365b31ae2395a9af1372 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 26 Oct 2024 02:31:52 -0500 Subject: network is maybe correct as virtio. pci needed? Signed-off-by: Jeff Carr --- libvirtxml.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'libvirtxml.go') diff --git a/libvirtxml.go b/libvirtxml.go index b702a1c..6d8aee8 100644 --- a/libvirtxml.go +++ b/libvirtxml.go @@ -173,14 +173,23 @@ func clearEthernet(domcfg *libvirtxml.Domain) { // 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" - type DomainInterfaceType string + // type DomainInterfaceType string + + var ib *libvirtxml.DomainInterfaceSourceBridge + ib = new(libvirtxml.DomainInterfaceSourceBridge) + ib.Bridge = brname newNet := libvirtxml.DomainInterface{ MAC: &libvirtxml.DomainInterfaceMAC{ Address: mac, }, + Source: &libvirtxml.DomainInterfaceSource{ + Bridge: ib, + }, + Model: &libvirtxml.DomainInterfaceModel{ + Type: "virtio", + }, Target: &libvirtxml.DomainInterfaceTarget{ - Dev: brname, }, } @@ -759,6 +768,22 @@ func dumpLibvirtxmlDomainNames() { field := t.Field(i) fmt.Println("DomainInterface:", field.Name) } + + var isource libvirtxml.DomainInterfaceSource + listFields(isource, "libvirtxml.DomainInterfaceSource") + + var ibridge libvirtxml.DomainInterfaceSourceBridge + listFields(ibridge, "libvirtxml.DomainInterfaceSourceBridge") +} + +func listFields(a any, name string) { + t := reflect.TypeOf(a) + + fmt.Println("Fields in", name) + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + fmt.Println(name, field.Name) + } } // dump out all the fields in libvirtxml.DomainDeviceList -- cgit v1.2.3