[libvirt] [PATCHv2 0/2] Fix docs for virBitmapParse
by Peter Krempa
Split out from the other series.
Peter Krempa (2):
util: Fix docs for virBitmapParse
conf: Fix usage of virBitmapParse
src/conf/network_conf.c | 2 +-
src/util/virbitmap.c | 23 +++++++++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
--
1.8.1.1
11 years, 11 months
[libvirt] [PATCH v2] qemu_agent: Ignore expected EOFs
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=892079
One of my previous patches (f2a4e5f176c408) tried to fix crashing
libvirtd on domain detroy. However, we need to copy pattern from
qemuProcessHandleMonitorEOF() instead of decrementing reference
counter. The rationale for this is, if qemu process is dying due
to domain being destroyed, we obtain EOF on both the monitor and
agent sockets. However, if the exit is expected, qemuProcessStop
is called, which cleans both agent and monitor sockets up. We
want qemuAgentClose() to be called iff the EOF is not expected,
so we don't leak an FD and memory.
---
diff to v1:
-handle race with qemuProcessHandleMonitorEOF correctly
src/qemu/qemu_process.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2f08215..013b2ca 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -133,14 +133,30 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
virObjectLock(vm);
priv = vm->privateData;
- if (priv->agent == agent &&
- !virObjectUnref(priv->agent))
+
+ if (!priv->agent) {
+ VIR_DEBUG("Agent freed already");
+ goto unlock;
+ }
+
+ if (priv->beingDestroyed) {
+ VIR_DEBUG("Domain is being destroyed, agent EOF is expected");
+ goto unlock;
+ }
+
+ if (priv->agent == agent)
priv->agent = NULL;
virObjectUnlock(vm);
qemuDriverUnlock(driver);
qemuAgentClose(agent);
+ return;
+
+unlock:
+ virObjectUnlock(vm);
+ qemuDriverUnlock(driver);
+ return;
}
--
1.8.0.2
11 years, 11 months
[libvirt] [PATCH 0/6] More Coverity changes
by John Ferlan
Like a gift that keeps on giving... More Coverity changes.
Adjust changes from earlier based on Eric's comments/feedback.
nodeinfo.c - use sa_assert() instead of comment:
https://www.redhat.com/archives/libvir-list/2013-January/msg01578.html
virnetclient.c - remove change - the VIR_FREE change resolves this:
https://www.redhat.com/archives/libvir-list/2013-January/msg01581.html
Two new Coverity warnings popped up today (lxc_driver.c & lxc_process.c).
No rhyme or reason, they just were new with no recent change to blame
(very strange).
I missed the virnettlscontexttest.c and it's VIR_FREE() warning this
morning because it's before all the BAD_SIZEOF. The virbitmaptest.c
change was on another branch waiting - I just moved it here.
One more major change and some fixups still due on prior changes and
the number of Coverity warnings goes below 50 of which 35 are related
to the sdt macros (started at 297).
John Ferlan (6):
nodeinfo: Use sa_assert() instead of Coverity error tag
tests: Remove VIR_FREE() on static/stack buffer (der.data)
lxc_driver: Need to check for vm before calling virDomainUnlock(vm)
lxc_process: Avoid passing NULL iface->iname
rpc: Revert Coverity tag message
virbitmaptest: Resolve Coverity errors
src/lxc/lxc_driver.c | 3 ++-
src/lxc/lxc_process.c | 14 ++++++++------
src/nodeinfo.c | 4 ++--
src/rpc/virnetclient.c | 1 -
tests/virbitmaptest.c | 24 ++++++++++++++++--------
tests/virnettlscontexttest.c | 3 ---
6 files changed, 28 insertions(+), 21 deletions(-)
--
1.7.11.7
11 years, 11 months
[libvirt] [PATCH v2] parallels: Resolve some resource leaks
by John Ferlan
Be sure to VIR_FREE(accel) and moved virDomainVideoDefFree() within no_memory
label to be consistent
Resolve resource leak in parallelsApplyIfaceParams() when the 'oldnet' is
allocated locally. Also virCommandFree(cmd) as necessary.
---
This is a followup patch to:
https://www.redhat.com/archives/libvir-list/2013-January/msg01565.html
Changes in v2:
Change label from cleanup to error
Add calls to virCommandFree()
src/parallels/parallels_driver.c | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 1b47246..2b79939 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -271,17 +271,17 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
if (!(tmp = virJSONValueObjectGetString(value, "size"))) {
parallelsParseError();
- goto cleanup;
+ goto error;
}
if (virStrToLong_ul(tmp, &endptr, 10, &mem) < 0) {
parallelsParseError();
- goto cleanup;
+ goto error;
}
if (!STREQ(endptr, "Mb")) {
parallelsParseError();
- goto cleanup;
+ goto error;
}
if (VIR_ALLOC(video) < 0)
@@ -304,8 +304,9 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
no_memory:
virReportOOMError();
-cleanup:
+ VIR_FREE(accel);
virDomainVideoDefFree(video);
+error:
return -1;
}
@@ -1793,7 +1794,7 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
{
bool create = false;
bool is_changed = false;
- virCommandPtr cmd;
+ virCommandPtr cmd = NULL;
char strmac[VIR_MAC_STRING_BUFLEN];
int i;
@@ -1808,58 +1809,58 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
if (!create && oldnet->type != newnet->type) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Changing network type is not supported"));
- return -1;
+ goto error;
}
if (!STREQ_NULLABLE(oldnet->model, newnet->model)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Changing network device model is not supported"));
- return -1;
+ goto error;
}
if (!STREQ_NULLABLE(oldnet->data.network.portgroup,
newnet->data.network.portgroup)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Changing network portgroup is not supported"));
- return -1;
+ goto error;
}
if (!virNetDevVPortProfileEqual(oldnet->virtPortProfile,
newnet->virtPortProfile)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Changing virtual port profile is not supported"));
- return -1;
+ goto error;
}
if (newnet->tune.sndbuf_specified) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Setting send buffer size is not supported"));
- return -1;
+ goto error;
}
if (!STREQ_NULLABLE(oldnet->script, newnet->script)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Setting startup script is not supported"));
- return -1;
+ goto error;
}
if (!STREQ_NULLABLE(oldnet->filter, newnet->filter)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Changing filter params is not supported"));
- return -1;
+ goto error;
}
if (newnet->bandwidth != NULL) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Setting bandwidth params is not supported"));
- return -1;
+ goto error;
}
for (i = 0; i < sizeof(newnet->vlan); i++) {
if (((char *)&newnet->vlan)[i] != 0) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Setting vlan params is not supported"));
- return -1;
+ goto error;
}
}
@@ -1901,15 +1902,24 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
is_changed = true;
}
+ if (create)
+ VIR_FREE(oldnet);
+
if (!create && !is_changed) {
/* nothing changed - no need to run prlctl */
+ virCommandFree(cmd);
return 0;
}
if (virCommandRun(cmd, NULL))
- return -1;
+ goto error;
return 0;
+error:
+ if (create)
+ VIR_FREE(oldnet);
+ virCommandFree(cmd);
+ return -1;
}
static int
--
1.7.11.7
11 years, 11 months
[libvirt] [PATCH] Fix nwfilter driver reload/shutdown handling when unprivileged
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Although the nwfilter driver skips startup when running in a
session libvirtd, it did not skip reload or shutdown. This
caused errors to be reported when sending SIGHUP to libvirtd,
and caused an abort() in libdbus on shutdown due to trying
to remove a dbus filter that was never added
NB, this was previously part of my large refactoring series
https://www.redhat.com/archives/libvir-list/2013-January/msg01411.html
but I've pulled it out since I noticed it has SEGV impact.
---
src/conf/nwfilter_conf.h | 1 +
src/nwfilter/nwfilter_driver.c | 31 +++++++++++++++++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index ca2c070..35f8dde 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -556,6 +556,7 @@ typedef struct _virNWFilterDriverState virNWFilterDriverState;
typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
struct _virNWFilterDriverState {
virMutex lock;
+ bool privileged;
virNWFilterObjList nwfilters;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index b67b704..19ebb03 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -165,7 +165,7 @@ nwfilterDriverInstallDBusMatches(DBusConnection *sysbus ATTRIBUTE_UNUSED)
* Initialization function for the QEmu daemon
*/
static int
-nwfilterDriverStartup(bool privileged ATTRIBUTE_UNUSED,
+nwfilterDriverStartup(bool privileged,
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
@@ -185,6 +185,7 @@ nwfilterDriverStartup(bool privileged ATTRIBUTE_UNUSED,
goto err_free_driverstate;
driverState->watchingFirewallD = (sysbus != NULL);
+ driverState->privileged = privileged;
if (!privileged)
return 0;
@@ -275,6 +276,9 @@ nwfilterDriverReload(void) {
return -1;
}
+ if (!driverState->privileged)
+ return 0;
+
conn = virConnectOpen("qemu:///system");
if (conn) {
@@ -333,21 +337,24 @@ nwfilterDriverShutdown(void) {
if (!driverState)
return -1;
- virNWFilterConfLayerShutdown();
- virNWFilterTechDriversShutdown();
- virNWFilterDHCPSnoopShutdown();
- virNWFilterLearnShutdown();
- virNWFilterIPAddrMapShutdown();
+ if (driverState->privileged) {
+ virNWFilterConfLayerShutdown();
+ virNWFilterTechDriversShutdown();
+ virNWFilterDHCPSnoopShutdown();
+ virNWFilterLearnShutdown();
+ virNWFilterIPAddrMapShutdown();
- nwfilterDriverLock(driverState);
+ nwfilterDriverLock(driverState);
- nwfilterDriverRemoveDBusMatches();
+ nwfilterDriverRemoveDBusMatches();
- /* free inactive nwfilters */
- virNWFilterObjListFree(&driverState->nwfilters);
+ /* free inactive nwfilters */
+ virNWFilterObjListFree(&driverState->nwfilters);
+
+ VIR_FREE(driverState->configDir);
+ nwfilterDriverUnlock(driverState);
+ }
- VIR_FREE(driverState->configDir);
- nwfilterDriverUnlock(driverState);
virMutexDestroy(&driverState->lock);
VIR_FREE(driverState);
--
1.8.0.2
11 years, 11 months
[libvirt] [PATCH 0/2] Fix parsing of vCPU counts from domain XMLs.
by Peter Krempa
These patches fix the parsing and the returned error if parsing of vCPUs
failed. If a overflowing number was used for the count, the domain might
disappear after the restart of the daemon.
Peter Krempa (2):
conf: Check if number of vCPUs fits in the storage variable
conf: Improve error messages if parsing of vCPU count fails
src/conf/domain_conf.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--
1.8.1.1
11 years, 11 months
[libvirt] [RFC PATCH v1 0/7] virCgroup refactor
by Hu Tao
Hi,
This series is posted for early review.
This series refactors virCgroup. The changes are:
- virCgroupItem is associated with a cgroup directory. The directory
is created only when needed, and removed if no one is using it.
- Anyone using cgroups creates instances of virCgroupItem and maintains
their lifetime.
Please focus on patch #5, which brings the main change(virCgroupItem),
and qemu part in patch #6, which shows the usage of virCgroupItem(I've not
tested lxc part yet).
Hu Tao (7):
call virstateCleanup to do the cleanup before libvirtd exits
include util.h in cgroup.h
include virterror_internal.h in threads.h
refactor virCgroupDetectMounts and virCgroupDetectPlacement
cgroup: refactor virCgroup
deploy the newly introduced virCgroupItem.
tests for virCgroup.
daemon/libvirtd.c | 6 +
src/conf/domain_audit.c | 16 +-
src/conf/domain_audit.h | 6 +-
src/conf/domain_conf.h | 5 +
src/libvirt_private.syms | 17 +-
src/lxc/lxc_cgroup.c | 91 ++-
src/lxc/lxc_conf.h | 2 +-
src/lxc/lxc_driver.c | 268 +++-----
src/lxc/lxc_process.c | 56 +-
src/qemu/qemu_cgroup.c | 287 +++------
src/qemu/qemu_cgroup.h | 17 +-
src/qemu/qemu_conf.h | 2 +-
src/qemu/qemu_driver.c | 478 +++++---------
src/qemu/qemu_hotplug.c | 44 +-
src/qemu/qemu_migration.c | 36 +-
src/qemu/qemu_process.c | 29 +-
src/util/vircgroup.c | 1570 ++++++++++++++++++++-------------------------
src/util/vircgroup.h | 108 ++--
src/util/virthread.h | 1 +
tests/Makefile.am | 5 +
tests/vircgrouptest.c | 103 +++
21 files changed, 1338 insertions(+), 1809 deletions(-)
create mode 100644 tests/vircgrouptest.c
--
1.8.0.1.240.ge8a1f5a
11 years, 11 months
[libvirt] [libvirt-designer 1/4] virtxml: Make global var local
by Christophe Fergeau
OsinfoLoader is declared as a global variable in virtxml.c but
is only used in one function, so it can be made local.
---
examples/virtxml.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/virtxml.c b/examples/virtxml.c
index 2918ee0..18b0456 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -35,7 +35,6 @@
GList *disk_str_list = NULL;
GList *iface_str_list = NULL;
-OsinfoLoader *loader = NULL;
OsinfoDb *db = NULL;
#define print_error(...) \
@@ -65,6 +64,7 @@ load_osinfo(void)
{
GError *err = NULL;
gboolean ret = FALSE;
+ OsinfoLoader *loader = NULL;
loader = osinfo_loader_new();
osinfo_loader_process_default_path(loader, &err);
--
1.8.1
11 years, 11 months
[libvirt] Error connecting to virConnectOpen("qemu:///system"); after 20 times
by Pankaj Rawat
Hi,
I am using libvirt api to create an app, I am facing a problem.
I can connect to connection object 20 number of times in programm after that it gives connection object null.
Here is the sample code.
Normally code should run 1000 times but it only runs 20 times
Filename: list.cpp
#include<pthread.h>
#include<stdlib.h>
#include<stdio.h>
#include<malloc.h>
#include <iostream>
#include<string.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
static int count;
static void customErrorFunc(void *userdata, virErrorPtr err)
{
}
int main()
{
virConnectPtr conn;
for ( int i=0; i< 1000;i++)
{
conn = virConnectOpen("qemu:///system");
if (conn == NULL) {
fprintf(stderr, "Failed to open connection to qemu:///system\n");
printf("Failed to open connection to qemu:///system\n");
virConnectClose(conn);
return NULL;
}
printf("Hello %d\n",i);
virError err;
virSetErrorFunc(NULL, customErrorFunc);
int j;
int numDomains1,numDomains2,numDomains;
int *activeDomains;
numDomains1 = virConnectNumOfDomains(conn);
activeDomains = (int*)malloc(sizeof(int) * numDomains1);
numDomains1 = virConnectListDomains(conn, activeDomains, numDomains1);
for (int j = 0 ; j < numDomains1 ; j++)
{
virDomainPtr dom;
dom = virDomainLookupByID(conn,activeDomains[j]);
free(dom);
}
free(activeDomains);
count--;
virConnectClose(conn);
}
}
Output:
Hello 0
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
Hello 7
Hello 8
Hello 9
Hello 10
Hello 11
Hello 12
Hello 13
Hello 14
Hello 15
Hello 16
Hello 17
Hello 18
Hello 19
Failed to open connection to qemu:///system
Failed to open connection to qemu:///system
Can any one tell me where I am going wrong.
Regards,
Pankaj Rawat
NECHCL ST
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. .
-----------------------------------------------------------------------------------------------------------------------
11 years, 11 months