[PATCH v2][Kimchi] Issue #651: Windows guests - default mouse type causing problems
by Ramon Medeiros
Add <input type='tablet' bus='usb'/> for winxp guests.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
Changes:
v2:
Last patch i added two dicts with same index. Now, add all changes to only one
index.
osinfo.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/osinfo.py b/osinfo.py
index 1527896..c51d6e0 100644
--- a/osinfo.py
+++ b/osinfo.py
@@ -85,7 +85,8 @@ template_specs = {'x86': {'old': dict(disk_bus='ide',
custom_specs = {'fedora': {'22': {'x86': dict(video_model='qxl')}},
- 'windows': {'xp': {'x86': dict(nic_model='pcnet')}}}
+ 'windows': {'xp': {'x86': dict(nic_model='pcnet',
+ tablet_bus="usb")}}}
modern_version_bases = {'x86': {'debian': '6.0', 'ubuntu': '7.10',
--
2.7.4
8 years, 1 month
[PATCH V2] [Kimchi] PCI hotplug: Check USB controller, define in template, add test in Power
by Lucio Correia
- Today it is not possible to hotplug a PCI in Power Systems without an
existing USB controller in the VM. This commit checks if there
is such controller in the VM, displaying an error message if not.
- When creating VMs using Kimchi in a Power System, the USB xhci
controller is defined by default to have PCI hotplug support.
- From now on all templates are created with xhci usb controller, so a
hotplug must be performed flawlessly. If anything wrong the test case
will fail.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
i18n.py | 1 +
model/vmhostdevs.py | 35 +++++++++++++++++++++++++++++++++++
tests/test_model.py | 25 +++++++++++++++++++++++++
vmtemplate.py | 13 +++++++++++++
xmlutils/usb.py | 45 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 119 insertions(+)
create mode 100644 xmlutils/usb.py
Changes in V2:
* fixed import platform
* added xmlutils/usb.py for better code organization
diff --git a/i18n.py b/i18n.py
index 814a8d9..03929e5 100644
--- a/i18n.py
+++ b/i18n.py
@@ -152,6 +152,7 @@ messages = {
"KCHVMHDEV0005E": _('The device %(name)s is probably in use by the host. Unable to attach it to the guest.'),
"KCHVMHDEV0006E": _('Hot-(un)plug of device %(name)s is not supported.'),
"KCHVMHDEV0007E": _('Failed to attach %(device)s to %(vm)s'),
+ "KCHVMHDEV0008E": _('VM %(vmid)s does not have a USB controller to accept PCI hotplug.'),
"KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"),
"KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"),
diff --git a/model/vmhostdevs.py b/model/vmhostdevs.py
index 4039240..1f893f2 100644
--- a/model/vmhostdevs.py
+++ b/model/vmhostdevs.py
@@ -20,6 +20,7 @@
import glob
import libvirt
import os
+import platform
import threading
from lxml import etree, objectify
from lxml.builder import E, ElementMaker
@@ -42,6 +43,9 @@ from wok.plugins.kimchi.xmlutils.qemucmdline import QEMU_NAMESPACE
CMDLINE_FIELD_NAME = 'spapr-pci-host-bridge.mem_win_size'
+USB_MODELS_PCI_HOTPLUG = ["piix3-uhci", "piix4-uhci", "ehci", "ich9-ehci1",
+ "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
+ "vt82c686b-uhci", "pci-ohci", "nec-xhci"]
WINDOW_SIZE_BAR = 0x800000000
@@ -134,6 +138,28 @@ class VMHostDevsModel(object):
return '<devices>%s</devices>' % hostdevs
+ def have_usb_controller(self, vmid):
+ dom = VMModel.get_vm(vmid, self.conn)
+
+ root = objectify.fromstring(dom.XMLDesc(0))
+
+ try:
+ controllers = root.devices.controller
+
+ except AttributeError:
+ return False
+
+ for controller in controllers:
+
+ if 'model' not in controller.attrib:
+ continue
+
+ if controller.attrib['type'] == 'usb' and \
+ controller.attrib['model'] in USB_MODELS_PCI_HOTPLUG:
+ return True
+
+ return False
+
def _get_pci_device_xml(self, dev_info, slot, is_multifunction):
if 'detach_driver' not in dev_info:
dev_info['detach_driver'] = 'kvm'
@@ -233,6 +259,15 @@ class VMHostDevsModel(object):
dom = VMModel.get_vm(vmid, self.conn)
driver = 'vfio' if self.caps.kernel_vfio else 'kvm'
+ # 'vfio' systems requires a usb controller in order to support pci
+ # hotplug on Power.
+ if driver == 'vfio' and platform.machine().startswith('ppc') and \
+ DOM_STATE_MAP[dom.info()[0]] != "shutoff" and \
+ not self.have_usb_controller(vmid):
+ msg = WokMessage('KCHVMHDEV0008E', {'vmid': vmid})
+ cb(msg.get_text(), False)
+ raise InvalidOperation("KCHVMHDEV0008E", {'vmid': vmid})
+
# Attach all PCI devices in the same IOMMU group
affected_names = self.devs_model.get_list(
_passthrough_affected_by=dev_info['name'])
diff --git a/tests/test_model.py b/tests/test_model.py
index 082cb9d..05d7415 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -24,6 +24,7 @@ import base64
import grp
import lxml.etree as ET
import os
+import platform
import pwd
import mock
import re
@@ -1626,6 +1627,30 @@ class ModelTests(unittest.TestCase):
volumes = inst.storagevolumes_get_list(args['name'])
self.assertEquals(len(volumes), 2)
+ def _host_is_power():
+ return platform.machine().startswith('ppc')
+
+ @unittest.skipUnless(_host_is_power(), 'Only required for Power hosts')
+ def test_pci_hotplug_requires_usb_controller(self):
+ config.set("authentication", "method", "pam")
+ inst = model.Model(None, objstore_loc=self.tmp_store)
+ tpl_params = {'name': 'test', 'memory': 1024, 'cdrom': UBUNTU_ISO}
+ inst.templates_create(tpl_params)
+
+ with RollbackContext() as rollback:
+ vm_params = {'name': 'kimchi-vm1', 'template': '/templates/test'}
+ task1 = inst.vms_create(vm_params)
+ inst.task_wait(task1['id'])
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
+ 'kimchi-vm1')
+ # Start vm
+ inst.vm_start('kimchi-vm1')
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_poweroff,
+ 'kimchi-vm1')
+ # check if create VM has USB controller
+ self.assertTrue(
+ inst.vmhostdevs_have_usb_controller('kimchi-vm1'))
+
class BaseModelTests(unittest.TestCase):
class FoosModel(object):
diff --git a/vmtemplate.py b/vmtemplate.py
index 06ee845..c3390fe 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
+import platform
import stat
import time
import urlparse
@@ -40,6 +41,7 @@ from wok.plugins.kimchi.xmlutils.graphics import get_graphics_xml
from wok.plugins.kimchi.xmlutils.interface import get_iface_xml
from wok.plugins.kimchi.xmlutils.qemucmdline import get_qemucmdline_xml
from wok.plugins.kimchi.xmlutils.serial import get_serial_xml
+from wok.plugins.kimchi.xmlutils.usb import get_usb_controller_xml
class VMTemplate(object):
@@ -358,6 +360,13 @@ class VMTemplate(object):
self.info['os_version'])
return unicode(interfaces, 'utf-8')
+ def _get_usb_controller(self):
+ # Power systems must include USB controller model
+ if not platform.machine().startswith('ppc'):
+ return ''
+
+ return get_usb_controller_xml('nec-xhci')
+
def _get_input_output_xml(self):
sound = """
<sound model='%(sound_model)s' />
@@ -469,6 +478,9 @@ class VMTemplate(object):
# cpu_info element
params['cpu_info_xml'] = self._get_cpu_xml()
+ # usb controller
+ params['usb_controller'] = self._get_usb_controller()
+
xml = """
<domain type='%(domain)s'>
%(qemu-stream-cmdline)s
@@ -503,6 +515,7 @@ class VMTemplate(object):
%(interfaces)s
%(graphics)s
%(input_output)s
+ %(usb_controller)s
%(serial)s
<memballoon model='virtio' />
</devices>
diff --git a/xmlutils/usb.py b/xmlutils/usb.py
new file mode 100644
index 0000000..84d2aeb
--- /dev/null
+++ b/xmlutils/usb.py
@@ -0,0 +1,45 @@
+#
+# Project Kimchi
+#
+# Copyright IBM Corp, 2016
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import lxml.etree as ET
+from lxml.builder import E
+
+
+def get_usb_controller_xml(model):
+ """
+ Returns a XML string defining USB controller. Example for model='nec-xhci':
+ <controller type='usb' index='0' model='nec-xhci'>
+ <address type='pci' domain='0x0000'
+ bus='0x00' slot='0x0f' function='0x0'/>
+ </controller>
+ """
+ m = E.controller(
+ E.address(
+ type='pci',
+ domain='0x0000',
+ bus='0x00',
+ slot='0x0f',
+ function='0x0'
+ ),
+ type='usb',
+ index='0',
+ model=model
+ )
+
+ return ET.tostring(m)
--
2.7.4
8 years, 1 month
[PATCH] [WoK] Github #143: non-ASCII characters in the password field
by dhbarboza82@gmail.com
From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
This patch enables WoK backend to read non-ASCII characters from
the password field.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
src/wok/auth.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wok/auth.py b/src/wok/auth.py
index 421f8f3..6b1c160 100644
--- a/src/wok/auth.py
+++ b/src/wok/auth.py
@@ -301,8 +301,8 @@ def check_auth_httpba():
def login(username, password, **kwargs):
auth_args = {'auth_type': config.get("authentication", "method"),
- 'username': username,
- 'password': password}
+ 'username': username.encode('utf-8'),
+ 'password': password.encode('utf-8')}
user = User.get(auth_args)
if not user:
--
2.7.4
8 years, 1 month
[PATCH v4][Kimchi] Issue: #1008 Issues while editing a VEPA network
by Ramon Medeiros
The list of interfaces was being appended to a non-clean list. Just
create it and add the results.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
Changes:
v4:
List all unused interfaces when editing a vepa network. User now can add new
interfaces while editting
v3:
Only list interfaces that are not being used when creating VEPA interface
v2:
Create empty result var
ui/js/src/kimchi.api.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 55fd55f..3dccfe9 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -693,7 +693,7 @@ var kimchi = {
getVEPAInterfaces : function(suc, err) {
wok.requestJSON({
- url : 'plugins/kimchi/interfaces?module=^(?!mlx5_core|mlx5-core).*$',
+ url : 'plugins/kimchi/interfaces?_inuse=false&module=^(?!mlx5_core|mlx5-core).*$',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
--
2.7.4
8 years, 1 month
[PATCH v2] [Kimchi 0/2] Issue #998 Not all static strings are externalized
by pkulkark@linux.vnet.ibm.com
From: Pooja Kulkarni <pkulkark(a)linux.vnet.ibm.com>
v2:
Rebased to latest master
v1:
This patch set externalizes all the
static string that should be externalized
to support globalization. Also contains
the updated .pot and .po files
Pooja Kulkarni (2):
Issue #998 Not all static strings are externalized
Issue #998 Updated .pot and .po files
po/POTFILES.in | 1 +
po/de_DE.po | 286 +++++++++++++++++++++++++++-
po/en_US.po | 267 ++++++++++++++++++++++++++-
po/es_ES.po | 286 +++++++++++++++++++++++++++-
po/fr_FR.po | 286 +++++++++++++++++++++++++++-
po/it_IT.po | 287 ++++++++++++++++++++++++++++-
po/ja_JP.po | 286 +++++++++++++++++++++++++++-
po/kimchi.pot | 267 ++++++++++++++++++++++++++-
po/ko_KR.po | 284 +++++++++++++++++++++++++++-
po/pt_BR.po | 286 +++++++++++++++++++++++++++-
po/ru_RU.po | 286 +++++++++++++++++++++++++++-
po/zh_CN.po | 284 +++++++++++++++++++++++++++-
po/zh_TW.po | 284 +++++++++++++++++++++++++++-
ui/js/src/kimchi.guest_storage_add.main.js | 12 +-
ui/js/src/kimchi.storagepool_add_main.js | 12 +-
ui/pages/guest-edit.html.tmpl | 14 +-
ui/pages/i18n.json.tmpl | 18 ++
17 files changed, 3307 insertions(+), 139 deletions(-)
--
2.1.0
8 years, 1 month
[PATCH v3][Kimchi] Issue: #1008 Issues while editing a VEPA network
by Ramon Medeiros
The list of interfaces was being appended to a non-clean list. Just
create it and add the results.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
Changes:
v3:
Only list interfaces that are not being used when creating VEPA interface
v2:
Create empty result var
ui/js/src/kimchi.api.js | 2 +-
ui/js/src/kimchi.network_edit_main.js | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 55fd55f..3dccfe9 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -693,7 +693,7 @@ var kimchi = {
getVEPAInterfaces : function(suc, err) {
wok.requestJSON({
- url : 'plugins/kimchi/interfaces?module=^(?!mlx5_core|mlx5-core).*$',
+ url : 'plugins/kimchi/interfaces?_inuse=false&module=^(?!mlx5_core|mlx5-core).*$',
type : 'GET',
contentType : 'application/json',
dataType : 'json',
diff --git a/ui/js/src/kimchi.network_edit_main.js b/ui/js/src/kimchi.network_edit_main.js
index 4dd830a..21f4c45 100644
--- a/ui/js/src/kimchi.network_edit_main.js
+++ b/ui/js/src/kimchi.network_edit_main.js
@@ -94,12 +94,13 @@ kimchi.setupNetworkFormEventForEdit = function(network) {
var loadIfaces = function(interfaceFilterArray){
var buildInterfaceOpts = function(result) {
var currentIfaces = network['interfaces'];
+ ifaces = [];
for (var i = 0; i < currentIfaces.length; i++) {
kimchi.getInterface(currentIfaces[i], function(iface) {
- result.push(iface);
+ ifaces.push(iface);
} , null, true);
}
- kimchi.createInterfacesOpts(result, interfaceFilterArray);
+ kimchi.createInterfacesOpts(ifaces, interfaceFilterArray);
for (var i = 0; i < currentIfaces.length; i++) {
$("#networkDestinationID option[value='" + currentIfaces[i] + "']").attr('selected','selected');
--
2.7.4
8 years, 1 month
[PATCH] [Wok] Added util method for formatting timestamp as per locale.
by pkulkark@linux.vnet.ibm.com
From: Pooja Kulkarni <pkulkark(a)linux.vnet.ibm.com>
Signed-off-by: Pooja Kulkarni <pkulkark(a)linux.vnet.ibm.com>
---
ui/js/src/wok.utils.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/ui/js/src/wok.utils.js b/ui/js/src/wok.utils.js
index dcec823..121a51f 100644
--- a/ui/js/src/wok.utils.js
+++ b/ui/js/src/wok.utils.js
@@ -258,6 +258,13 @@ wok.numberLocaleConverter = function numberConverter(number, locale){
return number;
}
+wok.timestampConverter = function timestampconverter(timestamp, locale){
+ var dte = new Date(timestamp)
+ var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric',
+ minute: 'numeric', second: 'numeric', timeZoneName: 'short'};
+ return dte.toLocaleString(locale, options);
+}
+
wok.localeConverters = {
"date-locale-converter": {
to: function(date){
--
2.1.0
8 years, 1 month
[PATCH] [Wok] Fix Ginger Base issue #122: Get immediate children while looking for selected options
by Aline Manera
There would be more than one list in the same page, so looking for all
the selected options may cause problems.
Fix that to only get the immediate children of the list widget.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
ui/js/src/wok.list.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/js/src/wok.list.js b/ui/js/src/wok.list.js
index 1d4e526..a92db19 100644
--- a/ui/js/src/wok.list.js
+++ b/ui/js/src/wok.list.js
@@ -173,7 +173,7 @@ wok.widget.List.prototype = (function() {
},function(event) {
var grid = event.data.grid;
grid.selectedIndex = [];
- $("li :checkbox:checked", this.bodyContainer).map(function() {
+ $("li > :checkbox:checked", this.bodyContainer).map(function() {
return $(this).parent().index();
}).each(function() {
grid.selectedIndex.push(this);
--
2.7.4
8 years, 1 month
[PATCH v2][Kimchi] Issue: #1008 Issues while editing a VEPA network
by Ramon Medeiros
The list of interfaces was being appended to a non-clean list. Just
create it and add the results.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
Changes:
v2:
Create empty result var
ui/js/src/kimchi.network_edit_main.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.network_edit_main.js b/ui/js/src/kimchi.network_edit_main.js
index 4dd830a..21f4c45 100644
--- a/ui/js/src/kimchi.network_edit_main.js
+++ b/ui/js/src/kimchi.network_edit_main.js
@@ -94,12 +94,13 @@ kimchi.setupNetworkFormEventForEdit = function(network) {
var loadIfaces = function(interfaceFilterArray){
var buildInterfaceOpts = function(result) {
var currentIfaces = network['interfaces'];
+ ifaces = [];
for (var i = 0; i < currentIfaces.length; i++) {
kimchi.getInterface(currentIfaces[i], function(iface) {
- result.push(iface);
+ ifaces.push(iface);
} , null, true);
}
- kimchi.createInterfacesOpts(result, interfaceFilterArray);
+ kimchi.createInterfacesOpts(ifaces, interfaceFilterArray);
for (var i = 0; i < currentIfaces.length; i++) {
$("#networkDestinationID option[value='" + currentIfaces[i] + "']").attr('selected','selected');
--
2.7.4
8 years, 1 month
[PATCH] [Kimchi] USB xhci hotplug: Check controller, define in template, add test in Power
by Lucio Correia
- Today it is not possible to hotplug a PCI in Power Systems without an
USB xhci controller existing in the VM. This commit checks if there
is such controller in the VM, displaying an error message if not.
- When creating VMs using Kimchi in a Power System, the USB xhci
controller is defined by default to have PCI hotplug support.
- From now on all templates are created with xhci usb controller, so a
hotplug must be performed flawlessly. If anything wrong the test case
will fail.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
i18n.py | 1 +
model/vmhostdevs.py | 34 ++++++++++++++++++++++++++++++++++
tests/test_model.py | 25 +++++++++++++++++++++++++
vmtemplate.py | 17 +++++++++++++++++
4 files changed, 77 insertions(+)
diff --git a/i18n.py b/i18n.py
index 82c679b..159021d 100644
--- a/i18n.py
+++ b/i18n.py
@@ -150,6 +150,7 @@ messages = {
"KCHVMHDEV0005E": _('The device %(name)s is probably in use by the host. Unable to attach it to the guest.'),
"KCHVMHDEV0006E": _('Hot-(un)plug of device %(name)s is not supported.'),
"KCHVMHDEV0007E": _('Failed to attach %(device)s to %(vm)s'),
+ "KCHVMHDEV0008E": _('VM %(vmid)s does not have an USB XHCI controller to accept PCI hotplug.'),
"KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"),
"KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"),
diff --git a/model/vmhostdevs.py b/model/vmhostdevs.py
index e289f03..edb6e36 100644
--- a/model/vmhostdevs.py
+++ b/model/vmhostdevs.py
@@ -43,6 +43,9 @@ from wok.plugins.kimchi.xmlutils.qemucmdline import QEMU_NAMESPACE
CMDLINE_FIELD_NAME = 'spapr-pci-host-bridge.mem_win_size'
+USB_MODELS_PCI_HOTPLUG = ["piix3-uhci", "piix4-uhci", "ehci", "ich9-ehci1",
+ "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
+ "vt82c686b-uhci", "pci-ohci", "nec-xhci"]
WINDOW_SIZE_BAR = 0x800000000
@@ -135,6 +138,28 @@ class VMHostDevsModel(object):
return '<devices>%s</devices>' % hostdevs
+ def have_xhci_usb_controller(self, vmid):
+ dom = VMModel.get_vm(vmid, self.conn)
+
+ root = objectify.fromstring(dom.XMLDesc(0))
+
+ try:
+ controllers = root.devices.controller
+
+ except AttributeError:
+ return False
+
+ for controller in controllers:
+
+ if 'model' not in controller.attrib:
+ continue
+
+ if controller.attrib['type'] == 'usb' and \
+ controller.attrib['model'] in USB_MODELS_PCI_HOTPLUG:
+ return True
+
+ return False
+
def _get_pci_device_xml(self, dev_info, slot, is_multifunction):
if 'detach_driver' not in dev_info:
dev_info['detach_driver'] = 'kvm'
@@ -234,6 +259,15 @@ class VMHostDevsModel(object):
dom = VMModel.get_vm(vmid, self.conn)
driver = 'vfio' if self.caps.kernel_vfio else 'kvm'
+ # 'vfio' systems requires a xhci usb controller in order to support
+ # pci hotplug on Power.
+ if driver == 'vfio' and platform.machine().startswith('ppc') and \
+ DOM_STATE_MAP[dom.info()[0]] != "shutoff" and \
+ not self.have_xhci_usb_controller(vmid):
+ msg = WokMessage('KCHVMHDEV0008E', {'vmid': vmid})
+ cb(msg.get_text(), False)
+ raise InvalidOperation("KCHVMHDEV0008E", {'vmid': vmid})
+
# Attach all PCI devices in the same IOMMU group
affected_names = self.devs_model.get_list(
_passthrough_affected_by=dev_info['name'])
diff --git a/tests/test_model.py b/tests/test_model.py
index 082cb9d..4ddd0d2 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -1626,6 +1626,31 @@ class ModelTests(unittest.TestCase):
volumes = inst.storagevolumes_get_list(args['name'])
self.assertEquals(len(volumes), 2)
+ def _host_is_power():
+ import platform
+ return platform.machine().startswith('ppc')
+
+ @unittest.skipUnless(_host_is_power(), 'Only required for Power hosts')
+ def test_pci_hotplug_requires_xhci_usb_controller(self):
+ config.set("authentication", "method", "pam")
+ inst = model.Model(None, objstore_loc=self.tmp_store)
+ tpl_params = {'name': 'test', 'memory': 1024, 'cdrom': UBUNTU_ISO}
+ inst.templates_create(tpl_params)
+
+ with RollbackContext() as rollback:
+ vm_params = {'name': 'kimchi-vm1', 'template': '/templates/test'}
+ task1 = inst.vms_create(vm_params)
+ inst.task_wait(task1['id'])
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_delete,
+ 'kimchi-vm1')
+ # Start vm
+ inst.vm_start('kimchi-vm1')
+ rollback.prependDefer(utils.rollback_wrapper, inst.vm_poweroff,
+ 'kimchi-vm1')
+ # check if create VM has USB XHCI controller
+ self.assertTrue(
+ inst.vmhostdevs_have_xhci_usb_controller('kimchi-vm1'))
+
class BaseModelTests(unittest.TestCase):
class FoosModel(object):
diff --git a/vmtemplate.py b/vmtemplate.py
index 0288330..56b339f 100644
--- a/vmtemplate.py
+++ b/vmtemplate.py
@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
+import platform
import stat
import time
import urlparse
@@ -358,6 +359,18 @@ class VMTemplate(object):
self.info['os_version'])
return unicode(interfaces, 'utf-8')
+ def _get_usb_controller(self):
+ # powerkvm systems must include xhci controller model
+ if not platform.machine().startswith('ppc'):
+ return ''
+
+ return """
+ <controller type='usb' index='0' model='nec-xhci'>
+ <address type='pci' domain='0x0000'
+ bus='0x00' slot='0x0f' function='0x0'/>
+ </controller>
+ """
+
def _get_input_output_xml(self):
sound = """
<sound model='%(sound_model)s' />
@@ -469,6 +482,9 @@ class VMTemplate(object):
# cpu_info element
params['cpu_info_xml'] = self._get_cpu_xml()
+ # usb controller xhci
+ params['usb_controller'] = self._get_usb_controller()
+
xml = """
<domain type='%(domain)s'>
%(qemu-stream-cmdline)s
@@ -503,6 +519,7 @@ class VMTemplate(object):
%(interfaces)s
%(graphics)s
%(input_output)s
+ %(usb_controller)s
%(serial)s
<memballoon model='virtio' />
</devices>
--
2.7.4
8 years, 1 month