[libvirt] [PATCH] util: honor anchored names when searching for executables
by Eric Blake
I got bit in a debugging session on an uninstalled libvirtd; the
code tried to call out to the installed $LIBEXECDIR/libvirt_iohelper
instead of my just-built version. So I set a breakpoint and altered
the binary name to be "./src/libvirt_iohelper", and it still failed
because I don't have "." on my PATH.
According to POSIX, execvp only searches PATH if the name does
not contain a slash. Since we are trying to mimic that behavior,
an anchored name should be relative to the current working dir.
* src/util/util.c (virFindFileInPath): Anchored relative names do
not invoke a PATH search.
---
src/util/util.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 1441c51..20ccfa7 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -596,6 +596,14 @@ char *virFindFileInPath(const char *file)
return NULL;
}
+ /* If we are passed an anchored path (containing a /), then there
+ * is no path search - it must exist in the current directory
+ */
+ if (strchr(file, '/')) {
+ virFileAbsPath(file, &path);
+ return path;
+ }
+
/* copy PATH env so we can tweak it */
path = getenv("PATH");
--
1.7.4.4
13 years, 4 months
[libvirt] [libvirt-qpid PATCH 0/3] Conversion of libvirt-qpid to matahari
by Zane Bitter
The following series converts libvirt-qpid into a matahari agent using the
QMFv2 APIs.
Since the patches are rather large, I have also pushed them to GitHub for
easier reviewing:
https://github.com/zaneb/libvirt-qpid/commits/review
Any and all comments are welcome.
thanks,
Zane.
---
Zane Bitter (3):
Convert to QMFv2 APIs
Convert class names to lower case
Make libvirt-qpid a matahari agent
AUTHORS | 4
configure.ac | 1
libvirt-qpid.spec | 6
src/DomainWrap.cpp | 444 ++++++++++++++++++---------------
src/DomainWrap.h | 49 +---
src/Error.h | 8 +
src/Exception.cpp | 38 +++
src/Exception.h | 30 ++
src/LibvirtAgent.cpp | 97 +++++++
src/LibvirtAgent.h | 36 +++
src/Makefile.am | 34 +--
src/ManagedObject.h | 78 ++++++
src/NodeWrap.cpp | 643 ++++++++++++++++++++----------------------------
src/NodeWrap.h | 64 ++---
src/PoolWrap.cpp | 365 +++++++++++++++------------
src/PoolWrap.h | 60 ++--
src/VolumeWrap.cpp | 153 ++++++-----
src/VolumeWrap.h | 58 +---
src/libvirt-schema.xml | 8 -
19 files changed, 1198 insertions(+), 978 deletions(-)
create mode 100644 src/Exception.cpp
create mode 100644 src/Exception.h
create mode 100644 src/LibvirtAgent.cpp
create mode 100644 src/LibvirtAgent.h
create mode 100644 src/ManagedObject.h
13 years, 4 months
[libvirt] [PATCH] Add domain events support to UML driver
by Daniel P. Berrange
* src/uml_conf.h: Add queue for dispatch of domain events
* src/uml_driver.c: Trigger domain events upon important lifecycle transitions
---
src/uml/uml_conf.h | 4 +
src/uml/uml_driver.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 194 insertions(+), 4 deletions(-)
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
index 1105f84..5401a7e 100644
--- a/src/uml/uml_conf.h
+++ b/src/uml/uml_conf.h
@@ -29,6 +29,7 @@
# include "capabilities.h"
# include "network_conf.h"
# include "domain_conf.h"
+# include "domain_event.h"
# include "virterror_internal.h"
# include "threads.h"
# include "command.h"
@@ -60,6 +61,9 @@ struct uml_driver {
int inotifyWatch;
virCapsPtr caps;
+
+ /* Event handling */
+ virDomainEventStatePtr domainEventState;
};
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 91591f1..d0736df 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -113,6 +113,9 @@ static int umlOpenMonitor(struct uml_driver *driver,
virDomainObjPtr vm);
static int umlReadPidFile(struct uml_driver *driver,
virDomainObjPtr vm);
+static void umlDomainEventFlush(int timer, void *opaque);
+static void umlDomainEventQueue(struct uml_driver *driver,
+ virDomainEventPtr event);
static int umlSetCloseExec(int fd) {
int flags;
@@ -166,6 +169,13 @@ umlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaqu
virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
vm->def->name, err ? err->message : _("unknown error"));
+ } else {
+ virDomainEventPtr event =
+ virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_STARTED,
+ VIR_DOMAIN_EVENT_STARTED_BOOTED);
+ if (event)
+ umlDomainEventQueue(data->driver, event);
}
}
virDomainObjUnlock(vm);
@@ -185,7 +195,9 @@ umlAutostartConfigs(struct uml_driver *driver) {
struct umlAutostartData data = { driver, conn };
+ umlDriverLock(driver);
virHashForEach(driver->domains.objs, umlAutostartDomain, &data);
+ umlDriverUnlock(driver);
if (conn)
virConnectClose(conn);
@@ -266,6 +278,7 @@ umlInotifyEvent(int watch,
char *tmp, *name;
struct uml_driver *driver = data;
virDomainObjPtr dom;
+ virDomainEventPtr event = NULL;
umlDriverLock(driver);
if (watch != driver->inotifyWatch)
@@ -311,6 +324,9 @@ reread:
umlShutdownVMDaemon(NULL, driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
virDomainAuditStop(dom, "shutdown");
+ event = virDomainEventNewFromObj(dom,
+ VIR_DOMAIN_EVENT_STOPPED,
+ VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
if (!dom->persistent) {
virDomainRemoveInactive(&driver->domains,
dom);
@@ -337,6 +353,9 @@ reread:
umlShutdownVMDaemon(NULL, driver, dom,
VIR_DOMAIN_SHUTOFF_FAILED);
virDomainAuditStop(dom, "failed");
+ event = virDomainEventNewFromObj(dom,
+ VIR_DOMAIN_EVENT_STOPPED,
+ VIR_DOMAIN_EVENT_STOPPED_FAILED);
if (!dom->persistent) {
virDomainRemoveInactive(&driver->domains,
dom);
@@ -347,6 +366,9 @@ reread:
umlShutdownVMDaemon(NULL, driver, dom,
VIR_DOMAIN_SHUTOFF_FAILED);
virDomainAuditStop(dom, "failed");
+ event = virDomainEventNewFromObj(dom,
+ VIR_DOMAIN_EVENT_STOPPED,
+ VIR_DOMAIN_EVENT_STOPPED_FAILED);
if (!dom->persistent) {
virDomainRemoveInactive(&driver->domains,
dom);
@@ -359,6 +381,8 @@ reread:
}
cleanup:
+ if (event)
+ umlDomainEventQueue(driver, event);
umlDriverUnlock(driver);
}
@@ -392,6 +416,13 @@ umlStartup(int privileged)
if (virDomainObjListInit(¨_driver->domains) < 0)
goto error;
+ uml_driver->domainEventState = virDomainEventStateNew(umlDomainEventFlush,
+ uml_driver,
+ NULL,
+ true);
+ if (!uml_driver->domainEventState)
+ goto error;
+
userdir = virGetUserDirectory(uid);
if (!userdir)
goto error;
@@ -469,9 +500,10 @@ umlStartup(int privileged)
0, NULL, NULL) < 0)
goto error;
+ umlDriverUnlock(uml_driver);
+
umlAutostartConfigs(uml_driver);
- umlDriverUnlock(uml_driver);
VIR_FREE(userdir);
return 0;
@@ -487,6 +519,21 @@ error:
return -1;
}
+static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
+{
+ struct uml_driver *driver = opaque;
+
+ if (newVM) {
+ virDomainEventPtr event =
+ virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_DEFINED,
+ VIR_DOMAIN_EVENT_DEFINED_ADDED);
+ if (event)
+ umlDomainEventQueue(driver, event);
+ }
+}
+
+
/**
* umlReload:
*
@@ -503,10 +550,10 @@ umlReload(void) {
¨_driver->domains,
uml_driver->configDir,
uml_driver->autostartDir,
- 0, NULL, NULL);
+ 0, umlNotifyLoadDomain, uml_driver);
+ umlDriverUnlock(uml_driver);
umlAutostartConfigs(uml_driver);
- umlDriverUnlock(uml_driver);
return 0;
}
@@ -569,6 +616,8 @@ umlShutdown(void) {
virDomainObjListDeinit(¨_driver->domains);
+ virDomainEventStateFree(uml_driver->domainEventState);
+
VIR_FREE(uml_driver->logDir);
VIR_FREE(uml_driver->configDir);
VIR_FREE(uml_driver->autostartDir);
@@ -929,6 +978,7 @@ cleanup:
/* XXX what if someone else tries to start it again
before we get the inotification ? Sounds like
trouble.... */
+ /* XXX this is bad for events too. must fix this better */
return ret;
}
@@ -1025,7 +1075,12 @@ static virDrvOpenStatus umlOpen(virConnectPtr conn,
}
static int umlClose(virConnectPtr conn) {
- /*struct uml_driver *driver = conn->privateData;*/
+ struct uml_driver *driver = conn->privateData;
+
+ umlDriverLock(driver);
+ virDomainEventCallbackListRemoveConn(conn,
+ driver->domainEventState->callbacks);
+ umlDriverUnlock(driver);
conn->privateData = NULL;
@@ -1293,6 +1348,7 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
virDomainDefPtr def;
virDomainObjPtr vm = NULL;
virDomainPtr dom = NULL;
+ virDomainEventPtr event = NULL;
virCheckFlags(0, NULL);
@@ -1318,6 +1374,9 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
goto cleanup;
}
virDomainAuditStart(vm, "booted", true);
+ event = virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_STARTED,
+ VIR_DOMAIN_EVENT_STARTED_BOOTED);
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
if (dom) dom->id = vm->def->id;
@@ -1326,6 +1385,8 @@ cleanup:
virDomainDefFree(def);
if (vm)
virDomainObjUnlock(vm);
+ if (event)
+ umlDomainEventQueue(driver, event);
umlDriverUnlock(driver);
return dom;
}
@@ -1366,6 +1427,7 @@ cleanup:
static int umlDomainDestroy(virDomainPtr dom) {
struct uml_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
+ virDomainEventPtr event = NULL;
int ret = -1;
umlDriverLock(driver);
@@ -1378,6 +1440,9 @@ static int umlDomainDestroy(virDomainPtr dom) {
umlShutdownVMDaemon(dom->conn, driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
virDomainAuditStop(vm, "destroyed");
+ event = virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_STOPPED,
+ VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
if (!vm->persistent) {
virDomainRemoveInactive(&driver->domains,
vm);
@@ -1388,6 +1453,8 @@ static int umlDomainDestroy(virDomainPtr dom) {
cleanup:
if (vm)
virDomainObjUnlock(vm);
+ if (event)
+ umlDomainEventQueue(driver, event);
umlDriverUnlock(driver);
return ret;
}
@@ -1640,6 +1707,7 @@ static int umlNumDefinedDomains(virConnectPtr conn) {
static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) {
struct uml_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
+ virDomainEventPtr event = NULL;
int ret = -1;
virCheckFlags(0, -1);
@@ -1655,10 +1723,16 @@ static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) {
ret = umlStartVMDaemon(dom->conn, driver, vm);
virDomainAuditStart(vm, "booted", ret >= 0);
+ if (ret == 0)
+ event = virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_STARTED,
+ VIR_DOMAIN_EVENT_STARTED_BOOTED);
cleanup:
if (vm)
virDomainObjUnlock(vm);
+ if (event)
+ umlDomainEventQueue(driver, event);
umlDriverUnlock(driver);
return ret;
}
@@ -2208,6 +2282,114 @@ cleanup:
}
+static int
+umlDomainEventRegister(virConnectPtr conn,
+ virConnectDomainEventCallback callback,
+ void *opaque,
+ virFreeCallback freecb)
+{
+ struct uml_driver *driver = conn->privateData;
+ int ret;
+
+ umlDriverLock(driver);
+ ret = virDomainEventCallbackListAdd(conn,
+ driver->domainEventState->callbacks,
+ callback, opaque, freecb);
+ umlDriverUnlock(driver);
+
+ return ret;
+}
+
+static int
+umlDomainEventDeregister(virConnectPtr conn,
+ virConnectDomainEventCallback callback)
+{
+ struct uml_driver *driver = conn->privateData;
+ int ret;
+
+ umlDriverLock(driver);
+ ret = virDomainEventStateDeregister(conn,
+ driver->domainEventState,
+ callback);
+ umlDriverUnlock(driver);
+
+ return ret;
+}
+static int
+umlDomainEventRegisterAny(virConnectPtr conn,
+ virDomainPtr dom,
+ int eventID,
+ virConnectDomainEventGenericCallback callback,
+ void *opaque,
+ virFreeCallback freecb)
+{
+ struct uml_driver *driver = conn->privateData;
+ int ret;
+
+ umlDriverLock(driver);
+ ret = virDomainEventCallbackListAddID(conn,
+ driver->domainEventState->callbacks,
+ dom, eventID,
+ callback, opaque, freecb);
+ umlDriverUnlock(driver);
+
+ return ret;
+}
+
+
+static int
+umlDomainEventDeregisterAny(virConnectPtr conn,
+ int callbackID)
+{
+ struct uml_driver *driver = conn->privateData;
+ int ret;
+
+ umlDriverLock(driver);
+ ret = virDomainEventStateDeregisterAny(conn,
+ driver->domainEventState,
+ callbackID);
+ umlDriverUnlock(driver);
+
+ return ret;
+}
+
+
+static void umlDomainEventDispatchFunc(virConnectPtr conn,
+ virDomainEventPtr event,
+ virConnectDomainEventGenericCallback cb,
+ void *cbopaque,
+ void *opaque)
+{
+ struct uml_driver *driver = opaque;
+
+ /* Drop the lock whle dispatching, for sake of re-entrancy */
+ umlDriverUnlock(driver);
+ virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
+ umlDriverLock(driver);
+}
+
+
+static void umlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
+{
+ struct uml_driver *driver = opaque;
+
+ umlDriverLock(driver);
+ virDomainEventStateFlush(driver->domainEventState,
+ umlDomainEventDispatchFunc,
+ driver);
+ umlDriverUnlock(driver);
+}
+
+
+/* driver must be locked before calling */
+static void umlDomainEventQueue(struct uml_driver *driver,
+ virDomainEventPtr event)
+{
+ virDomainEventStateQueue(driver->domainEventState, event);
+}
+
+
+
static virDriver umlDriver = {
.no = VIR_DRV_UML,
.name = "UML",
@@ -2250,11 +2432,15 @@ static virDriver umlDriver = {
.nodeGetMemoryStats = nodeGetMemoryStats, /* 0.9.3 */
.nodeGetCellsFreeMemory = nodeGetCellsFreeMemory, /* 0.5.0 */
.nodeGetFreeMemory = nodeGetFreeMemory, /* 0.5.0 */
+ .domainEventRegister = umlDomainEventRegister, /* 0.9.4 */
+ .domainEventDeregister = umlDomainEventDeregister, /* 0.9.4 */
.isEncrypted = umlIsEncrypted, /* 0.7.3 */
.isSecure = umlIsSecure, /* 0.7.3 */
.domainIsActive = umlDomainIsActive, /* 0.7.3 */
.domainIsPersistent = umlDomainIsPersistent, /* 0.7.3 */
.domainIsUpdated = umlDomainIsUpdated, /* 0.8.6 */
+ .domainEventRegisterAny = umlDomainEventRegisterAny, /* 0.9.4 */
+ .domainEventDeregisterAny = umlDomainEventDeregisterAny, /* 0.9.4 */
.domainOpenConsole = umlDomainOpenConsole, /* 0.8.6 */
};
--
1.7.4.4
13 years, 4 months
[libvirt] [PATCH 1/3] add --cache option for attach-disk
by Hu Tao
Add --cache option to allow user to specify cache mode of disk device
from virsh command line when attaching a disk device.
---
tools/virsh.c | 10 ++++++++--
tools/virsh.pod | 5 +++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 9a189fd..cab5a35 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10176,6 +10176,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
{"target", VSH_OT_DATA, VSH_OFLAG_REQ, N_("target of disk device")},
{"driver", VSH_OT_STRING, 0, N_("driver of disk device")},
{"subdriver", VSH_OT_STRING, 0, N_("subdriver of disk device")},
+ {"cache", VSH_OT_STRING, 0, N_("cache mode of disk device")},
{"type", VSH_OT_STRING, 0, N_("target device type")},
{"mode", VSH_OT_STRING, 0, N_("mode of device reading and writing")},
{"persistent", VSH_OT_BOOL, 0, N_("persist disk attachment")},
@@ -10188,7 +10189,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
const char *source = NULL, *target = NULL, *driver = NULL,
- *subdriver = NULL, *type = NULL, *mode = NULL;
+ *subdriver = NULL, *type = NULL, *mode = NULL,
+ *cache = NULL;
bool isFile = false, functionReturn = false;
int ret;
unsigned int flags;
@@ -10217,6 +10219,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
+ ignore_value(vshCommandOptString(cmd, "cache", &cache));
+
if (!stype) {
if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
isFile = true;
@@ -10249,8 +10253,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAsprintf(&buf, " name='%s'", driver);
if (subdriver)
virBufferAsprintf(&buf, " type='%s'", subdriver);
+ if (cache)
+ virBufferAsprintf(&buf, " cache='%s'", cache);
- if (driver || subdriver)
+ if (driver || subdriver || cache)
virBufferAddLit(&buf, "/>\n");
virBufferAsprintf(&buf, " <source %s='%s'/>\n",
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 736b919..79f49ba 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -874,8 +874,8 @@ For cdrom and floppy devices, this command only replaces the media within
the single existing device; consider using B<update-device> for this usage.
=item B<attach-disk> I<domain-id> I<source> I<target> optional
-I<--driver driver> I<--subdriver subdriver> I<--type type>
-I<--mode mode> I<--persistent> I<--sourcetype soucetype>
+I<--driver driver> I<--subdriver subdriver> I<--cache cache>
+I<--type type> I<--mode mode> I<--persistent> I<--sourcetype soucetype>
Attach a new disk device to the domain.
I<source> and I<target> are paths for the files and devices.
@@ -886,6 +886,7 @@ floppy device; consider using B<update-device> for this usage instead.
I<mode> can specify the two specific mode I<readonly> or I<shareable>.
I<persistent> indicates the changes will affect the next boot of the domain.
I<sourcetype> can indicate the type of source (block|file)
+I<cache> can be one of "default", "none", "writethrough" or "writeback".
=item B<attach-interface> I<domain-id> I<type> I<source> optional
I<--target target> I<--mac mac> I<--script script> I<--model model>
--
1.7.5.1
13 years, 4 months
[libvirt] [Question] qemu cpu pinning
by KAMEZAWA Hiroyuki
Hi,
When I run a VM(qemu-0.13) on my host with the latest libvirt,
I used following settings.
==
<domain type='kvm' id='1'>
<name>RHEL6</name>
<uuid>f7ad6bc3-e82a-1254-efb0-9e1a87d83d88</uuid>
<memory>2048000</memory>
<currentMemory>2048000</currentMemory>
<vcpu cpuset='4-7'>2</vcpu>
==
I expected all works for this domain will be tied to cpu 4-7.
After minites, I checked the VM behavior and it shows
==
[root@bluextal src]# cat /cgroup/cpuacct/libvirt/qemu/RHEL6/cpuacct.usage_percpu
0 511342 3027636 94237 657712515 257104928 513463748303 252386161
==
Hmm, cpu 1,2,3 are used for some purpose.
All threads for this qemu may be following.
==
[root@bluextal src]# cat /cgroup/cpuacct/libvirt/qemu/RHEL6/tasks
25707
25727
25728
25729
==
And I found
==
[root@bluextal src]# grep Cpus /proc/25707/status
Cpus_allowed: f0
Cpus_allowed_list: 4-7
[root@bluextal src]# grep Cpus /proc/25727/status
Cpus_allowed: ff
Cpus_allowed_list: 0-7
[root@bluextal src]# grep Cpus /proc/25728/status
Cpus_allowed: f0
Cpus_allowed_list: 4-7
[root@bluextal src]# grep Cpus /proc/25729/status
Cpus_allowed: f0
Cpus_allowed_list: 4-7
==
Thread 25727 has no limitation.
Is this an expected behavior and I need more setting in XML definition ?
Thanks,
-Kame
13 years, 4 months
[libvirt] [PATCH] command: avoid leaking fds across fork
by Eric Blake
Since libvirt is multi-threaded, we should use FD_CLOEXEC as much
as possible in the parent, and only relax fds to inherited after
forking, to avoid leaking an fd created in one thread to a fork
run in another thread. This gets us closer to that ideal, by
making virCommand automatically clear FD_CLOEXEC on fds intended
for the child, as well as avoiding a window of time with non-cloexec
pipes created for capturing output.
* src/util/command.c (virExecWithHook): Use CLOEXEC in parent. In
child, guarantee that all fds to pass to child are inheritable.
(getDevNull): Use CLOEXEC.
(prepareStdFd): New helper function.
* src/qemu/qemu_command.c (qemuBuildCommandLine): Simplify caller.
---
src/qemu/qemu_command.c | 16 --------------
src/util/command.c | 51 ++++++++++++++++++++++++-----------------------
2 files changed, 26 insertions(+), 41 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a3bce4a..ee706f9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4575,14 +4575,6 @@ qemuBuildCommandLine(virConnectPtr conn,
} else if (STREQ(migrateFrom, "stdio")) {
if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD)) {
virCommandAddArgFormat(cmd, "fd:%d", migrateFd);
- /* migrateFd might be cloexec, but qemu must inherit
- * it if vmop indicates qemu will be executed */
- if (vmop != VIR_VM_OP_NO_OP &&
- virSetInherit(migrateFd, true) < 0) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to clear cloexec flag"));
- goto error;
- }
virCommandPreserveFD(cmd, migrateFd);
} else if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
virCommandAddArg(cmd, "exec:cat");
@@ -4612,14 +4604,6 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
virCommandAddArg(cmd, migrateFrom);
- /* migrateFd might be cloexec, but qemu must inherit
- * it if vmop indicates qemu will be executed */
- if (vmop != VIR_VM_OP_NO_OP &&
- virSetInherit(migrateFd, true) < 0) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to clear cloexec flag"));
- goto error;
- }
virCommandPreserveFD(cmd, migrateFd);
} else if (STRPREFIX(migrateFrom, "unix")) {
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX)) {
diff --git a/src/util/command.c b/src/util/command.c
index 83d4e88..e4cf389 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -257,7 +257,7 @@ cleanup:
static int
getDevNull(int *null)
{
- if (*null == -1 && (*null = open("/dev/null", O_RDWR)) < 0) {
+ if (*null == -1 && (*null = open("/dev/null", O_RDWR|O_CLOEXEC)) < 0) {
virReportSystemError(errno,
_("cannot open %s"),
"/dev/null");
@@ -266,6 +266,18 @@ getDevNull(int *null)
return 0;
}
+/* Ensure that STD is an inheritable copy of FD. Return 0 on success,
+ * -1 on failure. */
+static int
+prepareStdFd(int fd, int std)
+{
+ if (fd == std)
+ return virSetInherit(fd, true);
+ if (dup2(fd, std) != std)
+ return -1;
+ return 0;
+}
+
/*
* @argv argv to exec
* @envp optional environment to use for exec
@@ -325,7 +337,7 @@ virExecWithHook(const char *const*argv,
if (outfd != NULL) {
if (*outfd == -1) {
- if (pipe(pipeout) < 0) {
+ if (pipe2(pipeout, O_CLOEXEC) < 0) {
virReportSystemError(errno,
"%s", _("cannot create pipe"));
goto cleanup;
@@ -338,12 +350,6 @@ virExecWithHook(const char *const*argv,
goto cleanup;
}
- if (virSetCloseExec(pipeout[0]) == -1) {
- virReportSystemError(errno,
- "%s", _("Failed to set close-on-exec file descriptor flag"));
- goto cleanup;
- }
-
childout = pipeout[1];
} else {
childout = *outfd;
@@ -356,7 +362,7 @@ virExecWithHook(const char *const*argv,
if (errfd != NULL) {
if (*errfd == -1) {
- if (pipe(pipeerr) < 0) {
+ if (pipe2(pipeerr, O_CLOEXEC) < 0) {
virReportSystemError(errno,
"%s", _("Failed to create pipe"));
goto cleanup;
@@ -369,12 +375,6 @@ virExecWithHook(const char *const*argv,
goto cleanup;
}
- if (virSetCloseExec(pipeerr[0]) == -1) {
- virReportSystemError(errno,
- "%s", _("Failed to set close-on-exec file descriptor flag"));
- goto cleanup;
- }
-
childerr = pipeerr[1];
} else {
childerr = *errfd;
@@ -424,28 +424,29 @@ virExecWithHook(const char *const*argv,
}
openmax = sysconf(_SC_OPEN_MAX);
- for (i = 3; i < openmax; i++)
- if (i != infd &&
- i != childout &&
- i != childerr &&
- (!keepfd || i >= FD_SETSIZE || !FD_ISSET(i, keepfd))) {
+ for (i = 3; i < openmax; i++) {
+ if (i == infd || i == childout || i == childerr)
+ continue;
+ if (!keepfd || i >= FD_SETSIZE || !FD_ISSET(i, keepfd)) {
tmpfd = i;
VIR_FORCE_CLOSE(tmpfd);
+ } else if (virSetInherit(i, true) < 0) {
+ virReportSystemError(errno, _("failed to preserve fd %d"), i);
+ goto fork_error;
}
+ }
- if (dup2(infd, STDIN_FILENO) < 0) {
+ if (prepareStdFd(infd, STDIN_FILENO) < 0) {
virReportSystemError(errno,
"%s", _("failed to setup stdin file handle"));
goto fork_error;
}
- if (childout > 0 &&
- dup2(childout, STDOUT_FILENO) < 0) {
+ if (childout > 0 && prepareStdFd(childout, STDOUT_FILENO) < 0) {
virReportSystemError(errno,
"%s", _("failed to setup stdout file handle"));
goto fork_error;
}
- if (childerr > 0 &&
- dup2(childerr, STDERR_FILENO) < 0) {
+ if (childerr > 0 && prepareStdFd(childerr, STDERR_FILENO) < 0) {
virReportSystemError(errno,
"%s", _("failed to setup stderr file handle"));
goto fork_error;
--
1.7.4.4
13 years, 4 months
[libvirt] [libvirt-qpid PATCH 0/3] Conversion of libvirt-qpid to matahari
by Zane Bitter
The following series converts libvirt-qpid into a matahari agent using the
QMFv2 APIs.
Since the patches are rather large, I have also pushed them to GitHub for
easier reviewing:
https://github.com/zaneb/libvirt-qpid/commits/review
Any and all comments are welcome.
thanks,
Zane.
---
Zane Bitter (3):
Convert to QMFv2 APIs
Convert class names to lower case
Make libvirt-qpid a matahari agent
AUTHORS | 4
configure.ac | 1
libvirt-qpid.spec | 6
src/DomainWrap.cpp | 444 ++++++++++++++++++---------------
src/DomainWrap.h | 49 +---
src/Error.h | 8 +
src/Exception.cpp | 38 +++
src/Exception.h | 30 ++
src/LibvirtAgent.cpp | 97 +++++++
src/LibvirtAgent.h | 36 +++
src/Makefile.am | 34 +--
src/ManagedObject.h | 78 ++++++
src/NodeWrap.cpp | 643 ++++++++++++++++++++----------------------------
src/NodeWrap.h | 64 ++---
src/PoolWrap.cpp | 365 +++++++++++++++------------
src/PoolWrap.h | 60 ++--
src/VolumeWrap.cpp | 153 ++++++-----
src/VolumeWrap.h | 58 +---
src/libvirt-schema.xml | 8 -
19 files changed, 1198 insertions(+), 978 deletions(-)
create mode 100644 src/Exception.cpp
create mode 100644 src/Exception.h
create mode 100644 src/LibvirtAgent.cpp
create mode 100644 src/LibvirtAgent.h
create mode 100644 src/ManagedObject.h
13 years, 4 months
[libvirt] [PATCH] build: avoid incremental 'make syntax-check' failure
by Eric Blake
Incrementally running 'make syntax-check' on a tree previously
built after commit 62dee6f but before 44036460 fails sc_po_check
(because the generated qemu_dispatch.h gained translatable strings).
This is a followup to commit addaa537 for that scenario.
* cfg.mk (sc_po_check): Add another prereq.
($(srcdir)/daemon/qemu_dispatch.h): Add rule.
---
Pushing under the build-breaker rule.
cfg.mk | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index b00cda3..5178a31 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -606,11 +606,15 @@ _autogen:
syntax-check: $(top_srcdir)/HACKING
# sc_po_check can fail if generated files are not built first
-sc_po_check: $(srcdir)/daemon/remote_dispatch.h \
+sc_po_check: \
+ $(srcdir)/daemon/remote_dispatch.h \
+ $(srcdir)/daemon/qemu_dispatch.h \
$(srcdir)/src/remote/remote_client_bodies.h
-$(srcdir)/daemon/remote_dispatch.h:
+$(srcdir)/daemon/remote_dispatch.h: $(srcdir)/src/remote/remote_protocol.x
$(MAKE) -C daemon remote_dispatch.h
-$(srcdir)/src/remote/remote_client_bodies.h:
+$(srcdir)/daemon/qemu_dispatch.h: $(srcdir)/src/remote/qemu_protocol.x
+ $(MAKE) -C daemon qemu_dispatch.h
+$(srcdir)/src/remote/remote_client_bodies.h: $(srcdir)/src/remote/remote_protocol.x
$(MAKE) -C src remote/remote_client_bodies.h
# List all syntax-check exemptions:
--
1.7.4.4
13 years, 4 months
[libvirt] [PATCH] Remove unused macros and enable -Wunused-macros
by Daniel P. Berrange
I'm only 80% convinced that this patch is a good idea
because in some cases I'm not entirely happy about
commenting out macros that may well be used in the near
future. On the plus side it has identified a reasonable
number of unused legacy crufty macros
This enables the -Wunused-macros GCC flag to identify
historical macros which are no longer used due to
code refactoring.
* m4/virt-compile-warnings.m4: Enable -Wunused-macros
* daemon/libvirtd.c: Remove MAX_LISTEN
* daemon/remote.c: Remove VIR_FROM_THIS
* examples/domain-events/events-c/event-test.c: Remove VIR_DEBUG
* python/libvirt-override.c: Put NAME() inside DEBUG_ERROR
* src/esx/esx*.c: Comment out unused VIR_FROM_THIS
* src/node_device/node_device_hal.c: Remove pointless macros
for accessing privateData
* src/openvz/openvz_driver.c: Remove CMDBUF_LEN/CMDOP_LEN
* src/qemu/qemu_monitor_text.c: Remove QEMU_CMD_PROMPT
and QEMU_PASSWD_PROMPT
* src/remote/remote_driver.c: Remove UNIX_PATH_MAX
* src/security/security_stack.c: Remove VIR_FROM_THIS
* src/uml/uml_conf.c: Remove umlLog()
* src/uml/uml_driver.c: Remove TEMPDIR
* src/util/bridge.c: Remove JIFFIES_TO_MS/MS_TO_JIFFIES
* src/util/hooks.c: Ensure VIR_FROM_THIS is used
* src/util/logging.c: Remove VIR_FROM_THIS
* src/util/macvtap.c: Disable unused constants
* src/util/storage_file.c: Disable QCOW1_HDR_TOTAL_SIZE
* src/vbox/vbox_driver.c: Remove duplicated VIR_FROM_THIS
and make sure it is used
* src/util/pci.c: Disable some unused constants
* src/xen/xen_hypervisor.c: Remove XEN_V0_IOCTL_HYPERCALL_CMD
and unused DOMFLAGS_CPUMASK/DOMFLAGS_CPUSHIFT
* src/xen/xm_internal.c: Remove XM_XML_ERROR,
XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU and
XEND_CONFIG_MIN_VERS_PVFB_NEWCONF
* tools/virsh.c: Remove DIR_MODE/LOCK_MODE, LVL_NOTICE constants
* tests/sockettest.c: Remove DO_TEST_PARSE
---
daemon/libvirtd.c | 2 +-
daemon/remote.c | 8 ++++++--
m4/virt-compile-warnings.m4 | 1 -
python/libvirt-override.c | 4 +++-
src/driver.c | 3 +--
src/esx/esx_device_monitor.c | 2 +-
src/esx/esx_interface_driver.c | 2 +-
src/esx/esx_network_driver.c | 2 +-
src/esx/esx_nwfilter_driver.c | 2 +-
src/esx/esx_secret_driver.c | 2 +-
src/esx/esx_vi.c | 12 +++---------
src/esx/esx_vi_methods.c | 11 ++++++-----
src/esx/esx_vi_types.c | 5 +++--
src/libvirt.c | 3 ---
src/locking/domain_lock.c | 2 --
src/node_device/node_device_hal.c | 17 ++++-------------
src/openvz/openvz_driver.c | 2 --
src/qemu/qemu_monitor_text.c | 3 ---
src/remote/remote_driver.c | 8 ++++++--
src/security/security_stack.c | 2 --
src/uml/uml_conf.c | 2 --
src/uml/uml_driver.c | 3 ---
src/util/bridge.c | 3 ---
src/util/hooks.c | 2 +-
src/util/logging.c | 2 --
src/util/macvtap.c | 6 ++++--
src/util/netlink.c | 8 +++++---
src/util/pci.c | 4 ++--
src/util/storage_file.c | 4 +++-
src/vbox/vbox_driver.c | 4 +---
src/xen/xen_hypervisor.c | 14 +++++---------
src/xen/xm_internal.c | 9 ---------
tests/sockettest.c | 10 ----------
tools/virsh.c | 16 +++-------------
34 files changed, 62 insertions(+), 118 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 06d2077..3c3ebe1 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1263,7 +1263,7 @@ enum {
OPT_VERSION = 129
};
-#define MAX_LISTEN 5
+
int main(int argc, char **argv) {
virNetServerPtr srv = NULL;
char *remote_config_file = NULL;
diff --git a/daemon/remote.c b/daemon/remote.c
index 2889908..5f089ce 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -65,10 +65,14 @@
(_to) = (_from); \
} while (0)
-# define HYPER_TO_LONG(_to, _from) HYPER_TO_TYPE(long, _to, _from)
+# if 0
+# define HYPER_TO_LONG(_to, _from) HYPER_TO_TYPE(long, _to, _from)
+# endif
# define HYPER_TO_ULONG(_to, _from) HYPER_TO_TYPE(unsigned long, _to, _from)
#else
-# define HYPER_TO_LONG(_to, _from) (_to) = (_from)
+# if 0
+# define HYPER_TO_LONG(_to, _from) (_to) = (_from)
+# endif
# define HYPER_TO_ULONG(_to, _from) (_to) = (_from)
#endif
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 305036f..4e98bc1 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -63,7 +63,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dontwarn="$dontwarn -Wconversion"
dontwarn="$dontwarn -Wsign-conversion"
dontwarn="$dontwarn -Wpacked"
- dontwarn="$dontwarn -Wunused-macros"
dontwarn="$dontwarn -Woverlength-strings"
dontwarn="$dontwarn -Wstack-protector"
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 8be9af7..4bf0bfb 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2663,7 +2663,9 @@ static char *updateTimeoutName = NULL;
static PyObject *removeTimeoutObj = NULL;
static char *removeTimeoutName = NULL;
-#define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
+#if DEBUG_ERROR
+# define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
+#endif
static int
libvirt_virEventAddHandleFunc (int fd,
diff --git a/src/driver.c b/src/driver.c
index 579c2b3..16c9661 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -30,13 +30,12 @@
#include "util.h"
#include "configmake.h"
-#define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
-
/* Make sure ... INTERNAL_CALL cannot be set by the caller */
verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL &
VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
#ifdef WITH_DRIVER_MODULES
+# define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
/* XXX re-implment this for other OS, or use libtools helper lib ? */
diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index 4bc8e7f..fc7b4de 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -35,7 +35,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index a468976..f324f0f 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -35,7 +35,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index 3c76fae..3a72f27 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -35,7 +35,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c
index 13cacd4..80bf5ff 100644
--- a/src/esx/esx_nwfilter_driver.c
+++ b/src/esx/esx_nwfilter_driver.c
@@ -34,7 +34,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c
index 656224e..68dd2bb 100644
--- a/src/esx/esx_secret_driver.c
+++ b/src/esx/esx_secret_driver.c
@@ -34,7 +34,7 @@
#include "esx_vi_methods.h"
#include "esx_util.h"
-#define VIR_FROM_THIS VIR_FROM_ESX
+/* #define VIR_FROM_THIS VIR_FROM_ESX */
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 64e5b73..fd3b447 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -40,13 +40,6 @@
#define VIR_FROM_THIS VIR_FROM_ESX
-
-#define ESX_VI__SOAP__RESPONSE_XPATH(_type) \
- ((char *)"/soapenv:Envelope/soapenv:Body/" \
- "vim:"_type"Response/vim:returnval")
-
-
-
#define ESX_VI__TEMPLATE__ALLOC(_type) \
int \
esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
@@ -3928,11 +3921,12 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
-
-#define ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE_IGNORE(_name) \
+#if 0
+# define ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE_IGNORE(_name) \
if (STREQ(dynamicProperty->name, #_name)) { \
continue; \
}
+#endif
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 1f1780f..0284ba7 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -1,4 +1,3 @@
-
/*
* esx_vi_methods.c: client for the VMware VI API 2.5 to manage ESX hosts
*
@@ -52,8 +51,10 @@
-#define ESX_VI__METHOD__CHECK_OUTPUT__RequiredList \
+#if 0
+# define ESX_VI__METHOD__CHECK_OUTPUT__RequiredList \
ESX_VI__METHOD__CHECK_OUTPUT__NotNone
+#endif
@@ -78,12 +79,12 @@
}
-
-#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type, _suffix) \
+#if 0
+# define ESX_VI__METHOD__DESERIALIZE_OUTPUT__RequiredList(_type) \
if (esxVI_##_type##_DeserializeList(response->node, output) < 0) { \
goto cleanup; \
}
-
+#endif
#define ESX_VI__METHOD__DESERIALIZE_OUTPUT__OptionalItem(_type, _suffix) \
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 2332fde..5d07103 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -557,11 +557,12 @@
-#define ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(_type) \
+#if 0
+# define ESX_VI__TEMPLATE__DISPATCH__DEEP_COPY(_type) \
case esxVI_Type_##_type: \
return esxVI_##_type##_DeepCopy((esxVI_##_type **)dst, \
(esxVI_##_type *)src);
-
+#endif
#define ESX_VI__TEMPLATE__DISPATCH__CAST_FROM_ANY_TYPE(_type) \
diff --git a/src/libvirt.c b/src/libvirt.c
index e00c64f..c00823e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -543,9 +543,6 @@ DllMain (HINSTANCE instance ATTRIBUTE_UNUSED,
#define virLibSecretError(code, ...) \
virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-#define virLibStreamError(code, ...) \
- virReportErrorHelper(VIR_FROM_STREAMS, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
#define virLibNWFilterError(code, ...) \
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index de1937c..58cbd3c 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -27,8 +27,6 @@
#include "virterror_internal.h"
#include "logging.h"
-#define VIR_FROM_THIS VIR_FROM_LOCKING
-
static int virDomainLockManagerAddLease(virLockManagerPtr lock,
virDomainLeaseDefPtr lease)
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 27fedc9..2aa7dd9 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -37,21 +37,12 @@
#include "logging.h"
#include "node_device_driver.h"
-#define VIR_FROM_THIS VIR_FROM_NODEDEV
-
/*
* Host device enumeration (HAL implementation)
*/
static virDeviceMonitorStatePtr driverState;
-#define CONN_DRV_STATE(conn) \
- ((virDeviceMonitorStatePtr)((conn)->devMonPrivateData))
-#define DRV_STATE_HAL_CTX(ds) ((LibHalContext *)((ds)->privateData))
-#define CONN_HAL_CTX(conn) DRV_STATE_HAL_CTX(CONN_DRV_STATE(conn))
-
-#define NODE_DEV_UDI(obj) ((const char *)((obj)->privateData)
-
static const char *hal_name(const char *udi)
{
@@ -440,7 +431,7 @@ static void dev_create(const char *udi)
return;
nodeDeviceLock(driverState);
- ctx = DRV_STATE_HAL_CTX(driverState);
+ ctx = driverState->privateData;
if (VIR_ALLOC(def) < 0)
goto failure;
@@ -599,7 +590,7 @@ static void dbus_watch_callback(int fdatch ATTRIBUTE_UNUSED,
(void)dbus_watch_handle(watch, dbus_flags);
nodeDeviceLock(driverState);
- hal_ctx = DRV_STATE_HAL_CTX(driverState);
+ hal_ctx = driverState->privateData;
dbus_conn = libhal_ctx_get_dbus_connection(hal_ctx);
nodeDeviceUnlock(driverState);
while (dbus_connection_dispatch(dbus_conn) == DBUS_DISPATCH_DATA_REMAINS)
@@ -807,7 +798,7 @@ static int halDeviceMonitorShutdown(void)
{
if (driverState) {
nodeDeviceLock(driverState);
- LibHalContext *hal_ctx = DRV_STATE_HAL_CTX(driverState);
+ LibHalContext *hal_ctx = driverState->privateData;
virNodeDeviceObjListFree(&driverState->devs);
(void)libhal_ctx_shutdown(hal_ctx, NULL);
(void)libhal_ctx_free(hal_ctx);
@@ -833,7 +824,7 @@ static int halDeviceMonitorReload(void)
virNodeDeviceObjListFree(&driverState->devs);
nodeDeviceUnlock(driverState);
- hal_ctx = DRV_STATE_HAL_CTX(driverState);
+ hal_ctx = driverState->privateData;
VIR_INFO("Creating new objects");
dbus_error_init(&err);
udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index c13f346..74b31ad 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -62,8 +62,6 @@
#define VIR_FROM_THIS VIR_FROM_OPENVZ
#define OPENVZ_MAX_ARG 28
-#define CMDBUF_LEN 1488
-#define CMDOP_LEN 288
static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index aa5d1c6..6fbbaf0 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -43,9 +43,6 @@
#define VIR_FROM_THIS VIR_FROM_QEMU
-#define QEMU_CMD_PROMPT "\n(qemu) "
-#define QEMU_PASSWD_PROMPT "Password: "
-
#define DEBUG_IO 0
/* Return -1 for error, 0 for success */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f318740..8a56c9c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -60,10 +60,14 @@
(_to) = (_from); \
} while (0)
-# define HYPER_TO_LONG(_to, _from) HYPER_TO_TYPE(long, _to, _from)
+# if 0
+# define HYPER_TO_LONG(_to, _from) HYPER_TO_TYPE(long, _to, _from)
+# endif
# define HYPER_TO_ULONG(_to, _from) HYPER_TO_TYPE(unsigned long, _to, _from)
#else
-# define HYPER_TO_LONG(_to, _from) (_to) = (_from)
+# if 0
+# define HYPER_TO_LONG(_to, _from) (_to) = (_from)
+# endif
# define HYPER_TO_ULONG(_to, _from) (_to) = (_from)
#endif
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index b63e4c8..5e8ead9 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -24,8 +24,6 @@
#include "virterror_internal.h"
-#define VIR_FROM_THIS VIR_FROM_SECURITY
-
typedef struct _virSecurityStackData virSecurityStackData;
typedef virSecurityStackData *virSecurityStackDataPtr;
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 0122472..d2c9ea6 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -52,8 +52,6 @@
#define VIR_FROM_THIS VIR_FROM_UML
-#define umlLog(level, msg, ...) \
- virLogMessage(__FILE__, level, 0, msg, __VA_ARGS__)
virCapsPtr umlCapsInit(void) {
struct utsname utsname;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index a71ea21..3cc4f1b 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -64,9 +64,6 @@
#define VIR_FROM_THIS VIR_FROM_UML
-/* For storing short-lived temporary files. */
-#define TEMPDIR LOCALSTATEDIR "/cache/libvirt"
-
typedef struct _umlDomainObjPrivate umlDomainObjPrivate;
typedef umlDomainObjPrivate *umlDomainObjPrivatePtr;
struct _umlDomainObjPrivate {
diff --git a/src/util/bridge.c b/src/util/bridge.c
index 7204e64..8d6e0ce 100644
--- a/src/util/bridge.c
+++ b/src/util/bridge.c
@@ -52,9 +52,6 @@
# include "logging.h"
# include "network.h"
-# define JIFFIES_TO_MS(j) (((j)*1000)/HZ)
-# define MS_TO_JIFFIES(ms) (((ms)*HZ)/1000)
-
struct _brControl {
int fd;
};
diff --git a/src/util/hooks.c b/src/util/hooks.c
index 30e20ac..b5a399c 100644
--- a/src/util/hooks.c
+++ b/src/util/hooks.c
@@ -42,7 +42,7 @@
#define VIR_FROM_THIS VIR_FROM_HOOK
#define virHookReportError(code, ...) \
- virReportErrorHelper(VIR_FROM_HOOK, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define LIBVIRT_HOOK_DIR SYSCONFDIR "/libvirt/hooks"
diff --git a/src/util/logging.c b/src/util/logging.c
index c86fcda..927fe6d 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -44,8 +44,6 @@
#include "threads.h"
#include "files.h"
-#define VIR_FROM_THIS VIR_FROM_NONE
-
/*
* A logging buffer to keep some history over logs
*/
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 30343c8..832e952 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -78,8 +78,10 @@ VIR_ENUM_IMPL(virMacvtapMode, VIR_MACVTAP_MODE_LAST,
# define MICROSEC_PER_SEC (1000 * 1000)
-# define NLMSGBUF_SIZE 256
-# define RATTBUF_SIZE 64
+# if 0
+# define NLMSGBUF_SIZE 256
+# define RATTBUF_SIZE 64
+# endif
# define STATUS_POLL_TIMEOUT_USEC (10 * MICROSEC_PER_SEC)
# define STATUS_POLL_INTERVL_USEC (MICROSEC_PER_SEC / 8)
diff --git a/src/util/netlink.c b/src/util/netlink.c
index 0672184..6986b93 100644
--- a/src/util/netlink.c
+++ b/src/util/netlink.c
@@ -37,9 +37,11 @@
#define VIR_FROM_THIS VIR_FROM_NET
-#define netlinkError(code, ...) \
- virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
+#if ! (defined(__linux__) && defined(HAVE_LIBNL))
+# define netlinkError(code, ...) \
+ virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
+ __FUNCTION__, __LINE__, __VA_ARGS__)
+#endif
#define NETLINK_ACK_TIMEOUT_S 2
diff --git a/src/util/pci.c b/src/util/pci.c
index 21c12b9..70de273 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -101,7 +101,7 @@ struct _pciDeviceList {
#define PCI_HEADER_TYPE 0x0e /* Header type */
#define PCI_HEADER_TYPE_BRIDGE 0x1
#define PCI_HEADER_TYPE_MASK 0x7f
-#define PCI_HEADER_TYPE_MULTI 0x80
+/*#define PCI_HEADER_TYPE_MULTI 0x80*/
/* PCI30 6.2.1 Device Identification */
#define PCI_CLASS_DEVICE 0x0a /* Device class */
@@ -128,7 +128,7 @@ struct _pciDeviceList {
#define PCI_EXP_DEVCAP_FLR (1<<28) /* Function Level Reset */
/* Header type 1 BR12 3.2 PCI-to-PCI Bridge Configuration Space Header Format */
-#define PCI_PRIMARY_BUS 0x18 /* BR12 3.2.5.2 Primary bus number */
+/*#define PCI_PRIMARY_BUS 0x18*/ /* BR12 3.2.5.2 Primary bus number */
#define PCI_SECONDARY_BUS 0x19 /* BR12 3.2.5.3 Secondary bus number */
#define PCI_SUBORDINATE_BUS 0x1a /* BR12 3.2.5.4 Highest bus number behind the bridge */
#define PCI_BRIDGE_CONTROL 0x3e
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 06cabc8..78ab730 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -102,7 +102,9 @@ qedGetBackingStore(char **, int *, const unsigned char *, size_t);
#define QCOW1_HDR_CRYPT (QCOWX_HDR_IMAGE_SIZE+8+1+1)
#define QCOW2_HDR_CRYPT (QCOWX_HDR_IMAGE_SIZE+8)
-#define QCOW1_HDR_TOTAL_SIZE (QCOW1_HDR_CRYPT+4+8)
+#if 0
+# define QCOW1_HDR_TOTAL_SIZE (QCOW1_HDR_CRYPT+4+8)
+#endif
#define QCOW2_HDR_TOTAL_SIZE (QCOW2_HDR_CRYPT+4+4+8+8+4+4+8)
#define QCOW2_HDR_EXTENSION_END 0
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index eab4679..05aa7fa 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -42,8 +42,6 @@
#include "virterror_internal.h"
#include "util.h"
-#define VIR_FROM_THIS VIR_FROM_VBOX
-
extern virDriver vbox22Driver;
extern virNetworkDriver vbox22NetworkDriver;
@@ -66,7 +64,7 @@ static virDriver vboxDriverDummy;
#define VIR_FROM_THIS VIR_FROM_VBOX
#define vboxError(code, ...) \
- virReportErrorHelper(VIR_FROM_VBOX, code, __FILE__, \
+ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
int vboxRegister(void) {
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 6a46a39..770df03 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -80,16 +80,12 @@ typedef struct v0_hypercall_struct {
} v0_hypercall_t;
#ifdef __linux__
-# define XEN_V0_IOCTL_HYPERCALL_CMD \
- _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t))
/* the new one */
typedef struct v1_hypercall_struct
{
uint64_t op;
uint64_t arg[5];
} v1_hypercall_t;
-# define XEN_V1_IOCTL_HYPERCALL_CMD \
- _IOC(_IOC_NONE, 'P', 0, sizeof(v1_hypercall_t))
typedef v1_hypercall_t hypercall_t;
#elif defined(__sun)
typedef privcmd_hypercall_t hypercall_t;
@@ -140,8 +136,6 @@ static regex_t xen_cap_rec;
# define DOMFLAGS_PAUSED (1<<3) /* Currently paused by control software. */
# define DOMFLAGS_BLOCKED (1<<4) /* Currently blocked pending an event. */
# define DOMFLAGS_RUNNING (1<<5) /* Domain is currently running. */
-# define DOMFLAGS_CPUMASK 255 /* CPU to which this domain is bound. */
-# define DOMFLAGS_CPUSHIFT 8
# define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code. */
# define DOMFLAGS_SHUTDOWNSHIFT 16
#endif
@@ -2729,13 +2723,13 @@ xenHypervisorMakeCapabilities(virConnectPtr conn)
}
}
- capabilities = fopen ("/sys/hypervisor/properties/capabilities", "r");
+ capabilities = fopen(HYPERVISOR_CAPABILITIES, "r");
if (capabilities == NULL) {
if (errno != ENOENT) {
VIR_FORCE_FCLOSE(cpuinfo);
virReportSystemError(errno,
_("cannot read file %s"),
- "/sys/hypervisor/properties/capabilities");
+ HYPERVISOR_CAPABILITIES);
return NULL;
}
}
@@ -3195,7 +3189,9 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
break;
case DOMFLAGS_SHUTDOWN:
/* The domain is shutdown. Determine the cause. */
- domain_shutdown_cause = domain_flags >> DOMFLAGS_SHUTDOWNSHIFT;
+ domain_shutdown_cause =
+ (domain_flags >> DOMFLAGS_SHUTDOWNSHIFT) &
+ DOMFLAGS_SHUTDOWNMASK;
switch (domain_shutdown_cause) {
case SHUTDOWN_crash:
info->state = VIR_DOMAIN_CRASHED;
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 530b0d4..0f5d146 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -52,14 +52,6 @@
#define VIR_FROM_THIS VIR_FROM_XENXM
-#ifdef WITH_RHEL5_API
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
-#else
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
-#endif
-
/* The true Xen limit varies but so far is always way
less than 1024, which is the Linux kernel limit according
to sched.h, so we'll match that for now */
@@ -78,7 +70,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
#define XEND_CONFIG_FILE "xend-config.sxp"
#define XEND_PCI_CONFIG_PREFIX "xend-pci-"
#define QEMU_IF_SCRIPT "qemu-ifup"
-#define XM_XML_ERROR "Invalid xml"
struct xenUnifiedDriver xenXMDriver = {
xenXMOpen, /* open */
diff --git a/tests/sockettest.c b/tests/sockettest.c
index b9e37ab..9e5b678 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -169,16 +169,6 @@ mymain(void)
if (!virTestGetDebug())
virSetErrorFunc(NULL, testQuietError);
-#define DO_TEST_PARSE(addrstr, family, pass) \
- do { \
- virSocketAddr addr; \
- struct testParseData data = { &addr, addrstr, family, pass }; \
- memset(&addr, 0, sizeof(addr)); \
- if (virtTestRun("Test parse " addrstr, \
- 1, testParseHelper, &data) < 0) \
- ret = -1; \
- } while (0)
-
#define DO_TEST_PARSE_AND_FORMAT(addrstr, family, pass) \
do { \
virSocketAddr addr; \
diff --git a/tools/virsh.c b/tools/virsh.c
index 9a189fd..988fbab 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -74,14 +74,13 @@ static char *progname;
/**
* The log configuration
*/
-#define MSG_BUFFER 4096
#define SIGN_NAME "virsh"
-#define DIR_MODE (S_IWUSR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) /* 0755 */
#define FILE_MODE (S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH) /* 0644 */
-#define LOCK_MODE (S_IWUSR | S_IRUSR) /* 0600 */
#define LVL_DEBUG "DEBUG"
#define LVL_INFO "INFO"
-#define LVL_NOTICE "NOTICE"
+#if 0
+# define LVL_NOTICE "NOTICE"
+#endif
#define LVL_WARNING "WARNING"
#define LVL_ERROR "ERROR"
@@ -423,15 +422,6 @@ _vshStrdup(vshControl *ctl, const char *s, const char *filename, int line)
exit(EXIT_FAILURE);
}
-/* Poison the raw allocating identifiers in favor of our vsh variants. */
-#undef malloc
-#undef calloc
-#undef realloc
-#undef strdup
-#define malloc use_vshMalloc_instead_of_malloc
-#define calloc use_vshCalloc_instead_of_calloc
-#define realloc use_vshRealloc_instead_of_realloc
-#define strdup use_vshStrdup_instead_of_strdup
static int idsorter(const void *a, const void *b) {
const int *ia = (const int *)a;
--
1.7.4.4
13 years, 4 months
[libvirt] [PATCH] Don't exist if the libvirtd config does not exist
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
It is common for the $HOME/.libvirt/libvirtd.conf file to not
exist. Treat this situation as non-fatal since we can carry
on with our default settings just fine.
* daemon/libvirtd.c: Treat ENOENT as non-fatal when loading
config
---
daemon/libvirtd.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 06d2077..fe0fa27 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1028,6 +1028,10 @@ daemonConfigLoad(struct daemonConfig *data,
{
virConfPtr conf;
+ if (access(filename, R_OK) == -1 &&
+ errno == ENOENT)
+ return 0;
+
conf = virConfReadFile (filename, 0);
if (!conf)
return -1;
--
1.7.6
13 years, 4 months