[libvirt] how to use libvirt hook scripts to modify domain xml while its start
cokabug
cokabug at gmail.com
Wed Apr 16 07:20:44 UTC 2014
here is the format scripts:
http://paste.openstack.org/show/75876/
On Wed, Apr 16, 2014 at 3:17 PM, cokabug <cokabug at gmail.com> wrote:
> i want add sound card to domain xml when guest start,after google,i found
> libvirt provide hook function.
> i follow the instruction to make a python,and boot a guest,but after use
> "virsh edit" its still dont have sound card config
>
>
> /etc/libvirt/hooks/qemu:
> #!/usr/bin/python
>
> import sys
> import re
> import os
>
> hooklog = '/tmp/hook.log'
> log = open(hooklog, 'w')
> stdinxml = sys.stdin.readlines()
>
> if sys.argv[2] == 'start':
> log.write("hook start,domain name: %s \n" % sys.argv[1])
> maxslot=-1
>
> for line in stdinxml:
> slotm = re.search("slot='(?P<slotnum>0x[0-9a-fA-F]{2})'", line)
> if slotm:
> slotnum = int(slotm.group('slotnum'),0)
> if slotnum > maxslot:
> maxslot = slotnum
> if '</devices>' in line:
> log.write("insert sound card config \n")
> slotnum = maxslot + 1
> line = " <sound model='ich6'>\n"
> line = line + " <address type='pci' domain='0x0000' bus='0x00'
> slot='0x%0.2X' function='0x0'/>\n" % slotnum
> line = line + " </sound>\n"
> line = line + " </devices>\n"
> stdoutxml = ''.join(line)
> sys.stdout.write(stdoutxml)
>
> tail -f /tmp/hook.log:
> hook start,domain name: instance-00000222
> insert sound card config
>
> tail /var/log/libvirt/libvirtd.log:
> 2014-04-16 07:13:39.159+0000: 52199: warning : qemuDomainObjTaint:1377 :
> Domain id=81 name='instance-00000222'
> uuid=974d62b7-f316-4f20-a91c-d11cb85980fe is tainted: high-privileges
>
>
> in these log,hook script seems to executed,but not effective.
>
> can anyone tell me where is wrong?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140416/9ce58ea8/attachment-0001.htm>
More information about the libvir-list
mailing list