3 # Copyright (C) 2014 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 # Generate libvirt XML. Would be nice to use virt-install here, but
23 # it doesn't work: RHBZ#1095789
24 def generate_libvirt_xml (vm_name, memory, vcpus, virtio, output):
25 network_model = "virtio"
27 network_model = "e1000"
29 # XXX Quoting, and we should use a real XML generator.
33 <memory unit='MiB'>%d</memory>
34 <currentMemory unit='MiB'>%d</currentMemory>
45 <cpu mode='host-model' fallback='allow' />
47 <timer name='rtc' tickpolicy='catchup'/>
48 <timer name='pit' tickpolicy='delay'/>
49 <timer name='hpet' present='no'/>
51 <on_poweroff>destroy</on_poweroff>
52 <on_reboot>restart</on_reboot>
53 <on_crash>restart</on_crash>
55 <interface type='bridge'>
56 <source bridge='br0'/>
60 <target type='virtio' port='0'/>
62 <input type='tablet' bus='usb'/>
63 <input type='mouse' bus='ps2'/>
64 <!-- <input type='keyboard' bus='ps2'/> -->
65 <graphics type='vnc' autoport='yes'/>
67 <model type='cirrus' vram='9216' heads='1'/>
69 """ % (vm_name, memory, memory, vcpus, network_model)
71 # virtio-scsi or IDE disk:
74 <controller type="scsi" index="0" model="virtio-scsi"/>
75 <disk type='file' device='disk'>
76 <driver name='qemu' type='qcow2' cache='none' io='native'/>
78 <target dev='sda' bus='scsi'/>
83 <disk type='file' device='disk'>
84 <driver name='qemu' type='qcow2' cache='none' io='native'/>
86 <target dev='sda' bus='ide'/>