52
52
def parseXML(self, node):
54
for n in node.xpathEval("*"):
56
if node.name == "features":
57
node_list = node.xpathEval("*")
59
feature_list.append(n.name)
62
node_list = node.xpathEval("feature/@name")
64
feature_list.append(n.content)
66
for feature in feature_list:
56
67
if not d.has_key(feature):
81
93
if toggle == "yes":
82
94
d[feature] |= d[feature] ^ (FEATURE_ON|FEATURE_OFF)
96
# Format for old HOST features, on OLD old guest features
97
# back compat is just <$featurename>, like <svm/>
84
98
if feature == "nonpae":
85
99
d["pae"] |= FEATURE_OFF
87
101
d[feature] |= FEATURE_ON
104
def __init__(self, node=None):
105
# e.g. "i686" or "x86_64"
111
self.features = CapabilityFeatures()
116
def parseXML(self, node):
117
newstyle_features = False
119
child = node.children
121
# Do a first pass to try and detect new style features
122
if child.name == "feature":
123
newstyle_features = True
127
if newstyle_features:
128
self.features = CapabilityFeatures(node)
130
child = node.children
132
if child.name == "arch":
133
self.arch = child.content
134
elif child.name == "model":
135
self.model = child.content
136
elif child.name == "topology":
137
self.sockets = xpathString(child, "@sockets") or 1
138
self.cores = xpathString(child, "@cores") or 1
139
self.threads = xpathString(child, "@threads") or 1
141
elif child.name == "features" and not newstyle_features:
142
self.features = CapabilityFeatures(child)
89
146
class Host(object):
90
147
def __init__(self, node = None):
91
# e.g. "i686" or "x86_64"
94
self.features = CapabilityFeatures()
95
149
self.topology = None
96
150
self.secmodel = None
98
152
if not node is None:
99
153
self.parseXML(node)
155
# Back compat for CPU class
158
def set_arch(self, val):
160
arch = property(get_arch, set_arch)
162
def get_features(self):
163
return self.cpu.features
164
def set_features(self, val):
165
self.cpu.features = val
166
features = property(get_features, set_features)
101
168
def parseXML(self, node):
102
169
child = node.children
284
342
self._fixBrokenEmulator()
345
for g in self.guests:
346
if g.os_type != "xen":
350
if d.hypervisor_type == "xen":
355
def no_install_options(self):
357
Return True if there are no install options available
359
for g in self.guests:
360
if len(g.domains) > 0:
365
def hw_virt_supported(self):
367
Return True if the machine supports hardware virtualization.
369
For some cases (like qemu caps pre libvirt 0.7.4) this info isn't
370
sufficiently provided, so we will return True in cases that we
373
# Obvious case of feature being specified
374
if (self.host.features["vmx"] == FEATURE_ON or
375
self.host.features["svm"] == FEATURE_ON):
378
# If there is other features, but no virt bit, then HW virt
380
if len(self.host.features.names()):
383
# Xen caps have always shown this info, so if we didn't find any
384
# features, the host really doesn't have the necc support
388
# Otherwise, we can't be sure, because there was a period for along
389
# time that qemu caps gave no indication one way or the other.
392
def is_kvm_available(self):
394
Return True if kvm guests can be installed
396
for g in self.guests:
397
if g.os_type != "hvm":
401
if d.hypervisor_type == "kvm":
406
def is_xenner_available(self):
408
Return True if xenner install option is available
410
for g in self.guests:
411
if g.os_type != "xen":
415
if d.hypervisor_type == "kvm":
420
def is_bios_virt_disabled(self):
422
Try to determine if fullvirt may be disabled in the bios.
426
- We appear to be xen
427
- There are no HVM install options
429
We don't do this check for KVM, since no KVM options may mean
430
KVM isn't installed or the module isn't loaded (and loading the
431
module will give an appropriate error
433
if not self.hw_virt_supported():
436
if not self._is_xen():
439
for g in self.guests:
440
if g.os_type == "hvm":
286
445
def guestForOSType(self, type = None, arch = None):
287
446
if self.host is None: