[libvirt] [RFC PATCH 0/5] another <disk> refactoring
by Eric Blake
I'm about to reuse the <mirror> sub-element of <disk> for my
pending series on active block commit, but to do that, I
wanted to get some refactoring out of the way first. Patches
1-4 are pretty straightforward, and 5 may be controversial
(I'm sending it now, even though it still needs more work, to
make sure I'm not doing something bad). I'm aware that this
will probably cause some rebase pain for Peter's work with
gluster, but at the same time, it will ease some of the work
that Benoit wants for introducing quorums.
Eric Blake (5):
conf: store snapshot source as pointer, for easier manipulation
conf: consolidate disk def allocation
conf: store disk source as pointer, for easier manipulation
conf: store mirroring information in virStorageSource
conf: alter disk mirror xml output
docs/schemas/domaincommon.rng | 29 +-
src/conf/domain_conf.c | 254 ++++++++------
src/conf/domain_conf.h | 6 +-
src/conf/snapshot_conf.c | 56 ++--
src/conf/snapshot_conf.h | 2 +-
src/libvirt_private.syms | 1 +
src/lxc/lxc_controller.c | 8 +-
src/lxc/lxc_driver.c | 8 +-
src/parallels/parallels_driver.c | 2 +-
src/qemu/qemu_command.c | 290 ++++++++--------
src/qemu/qemu_conf.c | 88 ++---
src/qemu/qemu_domain.c | 18 +-
src/qemu/qemu_driver.c | 372 +++++++++++----------
src/qemu/qemu_migration.c | 4 +-
src/qemu/qemu_process.c | 8 +-
src/security/security_selinux.c | 4 +-
src/vbox/vbox_tmpl.c | 6 +-
src/vmx/vmx.c | 2 +-
src/xenxs/xen_sxpr.c | 8 +-
src/xenxs/xen_xm.c | 4 +-
.../qemuxml2argv-disk-mirror-old.xml | 47 +++
.../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml | 9 +-
.../qemuxml2xmlout-disk-mirror-old-inactive.xml | 41 +++
.../qemuxml2xmlout-disk-mirror-old.xml | 52 +++
tests/qemuxml2xmltest.c | 1 +
tests/securityselinuxlabeltest.c | 6 +-
26 files changed, 778 insertions(+), 548 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-mirror-old.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old-inactive.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml
--
1.9.0
10 years, 6 months
[libvirt] [PATCH] bhyve: fix virObjectUnlock() usage
by Roman Bogorodskiy
In a number of places in the bhyve driver, virObjectUnlock()
is called with an arg without check if the arg is non-NULL, which
could result in passing NULL value and a warning like:
virObjectUnlock:340 : Object 0x0 ((unknown)) is not a virObjectLockable instance
* src/bhyve/bhyve_driver.c (bhyveDomainGetInfo)
(bhyveDomainGetState, bhyveDomainGetAutostart)
(bhyveDomainSetAutostart, bhyveDomainIsActive)
(bhyveDomainIsPersistent, bhyveDomainGetXMLDesc)
(bhyveDomainUndefine, bhyveDomainLookupByUUID)
(bhyveDomainLookupByName, bhyveDomainLookupByID)
(bhyveDomainCreateWithFlags, bhyveDomainOpenConsole):
Check if arg is not NULL before calling virObjectUnlock on it.
---
src/bhyve/bhyve_driver.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 580b124..c8902bf 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -309,7 +309,8 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
ret = 0;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -334,7 +335,8 @@ bhyveDomainGetState(virDomainPtr domain,
ret = 0;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -354,7 +356,8 @@ bhyveDomainGetAutostart(virDomainPtr domain, int *autostart)
ret = 0;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -417,7 +420,8 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autostart)
cleanup:
VIR_FREE(configFile);
VIR_FREE(autostartLink);
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -436,7 +440,8 @@ bhyveDomainIsActive(virDomainPtr domain)
ret = virDomainObjIsActive(obj);
cleanup:
- virObjectUnlock(obj);
+ if (obj)
+ virObjectUnlock(obj);
return ret;
}
@@ -455,7 +460,8 @@ bhyveDomainIsPersistent(virDomainPtr domain)
ret = obj->persistent;
cleanup:
- virObjectUnlock(obj);
+ if (obj)
+ virObjectUnlock(obj);
return ret;
}
@@ -474,7 +480,8 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
ret = virDomainDefFormat(vm->def, flags);
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -562,7 +569,8 @@ bhyveDomainUndefine(virDomainPtr domain)
ret = 0;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -730,7 +738,8 @@ bhyveDomainLookupByUUID(virConnectPtr conn,
dom->id = vm->def->id;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return dom;
}
@@ -757,7 +766,8 @@ static virDomainPtr bhyveDomainLookupByName(virConnectPtr conn,
dom->id = vm->def->id;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return dom;
}
@@ -785,7 +795,8 @@ bhyveDomainLookupByID(virConnectPtr conn,
dom->id = vm->def->id;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return dom;
}
@@ -820,7 +831,8 @@ bhyveDomainCreateWithFlags(virDomainPtr dom,
start_flags);
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
@@ -960,7 +972,8 @@ bhyveDomainOpenConsole(virDomainPtr dom,
ret = 0;
cleanup:
- virObjectUnlock(vm);
+ if (vm)
+ virObjectUnlock(vm);
return ret;
}
--
1.9.0
10 years, 6 months
[libvirt] [PATCH] blockcommit: document semantics of committing active layer
by Eric Blake
Now that qemu 2.0 allows commit of the active layer, people are
attempting to use virsh blockcommit and getting into a stuck
state, because libvirt is unprepared to handle the two-phase
commit required by qemu.
Stepping back a bit, there are two valid semantics for a
commit operation:
1. Maintain a 'golden' base, and a transient overlay. Make
changes in the overlay, and if everything appears to work,
commit those changes into the base, but still keep the overlay
for the next round of changes; repeat the cycle as desired.
2. Create an external snapshot, then back up the stable state
in the backing file. Once the backup is complete, commit the
overlay back into the base, and delete the temporary snapshot.
Since qemu doesn't know up front which of the two styles is
preferred, a block commit of the active layer merely gets
the job into a synchronized state, and sends an event; then
the user must either cancel (case 1) or complete (case 2),
where qemu then sends a second event that actually ends the
job. However, libvirt was blindly assuming the semantics that
apply to a commit of an intermediate image, where there is
only one sane conclusion (the job automatically ends with
fewer elements in the chain); and getting stuck because it
wasn't prepared for qemu to enter a second phase of the job.
This patch adds a flag to the libvirt API that a user MUST
supply in order to acknowledge that they will be using two-phase
semantics. It might be possible to have a mode where if the
flag is omitted, we automatically do the case 2 semantics on
the user's behalf; but before that happens, I must do additional
patches to track the fact that we are doing an active commit
in the domain XML. So the safest thing for now is to reject the
new flag in qemu, as well as prevent commits of the active layer
without the flag. Later patches will add support of the flag,
and once 2-phase semantics are working, we can then decide
whether to relax things to allow an omitted flag to cause an
automatic pivot.
* include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_COMMIT_ACTIVE)
(VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT): New enums.
* src/libvirt.c (virDomainBlockCommit): Document two-phase job
when committing active layer, through new flag.
(virDomainBlockJobAbort): Document that pivot also occurs after
active commit.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Explicitly
reject active copy; later patches will add it in.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
This patch should probably be backported, even if later patches
in the series are not, so that users avoid getting hung.
include/libvirt/libvirt.h.in | 12 ++++++----
src/libvirt.c | 55 +++++++++++++++++++++++++++++---------------
src/qemu/qemu_driver.c | 9 ++++++++
3 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 260c971..127de11 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2513,6 +2513,7 @@ typedef enum {
VIR_DOMAIN_BLOCK_JOB_TYPE_PULL = 1,
VIR_DOMAIN_BLOCK_JOB_TYPE_COPY = 2,
VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT = 3,
+ VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT = 4,
#ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_BLOCK_JOB_TYPE_LAST
@@ -2523,7 +2524,8 @@ typedef enum {
* virDomainBlockJobAbortFlags:
*
* VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC: Request only, do not wait for completion
- * VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT: Pivot to mirror when ending a copy job
+ * VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT: Pivot to new file when ending a copy or
+ * active commit job
*/
typedef enum {
VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC = 1 << 0,
@@ -2588,6 +2590,8 @@ typedef enum {
VIR_DOMAIN_BLOCK_COMMIT_DELETE = 1 << 1, /* Delete any files that are now
invalid after their contents
have been committed */
+ VIR_DOMAIN_BLOCK_COMMIT_ACTIVE = 1 << 2, /* Allow a two-phase commit when
+ top is the active layer */
} virDomainBlockCommitFlags;
int virDomainBlockCommit(virDomainPtr dom, const char *disk, const char *base,
@@ -4823,8 +4827,8 @@ typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
/**
* virConnectDomainEventBlockJobStatus:
*
- * The final status of a virDomainBlockPull() or virDomainBlockRebase()
- * operation
+ * Tracks status of a virDomainBlockPull(), virDomainBlockRebase(),
+ * or virDomainBlockCommit() operation
*/
typedef enum {
VIR_DOMAIN_BLOCK_JOB_COMPLETED = 0,
@@ -4843,7 +4847,7 @@ typedef enum {
* @dom: domain on which the event occurred
* @disk: fully-qualified filename of the affected disk
* @type: type of block job (virDomainBlockJobType)
- * @status: final status of the operation (virConnectDomainEventBlockJobStatus)
+ * @status: status of the operation (virConnectDomainEventBlockJobStatus)
* @opaque: application specified data
*
* The callback signature to use when registering for an event of type
diff --git a/src/libvirt.c b/src/libvirt.c
index 19fa18b..20abfce 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -19467,13 +19467,16 @@ virDomainOpenChannel(virDomainPtr dom,
*
* If the current block job for @disk is VIR_DOMAIN_BLOCK_JOB_TYPE_COPY, then
* the default is to abort the mirroring and revert to the source disk;
- * adding @flags of VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT causes this call to
- * fail with VIR_ERR_BLOCK_COPY_ACTIVE if the copy is not fully populated,
- * otherwise it will swap the disk over to the copy to end the mirroring. An
- * event will be issued when the job is ended, and it is possible to use
- * VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC to control whether this command waits
- * for the completion of the job. Restarting this job requires starting
- * over from the beginning of the first phase.
+ * likewise, if the current job is VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT,
+ * the default is to abort without changing the active layer of @disk.
+ * Adding @flags of VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT causes this call to
+ * fail with VIR_ERR_BLOCK_COPY_ACTIVE if the copy or commit is not yet
+ * ready; otherwise it will swap the disk over to the new active image
+ * to end the mirroring or active commit. An event will be issued when the
+ * job is ended, and it is possible to use VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC
+ * to control whether this command waits for the completion of the job.
+ * Restarting a copy or active commit job requires starting over from the
+ * beginning of the first phase.
*
* Returns -1 in case of failure, 0 when successful.
*/
@@ -19843,17 +19846,32 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk,
* the job is aborted, it is up to the hypervisor whether starting a new
* job will resume from the same point, or start over.
*
+ * As a special case, if @top is the active image (or NULL), and @flags
+ * includes VIR_DOMAIN_BLOCK_COMMIT_ACTIVE, the block job will have a type
+ * of VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT, and operates in two phases.
+ * In the first phase, the contents are being committed into @base, and the
+ * job can only be canceled. The job transitions to the second phase when
+ * the job info states cur == end, and remains alive to keep all further
+ * changes to @top synchronized into @base; an event with status
+ * VIR_DOMAIN_BLOCK_JOB_READY is also issued to mark the job transition.
+ * Once in the second phase, the user must choose whether to cancel the job
+ * (keeping @top as the active image, but now containing only the changes
+ * since the time the job ended) or to pivot the job (adjusting to @base as
+ * the active image, and invalidating @top).
+ *
* Be aware that this command may invalidate files even if it is aborted;
* the user is cautioned against relying on the contents of invalidated
- * intermediate files such as @top without manually rebasing those files
- * to use a backing file of a read-only copy of @base prior to the point
- * where the commit operation was started (although such a rebase cannot
- * be safely done until the commit has successfully completed). However,
- * the domain itself will not have any issues; the active layer remains
- * valid throughout the entire commit operation. As a convenience,
- * if @flags contains VIR_DOMAIN_BLOCK_COMMIT_DELETE, this command will
- * unlink all files that were invalidated, after the commit successfully
- * completes.
+ * intermediate files such as @top (when @top is not the active image)
+ * without manually rebasing those files to use a backing file of a
+ * read-only copy of @base prior to the point where the commit operation
+ * was started (and such a rebase cannot be safely done until the commit
+ * has successfully completed). However, the domain itself will not have
+ * any issues; the active layer remains valid throughout the entire commit
+ * operation.
+ *
+ * Some hypervisors may support a shortcut where if @flags contains
+ * VIR_DOMAIN_BLOCK_COMMIT_DELETE, then this command will unlink all files
+ * that were invalidated, after the commit successfully completes.
*
* By default, if @base is NULL, the commit target will be the bottom of
* the backing chain; if @flags contains VIR_DOMAIN_BLOCK_COMMIT_SHALLOW,
@@ -19861,8 +19879,9 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk,
* is NULL, the active image at the top of the chain will be used. Some
* hypervisors place restrictions on how much can be committed, and might
* fail if @base is not the immediate backing file of @top, or if @top is
- * the active layer in use by a running domain, or if @top is not the
- * top-most file; restrictions may differ for online vs. offline domains.
+ * the active layer in use by a running domain but @flags did not include
+ * VIR_DOMAIN_BLOCK_COMMIT_ACTIVE, or if @top is not the top-most file;
+ * restrictions may differ for online vs. offline domains.
*
* The @disk parameter is either an unambiguous source name of the
* block device (the <source file='...'/> sub-element, such as
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 55b4755..75c59e0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15377,6 +15377,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
const char *top_parent = NULL;
bool clean_access = false;
+ /* XXX Add support for COMMIT_ACTIVE, COMMIT_DELETE */
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, -1);
if (!(vm = qemuDomObjFromDomain(dom)))
@@ -15423,6 +15424,14 @@ qemuDomainBlockCommit(virDomainPtr dom,
&top_parent)))
goto endjob;
+ /* XXX Should we auto-pivot when COMMIT_ACTIVE is not specified? */
+ if (topSource == &disk->src && !(flags & VIR_DOMAIN_BLOCK_COPY_ACTIVE)) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("commit of '%s' active layer requires active flag"),
+ disk->dst);
+ goto endjob;
+ }
+
if (!topSource->backingStore) {
virReportError(VIR_ERR_INVALID_ARG,
_("top '%s' in chain for '%s' has no backing file"),
--
1.9.0
10 years, 6 months
[libvirt] [PATCH 0/3] qemu: fix broken RTC_CHANGE event when clock offset='variable'
by Laine Stump
This patch series is all about:
https://bugzilla.redhat.com/show_bug.cgi?id=964177
which points out a flaw in qemu's RTC_CHANGE event when the base for
the guest's real time clock was given as an explicit date (rather than
as 'utc' or 'localtime'). Patch 3/3 explains what qemu does, and how
this patch fixes it. (NB: the flaw has been in QEMU for so long now
that it has been documented and cannot be changed, so libvirt must
work around it)
In the meantime, the fix required that we learn the offset of
localtime from utc, and that seems like something we might want to do
for other reasons, so Patch 1/3 adds a new utility function do get
that value that is (I hope!) POSIX compliant.
Since the original patch to fix this problem was incorrect, and the
new patch doesn't use any of its code, Patch 2/3 reverts that patch
completely.
Note that I have tested this patch by starting a domain with several
variations of <clock> parameters (in a locale that is currently at
UTC+3) and using the following short script to add and remove seconds
from the guest's RTC while watching both the <clock> line in
/var/run/libvirt/qemu/$domain.xml and the offset value sent in
libvirt's VIR_DOMAIN_EVENT_ID_RTC_CHANGE event (using
examples/domain-events/events-c/event-test from a libvirt source tree
that has been built). All cases appear to maintain the adjustment in
the status properly, as well as sending the correct value to any event
handler.
Here is the script I used to add/remove time from the RTC:
#!/bin/sh
old=$(hwclock --show | cut -f1-7 -d' ')
oldabs=$(date +%s --date="$old")
newabs=$(expr $oldabs + $1)
new=$(date --date="@$newabs")
echo Old: $oldabs $old
echo New: $newabs $new
hwclock --set --date="@$newabs"
Laine Stump (3):
util: new function virTimeLocalOffsetFromUTC
Revert "qemu: Report the offset from host UTC for RTC_CHANGE event"
qemu: fix broken RTC_CHANGE event when clock offset='variable'
src/conf/domain_conf.c | 38 +++++++++++++++++++-------------------
src/conf/domain_conf.h | 9 ++++++---
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 16 +++++++++++++---
src/qemu/qemu_process.c | 47 ++++++++++++++++++++++++++++++++---------------
src/util/virtime.c | 41 ++++++++++++++++++++++++++++++++++++++++-
src/util/virtime.h | 5 +++--
7 files changed, 114 insertions(+), 43 deletions(-)
--
1.9.0
10 years, 6 months
[libvirt] [PATCH v2 0/3] Misc error improvements
by Cole Robinson
Collection of misc error improvements, see individual patches for details.
Patch 2 and 3 have been ACK'd already.
v2:
Rebased to master
Cole Robinson (3):
virerror: Fix incorrect use of RaiseErrorFull
virdbus: Remove redundant error macro
virdbus: Show method name in error message
src/util/virdbus.c | 12 +++---
src/util/virerror.h | 114 ++++++++++++++++------------------------------------
2 files changed, 41 insertions(+), 85 deletions(-)
--
1.9.0
10 years, 6 months
[libvirt] deadlock while updating VM network filter
by Marcin Gibuła
Hi,
I've encountered deadlock while updating VM network filter and I'm
trying to debug it. However I don't have any luck with reproducing it...
Here's a backtrace of libvirtd daemon. Any hints on how to fix that
would be appreciated:)
Libvirt version is 1.2.3.
Thread 12 (Thread 0x7fd4550b5700 (LWP 6414)):
#0 0x00007fd4585b5d0c in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00007fd45887e1ba in virCondWait () from /usr/lib64/libvirt.so.0
#2 0x00007fd45887e89b in virThreadPoolWorker () from
/usr/lib64/libvirt.so.0
#3 0x00007fd45887dcf6 in virThreadHelper () from /usr/lib64/libvirt.so.0
#4 0x00007fd4585b1f3a in start_thread () from /lib64/libpthread.so.0
#5 0x00007fd4582ebdad in clone () from /lib64/libc.so.6
Thread 11 (Thread 0x7fd4548b4700 (LWP 6415)):
#0 0x00007fd4585b87a4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x00007fd4585b419c in _L_lock_518 () from /lib64/libpthread.so.0
#2 0x00007fd4585b3feb in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00007fd4588a96c8 in virDomainListPopulate () from
/usr/lib64/libvirt.so.0
#4 0x00007fd45884c349 in virHashForEach () from /usr/lib64/libvirt.so.0
#5 0x00007fd4588bc486 in virDomainObjListExport () from
/usr/lib64/libvirt.so.0
#6 0x00007fd45891b601 in virConnectListAllDomains () from
/usr/lib64/libvirt.so.0
#7 0x00007fd4593b1d2f in remoteDispatchConnectListAllDomainsHelper ()
#8 0x00007fd4589844d9 in virNetServerProgramDispatch () from
/usr/lib64/libvirt.so.0
#9 0x00007fd4593dc4ed in virNetServerHandleJob ()
#10 0x00007fd45887e7fe in virThreadPoolWorker () from
/usr/lib64/libvirt.so.0
#11 0x00007fd45887dcf6 in virThreadHelper () from /usr/lib64/libvirt.so.0
#12 0x00007fd4585b1f3a in start_thread () from /lib64/libpthread.so.0
#13 0x00007fd4582ebdad in clone () from /lib64/libc.so.6
Thread 10 (Thread 0x7fd4540b3700 (LWP 6416)):
#0 0x00007fd4585b87a4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x00007fd4585b41b7 in _L_lock_565 () from /lib64/libpthread.so.0
#2 0x00007fd4585b4049 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00007fd44cd54100 in virNWFilterLockIface () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so
#4 0x00007fd44cd47925 in _virNWFilterTeardownFilter () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so
#5 0x00007fd44cd48910 in virNWFilterTeardownFilter () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so
#6 0x00007fd44c63d203 in qemuDomainChangeNet () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#7 0x00007fd44c69b88f in qemuDomainUpdateDeviceFlags () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#8 0x00007fd458920b2b in virDomainUpdateDeviceFlags () from
/usr/lib64/libvirt.so.0
#9 0x00007fd4593bc084 in remoteDispatchDomainUpdateDeviceFlagsHelper ()
#10 0x00007fd4589844d9 in virNetServerProgramDispatch () from
/usr/lib64/libvirt.so.0
#11 0x00007fd4593dc4ed in virNetServerHandleJob ()
#12 0x00007fd45887e7fe in virThreadPoolWorker () from
/usr/lib64/libvirt.so.0
#13 0x00007fd45887dcf6 in virThreadHelper () from /usr/lib64/libvirt.so.0
#14 0x00007fd4585b1f3a in start_thread () from /lib64/libpthread.so.0
#15 0x00007fd4582ebdad in clone () from /lib64/libc.so.6
Thread 9 (Thread 0x7fd4538b2700 (LWP 6417)):
#0 0x00007fd4585b5d0c in pthread_cond_wait@(a)GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00007fd45887e1ba in virCondWait () from /usr/lib64/libvirt.so.0
#2 0x00007fd45887e89b in virThreadPoolWorker () from
/usr/lib64/libvirt.so.0
#3 0x00007fd45887dcf6 in virThreadHelper () from /usr/lib64/libvirt.so.0
#4 0x00007fd4585b1f3a in start_thread () from /lib64/libpthread.so.0
#5 0x00007fd4582ebdad in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7fd41b7fe700 (LWP 22858)):
#0 0x00007fd4585b87a4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x00007fd4585b41b7 in _L_lock_565 () from /lib64/libpthread.so.0
#2 0x00007fd4585b4049 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00007fd44cd4873b in virNWFilterInstantiateFilterLate () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so
#4 0x00007fd44cd54690 in learnIPAddressThread () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so
#5 0x00007fd4585b1f3a in start_thread () from /lib64/libpthread.so.0
#6 0x00007fd4582ebdad in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7fd459372740 (LWP 6413)):
#0 0x00007fd4585b87a4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x00007fd4585b419c in _L_lock_518 () from /lib64/libpthread.so.0
#2 0x00007fd4585b3feb in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x00007fd44c6452b5 in qemuProcessHandleEvent () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#4 0x00007fd44c65c50d in qemuMonitorEmitEvent () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#5 0x00007fd44c66fc73 in qemuMonitorJSONIOProcess () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#6 0x00007fd44c65ae08 in qemuMonitorIO () from
/usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#7 0x00007fd4588476a5 in virEventPollRunOnce () from
/usr/lib64/libvirt.so.0
#8 0x00007fd458845b90 in virEventRunDefaultImpl () from
/usr/lib64/libvirt.so.0
--
mg
10 years, 6 months
[libvirt] [PATCH] virlog: Add stack trace log when libvirt receives fatal signal
by Wangrui (K)
An earlier commit(c0c8c1) Dan removed global log buffer feature entirely
because of duplicate log messages. An improvement is introduced. That is
dumping stack trace instead of log buffer upon libvirt crash.
Signed-off-by: Zhou Yimin <zhouyimin(a)huawei.com>
Signed-off-by: Wang Rui <moon.wangrui(a)huawei.com>
---
When libvirt receives fatal signal, the log output shows as following.
Caught abort signal dumping stack trace:
====== start of stack trace =====
/usr/lib64/libvirt.so.0(+0x1d4fde)[0x7f001b1b0fde]
/lib64/libpthread.so.0(+0xf800)[0x7f00182ed800]
/lib64/libc.so.6(gsignal+0x35)[0x7f0017b91b55]
/lib64/libc.so.6(abort+0x181)[0x7f0017b93131]
/lib64/libc.so.6(+0x70e0f)[0x7f0017bcfe0f]
/lib64/libc.so.6(+0x76618)[0x7f0017bd5618]
/lib64/libc.so.6(+0x76c3f)[0x7f0017bd5c3f]
/lib64/libc.so.6(+0x78fee)[0x7f0017bd7fee]
/lib64/libc.so.6(__libc_malloc+0x77)[0x7f0017bda747]
/usr/lib64/libvirt.so.0(virReallocN+0x65)[0x7f001b03c06d]
/usr/lib64/libvirt.so.0(+0x7ebbc)[0x7f001b05abbc]
/usr/lib64/libvirt.so.0(virFileReadLimFD+0x50)[0x7f001b05ad4a]
/usr/lib64/libvirt.so.0(virFileReadAll+0xa6)[0x7f001b05c7d1]
/usr/lib64/libvirt.so.0(virProcessGetStartTime+0x9a)[0x7f001b080ee9]
/usr/lib64/libvirt.so.0(virNetSocketGetUNIXIdentity+0xc1)[0x7f001b1bf709]
/usr/lib64/libvirt.so.0(virNetServerClientGetUNIXIdentity+0x68)[0x7f001b1b35b6]
/usr/sbin/libvirtd(+0x20103)[0x7f001bb8f103]
/usr/sbin/libvirtd(+0x20347)[0x7f001bb8f347]
/usr/lib64/libvirt.so.0(+0x1db9bd)[0x7f001b1b79bd]
/usr/lib64/libvirt.so.0(virNetServerProgramDispatch+0x209)[0x7f001b1b7dff]
/usr/lib64/libvirt.so.0(+0x1d5448)[0x7f001b1b1448]
/usr/lib64/libvirt.so.0(+0x1d572a)[0x7f001b1b172a]
/usr/lib64/libvirt.so.0(+0xb3964)[0x7f001b08f964]
/usr/lib64/libvirt.so.0(+0xb2dd0)[0x7f001b08edd0]
/lib64/libpthread.so.0(+0x77f6)[0x7f00182e57f6]
/lib64/libc.so.6(clone+0x6d)[0x7f0017c3a09d]
====== end of stack trace =====
src/libvirt_private.syms | 1 +
src/rpc/virnetserver.c | 43 +++++++++++++++++++++++
src/util/virlog.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
src/util/virlog.h | 2 ++
4 files changed, 134 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c3332c9..d781595 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1501,6 +1501,7 @@ virLogGetFilters;
virLogGetNbFilters;
virLogGetNbOutputs;
virLogGetOutputs;
+virLogEmergencyDumpAll;
virLogLock;
virLogMessage;
virLogParseDefaultPriority;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 7e3fc0a..2845098 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -340,6 +340,32 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc,
return 0;
}
+static void
+virNetServerFatalSignal(int sig, siginfo_t *siginfo ATTRIBUTE_UNUSED,
+ void *context ATTRIBUTE_UNUSED)
+{
+ struct sigaction sig_action;
+ int origerrno;
+
+ origerrno = errno;
+ virLogEmergencyDumpAll(sig);
+
+ /*
+ * If the signal is fatal, avoid looping over this handler
+ * by deactivating it
+ */
+#ifdef SIGUSR2
+ if (sig != SIGUSR2) {
+#endif
+ memset(&sig_action, 0, sizeof(sig_action));
+ sig_action.sa_handler = SIG_DFL;
+ sigaction(sig, &sig_action, NULL);
+ raise(sig);
+#ifdef SIGUSR2
+ }
+#endif
+ errno = origerrno;
+}
virNetServerPtr virNetServerNew(size_t min_workers,
size_t max_workers,
@@ -401,6 +427,23 @@ virNetServerPtr virNetServerNew(size_t min_workers,
sig_action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sig_action, NULL);
+ /*
+ * catch fatal errors to dump stack trace, also hook to USR2 for dynamic
+ * debugging purposes or testing
+ */
+ sig_action.sa_sigaction = virNetServerFatalSignal;
+ sig_action.sa_flags = SA_SIGINFO;
+ sigaction(SIGFPE, &sig_action, NULL);
+ sigaction(SIGSEGV, &sig_action, NULL);
+ sigaction(SIGILL, &sig_action, NULL);
+ sigaction(SIGABRT, &sig_action, NULL);
+#ifdef SIGBUS
+ sigaction(SIGBUS, &sig_action, NULL);
+#endif
+#ifdef SIGUSR2
+ sigaction(SIGUSR2, &sig_action, NULL);
+#endif
+
return srv;
error:
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 056950e..081b194 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <signal.h>
#include <execinfo.h>
#include <regex.h>
#if HAVE_SYSLOG_H
@@ -661,6 +662,93 @@ virLogStackTraceToFd(int fd)
}
static void
+virLogDumpAllFD(const char *msg, int len)
+{
+ size_t i;
+ bool found = false;
+
+ if (len <= 0)
+ len = strlen(msg);
+
+ for (i = 0; i < virLogNbOutputs; i++) {
+ if (virLogOutputs[i].f == virLogOutputToFd) {
+ int fd = (intptr_t) virLogOutputs[i].data;
+
+ if (fd >= 0) {
+ if (msg)
+ ignore_value(safewrite(fd, msg, len));
+ else
+ virLogStackTraceToFd(fd);
+
+ found = true;
+ }
+ }
+ }
+ if (!found) {
+ if (msg)
+ ignore_value(safewrite(STDERR_FILENO, msg, len));
+ else
+ virLogStackTraceToFd(STDERR_FILENO);
+ }
+}
+
+/**
+ * virLogEmergencyDumpAll:
+ * @signum: the signal number
+ *
+ * Emergency function called, possibly from a signal handler.
+ * It need to output the stack trace through the log output
+ * which are safe to use from a signal handler.
+ * In case none is found it is emitted to standard error.
+ */
+void
+virLogEmergencyDumpAll(int signum)
+{
+ switch (signum) {
+#ifdef SIGFPE
+ case SIGFPE:
+ virLogDumpAllFD("Caught signal Floating-point exception", -1);
+ break;
+#endif
+#ifdef SIGSEGV
+ case SIGSEGV:
+ virLogDumpAllFD("Caught Segmentation violation", -1);
+ break;
+#endif
+#ifdef SIGILL
+ case SIGILL:
+ virLogDumpAllFD("Caught illegal instruction", -1);
+ break;
+#endif
+#ifdef SIGABRT
+ case SIGABRT:
+ virLogDumpAllFD("Caught abort signal", -1);
+ break;
+#endif
+#ifdef SIGBUS
+ case SIGBUS:
+ virLogDumpAllFD("Caught bus error", -1);
+ break;
+#endif
+#ifdef SIGUSR2
+ case SIGUSR2:
+ virLogDumpAllFD("Caught User-defined signal 2", -1);
+ break;
+#endif
+ default:
+ virLogDumpAllFD("Caught unexpected signal", -1);
+ break;
+ }
+
+ virLogDumpAllFD(" dumping stack trace:\n", -1);
+ virLogDumpAllFD("\n\n ====== start of stack trace =====\n\n", -1);
+
+ virLogDumpAllFD(NULL, 1);
+
+ virLogDumpAllFD("\n\n ====== end of stack trace =====\n\n", -1);
+}
+
+static void
virLogOutputToFd(virLogSourcePtr source ATTRIBUTE_UNUSED,
virLogPriority priority ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED,
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 5b38891..628a2b1 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -201,6 +201,8 @@ extern void virLogVMessage(virLogSourcePtr source,
const char *fmt,
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
+extern void virLogEmergencyDumpAll(int signum);
+
bool virLogProbablyLogMessage(const char *str);
#endif
--
1.7.12.4
10 years, 6 months
[libvirt] [PATCH] qemu: Fix specifying char devs for PPC
by Olivia Yin
QEMU ppce500 board uses the old style -serial options.
Other PPC boards don't give any way to explicitly wire in a -chardev
except pseries which uses -device spapr-vty with -chardev.
---
src/qemu/qemu_capabilities.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b491f58..fe5dd19 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3460,13 +3460,17 @@ virQEMUCapsSupportsChardev(virDomainDefPtr def,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
return false;
- if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64))
+ if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64)
+ && (def->os.arch != VIR_ARCH_PPC) && (def->os.arch != VIR_ARCH_PPC64))
return true;
/* This may not be true for all ARM machine types, but at least
* the only supported non-virtio serial devices of vexpress and versatile
- * don't have the -chardev property wired up. */
+ * don't have the -chardev property wired up.
+ * For PPC machines, only pserial need -device spapr-vty with -chardev */
return (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO ||
(chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
- chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO));
+ chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) ||
+ (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+ chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO));
}
--
1.8.5
10 years, 6 months
[libvirt] [PATCH v6] migration: add support for migrateHost configuration
by Chen Fan
For now, we set the migration URI via command line '--migrate_uri' or
construct the URI by looking up the dest host's hostname which could be
solved by DNS automatically.
But in cases the dest host have two or more NICs to reach, we may need to
send the migration data over a specific NIC which is different from the
automatically resloved one for some reason like performance, security, etc.
thus we must explicitly specify the migrateuri in command line everytime,
but it is too troublesome if there are many such hosts(and don't forget
virt-manager).
This patch adds a configuration file option on dest host to save the
default value set which can be specified to a migration hostname or
one of this host's addresses used for transferring data, thus user doesn't
boring to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
---
src/qemu/libvirtd_qemu.aug | 1 +
src/qemu/qemu.conf | 9 ++++++++-
src/qemu/qemu_conf.c | 1 +
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_migration.c | 21 +++++++++++++++++----
src/qemu/test_libvirtd_qemu.aug.in | 1 +
6 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index e985d22..e7db7fe 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -84,6 +84,7 @@ module Libvirtd_qemu =
let network_entry = str_entry "migration_address"
| int_entry "migration_port_min"
| int_entry "migration_port_max"
+ | str_entry "migration_host"
let log_entry = bool_entry "log_timestamp"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 42f812d..1063625 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -450,12 +450,19 @@
#seccomp_sandbox = 1
-
# Override the listen address for all incoming migrations. Defaults to
# 0.0.0.0, or :: if both host and qemu are capable of IPv6.
#migration_address = "127.0.0.1"
+# The default hostname or IP address which will be used by a migration
+# source for transferring migration data to this host. The migration
+# source has to be able to resolve this hostname and connect to it so
+# setting "localhost" will not work. By default, the host's configured
+# hostname is used.
+#migration_host = "host.example.com"
+
+
# Override the port range used for incoming migrations.
#
# Minimum must be greater than 0, however when QEMU is not running as root,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 400c99c..f273056 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -576,6 +576,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
+ GET_VALUE_STR("migration_host", cfg->migrateHost);
GET_VALUE_STR("migration_address", cfg->migrationAddress);
GET_VALUE_BOOL("log_timestamp", cfg->logTimestamp);
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 5d2983a..78b08e5 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -163,6 +163,7 @@ struct _virQEMUDriverConfig {
int seccompSandbox;
+ char *migrateHost;
/* The default for -incoming */
char *migrationAddress;
int migrationPortMin;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f0df1a6..d6271fb 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2640,6 +2640,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
int ret = -1;
virURIPtr uri = NULL;
bool well_formed_uri = true;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ const char *migrateHost = cfg->migrateHost;
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
@@ -2653,8 +2655,9 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
/* The URI passed in may be NULL or a string "tcp://somehostname:port".
*
* If the URI passed in is NULL then we allocate a port number
- * from our pool of port numbers and return a URI of
- * "tcp://ourhostname:port".
+ * from our pool of port numbers, and if the migrateHost is configured,
+ * we return a URI of "tcp://migrateHost:port", otherwise return a URI
+ * of "tcp://ourhostname:port".
*
* If the URI passed in is not NULL then we try to parse out the
* port number and use that (note that the hostname is assumed
@@ -2664,8 +2667,17 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
goto cleanup;
- if ((hostname = virGetHostname()) == NULL)
- goto cleanup;
+ if (migrateHost != NULL) {
+ if (virSocketAddrIsNumeric(migrateHost) &&
+ virSocketAddrParse(NULL, migrateHost, AF_UNSPEC) < 0)
+ goto cleanup;
+
+ if (VIR_STRDUP(hostname, migrateHost) < 0)
+ goto cleanup;
+ } else {
+ if ((hostname = virGetHostname()) == NULL)
+ goto cleanup;
+ }
if (STRPREFIX(hostname, "localhost")) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2747,6 +2759,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
cleanup:
virURIFree(uri);
VIR_FREE(hostname);
+ virObjectUnref(cfg);
if (ret != 0) {
VIR_FREE(*uri_out);
if (autoPort)
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 30a4257..7796acc 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -70,6 +70,7 @@ module Test_libvirtd_qemu =
{ "keepalive_count" = "5" }
{ "seccomp_sandbox" = "1" }
{ "migration_address" = "127.0.0.1" }
+{ "migration_host" = "host.example.com" }
{ "migration_port_min" = "49152" }
{ "migration_port_max" = "49215" }
{ "log_timestamp" = "0" }
--
1.8.1.4
10 years, 6 months
[libvirt] [PATCH] tests: avoid dlsym mocking on mingw
by Eric Blake
I got a build failure when cross-compiling to mingw with the
mingw64-dbus package installed:
CC virmockdbus_la-virmockdbus.lo
../../tests/virmockdbus.c:29:6: error: 'dbus_connection_set_change_sigpipe' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
VIR_MOCK_STUB_VOID_ARGS(dbus_connection_set_change_sigpipe,
^
../../tests/virmockdbus.c:33:18: error: 'dbus_bus_get' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
VIR_MOCK_STUB_RET_ARGS(dbus_bus_get,
...
Well duh - mingw lacks dlopen and friends, even if it can support
dbus. A similar failure occured in virsystemdtest.c; but in that
file, we know that systemd is a Linux-only concept.
* tests/virmockdbus.c: Cripple on mingw.
* tests/virsystemdtest.c: Cripple on non-Linux.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule
tests/virmockdbus.c | 6 +++---
tests/virsystemdtest.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/virmockdbus.c b/tests/virmockdbus.c
index 8a01d9d..49db98c 100644
--- a/tests/virmockdbus.c
+++ b/tests/virmockdbus.c
@@ -1,7 +1,7 @@
/*
* virmockdbus.c: mocking of dbus message send/reply
*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 2013-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
#include <config.h>
-#ifdef WITH_DBUS
+#if defined(WITH_DBUS) && !defined(WIN32)
# include "virmock.h"
# include <dbus/dbus.h>
@@ -61,4 +61,4 @@ VIR_MOCK_LINK_RET_ARGS(dbus_connection_send_with_reply_and_block,
int, timeout_milliseconds,
DBusError *, error)
-#endif /* WITH_DBUS */
+#endif /* WITH_DBUS && !WIN32 */
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index 0fcd4e8..8f7b47e 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -22,7 +22,7 @@
#include "testutils.h"
-#ifdef WITH_DBUS
+#if defined(WITH_DBUS) && defined(__linux__)
# include <stdlib.h>
# include <dbus/dbus.h>
@@ -477,7 +477,7 @@ mymain(void)
VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virmockdbus.so")
-#else /* ! WITH_DBUS */
+#else /* ! (WITH_DBUS && __linux__) */
int
main(void)
{
--
1.9.0
10 years, 6 months