Merge ~paride/utah/+git/utah:server-vm-xml into utah:master
- Git
- lp:~paride/utah/+git/utah
- server-vm-xml
- Merge into master
Status: | Merged |
---|---|
Merged at revision: | 47f31216fd163027cb1d770475689410dc08b9df |
Proposed branch: | ~paride/utah/+git/utah:server-vm-xml |
Merge into: | utah:master |
Diff against target: |
526 lines (+275/-59) 9 files modified
conf/utah/default-vm.xml (+4/-4) conf/utah/server-vm-amd64-secureboot.xml (+61/-0) conf/utah/server-vm-amd64-uefi.xml (+60/-0) conf/utah/server-vm-amd64.xml (+58/-0) conf/utah/server-vm-arm64.xml (+53/-0) conf/utah/server-vm-ppc64el.xml (+5/-5) conf/utah/server-vm-s390x.xml (+1/-1) utah/provisioning/live_server.py (+21/-35) utah/provisioning/vm.py (+12/-14) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hudson-Doyle | Approve | ||
Review via email: mp+375441@code.launchpad.net |
Commit message
Introduce the server-vm-ARCH.xml libvirt template files
This change adds server-vm-ARCH.xml libvirt template files to be used
when testing server images. The server-
is also supported to test arch "variants", e.g. UEFI or Secure Boot on
amd64.
This change also switches the default VM arch from i686 to x86_64.
Description of the change
Paride Legovini (paride) wrote : | # |
Michael Hudson-Doyle (mwhudson) wrote : | # |
Seems ok to me. In some sense it would be nice to store a default vm definition and have some kind of way of applying a delta to convert it to the uefi/secure boot but well.
"one day"(tm) (but not until after 20.04 most likely) we'd like to install with uefi and boot for testing with bios and vice versa. Can you see a way towards doing that? (seems to conflict a bit with the general way utah operates to me)
Michael Hudson-Doyle (mwhudson) wrote : | # |
Actually in general we will want to support testing booting a degraded multipath or raid setup one day, which also falls in the general category of "different vm definition for testing vs installing". Something to think about (and in no way needing to block this branch!)
Paride Legovini (paride) wrote : | # |
Thanks for reviewing this one Michael. Well you said it: currently there is no easy way in utah to alter the test environment, utah hasn't been thought to do so. We're already deviating a bit from what I believe are its original design decision, moving from very generic libvirt XML files to arch-specific ones from which we inherit part of the machine configuration, without rewriting it. I see how testing different boot environments is important; we'll have to find a way.
Preview Diff
1 | diff --git a/conf/utah/default-vm.xml b/conf/utah/default-vm.xml |
2 | index df0ce52..aa9a860 100644 |
3 | --- a/conf/utah/default-vm.xml |
4 | +++ b/conf/utah/default-vm.xml |
5 | @@ -1,5 +1,5 @@ |
6 | <!-- |
7 | - Copyright (C) 2010-2012, Canonical Ltd (http://www.canonical.com/) |
8 | + Copyright (C) 2010-2019, Canonical Ltd (http://www.canonical.com/) |
9 | |
10 | This file is part of utah. |
11 | |
12 | @@ -17,14 +17,14 @@ |
13 | along with ubuntu-server-iso-testing. If not, see |
14 | <http://www.gnu.org/licenses/>. |
15 | --> |
16 | -<domain type='qemu'> |
17 | - <name>Utah Example</name> |
18 | +<domain type='kvm'> |
19 | + <name>Utah Template</name> |
20 | <uuid>00000000-0000-0000-0000-000000000000</uuid> |
21 | <memory>1048576</memory> |
22 | <currentMemory>1048576</currentMemory> |
23 | <vcpu>1</vcpu> |
24 | <os> |
25 | - <type arch='i686' machine='pc'>hvm</type> |
26 | + <type arch='x86_64' machine='pc'>hvm</type> |
27 | <boot dev='hd'/> |
28 | </os> |
29 | <features> |
30 | diff --git a/conf/utah/server-vm-amd64-secureboot.xml b/conf/utah/server-vm-amd64-secureboot.xml |
31 | new file mode 100644 |
32 | index 0000000..6c4a540 |
33 | --- /dev/null |
34 | +++ b/conf/utah/server-vm-amd64-secureboot.xml |
35 | @@ -0,0 +1,61 @@ |
36 | +<!-- |
37 | + Copyright (C) 2010-2019, Canonical Ltd (http://www.canonical.com/) |
38 | + |
39 | + This file is part of utah. |
40 | + |
41 | + utah is free software: you can redistribute it |
42 | + and/or modify it under the terms of the GNU General Public License |
43 | + as published by the Free Software Foundation, either version 3 of |
44 | + the License, or (at your option) any later version. |
45 | + |
46 | + utah is distributed in the hope that it will |
47 | + be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
48 | + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
49 | + GNU General Public License for more details. |
50 | + |
51 | + You should have received a copy of the GNU General Public License |
52 | + along with ubuntu-server-iso-testing. If not, see |
53 | + <http://www.gnu.org/licenses/>. |
54 | +--> |
55 | +<domain type='kvm'> |
56 | + <name>Utah Template</name> |
57 | + <uuid>00000000-0000-0000-0000-000000000000</uuid> |
58 | + <memory>1536000</memory> |
59 | + <currentMemory>1536000</currentMemory> |
60 | + <vcpu>1</vcpu> |
61 | + <os firmware='efi'> |
62 | + <type arch='x86_64' machine='q35'>hvm</type> |
63 | + <loader readonly='yes' type='pflash' secure="yes">/usr/share/OVMF/OVMF_CODE.fd</loader> |
64 | + <nvram template='/usr/share/OVMF/OVMF_VARS.fd'>/tmp/nvram.fd</nvram> |
65 | + <boot dev='hd'/> |
66 | + </os> |
67 | + <features> |
68 | + <acpi/> |
69 | + <apic/> |
70 | + <pae/> |
71 | + <smm state='on'/> |
72 | + </features> |
73 | + <clock offset='utc'/> |
74 | + <on_poweroff>destroy</on_poweroff> |
75 | + <on_reboot>restart</on_reboot> |
76 | + <on_crash>destroy</on_crash><!-- this could also be 'preserve' --> |
77 | + <devices> |
78 | + <disk type='file' device='cdrom'> |
79 | + <driver name='qemu' type='raw'/> |
80 | + <target dev='sdc' bus='sata'/> |
81 | + <readonly/> |
82 | + </disk> |
83 | + <interface type='bridge'> |
84 | + <mac address='52:54:00:3e:92:26'/> |
85 | + <source bridge='virbr0'/> |
86 | + <target dev='vnet1'/> |
87 | + <alias name='net0'/> |
88 | + <model type='virtio'/> |
89 | + </interface> |
90 | + <graphics type='vnc' autoport='yes'/> |
91 | + <video> |
92 | + <model type='qxl' vram='16384' heads='1'/> |
93 | + </video> |
94 | + </devices> |
95 | +</domain> |
96 | + |
97 | diff --git a/conf/utah/server-vm-amd64-uefi.xml b/conf/utah/server-vm-amd64-uefi.xml |
98 | new file mode 100644 |
99 | index 0000000..2596982 |
100 | --- /dev/null |
101 | +++ b/conf/utah/server-vm-amd64-uefi.xml |
102 | @@ -0,0 +1,60 @@ |
103 | +<!-- |
104 | + Copyright (C) 2010-2019, Canonical Ltd (http://www.canonical.com/) |
105 | + |
106 | + This file is part of utah. |
107 | + |
108 | + utah is free software: you can redistribute it |
109 | + and/or modify it under the terms of the GNU General Public License |
110 | + as published by the Free Software Foundation, either version 3 of |
111 | + the License, or (at your option) any later version. |
112 | + |
113 | + utah is distributed in the hope that it will |
114 | + be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
115 | + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
116 | + GNU General Public License for more details. |
117 | + |
118 | + You should have received a copy of the GNU General Public License |
119 | + along with ubuntu-server-iso-testing. If not, see |
120 | + <http://www.gnu.org/licenses/>. |
121 | +--> |
122 | +<domain type='kvm'> |
123 | + <name>Utah Template</name> |
124 | + <uuid>00000000-0000-0000-0000-000000000000</uuid> |
125 | + <memory>1536000</memory> |
126 | + <currentMemory>1536000</currentMemory> |
127 | + <vcpu>1</vcpu> |
128 | + <os firmware='efi'> |
129 | + <type arch='x86_64' machine='pc'>hvm</type> |
130 | + <loader readonly='yes' type='pflash' secure='no'>/usr/share/OVMF/OVMF_CODE.fd</loader> |
131 | + <nvram template='/usr/share/OVMF/OVMF_VARS.fd'>/tmp/nvram.fd</nvram> |
132 | + <boot dev='hd'/> |
133 | + </os> |
134 | + <features> |
135 | + <acpi/> |
136 | + <apic/> |
137 | + <pae/> |
138 | + </features> |
139 | + <clock offset='utc'/> |
140 | + <on_poweroff>destroy</on_poweroff> |
141 | + <on_reboot>restart</on_reboot> |
142 | + <on_crash>destroy</on_crash><!-- this could also be 'preserve' --> |
143 | + <devices> |
144 | + <disk type='file' device='cdrom'> |
145 | + <driver name='qemu' type='raw'/> |
146 | + <target dev='sdc' bus='sata'/> |
147 | + <readonly/> |
148 | + </disk> |
149 | + <interface type='bridge'> |
150 | + <mac address='52:54:00:3e:92:26'/> |
151 | + <source bridge='virbr0'/> |
152 | + <target dev='vnet1'/> |
153 | + <alias name='net0'/> |
154 | + <model type='virtio'/> |
155 | + </interface> |
156 | + <graphics type='vnc' autoport='yes'/> |
157 | + <video> |
158 | + <model type='qxl' vram='16384' heads='1'/> |
159 | + </video> |
160 | + </devices> |
161 | +</domain> |
162 | + |
163 | diff --git a/conf/utah/server-vm-amd64.xml b/conf/utah/server-vm-amd64.xml |
164 | new file mode 100644 |
165 | index 0000000..6e05524 |
166 | --- /dev/null |
167 | +++ b/conf/utah/server-vm-amd64.xml |
168 | @@ -0,0 +1,58 @@ |
169 | +<!-- |
170 | + Copyright (C) 2010-2019, Canonical Ltd (http://www.canonical.com/) |
171 | + |
172 | + This file is part of utah. |
173 | + |
174 | + utah is free software: you can redistribute it |
175 | + and/or modify it under the terms of the GNU General Public License |
176 | + as published by the Free Software Foundation, either version 3 of |
177 | + the License, or (at your option) any later version. |
178 | + |
179 | + utah is distributed in the hope that it will |
180 | + be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
181 | + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
182 | + GNU General Public License for more details. |
183 | + |
184 | + You should have received a copy of the GNU General Public License |
185 | + along with ubuntu-server-iso-testing. If not, see |
186 | + <http://www.gnu.org/licenses/>. |
187 | +--> |
188 | +<domain type='kvm'> |
189 | + <name>Utah Template</name> |
190 | + <uuid>00000000-0000-0000-0000-000000000000</uuid> |
191 | + <memory>1536000</memory> |
192 | + <currentMemory>1536000</currentMemory> |
193 | + <vcpu>1</vcpu> |
194 | + <os> |
195 | + <type arch='x86_64' machine='pc'>hvm</type> |
196 | + <boot dev='hd'/> |
197 | + </os> |
198 | + <features> |
199 | + <acpi/> |
200 | + <apic/> |
201 | + <pae/> |
202 | + </features> |
203 | + <clock offset='utc'/> |
204 | + <on_poweroff>destroy</on_poweroff> |
205 | + <on_reboot>restart</on_reboot> |
206 | + <on_crash>destroy</on_crash><!-- this could also be 'preserve' --> |
207 | + <devices> |
208 | + <disk type='file' device='cdrom'> |
209 | + <driver name='qemu' type='raw'/> |
210 | + <target dev='sdc' bus='sata'/> |
211 | + <readonly/> |
212 | + </disk> |
213 | + <interface type='bridge'> |
214 | + <mac address='52:54:00:3e:92:26'/> |
215 | + <source bridge='virbr0'/> |
216 | + <target dev='vnet1'/> |
217 | + <alias name='net0'/> |
218 | + <model type='virtio'/> |
219 | + </interface> |
220 | + <graphics type='vnc' autoport='yes'/> |
221 | + <video> |
222 | + <model type='qxl' vram='16384' heads='1'/> |
223 | + </video> |
224 | + </devices> |
225 | +</domain> |
226 | + |
227 | diff --git a/conf/utah/server-vm-arm64.xml b/conf/utah/server-vm-arm64.xml |
228 | new file mode 100644 |
229 | index 0000000..51e98c1 |
230 | --- /dev/null |
231 | +++ b/conf/utah/server-vm-arm64.xml |
232 | @@ -0,0 +1,53 @@ |
233 | +<!-- |
234 | + Copyright (C) 2010-2019, Canonical Ltd (http://www.canonical.com/) |
235 | + |
236 | + This file is part of utah. |
237 | + |
238 | + utah is free software: you can redistribute it |
239 | + and/or modify it under the terms of the GNU General Public License |
240 | + as published by the Free Software Foundation, either version 3 of |
241 | + the License, or (at your option) any later version. |
242 | + |
243 | + utah is distributed in the hope that it will |
244 | + be useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
245 | + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
246 | + GNU General Public License for more details. |
247 | + |
248 | + You should have received a copy of the GNU General Public License |
249 | + along with ubuntu-server-iso-testing. If not, see |
250 | + <http://www.gnu.org/licenses/>. |
251 | +--> |
252 | +<domain type='kvm'> |
253 | + <name>Utah Template</name> |
254 | + <uuid>00000000-0000-0000-0000-000000000000</uuid> |
255 | + <memory>1048576</memory> |
256 | + <currentMemory>1048576</currentMemory> |
257 | + <vcpu>1</vcpu> |
258 | + <cpu mode='host-passthrough' /> |
259 | + <os> |
260 | + <type arch='aarch64' machine='virt'>hvm</type> |
261 | + <loader readonly='yes' type='pflash'>/usr/share/AAVMF/AAVMF_CODE.fd</loader> |
262 | + <nvram template='/usr/share/AAVMF/AAVMF_VARS.fd'>/tmp/AAVMF_VARS.fd</nvram> |
263 | + <boot dev='hd'/> |
264 | + </os> |
265 | + <features> |
266 | + <acpi/> |
267 | + </features> |
268 | + <clock offset='utc'/> |
269 | + <on_poweroff>destroy</on_poweroff> |
270 | + <on_reboot>restart</on_reboot> |
271 | + <on_crash>destroy</on_crash><!-- this could also be 'preserve' --> |
272 | + <devices> |
273 | + <controller type='scsi' index='0' model='virtio-scsi'/> |
274 | + <disk type='file' device='cdrom'> |
275 | + <driver name='qemu' type='raw'/> |
276 | + <target dev='sdc' bus='scsi'/> |
277 | + <readonly/> |
278 | + </disk> |
279 | + <interface type='network'> |
280 | + <mac address='52:54:00:3e:92:26'/> |
281 | + <source network='default'/> |
282 | + <model type='virtio'/> |
283 | + </interface> |
284 | + </devices> |
285 | +</domain> |
286 | diff --git a/conf/utah/default-vm-ppc64.xml b/conf/utah/server-vm-ppc64el.xml |
287 | similarity index 90% |
288 | rename from conf/utah/default-vm-ppc64.xml |
289 | rename to conf/utah/server-vm-ppc64el.xml |
290 | index b0ea237..e510b4c 100644 |
291 | --- a/conf/utah/default-vm-ppc64.xml |
292 | +++ b/conf/utah/server-vm-ppc64el.xml |
293 | @@ -1,5 +1,5 @@ |
294 | <!-- |
295 | - Copyright (C) 2017, Canonical Ltd (http://www.canonical.com/) |
296 | + Copyright (C) 2017-2019, Canonical Ltd (http://www.canonical.com/) |
297 | |
298 | This file is part of utah. |
299 | |
300 | @@ -16,9 +16,9 @@ |
301 | You should have received a copy of the GNU General Public License |
302 | along with ubuntu-server-iso-testing. If not, see |
303 | <http://www.gnu.org/licenses/>. |
304 | ---> |
305 | -<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> |
306 | - <name>Utah Example</name> |
307 | +--> |
308 | +<domain type='kvm'> |
309 | + <name>Utah Template</name> |
310 | <uuid>00000000-0000-0000-0000-000000000000</uuid> |
311 | <memory>1048576</memory> |
312 | <currentMemory>1048576</currentMemory> |
313 | @@ -43,7 +43,7 @@ |
314 | <disk type='file' device='cdrom'> |
315 | <driver name='qemu' type='raw'/> |
316 | <backingStore/> |
317 | - <target dev='hdc' bus='sata'/> |
318 | + <target dev='sdc' bus='scsi'/> |
319 | <readonly/> |
320 | </disk> |
321 | <interface type='bridge'> |
322 | diff --git a/conf/utah/default-vm-s390x.xml b/conf/utah/server-vm-s390x.xml |
323 | similarity index 97% |
324 | rename from conf/utah/default-vm-s390x.xml |
325 | rename to conf/utah/server-vm-s390x.xml |
326 | index b41d965..22a9013 100644 |
327 | --- a/conf/utah/default-vm-s390x.xml |
328 | +++ b/conf/utah/server-vm-s390x.xml |
329 | @@ -18,7 +18,7 @@ |
330 | <http://www.gnu.org/licenses/>. |
331 | --> |
332 | <domain type='kvm'> |
333 | - <name>Utah Example</name> |
334 | + <name>Utah Template</name> |
335 | <uuid>00000000-0000-0000-0000-000000000000</uuid> |
336 | <memory>1048576</memory> |
337 | <currentMemory>1048576</currentMemory> |
338 | diff --git a/utah/provisioning/live_server.py b/utah/provisioning/live_server.py |
339 | index 550bbf1..6ea1deb 100644 |
340 | --- a/utah/provisioning/live_server.py |
341 | +++ b/utah/provisioning/live_server.py |
342 | @@ -189,31 +189,21 @@ class LiveServerVM(SSHMixin, LibvirtVM): |
343 | self.disks.append(disk) |
344 | self.logger.debug('Adding disk %s to list', disk) |
345 | |
346 | + def _installxml_rewrite_nvram(self, xmlt): |
347 | + ose = xmlt.find('os') |
348 | + nvram = ose.find('nvram') |
349 | + |
350 | + if nvram is None: |
351 | + # No nvram set (legacy, non-uefi boot) |
352 | + return |
353 | + |
354 | + ose.find('nvram').text = self.directory + '/nvram.fd' |
355 | + |
356 | def _installxml_rewrite_boot(self, xmlt): |
357 | # Set the arch appropriately, remove any configuration of |
358 | # kernel/initrd/commandline and configure the VM to boot from |
359 | # CD. |
360 | - xmlt.getroot().set('type', 'kvm') |
361 | ose = xmlt.find('os') |
362 | - if self.image.arch == 'i386': |
363 | - ose.find('type').set('arch', 'i686') |
364 | - elif self.image.arch == 'amd64': |
365 | - ose.find('type').set('arch', 'x86_64') |
366 | - elif self.image.arch == 'ppc64el': |
367 | - ose.find('type').set('arch', 'ppc64le') |
368 | - ose.find('type').set('machine', 'pseries') |
369 | - elif self.image.arch == 's390x': |
370 | - ose.find('type').set('arch', 's390x') |
371 | - ose.find('type').set('machine', 's390-ccw-virtio') |
372 | - else: |
373 | - ose.find('type').set('arch', self.image.arch) |
374 | - self.logger.debug('Setting up boot info') |
375 | - for kernele in list(ose.iterfind('kernel')): |
376 | - ose.remove(kernele) |
377 | - for initrde in list(ose.iterfind('initrd')): |
378 | - ose.remove(initrde) |
379 | - for cmdlinee in list(ose.iterfind('cmdline')): |
380 | - ose.remove(cmdlinee) |
381 | ose.find('boot').set('dev', 'cdrom') |
382 | |
383 | def _installxml_rewrite_disks(self, devices, image): |
384 | @@ -227,14 +217,6 @@ class LiveServerVM(SSHMixin, LibvirtVM): |
385 | self.logger.debug('Removed existing disk') |
386 | # TODO: Add a cdrom if none exists |
387 | if disk.get('device') == 'cdrom': |
388 | - if self.image.arch == 'ppc64el': |
389 | - disk.find('target').set('bus', 'virtio') |
390 | - elif self.image.arch == 's390x': |
391 | - disk.find('target').set('bus', 'virtio') |
392 | - else: |
393 | - disk.find('target').set('bus', 'ide') |
394 | - for address in list(disk.iterfind('address')): |
395 | - disk.remove(address) |
396 | if disk.find('source') is not None: |
397 | disk.find('source').set('file', image) |
398 | self.logger.debug('Rewrote existing CD-ROM') |
399 | @@ -252,6 +234,7 @@ class LiveServerVM(SSHMixin, LibvirtVM): |
400 | driver = ElementTree.Element('driver') |
401 | driver.set('name', 'qemu') |
402 | driver.set('type', disk['type']) |
403 | + driver.set('cache', 'unsafe') |
404 | diske.append(driver) |
405 | if 'mpath' in disk and disk['mpath']: |
406 | diske.append(ElementTree.Element('shareable')) |
407 | @@ -336,6 +319,7 @@ class LiveServerVM(SSHMixin, LibvirtVM): |
408 | self._installxml_rewrite_disks(devices, image) |
409 | self._installxml_rewrite_nics(devices) |
410 | self._installxml_add_serial(devices) |
411 | + self._installxml_rewrite_nvram(xmlt) |
412 | xmlt.write(os.path.join(tmpdir, 'install.xml')) |
413 | self.logger.info('Installation XML ready') |
414 | return xmlt |
415 | @@ -363,22 +347,23 @@ class LiveServerVM(SSHMixin, LibvirtVM): |
416 | self.logger.info('Logs will be written to %s', log_filename) |
417 | |
418 | before = time.time() |
419 | + |
420 | + vm = lv.defineXML(ElementTree.tostring(xml.getroot())) |
421 | + |
422 | try: |
423 | vm = lv.defineXML(ElementTree.tostring(xml.getroot())) |
424 | vm.create() |
425 | while vm.isActive() is not 0: |
426 | time.sleep(1) |
427 | + time.sleep(5) |
428 | finally: # This stops us from leaking VMs on exceptions |
429 | try: |
430 | + vm.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM) |
431 | vm.destroy() |
432 | - except libvirt.libvirtError: |
433 | - pass |
434 | - finally: |
435 | - # Workaround for LP: #1822096 |
436 | - # To be removed once fixed in libvirtd. |
437 | - time.sleep(5) |
438 | - |
439 | + time.sleep(5) # Workaround for LP: #1822096 |
440 | vm.undefine() |
441 | + except (libvirt.libvirtError, UnboundLocalError): |
442 | + pass |
443 | |
444 | after = time.time() |
445 | self.logger.info('Installation complete in %s seconds' % |
446 | @@ -438,6 +423,7 @@ class LiveServerVM(SSHMixin, LibvirtVM): |
447 | self.logger.info('Setting up final VM') |
448 | self.logger.info(ElementTree.tostring(xml.getroot())) |
449 | self.vm = self.lv.defineXML(ElementTree.tostring(xml.getroot())) |
450 | + self.cleanfunction(self.vm.undefineFlags, False, libvirt.VIR_DOMAIN_UNDEFINE_NVRAM) |
451 | self.cleanfunction(self.vm.destroy) |
452 | self.cleanfunction(self.vm.undefine) |
453 | if self.poweroff: |
454 | diff --git a/utah/provisioning/vm.py b/utah/provisioning/vm.py |
455 | index 21ed2be..755c95f 100644 |
456 | --- a/utah/provisioning/vm.py |
457 | +++ b/utah/provisioning/vm.py |
458 | @@ -331,12 +331,6 @@ class CustomVM(CustomInstallMixin, SSHMixin, LibvirtVM): |
459 | ose = xmlt.find('os') |
460 | if self.image.arch == ('i386'): |
461 | ose.find('type').set('arch', 'i686') |
462 | - elif self.image.arch == ('amd64'): |
463 | - ose.find('type').set('arch', 'x86_64') |
464 | - elif self.image.arch == ('ppc64el'): |
465 | - ose.find('type').set('arch', 'ppc64le') |
466 | - else: |
467 | - ose.find('type').set('arch', self.image.arch) |
468 | self.logger.debug('Setting up boot info') |
469 | for kernele in list(ose.iterfind('kernel')): |
470 | ose.remove(kernele) |
471 | @@ -379,6 +373,7 @@ class CustomVM(CustomInstallMixin, SSHMixin, LibvirtVM): |
472 | driver = ElementTree.Element('driver') |
473 | driver.set('name', 'qemu') |
474 | driver.set('type', disk['type']) |
475 | + driver.set('cache', 'unsafe') |
476 | diske.append(driver) |
477 | source = ElementTree.Element('source') |
478 | source.set('file', disk['file']) |
479 | @@ -451,6 +446,10 @@ class CustomVM(CustomInstallMixin, SSHMixin, LibvirtVM): |
480 | serial.append(target) |
481 | devices.append(serial) |
482 | |
483 | + nvram = ose.find('nvram') |
484 | + if nvram is not None: |
485 | + ose.find('nvram').text = self.directory + '/nvram.fd' |
486 | + |
487 | def _installvm(self, lv=None, tmpdir=None, xml=None): |
488 | """Install a VM, then undefine it in libvirt. |
489 | |
490 | @@ -473,22 +472,20 @@ class CustomVM(CustomInstallMixin, SSHMixin, LibvirtVM): |
491 | self.logger.info('Logs will be written to %s', log_filename) |
492 | |
493 | before = time.time() |
494 | + vm = lv.defineXML(ElementTree.tostring(xml.getroot())) |
495 | try: |
496 | - vm = lv.defineXML(ElementTree.tostring(xml.getroot())) |
497 | vm.create() |
498 | while vm.isActive() is not 0: |
499 | time.sleep(1) |
500 | + time.sleep(5) |
501 | finally: # This stops us from leaking VMs on exceptions |
502 | try: |
503 | + vm.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM) |
504 | vm.destroy() |
505 | - except libvirt.libvirtError: |
506 | - pass |
507 | - finally: |
508 | - # Workaround for LP: #1822096 |
509 | - # To be removed once fixed in libvirtd. |
510 | - time.sleep(5) |
511 | - |
512 | + time.sleep(5) # Workaround for LP: #1822096 |
513 | vm.undefine() |
514 | + except (libvirt.libvirtError, UnboundLocalError): |
515 | + pass |
516 | |
517 | after = time.time() |
518 | self.logger.info('Installation complete in %s seconds' % |
519 | @@ -606,6 +603,7 @@ class CustomVM(CustomInstallMixin, SSHMixin, LibvirtVM): |
520 | |
521 | self.logger.info('Setting up final VM') |
522 | self.vm = self.lv.defineXML(ElementTree.tostring(xml.getroot())) |
523 | + self.cleanfunction(self.vm.undefineFlags, False, libvirt.VIR_DOMAIN_UNDEFINE_NVRAM) |
524 | self.cleanfunction(self.vm.destroy) |
525 | self.cleanfunction(self.vm.undefine) |
526 | if self.poweroff: |
This branch is the one currently running on venonat.