network is maybe correct as virtio. pci needed?
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
7320fceb8d
commit
f42091a2ce
8
Makefile
8
Makefile
|
@ -17,10 +17,10 @@ xml-add:
|
|||
xml-add-save:
|
||||
./virtigo --libvirt ~/libvirt/*.xml --xml-ignore-disk=true --save
|
||||
|
||||
start-uptime.wit.com: build
|
||||
rm -f /tmp/blahcarr.xml /tmp/uptime.wit.com.xml
|
||||
./virtigo --start uptime.wit.com
|
||||
./virtigo --libvirt /tmp/uptime.wit.com.xml
|
||||
start-pihole.wit.com: build
|
||||
rm -f /tmp/blahcarr.xml /tmp/pihole.wit.com.xml
|
||||
./virtigo --start pihole.wit.com
|
||||
./virtigo --libvirt /tmp/pihole.wit.com.xml
|
||||
|
||||
old-start-all-droplets:
|
||||
curl --silent http://localhost:8080/start?start=git.wit.org
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<interface type='bridge'>
|
||||
<mac address='52:54:00:fb:7e:b1'/>
|
||||
<source bridge='worldbr'/>
|
||||
<model type='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||
</interface>
|
|
@ -112,3 +112,21 @@ DomainInterface: ROM
|
|||
DomainInterface: ACPI
|
||||
DomainInterface: Alias
|
||||
DomainInterface: Address
|
||||
Fields in libvirtxml.DomainInterfaceSource
|
||||
libvirtxml.DomainInterfaceSource User
|
||||
libvirtxml.DomainInterfaceSource Ethernet
|
||||
libvirtxml.DomainInterfaceSource VHostUser
|
||||
libvirtxml.DomainInterfaceSource Server
|
||||
libvirtxml.DomainInterfaceSource Client
|
||||
libvirtxml.DomainInterfaceSource MCast
|
||||
libvirtxml.DomainInterfaceSource Network
|
||||
libvirtxml.DomainInterfaceSource Bridge
|
||||
libvirtxml.DomainInterfaceSource Internal
|
||||
libvirtxml.DomainInterfaceSource Direct
|
||||
libvirtxml.DomainInterfaceSource Hostdev
|
||||
libvirtxml.DomainInterfaceSource UDP
|
||||
libvirtxml.DomainInterfaceSource VDPA
|
||||
libvirtxml.DomainInterfaceSource Null
|
||||
libvirtxml.DomainInterfaceSource VDS
|
||||
Fields in libvirtxml.DomainInterfaceSourceBridge
|
||||
libvirtxml.DomainInterfaceSourceBridge Bridge
|
||||
|
|
12
start.go
12
start.go
|
@ -49,8 +49,19 @@ func startDropletXml(start string) {
|
|||
// addEthernet(domcfg, "04:44:33:11:22:11", "worldbr")
|
||||
// addEthernet(domcfg, "04:44:33:33:44:55", "greenbr")
|
||||
|
||||
var count int = 0
|
||||
for _, n := range d.Networks {
|
||||
log.Info("add network", d.Hostname, "mac addr", n.Mac, "interface", n.Name)
|
||||
if n.Name != "worldbr" {
|
||||
log.Info("OVERRIDE BRIDGE WITH 'worldbr'")
|
||||
}
|
||||
addEthernet(domcfg, n.Mac, "worldbr")
|
||||
count += 1
|
||||
}
|
||||
if count == 1 {
|
||||
// this is normal
|
||||
} else {
|
||||
log.Info("WRONG NUMBER OF ETHERNET INTERFACES:", count)
|
||||
}
|
||||
|
||||
// add a check here to make these unique
|
||||
|
@ -60,6 +71,7 @@ func startDropletXml(start string) {
|
|||
fullname := findDisk(disk.Filename)
|
||||
if fullname == "" {
|
||||
log.Info("can not find disk", d.Hostname, "dir", disk.Filepath, "filename", disk.Filename)
|
||||
os.Exit(-1)
|
||||
} else {
|
||||
// qcow := "/home/nfs/" + d.Hostname + ".qcow2"
|
||||
setSimpleDisk(domcfg, fullname)
|
||||
|
|
Loading…
Reference in New Issue