[PATCH] [Kimchi 1/1] Fix issue #1170: ERROR:KCHVM0090E: Unable to create a password-less libvirt connection to the remote libvirt daemon
by Fu.Lin
Long ago, I submitted an issue:
https://github.com/kimchi-project/kimchi/issues/1170 ...
Test by following script:
import subprocess
import os
import time
def _check_remote_libvirt_conn(remote_host,
user='root', transport='ssh'):
FNULL = open(os.devnull, 'w')
dest_uri = 'qemu+%s://%s@%s/system' % (transport, user,
remote_host)
cmd = ['virsh', '-c', dest_uri, 'list']
proc = subprocess.Popen(cmd, stdout=FNULL, stderr=FNULL,
shell=True, preexec_fn=os.setsid)
timeout = 0
while proc.poll() is None:
time.sleep(1)
timeout += 1
if timeout == 5:
print("killed")
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
if __name__ == '__main__':
_check_remote_libvirt_conn('localhost')
`proc` is timeout every time although the connection is normal tested by
`virsh -c <uri>` list
The following is the reason of changing(From Python Document 2.7.14):
Do not use stdout=PIPE or stderr=PIPE with this function as that can
deadlock based on the child process output volume. Use Popen with the
communicate() method when you need pipes.
Using shell=True can be a security hazard. See the warning under
Frequently Used Arguments for details.
At the same time, if not change, it does not work.
diff --git a/model/vms.py b/model/vms.py
index 6da4f3b..92e771f 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -1885,10 +1885,11 @@ class VMModel(object):
def _check_remote_libvirt_conn(self, remote_host,
user='root', transport='ssh'):
+ FNULL = open(os.devnull, 'w')
dest_uri = 'qemu+%s://%s@%s/system' % (transport, user,
remote_host)
cmd = ['virsh', '-c', dest_uri, 'list']
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- shell=True, preexec_fn=os.setsid)
+ proc = subprocess.Popen(cmd, stdout=FNULL, stderr=FNULL,
+ shell=False, preexec_fn=os.setsid)
timeout = 0
while proc.poll() is None:
time.sleep(1)
--
Regards
River (Fu.Lin)
7 years, 1 month
[PATCH] [Kimchi 1/1] Fix error handler on $.ajax() function
by Aline Manera
To deal on $.ajax() error, the right function is .fail() instead of
.error()
Signed-off-by: Aline Manera <aline.manera(a)gmail.com>
---
ui/js/src/kimchi.api.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index a34b2ba3..bf9dd6ac 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -328,10 +328,10 @@ var kimchi = {
url += "?token=" + wok.urlSafeB64Encode(vm+'-console').replace(/=*$/g, "");
url += '&encrypt=1';
window.open(url);
- }).error(function(data) {
+ }).fail(function(data) {
wok.message.error(data.responseJSON.reason);
});
- }).error(function(data) {
+ }).fail(function(data) {
wok.message.error(data.responseJSON.reason);
});
},
--
2.13.6
7 years, 2 months
[PATCH] [Kimchi 1/1] Fix issue #1157: Consider DOS/MBR mime type as ISO file
by Aline Manera
While creating a Template, the user can provide an ISO file or an Image
file. Kimchi relies on python magic to get the file mime type and it was
only considering ISO 9660 CD-ROM as valid for ISO images and it was fall
backing to an Image file and failing .
Add DOS/MBR as well to fix that problem.
Signed-off-by: Aline Manera <aline.manera(a)gmail.com>
---
model/templates.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/model/templates.py b/model/templates.py
index 566a20ce..c27e83f7 100644
--- a/model/templates.py
+++ b/model/templates.py
@@ -39,7 +39,7 @@ from wok.plugins.kimchi.utils import is_libvirtd_up, pool_name_from_uri
from wok.plugins.kimchi.utils import create_disk_image
from wok.plugins.kimchi.vmtemplate import VMTemplate
-ISO_TYPE = "ISO 9660 CD-ROM"
+ISO_TYPE = ["DOS/MBR", "ISO 9660 CD-ROM"]
# In PowerPC, memories must be aligned to 256 MiB
PPC_MEM_ALIGN = 256
# Max memory 16TB for PPC and 4TiB for X (according to Red Hat), in KiB
@@ -99,7 +99,8 @@ class TemplatesModel(object):
ftype = file_type.file(path)
# cdrom
- if ISO_TYPE in ftype:
+ iscdrom = [t for t in ISO_TYPE if t in ftype]
+ if iscdrom:
params["cdrom"] = path
# check search permission
--
2.13.6
7 years, 2 months
[PATCH] [Kimchi 1/1] Fix issue #1006: Use relative path to access websockify
by Aline Manera
Signed-off-by: Aline Manera <aline.manera(a)gmail.com>
---
ui/js/src/kimchi.api.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 0cacab3a..a34b2ba3 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -324,7 +324,7 @@ var kimchi = {
url += server_root;
url += "/plugins/kimchi/serial/html/serial.html";
url += "?port=" + proxy_port;
- url += "&path=" + server_root + "/websockify";
+ url += "&path=" + server_root + "websockify";
url += "?token=" + wok.urlSafeB64Encode(vm+'-console').replace(/=*$/g, "");
url += '&encrypt=1';
window.open(url);
@@ -348,7 +348,7 @@ var kimchi = {
url += server_root;
url += "/plugins/kimchi/novnc/vnc_auto.html";
url += "?port=" + proxy_port;
- url += "&path=" + server_root + "/websockify";
+ url += "&path=" + server_root + "websockify";
/*
* From python documentation base64.urlsafe_b64encode(s)
* substitutes - instead of + and _ instead of / in the
--
2.13.6
7 years, 2 months