Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions kvirt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ def _parse_vms_list(_list, overrides={}):
name = vm.get('name')
status = vm.get('status')
ip = vm.get('ip', '')
userport = vm.get('userport')
if not ip and userport is not None:
ip = f'127.0.0.1:{userport}'
source = vm.get('image', '')
plan = vm.get('plan', '')
profile = vm.get('profile', '')
Expand Down Expand Up @@ -813,6 +816,9 @@ def list_vms(args):
name = vm.get('name')
status = vm.get('status')
ip = vm.get('ip', '')
userport = vm.get('userport')
if not ip and userport is not None:
ip = f'127.0.0.1:{userport}'
source = vm.get('image', '')
plan = vm.get('plan', '')
profile = vm.get('profile', '')
Expand All @@ -833,6 +839,9 @@ def list_vms(args):
name = vm.get('name')
status = vm.get('status')
ip = vm.get('ip', '')
userport = vm.get('userport')
if not ip and userport is not None:
ip = f'127.0.0.1:{userport}'
source = vm.get('image', '')
plan = vm.get('plan', '')
profile = vm.get('profile', '')
Expand Down
3 changes: 3 additions & 0 deletions kvirt/kmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def _parse_vms_list(_list, overrides={}):
name = vm.get('name')
status = vm.get('status')
ip = vm.get('ip', '')
userport = vm.get('userport')
if not ip and userport is not None:
ip = f'127.0.0.1:{userport}'
source = vm.get('image', '')
plan = vm.get('plan', '')
profile = vm.get('profile', '')
Expand Down
17 changes: 10 additions & 7 deletions kvirt/providers/kvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def disk_exists(self, pool, name):
return False

def get_capabilities(self, arch=None):
results = {'kvm': False, 'nestedfeature': None, 'machines': [], 'arch': arch}
results = {'kvm': False, 'hvf': False, 'nestedfeature': None, 'machines': [], 'arch': arch}
capabilitiesxml = self.conn.getCapabilities()
root = ET.fromstring(capabilitiesxml)
cpuxml = ''
Expand All @@ -200,7 +200,8 @@ def get_capabilities(self, arch=None):
for domain in list(guest.iter('domain')):
if domain.get('type') == 'kvm':
results['kvm'] = True
break
elif domain.get('type') == 'hvf':
results['hvf'] = True
for machine in list(guest.iter('machine')):
results['machines'].append(machine.text)
if 'vmx' in cpuxml:
Expand Down Expand Up @@ -270,7 +271,7 @@ def create(self, name, virttype=None, profile='kvirt', flavor=None, plan='kvirt'
uefi_legacy = overrides.get('uefi_legacy', False) or (uefi and self._rhel_legacy(capabilities['machines']))
iommu_model = 'smmuv3' if arch == 'aarch64' else 'intel'
aarch64 = arch == 'aarch64'
aarch64_full = aarch64 and capabilities['kvm']
aarch64_full = aarch64 and (capabilities['kvm'] or capabilities['hvf'])
as390x = arch == 's390x'
if aarch64:
if custom_emulator is not None:
Expand Down Expand Up @@ -946,13 +947,15 @@ def create(self, name, virttype=None, profile='kvirt', flavor=None, plan='kvirt'
else:
cpuxml = f"<cpu mode='custom' match='exact'><model fallback='allow'>{cpumodel}</model>"
if virttype is None:
if not capabilities['kvm']:
if capabilities['kvm']:
virttype = 'kvm'
elif capabilities['hvf']:
virttype = 'hvf'
else:
warning("No acceleration available with this hypervisor")
virttype = 'qemu'
nested = False
else:
virttype = 'kvm'
elif virttype not in ['qemu', 'kvm', 'xen', 'lxc']:
elif virttype not in ['qemu', 'kvm', 'hvf', 'xen', 'lxc']:
msg = f"Incorrect virttype {virttype}"
return {'result': 'failure', 'reason': msg}
nestedfeature = capabilities['nestedfeature']
Expand Down