Change in vdsm[master]: [WIP]vdsm: add support for S3/S4 suspend calls
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: [WIP]vdsm: add support for S3/S4 suspend calls
......................................................................
[WIP]vdsm: add support for S3/S4 suspend calls
Change-Id: Ic30016c5cd555f5771dde8db3f1340e1c11b3da7
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/guestIF.py
M vdsm_api/vdsmapi-schema.json
4 files changed, 58 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/19389/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 37bb908..96119ed 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -296,6 +296,20 @@
else:
return errCode['nonresp']
+ def desktopSuspend(self, mode):
+ """
+ Sleep the guest operating system
+ """
+ try:
+ v = self._cif.vmContainer[self._UUID]
+ except KeyError:
+ return errCode['noVM']
+ v.guestAgent.desktopSuspend(mode)
+ if v.guestAgent.isResponsive():
+ return {'status': doneCode}
+ else:
+ return errCode['nonresp']
+
def desktopSendHcCommand(self, message):
"""
Send a command to the guest agent (depricated).
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index fb65ad4..046bb0c 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -352,6 +352,10 @@
vm = API.VM(vmId)
return vm.desktopLogoff(force)
+ def vmDesktopSuspend(self, vmId, mode):
+ vm = API.VM(vmId)
+ return vm.desktopSuspend(mode)
+
def vmDesktopLock(self, vmId):
vm = API.VM(vmId)
return vm.desktopLock()
@@ -836,6 +840,7 @@
(self.vmMigrationCreate, 'migrationCreate'),
(self.vmDesktopLogin, 'desktopLogin'),
(self.vmDesktopLogoff, 'desktopLogoff'),
+ (self.vmDesktopSuspend, 'desktopSuspend'),
(self.vmDesktopLock, 'desktopLock'),
(self.vmDesktopSendHcCommand, 'sendHcCmdToDesktop'),
(self.vmHibernate, 'hibernate'),
diff --git a/vdsm/guestIF.py b/vdsm/guestIF.py
index 6f09ef1..2bb654b 100644
--- a/vdsm/guestIF.py
+++ b/vdsm/guestIF.py
@@ -299,6 +299,15 @@
except:
self.log.error("desktopLogoff failed", exc_info=True)
+ def desktopSuspend(self, mode):
+ try:
+ self.log.debug('desktopSleep called')
+ cmds = ('guest-suspend-ram', 'guest-suspend-hybrid',
+ 'guest-suspend-disk')
+ self._forward(cmds['mode'], {'success_response': 'yes'})
+ except:
+ self.log.debug('desktopSleep failed', exc_info=True)
+
def desktopShutdown(self, timeout, msg):
try:
self.log.debug("desktopShutdown called")
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 27c12c1..bc54041 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5079,6 +5079,36 @@
'data': {'vmID': 'UUID', 'force': 'bool'}}
##
+# @guestSuspendMode
+#
+# Enumeration of supported suspend modes
+#
+# @ram: S3 sleep
+#
+# @disk: S4 sleep
+#
+# @hybrid: Combination of @ram and @disk
+#
+# Since: 4.12.0
+##
+{'enum': 'guestSuspendMode', 'data': ['ram', 'disk', 'hybrid']}
+
+
+##
+# @VM.desktopSuspend:
+#
+# Suspend the guest operating system
+#
+# @vmID: The UUID of the VM
+#
+# @mode: Type of suspension
+#
+# Since: 4.12.0
+##
+{'command': {'class': 'VM', 'name': 'desktopSuspend'},
+ 'data': {'vmID': 'UUID', 'mode': 'guestSuspendMode'}}
+
+##
# @VM.desktopSendHcCommand:
#
# Send an arbitrary command to the guest agent.
--
To view, visit http://gerrit.ovirt.org/19389
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic30016c5cd555f5771dde8db3f1340e1c11b3da7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: vdsm: add support for hot(un)plug of pci-passthrough devices
by mpoledni@redhat.com
Martin Polednik has uploaded a new change for review.
Change subject: vdsm: add support for hot(un)plug of pci-passthrough devices
......................................................................
vdsm: add support for hot(un)plug of pci-passthrough devices
Hot(un)plug ability for pci-passthrough devices is extremely important
in order to allow for hotunplugging/migrating/hotplugging workflow as VM
cannot be migrated with pci device attached.
This patch implements the ability adding new API verbs: hotplugHostdev
and hotunplugHostdev, which attempts to append/remove the device from
domain XML and reports back the state.
Change-Id: I8fbf4a1d62789d9404e5977eb7eb01b17a1a43fb
Signed-off-by: Martin Polednik <mpoledni(a)redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/vm.py
M vdsm_api/vdsmapi-schema.json
5 files changed, 166 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/22523/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index d549500..f00180e 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -245,6 +245,14 @@
params = {'vmId': args[0], 'drive': drive}
return self.ExecAndExit(self.s.hotunplugDisk(params))
+ def hotplugHostdev(self, args):
+ params = {'vmId': args[0], 'hostdevName': args[1]}
+ return self.ExecAndExit(self.s.hotplugNic(params))
+
+ def hotunplugHostdev(self, args):
+ params = {'vmId': args[0], 'hostdevName': args[2]}
+ return self.ExecAndExit(self.s.hotunplugNic(params))
+
def do_changeCD(self, args):
vmId = args[0]
file = self._parseDriveSpec(args[1])
diff --git a/vdsm/API.py b/vdsm/API.py
index 44d5817..51eb506 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -456,6 +456,40 @@
return curVm.hotunplugDisk(params)
+ def hotplugHostdev(self, params):
+ try:
+ utils.validateMinimalKeySet(params, ('vmId', 'hostdevName'))
+ except ValueError:
+ self.log.error('Missing one of required parameters: vmId, '
+ 'hostdevName')
+ return {'status': {'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing one of required '
+ 'parameters: vmId, hostdevName'}}
+ try:
+ curVm = self._cif.vmContainer[self._UUID]
+ except KeyError:
+ self.log.warning("vm %s doesn't exist", self._UUID)
+ return errCode['noVM']
+
+ return curVm.hotplugHostdev(params)
+
+ def hotunplugHostdev(self, params):
+ try:
+ utils.validateMinimalKeySet(params, ('vmId', 'hostdevName'))
+ except ValueError:
+ self.log.error('Missing one of required parameters: vmId, '
+ 'hostdevName')
+ return {'status': {'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing one of required '
+ 'parameters: vmId, hostdevName'}}
+ try:
+ curVm = self._cif.vmContainer[self._UUID]
+ except KeyError:
+ self.log.warning("vm %s doesn't exist", self._UUID)
+ return errCode['noVM']
+
+ return curVm.hotunplugHostdev(params)
+
def migrate(self, params):
"""
Migrate a VM to a remote host.
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 5bcd84c..847ceaf 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -279,6 +279,14 @@
vm = API.VM(params['vmId'])
return vm.hotunplugNic(params)
+ def vmHotplugHostdev(self, params):
+ vm = API.VM(params['vmId'])
+ return vm.hotplugHostdev(params)
+
+ def vmHotunplugHostdev(self, params):
+ vm = API.VM(params['vmId'])
+ return vm.hotunplugHostdev(params)
+
def vmUpdateDevice(self, vmId, params):
vm = API.VM(vmId)
return vm.vmUpdateDevice(params)
@@ -861,6 +869,8 @@
(self.vmHotunplugDisk, 'hotunplugDisk'),
(self.vmHotplugNic, 'hotplugNic'),
(self.vmHotunplugNic, 'hotunplugNic'),
+ (self.vmHotplugHostdev, 'hotplugHostdev'),
+ (self.vmHotunplugHostdev, 'hotunplugHostdev'),
(self.vmUpdateDevice, 'vmUpdateDevice'))
def getIrsMethods(self):
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 90a6c0d..224bf7b 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -3183,6 +3183,84 @@
return {'status': doneCode, 'vmList': self.status()}
+ def hotplugHostdev(self, params):
+ hostdevName = params['hostdevName']
+ hostdev = HostDevice(self.conf, self.log, **hostdevName)
+ hostdevXML = hostdev.getXML().toprettyxml(encoding='utf-8')
+ hostdev._deviceXML = hostdevXML
+ self.log.debug("Hotplug hostdev xml: %s", hostdevXML)
+
+ try:
+ self._dom.attachDevice(hostdevXML)
+ except libvirt.libvirtError as e:
+ self.log.error("Hotplug failed", exc_info=True)
+ if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
+ return errCode['noVM']
+ return {'status': {'code': errCode['hotplugNic']['status']['code'],
+ 'message': e.message}}
+ else:
+ # FIXME! We may have a problem here if vdsm dies right after
+ # we sent command to libvirt and before save conf. In this case
+ # we will gather almost all needed info about this NIC from
+ # the libvirt during recovery process.
+ self._devices[HOSTDEV_DEVICES].append(hostdev)
+ with self._confLock:
+ self.conf['devices'].append(hostdev)
+ self.saveState()
+
+ return {'status': doneCode, 'vmList': self.status()}
+
+ def hotunplugHostdev(self, params):
+ hostdevName = params['hostdevName']
+
+ # Find hostdev object in vm's hostdev list
+ hostdev = None
+ for dev in self._devices[HOSTDEV_DEVICES][:]:
+ if dev.name == hostdevName:
+ hostdev = dev
+ break
+
+ if hostdev:
+ hostdevXML = hostdev.getXML().toprettyxml(encoding='utf-8')
+ self.log.debug("Hotunplug hostdev xml: %s", hostdevXML)
+ self._devices[HOSTDEV_DEVICES].remove(hostdev)
+ else:
+ self.log.error("Hotunplug hostdev failed - hostdev not found: %s",
+ hostdevName)
+ return {'status': {'code': errCode['hotunplugNic']
+ ['status']['code'],
+ 'message': "NIC not found"}}
+
+ hostdevDev = None
+ for dev in self.conf['devices'][:]:
+ if (dev['type'] == HOSTDEV_DEVICES and
+ dev['name'] == hostdevName):
+ hostdevDev = dev
+ with self._confLock:
+ self.conf['devices'].remove(dev)
+ break
+
+ self.saveState()
+
+ try:
+ self._dom.detachDevice(hostdevXML)
+ except libvirt.libvirtError as e:
+ self.log.error("Hotunplug failed", exc_info=True)
+ if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
+ return errCode['noVM']
+ # Restore hostdev device in vm's conf and _devices
+ if hostdevDev:
+ with self._confLock:
+ self.conf['devices'].append(hostdevDev)
+ if hostdev:
+ self._devices[HOSTDEV_DEVICES].append(hostdev)
+ self.saveState()
+ return {
+ 'status': {'code': errCode['hotunplugNic']['status']['code'],
+ 'message': e.message}}
+
+ return {'status': doneCode, 'vmList': self.status()}
+
def _lookupDeviceByAlias(self, devType, alias):
for dev in self._devices[devType][:]:
if dev.alias == alias:
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 1d4e499..85f2b28 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5793,6 +5793,42 @@
'returns': 'VmDefinition'}
##
+# @VM.hotplugHostdev:
+#
+# Add a new host device to a running VM.
+#
+# @vmID: The UUID of the VM
+#
+# @hostdevName: The name of host's device
+#
+# Returns:
+# The VM definition, as updated
+#
+# Since: 4.14.0
+##
+{'command': {'class': 'VM', 'name': 'hotplugHostdev'},
+ 'data': {'vmID': 'UUID', 'hostdevName': 'str'},
+ 'returns': 'VmDefinition'}
+
+##
+# @VM.hotunplugHostdev:
+#
+# Remove a host device from a running VM.
+#
+# @vmID: The UUID of the VM
+#
+# @hostdevName: The name of host's device
+#
+# Returns:
+# The VM definition, as updated
+#
+# Since: 4.14.0
+##
+{'command': {'class': 'VM', 'name': 'hotunplugHostdev'},
+ 'data': {'vmID': 'UUID', 'hostdevName': 'str'},
+ 'returns': 'VmDefinition'}
+
+##
# @MigrateMode:
#
# An enumeration of VM migration modes.
--
To view, visit http://gerrit.ovirt.org/22523
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8fbf4a1d62789d9404e5977eb7eb01b17a1a43fb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: vdsmcli: Add a contrib command line client alternative
by asegurap@redhat.com
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: vdsmcli: Add a contrib command line client alternative
......................................................................
vdsmcli: Add a contrib command line client alternative
This command line client is built by hand for the convenience of
developers and requires the click library:
pip install click
It easily supports commands and subcommands. For example:
vdsmcli network
is a command and 'show' and 'add' are its subcommands.
Examples:
toniel602 ~ # vdsmcli network show -k nics -k networks
============================================= Nics
eth6
eth5
eth4
eth3
eth2
eth1
============================================= Networks
foo
or
toniel602 ~ # vdsmcli --verbode --pprint network show -k networks
============================================= Networks
===============
foo
===============
{'addr': '',
'bootproto4': 'none',
'bridged': False,
'gateway': '',
'iface': 'bond42',
'interface': 'bond42',
'ipv6addrs': ['2620:52:0:223c:201:a4ff:feac:8796/64',
'fe80::201:a4ff:feac:8796/64'],
'ipv6gateway': 'fe80:52:0:223c::3fe',
'mtu': '1500',
'netmask': ''}
addition
toniel602 ~ # ./cvdsm.py -v -p network add foo --bridgeless --nic eth4
--nic eth5 --bond bond42
Networks: {u'foo': {'bonding': u'bond42', 'bridged': False}}
Bonds: {u'bond42': {'nics': (u'eth4', u'eth5')}}
Succeeded. Done
One could extend it with a vm command so that it was easy to do:
vdsmcli vm hotplug 34f5f608-91ed-48d1-af31-c3a3d788678e nic --mac 00:11:22:33:44:55 --model virtio
Change-Id: Ie5574b2b34f0b7b2174e9da0c4487f812ff20f5b
Signed-off-by: Antoni S. Puimedon <asegurap(a)redhat.com>
---
A contrib/vdsmcli.py
1 file changed, 113 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/28152/1
diff --git a/contrib/vdsmcli.py b/contrib/vdsmcli.py
new file mode 100644
index 0000000..2255201
--- /dev/null
+++ b/contrib/vdsmcli.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python2
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+"""This is a command line client for vdsm."""
+
+from pprint import pformat
+
+import click
+
+from vdsm import netinfo, vdscli
+
+_NET_DEVICE_TYPES = ('networks', 'bridges', 'vlans', 'bondings', 'nics')
+
+
+class Options(object):
+ def __init__(self, verbose=None, pprint=None):
+ self.verbose = verbose
+ self.pprint = pprint
+
+
+(a)click.group()
+(a)click.option('-v', '--verbose', is_flag=True)
+(a)click.option('-p', '--pprint', is_flag=True)
+(a)click.pass_context
+def cli(ctx, verbose, pprint):
+ ctx.obj = Options(verbose, pprint)
+
+
+(a)cli.group()
+(a)click.pass_obj
+def network(options):
+ """Network actions and information displaying."""
+ pass
+
+
+(a)network.command(help='Configure network')
+(a)click.pass_obj
+(a)click.option('--bridged/--bridgeless', default=True)
+(a)click.option('--vlan', default=None, type=click.INT)
+(a)click.option('--bond', default=None)
+(a)click.option('--bond-opts', default=None)
+(a)click.option('--nic', multiple=True)
+(a)click.argument('name')
+(a)click.argument('extra_attributes', required=False, nargs=-1)
+def add(options, bridged, vlan, bond, bond_opts, nic, name, extra_attributes):
+ conn = vdscli.connect()
+ networks = {name: {'bridged': bridged}}
+ if vlan:
+ networks[name]['vlan'] = vlan
+ if len(nic) == 1:
+ networks[name]['nic'] = nic[0]
+ if bond:
+ networks[name]['bonding'] = bond
+ bonds = {bond: {'nics': nic}}
+ if bond_opts:
+ bonds[bond]['options'] = bond_opts
+ else:
+ bonds = {}
+
+ for key, value in (elem.split('=') for elem in extra_attributes):
+ networks[name][key] = value
+
+ if options.verbose:
+ click.echo('Networks: %s' % (pformat(networks) if options.pprint else
+ networs))
+ click.echo('Bonds: %s' % (pformat(bonds) if options.pprint else bonds))
+ result = conn.setupNetworks(networks, bonds, {'connectivityCheck': False})
+ code = result['status']['code']
+ message = result['status']['message']
+ click.echo('%s. %s' % ('Succeeded' if code == 0 else 'Failed', message))
+
+
+(a)network.command(help='show network and net device information')
+(a)click.pass_obj
+(a)click.option('--kind', '-k', multiple=True, type=click.Choice(
+ _NET_DEVICE_TYPES))
+def show(options, kind):
+ if not kind:
+ kind = ('networks',)
+ conn = vdscli.connect()
+ info = netinfo.NetInfo(conn.getVdsCapabilities()['info'])
+ for k in kind:
+ click.echo('')
+ click.echo('=' * 45, nl=False)
+ click.echo(' ' + k[0].upper() + k[1:])
+ for name, attrs in getattr(info, k).iteritems():
+ if options.verbose:
+ click.echo('=' * 15)
+ click.echo(name)
+ if options.verbose:
+ click.echo('=' * 15)
+ click.echo(pformat(attrs) if options.pprint else attrs)
+ click.echo('')
+
+
+if __name__ == '__main__':
+ cli()
--
To view, visit http://gerrit.ovirt.org/28152
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5574b2b34f0b7b2174e9da0c4487f812ff20f5b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: volume: support multi line metadata values
by laravot@redhat.com
Liron Ar has uploaded a new change for review.
Change subject: volume: support multi line metadata values
......................................................................
volume: support multi line metadata values
Currently when creating the metadata dict it's assumed that each value
can be in a single line only while it's not necessarily true.
Change-Id: Ib03152b852294f7b69a8734c2aa1206ea2c1fabe
Signed-off-by: Liron Aravot <laravot(a)redhat.com>
---
M vdsm/storage/blockVolume.py
M vdsm/storage/volume.py
2 files changed, 12 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/28493/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index d448e00..d7cf020 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -580,7 +580,6 @@
self.log.error(e, exc_info=True)
raise se.VolumeMetadataReadError("%s: %s" % (metaId, e))
-
def setMetadata(self, meta, metaId=None):
"""
Set the meta data hash as the new meta data of the Volume
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index aed932e..bfc1ff1 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -814,19 +814,27 @@
"""
pass
-
def metadata2dict(self, meta):
out = {}
+ key = None
+ value = None
+
+ def put(key, value):
+ out[key.strip()] = "\n".join(value).strip()
+
for l in meta:
if l.startswith("EOF"):
- return out
+ break
if l.find("=") < 0:
+ value.append(l)
continue
+ if key:
+ put(key, value)
key, value = l.split("=")
- out[key.strip()] = value.strip()
+ value = [value]
+ put(key, value)
return out
-
def metadata2info(self, meta):
return {
--
To view, visit http://gerrit.ovirt.org/28493
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib03152b852294f7b69a8734c2aa1206ea2c1fabe
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <laravot(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: volume: move metadata dict creation to volume.py
by laravot@redhat.com
Liron Ar has uploaded a new change for review.
Change subject: volume: move metadata dict creation to volume.py
......................................................................
volume: move metadata dict creation to volume.py
Change-Id: I26c495d437fe327a4029fe1dae087d182ba6611b
Signed-off-by: Liron Aravot <laravot(a)redhat.com>
---
M vdsm/storage/blockVolume.py
M vdsm/storage/fileVolume.py
M vdsm/storage/volume.py
3 files changed, 16 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/28492/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 81331fa..d448e00 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -574,20 +574,12 @@
try:
meta = misc.readblock(lvm.lvPath(vgname, sd.METADATA),
offs * VOLUME_METASIZE, VOLUME_METASIZE)
- out = {}
- for l in meta:
- if l.startswith("EOF"):
- return out
- if l.find("=") < 0:
- continue
- key, value = l.split("=")
- out[key.strip()] = value.strip()
+ return self.metadata2dict(meta)
except Exception as e:
self.log.error(e, exc_info=True)
raise se.VolumeMetadataReadError("%s: %s" % (metaId, e))
- return out
def setMetadata(self, meta, metaId=None):
"""
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index 654818e..6b655b8 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -294,20 +294,11 @@
try:
f = self.oop.directReadLines(metaPath)
- out = {}
- for l in f:
- if l.startswith("EOF"):
- return out
- if l.find("=") < 0:
- continue
- key, value = l.split("=")
- out[key.strip()] = value.strip()
+ return self.metadata2dict(f)
except Exception as e:
self.log.error(e, exc_info=True)
raise se.VolumeMetadataReadError("%s: %s" % (metaId, e))
-
- return out
@classmethod
def __putMetadata(cls, metaId, meta):
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index 3a5ed8e..aed932e 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -814,6 +814,20 @@
"""
pass
+
+ def metadata2dict(self, meta):
+ out = {}
+ for l in meta:
+ if l.startswith("EOF"):
+ return out
+ if l.find("=") < 0:
+ continue
+ key, value = l.split("=")
+ out[key.strip()] = value.strip()
+
+ return out
+
+
def metadata2info(self, meta):
return {
"uuid": self.volUUID,
--
To view, visit http://gerrit.ovirt.org/28492
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I26c495d437fe327a4029fe1dae087d182ba6611b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <laravot(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: xen: libvirtconnection: connect to xen, if it is available
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: xen: libvirtconnection: connect to xen, if it is available
......................................................................
xen: libvirtconnection: connect to xen, if it is available
Change-Id: I6cc6474b012d900fe3c5e1dab7a1e3e815ae01c3
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/libvirtconnection.py
1 file changed, 6 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/28350/1
diff --git a/lib/vdsm/libvirtconnection.py b/lib/vdsm/libvirtconnection.py
index b1332db..983287f 100644
--- a/lib/vdsm/libvirtconnection.py
+++ b/lib/vdsm/libvirtconnection.py
@@ -29,6 +29,7 @@
from . import constants, utils
log = logging.getLogger()
+XEN = os.path.exists('/proc/xen')
class _EventLoop:
@@ -124,7 +125,7 @@
libvirt.VIR_ERR_INTERNAL_ERROR,
libvirt.VIR_ERR_NO_CONNECT,
libvirt.VIR_ERR_INVALID_CONN)
- if edom in EDOMAINS and ecode in ECODES:
+ if not XEN and edom in EDOMAINS and ecode in ECODES:
try:
__connections.get(id(target)).pingLibvirt()
except libvirt.libvirtError as e:
@@ -148,7 +149,10 @@
conn = __connections.get(id(target))
if not conn:
log.debug('trying to connect libvirt')
- conn = _open_qemu_connection()
+ if XEN:
+ conn = libvirt.open('xen:///')
+ else:
+ conn = _open_qemu_connection()
__connections[id(target)] = conn
setattr(conn, 'pingLibvirt', getattr(conn, 'getLibVersion'))
--
To view, visit http://gerrit.ovirt.org/28350
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6cc6474b012d900fe3c5e1dab7a1e3e815ae01c3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: xen: use qemu connection, as compareCPU is unavailable via xen
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: xen: use qemu connection, as compareCPU is unavailable via xen
......................................................................
xen: use qemu connection, as compareCPU is unavailable via xen
This patch is required until compareCPU is implemented by libvirt's xenlight
driver.
Change-Id: Ib86a325910aa57847fef194d7c4bd7c7854e2852
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/caps.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/28351/1
diff --git a/vdsm/caps.py b/vdsm/caps.py
index a4caa13..a27f582 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -368,7 +368,10 @@
@utils.memoized
def _getCompatibleCpuModels():
- c = libvirtconnection.get()
+ if libvirtconnection.XEN:
+ c = libvirtconnection._open_qemu_connection()
+ else:
+ c = libvirtconnection.get()
allModels = _getAllCpuModels()
def compatible(model, vendor):
--
To view, visit http://gerrit.ovirt.org/28351
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib86a325910aa57847fef194d7c4bd7c7854e2852
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: xen: do not attempt to read underlying device info
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: xen: do not attempt to read underlying device info
......................................................................
xen: do not attempt to read underlying device info
Xen's device information is quite different than what Vdsm currently
expects and needs. They lack bus address, alias, and driver.
With this patch, Vdsm-on-Xen does not even attempt to read this
information, which means that it would not be able to inract with the
underlying devices.
This is a hack which I do not expect getting into Vdsm proper. Much
deeper refactoring is required to handle Xen devices.
Change-Id: Ifae785c5caa2e37fb8968ead570502e935f7900f
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/28352/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 21662bc..6a0d035 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2921,7 +2921,8 @@
raise Exception('destroy() called before Vm started')
self._getUnderlyingVmInfo()
- self._getUnderlyingVmDevicesInfo()
+ if not libvirtconnection.XEN:
+ self._getUnderlyingVmDevicesInfo()
self._updateAgentChannels()
# Currently there is no protection agains mirroring a network twice,
--
To view, visit http://gerrit.ovirt.org/28352
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifae785c5caa2e37fb8968ead570502e935f7900f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: xen: hook: let oVirt run VMs on Xen hosts
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: xen: hook: let oVirt run VMs on Xen hosts
......................................................................
xen: hook: let oVirt run VMs on Xen hosts
With this hook installed (and previous hacks applied) it is possible to
start oVirt VMs as Xen domU HVM guests.
Note that this hook has undergone very limited testing: migration was
not attempted, as well as no shared storage.
The hook is known to be limited, as it does not support qcow images, or
spice; no emulated devices, no hotplugging nor virtio. It is expected to
serve as a proof of concept and as a basis to further experimentation by
other parties.
Change-Id: Iaabda72bebde98d2884fe9fcfe87d266e2dcdde0
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M configure.ac
M debian/Makefile.am
A debian/vdsm-hook-xen.docs
A debian/vdsm-hook-xen.install
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/xen/Makefile.am
A vdsm_hooks/xen/after_get_caps.py
A vdsm_hooks/xen/before_vm_start.py
A vdsm_hooks/xen/empty.test.xml
10 files changed, 343 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/28353/1
diff --git a/configure.ac b/configure.ac
index 5e7f333..0d5bcaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,6 +310,7 @@
vdsm_hooks/vmdisk/Makefile
vdsm_hooks/vmfex/Makefile
vdsm_hooks/vmfex_dev/Makefile
+ vdsm_hooks/xen/Makefile
vdsm_reg/Makefile
])
diff --git a/debian/Makefile.am b/debian/Makefile.am
index 00b0d33..b65dd70 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -87,6 +87,8 @@
vdsm-hook-vmfex.install \
vdsm-hook-vmfex-dev.docs \
vdsm-hook-vmfex-dev.install \
+ vdsm-hook-xen.docs \
+ vdsm-hook-xen.install \
vdsm.install \
vdsm.postinst \
vdsm.postrm \
diff --git a/debian/vdsm-hook-xen.docs b/debian/vdsm-hook-xen.docs
new file mode 100644
index 0000000..5ecd9c6
--- /dev/null
+++ b/debian/vdsm-hook-xen.docs
@@ -0,0 +1 @@
+COPYING
diff --git a/debian/vdsm-hook-xen.install b/debian/vdsm-hook-xen.install
new file mode 100644
index 0000000..917f772
--- /dev/null
+++ b/debian/vdsm-hook-xen.install
@@ -0,0 +1,2 @@
+usr/libexec/vdsm/hooks/before_device_create/70_xen
+usr/libexec/vdsm/hooks/after_get_caps/70_xen
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 35617ab..46d3d71 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -600,6 +600,16 @@
%description hook-vmdisk
Hook adds additional disk image for a VM (raw or qcow2)
+%package hook-xen
+Summary: Rum an oVirt VM as a Xen domU
+BuildArch: noarch
+Requires: %{name}
+
+%description hook-xen
+VDSM hook that allow oVirt to run its VMs as Xen domU.
+Install this hook on a Xen dom0 with HVM support, and add the host to Engine.
+
+
%if 0%{?with_gluster}
%package gluster
Summary: Gluster Plugin for VDSM
@@ -1385,7 +1395,13 @@
%{_libexecdir}/%{vdsm_name}/hooks/before_device_create/50_vmfex
%{_libexecdir}/%{vdsm_name}/hooks/before_device_migrate_destination/50_vmfex
%{_libexecdir}/%{vdsm_name}/hooks/before_nic_hotplug/50_vmfex
-%endif
+
+%files hook-xen
+%defattr(-, root, root, -)
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/70_xen
+%{_libexecdir}/%{vdsm_name}/hooks/after_get_caps/70_xen
+
+%endif # with_hooks
%files debug-plugin
%defattr(-, root, root, -)
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index 5e4d731..ef5a22a 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -48,6 +48,7 @@
vmdisk \
vmfex \
vmfex_dev \
+ xen \
$(NULL)
endif
diff --git a/vdsm_hooks/xen/Makefile.am b/vdsm_hooks/xen/Makefile.am
new file mode 100644
index 0000000..c6c76ca
--- /dev/null
+++ b/vdsm_hooks/xen/Makefile.am
@@ -0,0 +1,42 @@
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+include $(top_srcdir)/build-aux/Makefile.subs
+
+CLEANFILES = \
+ config.log
+
+EXTRA_DIST = \
+ after_get_caps.py \
+ before_vm_start.py \
+ empty.test.xml \
+ $(NULL)
+
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_get_caps
+ $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/70_xen
+ $(INSTALL_SCRIPT) $(srcdir)/after_get_caps.py \
+ $(DESTDIR)$(vdsmhooksdir)/after_get_caps/70_xen
+
+uninstall-local:
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/70_xen
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_get_caps/70_xen
diff --git a/vdsm_hooks/xen/after_get_caps.py b/vdsm_hooks/xen/after_get_caps.py
new file mode 100755
index 0000000..82f6ccb
--- /dev/null
+++ b/vdsm_hooks/xen/after_get_caps.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import sys
+import traceback
+
+import hooking
+
+
+def fake_caps(capsdict):
+ """Report kvmEnable, even though it is not, so the Engine knows that
+ virualization is available on this host"""
+ capsdict['kvmEnabled'] = 'True'
+ flags = set(capsdict['cpuFlags'].split(','))
+
+ # vmx is not exposed to dom0, yet Engine expects to see it
+ flags.add('vmx')
+
+ capsdict['cpuFlags'] += ','.join(flags)
+
+ return capsdict
+
+
+def test():
+ from pprint import pprint
+ pprint(fake_caps({}))
+
+
+def main():
+ hooking.write_json(fake_caps(hooking.read_json()))
+
+
+if __name__ == '__main__':
+ if '--test' in sys.argv:
+ test()
+ else:
+ try:
+ main()
+ except:
+ hooking.exit_hook('[unexpected error]: %s\n'
+ % traceback.format_exc())
diff --git a/vdsm_hooks/xen/before_vm_start.py b/vdsm_hooks/xen/before_vm_start.py
new file mode 100755
index 0000000..17bea92
--- /dev/null
+++ b/vdsm_hooks/xen/before_vm_start.py
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+from xml.dom import minidom
+import sys
+import traceback
+
+
+def drop_address(d):
+ addresses = d.getElementsByTagName('address')
+ if addresses:
+ d.removeChild(addresses[0])
+
+
+def drop_driver(d):
+ drivers = d.getElementsByTagName('driver')
+ if drivers:
+ d.removeChild(drivers[0])
+
+
+def xenify(domxml):
+ """Make a Vdsm-generate domxml runnable on a Xen host"""
+
+ # it's not kvm
+ domxml.getElementsByTagName('domain')[0].attributes['type'].value = 'xen'
+
+ # no vCPU hotplugging
+ vcpu = domxml.getElementsByTagName("vcpu")[0]
+ while vcpu.firstChild:
+ vcpu.removeChild(vcpu.firstChild)
+ vcpu.appendChild(domxml.createTextNode('1'))
+
+ devices = domxml.getElementsByTagName("devices")[0]
+ d = devices.firstChild
+ while d:
+ n = d.nextSibling
+ if d.nodeType == d.TEXT_NODE:
+ pass # skip whitespace
+
+ elif d.tagName == 'channel':
+ # no support for virtio channels.
+ devices.removeChild(d)
+
+ elif d.tagName == 'graphics' and d.attributes['type'].value == 'spice':
+ raise Exception('spice not supported, try vnc')
+
+ elif d.tagName == 'memballoon':
+ # no virtio balloon
+ devices.removeChild(d)
+
+ elif d.tagName == 'controller':
+ # no controllers
+ devices.removeChild(d)
+
+ elif d.tagName == 'video':
+ # use xen video device
+ drop_address(d)
+ d.getElementsByTagName('model')[0].attributes['type'].value = 'xen'
+
+ elif d.tagName == 'interface':
+ # xen interfaces are not pci devices
+ drop_address(d)
+ d.removeChild(d.getElementsByTagName('model')[0])
+ drop_driver(d)
+
+ elif d.tagName == 'disk' and d.attributes['device'].value == 'cdrom':
+ # bug: cdrom existence makes disk non-bootable
+ # bug: empty cdrom path is handled badly by libvirt
+ devices.removeChild(d)
+
+ elif d.tagName == 'disk':
+ # xen disks are not pci devices
+ drop_address(d)
+
+ target = d.getElementsByTagName('target')[0]
+ target.attributes['bus'].value = 'xen'
+ target.attributes['dev'].value = (
+ 'xvd' + target.attributes['dev'].value[2:])
+
+ driver = d.getElementsByTagName('driver')[0]
+ # most probably, enospace and co are missing, too.
+ if driver.attributes['type'].value != 'raw':
+ raise Exception(
+ 'I have no idea how to specify qcow to xen, '
+ 'please use raw')
+ d.removeChild(driver)
+
+ else:
+ pass
+ d = n
+
+ domxml.getElementsByTagName("features")[0].appendChild(
+ domxml.createElement('pae'))
+
+ return domxml
+
+
+def test():
+ domxml = minidom.parseString(sys.stdin.read())
+ print xenify(domxml).toxml(encoding='UTF-8')
+
+
+def main():
+ domxml = hooking.read_domxml()
+ hooking.write_domxml(xenify(domxml))
+
+
+if __name__ == '__main__':
+ if '--test' in sys.argv:
+ test()
+ else:
+ import hooking
+ try:
+ main()
+ except:
+ hooking.exit_hook('[unexpected error]: %s\n'
+ % traceback.format_exc())
diff --git a/vdsm_hooks/xen/empty.test.xml b/vdsm_hooks/xen/empty.test.xml
new file mode 100644
index 0000000..710e5b9
--- /dev/null
+++ b/vdsm_hooks/xen/empty.test.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?><domain type="kvm">
+
+ <!-- This is a domxml of a typical, yet extremely simple, oVirt VM.
+ It is supplied here to ease tests of the xenify script. -->
+
+ <name>empty</name>
+ <uuid>a6b0e0af-7f6d-4a18-95d6-f34477be340d</uuid>
+ <memory>20480</memory>
+ <currentMemory>20480</currentMemory>
+ <vcpu current="1">160</vcpu>
+ <memtune>
+ <min_guarantee>102400</min_guarantee>
+ </memtune>
+ <devices>
+ <channel type="unix">
+ <target name="com.redhat.rhevm.vdsm" type="virtio"/>
+ <source mode="bind" path="/var/lib/libvirt/qemu/channels/a6b0e0af-7f6d-4a18-95d6-f34477be340d.com.redhat.rhevm.vdsm"/>
+ </channel>
+ <channel type="unix">
+ <target name="org.qemu.guest_agent.0" type="virtio"/>
+ <source mode="bind" path="/var/lib/libvirt/qemu/channels/a6b0e0af-7f6d-4a18-95d6-f34477be340d.org.qemu.guest_agent.0"/>
+ </channel>
+ <input bus="ps2" type="mouse"/>
+ <channel type="spicevmc">
+ <target name="com.redhat.spice.0" type="virtio"/>
+ </channel>
+ <graphics autoport="yes" keymap="en-us" listen="0" type="vnc">
+ </graphics>
+ <memballoon model="virtio"/>
+ <controller index="0" model="virtio-scsi" type="scsi">
+ <address bus="0x00" domain="0x0000" function="0x0" slot="0x04" type="pci"/>
+ </controller>
+ <video>
+ <address bus="0x00" domain="0x0000" function="0x0" slot="0x02" type="pci"/>
+ <model type="vga"/>
+ </video>
+ <interface type="bridge">
+ <address bus="0x00" domain="0x0000" function="0x0" slot="0x03" type="pci"/>
+ <mac address="00:1a:4a:bd:c4:10"/>
+ <model type="virtio"/>
+ <source bridge="ovirtmgmt"/>
+ <filterref filter="vdsm-no-mac-spoofing"/>
+ <link state="up"/>
+ <driver queues="3"/>
+ </interface>
+ <disk device="cdrom" snapshot="no" type="file">
+ <address bus="1" controller="0" target="0" type="drive" unit="0"/>
+ <source file="" startupPolicy="optional"/>
+ <target bus="ide" dev="hdc"/>
+ <readonly/>
+ <serial/>
+ </disk>
+ <disk device="disk" snapshot="no" type="file">
+ <address bus="0x00" domain="0x0000" function="0x0" slot="0x06" type="pci"/>
+ <source file="/rhev/data-center/mnt/_var_lib_images/51dcf56a-371b-43f6-824e-1f2364d17a19/images/1ebbf8d0-853c-4c56-ad80-213afddbede1/79e8fb9c-39e8-48e6-b111-06d186e910d3"/>
+ <target bus="virtio" dev="vda"/>
+ <serial>1ebbf8d0-853c-4c56-ad80-213afddbede1</serial>
+ <driver cache="none" error_policy="stop" io="threads" name="qemu" type="raw"/>
+ </disk>
+ </devices>
+ <os>
+ <type arch="x86_64" machine="rhel6.5.0">hvm</type>
+ <smbios mode="sysinfo"/>
+ </os>
+ <sysinfo type="smbios">
+ <system>
+ <entry name="manufacturer">oVirt</entry>
+ <entry name="product">oVirt Node</entry>
+ <entry name="version">6-5.el6.centos.11.2</entry>
+ <entry name="serial">AEF32683-69FA-4EFB-AE8F-3555B2C1F6E5</entry>
+ <entry name="uuid">a6b0e0af-7f6d-4a18-95d6-f34477be340d</entry>
+ </system>
+ </sysinfo>
+ <clock adjustment="0" offset="variable">
+ <timer name="rtc" tickpolicy="catchup"/>
+ <timer name="pit" tickpolicy="delay"/>
+ <timer name="hpet" present="no"/>
+ </clock>
+ <features>
+ <acpi/>
+ </features>
+
+</domain>
--
To view, visit http://gerrit.ovirt.org/28353
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaabda72bebde98d2884fe9fcfe87d266e2dcdde0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: faqemu: move hook logic out of vdsm
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: faqemu: move hook logic out of vdsm
......................................................................
faqemu: move hook logic out of vdsm
Vdsm-proper has been aware of the faqemu hook. Now that we have an
after_get_caps hook point, this is no longer necessary. This patch move
the faking logic, so that it does not need to be shipped on production
systems and clutter the code.
Change-Id: I46d0079491f707b0abd3fbbe2d47f63697dac9c5
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm.spec.in
M vdsm/caps.py
M vdsm_hooks/faqemu/Makefile.am
A vdsm_hooks/faqemu/after_get_caps.py
4 files changed, 110 insertions(+), 42 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/27705/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index c620174..e6db372 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1464,6 +1464,7 @@
%defattr(-, root, root, -)
%doc COPYING
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/10_faqemu
+%{_libexecdir}/%{vdsm_name}/hooks/after_get_caps/10_faqemu
%if 0%{?with_gluster}
%files gluster
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 46094f3..7c1e520 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -1,5 +1,5 @@
#
-# Copyright 2011 Red Hat, Inc.
+# Copyright 2011-2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -197,7 +197,7 @@
@utils.memoized
-def _getLiveSnapshotSupport(arch, capabilities=None):
+def getLiveSnapshotSupport(arch, capabilities=None):
if capabilities is None:
capabilities = _getCapsXMLStr()
caps = minidom.parseString(capabilities)
@@ -295,7 +295,7 @@
@utils.memoized
-def _getEmulatedMachines(arch, capabilities=None):
+def getEmulatedMachines(arch, capabilities=None):
if capabilities is None:
capabilities = _getCapsXMLStr()
caps = minidom.parseString(capabilities)
@@ -444,13 +444,6 @@
return dict(release=release, version=version, name=osname)
-def getTargetArch():
- if config.getboolean('vars', 'fake_kvm_support'):
- return config.get('vars', 'fake_kvm_architecture')
- else:
- return platform.machine()
-
-
def _getSELinuxEnforceMode():
"""
Returns the SELinux mode as reported by kernel.
@@ -480,13 +473,11 @@
def get():
- targetArch = getTargetArch()
+ targetArch = platform.machine()
caps = {}
- caps['kvmEnabled'] = \
- str(config.getboolean('vars', 'fake_kvm_support') or
- os.path.exists('/dev/kvm')).lower()
+ caps['kvmEnabled'] = str(os.path.exists('/dev/kvm')).lower()
cpuInfo = CpuInfo()
cpuTopology = CpuTopology()
@@ -498,30 +489,9 @@
caps['cpuThreads'] = str(cpuTopology.threads())
caps['cpuSockets'] = str(cpuTopology.sockets())
caps['cpuSpeed'] = cpuInfo.mhz()
- if config.getboolean('vars', 'fake_kvm_support'):
- if targetArch == Architecture.X86_64:
- caps['cpuModel'] = 'Intel(Fake) CPU'
-
- flagList = ['vmx', 'sse2', 'nx']
-
- if targetArch == platform.machine():
- flagList += cpuInfo.flags()
-
- flags = set(flagList)
-
- caps['cpuFlags'] = ','.join(flags) + ',model_486,model_pentium,' \
- 'model_pentium2,model_pentium3,model_pentiumpro,' \
- 'model_qemu32,model_coreduo,model_core2duo,model_n270,' \
- 'model_Conroe,model_Penryn,model_Nehalem,model_Opteron_G1'
- elif targetArch == Architecture.PPC64:
- caps['cpuModel'] = 'POWER 7 (fake)'
- caps['cpuFlags'] = 'powernv,model_POWER7_v2.3'
- else:
- raise RuntimeError('Unsupported architecture: %s' % targetArch)
- else:
- caps['cpuModel'] = cpuInfo.model()
- caps['cpuFlags'] = ','.join(cpuInfo.flags() +
- _getCompatibleCpuModels())
+ caps['cpuModel'] = cpuInfo.model()
+ caps['cpuFlags'] = ','.join(cpuInfo.flags() +
+ _getCompatibleCpuModels())
caps.update(_getVersionInfo())
caps.update(netinfo.get())
@@ -534,7 +504,7 @@
caps['operatingSystem'] = osversion()
caps['uuid'] = utils.getHostUUID()
caps['packages2'] = _getKeyPackages()
- caps['emulatedMachines'] = _getEmulatedMachines(targetArch)
+ caps['emulatedMachines'] = getEmulatedMachines(targetArch)
caps['ISCSIInitiatorName'] = _getIscsiIniName()
caps['HBAInventory'] = storage.hba.HBAInventory()
caps['vmTypes'] = ['kvm']
@@ -550,7 +520,7 @@
caps['selinux'] = _getSELinux()
- liveSnapSupported = _getLiveSnapshotSupport(targetArch)
+ liveSnapSupported = getLiveSnapshotSupport(targetArch)
if liveSnapSupported is not None:
caps['liveSnapshot'] = str(liveSnapSupported).lower()
diff --git a/vdsm_hooks/faqemu/Makefile.am b/vdsm_hooks/faqemu/Makefile.am
index 3e1b0c0..e93c943 100644
--- a/vdsm_hooks/faqemu/Makefile.am
+++ b/vdsm_hooks/faqemu/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2011-2012 Red Hat, Inc.
+# Copyright 2011-2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,12 +24,18 @@
config.log
EXTRA_DIST = \
- before_vm_start.py
+ before_vm_start.py \
+ after_get_caps.py \
+ $(NULL)
install-data-local:
$(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_get_caps
$(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
$(DESTDIR)$(vdsmhooksdir)/before_vm_start/10_faqemu
+ $(INSTALL_SCRIPT) $(srcdir)/after_get_caps.py \
+ $(DESTDIR)$(vdsmhooksdir)/after_get_caps/10_faqemu
uninstall-local:
$(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/10_faqemu
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/after_get_caps/10_faqemu
diff --git a/vdsm_hooks/faqemu/after_get_caps.py b/vdsm_hooks/faqemu/after_get_caps.py
new file mode 100644
index 0000000..a4a008b
--- /dev/null
+++ b/vdsm_hooks/faqemu/after_get_caps.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import platform
+import sys
+import traceback
+
+# using vdsm internals in a hook is dangerous and frowned upon,
+# as internal APIs may change without notice.
+# However, faqemu is a bit different, as it is not expected to be ever used in
+# production.
+sys.path.append('/usr/share/vdsm')
+import caps
+import hooking
+from vdsm.config import config
+
+
+def fake_caps(c, target_arch):
+ c['kvmEnabled'] = 'True'
+ cpu_info = caps.CpuInfo()
+ if target_arch == caps.Architecture.X86_64:
+ c['cpuModel'] = 'Intel(Fake) CPU'
+
+ flagList = ['vmx', 'sse2', 'nx']
+
+ if target_arch == platform.machine():
+ flagList += cpu_info.flags()
+
+ flags = set(flagList)
+
+ c['cpuFlags'] = ','.join(flags) + ',model_486,model_pentium,' \
+ 'model_pentium2,model_pentium3,model_pentiumpro,' \
+ 'model_qemu32,model_coreduo,model_core2duo,model_n270,' \
+ 'model_Conroe,model_Penryn,model_Nehalem,model_Opteron_G1'
+ elif target_arch == caps.Architecture.PPC64:
+ c['cpuModel'] = 'POWER 7 (fake)'
+ c['cpuFlags'] = 'powernv,model_POWER7_v2.3'
+ else:
+ raise RuntimeError('Unsupported architecture: %s' % target_arch)
+
+ if target_arch != platform.machine():
+ c['emulatedMachines'] = caps.getEmulatedMachines(target_arch)
+
+ liveSnapSupported = caps.getLiveSnapshotSupport(target_arch)
+ if liveSnapSupported is not None:
+ caps['liveSnapshot'] = str(liveSnapSupported).lower()
+
+ return c
+
+
+def main():
+ if config.getboolean('vars', 'fake_kvm_support'):
+ try:
+ c = hooking.read_json()
+ target_arch = config.get('vars', 'fake_kvm_architecture')
+ c = fake_caps(c, target_arch)
+ hooking.write_json(c)
+ except:
+ hooking.exit_hook('faqemu: %s\n'
+ % traceback.format_exc())
+ sys.exit(2)
+
+
+def test():
+ from pprint import pprint
+ pprint(fake_caps({}, 'ppc64'))
+
+
+if __name__ == '__main__':
+ if '--test' in sys.argv:
+ test()
+ else:
+ main()
--
To view, visit http://gerrit.ovirt.org/27705
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I46d0079491f707b0abd3fbbe2d47f63697dac9c5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
7 years, 11 months