[libvirt] [PATCH] Fix make syntax-check from commit fba550f6
by Jim Fehlig
Add src/util/hash.c to po/POTFILES.in since it now has
translatable strings.
---
po/POTFILES.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4bd2b13..805e5ca 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -91,6 +91,7 @@ src/util/command.c
src/util/conf.c
src/util/dnsmasq.c
src/util/event_poll.c
+src/util/hash.c
src/util/hooks.c
src/util/hostusb.c
src/util/interface.c
--
1.7.3.1
13 years, 8 months
[libvirt] [PATCH] openvz: fix a simple bug in openvzListDefinedDomains()
by Jean-Baptiste Rouault
This patch adds missing curly brackets to an if
statement in openvzListDefinedDomains()
---
src/openvz/openvz_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 0d64e19..7792136 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1444,9 +1444,10 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
continue;
}
snprintf(vpsname, sizeof(vpsname), "%d", veid);
- if (!(names[got] = strdup(vpsname)))
+ if (!(names[got] = strdup(vpsname))) {
virReportOOMError();
goto out;
+ }
got ++;
}
waitpid(pid, NULL, 0);
--
1.7.0.4
13 years, 8 months
[libvirt] [PATCH v2] util: Forbid calling hash APIs from iterator callback
by Jiri Denemark
Calling most hash APIs is not safe from inside of an iterator callback.
Exceptions are APIs that do not modify the hash table and removing
current hash entry from virHashFroEach callback.
This patch make all APIs which are not safe fail instead of just relying
on the callback being nice not calling any unsafe APIs.
---
src/util/hash.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/src/util/hash.c b/src/util/hash.c
index 2a9a9cf..48a94ad 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -35,6 +35,12 @@
/* #define DEBUG_GROW */
+#define virHashIterationError(ret) \
+ do { \
+ VIR_ERROR0(_("Hash operation not allowed during iteration")); \
+ return ret; \
+ } while (0)
+
/*
* A single entry in the hash table
*/
@@ -54,6 +60,10 @@ struct _virHashTable {
struct _virHashEntry *table;
int size;
int nbElems;
+ /* True iff we are iterating over hash entries. */
+ bool iterating;
+ /* Pointer to the current entry during iteration. */
+ virHashEntryPtr current;
virHashDataFree dataFree;
virHashKeyCode keyCode;
virHashKeyEqual keyEqual;
@@ -316,6 +326,9 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
if ((table == NULL) || (name == NULL))
return (-1);
+ if (table->iterating)
+ virHashIterationError(-1);
+
/*
* Check for duplicate and insertion location.
*/
@@ -513,6 +526,8 @@ virHashRemoveEntry(virHashTablePtr table, const void *name)
for (entry = &(table->table[key]); entry != NULL;
entry = entry->next) {
if (table->keyEqual(entry->name, name)) {
+ if (table->iterating && table->current != entry)
+ virHashIterationError(-1);
if (table->dataFree && (entry->payload != NULL))
table->dataFree(entry->payload, entry->name);
entry->payload = NULL;
@@ -548,28 +563,38 @@ virHashRemoveEntry(virHashTablePtr table, const void *name)
* @data: opaque data to pass to the iterator
*
* Iterates over every element in the hash table, invoking the
- * 'iter' callback. The callback is allowed to remove the element using
- * virHashRemoveEntry but calling other virHash* functions is prohibited.
+ * 'iter' callback. The callback is allowed to remove the current element
+ * using virHashRemoveEntry but calling other virHash* functions is prohibited.
*
* Returns number of items iterated over upon completion, -1 on failure
*/
-int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data) {
+int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
+{
int i, count = 0;
if (table == NULL || iter == NULL)
return (-1);
+ if (table->iterating)
+ virHashIterationError(-1);
+
+ table->iterating = true;
+ table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
virHashEntryPtr entry = table->table + i;
while (entry) {
virHashEntryPtr next = entry->next;
if (entry->valid) {
+ table->current = entry;
iter(entry->payload, entry->name, data);
+ table->current = NULL;
count++;
}
entry = next;
}
}
+ table->iterating = false;
+
return (count);
}
@@ -593,6 +618,11 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
if (table == NULL || iter == NULL)
return (-1);
+ if (table->iterating)
+ virHashIterationError(-1);
+
+ table->iterating = true;
+ table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
virHashEntryPtr prev = NULL;
virHashEntryPtr entry = &(table->table[i]);
@@ -629,6 +659,8 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, const void *da
}
}
}
+ table->iterating = false;
+
return (count);
}
@@ -649,15 +681,24 @@ void *virHashSearch(virHashTablePtr table, virHashSearcher iter, const void *dat
if (table == NULL || iter == NULL)
return (NULL);
+ if (table->iterating)
+ virHashIterationError(NULL);
+
+ table->iterating = true;
+ table->current = NULL;
for (i = 0 ; i < table->size ; i++) {
virHashEntryPtr entry = table->table + i;
while (entry) {
if (entry->valid) {
- if (iter(entry->payload, entry->name, data))
+ if (iter(entry->payload, entry->name, data)) {
+ table->iterating = false;
return entry->payload;
+ }
}
entry = entry->next;
}
}
+ table->iterating = false;
+
return (NULL);
}
--
1.7.4.1
13 years, 8 months
[libvirt] [PATCH] Add PCI sysfs reset access
by Alex Williamson
I'm proposing we make use of $PCIDIR/reset in qemu-kvm to reset
devices on VM reset. We need to add it to libvirt's list of
files that get ownership for device assignment.
Signed-off-by: Alex Williamson <alex.williamson(a)redhat.com>
---
src/util/pci.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/pci.c b/src/util/pci.c
index 095ad3f..8d2dbb0 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1349,11 +1349,13 @@ int pciDeviceFileIterate(pciDevice *dev,
while ((ent = readdir(dir)) != NULL) {
/* Device assignment requires:
- * $PCIDIR/config, $PCIDIR/resource, $PCIDIR/resourceNNN, $PCIDIR/rom
+ * $PCIDIR/config, $PCIDIR/resource, $PCIDIR/resourceNNN,
+ * $PCIDIR/rom, $PCIDIR/reset
*/
if (STREQ(ent->d_name, "config") ||
STRPREFIX(ent->d_name, "resource") ||
- STREQ(ent->d_name, "rom")) {
+ STREQ(ent->d_name, "rom") ||
+ STREQ(ent->d_name, "reset")) {
if (virAsprintf(&file, "%s/%s", pcidir, ent->d_name) < 0) {
virReportOOMError();
goto cleanup;
13 years, 8 months
[libvirt] [PATCH 0/2] Last debug buffer patches: locking and docs
by Daniel Veillard
That's the remaining changes left for the debug buffer.
The first patch is the one removing locking in the signal
error handler. As discussed it's better to have a risk of
slightly corrupted output in the log dump than have a risk
crashing due to the unsafe locking operations in the
signal handler.
The second patch documents the debug buffer changes and
improve the logging page to add more structure, and more
examples.
Daniel
13 years, 8 months
[libvirt] [PATCH] do not unref obj in qemuDomainObjExitMonitorWithDriver
by Wen Congyang
Steps to reproduce this bug:
# cat test.sh
#! /bin/bash -x
virsh start domain
sleep 5
virsh qemu-monitor-command domain 'cpu_set 2 online' --hmp
# while true; do ./test.sh ; done
Then libvirtd will crash.
The reason is that:
we add a reference of obj when we open the monitor. We will reduce this
reference when we free the monitor.
If the reference of monitor is 0, we will free monitor automatically and
the reference of obj is reduced.
But in the function qemuDomainObjExitMonitorWithDriver(), we reduce this
reference again when the reference of monitor is 0.
It will cause the obj be freed in the function qemuDomainObjEndJob().
Then we start the domain again, and libvirtd will crash in the function
virDomainObjListSearchName(), because we pass a null pointer(obj->def->name)
to strcmp().
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
src/qemu/qemu_domain.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8a2b9cc..ae28b1c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -634,7 +634,6 @@ void qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver,
virDomainObjLock(obj);
if (refs == 0) {
- virDomainObjUnref(obj);
priv->mon = NULL;
}
}
--
1.7.1
13 years, 8 months
[libvirt] [PATCH] check driver name while attaching disk
by Wen Congyang
This bug was reported by Shi Jin(jinzishuai(a)gmail.com):
=============
# virsh attach-disk RHEL6RC /var/lib/libvirt/images/test3.img vdb --driver file --subdriver qcow2
Disk attached successfully
# virsh save RHEL6RC /var/lib/libvirt/images/memory.save
Domain RHEL6RC saved to /var/lib/libvirt/images/memory.save
# virsh restore /var/lib/libvirt/images/memory.save
error: Failed to restore domain from /var/lib/libvirt/images/memory.save
error: internal error unsupported driver name 'file' for disk '/var/lib/libvirt/images/test3.img'
=============
We have checked the driver name when we start or restore VM, but we do not check it while attaching
a disk.
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
src/qemu/qemu_driver.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2892dfe..e94080d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3994,6 +3994,14 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
goto endjob;
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+ if (dev->data.disk->driverName != NULL &&
+ !STREQ(dev->data.disk->driverName, "qemu")) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unsupported driver name '%s' for disk '%s'"),
+ dev->data.disk->driverName, dev->data.disk->src);
+ goto endjob;
+ }
+
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_DEVICES)) {
if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) !=0 ) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
--
1.7.1
13 years, 8 months
[libvirt] xen:/// vs. xen://FQDN/ vs xen+unix:/// discrepancy
by Philipp Hahn
Hello,
I regularly observe the problem, that depending on the libvirt-URL I get
different information:
root@xen4# virsh -c xen://xen4.domain.name/ list
Id Name State
----------------------------------
root@xen4# virsh -c xen:/// list
Id Name State
----------------------------------
0 Domain-0 running
1 dos4 idle
root@xen4# virsh -c xen+unix:/// list
Id Name State
----------------------------------
root@xen4# xm li
Name ID Mem VCPUs State
Time(s)
Domain-0 0 2044 2 r----- 419.7
dos4 1 4 1 -b---- 33.4
Has somebody observed the same problem and/or can give me any advise on where
to look for the problem?
I'm running a Debian-Lenny based OS with libvirt-0.8.2 on Xen-3.4.3 with a
2.6.32 kernel.
Sincerely
Philipp Hahn
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 28359 Bremen fax: +49 421 22 232-99
http://www.univention.de
13 years, 8 months
[libvirt] [PATCH] Add vim configuration that makes vim auto-indent code
by Hu Tao
---
.lvimrc | 10 ++++++++++
HACKING | 5 +++++
2 files changed, 15 insertions(+), 0 deletions(-)
create mode 100644 .lvimrc
diff --git a/.lvimrc b/.lvimrc
new file mode 100644
index 0000000..3a732ce
--- /dev/null
+++ b/.lvimrc
@@ -0,0 +1,10 @@
+set nocompatible
+filetype on
+set autoindent
+set smartindent
+set cindent
+set tabstop=4
+set shiftwidth=4
+set expandtab
+set cinoptions=(0,:0,l1,t0
+filetype plugin indent on
diff --git a/HACKING b/HACKING
index 4a71b37..adfb7ae 100644
--- a/HACKING
+++ b/HACKING
@@ -87,6 +87,11 @@ If you use Emacs, add the following to one of one of your start-up files
'(lambda () (if (string-match "/libvirt" (buffer-file-name))
(libvirt-c-mode))))
+If you use vim, install vim script at this page:
+http://www.vim.org/scripts/script.php?script_id=1408
+it will auto load .lvimrc at the root of libvirt source only when you're
+editing libvirt's code. Or you can append the contents of .lvimrc to you
+.vimrc file.
Code formatting (especially for new code)
=========================================
--
1.7.3.1
13 years, 8 months
[libvirt] [PATCH] virsh: fix memtune's help message for swap_hard_limit
by KAMEZAWA Hiroyuki
I found this when I used virsh memtune...
BTW, how to fix http://libvirt.org/formatdomain.html 's memtune description ?
==
>From 541ae04430f376e8168b413a20b35dce49779816 Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
Date: Thu, 3 Mar 2011 14:24:45 +0900
Subject: [PATCH 6/6] fix virsh commands' message for memtune'swap_hard_limit.
cgroup's /cgroup/memory/memory.memsw.limit_in_bytes is not
for limitinit 'swap' but for 'memory+swap' (then, it's memsw)
(So, this number cannot be smaller than memory.limit_in_bytes)
Note:
If other hypervisors than Linux support this and meaning is
not same as memory+swap, the name swap_hard_limit will have confusion.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
---
tools/virsh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 62fca17..3a8fdaa 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3033,7 +3033,7 @@ static const vshCmdOptDef opts_memtune[] = {
{"soft-limit", VSH_OT_INT, VSH_OFLAG_NONE,
N_("Memory during contention in kilobytes")},
{"swap-hard-limit", VSH_OT_INT, VSH_OFLAG_NONE,
- N_("Max swap in kilobytes")},
+ N_("Max memory+swap in kilobytes")},
{"min-guarantee", VSH_OT_INT, VSH_OFLAG_NONE,
N_("Min guaranteed memory in kilobytes")},
{NULL, 0, 0, NULL}
--
1.7.4.1
13 years, 8 months