On 2015-05-11 03:02, Wei ZHOU wrote:
Hi Mike,

Please apply the following patch to cloudstack, and copy the file
agent/bindir/libvirtqemuhook.in to repace /etc/libvirt/hooks/qemu on your
hosts


Wei,

I've applied the patch manually (git apply failed) and the error persists. Below you'll find the contents of /etc/libvirt/hooks/qemu (I've removed the licensing / header for brevity).

I've even stopped/started the router in case the patched script only runs when a VM is first started. I've included the domain.toxml() output below as well.

-- Mike

import sys
from xml.dom.minidom import parse
from cloudutils.configFileOps import configFileOps
from cloudutils.networkConfig import networkConfig
def isOldStyleBridge(brName):
    if brName.find("cloudVirBr") == 0:
       return True
    else:
       return False
def isNewStyleBridge(brName):
    if re.match(r"br(\w+)-(\d+)", brName) == None:
       return False
    else:
       return True
def getGuestNetworkDevice():
    netlib = networkConfig()
    cfo = configFileOps("/etc/cloudstack/agent/agent.properties")
    guestDev = cfo.getEntry("guest.network.device")
    enslavedDev = netlib.getEnslavedDev(guestDev, 1)
    return enslavedDev.split(".")[0]
def handleMigrateBegin():
    try:
        domain = parse(sys.stdin)
        for interface in domain.getElementsByTagName("interface"):
            source = interface.getElementsByTagName("source")[0]
            bridge = source.getAttribute("bridge")
            if isOldStyleBridge(bridge):
                vlanId = bridge.replace("cloudVirBr","")
            elif isNewStyleBridge(bridge):
                vlanId = re.sub(r"br(\w+)-","",bridge)
            else:
                continue
            phyDev = getGuestNetworkDevice()
            newBrName="br" + phyDev + "-" + vlanId
            source.setAttribute("bridge", newBrName)
        print(domain.toxml())
    except:
        pass
if __name__ == '__main__':
    if len(sys.argv) != 5:
        sys.exit(0)

    if sys.argv[2] == "migrate" and sys.argv[3] == "begin":
        handleMigrateBegin()



2015-05-11 12:04:36,831 DEBUG [kvm.resource.LibvirtComputingResource] (agentRequest-Handler-2:null) starting r-93-VM: <domain type='k
vm'>
<name>r-93-VM</name>
<uuid>5269e919-564a-4986-92c1-07464e99e3ce</uuid>
<description>Debian GNU/Linux 7(64-bit)</description>
<clock offset='utc'>
</clock>
<features>
<pae/>
<apic/>
<acpi/>
</features>
<devices>
<emulator>/usr/bin/kvm-spice</emulator>
<interface type='bridge'>
<source bridge='brbond0-1208'/>
<mac address='02:00:6b:5b:00:03'/>
<model type='e1000'/>
<bandwidth>
<inbound average='25600' peak='25600'/>
<outbound average='25600' peak='25600'/>
</bandwidth>
</interface>
<interface type='bridge'>
<source bridge='cloud0'/>
<mac address='0e:00:a9:fe:01:68'/>
<model type='e1000'/>
</interface>
<interface type='bridge'>
<source bridge='cloudbr0'/>
<mac address='06:13:ca:00:00:36'/>
<model type='e1000'/>
<bandwidth>
<inbound average='25600' peak='25600'/>
<outbound average='25600' peak='25600'/>
</bandwidth>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<graphics type='vnc' autoport='yes' listen='172.16.16.30' passwd='2b74e551cba07566'/>
<disk  device='disk' type='file'>
<driver name='qemu' type='qcow2' cache='none' />
<source file='/mnt/d5174632-721e-39ed-b93b-462539f63c77/c1b45654-5e74-420e-bf91-5beb745546f8'/>
<target dev='hda' bus='ide'/>
</disk>
<disk  device='cdrom' type='file'>
<driver name='qemu' type='raw' cache='none' />
<source file='/usr/share/cloudstack-common/vms/systemvm.iso'/>
<target dev='hdc' bus='ide'/>
</disk>
<console type='pty'>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/r-93-VM.agent'/>
<target type='virtio' name='r-93-VM.vport'/>
<address type='virtio-serial'/>
</channel>
</devices>
<memory>262144</memory>
<devices>
<memballoon model='none'/>
</devices>
<vcpu>1</vcpu>
<os>
<type  arch='x86_64' machine='pc'>hvm</type>
<boot dev='cdrom'/>
<boot dev='hd'/>
</os>
<cputune>
<shares>500</shares>
</cputune>
<cpu></cpu><on_reboot>restart</on_reboot>
<on_poweroff>destroy</on_poweroff>
<on_crash>destroy</on_crash>
</domain>

Reply via email to