[PATCH 0/3] VM suspend/resume
by Crístian Viana
Crístian Viana (3):
Optimize VM update function
Update some VM state conditions
Add support for VM suspend and resume
src/kimchi/control/vms.py | 2 ++
src/kimchi/i18n.py | 4 ++++
src/kimchi/model/vms.py | 47 ++++++++++++++++++++++++++++++++++++++++++++---
tests/test_model.py | 20 ++++++++++++++++++++
tests/test_rest.py | 28 ++++++++++++++++++++++++++++
5 files changed, 98 insertions(+), 3 deletions(-)
--
2.1.0
9 years, 11 months
[PATCH] Change systemd KillMode to avoid kill Yum process
by Rodrigo Trujillo
Kimchi has a problem when updating itself. Kimchid is restarted and all
children are killed, including Yum. When that happens, the updates are
not finished properly and the system ends up in an inconsistent state.
This patch changes the Systemd KillMode to "process", so, child
processes will remain in the system, letting yum finishes all
transactions in background, while kimchi restarts correctly.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
contrib/kimchi.spec.fedora.in | 6 ++++--
contrib/kimchid.service.fedora | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 92d3e49..4236641 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -109,10 +109,12 @@ install -Dm 0755 contrib/kimchid.sysvinit %{buildroot}%{_initrddir}/kimchid
%post
if [ $1 -eq 1 ] ; then
/bin/systemctl enable kimchid.service >/dev/null 2>&1 || :
- # Initial installation
- /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
+# Reload systemd in initial install and in update, because kimchid.service
+# may have been changed
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+
%preun
diff --git a/contrib/kimchid.service.fedora b/contrib/kimchid.service.fedora
index 7abe49b..92b8d86 100644
--- a/contrib/kimchid.service.fedora
+++ b/contrib/kimchid.service.fedora
@@ -6,7 +6,7 @@ After=libvirtd.service
[Service]
Type=simple
ExecStart=/usr/bin/kimchid
-ExecStop=/bin/kill -TERM $MAINPID
+KillMode=process
EnvironmentFile=/etc/kimchi/kimchi.conf
[Install]
--
1.9.3
9 years, 11 months
[PATCH] Supports Kimchi on LE systems
by Ramon Medeiros
On LE systems, some changes on libvirt xml is needed. The input device
for keyboard is not kbd anymore, the architecture is still ppc64 and the
qemu binary is not qemu-kvm as in the other archs.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/config.py.in | 11 +++++++++--
src/kimchi/osinfo.py | 6 +++++-
src/kimchi/vmtemplate.py | 8 ++++++++
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index 83a5dd0..f0089dc 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -68,12 +68,19 @@ def find_qemu_binary(find_emulator=False):
raise Exception("Unable to get qemu binary location: %s" % e)
try:
xml = connect.getCapabilities()
+
+ # ISSUE #573: On POWER8 debian little endian, the qemu binary is
+ # qemu-system-ppc64, not qemu-system-ppc64el as expected
+ arch = platform.machine()
+ if platform.machine() == "ppc64le":
+ arch = "ppc64"
+
if find_emulator:
expr = "/capabilities/guest/arch[@name='%s']\
- /emulator" % platform.machine()
+ /emulator" % arch
else:
expr = "/capabilities/guest/arch[@name='%s']\
- /domain[@type='kvm']/emulator" % platform.machine()
+ /domain[@type='kvm']/emulator" % arch
res = xpath_get_text(xml, expr)
location = res[0]
except Exception, e:
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index 0e16b50..2f6558d 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -29,7 +29,7 @@ from kimchi.config import paths
SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'),
- 'power': ('ppc', 'ppc64')}
+ 'power': ('ppc', 'ppc64', 'ppc64le')}
common_spec = {'cpus': 1, 'memory': 1024, 'disks': [{'index': 0, 'size': 10}],
@@ -94,6 +94,10 @@ def lookup(distro, version):
params['os_version'] = version
arch = _get_arch()
+ # ppc64le hack: qemu ppc64le uses ppc64 in libvirt xml
+ if params["arch"] == "ppc64le":
+ params["arch"] = "ppc64"
+
if distro in modern_version_bases[arch]:
if LooseVersion(version) >= LooseVersion(
modern_version_bases[arch][distro]):
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index e41a959..a017874 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -245,9 +245,17 @@ class VMTemplate(object):
mouse = """
<input type='mouse' bus='%(mouse_bus)s'/>
"""
+
keyboard = """
<input type='kbd' bus='%(kbd_bus)s'> </input>
"""
+
+ # PPC64EL does not uses kbd
+ if os.uname()[4] == "ppc64le":
+ keyboard = """
+ <input type='keyboard' bus='%(kbd_bus)s'> </input>
+ """
+
tablet = """
<input type='tablet' bus='%(kbd_bus)s'> </input>
"""
--
1.8.3.1
9 years, 11 months
[kimchi-devel][PATCH 0/7] Multiple instances of file handler leak fix
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
File handler leak can be tested with following scripts against real model
kimchi server,
run "lsof -p $(kimchidpid)" and you can see many file opened without close.
import base64
import json
import os
import unittest
import time
from functools import partial
from utils import request
host = None
ssl_port = None
def setUpModule():
global host, ssl_port
host = '127.0.0.1'
ssl_port = 8001
class RestTests(unittest.TestCase):
def setUp(self):
self.request = partial(request, host, ssl_port)
def test_leak(self):
def fake_auth_header():
headers = {'Accept': 'application/json'}
user, pw = ('my_username', 'my_passwd')
hdr = "Basic " + base64.b64encode("%s:%s" % (user, pw))
headers['AUTHORIZATION'] = hdr
return headers
def do_thousands(url):
for i in range(1000):
self.request(url, headers=fake_auth_header())
print "called %i times" % i
url = "https://%s:%s/toys" % \
(host, ssl_port)
do_thousands(url)
Royce Lv (7):
Fix md5 file handler leak
Fix file handler leak for uptime file
Close json schema file after loading
close fh after iso scanning
Fix leak in check_url_path
Work around eventfd leak using multiprocessing
Fix file handler leak in netinfo.py
src/kimchi/auth.py | 65 +++++++++++++++++++++++-----------------
src/kimchi/isoinfo.py | 5 ++--
src/kimchi/model/debugreports.py | 5 ++--
src/kimchi/model/host.py | 5 ++--
src/kimchi/netinfo.py | 16 ++++++----
src/kimchi/root.py | 4 +--
src/kimchi/utils.py | 4 ++-
7 files changed, 61 insertions(+), 43 deletions(-)
--
1.9.3
9 years, 11 months
[PATCH] Bugfix: Template disk allocation changed back to default(10G)
by Wen Wang
Keep the changed value until save option has been chosen.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_edit_main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 1149541..f809223 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -102,7 +102,7 @@ kimchi.template_edit_main = function() {
if (tempType === 'iscsi' || tempType === 'scsi') {
$('.template-storage-disk', selectedItem).attr('readonly', true).val(scsiCap);
} else {
- $('.template-storage-disk', selectedItem).attr('readonly', false).val('10');
+ $('.template-storage-disk', selectedItem).attr('readonly', false);
}
$('.template-storage-name').val(tempStorageNameFull);
});
--
2.1.0
9 years, 11 months
[PATCH] Allow -v to be passed through in run_tests.sh
by Julien Goodwin
Another trivial one, just making it slightly easier to debug tests.
Julien Goodwin (1):
Allow -v to be passed through in run_tests.sh
tests/run_tests.sh.in | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
--
2.1.4
9 years, 11 months
[PATCH] Issue #526 (partial)
by Crístian Viana
This patch partially fixes the issue #526. There's still a known bug which
happens when the user reverts a VM to a snapshot when the VM's name has been
changed since the snapshot was taken. In other words, the following behavior
will still cause a bug:
- Create a VM named "foo".
- Create a snapshot of VM "foo" named "snap1".
- Rename VM "foo" to "bar".
- Revert VM "bar" to snapshot "snap1".
The last step works correctly under the hood (i.e. the VM is reverted to that
snapshot) but Kimchi cannot return from its REST request because the VM
changed its name during the revert action.
Zongmei Gou will send another patch which fixes the bug described above as the
patch is already done.
Crístian Viana (1):
issue #526: Support updating name for VMs with snapshots
src/kimchi/model/vms.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++--
tests/test_model.py | 3 +++
2 files changed, 57 insertions(+), 2 deletions(-)
--
2.1.0
9 years, 11 months
[PATCH] Re: Solve the snapshot revert problem, relate to issue #526
by gouzongmei@163.com
From: Zongmei Gou <gouzongmei(a)ourfuture.cn>
Hi Aline,
This is the right patch I sent to Kimchi ML.
In fact I added you to CC list every time, but I have no idea why you can't
receive my patch sometimes. So I use this email this time.
---
src/kimchi/control/base.py | 14 +++++++++++---
src/kimchi/model/vmsnapshots.py | 6 ++++++
tests/test_model.py | 12 ++++++++++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index 97e789f..484e9b9 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -57,10 +57,18 @@ class Resource(object):
self.role_key = None
self.admin_methods = []
- def _redirect(self, ident, code=303):
- if ident is not None and ident != self.ident:
+ def _redirect(self, action_result, code=303):
+ if isinstance(action_result, list):
+ uri_params = []
+ for arg in action_result:
+ if arg is None:
+ arg = ''
+ uri_params.append(urllib2.quote(arg.encode('utf-8'), safe=""))
+ raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
+ elif action_result is not None and action_result != self.ident:
uri_params = list(self.model_args[:-1])
- uri_params += [urllib2.quote(ident.encode('utf-8'), safe="")]
+ uri_params += [urllib2.quote(action_result.encode('utf-8'),
+ safe="")]
raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
def generate_action_handler(self, action_name, action_args=None):
diff --git a/src/kimchi/model/vmsnapshots.py b/src/kimchi/model/vmsnapshots.py
index 725770d..0c5b601 100644
--- a/src/kimchi/model/vmsnapshots.py
+++ b/src/kimchi/model/vmsnapshots.py
@@ -29,6 +29,7 @@ from kimchi.model.tasks import TaskModel
from kimchi.model.vms import DOM_STATE_MAP, VMModel
from kimchi.model.vmstorages import VMStorageModel, VMStoragesModel
from kimchi.utils import add_task
+from kimchi.xmlutils.utils import xpath_get_text
class VMSnapshotsModel(object):
@@ -156,6 +157,11 @@ class VMSnapshotModel(object):
vir_dom = VMModel.get_vm(vm_name, self.conn)
vir_snap = self.get_vmsnapshot(vm_name, name)
vir_dom.revertToSnapshot(vir_snap, 0)
+
+ # get vm name recorded in the snapshot and return new uri params
+ vm_new_name = xpath_get_text(vir_snap.getXMLDesc(0),
+ 'domain/name')[0]
+ return [vm_new_name, name]
except libvirt.libvirtError, e:
raise OperationFailed('KCHSNAP0009E', {'name': name,
'vm': vm_name,
diff --git a/tests/test_model.py b/tests/test_model.py
index c956007..b9d71cf 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -176,8 +176,16 @@ class ModelTests(unittest.TestCase):
current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm')
self.assertEquals(snap, current_snap)
- snap = inst.vmsnapshot_lookup(u'kimchi-vm', params['name'])
- inst.vmsnapshot_revert(u'kimchi-vm', params['name'])
+ # update vm name
+ inst.vm_update('kimchi-vm', {'name': u'kimchi-vm-new'})
+
+ # Look up the first created snapshot from the renamed vm
+ snap = inst.vmsnapshot_lookup(u'kimchi-vm-new', params['name'])
+
+ # snapshot revert to the first created vm
+ result = inst.vmsnapshot_revert(u'kimchi-vm-new', params['name'])
+ self.assertEquals(result, [u'kimchi-vm', snap['name']])
+
vm = inst.vm_lookup(u'kimchi-vm')
self.assertEquals(vm['state'], snap['state'])
--
1.8.3.1
9 years, 11 months
[PATCH] Disable static path checking by cherrypy
by Christy Perez
CherryPy has a checker module that runs certain tests for resources.
One such test is for static paths, in which is tests all resources
using a non-existent html file. Since Kimchi is not a static web app,
this check can be safely disregarded.
The motivation behind this change is the following scenario:
The need to treat a certain flavor of a resource differently takes
advantage of the base model passed to the control's init function.
When calling the base model function to retreive the desired property,
an exception is thrown because the underlying resource doesn't exist.
This brings to light that any use of the base model from the init
of any control object will result in the same checker issue.
To easily test this issue:
- Add the following line to the __init__ function in control/vms.py:
model.vm_lookup(self.ident.decode('utf-8'))
- Run the rest tests: $ sudo ./run_tests.sh test_rest.RestTests
See: cherrypy._cpchecker
Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
---
src/kimchi/config.py.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index 83a5dd0..86ca862 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -23,10 +23,9 @@ import os
import platform
import threading
-
+from cherrypy import checker
from ConfigParser import SafeConfigParser
-
from kimchi.xmlutils.utils import xpath_get_text
__version__ = "@kimchiversion@"
@@ -40,7 +39,6 @@ kimchiLock = threading.Lock()
# Storage pool constant for read-only pool types
READONLY_POOL_TYPE = ['iscsi', 'scsi', 'mpath']
-
def get_object_store():
return os.path.join(paths.state_dir, 'objectstore')
@@ -182,6 +180,8 @@ class UIConfig(dict):
class KimchiConfig(dict):
# session time out is 10 minutes
SESSIONSTIMEOUT = 10
+ global checker
+ checker.check_static_paths = False
kimchi_config = {
'/': {
--
1.9.3
9 years, 11 months
[PATCH] Re: Solve the snapshot revert problem, relate to issue #526
by gouzongmei@ourfuture.cn
From: Zongmei Gou <gouzongmei(a)ourfuture.cn>
Hi, Cristian
Thanks for your time on this, I've modified my patch according to your opinion,
some problems may still exist.
1. The 'revert' function need return vm name recorded in the snapshot xml, not the snapshot
name, so the "vir_snap.getName()" won't help.
2. Test case for vmsnapshot revert has been added to 'test_vm_lifecycle', and
no duplicate cases exist now.
3. AFAIK, libvirt's Test driver does not support the function "virDomainListAllSnapshots",
which cause 'test_edit_vm' failed in test_rest.py(once test our patch together), so if
I catch this error(like 'delete' function on line 800 in vms.py), this case will pass.
4. For "test_rest", the snapshot revert function in mockmodel.py is different with the real model,
which causes the response status different. So I just kept it, and all related test cases passed
by now in my environment.
Any suggestion about this issue is welcome, especially for 4,
because I'm still a little confused with it.
Thanks
---
src/kimchi/control/base.py | 14 +++++++++++---
src/kimchi/model/vmsnapshots.py | 6 ++++++
tests/test_model.py | 12 ++++++++++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index 97e789f..484e9b9 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -57,10 +57,18 @@ class Resource(object):
self.role_key = None
self.admin_methods = []
- def _redirect(self, ident, code=303):
- if ident is not None and ident != self.ident:
+ def _redirect(self, action_result, code=303):
+ if isinstance(action_result, list):
+ uri_params = []
+ for arg in action_result:
+ if arg is None:
+ arg = ''
+ uri_params.append(urllib2.quote(arg.encode('utf-8'), safe=""))
+ raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
+ elif action_result is not None and action_result != self.ident:
uri_params = list(self.model_args[:-1])
- uri_params += [urllib2.quote(ident.encode('utf-8'), safe="")]
+ uri_params += [urllib2.quote(action_result.encode('utf-8'),
+ safe="")]
raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
def generate_action_handler(self, action_name, action_args=None):
diff --git a/src/kimchi/model/vmsnapshots.py b/src/kimchi/model/vmsnapshots.py
index 725770d..0c5b601 100644
--- a/src/kimchi/model/vmsnapshots.py
+++ b/src/kimchi/model/vmsnapshots.py
@@ -29,6 +29,7 @@ from kimchi.model.tasks import TaskModel
from kimchi.model.vms import DOM_STATE_MAP, VMModel
from kimchi.model.vmstorages import VMStorageModel, VMStoragesModel
from kimchi.utils import add_task
+from kimchi.xmlutils.utils import xpath_get_text
class VMSnapshotsModel(object):
@@ -156,6 +157,11 @@ class VMSnapshotModel(object):
vir_dom = VMModel.get_vm(vm_name, self.conn)
vir_snap = self.get_vmsnapshot(vm_name, name)
vir_dom.revertToSnapshot(vir_snap, 0)
+
+ # get vm name recorded in the snapshot and return new uri params
+ vm_new_name = xpath_get_text(vir_snap.getXMLDesc(0),
+ 'domain/name')[0]
+ return [vm_new_name, name]
except libvirt.libvirtError, e:
raise OperationFailed('KCHSNAP0009E', {'name': name,
'vm': vm_name,
diff --git a/tests/test_model.py b/tests/test_model.py
index c956007..b9d71cf 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -176,8 +176,16 @@ class ModelTests(unittest.TestCase):
current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm')
self.assertEquals(snap, current_snap)
- snap = inst.vmsnapshot_lookup(u'kimchi-vm', params['name'])
- inst.vmsnapshot_revert(u'kimchi-vm', params['name'])
+ # update vm name
+ inst.vm_update('kimchi-vm', {'name': u'kimchi-vm-new'})
+
+ # Look up the first created snapshot from the renamed vm
+ snap = inst.vmsnapshot_lookup(u'kimchi-vm-new', params['name'])
+
+ # snapshot revert to the first created vm
+ result = inst.vmsnapshot_revert(u'kimchi-vm-new', params['name'])
+ self.assertEquals(result, [u'kimchi-vm', snap['name']])
+
vm = inst.vm_lookup(u'kimchi-vm')
self.assertEquals(vm['state'], snap['state'])
--
1.8.3.1
9 years, 11 months