[libvirt] [PATCH] virsh: plug memory leak on cmdDomblkstat
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leak introduced in commit 88a993b:
* tools/virsh.c: fix memory leak on cmdDomblkstat.
* how to reproduce?
% valgrind -v --leak-check=full virsh cmdDomblkstat <domain name>
* actual valgrind result:
==6573== 1,836 bytes in 1 blocks are definitely lost in loss record 110 of 124
==6573== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==6573== by 0x330D71497D: xdr_string (in /lib64/libc-2.12.so)
==6573== by 0x4D26CED: xdr_remote_nonnull_string (remote_protocol.c:30)
==6573== by 0x4D28138: xdr_remote_domain_get_xml_desc_ret (remote_protocol.c:1418)
==6573== by 0x4D3C0C2: virNetMessageDecodePayload (virnetmessage.c:382)
==6573== by 0x4D3279F: virNetClientProgramCall (virnetclientprogram.c:382)
==6573== by 0x4D0D50B: callWithFD (remote_driver.c:4339)
==6573== by 0x4D0D5AB: call (remote_driver.c:4360)
==6573== by 0x4D16EAF: remoteDomainGetXMLDesc (remote_client_bodies.h:861)
==6573== by 0x4CF9F4F: virDomainGetXMLDesc (libvirt.c:4098)
==6573== by 0x4154D9: cmdDomblklist (virsh.c:1722)
==6573== by 0x4149E2: vshCommandRun (virsh.c:16365)
==6573==
==6573== 46,009 (352 direct, 45,657 indirect) bytes in 1 blocks are definitely lost in loss record 123 of 124
==6573== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==6573== by 0x3318286DC6: xmlXPathNewContext (in /usr/lib64/libxml2.so.2.7.6)
==6573== by 0x4C79AE2: virXMLParseHelper (xml.c:779)
==6573== by 0x415512: cmdDomblklist (virsh.c:1726)
==6573== by 0x4149E2: vshCommandRun (virsh.c:16365)
==6573== by 0x427743: main (virsh.c:17867)
==6573==
==6573== LEAK SUMMARY:
==6573== definitely lost: 2,188 bytes in 2 blocks
==6573== indirectly lost: 45,657 bytes in 332 blocks
==6573== possibly lost: 0 bytes in 0 blocks
==6573== still reachable: 128,034 bytes in 1,364 blocks
==6573== suppressed: 0 bytes in 0 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
tools/virsh.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index a51478f..7c2f3fc 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1757,6 +1757,9 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
cleanup:
VIR_FREE(disks);
virDomainFree(dom);
+ VIR_FREE(xml);
+ xmlFreeDoc(xmldoc);
+ xmlXPathFreeContext(ctxt);
return ret;
}
--
1.7.1
12 years, 11 months
Re: [libvirt] how to use macvtap in kvm guest
by Amit Tewari
Hi,
No guest can not get ip.
When I do ifup eth0 it give error device not found.
Hostos=rhel 6.x86_64
Guest os= rhel 6.x86_64
Libvirt =0.8.7
Macvtap driver is loaded.
Qemu-kvm= 0.12.1.2
i think this error is creating problem
macvtap0:no ipv6 routers present
________________________________
From: xhu [mailto:xhu@redhat.com]
Sent: Friday, December 09, 2011 10:53 AM
To: Amit Tewari
Cc: libvir-list(a)redhat.com
Subject: Re: [libvirt] how to use macvtap in kvm guest
On 12/09/2011 12:28 PM, Amit Tewari wrote:
Hi
I am creating macvtap0 interface on my eth1 interface.
ip link show macvtap0
133: macvtap0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq
state UNKNOWN qlen 500
link/ether 3e:63:18:f3:49:63 brd ff:ff:ff:ff:ff:ff
guest interface file-
<interface type='direct'>
<mac address='3e:63:18:f3:49:63'/>
<source dev='eth0' mode='bridge'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
</interface>
Now when I do-
Virsh define guest works fine
But when I do virsh start guest
can guest gain ip?
Dmesg shows error
macvtap0:no ipv6 routers present
libvirtd[24907]: segfault at 0 ip 0000003e22280062 sp 00007fd3057f8cb8
error 4 in libc-2.12.so[3e22200000+187000]
and even if guest starts its eth interface is not created
could you provide your host os, guest os, libvirt, qemu-kvm version?
it is fine as i tried, no segment fault message and the guest can get
ip.
DISCLAIMER:
------------------------------------------------------------------------
-----------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily
reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure,
modification,
distribution and / or publication of
this message without the prior written consent of the author of this
e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
------------------------------------------------------------------------
-----------------------------------------------
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
12 years, 11 months
[libvirt] [PATCH] fix memory leak in src/nodeinfo.c
by Stefan Berger
Fix memory leak:
==27534== 24 bytes in 1 blocks are definitely lost in loss record 207 of 530
==27534== at 0x4A05E46: malloc (vg_replace_malloc.c:195)
==27534== by 0x38EC26EC37: vasprintf (in /lib64/libc-2.13.so)
==27534== by 0x4E998E6: virVasprintf (util.c:1677)
==27534== by 0x4E999F1: virAsprintf (util.c:1695)
==27534== by 0x4F1EAAC: nodeGetInfo (nodeinfo.c:593)
==27534== by 0x47948F: qemuCapsInitCPU (qemu_capabilities.c:855)
==27534== by 0x4796B1: qemuCapsInit (qemu_capabilities.c:915)
==27534== by 0x456550: qemuCreateCapabilities (qemu_driver.c:245)
==27534== by 0x4578C4: qemudStartup (qemu_driver.c:580)
==27534== by 0x4F20886: virStateInitialize (libvirt.c:852)
==27534== by 0x420E55: daemonRunStateInit (libvirtd.c:1156)
==27534== by 0x4E94C56: virThreadHelper (threads-pthread.c:157)
Mark this leaked variable as const char * when it is passed into another
function.
---
src/nodeinfo.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: libvirt-iterator/src/nodeinfo.c
===================================================================
--- libvirt-iterator.orig/src/nodeinfo.c
+++ libvirt-iterator/src/nodeinfo.c
@@ -68,7 +68,7 @@
/* NB, this is not static as we need to call it from the testsuite */
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
- char *sysfs_cpudir,
+ const char *sysfs_cpudir,
virNodeInfoPtr nodeinfo);
static int linuxNodeGetCPUStats(FILE *procstat,
@@ -199,7 +199,7 @@ static int parse_core(unsigned int cpu)
}
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
- char *sysfs_cpudir,
+ const char *sysfs_cpudir,
virNodeInfoPtr nodeinfo)
{
char line[1024];
@@ -597,9 +597,12 @@ int nodeGetInfo(virConnectPtr conn ATTRI
ret = linuxNodeInfoCPUPopulate(cpuinfo, sysfs_cpuinfo, nodeinfo);
VIR_FORCE_FCLOSE(cpuinfo);
- if (ret < 0)
+ if (ret < 0) {
+ VIR_FREE(sysfs_cpuinfo);
return -1;
+ }
+ VIR_FREE(sysfs_cpuinfo);
/* Convert to KB. */
nodeinfo->memory = physmem_total () / 1024;
12 years, 11 months
[libvirt] [PATCH v2] fix error when parsing ppc64 models on x86 host
by Stefan Berger
When parsing ppc64 models on an x86 host an out-of-memory error message
is displayed due
to it checking for retcpus being NULL. Fix this by removing the check
whether retcpus is NULL
since we will realloc into this variable.
Also in the X86 model parser display the OOM error at the location where
it happens.
---
v2: Fixing leak of 'cpus'
---
src/qemu/qemu_capabilities.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
Index: libvirt-iterator/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-iterator.orig/src/qemu/qemu_capabilities.c
+++ libvirt-iterator/src/qemu/qemu_capabilities.c
@@ -443,8 +443,10 @@ qemuCapsParseX86Models(const char *outpu
if (retcpus) {
unsigned int len;
- if (VIR_REALLOC_N(cpus, count + 1) < 0)
+ if (VIR_REALLOC_N(cpus, count + 1) < 0) {
+ virReportOOMError();
goto error;
+ }
if (next)
len = next - p - 1;
@@ -456,8 +458,10 @@ qemuCapsParseX86Models(const char *outpu
len -= 2;
}
- if (!(cpus[count] = strndup(p, len)))
+ if (!(cpus[count] = strndup(p, len))) {
+ virReportOOMError();
goto error;
+ }
}
count++;
} while ((p = next));
@@ -491,12 +495,7 @@ qemuCapsParsePPCModels(const char *outpu
const char *next;
unsigned int count = 0;
const char **cpus = NULL;
- int i;
-
- if (!retcpus) {
- VIR_DEBUG("No retcpus specified");
- return -1;
- }
+ int i, ret;
do {
const char *t;
@@ -523,32 +522,38 @@ qemuCapsParsePPCModels(const char *outpu
if (retcpus) {
unsigned int len;
- if (VIR_REALLOC_N(cpus, count + 1) < 0)
+ if (VIR_REALLOC_N(cpus, count + 1) < 0) {
virReportOOMError();
+ ret = -1;
goto error;
+ }
len = t - p - 1;
- if (!(cpus[count] = strndup(p, len)))
+ if (!(cpus[count] = strndup(p, len))) {
virReportOOMError();
+ ret = -1;
goto error;
+ }
}
count++;
} while ((p = next));
if (retcount)
*retcount = count;
- if (retcpus)
+ if (retcpus) {
*retcpus = cpus;
- return 0;
+ cpus = NULL;
+ }
+ ret = 0;
error:
if (cpus) {
for (i = 0; i < count; i++)
VIR_FREE(cpus[i]);
+ VIR_FREE(cpus);
}
- VIR_FREE(cpus);
- return -1;
+ return ret;
}
int
@@ -587,10 +592,8 @@ qemuCapsProbeCPUModels(const char *qemu,
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
- if (parse(output, count, cpus) < 0) {
- virReportOOMError();
+ if (parse(output, count, cpus) < 0)
goto cleanup;
- }
ret = 0;
12 years, 11 months
[libvirt] [PATCH] threadpool: Don't wait on condition if pool has no workers
by Michal Privoznik
Pool creates new workers dynamically. However, it is possible
for a pool to have no workers. If we want to free that pool,
we don't want to wait on quit condition as it will never be
signaled.
---
Pushing under trivial rule
src/util/threadpool.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/util/threadpool.c b/src/util/threadpool.c
index c16e2af..883d1e5 100644
--- a/src/util/threadpool.c
+++ b/src/util/threadpool.c
@@ -258,7 +258,8 @@ void virThreadPoolFree(virThreadPoolPtr pool)
virCondBroadcast(&pool->prioCond);
}
- ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
+ if (pool->nWorkers > 0 || pool->nPrioWorkers > 0)
+ ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
while ((job = pool->jobList.head)) {
pool->jobList.head = pool->jobList.head->next;
--
1.7.3.4
12 years, 11 months
[libvirt] [PATCH] fix error when parsing ppc64 models on x86 host
by Stefan Berger
When parsing ppc64 models on an x86 host an out-of-memory error message
is displayed due
to it checking for retcpus being NULL. Fix this by removing the check
whether retcpus is NULL
since we will realloc into this variable.
Also in the X86 model parser display the OOM error at the location where
it happens.
---
src/qemu/qemu_capabilities.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
Index: libvirt-iterator/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-iterator.orig/src/qemu/qemu_capabilities.c
+++ libvirt-iterator/src/qemu/qemu_capabilities.c
@@ -443,8 +443,10 @@ qemuCapsParseX86Models(const char *outpu
if (retcpus) {
unsigned int len;
- if (VIR_REALLOC_N(cpus, count + 1) < 0)
+ if (VIR_REALLOC_N(cpus, count + 1) < 0) {
+ virReportOOMError();
goto error;
+ }
if (next)
len = next - p - 1;
@@ -456,8 +458,10 @@ qemuCapsParseX86Models(const char *outpu
len -= 2;
}
- if (!(cpus[count] = strndup(p, len)))
+ if (!(cpus[count] = strndup(p, len))) {
+ virReportOOMError();
goto error;
+ }
}
count++;
} while ((p = next));
@@ -493,11 +497,6 @@ qemuCapsParsePPCModels(const char *outpu
const char **cpus = NULL;
int i;
- if (!retcpus) {
- VIR_DEBUG("No retcpus specified");
- return -1;
- }
-
do {
const char *t;
@@ -587,10 +586,8 @@ qemuCapsProbeCPUModels(const char *qemu,
if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
- if (parse(output, count, cpus) < 0) {
- virReportOOMError();
+ if (parse(output, count, cpus) < 0)
goto cleanup;
- }
ret = 0;
12 years, 11 months
[libvirt] [PATCH] virsh: correct the cmdDomIfGetLink function return value error
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
* tools/virsh.c: Although finding interface with matching mac addr, forgot to
set 'ret' boolean value to 'true'.
* how to reproduce?
% virsh domif-getlink <guest name> <interface mac>
% echo $?
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
tools/virsh.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 276e1cc..91c3459 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1538,6 +1538,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
mac = virXMLPropString(cur, "address");
if (STRCASEEQ(mac, iface)){
+ ret = true;
goto hit;
}
}
--
1.7.1
12 years, 11 months
[libvirt] [PATCH] bridge: Fix forward delay APIs
by Jiri Denemark
Due to copy&paste error in c1df2c14b590b3d68b707aa4f3a570f95a6bc548,
virNetDevBridge[SG]etSTPDelay APIs were accessing wrong file.
---
src/util/virnetdevbridge.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index e246b2c..08c8f5c 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -395,7 +395,7 @@ int virNetDevBridgeSetSTPDelay(const char *brname,
if ((fd = virNetDevSetupControl(brname, &ifr)) < 0)
goto cleanup;
- ret = virNetDevBridgeSet(brname, "stp_state", MS_TO_JIFFIES(delay),
+ ret = virNetDevBridgeSet(brname, "forward_delay", MS_TO_JIFFIES(delay),
fd, &ifr);
cleanup:
@@ -426,7 +426,7 @@ int virNetDevBridgeGetSTPDelay(const char *brname,
if ((fd = virNetDevSetupControl(brname, &ifr)) < 0)
goto cleanup;
- ret = virNetDevBridgeGet(brname, "stp_state", &i,
+ ret = virNetDevBridgeGet(brname, "forward_delay", &i,
fd, &ifr);
*delayms = JIFFIES_TO_MS(i);
--
1.7.8
12 years, 11 months
[libvirt] [PATCH] cpu: Add cpu flags supported by newest qemu
by Peter Krempa
Add support for newly supported Intel cpu features. Newly supported
flags are: pclmuldq, dtes64, smx, fma, pdcm, movbe, xsave, osxsave and
avx. This adds support for Intel's Sandy Bridge platform.
---
I did not add a new cpu model, as there's no corresponding model in QEMU yet.
https://bugzilla.redhat.com/show_bug.cgi?id=761005
src/cpu/cpu_map.xml | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 35dca20..693caf1 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -100,6 +100,12 @@
<feature name='pni'> <!-- CPUID_EXT_SSE3 -->
<cpuid function='0x00000001' ecx='0x00000001'/>
</feature>
+ <feature name='pclmuldq'>
+ <cpuid function='0x00000001' ecx='0x00000002'/>
+ </feature>
+ <feature name='dtes64'>
+ <cpuid function='0x00000001' ecx='0x00000004'/>
+ </feature>
<feature name='monitor'> <!-- CPUID_EXT_MONITOR -->
<cpuid function='0x00000001' ecx='0x00000008'/>
</feature>
@@ -109,6 +115,9 @@
<feature name='vmx'> <!-- CPUID_EXT_VMX -->
<cpuid function='0x00000001' ecx='0x00000020'/>
</feature>
+ <feature name='smx'>
+ <cpuid function='0x00000001' ecx='0x00000040'/>
+ </feature>
<feature name='est'> <!-- CPUID_EXT_EST -->
<cpuid function='0x00000001' ecx='0x00000080'/>
</feature>
@@ -121,12 +130,18 @@
<feature name='cid'> <!-- CPUID_EXT_CID -->
<cpuid function='0x00000001' ecx='0x00000400'/>
</feature>
+ <feature name='fma'>
+ <cpuid function='0x00000001' ecx='0x00001000'/>
+ </feature>
<feature name='cx16'> <!-- CPUID_EXT_CX16 -->
<cpuid function='0x00000001' ecx='0x00002000'/>
</feature>
<feature name='xtpr'> <!-- CPUID_EXT_XTPR -->
<cpuid function='0x00000001' ecx='0x00004000'/>
</feature>
+ <feature name='pdcm'>
+ <cpuid function='0x00000001' ecx='0x00008000'/>
+ </feature>
<feature name='dca'> <!-- CPUID_EXT_DCA -->
<cpuid function='0x00000001' ecx='0x00040000'/>
</feature>
@@ -139,12 +154,24 @@
<feature name='x2apic'> <!-- CPUID_EXT_X2APIC -->
<cpuid function='0x00000001' ecx='0x00200000'/>
</feature>
+ <feature name='movbe'>
+ <cpuid function='0x00000001' ecx='0x00400000'/>
+ </feature>
<feature name='popcnt'> <!-- CPUID_EXT_POPCNT -->
<cpuid function='0x00000001' ecx='0x00800000'/>
</feature>
<feature name='aes'>
<cpuid function='0x00000001' ecx='0x02000000'/>
</feature>
+ <feature name='xsave'>
+ <cpuid function='0x00000001' ecx='0x04000000'/>
+ </feature>
+ <feature name='osxsave'>
+ <cpuid function='0x00000001' ecx='0x08000000'/>
+ </feature>
+ <feature name='avx'>
+ <cpuid function='0x00000001' ecx='0x10000000'/>
+ </feature>
<feature name='hypervisor'> <!-- CPUID_EXT_HYPERVISOR -->
<cpuid function='0x00000001' ecx='0x80000000'/>
</feature>
--
1.7.3.4
12 years, 11 months