[libvirt] [PATCHv2] python: Avoid memory leaks on libvirt_virNodeGetMemoryStats
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leaks are introduced in commit 17c7795.
* python/libvirt-override.c (libvirt_virNodeGetMemoryStats): fix memory leaks
and improve codes return value.
For details, please see the following link:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770944
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
python/libvirt-override.c | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4e8a97e..594aae6 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2426,7 +2426,9 @@ libvirt_virNodeGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
static PyObject *
libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
{
- PyObject *ret;
+ PyObject *ret = VIR_PY_NONE;
+ PyObject *key = NULL;
+ PyObject *val = NULL;
PyObject *pyobj_conn;
virConnectPtr conn;
unsigned int flags;
@@ -2442,32 +2444,45 @@ libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
c_retval = virNodeGetMemoryStats(conn, cellNum, NULL, &nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
if (c_retval < 0)
- return VIR_PY_NONE;
+ return ret;
if (nparams) {
if (VIR_ALLOC_N(stats, nparams) < 0)
- return VIR_PY_NONE;
+ return PyErr_NoMemory();
LIBVIRT_BEGIN_ALLOW_THREADS;
c_retval = virNodeGetMemoryStats(conn, cellNum, stats, &nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(stats);
- return VIR_PY_NONE;
- }
- }
- if (!(ret = PyDict_New())) {
- VIR_FREE(stats);
- return VIR_PY_NONE;
+ if (c_retval < 0)
+ goto error;
}
+ if (!(ret = PyDict_New()))
+ goto error;
+
for (i = 0; i < nparams; i++) {
- PyDict_SetItem(ret,
- libvirt_constcharPtrWrap(stats[i].field),
- libvirt_ulonglongWrap(stats[i].value));
+ key = libvirt_constcharPtrWrap(stats[i].field);
+ val = libvirt_ulonglongWrap(stats[i].value);
+
+ if (!key || !val)
+ goto error;
+
+ if (PyDict_SetItem(ret, key, val) < 0) {
+ Py_DECREF(ret);
+ goto error;
+ }
+
+ Py_DECREF(key);
+ Py_DECREF(val);
}
VIR_FREE(stats);
return ret;
+
+error:
+ VIR_FREE(stats);
+ Py_XDECREF(key);
+ Py_XDECREF(val);
+ return ret;
}
static PyObject *
--
1.7.1
12 years, 8 months
[libvirt] [PATCH] correct security_require_confined default value
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
* src/qemu/qemu.conf: set security_require_confined default value to 0.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu.conf | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 95428c1..6cb3707 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -145,7 +145,7 @@
# If set to non-zero, then attempts to create unconfined
# guests will be blocked. Defaults to 0.
-# security_require_confined = 1
+# security_require_confined = 0
# The user ID for QEMU processes run by the system instance.
#user = "root"
--
1.7.1
12 years, 8 months
[libvirt] [PATCH 0/4 v2] New command for changing media
by Osier Yang
[PATCH 0/4] introduces two new helper functions: vshFindDisk is to find
the disk XML node in xml doc with the flags (indicates it's normal disk
or changeable disk). VshPrepareDiskXML is to prepare the disk XML for
disk changing commands' use, such as detach-disk. The purpose of this
patch is to prepare for upcoming new command "change-disk", which will
use the two helper functions too.
Please see [PATCH 4/4] for a overall description of the new command.
v1 - v2
* No changes, only rebasing
[PATCH 1/4] virsh: Two new helper functions for disk device changes
[PATCH 2/4] virsh: Use vshFindDisk and vshPrepareDiskXML in
[PATCH 3/4] virsh: New command cmdChangeMedia
[PATCH 4/4] virsh: Add document for cmdChangeMedia
Regards,
Osier
12 years, 8 months
[libvirt] [PATCH 0/3 v3] New command for changing media
by Osier Yang
[PATCH 0/3] introduces two new helper functions: vshFindDisk is to find
the disk XML node in xml doc with the type (indicates it's normal disk
or changeable disk). VshPrepareDiskXML is to prepare the disk XML for
disk changing commands' use, such as detach-disk. The purpose of this
patch is to prepare for upcoming new command "change-disk", which will
use the two helper functions too.
Please see [PATCH 3/3] for a overall description of the new command.
v2 - v3
* Update vshFindDisk to support search the disk node with both
the source path and target name.
* Change names of the two new enums ([PATCH 1/3]).
* Use virXMLParseStringCtxt instead of xmlReadDoc
* Use VIR_ALLOC_N instead of vshCalloc.
* [PATCH 3/4] and [PATCH 4/4] are merged into [PATCH 3/3]
* Change option "--target" into "--path".
* Defaults to use "--update" if none of "--eject", "--insert",
and "--update" is specified.
* Update docs to be consistent with the changes on codes.
* Other nits.
[PATCH 1/3] virsh: Two new helper functions for disk device changes
[PATCH 2/3] virsh: Use vshFindDisk and vshPrepareDiskXML in cmdDetachDisk
[PATCH 3/3] virsh: New command cmdChangeMedia
Regards,
Osier
12 years, 8 months
[libvirt] Add a new api, get this error.gnutls_record_recv: A TLS packet with unexpected length was received.
by chang liu
hi all,
Sorry to disturb you.
I wanna to add a new api to get some sheepdog cluster info, but I has
get this error, I don't know how to do.
I have add a function to daemon/remote.c that call the libvirt.c 's
api, remoteDispatchConnectExecuteCommand, and here i get the return value.
struct remote_connect_execute_command_ret {
remote_nonnull_string ret_val;
};
typedef struct remote_connect_execute_command_ret
remote_connect_execute_command_ret;
static int
remoteDispatchConnectExecuteCommand (struct qemud_server *server
ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
remote_message_header *hdr ATTRIBUTE_UNUSED,
remote_error *rerr,
remote_connect_execute_command_args *args,
remote_connect_execute_command_ret *ret)
the return value has been in ret->ret_val. I know the func
remoteDispatchDomainDumpXml returns it's values by ret->xml.
And after this, the things is the same, but when I dump xml, it's ok,
but when i wanna to get my value, it's cause
this error:
error : qemudClientReadBuf:1708 : gnutls_record_recv: A TLS
packet with unexpected length was received.
Could any body tell me, if I wanna to get a string data, do I need to
do any additional actions?
12 years, 8 months
[libvirt] [PATCH v4 0/1] Add netlink events to virnetlink
by D. Herrendoerfer
From: "D. Herrendoerfer" <d.herrendoerfer(a)herrendoerfer.name>
This is the updated netlink event code based upon the updated
virnetlink.[ch] files. Most of the previous remarks have been
addressed. This has also seen some preliminary testing.
D. Herrendoerfer (1):
util: Add netlink event handling to virnetlink.c
daemon/libvirtd.c | 8 +
src/libvirt_private.syms | 6 +
src/util/virnetlink.c | 436 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/virnetlink.h | 29 +++
4 files changed, 478 insertions(+), 1 deletions(-)
--
1.7.7.5
12 years, 8 months
[libvirt] [PATCH] qemu: make block io tuning smarter
by Eric Blake
When blkdeviotune was first committed in 0.9.8, we had the limitation
that setting one value reset all others. But bytes and iops should
be relatively independent. Furthermore, setting tuning values on
a live domain followed by dumpxml did not output the new settings.
* src/qemu/qemu_driver.c (qemuDiskPathToAlias): Add parameter, and
update callers.
(qemuDomainSetBlockIoTune): Don't lose previous unrelated
settings. Make live changes reflect to dumpxml output.
* tools/virsh.pod (blkdeviotune): Update documentation.
---
src/qemu/qemu_driver.c | 45 +++++++++++++++++++++++++++++++++++++++++----
tools/virsh.pod | 5 +++--
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 45c4100..dea52bf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11309,7 +11309,7 @@ cleanup:
}
static char *
-qemuDiskPathToAlias(virDomainObjPtr vm, const char *path)
+qemuDiskPathToAlias(virDomainObjPtr vm, const char *path, int *idx)
{
int i;
char *ret = NULL;
@@ -11320,6 +11320,8 @@ qemuDiskPathToAlias(virDomainObjPtr vm, const char *path)
goto cleanup;
disk = vm->def->disks[i];
+ if (idx)
+ *idx = i;
if (disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK &&
disk->type != VIR_DOMAIN_DISK_TYPE_FILE)
@@ -11361,7 +11363,7 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
goto cleanup;
}
- device = qemuDiskPathToAlias(vm, path);
+ device = qemuDiskPathToAlias(vm, path, NULL);
if (!device) {
goto cleanup;
}
@@ -11529,11 +11531,14 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
qemuDomainObjPrivatePtr priv;
virDomainDefPtr persistentDef = NULL;
virDomainBlockIoTuneInfo info;
+ virDomainBlockIoTuneInfo *oldinfo;
char uuidstr[VIR_UUID_STRING_BUFLEN];
const char *device = NULL;
int ret = -1;
int i;
int idx = -1;
+ bool set_bytes = false;
+ bool set_iops = false;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -11564,7 +11569,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
goto cleanup;
}
- device = qemuDiskPathToAlias(vm, disk);
+ device = qemuDiskPathToAlias(vm, disk, &idx);
if (!device) {
goto cleanup;
}
@@ -11581,21 +11586,27 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC)) {
info.total_bytes_sec = param->value.ul;
+ set_bytes = true;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC)) {
info.read_bytes_sec = param->value.ul;
+ set_bytes = true;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC)) {
info.write_bytes_sec = param->value.ul;
+ set_bytes = true;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC)) {
info.total_iops_sec = param->value.ul;
+ set_iops = true;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC)) {
info.read_iops_sec = param->value.ul;
+ set_iops = true;
} else if (STREQ(param->field,
VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC)) {
info.write_iops_sec = param->value.ul;
+ set_iops = true;
}
}
@@ -11614,10 +11625,25 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ /* If the user didn't specify bytes limits, inherit previous
+ * values; likewise if the user didn't specify iops
+ * limits. */
+ oldinfo = &vm->def->disks[idx]->blkdeviotune;
+ if (!set_bytes) {
+ info.total_bytes_sec = oldinfo->total_bytes_sec;
+ info.read_bytes_sec = oldinfo->read_bytes_sec;
+ info.write_bytes_sec = oldinfo->write_bytes_sec;
+ }
+ if (!set_iops) {
+ info.total_iops_sec = oldinfo->total_iops_sec;
+ info.read_iops_sec = oldinfo->read_iops_sec;
+ info.write_iops_sec = oldinfo->write_iops_sec;
+ }
priv = vm->privateData;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, &info);
qemuDomainObjExitMonitorWithDriver(driver, vm);
+ vm->def->disks[idx]->blkdeviotune = info;
if (ret < 0)
goto endjob;
}
@@ -11627,6 +11653,17 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
idx = virDomainDiskIndexByName(persistentDef, disk, true);
if (idx < 0)
goto endjob;
+ oldinfo = &persistentDef->disks[idx]->blkdeviotune;
+ if (!set_bytes) {
+ info.total_bytes_sec = oldinfo->total_bytes_sec;
+ info.read_bytes_sec = oldinfo->read_bytes_sec;
+ info.write_bytes_sec = oldinfo->write_bytes_sec;
+ }
+ if (!set_iops) {
+ info.total_iops_sec = oldinfo->total_iops_sec;
+ info.read_iops_sec = oldinfo->read_iops_sec;
+ info.write_iops_sec = oldinfo->write_iops_sec;
+ }
persistentDef->disks[idx]->blkdeviotune = info;
ret = virDomainSaveConfig(driver->configDir, persistentDef);
if (ret < 0) {
@@ -11688,7 +11725,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
goto cleanup;
}
- device = qemuDiskPathToAlias(vm, disk);
+ device = qemuDiskPathToAlias(vm, disk, NULL);
if (!device) {
goto cleanup;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index bd79b4c..a67c2eb 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -604,8 +604,9 @@ I<--total_iops_sec> specifies total I/O operations limit per second.
I<--read_iops_sec> specifies read I/O operations limit per second.
I<--write_iops_sec> specifies write I/O operations limit per second.
-When setting any value, all remaining values are reset to unlimited,
-an explicit 0 also clears any limit. A non-zero value for a given total
+Bytes and iops values are independent, but setting only one value (such
+as --read_bytes_sec) resets the other two in that category to unlimited.
+An explicit 0 also clears any limit. A non-zero value for a given total
cannot be mixed with non-zero values for read or write.
If I<--live> is specified, affect a running guest.
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] Install API XML desc to a standard location
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Language bindings may well want to use the libvirt-api.xml and
libvirt-qemu-api.xml files to either auto-generate themselves,
or sanity check the manually written bindings for completeness.
Currently these XML files are not installed as standard, merely
ending up as a %doc file in the RPM.
This changes them to be installed into $prefix/share/libvirt/apis/
The *-refs.xml files are not installed, since those are only
useful during generation of the online API doc files.
The pkg-config file is enhanced so that you cann query the install
location of the API files. eg
# pkg-config --variable=libvirt_qemu_api libvirt
/home/berrange/builder/i686-pc-mingw32/sys-root/mingw/share/libvirt/libvirt-qemu-api.xml
* docs/Makefile.am: Install libvirt-api.xml & libvirt-qemu-api.xml
* libvirt.pc.in: Add vars for querying API install location
* libvirt.spec.in, mingw32-libvirt.spec.in: Include API XML files
---
docs/Makefile.am | 3 +++
libvirt.pc.in | 3 +++
libvirt.spec.in | 4 ++++
mingw32-libvirt.spec.in | 4 ++++
4 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 5644fe2..2bef982 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -85,6 +85,9 @@ qemu_xml = \
libvirt-qemu-api.xml \
libvirt-qemu-refs.xml
+apidir = $(pkgdatadir)/api
+api_DATA = libvirt-api.xml libvirt-qemu-api.xml
+
fig = \
libvirt-net-logical.fig \
libvirt-net-physical.fig \
diff --git a/libvirt.pc.in b/libvirt.pc.in
index d7a5e55..c64a7ca 100644
--- a/libvirt.pc.in
+++ b/libvirt.pc.in
@@ -3,6 +3,9 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
+libvirt_api=@datadir(a)/libvirt/libvirt-api.xml
+libvirt_qemu_api=@datadir(a)/libvirt/libvirt-qemu-api.xml
+
Name: libvirt
Version: @VERSION@
Description: libvirt library
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 62b0ed4..d04fba9 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1249,6 +1249,10 @@ rm -f $RPM_BUILD_ROOT%{_sysconfdir}/sysctl.d/libvirtd
%doc %{_datadir}/gtk-doc/html/libvirt/*.png
%doc %{_datadir}/gtk-doc/html/libvirt/*.css
+%dir %{_datadir}/libvirt/apis/
+%{_datadir}/libvirt/apis/libvirt-api.xml
+%{_datadir}/libvirt/apis/libvirt-qemu-api.xml
+
%doc docs/*.html docs/html docs/*.gif
%doc docs/libvirt-api.xml
%doc examples/hellolibvirt
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index 7937e22..659d649 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -156,6 +156,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mingw32_libdir}/libvirt-qemu.dll.a
%{_mingw32_libdir}/libvirt-qemu.la
+%dir %{_mingw32_datadir}/libvirt/apis/
+%{_mingw32_datadir}/libvirt/apis/libvirt-api.xml
+%{_mingw32_datadir}/libvirt/apis/libvirt-qemu-api.xml
+
%dir %{_mingw32_datadir}/libvirt/
%dir %{_mingw32_datadir}/libvirt/schemas/
%{_mingw32_datadir}/libvirt/schemas/basictypes.rng
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH 0/2] add ibmvscsi and virtio-scsi controller models
by Paolo Bonzini
Hi, these patches let you specify explicitly all supported controller
models for QEMU, and add the new virtio-scsi model.
Paolo Bonzini (2):
qemu: add ibmvscsi controller model
qemu: add virtio-scsi controller model
docs/formatdomain.html.in | 4 +-
docs/schemas/domaincommon.rng | 2 +
src/conf/domain_conf.c | 4 ++-
src/conf/domain_conf.h | 2 +
src/qemu/qemu_command.c | 26 ++++++++++++++--
src/vmx/vmx.c | 10 ++++--
.../qemuxml2argv-disk-scsi-virtio-scsi.args | 9 ++++++
.../qemuxml2argv-disk-scsi-virtio-scsi.xml | 31 ++++++++++++++++++++
.../qemuxml2argv-disk-scsi-vscsi.args | 8 +++++
.../qemuxml2argv-disk-scsi-vscsi.xml | 31 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 4 ++
tests/qemuxml2xmltest.c | 2 +
12 files changed, 123 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml
--
1.7.7.1
12 years, 8 months