Skip to content

Commit 4404195

Browse files
committed
Add QEMu as a target Hypervisor. It acts exactly the same as KVM, but
the libvirt plugin makes sure it runs through qemu rather than kvm. This is useful for non-VT-capable hosts.
1 parent 3e8eb89 commit 4404195

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

VMBuilder/plugins/kvm/vm.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
#
1919
from VMBuilder import register_hypervisor, Hypervisor
2020
import VMBuilder
21-
import VMBuilder.hypervisor
2221
import os
23-
import os.path
2422
import stat
2523

2624
class KVM(Hypervisor):
@@ -55,4 +53,15 @@ def deploy(self, destdir):
5553
os.chmod(script, stat.S_IRWXU | stat.S_IRWXU | stat.S_IROTH | stat.S_IXOTH)
5654
self.call_hooks('fix_ownership', script)
5755

56+
def libvirt_domain_type_name(self):
57+
return 'kvm'
58+
59+
class QEMu(KVM):
60+
name = 'QEMu'
61+
arg = 'qemu'
62+
63+
def libvirt_domain_type_name(self):
64+
return 'qemu'
65+
5866
register_hypervisor(KVM)
67+
register_hypervisor(QEMu)

VMBuilder/plugins/libvirt/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def preflight_check(self):
3737
if not libvirt_uri:
3838
return True
3939

40-
if not self.context.name == 'KVM':
41-
raise VMBuilderUserError('The libvirt plugin is only equiped to work with KVM at the moment.')
40+
if not self.context.name == 'KVM' and not self.context.name == 'QEMu':
41+
raise VMBuilderUserError('The libvirt plugin is only equiped to work with KVM and QEMu at the moment.')
4242

4343
import libvirt
4444
import xml.etree.ElementTree
@@ -70,7 +70,8 @@ def deploy(self, destdir):
7070
'virtio_net' : self.context.distro.use_virtio_net(),
7171
'disks' : self.context.disks,
7272
'filesystems' : self.context.filesystems,
73-
'hostname' : hostname }
73+
'hostname' : hostname,
74+
'domain_type' : self.context.libvirt_domain_type_name() }
7475
if self.context.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
7576
vmxml = VMBuilder.util.render_template('libvirt', self.context, 'libvirtxml_fsimage', tmpl_ctxt)
7677
else:

VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<domain type='kvm'>
1+
<domain type='$domain_type'>
22
<name>$hostname</name>
33
<memory>#echo int($mem) * 1024 #</memory>
44
<vcpu>$cpus</vcpu>

0 commit comments

Comments
 (0)