[libvirt] [PATCH 0/2] Couple of sysinfo fixes

I've just tried sysinfo on my RPi, and found some bugs there. Michal Privoznik (2): virSysinfoParseProcessor: Drop useless check for NULL sysinfo: Fix reports on arm src/util/virsysinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.3.6

VIR_STRDUP plays nicely with NULLs. Theres no need to guard its call with check for non-NULL. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virsysinfo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 4edce66..8bb17f0 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -315,8 +315,7 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret) cur, eol - cur) < 0) goto error; - if (processor_type && - VIR_STRDUP(processor->processor_type, processor_type) < 0) + if (VIR_STRDUP(processor->processor_type, processor_type) < 0) goto error; base = cur; -- 2.3.6

On 05/12/2015 10:23 AM, Michal Privoznik wrote:
VIR_STRDUP plays nicely with NULLs. Theres no need to guard its call with check for non-NULL.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virsysinfo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
ACK
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 4edce66..8bb17f0 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -315,8 +315,7 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret) cur, eol - cur) < 0) goto error;
- if (processor_type && - VIR_STRDUP(processor->processor_type, processor_type) < 0) + if (VIR_STRDUP(processor->processor_type, processor_type) < 0) goto error;
base = cur;
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Due to a commit in kernel (155597223) it's 'processor' rather than 'Processor'. Fix our parser too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virsysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 8bb17f0..fb8cb2c 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -289,7 +289,7 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret) virSysinfoProcessorDefPtr processor; char *processor_type = NULL; - if (!(tmp_base = strstr(base, "Processor"))) + if (!(tmp_base = strstr(base, "processor"))) return 0; base = tmp_base; -- 2.3.6

On 05/12/2015 10:23 AM, Michal Privoznik wrote:
Due to a commit in kernel (155597223) it's 'processor' rather than 'Processor'. Fix our parser too.
Shouldn't we be parsing this string case-insensitively, to work with kernels that pre-date that kernel commit?
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virsysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 8bb17f0..fb8cb2c 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -289,7 +289,7 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret) virSysinfoProcessorDefPtr processor; char *processor_type = NULL;
- if (!(tmp_base = strstr(base, "Processor"))) + if (!(tmp_base = strstr(base, "processor"))) return 0;
base = tmp_base;
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, May 12, 2015 at 11:44:49AM -0600, Eric Blake wrote:
On 05/12/2015 10:23 AM, Michal Privoznik wrote:
Due to a commit in kernel (155597223) it's 'processor' rather than 'Processor'. Fix our parser too.
Shouldn't we be parsing this string case-insensitively, to work with kernels that pre-date that kernel commit?
The referenced commit is from 2005. I would not lose sleep over libvirt not working with a ten year old kernel. But the libvirt code using Processor was added by commit 347081e [1] in 2013. Looks like the relevant kernel commit here is b4b8f770e [2] from 2012. After that the model name is printed under 'model name', not 'Processor:', so I'd expect your patch to break the test case added by [1]. Adding a new test case is very welcome. Jan [1] http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=347081e [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=b...
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virsysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 8bb17f0..fb8cb2c 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -289,7 +289,7 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret) virSysinfoProcessorDefPtr processor; char *processor_type = NULL;
- if (!(tmp_base = strstr(base, "Processor"))) + if (!(tmp_base = strstr(base, "processor"))) return 0;
base = tmp_base;
participants (3)
-
Eric Blake
-
Ján Tomko
-
Michal Privoznik