[PATCH V10 2/7] add method to test libvirt metadata api are available
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
same mechanism with other feature tests.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/featuretests.py | 31 +++++++++++++++++++++++++++++++
src/kimchi/model/config.py | 2 ++
2 files changed, 33 insertions(+)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
index b1001ea..5192361 100644
--- a/src/kimchi/featuretests.py
+++ b/src/kimchi/featuretests.py
@@ -28,6 +28,7 @@ import threading
from lxml.builder import E
+from kimchi.rollbackcontext import RollbackContext
from kimchi.utils import kimchi_log
@@ -53,6 +54,16 @@ ISO_STREAM_XML = """
</devices>
</domain>"""
+SIMPLE_VM_XML = """
+<domain type='kvm'>
+ <name>A_SIMPLE_VM</name>
+ <memory unit='KiB'>10240</memory>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+</domain>"""
+
SCSI_FC_XML = """
<pool type='scsi'>
<name>TEST_SCSI_FC_POOL</name>
@@ -175,3 +186,23 @@ class FeatureTests(object):
pool is None or pool.undefine()
conn is None or conn.close()
return True
+
+ @staticmethod
+ def has_metadata_support():
+ KIMCHI_META_URL = "https://github.com/kimchi-project/kimchi/"
+ KIMCHI_NAMESPACE = "kimchi"
+ with RollbackContext() as rollback:
+ FeatureTests.disable_screen_error_logging()
+ rollback.prependDefer(FeatureTests.enable_screen_error_logging)
+ conn = libvirt.open('qemu:///system')
+ rollback.prependDefer(conn.close)
+ dom = conn.defineXML(SIMPLE_VM_XML)
+ rollback.prependDefer(dom.undefine)
+ try:
+ dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT,
+ "<metatest/>", KIMCHI_NAMESPACE,
+ KIMCHI_META_URL,
+ flags=libvirt.VIR_DOMAIN_AFFECT_CURRENT)
+ return True
+ except libvirt.libvirtError:
+ return False
diff --git a/src/kimchi/model/config.py b/src/kimchi/model/config.py
index c9e3e9d..0ef0855 100644
--- a/src/kimchi/model/config.py
+++ b/src/kimchi/model/config.py
@@ -53,6 +53,7 @@ class CapabilitiesModel(object):
self.qemu_stream_dns = False
self.libvirt_stream_protocols = []
self.fc_host_support = False
+ self.metadata_support = False
# Subscribe function to set host capabilities to be run when cherrypy
# server is up
@@ -65,6 +66,7 @@ class CapabilitiesModel(object):
self.qemu_stream_dns = FeatureTests.qemu_iso_stream_dns()
self.nfs_target_probe = FeatureTests.libvirt_support_nfs_probe()
self.fc_host_support = FeatureTests.libvirt_support_fc_host()
+ self.metadata_support = FeatureTests.has_metadata_support()
self.libvirt_stream_protocols = []
for p in ['http', 'https', 'ftp', 'ftps', 'tftp']:
--
1.9.0
10 years, 5 months
[PATCH V10 1/7] bug fix: call a method should be followed by "()"
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
it should be:
FeatureTests.enable_screen_error_logging()
instead of:
FeatureTests.enable_screen_error_logging
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/featuretests.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py
index 07d5676..b1001ea 100644
--- a/src/kimchi/featuretests.py
+++ b/src/kimchi/featuretests.py
@@ -171,7 +171,7 @@ class FeatureTests(object):
# Libvirt requires adapter name, not needed when supports to FC
return False
finally:
- FeatureTests.enable_screen_error_logging
+ FeatureTests.enable_screen_error_logging()
pool is None or pool.undefine()
conn is None or conn.close()
return True
--
1.9.0
10 years, 5 months
[PATCH V9 0/7] bug fix: get user and group when VM is running
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V8 -> V9
move meta feature test to src/kimchi/model/config.py
use ElementMaker to construct a metanode.
V7 -> V8
add a feature test to probe libvirt support metadata.
add namespace for manully metadata.
V6 -> V7:
After V6 rebase, still find one error code "KCHVM0029E" does not change.
V5 -> V6:
rebase
V4 -> V5:
it is wrong to call dom.isPersistent in V4, fix it.
V3 -> V4:
work around if libvirt do not support metadata API well.
V2 -> V3:
move the virDomain.metadata and virDomain.setMetadata to model/utils.py
add testcase
V1 -> V2:
libvirt also support virDomain.metadata and virDomain.setMetadata two api.
use virDomain.metadata to get the user and group.
use virDomain.setMetadata to set the user and group.
ShaoHe Feng (7):
bug fix: call a method should be followed by "()"
add method to test libvirt metadata api are available
Add two function to set and get domain xml metadata
manually manage the metadata element
bug fix: get user and group when vm is living.
update test case to set/get user and group when VM is running
write the template OS info to vm metadata
src/kimchi/featuretests.py | 33 ++++++++++++-
src/kimchi/i18n.py | 1 +
src/kimchi/model/config.py | 2 +
src/kimchi/model/utils.py | 103 +++++++++++++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 113 +++++++++++++++++++++++++++------------------
tests/test_model.py | 13 ++++++
6 files changed, 220 insertions(+), 45 deletions(-)
--
1.9.0
10 years, 5 months
[PATCH 0/4] Host PCI Device Pass Through
by Zhou Zheng Sheng
Hi,
This patch series is to enable Kimchi to assign host PCI devices
directly to a VM, thus greately improve VM performance. For example,
pass through a NIC to VM to improve guest network throughput, or pass
through a video card to VM to enable the guest OS to run 3D video
games.
Firstly, the user should be able to list all host devices in a tree, so
as to determine which PCI devices should be passed through. Once a PCI
device is assigned to VM, all the sub-device connected to it would be
also assigned to VM. The device listing and device tree formatting is
implemented in the patch "list all types of host devices" and "list all
host devices in a tree".
Secondly, the user should be able to pass the names of the host PCI
devices to a VM template. Then the user can create a VM from the
template, and the PCI devices would be automatically assigned to the VM
when it starts, and automatically released when the VM is powered off.
This is implemented in the patch "pass through PCI device to VM".
The author also fixed a bug in VM template during the test. The fix is
in patch "add disk size error message".
All the patches are for back-end. The detailed implementation and
testing method are written in the patch commit messages.
Zhou Zheng Sheng (4):
VM template: add disk size error message
host pci pass through: list all types of host devices
host pci pass through: list all host devices in a tree
host pci pass through: pass through PCI device to VM
docs/API.md | 18 +-
src/kimchi/API.json | 24 ++-
src/kimchi/control/host.py | 21 +++
src/kimchi/control/templates.py | 5 +-
src/kimchi/featuretests.py | 9 +
src/kimchi/hostdev.py | 307 +++++++++++++++++++++++++++++++++
src/kimchi/i18n.py | 14 ++
src/kimchi/mockmodel.py | 7 +-
src/kimchi/model/config.py | 2 +
src/kimchi/model/host.py | 15 +-
src/kimchi/model/libvirtstoragepool.py | 18 +-
src/kimchi/model/templates.py | 58 +++++++
src/kimchi/vmtemplate.py | 43 +++++
tests/test_rest.py | 6 +-
tests/test_storagepool.py | 7 +-
15 files changed, 512 insertions(+), 42 deletions(-)
create mode 100644 src/kimchi/hostdev.py
--
1.9.0
10 years, 5 months
[PATCHv3 0/7] Attach guest disks
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
This patch need to be changed with Shaohe's metadata patch,
and cannot be merged directly.As metadata patch cannot pass all tests.
v1>v3,
Choose bus type according to os info in metadata.
When adding a disk, specify a pool and vol name,
so that kimchi can chek ref_cnt to make sure no others
using that volume,
also volume format is filled to driver so that qcow2 image
will not recognized as raw.
Tested:
1. when no bus is specified,
kimchi chose 'ide' for cdrom and 'virtio' for disk
2. when bus is specified,
kimchi attach disk with specified bus.
3. ide does not support hot plug.
4. Disk size for qcow2 and raw is right.
Depend on Sheldon's patch:
[PATCH]manually manage the metadata element
[PATCH]write the template OS info to vm metadata
[PATCH]Add two function to set and get domain xml metadata
[PATCH]bug fix: get user and group when vm is living.
[PATCH]update test case to set/get user and group when VM is running
Royce Lv (7):
Guest disks: Update doc to support manage guest disks
Guest disks: Update api definition and error reporting
Guest disks: Choose proper bus for device
Guest disks: Abstract vm disk functions
Guest disk: deals with disk attachment
Multiple pep8 fixes
Guest disks: Update testcase
docs/API.md | 12 ++--
src/kimchi/API.json | 37 +++++++---
src/kimchi/i18n.py | 28 ++++----
src/kimchi/mockmodel.py | 18 ++---
src/kimchi/model/storagevolumes.py | 9 +--
src/kimchi/model/vmstorages.py | 138 ++++++++++++++++++-------------------
src/kimchi/vmdisks.py | 58 ++++++++++++++++
tests/test_model.py | 75 ++++++++++++++++++++
8 files changed, 265 insertions(+), 110 deletions(-)
create mode 100644 src/kimchi/vmdisks.py
--
1.8.3.2
10 years, 5 months
[PATCH] bug fix: Use secure cookies
by Aline Manera
From: Aline Manera <alinefm(a)br.ibm.com>
Since this cookie does not contain the "secure" attribute, it might also
be sent to the site during an unencrypted session. Any information such
as cookies, session tokens or user credentials that are sent to the
server as clear text, may be stolen and used later for identity theft or
user impersonation.
Fix it.
Signed-off-by: Aline Manera <alinefm(a)br.ibm.com>
---
src/kimchi/config.py.in | 1 +
ui/js/src/kimchi.cookie.js | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index f8a645a..da89e3a 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -172,6 +172,7 @@ class KimchiConfig(dict):
'tools.nocache.on': True,
'tools.sessions.on': True,
'tools.sessions.name': 'kimchi',
+ 'tools.sessions.secure': True,
'tools.sessions.httponly': True,
'tools.sessions.locking': 'explicit',
'tools.sessions.storage_type': 'ram',
diff --git a/ui/js/src/kimchi.cookie.js b/ui/js/src/kimchi.cookie.js
index d63fb97..2a69407 100644
--- a/ui/js/src/kimchi.cookie.js
+++ b/ui/js/src/kimchi.cookie.js
@@ -18,6 +18,7 @@
kimchi.cookie = {
set: function(key, value, expireDays) {
value = encodeURIComponent(value);
+ value += '; secure'
if (expireDays) {
var expireDate = new Date();
expireDate.setDate(expireDate.getDate() + expireDays);
--
1.7.10.4
10 years, 5 months
[V6 0/5] bug fix: get user and group when VM is running
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V5 -> V6:
rebase
V4 -> V5:
it is wrong to call dom.isPersistent in V4, fix it.
V3 -> V4:
work around if libvirt do not support metadata API well.
V2 -> V3:
move the virDomain.metadata and virDomain.setMetadata to model/utils.py
add testcase
V1 -> V2:
libvirt also support virDomain.metadata and virDomain.setMetadata two api.
use virDomain.metadata to get the user and group.
use virDomain.setMetadata to set the user and group.
ShaoHe Feng (5):
Add two function to set and get domain xml metadata
bug fix: get user and group when vm is living.
update test case to set/get user and group when VM is running
write the template OS info to vm metadata
manually manage the metadata element
src/kimchi/i18n.py | 1 +
src/kimchi/model/utils.py | 73 +++++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 102 ++++++++++++++++++++++++++++------------------
tests/test_model.py | 13 ++++++
4 files changed, 150 insertions(+), 39 deletions(-)
--
1.9.0
10 years, 5 months
[PATCH V8 0/7] bug fix: get user and group when VM is running
by shaohef@linux.vnet.ibm.com
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
V7 -> V8
add a feature test to probe libvirt support metadata.
add namespace for manully metadata.
V6 -> V7:
After V6 rebase, still find one error code "KCHVM0029E" does not change.
V5 -> V6:
rebase
V4 -> V5:
it is wrong to call dom.isPersistent in V4, fix it.
V3 -> V4:
work around if libvirt do not support metadata API well.
V2 -> V3:
move the virDomain.metadata and virDomain.setMetadata to model/utils.py
add testcase
V1 -> V2:
libvirt also support virDomain.metadata and virDomain.setMetadata two api.
use virDomain.metadata to get the user and group.
use virDomain.setMetadata to set the user and group.
ShaoHe Feng (7):
Add two function to set and get domain xml metadata
bug fix: get user and group when vm is living.
update test case to set/get user and group when VM is running
write the template OS info to vm metadata
bug fix: call a method should be followed by "()"
add method to test libvirt api are available
manually manage the metadata element
src/kimchi/config.py.in | 14 ++++++-
src/kimchi/featuretests.py | 44 ++++++++++++++++++-
src/kimchi/i18n.py | 1 +
src/kimchi/model/utils.py | 97 ++++++++++++++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 102 ++++++++++++++++++++++++++++-----------------
tests/test_model.py | 13 ++++++
6 files changed, 229 insertions(+), 42 deletions(-)
--
1.9.0
10 years, 5 months
[RFC] - Guest Memory/CPU warning
by Rodrigo Trujillo
Hi all,
we have recently merged the patches that allow user to change guest
memory and cpu.
When user change this parameters, we have some problems:
1- If user assigned more virtual cpus than the amount in the host
and start the VM, VM will start normally, but the host server will have
the performance heavily declined.
2- If user assigned more virtual memory than the physical amount in
the host, the VM does not start and qemu throws an exception like
"Cannot allocate memory."
Solutions:
1a - Show the number of host physical CPUs in edit Template and
edit Guest windows, then warn the user if he assigns a higher number
1b - Show the number of host physical CPUs in edit Template and
edit Guest windows, then does not allow to set up a higher number
(generate a error during edition)
2a - Show the host MEMORY amount in edit Template and edit Guest
windows, then warn the user if he assigns a higher number
2b - Show the host MEMORY amount in edit Template and edit Guest
windows, then does not allow to set up a higher number (generate a error
during edition)
- A third option would be check the numbers before start a guest
and warn the user, or does not allow the vm to be started.
I would like to implement 1a and 2b.
Do you have any thoughts or concerns/suggestions ?
Rodrigo Trujillo
10 years, 5 months
[PATCH] Fix PEP8 in scan.py
by Rodrigo Trujillo
Fixes pep9 issues in src/kimchi/scan.py and adds it to PEP8_WHITELIST.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
Makefile.am | 1 +
src/kimchi/scan.py | 15 +++++++++------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 1e4a8be..9785de9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -60,6 +60,7 @@ PEP8_WHITELIST = \
src/kimchi/repositories.py \
src/kimchi/rollbackcontext.py \
src/kimchi/root.py \
+ src/kimchi/scan.py \
src/kimchi/server.py \
src/kimchi/swupdate.py \
src/kimchi/template.py \
diff --git a/src/kimchi/scan.py b/src/kimchi/scan.py
index b67e3a5..e50dbbc 100644
--- a/src/kimchi/scan.py
+++ b/src/kimchi/scan.py
@@ -15,7 +15,7 @@
#
# 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
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
import glob
@@ -32,6 +32,7 @@ from kimchi.utils import kimchi_log
SCAN_IGNORE = ['/tmp/kimchi-scan-*']
+
class Scanner(object):
SCAN_TTL = 300
@@ -56,8 +57,8 @@ class Scanner(object):
shutil.rmtree(d)
self.clean_cb(transient_pool)
except OSError as e:
- kimchi_log.debug(
- "Exception %s occured when cleaning stale pool, ignore" % e.message)
+ msg = "Exception %s occured when cleaning stale pool, ignore"
+ kimchi_log.debug(msg % e.message)
def scan_dir_prepare(self, name):
# clean stale scan storage pools
@@ -71,16 +72,18 @@ class Scanner(object):
duplicates = "%s/%s*" % (params['pool_path'], iso_name)
for f in glob.glob(duplicates):
iso_img = IsoImage(f)
- if (iso_info['distro'], iso_info['version']) == iso_img.probe():
+ if (iso_info['distro'], iso_info['version']) == \
+ iso_img.probe():
return
- iso_path = iso_name + hashlib.md5(iso_info['path']).hexdigest() + '.iso'
+ iso_path = iso_name + hashlib.md5(iso_info['path']).hexdigest() + \
+ '.iso'
link_name = os.path.join(params['pool_path'],
os.path.basename(iso_path))
os.symlink(iso_info['path'], link_name)
ignore_paths = params.get('ignore_list', [])
scan_params = dict(path=params['scan_path'], updater=updater,
- ignore_list=ignore_paths + SCAN_IGNORE)
+ ignore_list=ignore_paths + SCAN_IGNORE)
probe_iso(None, scan_params)
cb('', True)
--
1.9.0
10 years, 5 months