Ooop! The patch lost the last modification...so please use the new one, sorry.
On Fri, Oct 16, 2009 at 9:45 PM, Daniel P. Berrange <berrange(a)redhat.com> wrote:
On Fri, Oct 16, 2009 at 05:05:27PM +0900, Ryota Ozaki wrote:
> BTW, by the defect I first got the following error and it made me
confused.
>
> # virsh -c lxc:/// dominfo 4930
> Id: 4930
> Name: lxc
> UUID: 084369a0-956a-3010-fc37-ddeb4d627e69
> OS Type: exe
> Autostart: disable
> error: this function is not supported by the hypervisor: virNodeGetSecurityModel
>
> The really error happens in lxcDomainGetInfo, so I guess something is wrong
> with internal error propagation. Anyone know this unexpected behavior?
This looks rather odd - I can't think of anything which could cause this
to happen - virsh is supposed to be filtering out that error message
OK, I've looked into a bit deep and found the following sequence happens.
In cmdDominfo (virsh.c), if virDomainGetInfo fails, 'ret' is set with FALSE.
Even so, further virNodeGetSecurityModel is called too. And if it also fails
then VIR_ERR_NO_SUPPORT is set. Normally, VIR_ERR_NO_SUPPORT does not lead
cmdDominfo failed, however, 'ret' is previously set with FALSE, then virsh
fails.
ozaki-r
From 55f11663316a9233987aacbaa1b561d0cea13cf8 Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Sat, 17 Oct 2009 08:16:34 +0900
Subject: [PATCH] LXC fix virCgroupGetValueStr on handling a string
terminated with '¥n'
* src/util/cgroup.c: get rid of '¥n' from the return value
of virCgroupGetValueStr
---
src/util/cgroup.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index f728a2f..bdd4eb6 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -309,6 +309,10 @@ static int virCgroupGetValueStr(virCgroupPtr group,
DEBUG("Failed to read %s: %m¥n", keypath);
rc = -errno;
} else {
+ /* Terminated with '¥n' has sometimes harmful effects to the caller */
+ char *p = strchr(*value, '¥n');
+ if (p) *p = '¥0';
+
rc = 0;
}
@@ -969,13 +973,7 @@ int virCgroupSetFreezerState(virCgroupPtr group,
const char *state)
int virCgroupGetFreezerState(virCgroupPtr group, char **state)
{
- int ret;
- ret = virCgroupGetValueStr(group,
+ return virCgroupGetValueStr(group,
VIR_CGROUP_CONTROLLER_CPU,
"freezer.state", state);
- if (ret == 0) {
- char *p = strchr(*state, '¥n');
- if (p) *p = '¥0';
- }
- return ret;
}
--
1.6.2.5