Saggi Mizrahi has uploaded a new change for review.
Change subject: Refactor mom init error flow
......................................................................
Refactor mom init error flow
Splitting a log to to log invocation is bad because it could potentially
separate the 2 log lines. Further more, it usually points out to a bad
flow if you only sometimes need to log in the same flow so you resort to
such tricks.
- Add proper exception when MomThread fails to initialize
- Make the two error flows clear and have each logged properly
Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/clientIF.py
M vdsm/momIF.py
2 files changed, 25 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/9481/1
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 82603af..0bd686f 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -29,7 +29,7 @@
from storage.hsm import HSM
from vdsm.config import config
import ksm
-from momIF import MomThread
+from momIF import MomThread, isMomAvailable
from vdsm import netinfo
from vdsm.define import doneCode, errCode
import libvirt
@@ -189,14 +189,20 @@
'Please make sure it is installed.')
def _prepareMOM(self):
- try:
- momconf = config.get("mom", "conf")
- self.mom = MomThread(momconf)
- except:
- self.log.warn("MOM initialization failed and fall "
- "back to KsmMonitor")
- self.log.debug("Details:", exc_info=True)
- self.ksmMonitor = ksm.KsmMonitorThread(self)
+ momconf = config.get("mom", "conf")
+
+ if isMomAvailable():
+ try:
+ self.mom = MomThread(momconf)
+ return
+ except:
+ self.log.warn("MOM initialization failed and fall "
+ "back to KsmMonitor", exc_info=True)
+
+ else:
+ self.log.warn("MOM is not available, fallback to KsmMonitor")
+
+ self.ksmMonitor = ksm.KsmMonitorThread(self)
def _syncLibvirtNetworks(self):
"""
diff --git a/vdsm/momIF.py b/vdsm/momIF.py
index 827e9e4..807daef 100644
--- a/vdsm/momIF.py
+++ b/vdsm/momIF.py
@@ -27,11 +27,20 @@
_momAvailable = False
+class MomNotAvailableError(RuntimeError):
+ pass
+
+
+def isMomAvailable():
+ return _momAvailable
+
+
class MomThread(threading.Thread):
def __init__(self, momconf):
if not _momAvailable:
- raise Exception("MOM is not available")
+ raise MomNotAvailableError()
+
self.log = logging.getLogger("MOM")
self.log.info("Starting up MOM")
self._mom = mom.MOM(momconf)
--
To view, visit http://gerrit.ovirt.org/9481
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
Dan Kenigsberg has uploaded a new change for review.
Change subject: [WIP] a more delicate rollback
......................................................................
[WIP] a more delicate rollback
If things go wrong during setupNetwork, we try to revert the networking
state to what it used to be. Until this patch, we stopped the network
service, reverted all ifcfg-* files, and restarted networking.
This procedure disruppted all connection, even those unrelated to the
ones being set up.
With this change, we are taking down only affected devices, and revert
them to their pre-setupNetwork state.
Change-Id: If413164a34a1e6f0d7e4ef75ba931e630a26e666
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/configNetwork.py
1 file changed, 37 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/9506/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 09d70ac..6e8649c 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -320,6 +320,41 @@
open(confFile, 'w').write(content)
logging.info('Restored %s', confFile)
+ def _devType(self, content):
+ if re.search('^TYPE=Bridge$', content, re.MULTILINE):
+ return "Bridge"
+ elif re.search('^VLAN=yes$', content, re.MULTILINE):
+ return "Vlan"
+ else:
+ return "Other"
+
+ def _sortModifiedIfcfgs(self):
+ devdict = {'Bridge': [],
+ 'Vlan': [],
+ 'Other': []}
+ for confFile, _ in self._backups.iteritems():
+ try:
+ content = file(confFile).read()
+ except IOError as e:
+ if e.errno == os.errno.ENOENT:
+ continue
+ else:
+ raise
+ dev = confFile[len(self.NET_CONF_PREF):]
+
+ devdict[self._devType(content)].append(dev)
+
+ return nicSort(devdict['Other']) + devdict['Vlan'] + \
+ devdict['Bridge']
+
+ def _stopAtomicDevices(self):
+ for dev in reversed(self._sortModifiedIfcfgs()):
+ ifdown(dev)
+
+ def _startAtomicDevices(self):
+ for dev in self._sortModifiedIfcfgs():
+ ifup(dev)
+
@classmethod
def _persistentBackup(cls, filename):
""" Persistently backup ifcfg-* config files """
@@ -374,12 +409,12 @@
if not self._backups and not self._networksBackups:
return
- execCmd(['/etc/init.d/network', 'stop'])
+ self._stopAtomicDevices()
self.restoreAtomicNetworkBackup()
self.restoreAtomicBackup()
- execCmd(['/etc/init.d/network', 'start'])
+ self._startAtomicDevices()
@classmethod
def clearBackups(cls):
--
To view, visit http://gerrit.ovirt.org/9506
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If413164a34a1e6f0d7e4ef75ba931e630a26e666
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
Vinzenz Feenstra has uploaded a new change for review.
Change subject: vdsm: Attaching a console should be controllable
......................................................................
vdsm: Attaching a console should be controllable
Added a new VmParameter 'attachConsole' which defines
whether or not a console should be attached upon creation
Change-Id: Ie92b0ad693fdde7eae9091d944403ac4477eb186
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/libvirtvm.py
M vdsm_api/vdsmapi-schema.json
2 files changed, 7 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/9359/1
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index ca31a43..16e081f 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1260,7 +1260,9 @@
_QEMU_GA_DEVICE_NAME)
domxml.appendInput()
domxml.appendGraphics()
- domxml.appendConsole()
+
+ if utils.tobool(self.conf.get('attachConsole', 'false')):
+ domxml.appendConsole()
for devType in self._devices:
for dev in self._devices[devType]:
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 6591410..f736307 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -2379,6 +2379,9 @@
#
# @vmType: The type of VM
#
+# @attachConsole: Defines if a virtio-console should be attached to the
+# virtual machine
+#
# Since: 4.10.0
##
{'type': 'VmParameters',
@@ -2388,7 +2391,7 @@
'nice': 'int', 'smp': 'uint', 'smpCoresPerSocket': 'uint',
'smpThreadsPerCore': 'uint', 'timeOffset': 'uint',
'transparentHugePages': 'bool', 'vmId': 'UUID', 'vmName': 'str',
- 'vmType': 'VmType'}}
+ 'vmType': 'VmType', 'attachConsole': 'bool'}}
##
# @VmInfo:
--
To view, visit http://gerrit.ovirt.org/9359
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie92b0ad693fdde7eae9091d944403ac4477eb186
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: [WIP] netwiring: [3/3] Add API definitions.
......................................................................
[WIP] netwiring: [3/3] Add API definitions.
Third and final of the Network Wiring feature patches. It adds the
implementation for using the new updateVmDevice feature.
TODO: Add vdsm startup creation of the DUMMY_BRIDGE.
TODO: Add the port mirroring processing.
Change-Id: I3b9b4f49f80466a83e3e13f1042ac2a8866c6bcd
Signed-off-by: Antoni S. Puimedon <asegurap(a)redhat.com>
---
M vdsm/API.py
M vdsm/define.py
M vdsm/libvirtvm.py
3 files changed, 103 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/9562/1
diff --git a/vdsm/API.py b/vdsm/API.py
index e87b7e5..966a921 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -353,6 +353,17 @@
response['status']['message'] = 'Hibernation process starting'
return response
+ def updateVmDevice(self, params):
+ if 'type' not in params:
+ self.log.error('Missing a required parameters: type')
+ return {'status': {'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing one of required '
+ 'parameters: type'}}
+ v = self._cif.vmContainer.get(self._UUID)
+ if not v:
+ return errCode['noVM']
+ return v.updateDevice(params)
+
def hotplugNic(self, params):
try:
utils.validateMinimalKeySet(params, ('vmId', 'nic'))
diff --git a/vdsm/define.py b/vdsm/define.py
index 11a6ef6..e2ba196 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -124,6 +124,9 @@
'replicaErr': {'status':
{'code': 55,
'message': 'Drive replication error'}},
+ 'updateDevice': {'status':
+ {'code': 56,
+ 'message': 'Failed to update device'}},
'recovery': {'status':
{'code': 99,
'message':
@@ -137,3 +140,5 @@
#exitCodes
ERROR = 1
NORMAL = 0
+
+DUMMY_BRIDGE = 'none-br'
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 3439dc3..3fdde03 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -25,7 +25,7 @@
import threading
import vm
-from vdsm.define import ERROR, doneCode, errCode
+from vdsm.define import ERROR, doneCode, errCode, DUMMY_BRIDGE
from vdsm import utils
from vdsm import constants
import guestIF
@@ -1517,6 +1517,92 @@
return {'status': doneCode, 'vmList': self.status()}
+ def _updateNetDevice(self, params):
+ try:
+ utils.validateMinimalKeySet(params, ('alias', 'linkState'))
+ except ValueError:
+ self.log.error('Missing at least one of the required parameters: '
+ 'alias, linkState')
+ return {'status': {'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing at least one of required '
+ 'parameters: alias, linkState'}}
+
+ dev = None
+ for dev in self.conf['devices']:
+ if (dev['type'] == vm.NIC_DEVICES and
+ dev['alias'] == params['alias']):
+ break
+
+ if dev is None:
+ self.log.error('Network device %s cannot be updated. It does not'
+ 'exist', params['alias'])
+ return {'status':
+ {'code': errCode['updateDevice']['status']['code'],
+ 'message': 'Missing net device'}}
+
+ network = dev['network']
+
+ # Prepare the updateDevice xml
+ netelem = xml.dom.minidom.Element(params['type'])
+ netelem.setAttribute('type', 'bridge')
+ mac = xml.dom.minidom.Element('mac')
+ mac.setAttribute('address', dev['macAddr'])
+ netelem.appendChild(mac)
+ model = xml.dom.minidom.Element('model')
+ model.setAttribute('type', dev['nicModel'])
+ netelem.appendChild(model)
+
+ if 'network' not in params:
+ # If no network is specified we take the vnic to the dummy bridge
+ # and set the link 'down' always.
+ source = xml.dom.minidom.Element('source')
+ source.setAttribute('bridge', DUMMY_BRIDGE)
+ netelem.appendChild(source)
+ link = xml.dom.minidom.Element('link')
+ link.setAttribute('state', 'down')
+ netelem.appendChild(link)
+ else:
+ # There is a network defined. Thus, we either just modify the link
+ # status or move between network backends.
+ source = xml.dom.minidom.Element('source')
+ source.setAttribute('bridge', network)
+ netelem.appendChild(source)
+ link = xml.dom.minidom.Element('link')
+ if network != params['network']:
+ # If a different network is specified. First we take the link
+ # down and then update the device to connect to the new bridge.
+ link.setAttribute('state', 'down')
+ netelem.appendChild(link)
+ try:
+ self._dom.updateDeviceFlags(
+ netelem.toxml(),
+ libvirt.libvirt.VIR_DOMAIN_AFFECT_LIVE)
+ except:
+ self.log.debug("updateNetDevice failed", exc_info=True)
+ return {'status':
+ {'code': errCode['updateDevice']['status']['code'],
+ 'message': 'Failed to take the link down.'}}
+
+ link.setAttribute('state', params['linkState'])
+ source.setAttribute('bridge', params['network'])
+
+ try:
+ self._dom.updateDeviceFlags(
+ netelem.toxml(),
+ libvirt.libvirt.VIR_DOMAIN_AFFECT_LIVE)
+ except:
+ self.log.debug("updateNetDeviceFlags failed", exc_info=True)
+ return {'status':
+ {'code': errCode['updateDevice']['status']['code'],
+ 'message': 'Failed to take the link %s' % \
+ link.getAttribute('state')}}
+
+ def updateDevice(self, params):
+ if params['type'] == vm.NIC_DEVICES:
+ return self._updateNetDevice(params)
+ else:
+ return errCode['noimpl']
+
def hotunplugNic(self, params):
if self.isMigrating():
return errCode['migInProgress']
--
To view, visit http://gerrit.ovirt.org/9562
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b9b4f49f80466a83e3e13f1042ac2a8866c6bcd
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap(a)redhat.com>