Applied to master. Thanks!
On 07/28/2016 04:31 PM, Jose Ricardo Ziviani wrote:
- In order to validade if a given PCI is ok to be attached, a
heavy
verification has to be done. This commit add such verification
in the task. This will give a faster response to the UI,
improving the user experience.
- Add a small fix for an issue in PCI filter, added by commit eb3864f.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
v2:
- Fix issue in PCI Filter button
model/vmhostdevs.py | 22 ++++++++++++++++-
ui/js/src/kimchi.guest_edit_main.js | 49 ++++++++++++++++++++-----------------
2 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/model/vmhostdevs.py b/model/vmhostdevs.py
index 15b5bec..ef39de3 100644
--- a/model/vmhostdevs.py
+++ b/model/vmhostdevs.py
@@ -89,7 +89,6 @@ class VMHostDevsModel(object):
def create(self, vmid, params):
dev_name = params['name']
- self._passthrough_device_validate(dev_name)
dev_info = self.dev_model.lookup(dev_name)
if dev_info['device_type'] == 'pci':
@@ -216,6 +215,13 @@ class VMHostDevsModel(object):
dev_info = params['dev_info']
lock = params['lock']
+ try:
+ self._passthrough_device_validate(dev_info['name'])
+
+ except InvalidParameter as e:
+ cb(e.message, False)
+ raise
+
with lock:
try:
self._validate_pci_passthrough_env()
@@ -455,6 +461,13 @@ class VMHostDevsModel(object):
dev_info = params['dev_info']
lock = params['lock']
+ try:
+ self._passthrough_device_validate(dev_info['name'])
+
+ except InvalidParameter as e:
+ cb(e.message, False)
+ raise
+
with lock:
dom = VMModel.get_vm(vmid, self.conn)
@@ -501,6 +514,13 @@ class VMHostDevsModel(object):
dom = VMModel.get_vm(vmid, self.conn)
lock = params['lock']
+ try:
+ self._passthrough_device_validate(dev_info['name'])
+
+ except InvalidParameter as e:
+ cb(e.message, False)
+ raise
+
with lock:
with RollbackContext() as rollback:
xmlstr = self._get_usb_device_xml(dev_info)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index c4f39c4..a59d51a 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -534,7 +534,7 @@ kimchi.guest_edit_main = function() {
});
};
var pciDeviceButtonHandler = function() {
- $('button', '#form-guest-edit-pci').on('click',
function(event) {
+ $('.btn.btn-link', '#form-guest-edit-pci').on('click',
function(event) {
event.preventDefault();
var obj = $(this);
var objIcon = obj.find('i');
@@ -546,9 +546,11 @@ kimchi.guest_edit_main = function() {
wok.message.error(err.responseJSON.reason,
'#alert-modal-container');
});
} else {
+ $('html').addClass('in-progress');
+ $('#form-guest-edit-pci > .wok-mask').show();
+ var haveCompanions = false;
+ var pciTitle = i18n['KCHVMED6007M'] + '\n';
kimchi.getPCIDeviceCompanions(id, function(infoData) {
- var pciTitle = i18n['KCHVMED6007M'] + '\n';
- var haveCompanions = false;
for (var p = 0; p < infoData.length; p++) {
if (infoData[p].device_type === 'net') {
haveCompanions = true;
@@ -564,24 +566,19 @@ kimchi.guest_edit_main = function() {
pciTitle += ', ' + i18n['KCHVMED6006M'] +
' ' + infoData[p].model + '\n';
}
}
- var settings = {
- title: i18n['KCHVMED6012M'],
- content: pciTitle,
- confirm: i18n['KCHAPI6002M'],
- cancel: i18n['KCHAPI6003M']
- };
+ });
+ $('#form-guest-edit-pci > .wok-mask').fadeOut(300, function()
{});
+ $('html').removeClass('in-progress');
- if (haveCompanions) {
- wok.confirm(settings, function() {
- kimchi.addVMPCIDevice(kimchi.selectedGuest, {
- name: id
- }, function(task) {
- getOngoingAttachingDevices(task);
- }, function(err) {
- wok.message.error(err.responseJSON.reason,
'#alert-modal-container');
- });
- });
- } else {
+ var settings = {
+ title: i18n['KCHVMED6012M'],
+ content: pciTitle,
+ confirm: i18n['KCHAPI6002M'],
+ cancel: i18n['KCHAPI6003M']
+ };
+
+ if (haveCompanions) {
+ wok.confirm(settings, function() {
kimchi.addVMPCIDevice(kimchi.selectedGuest, {
name: id
}, function(task) {
@@ -589,8 +586,16 @@ kimchi.guest_edit_main = function() {
}, function(err) {
wok.message.error(err.responseJSON.reason,
'#alert-modal-container');
});
- }
- });
+ });
+ } else {
+ kimchi.addVMPCIDevice(kimchi.selectedGuest, {
+ name: id
+ }, function(task) {
+ getOngoingAttachingDevices(task);
+ }, function(err) {
+ wok.message.error(err.responseJSON.reason,
'#alert-modal-container');
+ });
+ }
}
});
};