1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-08-17 09:49:59 +03:00

Compare commits

...

1017 Commits

Author SHA1 Message Date
d3d33c8281 Release of libvirt-0.8.3
* configure.ac docs/news.html.in libvirt.spec.in: updates
* po/*.po*: update and regenerated
2010-08-04 15:03:25 +02:00
bf0bf4e783 qemu: Fix PCI address allocation
Patch version revamped by Eric Blake <eblake@redhat.com> of Jiri
Denemark <jdenemar@redhat.com> original patch

When attaching a PCI device which doesn't explicitly set its PCI
address, libvirt allocates the address automatically. The problem is
that when checking which PCI address is unused, we only check for those
with slot number higher than the highest slot number ever used.

Thus attaching/detaching such device several times in a row (31 is the
theoretical limit, less then 30 tries are enough in practise) makes any
further device attachment fail. Furthermore, attaching a device with
predefined PCI address to 0:0:31 immediately forbids attachment of any
PCI device without explicit address.

This patch changes the logic so that we always check all PCI addresses
before we say there is no PCI address available.

Modifications from v1: revert back to remembering the last slot
reserved, but allow wraparound to not be limited by the end.
In this way, slots are still assigned in the same order as
before the patch, rather than filling in the gaps closest to
0 and risking making windows guests mad.

* src/qemu/qemu_conf.c: fix pci reservation code to do a round-robbin
  check of all available PCI splot availability before failing.
2010-08-04 14:46:06 +02:00
9cbc3c8e06 OpenVZ: implement suspend/resume driver APIs
* src/openvz/openvz_driver.c: implements openvzDomainSuspend and
  openvzDomainResume
2010-08-04 14:00:07 +02:00
6328dfcb67 Don't leak delay string when freeing virInterfaceBridgeDefs 2010-08-03 11:37:05 -04:00
7c5f80e2f0 Fix build error in virsh.c
Another gettext string with no format args sent to printf as a format string.
2010-08-03 10:37:34 -04:00
14954fb8cb esx: Set storage pool target path to host.mountInfo.path
Now all storage pool types expose the target path.
2010-08-02 22:25:15 +02:00
5254546bba esx: Make storage pool lookup by name and UUID more robust
Don't rely on summary.url anymore, because its value is different
between an esx:// and vpx:// connection. Use host.mountInfo.path
instead.

Don't fallback to lookup by UUID (actually lookup by absolute path)
in esxVI_LookupDatastoreByName when lookup by name fails. Add a
seperate function for this: esxVI_LookupDatastoreByAbsolutePath
2010-08-02 22:25:15 +02:00
e4938ce2f1 esx: Restrict vpx:// to handle a single host in a vCenter
Now a vpx:// connection has an explicitly specified host. This
allows to enabled several functions for a vpx:// connection
again, like host UUID, hostname, general node info, max vCPU
count, free memory, migration and defining new domains.

Lookup datacenter, compute resource, resource pool and host
system once and cache them. This simplifies the rest of the
code and reduces overall HTTP(S) traffic a bit.

esx:// and vpx:// can be mixed freely for a migration.

Ensure that migration source and destination refer to the
same vCenter. Also directly encode the resource pool and
host system object IDs into the migration URI in the prepare
function. Then directly build managed object references in
the perform function instead of re-looking up already known
information.
2010-08-02 22:25:15 +02:00
9f85668bd7 esx: Map some managed object types
Datacenter, ComputeResource and HostSystem will be used for
simplified handling and caching.
2010-08-02 22:25:15 +02:00
ac041072f8 esx: Parse the path of the URI
The path will be used to specify the datacenter, compute resource
and host system to be used with a vpx:// connection.
2010-08-02 22:25:15 +02:00
6790805d6e qemu: don't lose error on setting monitor capabilities
Spotted by clang.  Regression introduced in commit e72cc3c11d.

* src/qemu/qemu_driver.c (qemuConnectMonitor): Don't lose error status.
2010-08-02 14:16:10 -06:00
aa2d747350 build: avoid compiler warning, for real this time
* tools/virsh.c (vshParseArgv): Drop spurious argument to printf.
2010-08-02 14:16:03 -06:00
a7d65ee9c1 Fix virsh error message when -d arg is not numeric 2010-08-02 22:03:13 +02:00
c66bf97003 Add Aurelien to AUTHORS 2010-08-02 21:55:33 +02:00
4bde003371 Fix a couple of typo in iSCSI backend
- a pure typo error and a wrong command referenced in an error message.
2010-08-02 21:52:02 +02:00
b259bab8e7 Make virsh -d check its input
it was using atoi direct without checking leading to confusion
in case of flag error for example with -c

* tools/virsh.c: vshParseArgv() use virStrToLong_i and remove the
  unchecked atoi used to parse teh parameter
2010-08-02 21:20:26 +02:00
fd5b15ff1a Add iptables rule to fixup DHCP response checksum.
This patch attempts to take advantage of a newly added netfilter
module to correct for a problem with some guest DHCP client
implementations when used in conjunction with a DHCP server run on the
host systems with packet checksum offloading enabled.

The problem is that, when the guest uses a RAW socket to read the DHCP
response packets, the checksum hasn't yet been fixed by the IP stack,
so it is incorrect.

The fix implemented here is to add a rule to the POSTROUTING chain of
the mangle table in iptables that fixes up the checksum for packets on
the virtual network's bridge that are destined for the bootpc port (ie
"dhcpc", ie port 68) port on the guest.

Only very new versions of iptables will have this support (it will be
in the next upstream release), so a failure to add this rule only
results in a warning message. The iptables patch is here:

  http://patchwork.ozlabs.org/patch/58525/

A corresponding kernel module patch is also required (the backend of
the iptables patch) and that will be in the next release of the
kernel.
2010-08-02 11:34:14 -04:00
86b043ad3e Fix the ACS checking in the PCI code.
When trying to assign a PCI device to a guest, we have
to check that all bridges upstream of that device support
ACS.  That means that we have to find the parent bridge of
the current device, check for ACS, then find the parent bridge
of that device, check for ACS, etc.  As it currently stands,
the code to do this iterates through all PCI devices on the
system, looking for a device that has a range of busses that
included the current device's bus.

That check is not restrictive enough, though.  Depending on
how we iterated through the list of PCI devices, we could first
find the *topmost* bridge in the system; since it necessarily had
a range of busses including the current device's bus, we
would only ever check the topmost bridge, and not check
any of the intermediate bridges.

Note that this also caused a fairly serious bug in the
secondary bus reset code, where we could erroneously
find and reset the topmost bus instead of the inner bus.

This patch changes pciGetParentDevice() so that it first
checks if a bridge device's secondary bus exactly matches
the bus of the device we are looking for.  If it does, we've
found the correct parent bridge and we are done.  If it does not,
then we check to see if this bridge device's busses *include* the
bus of the device we care about.  If so, we mark this bridge device
as best, and go on.  If we later find another bridge device whose
busses include this device, but is more restrictive, then we
free up the previous best and mark the new one as best.  This
algorithm ensures that in the normal case we find the direct
parent, but in the case that the parent bridge secondary bus
is not exactly the same as the device, we still find the
correct bridge.

This patch was tested by me on a 4-port NIC with a
bridge without ACS (where assignment failed), a 4-port
NIC with a bridge with ACS (where assignment succeeded),
and a 2-port NIC with no bridges (where assignment
succeeded).

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-08-02 09:54:38 -04:00
32c6a959ac Free up memballoon def.
Forgetting to do this was causing a memory leak.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-08-02 09:36:54 -04:00
ab85b5eaa2 Don't put a semicolon on the end of a VIR_ENUM_IMPL.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-08-02 09:36:42 -04:00
f72e4a9db1 Fix a bogus warning when parsing <hostdev>
When parsing hostdev, the following message would be emitted:

10:17:19.052: error : virDomainHostdevDefParseXML:3748 : internal error unknown node alias

However, alias is appropriately parsed in
virDomainDeviceInfoParseXML anyway.  Disable the error message
in the initial XML parsing loop.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-08-02 09:36:28 -04:00
b6aa8e16bb Remove duplicate </p> from downloads.html.in 2010-08-01 01:54:40 +02:00
e670d39417 Update ID after stopping a domain 2010-07-30 22:49:26 +02:00
fd81a09729 openvzDomainCreateWithFlags: set domain id to the correct value
When an openvz domain is defined with virDomainDefineXML,
domain id is set to -1. A call to virDomainGetInfo after
starting the domain would then fail because this invalid
id is passed to openvzGetProcessInfo.
2010-07-30 22:25:32 +02:00
549b839960 storage: kill dead stores
Found by clang.  Clang complained that virStorageBackendProbeTarget
could dereference NULL if backingStoreFormat was NULL, but since all
callers passed a valid pointer, I added attributes instead of null
checks.

* src/storage/storage_backend.c
(virStorageBackendQEMUImgBackingFormat): Kill dead store.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.  Skip null checks, by adding attributes.
2010-07-30 14:13:47 -06:00
68e4be71be qemu: kill some dead stores
Spotted by clang.

* src/qemu/qemu_monitor.c (qemuMonitorClose): Kill dead store.
* src/qemu/qemu_driver.c (qemudDomainSaveImageStartVM): Likewise.
2010-07-30 11:33:26 -06:00
c52b90ed6c network: kill dead store
* src/network/bridge_driver.c (networkDefine): Kill dead store.
2010-07-30 11:29:20 -06:00
2f5097f38d xenapi: Update ID after starting a domain 2010-07-30 17:14:02 +02:00
6139b27477 esx: Update ID after starting a domain 2010-07-30 17:14:02 +02:00
435fa6d709 Fix DMI uuid parsing.
valgrind was complaining that virUUIDParse was depending on
an uninitialized value.  Indeed it was; virSetHostUUIDStr()
didn't initialize the dmiuuid buffer to 0's, meaning that
anything after the string read from /sys was uninitialized.
Clear out the dmiuuid buffer before use, and make sure to
always leave a \0 at the end.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-30 11:04:07 -04:00
e7da872294 Do not activate boot=on on devices when not using KVM
Basically the 'boot=on' boot selection device is something present in
KVM but not in upstream QEmu, as a result if we boot a QEmu domain
without KVM acceleration we must disable boot=on ... even if the front
end kvm binary expose that capability in the help page.

* src/qemu/qemu_conf.c: in qemudBuildCommandLine if -no-kvm
  is passed, then deactivate QEMUD_CMD_FLAG_DRIVE_BOOT
2010-07-30 16:38:48 +02:00
4313e1b9b1 Fix a memory leak in the qemudBuildCommandLine.
ADD_ARG_LIT should only be used for literal arguments,
since it duplicates the memory.  Since virBufferContentAndReset
is already allocating memory, we should only use ADD_ARG.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-30 10:01:50 -04:00
5cff36e39a esx: Fix freeing of heterogeneous lists
Always call the free function of the base type. The base type
function then dynamically dispatches the call to the free function
for the actual type.
2010-07-30 14:42:57 +02:00
c38e2f7a39 esx: Switch from name to number checks in the subdrivers 2010-07-30 14:42:57 +02:00
25e34b703a esx: Improve blocked task detection and fix race condition
esxVI_WaitForTaskCompletion can take a UUID to lookup the
corresponding domain and check if the current task for it
is blocked by a question. It calls another function to do
this: esxVI_LookupAndHandleVirtualMachineQuestion looks up
the VirtualMachine and checks for a question. If there is
a question it calls esxVI_HandleVirtualMachineQuestion to
handle it.

If there was no question or it has been answered the call
to esxVI_LookupAndHandleVirtualMachineQuestion returns 0.
If any error occurred during the lookup and answering
process -1 is returned. The problem with this is, that -1
is also returned when there was no error but the question
could not be answered. So esxVI_WaitForTaskCompletion cannot
distinguish between this two situations and reports that a
question is blocking the task even when there was actually
another problem.

This inherent problem didn't surface until vSphere 4.1 when
you try to define a new domain. The driver tries to lookup
the domain that is just in the process of being registered.
There seems to be some kind of race condition and the driver
manages to issue a lookup command before the ESX server was
able to register the domain. This used to work before.

Due to the return value problem described above the driver
reported a false error message in that case.

To solve this esxVI_WaitForTaskCompletion now takes an
additional occurrence parameter that describes whether or
not to expect the domain to be existent. Also add a new
parameter to esxVI_LookupAndHandleVirtualMachineQuestion
that allows to distinguish if the call returned -1 because
of an actual error or because the question could not be
answered.
2010-07-30 14:42:57 +02:00
2c216d95e8 esx: silence spurious compiler warning
* src/esx/esx_vi_types.c (_DESERIALIZE_NUMBER)
(ESX_VI__TEMPLATE__DESERIALIZE_NUMBER): Add range check to shut up
gcc 4.5.0 regarding long long.
2010-07-29 14:36:43 -06:00
701f356ac6 build: distribute libvirt_qemu.syms
* src/Makefile.am (EXTRA_DIST): Ensure 'make distcheck' and
'rpmbuild' can reproduce a build.
* daemon/Makefile.am (DAEMON_SOURCES): Likewise.
2010-07-29 14:19:40 -06:00
e7064aa6a2 build: restore operation of bit-rotted 'make cov'
'./autobuild.sh' with lcov installed discovered that our
coverage support has been bit-rotting for a while.  This
restores it back to a successful state, although I have
not yet spent any time looking through the resulting files to
look for low-hanging fruit in the unit test coverage front.

* configure.ac: Clear COMPILER_FLAGS at right place.
* Makefile.am (cov): Newer genhtml no longer likes plain -s.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Don't AC_SUBST
COMPILER_FLAGS; it is a shell variable for use in configure only.
* src/Makefile.am (AM_CFLAGS, AM_LDFLAGS): New variables, to make
it easier to provide global flag additions.  Use throughout, to
uniformly apply coverage flags.
* .gitignore: Globally ignore gcov output.
* daemon/.gitignore: Simplify.
* src/.gitignore: Likewise.
* tests/.gitignore: Likewise.
2010-07-29 13:41:25 -06:00
08ae41e930 xen: fix logic bug
The recent switch to enable -Wlogical-op paid off again.
gcc 4.5.0 (rawhide) is smarter than 4.4.4 (Fedora 13).

* src/xen/xend_internal.c (xenDaemonAttachDeviceFlags)
(xenDaemonUpdateDeviceFlags, xenDaemonDetachDeviceFlags): Use
correct operator.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-07-29 13:29:08 -06:00
d580eafca8 build: fix 'make syntax-check' failure
src/lxc/veth.c:150:        VIR_DEBUG(_("Failed to delete '%s' (%d)"),
src/lxc/veth.c:188:            VIR_DEBUG(_("Failed to disable '%s' (%d)"),
maint.mk: do not mark these strings for translation

* src/lxc/veth.c (vethDelete, vethInterfaceUpOrDown): Don't
translate VIR_DEBUG.
2010-07-29 13:28:32 -06:00
938f2dbd9e lxc: Fix return values of veth.c functions
Previously, the functions in src/lxc/veth.c could sometimes return
positive values on failure rather than -1. This made accurate error
reporting difficult, and led to one failure to catch an error in a
calling function.

This patch makes all the functions in veth.c consistently return 0 on
success, and -1 on failure. It also fixes up the callers to the veth.c
functions where necessary.

Note that this patch may be related to the bug:

  https://bugzilla.redhat.com/show_bug.cgi?id=607496.

It will not fix the bug, but should unveil what happens.

* po/POTFILES.in - add veth.c, which previously had no translatable strings
* src/lxc/lxc_controller.c
* src/lxc/lxc_container.c
* src/lxc/lxc_driver.c    - fixup callers to veth.c, and remove error logs,
                            as they are now done in veth.c
* src/lxc/veth.c - make all functions consistently return -1 on error.
* src/lxc/veth.h - use ATTRIBUTE_NONNULL to protect against NULL args.
2010-07-29 14:08:35 -04:00
1999e4f8f8 Eliminate memory leak in xenUnifiedDomainInfoListFree
This fixes a leak described in

   https://bugzilla.redhat.com/show_bug.cgi?id=590073

xenUnifiedDomainInfoList has a pointer to a list of pointers to
xenUnifiedDomain. We were freeing up all the domains, but neglecting
to free the list.

This was found by Paolo Bonzini <pbonzini@redhat.com>.
2010-07-29 12:25:24 -04:00
b611a3fb47 lxc: Fix 'autostart' doesn't take effect actually
lxcStartup forgot to call lxcAutostartConfigs. Fix it.

This patch should fix https://bugzilla.redhat.com/show_bug.cgi?id=589863 .
2010-07-29 09:02:05 -06:00
6bd5a7c200 Fix --with-xen-proxy related compile error
Move virDomainChrTargetTypeToString out of the #ifndef PROXY
block, because it's used outside of it.
2010-07-29 17:00:59 +02:00
56b408231a Fix a potential race in pciInitDevice.
If detecting the FLR flag of a pci device fails, then we
could run into the situation of trying to close a file
descriptor twice, once in pciInitDevice() and once in pciFreeDevice().
Fix that by removing the pciCloseConfig() in pciInitDevice() and
just letting pciFreeDevice() handle it.

Thanks to Chris Wright for pointing out this problem.

While we are at it, fix an error check.  While it would actually
work as-is (since success returns 0), it's still more clear to
check for < 0 (as the rest of the code does).

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-29 10:18:23 -04:00
82b6d7600e qemu: virtio console support
Enable specifying a virtio console device with:

<console type='pty'>
  <target type='virtio'/>
</console>
2010-07-28 16:48:00 -04:00
6b24755235 domain conf: Track <console> target type
All <console> devices now export a <target> type attribute. QEMU defaults
to 'serial', UML defaults to 'uml, xen can be either 'serial' or 'xen'
depending on fullvirt. Understandably there is lots of test fallout.

This will be used to differentiate between a serial vs. virtio console for
QEMU.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-07-28 16:47:59 -04:00
6488ea2c5c domain conf: char: Add an explicit targetType field
targetType only tracks the actual <target> format we are parsing. Currently
we only fill abide this value for channel devices.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-07-28 16:47:58 -04:00
50147933a5 domain conf: Rename character prop targetType -> deviceType
There is actually a difference between the character device type (serial,
parallel, channel, ...) and the target type (virtio, guestfwd). Currently
they are awkwardly conflated.

Start to pull them apart by renaming targetType -> deviceType. This is
an entirely mechanical change.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-07-28 16:47:57 -04:00
4a34633a7f docs: domain: Document virtio <channel>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-07-28 16:47:56 -04:00
b2a4a383d3 tests: Test qemuxml2xml when expected xml changes
Add tests for auto memballon, implicit IDE, SCSI, virtio channel
controllers, and console/serial back compat.

Additionally, an explicit qemuxml2argvtest for scsi disks is added.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-07-28 16:47:56 -04:00
e4fb6a3c7d fix handling of PORT_PROFILE_RESPONSE_INPROGRESS netlink message
During function test of the 802.1Qbg implementation in lldpad we came
across a small problem in the handling of the netlink message
corresponding to PORT_PROFILE_RESPONSE_INPROGRESS. This should not
result in returning the default rc=1.

- src/util/macvtap.c: fix getPortProfileStatus() to return 0 in that
  case and also fix an indentation problem
2010-07-28 16:17:21 +02:00
40a0e82c87 maint: fix comment typos
* src/network/bridge_driver.c
(networkAddMasqueradingIptablesRules): Fix spelling and grammar.
2010-07-28 08:07:16 -06:00
8bb0cd14e7 Fix up confusing indentation in qemudDomainAttachHostPciDevice.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-28 09:47:47 -04:00
40e973dd00 maint: turn on gcc logical-op checking
This would have detected the bug in commit 38ad33931 (Aug 09), which
we missed until commit f828ca35 (Jul 10); over 11 months later.

However, on Fedora 13, it also triggers LOTS of warnings from
the libcurl-devel header for two files:

esx/esx_vi.c: In function 'esxVI_CURL_Perform':
esx/esx_vi.c:232: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
esx/esx_vi.c:232: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
esx/esx_vi.c:232: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
...
xenapi/xenapi_driver.c: In function 'call_func':
xenapi/xenapi_driver.c:1872: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
xenapi/xenapi_driver.c:1872: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
xenapi/xenapi_driver.c:1872: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
...

libcurl allows to disable the type-checking code that triggers those
warnings, along with the reduction in type-safety of calls to some
libcurl functions. I figure this is worth the improved compiler
checking throughout the rest of libvirt.

* acinclude.m4 (--enable-compile-warnings=error): Add -Wlogical-op.
* configure.ac: Add -DCURL_DISABLE_TYPECHECK to LIBCURL_CFLAGS to
avoid compilation warning.

Suggested by Daniel P. Berrange.
Tweaked by Matthias Bolte.
2010-07-28 15:25:36 +02:00
e5360d0bfe libvirt-guests: add reload, condrestart
Optional per LSB, but required by Fedora:
https://fedoraproject.org/wiki/Packaging/SysVInitScript

* daemon/libvirt-guests.init.in (main): Add more required
commands.
2010-07-28 07:22:35 -06:00
c629a2883c libvirt-guests: enhance status
LSB and https://fedoraproject.org/wiki/Packaging/SysVInitScript
require status to output something useful, rather than just use
the exit code.

* daemon/libvirt-guests.init.in (rh_status): Break into new routine,
and provide output.
(usage): Document status.
2010-07-28 07:22:25 -06:00
592277bcff libvirt-guests: detect invalid arguments
Reject extra arguments.
Return the correct status for unknown arguments, as mandated by
https://fedoraproject.org/wiki/Packaging/SysVInitScript
Add --help, as a permitted extension.

* daemon/libvirt-guests.init.in (usage): New function.  Use it in
more places, and return correct value.
2010-07-28 06:46:29 -06:00
9749d94f7b Invert logic for checking for QEMU disk cache options
QEMU has had two different syntax for disk cache options

 Old: on|off
 New: writeback|writethrough|none

QEMU recently added another 'unsafe' option which broke the
libvirt check. We can avoid this & future breakage, if we
do a negative check for the old syntax, instead of a positive
check for the new syntax

* src/qemu/qemu_conf.c: Invert cache option check
2010-07-28 11:27:13 +01:00
4f24ca01e8 qemu: Allow setting boot menu on/off
Add a new element to the <os> block:

  <bootmenu enable="yes|no"/>

Which maps to -boot,menu=on|off on the QEMU command line.

I decided to use an explicit 'enable' attribute rather than just make the
bootmenu element boolean. This allows us to treat lack of a bootmenu element
as 'use hypervisor default'.
2010-07-27 16:38:32 -04:00
f8b76f419a docs: Link wiki FAQ to main page
Since DV recommended keeping the build instructions distributed with the
source, move them from the old FAQ to the downloads page.
2010-07-27 15:41:36 -04:00
6fe9025eb5 qemu: Error on unsupported graphics config
Throw an explicit error if multiple graphics devices are specified, or
an unsupported type is specified (rdp).
2010-07-27 15:41:36 -04:00
d1018b1bde libvirt-guests: Don't throw errors if libvirtd is not installed
When only client parts of libvirt are installed (i.e., no libvirtd
daemon), libvirt-guests init script in its default configuration would
throw seriously looking errors during host shutdown:

Running guests on default URI: error: unable to connect to
'/var/run/libvirt/libvirt-sock', libvirtd may need to be started: No
such file or directory
error: failed to connect to the hypervisor

This patch changes the script to print rather harmless message in that
situation:

Running guests on default URI: libvirtd not installed; skipping this
URI.
2010-07-27 14:21:51 +02:00
71e92a1575 Force FLR on for buggy SR-IOV devices.
Some buggy PCI devices actually support FLR, but
forget to advertise that fact in their PCI config space.
However, Virtual Functions on SR-IOV devices are
*required* to support FLR by the spec, so force has_flr
on if this is a virtual function.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-26 16:30:28 -04:00
4018a026b2 build: fix VPATH builds
After the recent libvirt-qemu library addition, VPATH builds fail with:

  CC     libvirt_qemu_la-libvirt-qemu.lo
In file included from ../../src/libvirt-qemu.c:29:
../../include/libvirt/libvirt-qemu.h:17:22: error: libvirt.h: No such file or directory
...
  CCLD   libvirt-qmeu.la
/usr/bin/ld: cannot open linker script file libvirt_qemu.syms: No such file or directory

This fixes both issues (there are still some documentation VPATH issues,
but those don't show up with 'make check').

* configure.ac (LIBVIRT_QEMU_SYMBOL_FILE): While libvirt.syms is
generated and lives in $(builddir), libvirt_qemu.syms is static
and lives in $(srcdir).
* include/libvirt/libvirt-qemu.h (includes): Pull in libvirt.h via
the public location, since this is a public header.
2010-07-26 12:06:48 -06:00
46bcdb960d pciResetDevice: use inactive devices to determine safe reset
When doing a PCI secondary bus reset, we must be sure that there are no
active devices on the same bus segment.  The active device tracking is
designed to only track host devices that are active in use by guests.
This ignores host devices that are actively in use by the host.  So the
current logic will reset host devices.

Switch this logic around and allow sbus reset when we are assigning all
devices behind a bridge to the same guest at guest startup or as a result
of a single attach-device command.

* src/util/pci.h: change signature of pciResetDevice to add an
  inactive devices list
* src/qemu/qemu_driver.c src/xen/xen_driver.c: use (or not) the new
  functionality of pciResetDevice() depending on the place of use
* src/util/pci.c: implement the interface and logic changes
2010-07-26 18:43:04 +02:00
042b208370 qemudDomainAttachHostPciDevice refactor to use new helpers
- src/qemu/qemu_driver.c: Eliminate code duplication by using the new
  helpers qemuPrepareHostdevPCIDevices and qemuDomainReAttachHostdevDevices.
  This reduces the number of open coded calls to pciResetDevice.
2010-07-26 18:34:24 +02:00
f1365b558d Add helpers qemuPrepareHostdevPCIDevice and qemuDomainReAttachHostdevDevices
- src/qemu/qemu_driver.c: These new helpers take hostdev list and count
  directly rather than getting them indirectly from domain definition.
  This will allow reuse for the attach-device case.
2010-07-26 18:23:17 +02:00
8bd00c0edf qemuGetPciHostDeviceList take hostdev list directly
- src/qemu/qemu_driver.c: Update qemuGetPciHostDeviceList to take a
  hostdev list and count directly, rather than getting this indirectly
  from domain definition. This will allow reuse for the attach-device case.
2010-07-26 18:17:20 +02:00
d3864c3782 esx: Support vSphere 4.1
Also accept version > 4.1, but output a warning.
2010-07-24 21:22:54 +02:00
3827f7f087 esx: Add vpx:// scheme to allow direct connection to a vCenter
Add a pointer to the primary context of a connection and use it in all
driver functions that don't dependent on the context type. This includes
almost all functions that deal with a virDomianPtr. Therefore, using
a vpx:// connection allows you to perform all the usual domain related
actions like start, destroy, suspend, resume, dumpxml etc.

Some functions that require an explicitly specified ESX server don't work
yet. This includes the host UUID, the hostname, the general node info, the
max vCPU count and the free memory. Also not working yet are migration and
defining new domains.
2010-07-24 20:46:05 +02:00
1b38e92b7a esx: Don't ignore the vcenter query parameter
Since 070f61002f the vcenter query
parameter has been ignored, because the refactoring to use
esxUtil_ParseQuery was incomplete. This effectively broke migration,
because the vcenter query parameter is essential for a migration.
2010-07-24 17:31:05 +02:00
cf8cf8a59f esx: Add autodetection for the SCSI controller model
This works for file-backed SCSI disk device with a datastore
related source path.
2010-07-24 17:31:04 +02:00
afb85c5889 esx: Allow 'vmpvscsi' as SCSI controller model 2010-07-24 17:31:04 +02:00
8c145200e7 secaatest: Fix compilation
Since 68719c4bdd virSecurityDriverStartup
takes and additional parameter to control disk format probing.

Pass false as third parameter.
2010-07-24 17:15:11 +02:00
8f86eaca49 virt-aa-helper-test: Fix failure due to the new disk format probing option
Commit 68719c4bdd added the disk format
probing option. This makes virt-aa-helper-test fail because the domain
config didn't specifiy the disk format and it didn't pass '-p 1' to
virt-aa-helper to allow disk format probing.

Specify the disk format in the domain config. Pass the '-p 1' option
to virt-aa-helper for the test case with two disks. This way this test
also covers this new option.
2010-07-24 17:15:11 +02:00
d01340e796 virt-aa-helper: Make getopt accept the p option
Commit 68719c4bdd added the
p option to control disk format probing, but it wasn't added
to the getopt_long optstring parameter.

Add the p option to the getopt_long optstring parameter.
2010-07-24 17:15:11 +02:00
adde0e2cf6 virt-aa-helper: Fix return value of add_file_path
Commit a885334499 added this
function and wrapped vah_add_file in it. vah_add_file may
return -1, 0, 1. It returns 1 in case the call to valid_path
detects a restricted file. The original code treated a return
value != 0 as error. The refactored code treats a return
value < 0 as error. This triggers segfault in virt-aa-helper
and breaks virt-aa-helper-test for the restricted file tests.

Make sure that add_file_path returns -1 on error.
2010-07-24 17:15:11 +02:00
05c9a41336 virt-aa-helper: Ignore open errors again
virt-aa-helper used to ignore errors when opening files.
Commit a885334499 refactored
the related code and changed this behavior. virt-aa-helper
didn't ignore open errors anymore and virt-aa-helper-test
fails.

Make sure that virt-aa-helper ignores open errors again.
2010-07-24 17:15:11 +02:00
80f7a45c8d qemu-api: avoid build failure
* src/remote_protocol-structs: Tweak to match intentional type
change (with no ABI change) in remote protocol.
2010-07-23 17:03:56 -06:00
a71be01f04 Add tests for the new Qemu namespace XML.
Thanks to DV for knocking together the Relax-NG changes
quickly for me.

Changes since v1:
 - Change the domain.rng to correspond to the new schema
 - Don't allocate caps->ns in testQemuCapsInit since it is a static table

Changes since v2:
 - Change domain.rng to add restrictions on allowed environment names

Changes since v3:
 - Remove a bogus comment in the tests

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:45 -04:00
337d201ef2 Qemu remote protocol.
Since we are adding a new "per-hypervisor" protocol, we
make it so that the qemu remote protocol uses a new
PROTOCOL and PROGRAM number.  This allows us to easily
distinguish it from the normal REMOTE protocol.

This necessitates changing the proc in remote_message_header
from a "remote_procedure" to an "unsigned", which should
be the same size (and thus preserve the on-wire protocol).

Changes since v1:
 - Fixed up a couple of script problems in remote_generate_stubs.pl
 - Switch an int flag to a bool in dispatch.c

Changes since v2:
 - None

Changes since v3:
 - Change unsigned proc to signed proc, to conform to spec

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:33 -04:00
057e855324 Qemu arbitrary monitor commands.
Implement the qemu driver's virDomainQemuMonitorCommand
and hook it into the API entry point.

Changes since v1:
 - Rename the (external) qemuMonitorCommand to qemuDomainMonitorCommand
 - Add virCheckFlags to qemuDomainMonitorCommand

Changes since v2:
 - Drop ATTRIBUTE_UNUSED from the flags

Changes since v3:
 - Add a flag to priv so we only print out monitor command warning once.  Note
   that this has not been plumbed into qemuDomainObjPrivateXMLFormat or
   qemuDomainObjPrivateXMLParse, which means that if you run a monitor command,
   restart libvirtd, and then run another monitor command, you may get an
   an erroneous VIR_INFO.  It's a pretty minor matter, and I didn't think it
   warranted the additional code.
 - Add BeginJob/EndJob calls around EnterMonitor/ExitMonitor

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:24 -04:00
21adf03c2d Qemu Monitor API entry point.
Add the library entry point for the new virDomainQemuMonitorCommand()
entry point.  Because this is not part of the "normal" libvirt API,
it gets its own header file, library file, and will eventually
get its own over-the-wire protocol later in the series.

Changes since v1:
 - Go back to using the virDriver table for qemuDomainMonitorCommand, due to
   linking issues
 - Added versioning information to the libvirt-qemu.so

Changes since v2:
 - None

Changes since v3:
 - Add LGPL header to libvirt-qemu.c
 - Make virLibConnError and virLibDomainError macros instead of function calls

Changes since v4:
 - Move exported symbols to libvirt_qemu.syms

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:14 -04:00
ae027de32d Handle arbitrary qemu command-lines in qemuParseCommandLine.
Now that we have the ability to specify arbitrary qemu
command-line parameters in the XML, use it to handle unknown
command-line parameters when doing a native-to-xml conversion.

Changes since v1:
 - Rename num_extra to num_args
 - Fix up a memory leak on an error path

Changes since v2:
 - Add a VIR_WARN when adding the argument via qemu:arg

Changes since v3:
 - None

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:07 -04:00
869939a543 Qemu arbitrary command-line arguments.
Implement the qemu hooks for XML namespace data.  This
allows us to specify a qemu XML namespace, and then
specify:

<qemu:commandline>
 <qemu:arg value='arg'/>
 <qemu:env name='name' value='value'/>
</qemu:commandline>

In the domain XML.

Changes since v1:
 - Change the <qemu:arg>arg</qemu:arg> XML to <qemu:arg value='arg'/> XML
 - Fix up some memory leaks in qemuDomainDefNamespaceParse
 - Rename num_extra and extra to num_args and args, respectively
 - Fixed up some error messages
 - Make sure to escape user-provided data in qemuDomainDefNamespaceFormatXML

Changes since v2:
 - Add checking to ensure environment variable names are valid
 - Invert the logic in qemuDomainDefNamespaceFormatXML to return early

Changes since v3:
 - Change strspn() to c_isalpha() check of first letter of environment variable

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:29:59 -04:00
d55b734589 Add namespace callback hooks to domain_conf.
This patch adds namespace XML parsers to be hooked into
the main domain parser.  This allows for individual hypervisor
drivers to add per-namespace XML into the main domain XML.

Changes since v1:
 - Use a statically declared table for caps->ns, removing the need to
   allocate/free it.

Changes since v2:
 - None

Changes since v3:
 - None

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:29:51 -04:00
eac63161cc Fix SEGV on exit after domainEventDeregister()
When the last callback is removed using domainEventDeregister(), the
events dispatcher is deregistered from the C-library, but
domainEventsCallbacks is still an empty list.
On shutdown __del__() deregisters the dispatacher again, which SEGVs

	# You need the event-loop implementation from the Python examples;
	# give the file a name which is importable by Python.
	ln examples/domain-events/events-python/event-test.py eloop.py
	python -c 'from eloop import *
	import sys

	def dump(*args): print " ".join(map(str, args))

	virEventLoopPureStart()
	c = libvirt.open("xen:///")
	c.domainEventRegister(dump, None)
	c.domainEventDeregister(dump)
	sys.exit(0)'

domainEventDeregister() needs to delete domainEventCallbacks so subsequent
calls to __del__() and domainEventRegister() choose the right code paths.
Setting it to None is not enough, since calling domainEventRegiser() again
would trigger an TypeError.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-07-23 13:26:40 -06:00
2fc10e1a59 Fix .mailmap after accidental wrong committer address 2010-07-23 10:43:45 +01:00
f4828ca353 pciSharesBusWithActive fails to find multiple devices on bus
The first conditional is always true which means the iterator will
never find another device on the same bus.

    if (dev->domain != check->domain ||
        dev->bus != check->bus ||
  ----> (check->slot == check->slot &&
         check->function == check->function)) <-----

The goal of that check is to verify that the device is either:

  in a different pci domain
  on a different bus
  is the same identical device

This means libvirt may issue a secondary bus reset when there are
devices
on that bus that actively in use by the host or another guest.

* src/util/pci.c: fix a bogus test in pciSharesBusWithActive()
2010-07-23 11:25:24 +02:00
8d4f024221 Fix incorrect use of private data in remote driver
The remote driver is using the wrong privateData field in
a couple of functions. THis is harmless for stateful
drivers like QEMU/UML/LXC, but will crash with Xen

* src/remote/remote_driver.c: Fix use of privateData field
2010-07-23 05:16:18 -04:00
6ea90b843e Set a stable & high MAC addr for guest TAP devices on host
A Linux software bridge will assume the MAC address of the enslaved
interface with the numerically lowest MAC addr. When the bridge
changes MAC address there is a period of network blackout, so a
change should be avoided. The kernel gives TAP devices a completely
random MAC address. Occassionally the random TAP device MAC is lower
than that of the physical interface (eth0, eth1etc) that is enslaved,
causing the bridge to change its MAC.

This change sets an explicit MAC address for all TAP devices created
using the configured MAC from the XML, but with the high byte set
to 0xFE. This should ensure TAP device MACs are higher than any
physical interface MAC.

* src/qemu/qemu_conf.c, src/uml/uml_conf.c: Pass in a MAC addr
  for the TAP device with high byte set to 0xFE
* src/util/bridge.c, src/util/bridge.h: Set a MAC when creating
  the TAP device to override random MAC
2010-07-23 10:15:04 +01:00
020d220421 Fix PCI address assignment if no IDE controller is present
The PCI slot 1 must be reserved at all times, since PIIX3 is
always present, even if no IDE device is in use for guest disks

* src/qemu/qemu_conf.c: Always reserve slot 1 for PIIX3
2010-07-23 10:14:50 +01:00
7af5f4689f lxc: force kill of init process by sending SIGKILL if needed
Init process may remain after sending SIGTERM for some reason.
For example, if original init program is used, it is definitely
not killed by SIGTERM.

* src/lxc/lxc_controller.c: kill with SIGKILL if SIGTERM wasn't
  sufficient
2010-07-22 18:57:43 +02:00
ae3d31bf4f Remove erroneous setting of return value to errno.
One error exit in virStorageBackendCreateBlockFrom was setting the
return value to errno. The convention for volume build functions is to
return 0 on success or -1 on failure. Not only was it not necessary to
set the return value (it defaults to -1, and is set to 0 when
everything has been successfully completed), in the case that some
caller were checking for < 0 rather than != 0, they would incorrectly
believe that it completed successfully.
2010-07-21 17:32:19 -04:00
3e0f05fc4c Change virDirCreate to return -errno on failure.
virDirCreate also previously returned 0 on success and errno on
failure. This makes it fit the recommended convention of returning 0
on success, -errno (ie a negative number) on failure.
2010-07-21 14:32:59 -04:00
ace1a2bac4 Make virStorageBackendCopyToFD return -errno.
Previously virStorageBackendCopyToFD would simply return -1 on
error. This made the error return from one of its callers inconsistent
(createRawFileOpHook is supposed to return -errno, but if
virStorageBackendCopyToFD failed, createRawFileOpHook would just
return -1). Since there is a useful errno in every case of error
return from virStorageBackendCopyToFD, and since the other uses of
that function ignore the return code (beyond simply checking to see if
it is < 0), this is a safe change.
2010-07-21 14:32:45 -04:00
2ad04f7853 Change virFileOperation to return -errno (ie < 0) on error.
virFileOperation previously returned 0 on success, or the value of
errno on failure. Although there are other functions in libvirt that
use this convention, the preferred (and more common) convention is to
return 0 on success and -errno (or simply -1 in some cases) on
failure. This way the check for failure is always (ret < 0).

* src/util/util.c - change virFileOperation and virFileOperationNoFork to
                    return -errno on failure.

* src/storage/storage_backend.c, src/qemu/qemu_driver.c
  - change the hook functions passed to virFileOperation to return
    -errno on failure.
2010-07-21 14:32:35 -04:00
ee0684aba4 Document the memory balloon device
* formatdomain.html.in: Document <memballoon> element
2010-07-21 11:53:56 +01:00
0e308c2c9f Re-arrange PCI device address assignment to match QEMU's default
To try and ensure that people upgrading from old QEMU get guests
with the same PCI device ordering, change the way we assign addrs
to match QEMU's default order. This should make Windows less
annoyed.

* src/qemu/qemu_conf.c: Follow QEMU's default PCI ordering
  logic when assigning addresses
* tests/*.args: Update for changed PCI addresses
2010-07-21 11:35:21 +01:00
b2f1863533 Explicitly represent balloon device in XML and handle PCI address
To allow compatibility with older QEMU PCI device slot assignment
it is necessary to explicitly track the balloon device in the
XML. This introduces a new device

   <memballoon model='virtio|xen'/>

It can also have a PCI address, auto-assigned if necessary.

The memballoon will be automatically added to all Xen and QEMU
guests by default.

* docs/schemas/domain.rng: Add <memballoon> element
* src/conf/domain_conf.c, src/conf/domain_conf.h: parsing
  and formatting for memballoon device. Always add a memory
  balloon device to Xen/QEMU if none exists in XML
* src/libvirt_private.syms: Export memballoon model APIs
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Honour the
  PCI device address in memory balloon device
* tests/*: Update to test new functionality
2010-07-21 11:33:11 +01:00
ccd2c82ee4 Rearrange VGA/IDE controller address reservation
The first VGA and IDE devices need to have fixed PCI address
reservations. Currently this is handled inline with the other
non-primary VGA/IDE devices. The fixed virtio balloon device
at slot 3, ensures auto-assignment skips the slots 1/2. The
virtio address will shortly become configurable though. This
means the reservation of fixed slots needs to be done upfront
to ensure that they don't get re-used for other devices.

This is more or less reverting the previous changeset:

  commit 83acdeaf17
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Feb 3 16:11:29 2010 +0000

  Fix restore of QEMU guests with PCI device reservation

The difference is that this time, instead of unconditionally
reserving the address, we only reserve the address if it was
initially type=none. Addresses of type=pci were handled
earlier in process by qemuDomainPCIAddressSetCreate(). This
ensures restore step doesn't have problems

* src/qemu/qemu_conf.c: Reserve first VGA + IDE address
  upfront
2010-07-21 11:30:26 +01:00
021251bd7d Remove inappropriate use of VIR_ERR_NO_SUPPORT
The VIR_ERR_NO_SUPPORT refers to an API which is not implemented.
There is a separate VIR_ERR_CONFIG_UNSUPPORTED for XML config
options that are not available with the current hypervisor.

* src/qemu/qemu_conf.c, src/qemu/qemu_driver.c: Remove
  many VIR_ERR_NO_SUPPORT replace with VIR_ERR_CONFIG_UNSUPPORTED
2010-07-21 11:30:26 +01:00
cd35e8927f Fix a NULL dereference in the case that the arg in question
didn't exist.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 12:51:12 -04:00
4d13418890 Remove bogus free of static strings
Remove bogus free of statically allocated strings introduced
in 03ca42046a

* src/conf/capabilities.c: Don't free static strings for
  default disk driver type/name
2010-07-20 17:09:41 +01:00
f0c8e1cb37 Fix a deadlock in bi-directional p2p concurrent migration.
If you try to execute two concurrent migrations p2p
from A->B and B->A, the two libvirtd's will deadlock
trying to perform the migrations.  The reason for this is
that in p2p migration, the libvirtd's are responsible for
making the RPC Prepare, Migrate, and Finish calls.  However,
they are currently holding the driver lock while doing so,
which basically guarantees deadlock in this scenario.

This patch fixes the situation by adding
qemuDomainObjEnterRemoteWithDriver and
qemuDomainObjExitRemoteWithDriver helper methods.  The Enter
take an additional object reference, then drops both the
domain object lock and the driver lock.  The Exit takes
both the driver and domain object lock, then drops the
reference.  Adding calls to these Enter and Exit helpers
around remote calls in the various migration methods
seems to fix the problem for me in testing.

This should make the situation safe. The additional domain
object reference ensures that the domain object won't disappear
while this operation is happening.  The BeginJob that is called
inside of qemudDomainMigratePerform ensures that we can't execute a
second migrate (or shutdown, or save, etc) job while the
migration is active.  Finally, the additional check on the state
of the vm after we reacquire the locks ensures that we can't
be surprised by an external event (domain crash, etc).

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 09:52:52 -04:00
963a5b7a08 Make virsh setmaxmem balloon only when successful.
After playing around with virsh setmaxmem for a bit,
I ran into some surprising behavior; if a hypervisor does
not support the virDomainSetMaxMemory() API, but the value
specified for setmaxmem is less than the current amount
of memory in the domain, the domain would be ballooned
down *before* an error was reported.

To make this more consistent, run virDomainSetMaxMemory()
before trying to shrink; that way, if an error is thrown,
no changes to the running domain are made.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 09:44:14 -04:00
4af1817d1d Use unsigned long in cmdSetmem.
The virsh command "setmem" takes as input a number that
should represent an unsigned long number of kilobytes.  Fix
cmdSetmem to properly parse this as an unsigned long instead
of an int.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-20 09:35:29 -04:00
e0f26c46ae fsync new storage volumes even if new volume was copied.
Originally the storage volume files were opened with O_DSYNC to make
sure they were flushed to disk immediately. It turned out that this
was extremely slow in some cases, so the O_DSYNC was removed in favor
of just calling fsync() after all the data had been written. However,
this call to fsync was inside the block that is executed to zero-fill
the end of the volume file. In cases where the new volume is copied
from an old volume, and they are the same length, this fsync would
never take place.

Now the fsync is *always* done, unless there is an error (in which
case it isn't important, and is most likely inappropriate.
2010-07-19 21:01:28 -04:00
35bebb5782 Don't skip zero'ing end of volume file when inputvol is shorter than newvol
A missing set of braces around an error condition caused us to skip
zero'ing out the remainder of a new volume file if the new volume was
longer than the original (the goto was supposed to be taken only in
the case of error, but was always being taken).
2010-07-19 21:01:12 -04:00
4487d33f67 Always clear out the last_error in virshReportError.
Otherwise you can get bogus "unknown error" printouts on
subsequent commands.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-19 14:56:29 -04:00
0cdff7b5e7 Fix up inconsistent virsh option error reporting.
The virsh option error reporting was not being used
consistently; some commands would spit out errors on
missing required options while others would just silently fail.
However, vshCommandOptString knows which ones are required
and which ones aren't, so make it spit out an error where
appropriate.  The rest of the patch is just cleaning up
the uses of vshCommandOptString to deal with the new error
reporting.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-19 14:51:00 -04:00
187da82fea Use the extract backing store format in storage volume lookup
The storage volume lookup code was probing for the backing store
format, instead of using the format extracted from the file
itself. This meant it could report in accurate information. If
a format is included in the file, then use that in preference,
with probing as a fallback.

* src/storage/storage_backend_fs.c: Use extracted backing store
  format
2010-07-19 18:25:14 +01:00
27f45438c8 Rewrite qemu-img backing store format handling
When creating qcow2 files with a backing store, it is important
to set an explicit format to prevent QEMU probing. The storage
backend was only doing this if it found a 'kvm-img' binary. This
is wrong because plenty of kvm-img binaries don't support an
explicit format, and plenty of 'qemu-img' binaries do support
a format. The result was that most qcow2 files were not getting
a backing store format.

This patch runs 'qemu-img -h' to check for the two support
argument formats

  '-o backing_format=raw'
  '-F raw'

and use whichever option it finds

* src/storage/storage_backend.c: Query binary to determine
  how to set the backing store format
2010-07-19 18:25:14 +01:00
03ca42046a Add ability to set a default driver name/type when parsing disks
Record a default driver name/type in capabilities struct. Use this
when parsing disks if value is not set in XML config.

* src/conf/capabilities.h: Record default driver name/type for disks
* src/conf/domain_conf.c: Fallback to default driver name/type
  when parsing disks
* src/qemu/qemu_driver.c: Set default driver name/type to raw
2010-07-19 18:25:14 +01:00
68719c4bdd Disable all disk probing in QEMU driver & add config option to re-enable
Disk format probing is now disabled by default. A new config
option in /etc/qemu/qemu.conf will re-enable it for existing
deployments where this causes trouble
2010-07-19 18:25:13 +01:00
f70e080962 Pass security driver object into all security driver callbacks
The implementation of security driver callbacks often needs
to access the security driver object. Currently only a handful
of callbacks include the driver object as a parameter. Later
patches require this is many more places.

* src/qemu/qemu_driver.c: Pass in the security driver object
  to all callbacks
* src/qemu/qemu_security_dac.c, src/qemu/qemu_security_stacked.c,
  src/security/security_apparmor.c, src/security/security_driver.h,
  src/security/security_selinux.c: Add a virSecurityDriverPtr
  param to all security callbacks
2010-07-19 18:25:13 +01:00
a885334499 Convert all disk backing store loops to shared helper API
Update the QEMU cgroups code, QEMU DAC security driver, SELinux
and AppArmour security drivers over to use the shared helper API
virDomainDiskDefForeachPath().

* src/qemu/qemu_driver.c, src/qemu/qemu_security_dac.c,
  src/security/security_selinux.c, src/security/virt-aa-helper.c:
  Convert over to use virDomainDiskDefForeachPath()
2010-07-19 18:25:13 +01:00
9d0a630f51 Add an API for iterating over disk paths
There is duplicated code which iterates over disk backing stores
performing some action. Provide a convenient helper for doing
this to eliminate duplication & risk of mistakes with disk format
probing

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/libvirt_private.syms: Add virDomainDiskDefForeachPath()
2010-07-19 18:25:13 +01:00
bf80fc68ca Require format to be passed into virStorageFileGetMetadata
Require the disk image to be passed into virStorageFileGetMetadata.
If this is set to VIR_STORAGE_FILE_AUTO, then the format will be
resolved using probing. This makes it easier to control when
probing will be used

* src/qemu/qemu_driver.c, src/qemu/qemu_security_dac.c,
  src/security/security_selinux.c, src/security/virt-aa-helper.c:
  Set VIR_STORAGE_FILE_AUTO when calling virStorageFileGetMetadata.
* src/storage/storage_backend_fs.c: Probe for disk format before
  calling virStorageFileGetMetadata.
* src/util/storage_file.h, src/util/storage_file.c: Remove format
  from virStorageFileMeta struct & require it to be passed into
  method.
2010-07-19 18:25:04 +01:00
c70cb0f49b Refactor virStorageFileGetMetadataFromFD to separate functionality
The virStorageFileGetMetadataFromFD did two jobs in one. First
it probed for storage type, then it extracted metadata for the
type. It is desirable to be able to separate these jobs, allowing
probing without querying metadata, and querying metadata without
probing.

To prepare for this, split out probing code into a new pair of
methods

  virStorageFileProbeFormatFromFD
  virStorageFileProbeFormat

* src/util/storage_file.c, src/util/storage_file.h,
  src/libvirt_private.syms: Introduce virStorageFileProbeFormat
  and virStorageFileProbeFormatFromFD
2010-07-19 16:29:07 +01:00
779b6ea7c4 Remove 'type' field from FileTypeInfo struct
Instead of including a field in FileTypeInfo struct for the
disk format, rely on the array index matching the format.
Use verify() to assert the correct number of elements in the
array.

* src/util/storage_file.c: remove type field from FileTypeInfo
2010-07-19 15:51:02 +01:00
a93402d48b Extract the backing store format as well as name, if available
When QEMU opens a backing store for a QCow2 file, it will
normally auto-probe for the format of the backing store,
rather than assuming it has the same format as the referencing
file. There is a QCow2 extension that allows an explicit format
for the backing store to be embedded in the referencing file.
This closes the auto-probing security hole in QEMU.

This backing store format can be useful for libvirt users
of virStorageFileGetMetadata, so extract this data and report
it.

QEMU does not require disk image backing store files to be in
the same format the file linkee. It will auto-probe the disk
format for the backing store when opening it. If the backing
store was intended to be a raw file this could be a security
hole, because a guest may have written data into its disk that
then makes the backing store look like a qcow2 file. If it can
trick QEMU into thinking the raw file is a qcow2 file, it can
access arbitrary files on the host by adding further backing
store links.

To address this, callers of virStorageFileGetMeta need to be
told of the backing store format. If no format is declared,
they can make a decision whether to allow format probing or
not.
2010-07-19 15:51:02 +01:00
c567853089 CVE-2010-2242 Apply a source port mapping to virtual network masquerading
IPtables will seek to preserve the source port unchanged when
doing masquerading, if possible. NFS has a pseudo-security
option where it checks for the source port <= 1023 before
allowing a mount request. If an admin has used this to make the
host OS trusted for mounts, the default iptables behaviour will
potentially allow NAT'd guests access too. This needs to be
stopped.

With this change, the iptables -t nat -L -n -v rules for the
default network will be

Chain POSTROUTING (policy ACCEPT 95 packets, 9163 bytes)
 pkts bytes target     prot opt in     out     source               destination
   14   840 MASQUERADE  tcp  --  *      *       192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535
   75  5752 MASQUERADE  udp  --  *      *       192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535
    0     0 MASQUERADE  all  --  *      *       192.168.122.0/24    !192.168.122.0/24

* src/network/bridge_driver.c: Add masquerade rules for TCP
  and UDP protocols
* src/util/iptables.c, src/util/iptables.c: Add source port
  mappings for TCP & UDP protocols when masquerading.
2010-07-19 15:50:27 +01:00
de7d4c6ae7 man pages: update authors and copyright notice for libvirtd and virsh
This patch removes the individual author names from the libvirtd and virsh
man pages, instead referring to the main AUTHORS file distributed with
libvirt.  This approach is needed, as we can't guarantee unicode support
across all versions of pod2man used with libvirt.

Additionally, this patch includes the libvirtd man page in the spec file
used with "make rpm".  Without this patch "make rpm" is broken.
2010-07-17 04:51:01 +10:00
ee41ba665b Fix compile on i686.
When printing out size_t, we need to use %zu to make sure it
will continue to compile on both 32-bit and 64-bit platforms.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:14:53 -04:00
ac475b9f83 Remove unused and bitrotting vshCommandOptStringList
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:07:21 -04:00
9aa236e19f Remove error checking after using vshMalloc.
vshMalloc and friends always exit() on allocation failure,
so there is no reason to do checking for NULL in the code
that uses it.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:07:00 -04:00
de6380726b Remove the "showerror" parameter from vshConnectionUsability.
Nobody was using it anyway.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-16 09:06:43 -04:00
ae3275c0bb RFC: Canonicalize block device paths
There are many naming conventions for partitions associated with a
block device.  Some of the major ones are:

/dev/foo -> /dev/foo1
/dev/foo1 -> /dev/foo1p1
/dev/mapper/foo -> /dev/mapper/foop1
/dev/disk/by-path/foo -> /dev/disk/by-path/foo-part1

The universe of possible conventions isn't clear.  Rather than trying
to understand all possible conventions, this patch divides devices
into two groups, device mapper devices and everything else.  Device
mapper devices seem always to follow the convention of device ->
devicep1; everything else is canonicalized.
2010-07-15 12:57:01 -04:00
a3fc67a12c daemon: dispatch.c should include stdio.h (and stdarg.h)
dispatch.c requires stdio.h (and stdarg.h), however, currently
dispatch.c implicitly relys on rpc/xdr.h to include stdio.h.
If rpc/xdr.h unxpectedly does not include stdio.h, the compilation
of dispatch.c fails.

This can happen, for example, when portablexdr is installed
under /usr/local; because portablexdr's rpc/xdr.h does not
include stdio.h and gcc looks up it not /usr/include/rpc/xdr.h.

Note that stdarg.h is also included according to man va_start,
although stdio.h seems including it anyway.
2010-07-15 09:27:47 +02:00
60ef6d6322 uml_driver: correct logic error in umlMonitorCommand
* src/uml/uml_driver.c (umlMonitorCommand): Correct flaw that would
cause unconditional "incomplete reply ..." failure, since "nbytes"
was always 0 or 1.
2010-07-14 12:42:59 -05:00
c1fd7d7b3e qemuConnectMonitor: fix a bug that would have masked SELinux failure
* src/qemu/qemu_driver.c (qemuConnectMonitor): Correct erroneous
parenthesization in two expressions.  Without this fix, failure
to set or clear SELinux security context in the monitor would go
undiagnosed.  Also correct a diagnostic and split some long lines.
2010-07-14 12:42:59 -05:00
f9abc44ad5 python: Fix IOErrorReasonCallback bindings
A copy and paste error was causing us to dispatch the incorrect
routine. Spotted by Dan Kenigsberg.
2010-07-14 10:52:18 -04:00
f1f8bec486 .gitignore: Ignore generated libvirtd docs 2010-07-13 18:10:49 -04:00
8aa08ea873 esx: Make esxVI_*_Deserialize dynamically dispatched
This will be used to deserialize the response from a call
to esxVI_SearchDatastore_Task properly.
2010-07-13 18:44:14 +02:00
9af989fabc Add openauth example to demonstrate a custom auth callback 2010-07-13 13:50:27 +02:00
73b9dfeb31 Eliminate compiler warning due to gettext string with no format args 2010-07-12 23:35:43 -04:00
7327604177 docs: fix so generated .html files are removed with make clean 2010-07-13 05:34:25 +10:00
f5055f2310 cpuCompare: Fix crash on unexpected CPU XML
When comparing a CPU without <model> element, such as

    <cpu>
        <topology sockets='1' cores='1' threads='1'/>
    </cpu>

libvirt would happily crash without warning.
2010-07-12 19:45:22 +02:00
517aba9fac cpu: Fail when CPU type cannot be detected from XML
When autodetecting whether XML describes guest or host CPU, the presence
of <arch> element is checked. If it's present, we treat the XML as host
CPU definition. Which is right, since guest CPU definitions do not
contain <arch> element. However, if at the same time the root <cpu>
element contains `match' attribute, we would silently ignore it and
still treat the XML as host CPU. We should rather refuse such invalid
XML.
2010-07-12 19:45:22 +02:00
ac3daf0899 cpuCompare: Fix comparison of two host CPUs
When a CPU to be compared with host CPU describes a host CPU instead of
a guest CPU, the result is incorrect. This is because instead of
treating additional features in host CPU description as required, they
were treated as if they were mentioned with all possible policies at the
same time.
2010-07-12 19:45:22 +02:00
4677b06428 qemu: Use -nodefconfig when probing for CPU models
In case qemu supports -nodefconfig, libvirt adds uses it when launching
new guests. Since this option may affect CPU models supported by qemu,
we need to use it when probing for available models.
2010-07-12 19:45:22 +02:00
2d14615a75 virsh: Fix man page syntax
pod2man prints the following warning when generating virsh.1:

    tools/virsh.pod:890: Unmatched =back
2010-07-12 19:45:22 +02:00
8fa58ab348 Fix potential crash in QEMU monitor JSON impl
An indentation mistake meant that a check for return status
was not properly performed in all cases. This could result
in a crash on NULL pointer in a following line.

* src/qemu/qemu_monitor_json.c: Fix check for return status
  when processing JSON for blockstats
2010-07-12 18:34:18 +01:00
69bf3535a7 Fix build by removing unknown pod2man flag
Some versions of pod2man do not support the -u flag, so this
can't be used

* daemon/Makefile.am: Remove -u flag from pod2man
2010-07-12 14:09:30 +01:00
a6c539445e Ensure we return the callback ID in python events binding
A missing return statement in the python binding meant that
the callers could not get the callback ID, and thus not be
able to unregister event callbacks

* python/libvirt-override-virConnect.py: Add missing return
  statement
2010-07-12 13:41:52 +01:00
8cc02e8627 html docs: added firewall explanation page by daniel berrange 2010-07-10 22:47:00 +10:00
c6a6dc1d2d libvirtd: add man page for libvirtd
With gracious thanks to Chris Lalancette for helping knock the
description section into shape.

This addresses BZ #595350

  https://bugzilla.redhat.com/show_bug.cgi?id=595350
2010-07-10 00:10:55 +10:00
f5271fc166 virsh: add new --details option to vol-list
This patch adds a new --details option to the virsh vol-list
command, making its output more useful when many luns are
present.

Addresses BZ # 605543

  https://bugzilla.redhat.com/show_bug.cgi?id=605543
2010-07-09 23:35:28 +10:00
b3db32610d authors: update my authors details 2010-07-09 23:21:00 +10:00
bfe2bef106 Fix a compile error in the previous commit.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-08 08:49:01 -04:00
d222626af4 Implement virsh managedsave-remove command.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-08 08:42:39 -04:00
269aa8043c cpu: Add new models from qemu's target-x86_64.conf 2010-07-07 17:26:13 +02:00
af53714f47 cpu: Add support for CPU vendor
By specifying <vendor> element in CPU requirements a guest can be
restricted to run only on CPUs by a given vendor. Host CPU vendor is
also specified in capabilities XML.

The vendor is checked when migrating a guest but it's not forced, i.e.,
guests configured without <vendor> element can be freely migrated.
2010-07-07 17:26:00 +02:00
d9332c23b4 cpuBaseline: Detect empty set of common features
In case the set of CPUs has no features in common, report incompatible
CPUs instead of returning the simplest CPU model with all features
disabled.
2010-07-07 17:25:06 +02:00
4e0f648fbb cpuBaseline: Don't mess with the CPU returned by arch driver
All features in the baseline CPU definition were always created with
policy='require' even though an arch driver returned them with different
policy settings.
2010-07-07 17:24:53 +02:00
20a7a1be6e Make html docs in non-srcdir build 2010-07-07 17:24:27 +02:00
6f8e223780 Release of libvirt-0.8.2
- configure.ac docs/news.html.in libvirt.spec.in: updated
- po/*/o* : updated or.po and regenerated
2010-07-05 17:29:25 +02:00
df90ca7661 vbox: Let configure detect/set the XPCOMC directory
This allows the user to give an explicit path to configure

  ./configure --with-vbox=/path/to/virtualbox

instead of having the VirtualBox driver probe a set of possible
paths at runtime. If no explicit path is specified then configure
probes the set of "known" paths.

https://bugzilla.redhat.com/show_bug.cgi?id=609185
2010-07-03 12:40:14 +02:00
ed005221ff udev: Parse PCI devices even if libpciaccess fails
We only use libpciaccess for resolving device product/vendor. If
initializing the library fails (say if using qemu:///session), don't
warn so loudly, and carry on as usual.
2010-07-02 10:30:29 -04:00
15770695d8 qemu: Improve some qemu.conf error reporting
Log some info if we can't find a config file. Make parse failures
fatal, and actually raise an error message.
2010-07-02 10:29:56 -04:00
e190754ed3 util: virExec: Dispatch all errors raised after fork
Any error message raised after the process has forked needs
to be followed by virDispatchError, otherwise we have no chance of
ever seeing it. This was selectively done for hook functions in the past,
but really applies to all post-fork errors.
2010-07-02 10:29:06 -04:00
29da015aac cgroup: Fix compilation broken on MinGW due to dirent->d_type
As pointed out by Eric Blake, using dirent->d_type breaks
compilation on MinGW. This patch addresses this by using
'#if defined' as same as doing for virCgroupForDriver.
2010-06-30 08:32:23 -06:00
8919b4d425 html docs: add link to PHP bindings by Radek Hladik 2010-06-30 08:06:25 -06:00
26752f3be1 virsh: tweak help output for VSH_OT_DATA
https://bugzilla.redhat.com/show_bug.cgi?id=609044 complained
that 'virsh help pool-create-as' didn't document the shortcut
that you can do 'virsh pool-create-as $name $type --target $target'
rather than having to supply the four optional source- arguments
in order to fill out the necessary positional arguments.

This one-liner changes the help output to hopefully make this more obvious:

  NAME
    pool-create-as - create a pool from a set of args

  SYNOPSIS
    pool-create-as <name> [--print-xml] <type> [<source-host>] [<source-path>] [<source-dev>] [<source-name>] [<target>] [--source-format <string>]

  DESCRIPTION
    Create a pool.

  OPTIONS
    [--name] <string>  name of the pool
    --print-xml      print XML document, but don't define/create
    [--type] <string>  type of the pool
    [--source-host] <string>  source-host for underlying storage
    [--source-path] <string>  source path for underlying storage
    [--source-dev] <string>  source device for underlying storage
    [--source-name] <string>  source name for underlying storage
    [--target] <string>  target for underlying storage
    --source-format <string>  format for underlying storage

* tools/virsh.c (vshCmddefHelp): Make it more obvious that data
arguments may, but not must, be specified by option leaders.
2010-06-30 07:17:40 -06:00
8134d396fe Avoid invoking the qemu monitor destroy callback if the constructor fails
Some, but not all, codepaths in the qemuMonitorOpen() method
would trigger the destroy callback. The caller does not expect
this to be invoked if construction fails, only during normal
release of the monitor. This resulted in a possible double-unref
of the virDomainObjPtr, because the caller explicitly unrefs
the virDomainObjPtr  if qemuMonitorOpen() fails

* src/qemu/qemu_monitor.c: Don't invoke destroy callback from
  qemuMonitorOpen() failure paths
2010-06-30 13:48:15 +01:00
adc796c8eb cgroup: Add missing errno == ENOENT check in virCgroupRemoveRecursively
ENOENT happens normally when a subsystem is enabled with any other
subsystems and the directory of the target group has already removed
in a prior loop. In that case, the function should just return without
leaving an error message.

NB this is the same behavior as before introducing virCgroupRemoveRecursively.
2010-06-29 12:16:51 -06:00
ec75b0cf59 Fix crash when detaching devices from qemu domains.
Make sure to *not* call qemuDomainPCIAddressReleaseAddr if
QEMUD_CMD_FLAG_DEVICE is *not* set (for older qemu).  This
prevents a crash when trying to do device detachment from
a qemu guest.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-06-29 10:40:20 -04:00
53a1db4dfc Check for active PCI devices when doing nodedevice operations.
In the current libvirt PCI code, there is no checking whether
a PCI device is in use by a guest when doing node device
detach or reattach.  This causes problems when a device is
assigned to a guest, and the administrator starts issuing
nodedevice commands.  Make it so that we check the list
of active devices when trying to detach/reattach, and only
allow the operation if the device is not assigned to a guest.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-06-29 10:40:00 -04:00
415b14903e virsh: add new --details option to pool-list
This patch adds a new --details option to the virsh pool-list
command, making its output more useful to people who use virsh
for significant lengths of time.

Addresses BZ # 605543

  https://bugzilla.redhat.com/show_bug.cgi?id=605543
2010-06-29 08:37:39 -06:00
db1fbbd86a virFileResolveLink: guarantee an absolute path
https://bugzilla.redhat.com/show_bug.cgi?id=608092

* src/util/util.c (virFileResolveLink): Use
canonicalize_file_name, rather than areadlink.
2010-06-29 07:24:38 -06:00
5b26f2d8e6 phyp: don't steal storage management from other drivers
Fix regression introduced in commit a4a287242 - basically, the
phyp storage driver should only accept the same URIs that the
main phyp driver is willing to accept.  Blindly accepting all
URIs meant that the phyp storage driver was being consulted for
'virsh -c qemu:///session pool-list --all', rather than the
qemu storage driver, then since the URI was not for phyp, attempts
to then use the phyp driver crashed because it was not initialized.

* src/phyp/phyp_driver.c (phypStorageOpen): Only accept connections
already open to a phyp driver.
2010-06-29 07:24:19 -06:00
11a7060250 Avoid calling virStorageFileIsSharedFS with NULL
This code was just recently added (by me) and didn't account for the
fact that stdin_path is sometimes NULL. If it's NULL, and
SetSecurityAllLabel fails, a segfault would result.
2010-06-28 23:52:04 -04:00
1c46f4cc03 lxc: Fix virsh console doesn't work after restarting libvirtd
Because tty path is unexpectedly not saved in the live configuration
file of a domain, libvirtd cannot get the console of the domain back
after restarting.

The reason why the tty path isn't saved is that, to save the tty path,
the save function, virDomainSaveConfig, requires that the target domain
is running (pid != -1), however, lxc driver calls the function before
starting the domain to pass the configuration to controller.

To ensure to save the tty path, the patch lets lxc driver call the save
function again after starting the domain.
2010-06-28 10:51:29 -06:00
df8225ac54 lxc: Fix error handlings in lxcContainerRenameAndEnableInterfaces
The function is expected to return negative value on failure,
however, it returns positive value when either setInterfaceName
or vethInterfaceUpOrDown fails. Because the function returns
the return value of either as is, however, the two functions
may return positive value on failure.

The patch fixes the defects and add error messages.
2010-06-28 10:51:29 -06:00
b3a96d9049 lxc: Change VIR_ERROR to VIR_DEBUG for just a debugging message
The message is actually not of error but of debugging.
02:22:56.091: error : lxcControllerMain:316 : monitor=3 client=4 appPty=19 contPty=7
2010-06-28 10:51:29 -06:00
06f81c63eb Selectively ignore domainSetSecurityAllLabel failure in domain restore
When the saved domain image is on an NFS share, at least some part of
domainSetSecurityAllLabel will fail (for example, selinux labels can't
be modified). To allow domain restore to still work in this case, just
ignore the errors.
2010-06-28 11:56:02 -04:00
f35a9fc164 use virStorageFileIsSharedFS utility function in qemudDomainSaveFlag
Previously, this function had it's own bit of code performing the same
function. Since there's now an equivalent utility function, let's use it.
2010-06-28 11:55:53 -04:00
fb457c5c0c Enhance virStorageFileIsSharedFS
virStorageFileIsSharedFS would previously only work if the entire path
in question was stat'able by the uid of the libvirtd process. This
patch changes it to crawl backwards up the path retrying the statfs
call until it gets to a partial path that *can* be stat'ed.

This is necessary to use the function to learn the fstype for files
stored as a different user (and readable only by that user) on a
root-squashed remote filesystem.
2010-06-28 11:55:45 -04:00
590c9c9acf Set proper selinux label on image file during qemu domain restore
Also restore the label to its original value after qemu is finished
with the file.

Prior to this patch, qemu domain restore did not function properly if
selinux was set to enforce.
2010-06-28 11:55:32 -04:00
47ae6d3d7e build: fix regression with libvirt-api.xml generation
(EXTRA_DIST): Remove redundant listing of xml files.
(html/%-%.html, html/%-virterror.html, %-api.xml, %-refs.xml):
Rewrite with...
(python_generated_files): ...new macro, since make didn't see
through the dependency chain correctly otherwise.
2010-06-25 17:10:57 -06:00
3003c46d13 Fix a reference leak for node devices.
There were some major, and some minor bugs having to do with
the reference counting of node devices in daemon/remote.c.

Some functions were completely failing to unreference node devices;
this would lead to many open file descriptors, which would eventually
fail.

The minor bugs were along the same lines, but were in rarely
used error paths.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
Signed-off-by: Matthias Bolte <matthias.bolte@googlemail.com>
2010-06-26 00:53:59 +02:00
6d9743158c Don't squash file permissions when migration fails
If an active migration operation fails, or is cancelled by the
admin, the QEMU on the destination is shutdown and the one on
the source continues running. It is important in shutting down
the QEMU on the destination, the security drivers don't reset
the file labelling/permissions.

* src/qemu/qemu_driver.c: Don't reset labelling/permissions
  on migration abort
2010-06-25 10:19:20 -04:00
17dedf7cb5 phyp: optimize use of sed
Minor speedups by using the full power of sed.

* src/phyp/phyp_driver.c (phypGetVIOSFreeSCSIAdapter)
(phypDiskType, phypListDefinedDomains): Use fewer processes, by
folding other work into sed.
(phypGetVIOSPartitionID): Likewise.  Also avoid non-portable use
of 'sed -s'.
2010-06-25 07:52:43 -06:00
ebc46fea6f phyp: add storage management driver
Add the storage management driver to the Power Hypervisor driver.
This is a big but simple patch, it's just a new set of functions.

This patch includes:
 * Storage driver: The set of pool-* and vol-* functions.
 * attach-disk function.
 * Support for IVM on the new functions.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-06-25 07:52:43 -06:00
a4a287242e phyp: add rudimentary storage driver
* src/phyp/phyp_driver.c (phypStorageDriver): New driver.
(phypStorageOpen, phypStorageClose): New functions.
(phypRegister): Register it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-06-25 07:52:43 -06:00
89144534eb phyp: reduce scope of driver functions
Several phyp functions are not namespace clean, and had no reason
to be exported since no one outside the phyp driver needed to use
them.  Rather than do lots of forward declarations, I was able
to topologically sort the file.  So, this patch looks huge, but
is really just a matter of marking things static and dealing with
the compiler fallout.

* src/phyp/phyp_driver.h (PHYP_DRIVER_H): Add include guard.
(phypCheckSPFreeSapce): Delete unused declaration.
(phypGetSystemType, phypGetVIOSPartitionID, phypCapsInit)
(phypBuildLpar, phypUUIDTable_WriteFile, phypUUIDTable_ReadFile)
(phypUUIDTable_AddLpar, phypUUIDTable_RemLpar, phypUUIDTable_Pull)
(phypUUIDTable_Push, phypUUIDTable_Init, phypUUIDTable_Free)
(escape_specialcharacters, waitsocket, phypGetLparUUID)
(phypGetLparMem, phypGetLparCPU, phypGetLparCPUGeneric)
(phypGetRemoteSlot, phypGetBackingDevice, phypDiskType)
(openSSHSession): Move declarations to phyp_driver.c and make static.
* src/phyp/phyp_driver.c: Rearrange file contents to provide
topological sorting of newly-static funtions (no semantic changes
other than reduced scope).
(phypGetBackingDevice, phypDiskType): Mark unused, for now.
2010-06-25 07:52:43 -06:00
f9a9214629 maint: add gnulib gettimeofday module
* bootstrap.conf (gnulib_modules): Add gettimeofday.
2010-06-25 07:46:28 -06:00
39f8af3880 Fix test case failure due to missing -nodefconfig
The previous change which split -nodefconfig probing off
from -device broke the test case because it missed adding
the QEMUD_CMD_FLAG_NODEFCONFIG to the test

* src/util/bridge.c: Set QEMUD_CMD_FLAG_NODEFCONFIG for all
  configs with QEMUD_CMD_FLAG_DEVICE set
2010-06-25 14:40:24 +01:00
28e96d720b Fix migration in text mode and shared storage migration in json mode
The patches for shared storage migration were not correctly written
for json mode. Thus the 'blk' and 'inc' parameters were never being
set. In addition they didn't set the QEMU_MONITOR_MIGRATE_BACKGROUND
so migration was synchronous. Due to multiple bugs in QEMU's JSON
impl this wasn't noticed because it treated the sync migration requst
as asynchronous anyway. Finally 'background' parameter was converted
to take arbitrary flags but not renamed, and not all uses were changed
to unsigned int.

* src/qemu/qemu_driver.c: Set QEMU_MONITOR_MIGRATE_BACKGROUND in
  doNativeMigrate
* src/qemu/qemu_monitor_json.c: Process QEMU_MONITOR_MIGRATE_NON_SHARED_DISK
  and QEMU_MONITOR_MIGRATE_NON_SHARED_INC flags
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.h, src/qemu/qemu_monitor_text.c,
  src/qemu/qemu_monitor_text.h: change 'int background' to
  'unsigned int flags' in migration APIs. Add logging of flags
  parameter
2010-06-25 14:40:06 +01:00
755b53f946 Avoid blocking all APIs during incoming migration
During incoming migration the QEMU monitor is not able to be
used. The incoming migration code did not keep hold of the
job lock because migration is split across multiple API calls.
This meant that further monitor commands on the guest would
hang until migration finished with no timeout.

In this change the qemuDomainMigratePrepare method sets the
job flag just before it returns. The qemuDomainMigrateFinish
method checks for this job flag & clears it once done. This
prevents any use of the monitor between prepare+finish steps.

The qemuDomainGetJobInfo method is also updated to refresh
the job elapsed time. This means that virsh domjobinfo can
return time data during incoming migration

* src/qemu/qemu_driver.c: Keep a job active during incoming
  migration. Refresh job elapsed time when returning job info
2010-06-25 14:39:58 +01:00
2bad82f71e Set labelling for character devices in security drivers
When configuring serial, parallel, console or channel devices
with a file, dev or pipe backend type, it is necessary to label
the file path in the security drivers. For char devices of type
file, it is neccessary to pre-create (touch) the file if it does
not already exist since QEMU won't be allowed todo so itself.
dev/pipe configs already require the admin to pre-create before
starting the guest.

* src/qemu/qemu_security_dac.c: set file ownership for character
  devices
* src/security/security_selinux.c: Set file labeling for character
  devices
* src/qemu/qemu_driver.c: Add character devices to cgroup ACL
2010-06-25 14:39:54 +01:00
bf1f3f7a36 Add API for iterating over all character devices
The parallel, serial, console and channel devices are all just
character devices. A lot of code needs todo the same thing to
all these devices. This provides an convenient API for iterating
over all of them.

* src/conf/domain_conf.c, src/conf/domain_conf.c,
  src/libvirt_private.syms: Add virDomainChrDefForeach
2010-06-25 14:39:45 +01:00
a711633909 Add missing parameter in python Disk IO error callback
The IO error callback was forgetting to pass the action
parameter, causing a stack trace when IO errors arrive

* python/libvirt-override-virConnect.py: Add missing action
  parameter in IO error callback
2010-06-25 14:39:37 +01:00
7d02393b1b Check for presence of qemu -nodefconfig option before using it
We previously assumed that if the -device option existed in qemu, that
-nodefconfig would also exist. It turns out that isn't the case, as
demonstrated by qemu-kvm-0.12.3 in Fedora 13.

*/src/qemu/qemu_conf.[hc] - add a new QEMUD_CMD_FLAG, set it via the
                            help output, and check it before adding
                            -nodefconfig to the qemu commandline.
2010-06-24 18:04:07 -04:00
edfedfb414 Adding Storage Management driver (style and indentation)
This is just the indentation, style  and cleanup patch.
2010-06-24 14:03:50 -06:00
e214bcf37c esx: Use bool instead of int where appropriated 2010-06-24 14:56:04 +02:00
d72d92565b esx: Add support for the controller element
Also don't abuse the disk driver name to specify the SCSI controller
model anymore:

  <driver name='buslogic'/>

Use the newly added model attribute of the controller element for this:

  <controller type='scsi' index='0' model='buslogic'/>

The disk driver name approach is deprecated now, but still works for
backward compatibility reasons.

Update the documentation and tests accordingly.

Fix usage of the words controller and id in the VMX handling code. Use
controller, bus and unit properly.
2010-06-24 14:56:04 +02:00
c391291244 Add optional model attribute to the controller element
This is a step towards controller support for the ESX driver.
2010-06-24 14:56:04 +02:00
f8f29b1fc2 Add wide SCSI bus disk address generation support
The domain XML parsing code autogenerates disk address and
controller elements when they are not explicitly specified.
The code assumes a narrow SCSI bus (7 units per bus). ESX
uses a wide SCSI bus (16 units per bus).

This is a step towards controller support for the ESX driver.
2010-06-24 14:56:04 +02:00
a73b389d12 Cleanup some LIBADD and CFLAGS
Move libnl to libvirt_util.la, because macvtap.c requires it.

Add GnuTLS to libvirt_driver.la, because libvirt.c calls gcrypt functions.
When built without loadable driver modules, then the remote driver pulls
in GnuTLS.

Move libgnu.la from libvirt_parthelper_CFLAGS to libvirt_parthelper_LDADD.
2010-06-24 14:16:27 +02:00
4a4eb13e7a cgroup: Enable memory.use_hierarchy of cgroup for domain
Through conversation with Kumar L Srikanth-B22348, I found
that the function of getting memory usage (e.g., virsh dominfo)
doesn't work for lxc with ns subsystem of cgroup enabled.

This is because of features of ns and memory subsystems.
Ns creates child cgroup on every process fork and as a result
processes in a container are not assigned in a cgroup for
domain (e.g., libvirt/lxc/test1/). For example, libvirt_lxc
and init (or somewhat specified in XML) are assigned into
libvirt/lxc/test1/8839/ and libvirt/lxc/test1/8839/8849/,
respectively. On the other hand, memory subsystem accounts
memory usage within a group of processes by default, i.e.,
it does not take any child (and descendant) groups into
account. With the two features, virsh dominfo which just
checks memory usage of a cgroup for domain always returns
zero because the cgroup has no process.

Setting memory.use_hierarchy of a group allows to account
(and limit) memory usage of every descendant groups of the group.
By setting it of a cgroup for domain, we can get proper memory
usage of lxc with ns subsystem enabled. (To be exact, the
setting is required only when memory and ns subsystems are
enabled at the same time, e.g., mount -t cgroup none /cgroup.)
2010-06-23 14:31:38 -06:00
842b51ff5d cgroup: Change virCgroupRemove to remove all descendant groups at first
As same as normal directories, a cgroup cannot be removed if it
contains sub groups. This patch changes virCgroupRemove to remove
all descendant groups (subdirectories) of a target group before
removing the target group.

The handling is required when we run lxc with ns subsystem of cgroup.
Ns subsystem automatically creates child cgroups on every process
forks, but unfortunately the groups are not removed on process exits,
so we have to remove them by ourselves.

With this patch, such child (and descendant) groups are surely removed
at lxc shutdown, i.e., lxcVmCleanup which calls virCgroupRemove.
2010-06-23 14:30:19 -06:00
4cc2b6d676 virsh: document attach-disk better
http://bugzilla.redhat.com/601143, part 1 - document existing
behavior.  Ever since Mar 2010 (commit ced154cb), the use of
'attach-disk' or 'attach-device' to change cdrom/floppy media has been
documented but deprecated, but the replacement to use 'update-device'
was not documented.

* tools/virsh.c (cmdAttachInterface, cmdAttachDisk): Fix bad error
message.
* tools/virsh.pod (attach-device, attach-disk): Refer to
update-device for cdrom and floppy behavior.
(update-device): Add documentation.
2010-06-23 08:35:40 -06:00
4efaf77b19 network: allow tftp port if tftp is defined
add iptables rules to allow TFTP from the virtual network if <tftp>
element is defined in the network definition.

Fedora bz#580215

* src/network/bridge_driver.c: open UDP port 69 for TFTP traffic if
  tftproot is defined
2010-06-23 08:24:00 -06:00
0c141c893a bridge_driver.c: fix file description 2010-06-23 08:18:57 -06:00
f310b25341 Add '-nodefconfig' command line arg to QEMU
We already use the '-nodefaults' command line arg with QEMU to stop
it adding any default devices to guests. Unfortunately, QEMU will
load global config files from /etc/qemu that may also add default
devices. These aren't blocked by '-nodefaults', so we need to also
add the '-nodefconfig' arg to prevent that.

Unfortunately these global config files are also used to define
custom CPU models. So in blocking global hardware device addition
we also block definitions of new CPU models. Libvirt doesn't know
about these custom CPU models though, so it would never make use
of them anyway. Thus blocking them via -nodefconfig isn't a show
stopping problem. We would need to expand libvirt's own CPU model
XML database to support these instead.

* src/qemu/qemu_conf.c: Add '-nodefconfig' if available
* tests/qemuxml2argvdata/: Add '-nodefconfig' to all data files which
  have '-nodefaults' present
2010-06-23 14:08:05 +01:00
c212160260 Fix reference handling leak on qemuMonitor
The current code pattern requires that callers of qemuMonitorClose
check for the return value == 0, and if so, set priv->mon = NULL
and release the reference held on the associated virDomainObjPtr

The change d84bb6d6a3 violated that
requirement, meaning that priv->mon never gets set to NULL, and
a reference count is leaked on virDomainObjPtr.

This design was a bad one, so remove the need to check the return
valueof qemuMonitorClose(). Instead allow registration of a
callback that's invoked just when the last reference on qemuMonitorPtr
is released.

Finally there was a potential reference leak in qemuConnectMonitor
in the failure path.

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a destroy
  callback invoked from qemuMonitorFree
* src/qemu/qemu_driver.c: Use the destroy callback to release the
  reference on virDomainObjPtr when the monitor is freed. Fix other
  potential reference count leak in connecting to monitor
2010-06-23 14:08:05 +01:00
8d616decc5 Make checks for inactive QEMU guest more robust
Before issuing monitor commands it is neccessary to check whether
the guest is still running. Most places use virDomainIsActive()
correctly, but a few relied on 'priv->mon != NULL'. In theory
these should be equivalent, but the release of the last reference
count on priv->mon can be delayed a small amount of time until
the event handler is finally deregistered. A further ref counting
bug also means that priv->mon might be never released. In such a
case, code could mistakenly issue a monitor command and wait for
a response that will never arrive, effectively leaving the QEMU
driver waiting on virCondWait() forever..

To protect against these possibilities, make sure all code uses
virDomainIsActive(), not 'priv->mon != NULL'

* src/qemu/qemu_driver.c: Replace 'priv->mon != NULL' with
  calls to 'priv->mon != NULL'()
2010-06-23 14:08:05 +01:00
9b0244ae38 Improve some error messages about unsupported APIs/URIs
If there is no driver for a URI we report

  "no hypervisor driver available"

This is bad because not all virt drivers are hypervisors (ie container
based virt).

If there is no driver support for an API we report

  "this function is not supported by the hypervisor"

This is bad for the same reason, and additionally because it is
also used for the network, interface & storage drivers.

* src/util/virterror.c: Improve error messages
2010-06-23 14:07:39 +01:00
6c267f01b1 Don't leak open fd to virsh in libvirt-guests init script
Running virsh while having /var/lib/libvirt/libvirt-guests file open
makes SELinux emit messages about preventing virsh from reading that
file. Since virsh doesn't really want to read anything, it's better to
run it with /dev/null on stdin to prevent those messages.
2010-06-22 17:48:14 +02:00
cab5a52aa2 nwfilter: fix loadable module support
Following Daniel Berrange's multiple helpful suggestions for improving
this patch and introducing another driver interface, I now wrote the
below patch where the nwfilter driver registers the functions to
instantiate and teardown the nwfilters with a function in
conf/domain_nwfilter.c called virDomainConfNWFilterRegister. Previous
helper functions that were called from qemu_driver.c and qemu_conf.c
were move into conf/domain_nwfilter.h with slight renaming done for
consistency. Those functions now call the function expored by
domain_nwfilter.c, which in turn call the functions of the new driver
interface, if available.
2010-06-21 14:18:31 -04:00
c7a33939bc virsh: remove a doubled up include for errno.h 2010-06-21 10:11:34 +02:00
d147b18de2 Misc cleanups
- Fix documentation for virGetStorageVol: it has 'key' argument instead
  of 'uuid'.
- Remove TODO comment from virReleaseStorageVol: we use volume key as an
  identifier instead of UUID.
- Print human-readable UUID string in debug message in virReleaseSecret.
2010-06-21 10:11:34 +02:00
72a7f8b2a9 Do not free static buffer with UUID
As anywhere else, uuid is defined as a fixed size array inside
_virSecret structure; we shouldn't try to free it.
2010-06-21 10:11:34 +02:00
c5ec45a3a4 Remove unnecessary check for non-NULL uuid
The first thing we do in all these functions is to check uuid != NULL
and fail if it isn't.
2010-06-21 10:11:34 +02:00
30ec755ecb Index hashes by UUID instead of name
Per-connection hashes for domains, networks, storage pools and network
filter pools were indexed by names which was not the best choice. UUIDs
are better identifiers, so lets use them.
2010-06-21 10:11:34 +02:00
ff5f7d7204 Allow one-or-more <boot dev="..."/> entries
According to docs/formatdomain.html.in, "The boot element can be
repeated multiple times to setup a priority list of boot devices to try
in turn." The Relax-NG schema required / allowed exactly one entry.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-06-21 10:11:33 +02:00
7057f39c51 nwfilter: extensions of docs with
As requested, here a couple of paragraphs about the recently added statematch attribute and some advanced (and tricky) traffic filtering topics.
2010-06-18 13:44:17 -04:00
9edceb3233 Add ACK'd v2 changes for previous commit 2010-06-18 11:56:04 -04:00
58406dd54e qemu: Fix crash on failed VM startup
If VM startup fails early enough (can't find a referenced USB device),
libvirtd will crash trying to clear the VNC port bit, since port = 0,
which overflows us out of the bitmap bounds.

Fix this by being more defensive in the bitmap operations, and only
clearing a previously set VNC port.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-06-18 10:14:34 -04:00
08fee18cc2 Fix description of virStorageVolGetInfo()
Probably a copy-paste-bug in python/libvirt-override-api.xml:
virStorageVolGetInfo() extracts information about a "storage volume",
not the "storage pool" as virStoragePoolGetInfo() does.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-06-18 12:57:54 +02:00
2b39cd355a virsh: add --uuid option to vol-pool
Adds an optional switch, --uuid, for telling the virsh vol-pool command
to return the pool UUID rather than pool name.
2010-06-17 14:45:34 -06:00
322b1fd44b qemu: reduce file padding requirements
Followup to https://bugzilla.redhat.com/show_bug.cgi?id=599091,
commit 20206a4b, to reduce disk waste in padding.

* src/qemu/qemu_monitor.h (QEMU_MONITOR_MIGRATE_TO_FILE_BS): Drop
back to 4k.
(QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE): New macro.
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update comment.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrateToFile): Use
two invocations of dd to output non-aligned large blocks.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONMigrateToFile):
Likewise.
2010-06-17 13:29:16 -06:00
51d3fb0276 nwfilter: add XML attribute to control iptables state match
This patch adds an optional XML attribute to a nwfilter rule to give the user control over whether the rule is supposed to be using the iptables state match or not. A rule may now look like shown in the XML below with the statematch attribute either having value '0' or 'false' (case-insensitive).

[...]
<rule action='accept' direction='in' statematch='false'>
<tcp srcmacaddr='1:2:3:4:5:6'
           srcipaddr='10.1.2.3' srcipmask='32'
           dscp='33'
           srcportstart='20' srcportend='21'
           dstportstart='100' dstportend='1111'/>
</rule>
[...]

I am also extending the nwfilter schema and add this attribute to a test case.
2010-06-17 14:12:34 -04:00
c2160b137d virsh: ensure persistence and autostart are shown for dominfo and pool-info
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands.  This patch also adds the autostart status
to the output of the virsh pool-info command.

Red Hat BZ for this:

  https://bugzilla.redhat.com/show_bug.cgi?id=603696
2010-06-17 11:57:54 -06:00
788269e970 phyp: adding support for IVM
Use virBuffer* API to conditionally keep the portion of the command
line specific to HMC, so that IVM can work.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-06-17 11:49:09 -06:00
2dce970162 nwfilter: use match target on incoming traffic
The following patch enables the iptables match target to be used by
default for incoming traffic. So far it has only be used for outgoing
traffic.
2010-06-17 07:15:20 -04:00
045a5722ab macvtap: work-around for 2.6.32 and older kernels
This patch works around a recent extension of the netlink driver I had made use of when building the netlink messages. Unfortunately older kernels don't accept IFLA_IFNAME + name of interface as a replacement for the interface's index, so this patch now gets the interface index ifindex if it's not provided (ifindex <= 0).
2010-06-17 07:05:38 -04:00
07be2403b6 virsh: change printf() calls to vshPrint()
Trivial fix changing printf() calls to vshPrint() where the ctl
variable is available.
2010-06-16 17:17:08 -06:00
7d38d7b49b virsh: improve help text for vol query commands
Improves the help text for vol-path, vol-name, and vol-key, which
previously referred to volume UUIDs.

Addresses BZ # 598365.
2010-06-16 16:32:05 -06:00
31495ef6a1 virsh: add pool support to vol-key command
Presently the vol-key command only supports being provided with
a volume path.

This patch adds support for providing it with a pool and volume
identifier pair as well.

    virsh # vol-key --pool <pool-name-or-uuid> <vol-name-or-path>
2010-06-16 16:32:05 -06:00
08d42b52f1 Add several missing vir*Free calls in libvirtd's remote code
Justin Clift reported a problem with adding virStoragePoolIsPersistent
to virsh's pool-info command, resulting in a strange problem. Here's
an example:

    virsh # pool-create-as images_dir3 dir - - - - "/home/images2"
    Pool images_dir3 created

    virsh # pool-info images_dir3
    Name:           images_dir3
    UUID:           90301885-94eb-4ca7-14c2-f30b25a29a36
    State:          running
    Capacity:       395.20 GB
    Allocation:     30.88 GB
    Available:      364.33 GB

    virsh # pool-destroy images_dir3
    Pool images_dir3 destroyed

At this point the images_dir3 pool should be gone (because it was
transient) and we should be able to create a new pool with the same name:

    virsh # pool-create-as images_dir3 dir - - - - "/home/images2"
    Pool images_dir3 created

    virsh # pool-info images_dir3
    Name:           images_dir3
    UUID:           90301885-94eb-4ca7-14c2-f30b25a29a36
    error: Storage pool not found

The new pool got the same UUID as the first one, but we didn't specify
one. libvirt should have picked a random UUID, but it didn't.

It turned out that virStoragePoolIsPersistent leaks a reference to the
storage pool object (actually remoteDispatchStoragePoolIsPersistent does).
As a result, pool-destroy doesn't remove the virStoragePool for the
"images_dir3" pool from the virConnectPtr's storagePools hash on libvirtd's
side. Then the second pool-create-as get's the stale virStoragePool object
associated with the "images_dir3" name. But this object has the old UUID.

This commit ensures that all get_nonnull_* and make_nonnull_* calls for
libvirt objects are matched properly with vir*Free calls. This fixes the
reference leaks and the reported problem.

All remoteDispatch*IsActive and remoteDispatch*IsPersistent functions were
affected. But also remoteDispatchDomainMigrateFinish2 was affected in the
success path. I wonder why that didn't surface earlier. Probably because
domainMigrateFinish2 is executed on the destination host and in the common
case this connection is opened especially for the migration and gets closed
after the migration is done. So there was no chance to run into a problem
because of the leaked reference.
2010-06-16 23:06:12 +02:00
02d57c2bce esx: Update case insensitive .vmx tests
Commit b9efc7dc3b made virFileHasSuffix
case insensitive. Honor this in the tests by switching vmdk to VMDK.
2010-06-16 23:06:12 +02:00
b0f414c67b esx: Accept 'disk' as harddisk device type in .vmx files 2010-06-16 23:06:12 +02:00
02988742b7 phyp: sed cleanups
* src/phyp/phyp_driver.c (phypNumDomainsGeneric): Avoid glob
collision by quoting sed argument.
(phypDomainSetCPU): Avoid non-portable \+ in sed.
(phypGetVIOSPartitionID, phypDiskType, phypListDomainsGeneric)
(phypListDefinedDomains): Micro-optimize anchored substitutions.
2010-06-16 14:08:44 -06:00
043f05fda4 virsh: mark autostart answers for translation
This is a trivial fix for several autostart yes/no strings that
weren't correctly marked for translation.
2010-06-15 15:36:27 -06:00
cbe6ebdb53 virsh: add start --paused support
Make 'start --paused' mirror 'create --paused'.

* tools/virsh.c (cmdStart): Use new virDomainCreateWithFlags API
when needed.
* tools/virsh.pod (start): Document --paused.
2010-06-15 09:50:58 -06:00
d024d2ba36 qemu: support starting persistent domain paused
Match earlier change for qemu pause support with virDomainCreateXML.

* src/qemu/qemu_driver.c (qemudDomainObjStart): Add parameter; all
callers changed.
(qemudDomainStartWithFlags): Implement flag support.
2010-06-15 09:37:11 -06:00
de3aadaa71 drivers: add virDomainCreateWithFlags if virDomainCreate exists
* src/esx/esx_driver.c (esxDomainCreate): Move guts...
(esxDomainCreateWithFlags): ...to new function.
(esxDriver): Trivially support the new API.
* src/lxc/lxc_driver.c (lxcDomainStart, lxcDomainStartWithFlags)
(lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDomainStart)
(oneDomainStartWithFlags, oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDomainCreate)
(openvzDomainCreateWithFlags, openvzDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainStart)
(qemudDomainStartWithFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testDomainCreate)
(testDomainCreateWithFlags, testDriver): Likewise.
* src/uml/uml_driver.c (umlDomainStart, umlDomainStartWithFlags)
(umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainCreate)
(vboxDomainCreateWithFlags, Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainCreate)
(xenUnifiedDomainCreateWithFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainCreate)
(xenapiDomainCreateWithFlags, xenapiDriver): Likewise.
2010-06-15 09:37:11 -06:00
6c83e7ca6f remote: protocol implementation for virDomainCreateWithFlags
Define the wire format for the new virDomainCreateWithFlags
API, and implement client and server side of marshaling code.

* daemon/remote.c (remoteDispatchDomainCreateWithFlags): Add
server side dispatch for virDomainCreateWithFlags.
* src/remote/remote_driver.c (remoteDomainCreateWithFlags)
(remote_driver): Client side serialization.
* src/remote/remote_protocol.x
(remote_domain_create_with_flags_args)
(remote_domain_create_with_flags_ret)
(REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS): Define wire format.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.
2010-06-15 09:37:04 -06:00
460ca88b98 libvirt: introduce domainCreateWithFlags API
Persistent domain creation needs the same features as transient
domains, but virDomainCreate lacks the flags argument present in
virDomainCreateXML.  virDomainCreateFlags is already claimed as
a public enum, so we have to break convention and expose
virDomainCreateWithFlags.

* include/libvirt/libvirt.h.in (virDomainCreateWithFlags): Add.
* src/driver.h (virDrvDomainCreateWithFlags): Internal API.
* src/libvirt.c (virDomainCreateWithFlags): Glue public API to
driver API.
* src/libvirt_public.syms (LIBVIRT_0.8.2): Expose public API.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
2010-06-15 07:32:41 -06:00
fb8552f83a maint: simplify some ignore files
* .hgignore: Delete, no longer used.
* examples/python/.gitignore: Delete, covered globally.
* include/.gitignore: Likewise.
* python/tests/.gitignore: Likewise.
* docs/schemas/.gitignore: Likewise.
* tests/xml2sexprdata/.gitignore: Likewise.
* tests/sexpr2xmldata/.gitignore: Likewise.
* tests/confdata/.gitignore: Likewise.
* tests/xencapsdata/.gitignore: Likewise.
* tests/xmconfigdata/.gitignore: Likewise.
* tests/xml2sexprdata/.gitignore: Likewise.
2010-06-15 07:31:10 -06:00
352b6df34d parthelper: fix compilation without optimization
Daniel's patch works with gcc and CFLAGS containing -O (the
autoconf default), but fails with non-gcc or with other
CFLAGS (such as -g), since c-ctype.h declares c_isdigit as
a macro only for certain compilation settings.

* src/Makefile.am (libvirt_parthelper_LDFLAGS): Add gnulib
library, for when c_isdigit is not a macro.
* src/storage/parthelper.c (main): Avoid out-of-bounds
dereference, noticed by Jim Meyering.
2010-06-14 15:11:49 -06:00
bc8d9f2077 Fix enumeration of partitions in disks with a trailing digit in path
Disks with a trailing digit in their path (eg /dev/loop0 or
/dev/dm0) have an extra 'p' appended before the partition
number (eg, to form /dev/loop0p1 not /dev/loop01). Fix the
partition lookup to append this extra 'p' when required

* src/storage/parthelper.c: Add a 'p' before partition
  number if required
2010-06-14 14:55:23 -06:00
582c75ec45 uml: sanity check external data before using it
Otherwise, a malicious packet could cause a DoS via spurious
out-of-memory failure.

* src/uml/uml_driver.c (umlMonitorCommand): Validate that incoming
data is reliable before using it to allocate/dereference memory.
Don't report bogus errno on short read.
Reported by Jim Meyering.
2010-06-11 10:33:09 -06:00
d0dabc2bf8 Improve error message for disabled client-side drivers
Report that libvirt was built without that driver instead of
trying to connect to a libvirtd, when we know that this is
going to fail.
2010-06-11 18:24:13 +02:00
1443cbe840 vbox: check getenv("DISPLAY") for NULL in vboxDomainDumpXML
Otherwise this will segfault if DISPLAY is not defined.
2010-06-10 22:39:49 +02:00
fc1da688c0 Check getenv("PATH") for NULL in virFindFileInPath
Otherwise this will segfault if PATH is not defined.

Reported by Emre Erenoglu
2010-06-10 22:39:11 +02:00
b28a068b43 virsh: add snapshot backing store support to vol-create-as
This patch adds two new parameters to the vol-create-as command:

 --backing-vol <volume-name-or-key-or-path>
 --backing-vol-format <format-of-backing-vol>

  virsh # vol-create-as guest_images_lvm snapvol1 5G --backing-vol \
              rhel6vm1lun1
  Vol snapvol1 created

  virsh # vol-create-as image_dir qcow2snap2 5G --format qcow2 \
              --backing-vol imagevol1.qcow2 \
              --backing-vol-format qcow2
  Vol qcow2snap2 created

Additionally, the virsh man page update fixes incorrect snapshot
parameters that were included in my prior bulk volume command patch.
2010-06-10 12:03:13 -06:00
3cf642a0f9 build: fix some mingw issues
On Fedora 13 with sufficient mingw32-* packages installed, running
./autobuild.sh failed to cross-compile to mingw because
mingw32-pthreads installed a broken <pthread.h>.  With that
issue fixed, the build still failed due to use of O_SYNC.
Meanwhile, recent .spec.in changes got out of sync.

* bootstrap.conf (gnulib_modules): Add fcntl-h, for O_SYNC.
* .gnulib: Update to latest, to work around buggy pthreads-win32
library.
* bootstrap: Import latest from gnulib.
* mingw32-libvirt.spec.in: Distribute new file.
2010-06-10 06:05:31 -06:00
6e5a04f034 build: avoid pthreads-win32 on mingw
* src/util/threads.c (includes) [WIN32]: On mingw, favor native
threading over pthreads-win32 library.
* src/util/thread.h [WIN32] Likewise.
Suggested by Daniel P. Berrange.
2010-06-10 06:05:31 -06:00
c37c321cc2 Fix cgroup setup code to cope with root squashing NFS
When a disk is on a root squashed NFS server, it may not be
possible to stat() the disk file in virCgroupAllowDevice.
The virStorageFileGetMeta method may also fail to extract
the parent backing store. Both of these errors have to be
ignored to avoid breaking NFS deployments

* src/qemu/qemu_driver.c: Ignore errors in cgroup setup to
   keep root squash NFS happy
2010-06-09 09:44:20 -04:00
c09f663a47 virsh: fixed trivial comment and debug message in vshCommandOptVolBy function 2010-06-09 06:16:54 -06:00
74231267f8 virsh: remove xen reference in header comment
With libvirt and virsh now being used for much more than Xen, this
patch removes the outdated reference to Xen in the file header.
2010-06-09 05:18:27 -06:00
46c14d2045 esx: Add proxy query parameter
Allow to specify a proxy to be used by libcurl.
2010-06-09 12:55:02 +02:00
070f61002f esx: Refactor esxUtil_ParseQuery's parameter handling
Pass a struct containing the parameters instead of passing each
one individually. This make future extensions a bit simpler.
2010-06-09 11:29:09 +02:00
cd2b18968d virsh: add the volume commands to the virsh man page
This patch also includes the new vol-pool command.
2010-06-08 18:59:29 -06:00
62f8674d62 virsh: add new vol-pool command
This patch adds a new "vol-pool" command to virsh, to round out the
identifier conversion functions for volumes in virsh.  Now it is
possible to work with volumes when starting from just a volume key
or volume path.
2010-06-08 18:55:07 -06:00
734bbf0ea9 virsh: add --paused option to create
* tools/virsh.c (opts_create): Add --paused option.
(cmdCreate): Pass appropriate flag.
* tools/virsh.pod: Document it.
2010-06-08 15:41:53 -06:00
68e4793ae0 qemu: allow creation of a paused domain
https://bugzilla.redhat.com/show_bug.cgi?id=589465

Some guests (eg with badly configured grub, or Windows' installation cd)
require quick response from the console user. That's why we have a
"launchPaused" option in vdsm.

To implement it via libvirt, we need to ask libvirt not to call
qemuMonitorStartCPUs() after starting qemu.  Calling virDomainStop
immediately after the domain is up is inherently raceful.

* src/qemu/qemu_driver.c (qemudStartVMDaemon): Add new parameter;
all callers adjusted.
(qemudDomainCreate): Implement support for new flag.
2010-06-08 15:35:57 -06:00
2502ebb30a virDomainCreateXML: support new flag
* include/libvirt/libvirt.h.in (virDomainCreateFlags): Add
VIR_DOMAIN_START_PAUSED.
* src/libvirt.c (virDomainCreateXML): Update documentation.
* src/lxc/lxc_driver.c (lxcDomainCreateAndStart): Reject new flag
as unimplemented.
* src/opennebula/one_driver.c (oneDomainCreateAndStart):
Likewise.
* src/openvz/openvz_driver.c (openvzDomainCreateXML): Likewise.
* src/phyp/phyp_driver.c (phypDomainCreateAndStart): Likewise.
* src/qemu/qemu_driver.c (qemudDomainCreate): Likewise.
* src/test/test_driver.c (testDomainCreateXML): Likewise.
* src/uml/uml_driver.c (umlDomainCreate): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainCreateXML): Likewise.
* src/xen/xend_internal.c (xenDaemonCreateXML): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainCreateXML): Likewise.
2010-06-08 15:35:55 -06:00
e7f3bad46e Fix leaks in udev device add/remove v3
* This patch is a modification of a patch submitted by Nigel Jones.
  It fixes several memory leaks on device addition/removal:

1. Free the virNodeDeviceDefPtr in udevAddOneDevice if the return
   value is non-zero

2. Always release the node device reference after the device has been
   processed.

* Refactored for better readability per the suggestion of clalance
2010-06-08 14:46:29 -04:00
77da2487ea Add multiIQN tests
* Fix broken rng schema
* Add test input & output files
2010-06-08 13:14:26 -04:00
98fafb0c3e Add multiiqn XML dump
* Use virBufferEscapeString() per Dan B.
2010-06-08 13:14:18 -04:00
9cb08020e1 Fix test breakage from virtio serial changes
The virtio serial changes broke the test suite because they forgot
to add the new address attribute to the domain XML schema. The
xml2xml test also broke because the XML no longer roundtrips. This
is due to testing of auto-addition of <controller> elements. Split
that test case off into a separate XML file to avoid breakage

* docs/schemas/domain.rng: Allow port number for virtio serial addresses
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args,
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: Revert to
  a simple config to avoid breaking xml2xml test
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.xml,
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.args: Add
  complex test case for auto-controller addition for xml2argv test
* tests/qemuxml2argvtest.c: Add channel-virtio-auto test
2010-06-08 16:31:50 +01:00
f4365c73a2 Enable probing of VPC disk format type
A look at the QEMU source revealed the missing bits of info about
the VPC file format, so we can enable this now

* src/util/storage_file.c: Enable VPC format, providing version
  and disk size offset fields
2010-06-08 16:05:36 +01:00
1c72695c44 Ensure that PCI device is reattached to host if hotadd fails
When an attempt to hotplug a PCI device to a guest fails,
the device was left attached to pci-stub. It is neccessary
to reset the device and then attach it to the host driver
again.

* src/qemu/qemu_driver.c: Reattach PCI device to host if
  hotadd fails
2010-06-08 15:21:07 +01:00
f43dc26af7 Don't raise errors in the selinux restore code
The restore code is done in places where errors cannot be
raised, since they will overwrite over pre-existing errors.

* src/security/security_selinux.c: Only warn about failures
  in label restore, don't report errors
2010-06-08 15:21:07 +01:00
c833efd35b Fix check for errors in device_add command in QEMU text monitor
Any output at all from device_add indicates an error in the
command execution. Thus it needs to check for reply != ""

* src/qemu/qemu_monitor_text.c: Fix reply check for errors
  to treat any output as an error
2010-06-08 15:20:59 +01:00
345ff369e5 Prefer UDEV to HAL drivers if both a compiled
HAL is deprecated and UDEV is the future. Thus if both
options are compiled, we should prefer use of UDEV over
HAL

* src/node_device/node_device_driver.c: Switch init
  order to try UDEV first, then HAL
2010-06-08 15:15:02 +01:00
e72cc3c11d Add support for setting socket MLS level in SELinux driver
When SELinux is running in MLS mode, libvirtd will have a
different security level to the VMs. For libvirtd to be
able to connect to the monitor console, the client end of
the UNIX domain socket needs a different label. This adds
infrastructure to set the socket label via the security
driver framework

* src/qemu/qemu_driver.c: Call out to socket label APIs in
  security driver
* src/qemu/qemu_security_stacked.c: Wire up socket label
  drivers
* src/security/security_driver.h: Define security driver
  entry points for socket labelling
* src/security/security_selinux.c: Set socket label based on
  VM label
2010-06-08 15:14:57 +01:00
3bb3743934 Network duplicate UUID/name checking
The network driver is not doing correct checking for
duplicate UUID/name values. This introduces a new method
virNetworkObjIsDuplicate, based on the previously
written virDomainObjIsDuplicate.

* src/conf/network_conf.c, src/conf/network_conf.c,
  src/libvirt_private.syms: Add virNetworkObjIsDuplicate,
* src/network/bridge_driver.c: Call virNetworkObjIsDuplicate
  for checking uniqueness of uuid/names
2010-06-08 15:11:20 +01:00
627409d1f4 Fix error codes for missing storage pools
The storage pool driver is mistakenly using the error code
VIR_ERR_INVALID_STORAGE_POOL which is for diagnosing invalid
pointers. This patch switches it to use VIR_ERR_NO_STORAGE_POOL
which is the correct code for cases where the storage pool does
not exist

* src/storage/storage_driver.c: Replace VIR_ERR_INVALID_STORAGE_POOL
  with VIR_ERR_NO_STORAGE_POOL
2010-06-08 15:11:13 +01:00
e9364d9f2a Storage pool duplicate UUID/name checking
The storage pool driver is not doing correct checking for
duplicate UUID/name values. This introduces a new method
virStoragePoolObjIsDuplicate, based on the previously
written virDomainObjIsDuplicate.

* src/conf/storage_conf.c, src/conf/storage_conf.c,
  src/libvirt_private.syms: Add virStoragePoolObjIsDuplicate,
* src/storage/storage_driver.c: Call virStoragePoolObjIsDuplicate
  for checking uniqueness of uuid/names
2010-06-08 15:11:08 +01:00
f4f91e7b24 Fix auto-adding of virtio serial controllers
The domain parsing code would auto-add a virtio serial controller
if it saw any virtio serial channel defined. Unfortunately it
always added a controller with index=0, even if the channel address
specified an index != 0. It only added one controller, even if
multiple controllers were referenced by channels. Finally, it let
the ports+vectors parameters initialize to zero instead of -1, which
prevented the controllers accepting any ports.

* src/conf/domain_conf.c: Initialize ports+vectors when adding
  virtio serial controllers. Add all neccessary virtio serial
  controllers, instead of hardcoding controller 0
* qemuxml2argvdata/qemuxml2argv-channel-virtio.args,
  qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: Expand to
  test controller auto-add behaviour
2010-06-08 15:08:21 +01:00
2e56cfa7d2 Include port number with virtio serial devices
To ensure that the device addressing scheme is stable across
hotplug/unplug, all virtio serial channels needs to have an
associated port number in their address. This is then specified
to QEMU using the nr=NNN parameter

* src/conf/domain_conf.c, src/conf/domain_conf.h: Parsing
  for port number in vioserial address types.
* src/qemu/qemu_conf.c: Set 'nr=NNN' parameter with virtio
  serial port number
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args,
  tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml: Expand
  data set to ensure coverage of port addressing
2010-06-08 15:08:15 +01:00
b490f2c1e0 Disable use of 'reason' field in block IO event in QEMU
QEMU upstream decided against adding a 'reason' field to
the block IO event in QMP. Disable this code to remove a
annoying warning message. It will be renabled when the
error string reason is re-introduced in QEMU
2010-06-08 15:05:42 +01:00
53fc1d8afd Ensure UNIX domain sockets are removed on daemon shutdown
When libvirtd exits it is leaving UNIX domain sockets on
the filesystem. These need to be removed.

The qemudInitPaths() method has signficant code churn to
switch from using a pre-allocated buffer on the stack, to
dynamically allocating on the heap.

* daemon/libvirtd.c, daemon/libvirtd.h: Store a reference
  to the UNIX domain socket path and unlink it on shutdown
2010-06-08 15:05:37 +01:00
3093daf184 virsh: fix minor virsh man page typos and formatting problems
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-06-07 18:22:42 -06:00
97b68a4943 Fix AppArmor save/restore.Add stdin_path to qemudStartVMDaemon() args.
Refactor to update AppArmor security driver to adjust profile for
save/restore. This addresses the following bugs:

 https://bugzilla.redhat.com/show_bug.cgi?id=529363
 https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/457716
2010-06-07 14:41:21 -04:00
2b57478ef0 Add stdin_path to qemudStartVMDaemon() args.
Adjust args to qemudStartVMDaemon() to also specify path to stdin_fd,
so this can be passed to the AppArmor driver via SetSecurityAllLabel().

This updates all calls to qemudStartVMDaemon() as well as setting up
the non-AppArmor security driver *SetSecurityAllLabel() declarations
for the above. This is required for the following
"apparmor-fix-save-restore" patch since AppArmor resolves the passed
file descriptor to the pathname given to open().
2010-06-07 14:41:09 -04:00
ef77388ba4 avoid syntax-check failure
* .mailmap: Map a stray commit-author email address to the canonical one.
Reported by Justin Clift.
2010-06-06 10:27:28 +02:00
20206a4bc9 Adjust block size used by dd to speed QEMU domain save operations.
See https://bugzilla.redhat.com/show_bug.cgi?id=599091

Saving a paused 512MB domain took 3m47s with the old block size of 512
bytes. Changing the block size to 1024*1024 decreased the time to 56
seconds. (Doubling again to 2048*1024 yielded 0 improvement; lowering
to 512k increased the save time to 1m10s, about 20%)
2010-06-04 15:36:17 -04:00
1d45e1b622 Fix dereference of potentially freed pointer in qemudDomainSaveFlags
The pointer to the xml describing the domain is saved into an object
prior to calling VIR_REALLOC_N() to make the size of the memory it
points to a multiple of QEMU_MONITOR_MIGRATE_TO_FILE_BS. If that
operation needs to allocate new memory, the pointer that was saved is
no longer valid.

To avoid this situation, adjust the size *before* saving the pointer.

(This showed up when experimenting with very large values of
QEMU_MONITOR_MIGRATE_TO_FILE_BS).
2010-06-04 15:36:04 -04:00
b1eb7f2e98 Fixes for commit 211dd1e9
Fixes for issues in commit 211dd1e9 noted by by Jim Meyering.

1. Allocate content buffer of size content_length + 1 to ensure
   NUL-termination.
2. Limit content buffer size to 64k
3. Fix whitespace issue

V2:
  - Add comment to clarify allocation of content buffer
  - Add ATTRIBUTE_NONNULL where appropriate
  - User NULLSTR macro
2010-06-04 11:19:33 -06:00
fc6d5b2649 autobuild.sh: avoid bashism
* autobuild.sh: Replace 'set -o pipefail' with POSIX alternative.
Reported by Matthias Bolte.
2010-06-04 10:03:52 -06:00
211dd1e9c5 Allocate buffer to hold xend response
There are cases when a response from xend can exceed 4096 bytes, in
which case anything beyond 4096 is ignored. This patch changes the
current fixed-size, stack-allocated buffer to a dynamically allocated
buffer based on Content-Length in HTTP header.
2010-06-03 12:19:58 -06:00
2874a683e9 Update nodedev scsi_host data before use
* It appears that the udev event for HBA creation arrives before the
  associated sysfs data is fully populated, resulting in bogus data
  for the nodedev entry until the entry is refreshed.  This problem is
  particularly troublesome when creating NPIV vHBAs because it results
  in libvirt failing to find the newly created adapter and waiting for
  the full timeout period before erroneously failing the create
  operation.  This patch forces an update before any attempt to use
  any scsi_host nodedev entry.
2010-06-03 10:54:39 -04:00
d3e43bad98 Fix device destroy return value
* Set return value in error cases
* Clarify error message when parent device is not vport capable
2010-06-03 10:54:29 -04:00
a5b7965a29 phyp: Strict check when listing domains 2010-06-03 14:36:49 +02:00
ca3b22bb5c add 802.1Qbh and 802.1Qbg handling
This patch that adds support for configuring 802.1Qbg and 802.1Qbh
switches. The 802.1Qbh part has been successfully tested with real
hardware. The 802.1Qbg part has only been tested with a (dummy)
server that 'behaves' similarly to how we expect lldpad to 'behave'.

The following changes were made during the development of this patch:

 - Merging Scott's v13-pre1 patch
 - Fixing endptr related bug while using virStrToLong_ui() pointed out
   by Jim Meyering
 - Addressing Jim Meyering's comments to v11
 - requiring mac address to the vpDisassociateProfileId() function to
   pass it further to the 802.1Qbg disassociate part (802.1Qbh untouched)
 - determining pid of lldpad daemon by reading it from /var/run/libvirt.pid
   (hardcode as is hardcode alson in lldpad sources)
 - merging netlink send code for kernel target and user space target
   (lldpad) using one function nlComm() to send the messages
 - adding a select() after the sending and before the reading of the
   netlink response in case lldpad doesn't respond and so we don't hang
 - when reading the port status, in case of 802.1Qbg, no status may be
   received while things are 'in progress' and only at the end a status
   will be there.
 - when reading the port status, use the given instanceId and vf to pick
   the right IFLA_VF_PORT among those nested under IFLA_VF_PORTS.
 - never sending nor parsing IFLA_PORT_SELF type of messages in the
   802.1Qbg case
 - iterating over the elements in a IFLA_VF_PORTS to pick the right
   IFLA_VF_PORT by either IFLA_PORT_PROFILE and given profileId
   (802.1Qbh) or IFLA_PORT_INSTANCE_UUID and given instanceId (802.1Qbg)
   and reading the current status in IFLA_PORT_RESPONSE.
 - recycling a previous patch that adds functionality to interface.c to
   - get the vlan identifier on an interface
   - get the flags of an interface and some convenience function to
     check whether an interface is 'up' or not (not currently used here)
 - adding function to determine the root physical interface of an
   interface. For example if a macvtap is linked to eth0.100, it will
   find eth0. Also adding a function that finds the vlan on the 'way to
   the root physical interface'
 - conveying the root physical interface name and index in case of 802.1Qbg
 - conveying mac address of macvlan device and vlan identifier in
   IFLA_VFINFO_LIST[ IFLA_VF_INFO[ IFLA_VF_MAC(mac), IFLA_VF_VLAN(vlan) ] ]
   to (future) lldpad via netlink
  - To enable build with --without-macvtap rename the
    [dis|]associatePortProfileId functions, prepend 'vp' before their
    name and make them non-static functions.
  - Renaming variable multicast to nltarget_kernel and inverting
    the logic
  - Addressing Jim Meyering's comments; this also touches existing
    code for example for correcting indentation of break statements or
    simplification of switch statements.
  - Renamed occurrencvirVirtualPortProfileDef to virVirtualPortProfileParamses
  - 802.1Qbg part prepared for sending a RTM_SETLINK and getting
    processing status back plus a subsequent RTM_GETLINK to
    get IFLA_PORT_RESPONSE.
    Note: This interface for 802.1Qbg may still change
  - [David Allan] move getPhysfn inside IFLA_VF_PORT_MAX to avoid
compiler
    warning when latest if_link.h isn't available
  - move from Stefan's 802.1Qb{g|h} XML v8 to v9
  - move hostuuid and vf index calcs to inside doPortProfileOp8021Qbh
  - remove debug fprintfs
  - use virGetHostUUID (thanks Stefan!)
  - fix compile issue when latest if_link.h isn't available
  - change poll timeout to 10s, at 1/8 intervals
     - if polling times out, log msg and return -ETIMEDOUT
  - Add Stefan's code for getPortProfileStatus
  - Poll for up to 2 secs for port-profile status, at 1/8 sec intervals:
     - if status indicates error, abort openMacvtapTap
     - if status indicates success, exit polling
     - if status is "in-progress" after 2 secs of polling, exit
       polling loop silently, without error

My patch finishes out the 802.1Qbh parts, which Stefan had mostly complete.
I've tested using the recent kernel updates for VF_PORT netlink msgs and
enic for Cisco's 10G Ethernet NIC.  I tested many VMs, each with several
direct interfaces, each configured with a port-profile per the XML.  VM-to-VM,
and VM-to-external work as expected.  VM-to-VM on same host (using same NIC)
works same as VM-to-VM where VMs are on diff hosts.  I'm able to change
settings on the port-profile while the VM is running to change the virtual
port behaviour.  For example, adjusting a QoS setting like rate limit.  All
VMs with interfaces using that port-profile immediatly see the effect of the
change to the port-profile.

I don't have a SR-IOV device to test so source dev is a non-SR-IOV device,
but most of the code paths include support for specifing the source dev and
VF index.  We'll need to complete this by discovering the PF given the VF
linkdev.  Once we have the PF, we'll also have the VF index.  All this info-
mation is available from sysfs.
2010-06-02 21:35:22 -04:00
ce49cfb48a bitmap: reject zero-size bitmap
* src/util/bitmap.c (virBitmapAlloc): Tighten sanity check.
2010-06-02 09:03:57 -06:00
fa6da6608a hostusb: Properly handle 'usbX' sysfs files
Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=598272

Some files under /sys/bus/usb/devices/ have the format 'usbX', where
X is the USB bus number. Use STRPREFIX to correctly parse the bus numbers.
2010-06-02 09:57:55 -04:00
3db47cb5d2 Add --source-format argument to virsh pool-define-as and pool-create-as
This is the corresponding patch for the virsh man page (virsh.pod).
2010-06-01 16:58:00 -06:00
b221973a11 Add --source-format argument to virsh pool-define-as and pool-create-as
When creating pools from dedicated disks, the existing pool-define-as
and pool-create-as commands are a bit non-optimal.

Ideally, a person would be able to specify all of the required options
directly on the command line instead of having to edit the XML.

At the moment, there is no way to specify the format type (ie gpt) so it
gets included in the XML the pool is constructed with.

Please find attached a simple (tested) patch to add an optional
"--source-format 'type'" to virsh.  This is patched against current git
master and will apply cleanly.

Also created a Red Hat BZ ticket for this (#597790) for tracking.
2010-06-01 16:57:17 -06:00
e5f31f461f Trivial virsh.pod additions --all for "list" command and similar
This is just a trivial patch to virsh.pod (from git master). It adds the
following pieces to the virsh man page:

  + Shows the --inactive and --all optional parameters for the list
    command.

    Closes Bugzilla #575512, reported by Renich Bon Ciric
    https://bugzilla.redhat.com/show_bug.cgi?id=575512

  + Corrects the existing description of the list command, to now say
    that only running domains are listed if no domains are specified.

    The man page up until this point has said all domains are listed if
    no domains are specified, which is incorrect.

  + Adds the "shut off" state to the list of states for the list
    command.

  + Adds a missing =back around line 755, that pod2man was complaining
    was missing.
2010-06-01 16:46:51 -06:00
e82f917015 build: fix VPATH 'make syntax-check'
* cfg.mk (sc_check_author_list): Look in correct location.
2010-06-01 16:34:25 -06:00
12f7ed9357 build: depend on correct file
Otherwise, VPATH builds fail with:

make[1]: *** No rule to make target `libvirt-guests.init', needed by `all'.

Regression introduced in commit 482e08a9.

* daemon/Makefile.am (%.init): Look in correct place for
config.status.
2010-06-01 15:09:25 -06:00
8b5bc6c479 qemu: Add a qemu.conf option for clearing capabilities
Currently there is no way to opt out of libvirt dropping POSIX
capabilities for qemu. This at least is a useful debugging tool, but
is also wanted by users (and distributors):

https://bugzilla.redhat.com/show_bug.cgi?id=559154
https://bugzilla.redhat.com/show_bug.cgi?id=573850

v2: Clarify qemu.conf comment, warn about security implications

v3: Add .aug changes
2010-06-01 13:01:17 -04:00
f9a4df5a5b build: make cpp indentation conform
* src/storage/storage_backend.h (VIR_STORAGE_VOL_OPEN_DEFAULT):
Adjust s/#define/# define/, and align continued lines.
2010-05-29 09:45:21 +02:00
4a1abb3f50 storage: Check for invalid storage mode before opening
If a directory pool contains pipes or sockets, a pool start can fail or hang:

https://bugzilla.redhat.com/show_bug.cgi?id=589577

We already try to avoid these special files, but only attempt after
opening the path, which is where the problems lie. Unify volume opening
into helper functions, which use the proper open() flags to avoid error,
followed by fstat to validate storage mode.

Previously, virStorageBackendUpdateVolTargetInfoFD attempted to enforce the
storage mode check, but allowed callers to detect this case and silently
continue. In practice, only the FS backend was using this feature, the rest
were treating unknown mode as an error condition. Unfortunately the InfoFD
function wasn't raising an error message here, so error reporting was
busted.

This patch adds 2 functions: virStorageBackendVolOpen, and
virStorageBackendVolOpenModeSkip. The latter retains the original opt out
semantics, the former now throws an explicit error.

This patch maintains the previous volume mode checks: allowing specific
modes for specific pool types requires a bit of surgery, since VolOpen
is called through several different helper functions.

v2: Use ATTRIBUTE_NONNULL. Drop stat check, just open with
    O_NONBLOCK|O_NOCTTY.

v3: Move mode check logic back to VolOpen. Use 2 VolOpen functions with
    different error semantics.

v4: Make second VolOpen function more extensible. Didn't opt to change
    FS backend defaults, this can just be to fix the original bug.

v5: Prefix default flags with VIR_, use ATTRIBUTE_RETURN_CHECK
2010-05-28 15:47:49 -04:00
ca1b7cc8e4 macvtap: cannot support target device name
Since the macvtap device needs active tear-down and the teardown logic
is based on the interface name, it can happen that if for example 1 out
of 3 interfaces was successfully created, that during the failure path
the macvtap's target device name is used to tear down an interface that
is doesn't own (owned by another VM).

So, in this patch, the target interface name is reset so that there is
no target interface name and the interface name is always cleared after
a tear down.
2010-05-28 13:00:58 -04:00
8b46a7bbdb Improve nodedev parent/child relationships
* If a nodedev has a parent that we don't want to display, we should
  continue walking up the udev device tree to see if any of its
  earlier ancestors are devices that we display.  It makes the tree
  much nicer looking than having a whole lot of devices hanging off
  the root node.
2010-05-28 12:48:45 -04:00
1a5c465ee5 Fix libvirt-guests init script
Firstly, the init script has to touch its file under /var/lock/subsys
when started, otherwise the system would think it's not running and
won't stop it during shutdown.

Secondly, for some reason there is a policy to automatically enable
init scripts when they are installed, so let the specfile do this. We
also need to start the init script to ensure it will be stopped during
the first shutdown after installing the package.

Also $LISTFILE should be enclosed by quotes everywhere as suggested by
Eric.
2010-05-28 18:00:53 +02:00
208b2ad879 maint: new syntax-check rule to ensure that AUTHORS stays in sync
* cfg.mk (sc_check_AUTHOR_list): New rule.
* .mailmap: New file, to tell git log how to map email addresses.
2010-05-28 15:02:04 +02:00
55945841bc hooks: fix typo
* src/util/hooks.c (virHookLxcOp): Use correct bound.
2010-05-28 06:54:28 -06:00
6456eef8b5 build: silence cppi warning, clarify vbox headers
These files are borrowed from upstream release versions, and should
not need further edits in the context of libvirt (instead, a new
upstream vbox release would entail adding a new header file).  We do
not re-generate these files as part of libvirt, nor do we want to lose
our minor edits (such as cppi cleanups).

* src/vbox/vbox_CAPI_v2_2.h: Clarify file origins.
* src/vbox/vbox_CAPI_v3_0.h: Likewise.
* src/vbox/vbox_CAPI_v3_1.h: Likewise.
* src/vbox/vbox_CAPI_v3_2.h: Likewise.  Reindent with cppi.
2010-05-27 17:00:39 -06:00
a83fe2c23e network: bridge: Don't start network if it collides with host routing
Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=235961

If using the default virtual network, an easy way to lose guest network
connectivity is to install libvirt inside the VM. The autostarted
default network inside the guest collides with host virtual network
routing. This is a long standing issue that has caused users quite a
bit of pain and confusion.

On network startup, parse /proc/net/route and compare the requested
IP+netmask against host routing destinations: if any matches are found,
refuse to start the network.

v2: Drop sscanf, fix a comment typo, comment that function could use
    libnl instead of /proc

v3: Consider route netmask. Compare binary data rather than convert to
    string.

v4: Return to using sscanf, drop inet functions in favor of virSocket,
    parsing safety checks. Don't make parse failures fatal, in case
    expected format changes.

v5: Try and continue if we receive unexpected. Delimit parsed lines to
    prevent scanning past newline
2010-05-27 18:02:53 -04:00
1be3f095c9 maint: update AUTHORS with recent contributors
git shortlog $(git log -1 --format=%H AUTHORS).. | grep -v "^ "

then add missing entries to AUTHORS.

* AUTHORS: Update.
2010-05-27 15:24:50 -06:00
953809dbe4 xen: Fix chardev listen sexpr formatting
'listen' isn't a valid qemu-dm option, as reported a long time ago here:

https://bugzilla.redhat.com/show_bug.cgi?id=492958

Matches the near identical logic in qemu_conf.c

v2: When parsing sexpr, only match on ",server", rather than
    full ',server,nowait'.
2010-05-27 14:26:05 -04:00
7842e544ca xen: Remove unused function
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2010-05-27 14:16:47 -04:00
07f6c3a95f v2 of Cole's wlan support
* Incorporated Jim's feedback (v1 & v2)

* Moved case of DEVTYPE == "wlan" up as it's definitive that we have a network interface.

* Made comment more detailed about the wired case to explain better
  how it differentiates between wired network interfaces and USB
  devices.
2010-05-27 13:20:04 -04:00
dafd354d12 Add docs on drive <serial> element
* docs/formatdomain.html.in: Document <serial> element within
  <disk> and fix typo on <driver/> element
2010-05-27 12:44:41 +01:00
041aac8648 esx: Simplify goto usage
Eliminate almost all backward jumps by replacing this common pattern:

int
some_random_function(void)
{
    int result = 0;
    ...

  cleanup:
    <unconditional cleanup code>
    return result;

  failure:
    <cleanup code in case of an error>
    result = -1;
    goto cleanup
}

with this simpler pattern:

int
some_random_function(void)
{
    int result = -1;
    ...
    result = 0;

  cleanup:
    if (result < 0) {
        <cleanup code in case of an error>
    }

    <unconditional cleanup code>
    return result;
}

Add a bool success variable in functions that don't have a int result
that can be used for the new pattern.

Also remove some unnecessary memsets in error paths.
2010-05-27 01:32:25 +02:00
8b0cd87696 Support for VirtualBox version 3.2 2010-05-27 01:28:21 +02:00
fa0bb9f6b1 Use printf instead of echo -e in libvirt.spec.in
make rpm created dummy tests containing '-e #!/bin/sh' for me.
2010-05-27 01:11:15 +02:00
5ac0272370 Install, distribute and package domainsnapshot.rng 2010-05-27 01:11:15 +02:00
047b024f1c build: support 'make check' in pristine tree
Otherwise, 'make check' in the python dir tries to reference a file in
docs that is built by 'make' but not by 'make check'.

* docs/Makefile.am (check-local): New rule.
Reported by Matthias Bolte.
2010-05-26 16:14:47 -06:00
b4cead5949 esx: Expose host UUID in the capabilities XML
Parse the BIOS UUID. This information may not be available, in that
case no host UUID is exposed in the capabilities XML.
2010-05-27 00:03:57 +02:00
bbe29be9a8 Fix integer overflow in hotplug methods
The hotplug methods still had the qemuCmdFlags variable declared
as an int, instead of unsigned long long. This caused flag checks
to be incorrect for flags > 31

* src/qemu/qemu_driver.c: Fix integer overflow in hotplug
2010-05-26 17:41:55 +01:00
c444af1ac2 Pass pre-opened PCI device sysfs config file to QEMU
This allows libvirt to open the PCI device sysfs config file prior
to dropping privileges so qemu can access the full config space.
Without this, a de-privileged qemu can only access the first 64
bytes of config space.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Detect support
  for pci-assign.configfd option. Use this option when formatting
  PCI device string if possible
* src/qemu/qemu_driver.c: Pre-open PCI sysfs config file and pass
  to QEMU
2010-05-26 17:41:55 +01:00
7f44743c52 daemon: sysconf: Update comment about VNC audio 2010-05-26 10:51:36 -04:00
0117b7da68 Fix failing virGetHostname.
We've been running into a lot of situations where
virGetHostname() is returning "localhost", where a plain
gethostname() would have returned the correct thing.  This
is because virGetHostname() is *always* trying to canonicalize
the name returned from gethostname(), even when it doesn't
have to.

This patch changes virGetHostname so that if the value returned
from gethostname() is already FQDN or localhost, it returns
that string directly.  If the value returned from gethostname()
is a shortened hostname, then we try to canonicalize it.  If
that succeeds, we returned the canonicalized hostname.  If
that fails, and/or returns "localhost", then we just return
the original string we got from gethostname() and hope for
the best.

Note that after this patch it is up to clients to check whether
"localhost" is an allowed return value.  The only place
where it's currently not is in qemu migration.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-26 08:59:31 -04:00
33737db1be xen-proxy build broken
The virVirtualPortProfileFormat just went below the
virVirtualPortProfileParamsParseXML function and got inside the

The attached patch moves virVirtualPortProfileFormat below the #ifndef
PROXY block.
2010-05-26 06:45:28 -04:00
ddb4ae0ca9 esx: Add read-only storage pool access
Allows listing existing pools and requesting information about them.

Alter the esxVI_ProductVersion enum in a way that allows to check for
product type by masking.
2010-05-26 12:01:27 +02:00
6e6acb776b build: fix HTML errors in nwfilter docs
A build on Ubuntu reported:

|| Generating formatnwfilter.html.tmp
/dados/develop/libvirt/docs/formatnwfilter.html.in|390| HTML parser error : Unexpected end tag : p
||     </p>
||         ^
/dados/develop/libvirt/docs/formatnwfilter.html.in|705| HTML parser error : Unexpected end tag : code
||          <td>End of range of valid source ports</code></td>
||                                                       ^
/dados/develop/libvirt/docs/formatnwfilter.html.in|710| HTML parser error : Unexpected end tag : code
||          <td>Start of range of valid destination ports</code></td>
||                                                              ^

* docs/formatnwfilter.html.in: Fix invalid HTML constructs.
Reported by Eduardo Otubo.
2010-05-25 17:33:21 -06:00
8d9c7a93bc build: fix compilation without macvtap
* src/util/macvtap.c: (associatePortProfileId)
(disassociatePortProfileId): Move inside HAVE_MACVTAP
conditional.
Reported by Eduardo Otubo.
2010-05-25 16:51:12 -06:00
572c6cc10a tests: avoid new failure of the daemon-conf test
* tests/daemon-conf: Accommodate the fact that out template,
daemon/libvirtd.conf now contains an invalid host_uuid.
Convert it to a valid one before the final libvirtd-running
test that must terminate normally.
2010-05-25 15:53:19 -06:00
3db8607f34 libvirtd: diagnose invalid host UUID
* daemon/libvirtd.c (remoteReadConfigFile): Diagnose an invalid
host UUID rather than silently exiting with status 7.
2010-05-25 15:53:19 -06:00
a8f75d2c7d vepa: parsing for 802.1Qb{g|h} XML
This patch parses the following two XML descriptions, one for
802.1Qbg and one for 802.1Qbh, and stores the data internally.
The actual triggering of the switch setup protocol has not been
implemented here but the relevant code to do that should go into
the functions associatePortProfileId() and disassociatePortProfileId().

   <interface type='direct'>
      <source dev='eth0.100' mode='vepa'/>
      <model type='virtio'/>
      <virtualport type='802.1Qbg'>
        <parameters managerid='12' typeid='0x123456' typeidversion='1'
         instanceid='fa9b7fff-b0a0-4893-8e0e-beef4ff18f8f'/>
      </virtualport>
      <filterref filter='clean-traffic'/>
    </interface>

    <interface type='direct'>
      <source dev='eth0.100' mode='vepa'/>
      <model type='virtio'/>
      <virtualport type='802.1Qbh'>
        <parameters profileid='my_profile'/>
      </virtualport>
    </interface>

I'd suggest to use this patch as a base for triggering the setup
protocol with the 802.1Qb{g|h} switch.

Several rounds of changes were made to this patch. The
following is a list of these changes.
- Renamed structure virVirtualPortProfileDef to virVirtualPortProfileParams
  as per Daniel Berrange's request
- Addressing Daniel Berrange's comments:
 - removing macvtap.h's dependency on domain_conf.h by
   moving the virVirtualPortProfileDef structure into macvtap.h
   and not passing virtDomainNetDefPtr to any functions in
   macvtap.c
- Addressed most of Chris Wright's comments:
  - indicating error in case virtualport XML node cannot be parsed
    properly
  - parsing hex and decimal numbers using virStrToLong_ui() with
    parameter '0' for base
  - tgifname (target interface name) variable wasn't necessary
    to pass to openMacvtapTap function anymore
- assigning the virtual port data structure to the virDomainNetDef
  only if it was previously parsed
- make sure that the error code returned by openMacvtapTap() is a negative n
  in case the associatePortProfileId() function failed.
- renaming vsi in the XML to virtualport
- replace all occurrences of vsi in the source as well
- removing mode and MAC address parameters from the functions that
  will communicate with the hareware diretctly or indirectly
- moving the associate and disassociate functions to the end of the
  file for subsequent patches to easier make them generally available
  for export
- passing the macvtap interface name rather than the link device since
  this otherwise gives funny side effects when using netlink messages
  where IFLA_IFNAME and IFLA_ADDRESS are specified and the link dev
  all of a sudden gets the MAC address of the macvtap interface.
- Removing rc = -1 error indications in the case of 802.1Qbg|h setup in case
  we wanted to use hook scripts for the setup and so the setup doesn't fail
  here.
- if instance ID UUID is not supplied it will automatically be generated
  - adapted schema to make instance ID UUID optional
  - added test case
- parser and XML generator have been separated into their own
  functions so they can be re-used elsewhere (passthrough case
  for example)
- Adapted XML parser and generator support the above shown type
  (802.1Qbg, 802.1Qbh).
- Adapted schema to above XML
- Adapted test XML to above XML
- Passing through the VM's UUID which seems to be necessary for
  802.1Qbh -- sorry no host UUID
- adding virtual function ID to association function, in case it's
  necessary to use (for SR-IOV)
2010-05-25 17:37:00 -04:00
a34871d9a5 vepa+vsi: Introduce dependency on libnl
This patch introduces a dependency on libnl, which subsequent patches
will then use.

Changes from V1 to V2:
- added diffstats
- following changes in tree
2010-05-25 15:31:38 -04:00
a7fb2258ca storage: Sanitize pool target paths
Spurious / in a pool target path makes life difficult for apps using the
GetVolByPath, and doing other path based comparisons with pools. This
has caused a few issues for virt-manager users:

https://bugzilla.redhat.com/show_bug.cgi?id=494005
https://bugzilla.redhat.com/show_bug.cgi?id=593565

Add a new util API which removes spurious /, virFileSanitizePath. Sanitize
target paths when parsing pool XML, and for paths passed to GetVolByPath.

v2: Leading // must be preserved, properly sanitize path=/, sanitize
    away /./ -> /

v3: Properly handle starting ./ and ending /.

v4: Drop all '.' handling, just sanitize / for now.
2010-05-25 12:30:44 -04:00
60881161ea Expose a host UUID in the capabilities XML
Allow for a host UUID in the capabilities XML. Local drivers
will initialize this from the SMBIOS data. If a sanity check
shows SMBIOS uuid is invalid, allow an override from the
libvirtd.conf configuration file

* daemon/libvirtd.c, daemon/libvirtd.conf: Support a host_uuid
  configuration option
* docs/schemas/capability.rng: Add optional host uuid field
* src/conf/capabilities.c, src/conf/capabilities.h: Include
  host UUID in XML
* src/libvirt_private.syms: Export new uuid.h functions
* src/lxc/lxc_conf.c, src/qemu/qemu_driver.c,
  src/uml/uml_conf.c: Set host UUID in capabilities
* src/util/uuid.c, src/util/uuid.h: Support for host UUIDs
* src/node_device/node_device_udev.c: Use the host UUID functions
* tests/confdata/libvirtd.conf, tests/confdata/libvirtd.out: Add
  new host_uuid config option to test
2010-05-25 17:09:18 +01:00
e596dbb32a Fix handling of disk backing stores with cgroups
The cgroups ACL code was only allowing the primary disk image.
It is possible to chain images together, so we need to search
for backing stores and add them to the ACL too. Since the ACL
only handles block devices, we ignore the EINVAL we get from
plain files. In addition it was missing code to teardown the
cgroup when hot-unplugging a disk

* src/qemu/qemu_driver.c: Allow backing stores in cgroup ACLs
  and add missing teardown code in unplug path
2010-05-25 10:57:54 -04:00
93500040f9 Fix up basic migration.
Basic live migration was broken by the commit that added
non-shared block support in two ways:

1)  It added a virCheckFlags() to doNativeMigrate().  Besides
the fact that typical usage of virCheckFlags() is in driver
entry points, and doNativeMigrate() is not an entry point,
it was missing important flags like VIR_MIGRATE_LIVE.  Move
the virCheckFlags to the top-level qemuDomainMigratePrepare2
and friends.

2)  It also added a memory leak in qemuMonitorTextMigrate()
by not freeing the memory used by virBufferContentAndReset().
This is fixed by storing the pointer in a temporary variable
and freeing it at the end.

With this patch in place, normal live migration works again.

v3: Instead of the churn for virCheckFlagsUI and UL, instead
always promote flags to an unsigned long and always use %lx
for the fprintf.
v2: Add back flags check, which required adding virCheckFlagsUI
and virCheckFlagsUL

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-25 10:48:10 -04:00
fb3ebd0397 qemu: Allow using regular audio backends with VNC
Currently all host audio backends are disabled if a VM is using VNC, in
favor of the QEMU VNC audio extension. Unfortunately no released VNC
client supports this extension, so users have no way of getting audio
to work if using VNC.

Add a new config option in qemu.conf which allows changing libvirt's
behavior, but keep the default intact.

v2: Fix doc typos, change name to vnc_allow_host_audio
2010-05-25 10:49:29 -04:00
c82d106ed1 storage: mpath: Fix incorrect VIR_ERROR use 2010-05-25 10:49:28 -04:00
60d05f7321 Allow nwfilter functions to be compiled with C++
Unfortunately the NWFilter functions were outside of the
"extern C { ... }" declaration in include/libvirt/libvirt.h.in,
which means that they couldn't be properly used with C++.  Move
them inside of the braces, which should fix the problem.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-25 09:29:33 -04:00
f36eb6935d nwfilter: documentation
This patch adds documentation of the nwfilter subsystem of libvirt to
the existing (web) docs.
2010-05-25 07:09:31 -04:00
7488107fa8 maint: update AUTHORS with recent contributors
git shortlog $(git log -1 --format=%H AUTHORS).. | grep -v "^ "

then add missing entries to AUTHORS.

* AUTHORS: Update.
2010-05-24 16:30:39 -06:00
7d47e813b4 qemu: Release bus address on PCI host device remove
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2010-05-24 16:22:20 -06:00
ddfd4dba95 qemu: avoid corrupting guest info struct on host device PCI hot add
The device path doesn't make use of guestAddr, so the memcpy corrupts
the guest info struct.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2010-05-24 16:22:09 -06:00
ebb0c19c48 Query block allocation extent from QEMU monitor
The virDomainGetBlockInfo API allows query physical block
extent and allocated block extent. These are normally the
same value unless storing a special format like qcow2
inside a block device. In this scenario we can query QEMU
to get the actual allocated extent.

Since last time:

 - Return fatal error in text monitor
 - Only invoke monitor command for block devices
 - Fix error handling JSON code

* src/qemu/qemu_driver.c: Fill in block aloction extent when VM
  is running
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  API to query the highest block extent via info blockstats
2010-05-24 15:55:51 -06:00
dd1058fa8f lxcSetSchedulerParameters: reverse order of tests; diagnose a failure
* src/lxc/lxc_driver.c (lxcSetSchedulerParameters): Ensure that
"->field" is "cpu_shares" before possibly giving a diagnostic about
a type for a "cpu_shares" value.
Also, virCgroupSetCpuShares could fail without evoking a diagnostic.
Add one.
2010-05-24 15:55:04 -06:00
fff6be0cc0 Don't overwrite virDomainAssignDef errors.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-24 16:00:57 -04:00
e40a285bb7 storage: Combine some duplicate code
Volume detection in the scsi backend was duplicating code already
present in storage_backend.c. Let's drop the duplicate code.

Also, change the shared function name to be less generic, and remove
some error squashing in the other call site.
2010-05-24 10:43:19 -04:00
5086f85cc1 storage: mpath: Clean up some error handling
We were squashing error messages in a few cases. Recode to follow common
ret = -1 convention.

v2: Handle more error squashing issues further up in MakeNewVol and
    CreateVols. Use ret = -1 convention in MakeVols.
2010-05-24 10:43:19 -04:00
bfa6b73e43 Remove dead code after refactoring qemudDomainStart
The event is already generated and sent by qemudDomainObjStart, no need
to do anything about here.
2010-05-24 08:08:29 +02:00
d5fda6d6bc libvirtd: start each diagnostic with "argv0: "
Some diagnostics had a hard-coded "libvirtd: " prefix, some used
"error: " and some used "argv[0]: ".  Always use "argv[0]: ".
* daemon/libvirtd.c (argv0): New global.
(main): Set it.
(version, usage): Remove argv0 parameter.  Use global; update callers.
(daemonForkIntoBackground): Use argv0:, not error:.
(qemudWritePidFile): Start each diagnostic with argv0:.
Suggested by Eric Blake.
2010-05-22 23:09:30 +02:00
0c31633834 libvirtd: mark strings for translation, including --help output
* daemon/libvirtd.c (daemonForkIntoBackground, main): Mark strings
for translation.
(usage): Rework --help so that it is translatable, replacing
each embedded, configuration-dependent, macro with an `%s'.

libvirtd: don't ignore virInitialize failure
* daemon/libvirtd.c (main): Diagnose virInitialize failure
and exit nonzero.
2010-05-22 23:09:30 +02:00
0e1f4633d0 build: fix cppi warnings
* src/util/bitmap.h (includes): Placate cppi.
2010-05-21 16:02:18 -06:00
482e08a98a build: force init scripts to rebuild on changed --prefix
Otherwise, './configure --prefix=/foo && make &&
 ./configure --prefix=/bar && make' leaves the wrong files
in libvirtd.init (/foo instead of /bar).

* daemon/Makefile.am (libvirtd.init): Add dependency on
config.status.  Reported by Cole Robinson.
2010-05-21 15:18:24 -06:00
9c563e76e8 build: Distribute the whole tests/qemuhelpdata directory
Instead of distributing the individual files.

Now it's less error prone and consistent with the rest of
the data directories in the tests directory.
2010-05-21 20:08:57 +02:00
afa3f0af1f .gitignore: Add libvirt-guests.init 2010-05-21 13:59:31 -04:00
ba196952f5 Fix race in finding available vnc port
The qemu driver contains a subtle race in the logic to find next
available vnc port.  Currently it iterates through all available ports
and returns the first for which bind(2) succeeds.  However it is possible
that a previously issued port has not yet been bound by qemu, resulting
in the same port used for a subsequent domain.

This patch addresses the race by using a simple bitmap to "reserve" the
ports allocated by libvirt.

V2:
  - Put port bitmap in struct qemud_driver
  - Initialize bitmap in qemudStartup

V3:
  - Check for failure of virBitmapGetBit
  - Additional check for port != -1 before calling virbitmapClearBit

V4:
  - Check for failure of virBitmap{Set,Clear}Bit
2010-05-21 11:29:03 -06:00
c020f6203e Add defines for QEMU_VNC_PORT_{MIN,MAX} and use them 2010-05-21 11:29:03 -06:00
2f32d7afd5 Add simple bitmap operations to utils
V2:
  - Move bitmap impl to src/util/bitmap.[ch]
  - Use CHAR_BIT instead of explicit '8'
  - Use size_t instead of unsigned int
  - Fix calculation of bitmap size in virBitmapAlloc
  - Ensure bit is within range of map in the set, clear, and get
    operations
  - Use bool in virBitmapGetBit
  - Add virBitmapFree to free-like funcs in cfg.mk

V3:
  - Check for overflow in virBitmapAlloc
  - Fix copy and paste bug in virBitmapAlloc
  - Use size_t in prototypes
  - Add ATTRIBUTE_NONNULL in prototypes where appropriate
    and remove NULL check from impl

V4:
  - Add ATTRIBUTE_RETURN_CHECK in prototypes where appropriate.
2010-05-21 11:29:03 -06:00
377bc412ce daemon: Export SDL audio environment variables
/etc/sysconfig/libvirtd has a few environment variables for configuring
libvirt SDL audio. The libvirtd process doesn't see these, however, because
they are never exported. Let's export the variables after sourcing the
sysconfig script.

There is another problem here that the commented out values in the
sysconfig script are not neccessarily the actual defaults, we are qemus
mercy here. Not sure how to solve that.
2010-05-21 12:48:34 -04:00
8583b947b1 Remove isValidIfname.
We shouldn't be checking validity in domain_conf, since
it can be used by multiple different hosts and hypervisors.
Remove the check completely.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-21 09:32:15 -04:00
66823690e4 Init script for handling guests on shutdown/boot
Example output during shutdown:

Running guests on default URI: console, rhel6-1, rhel5-64
Running guests on lxc:/// URI: lxc-shell
Running guests on xen:/// URI: error: no hypervisor driver available for xen:///
error: failed to connect to the hypervisor
Running guests on vbox+tcp://orkuz/system URI: no running guests.
Suspending guests on default URI...
Suspending console: done
Suspending rhel6-1: done
Suspending rhel5-64: done
Suspending guests on lxc:/// URI...
Suspending lxc-shell: error: Failed to save domain 9cba8bfb-56f4-6589-2d12-8a58c886dd3b state
error: this function is not supported by the hypervisor: virDomainManagedSave

Note, the "Suspending $guest: " shows progress during the suspend phase
if domjobinfo gives meaningful output.

Example output during boot:

Resuming guests on default URI...
Resuming guest rhel6-1: done
Resuming guest rhel5-64: done
Resuming guest console: done
Resuming guests on lxc:/// URI...
Resuming guest lxc-shell: already active

Configuration used for generating the examples above:
URIS='default lxc:/// xen:/// vbox+tcp://orkuz/system'

The script uses /var/lib/libvirt/libvirt-guests files to note all active
guest it should try to resume on next boot. It's content looks like:

default 7f8b9d93-30e1-f0b9-47a7-cb408482654b 085b4c95-5da2-e8e1-712f-6ea6a4156af2 fb4d8360-5305-df3a-2da1-07d682891b8c
lxc:/// 9cba8bfb-56f4-6589-2d12-8a58c886dd3b
2010-05-21 09:33:30 +02:00
e0037c2ee8 Autostart domains using virDomainObjStart 2010-05-21 09:30:16 +02:00
5e3537f88a Refactor qemudDomainStart
We need a common internal function for starting managed domains to be
used during autostart. This patch factors out relevant code from
qemudDomainStart into qemudDomainObjStart and makes it use the
refactored code for domain restore instead of calling qemudDomainRestore
API directly.
2010-05-21 09:29:01 +02:00
575cf9a9ce Factor out def assignment to existing domain from virDomainAssignDef
We need to be able to assign new def to an existing virDomainObj which
is already locked. This patch factors out the relevant code from
virDomainAssignDef into virDomainObjAssignDef.
2010-05-21 09:25:42 +02:00
de5a60e1cc Refactor qemudDomainRestore
We need to be able to restore a domain which we already locked and
started a job for it without undoing these steps. This patch factors
out internals of qemudDomainRestore into separate functions which work
for locked objects.
2010-05-21 09:22:32 +02:00
b8ed797c7c maint: update po/POTFILES.in
* po/POTFILES.in: Add 3 files.
2010-05-20 21:36:26 +02:00
7a3267cfcf maint: enforce policy wrt VIR_DEBUG and VIR_DEBUG0
* cfg.mk (sc_prohibit_gettext_markup): Just like VIR_WARN*.
2010-05-20 21:36:26 +02:00
d6f9cf4222 maint: don't mark VIR_DEBUG or VIR_DEBUG0 diagnostics for translation
Run this command:
  git grep -l VIR_DEBUG|xargs perl -pi -e \
    's/(VIR_DEBUG0?)\s*\(_\((".*?")\)/$1($2/'
2010-05-20 21:36:26 +02:00
2f26addb25 maint: enforce policy wrt VIR_ERROR and VIR_ERROR0
* cfg.mk (msg_gen_function): Add VIR_ERROR and VIR_ERROR0,
so that sc_libvirt_unmarked_diagnostics will check them, too.
2010-05-20 21:36:26 +02:00
5adbd9cb4c maint: change "" in err ? err->message : "" to _("unknown error"), ...
These changes avoid false-positive syntax-check failure,
and also make the resulting diagnostics more comprehensible.
2010-05-20 21:36:26 +02:00
cc21fd9a91 maint: more of same, but manual: convert VIR_ERROR("%s" to VIR_ERROR0( 2010-05-20 21:36:25 +02:00
82a3c81d8c maint: VIR_ERROR/VIR_ERROR0: mark up the remaining ones manually
Handle concatenated strings manually.
2010-05-20 21:36:25 +02:00
2d3208029b maint: mark translatable string args of VIR_ERROR
Run this:
  git grep -l 'VIR_ERROR\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR)\s*\((".*?"),/$1(_($2),/'
2010-05-20 21:36:25 +02:00
8d63d82e5c maint: mark translatable string args of VIR_ERROR0
Run this:
  git grep -l 'VIR_ERROR0\s*("'|xargs perl -pi -e \
    's/(VIR_ERROR0)\s*\((".*?")\)/$1(_($2))/'
2010-05-20 21:36:25 +02:00
5910472fa5 maint: use VIR_ERROR0 rather than VIR_ERROR with a bare "%s"
Change VIR_ERROR("%s", "..."
to     VIR_ERROR0("..."

and

Change VIR_ERROR("%s", _("...")
to     VIR_ERROR0(_("...")

Use this command:
  git grep -E -l 'VIR_ERROR\("%s", (_\()?"'|xargs perl -pi -e \
  's/VIR_ERROR\("%s", (_\()?"/VIR_ERROR0($1"/'
2010-05-20 21:36:25 +02:00
c80651a5ae qemu driver: fix version check typos
* src/qemu/qemu_conf.c (qemudParseHelpStr): Fix errors that made
it impossible to diagnose invalid minor and micro version number
components.

Signed-off-by: Chris Wright <chrisw@redhat.com>
2010-05-20 21:35:36 +02:00
9d0adf2498 daemon: A few initscript corrections
Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=565238

- Avahi service is called 'avahi-daemon'
- chkconfig descriptions must use \ for line continuations
2010-05-20 15:11:22 -04:00
ac23d911df qemu: Use ShutdownVMDaemon for all startup cleanup paths
The current cleanup: in StartVMDaemon path is a poor duplication.
qemuShutdownVMDaemon can handle teardown for inactive VMs, so let's use it.

v2: Remove old abort: label, only use cleanup:
2010-05-20 15:11:22 -04:00
54971d9170 Domain snapshot RNG and tests.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-20 13:50:03 -04:00
8749256d0b Fix up the python bindings for snapshotting.
This involved a few fixes.  To start with,
an virDomainSnapshot object is really tied to a
domain, not a connection, so we have to generate
a slightly different object so that we can get
at self._dom for the object.

Next, we had to "dummy" up an override piece of
XML with a bogus argument that the function doesn't
actually take.  That's so that the generator places
virDomainRevertToSnapshot underneath the correct
class (namely, the virDomain class).

Finally, we had to hand-implement the
virDomainRevertToSnapshot implementation, ignoring the
bogus pointer we are being passed.

With all of this in place, I was able to successfully
take a snapshot and revert to it using only the
Python bindings.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-20 13:49:38 -04:00
20beb0c0db qemu_conf.c: also recognize new first line of qemu -help output
* src/qemu/qemu_conf.c (QEMU_VERSION_STR_1, QEMU_VERSION_STR_2):
Define these instead of...
(QEMU_VERSION_STR): ... this.  Remove definition.
(qemudParseHelpStr): Check first for the new, shorter prefix,
"QEMU emulator version", and then for the old one,
"QEMU PC emulator version" when trying to parse the version number.
Based on a patch by Chris Wright.
2010-05-20 19:13:26 +02:00
1f6fc519cd lxc_controller.c: don't ignore failed "accept"
* src/lxc/lxc_controller.c (ignorable_epoll_accept_errno): New function.
(lxcControllerMain): Handle a failed accept carefully:
most errno values indicate legitimate failure and must be fatal.
However, ignore a special case: that in which an incoming client quits
between the poll() indicating its presence, and our accept() which
is trying to process it.
2010-05-20 19:12:39 +02:00
348c6fc0ab qemu: Don't deny ShutdownVMDaemon for non-running VMs
Clients that require this already seem to do so. Calling this function
with pid < 1 also should not cause problems.
2010-05-20 11:45:20 -04:00
4da188ea3d qemu: Remove explicit VNC XML cleanup
This only exists for a certain cleanup path in StartVMDaemon, but is
unneeded since domain_conf.c handles this for us automatically.
2010-05-20 11:45:19 -04:00
b6992818c6 qemu: Properly cleanup in security startup error path
Everything after hostdev setup needs to jump to cleanup on error.
2010-05-20 11:45:19 -04:00
6752d11997 libvirtd: don't ignore virInitialize failure
* daemon/libvirtd.c (main): Diagnose virInitialize failure
and exit nonzero.
2010-05-20 16:19:38 +02:00
7e1249f259 Rename qemuBuildCommandLine tapfds -> vmfds.
There doesn't seem to be anything specific to tap devices for this
array of file descriptors which need to stay open of the guest to use.
Rename then for others to make use of.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-05-20 10:05:20 -04:00
97d5c95d8e maint: prohibit newline at end of diagnostic
* cfg.mk (sc_prohibit_newline_at_end_of_diagnostic): New rule.
Idea proposed by Jiri Denemark.
2010-05-20 15:44:44 +02:00
e1b419ea25 maint: remove unwanted newline at end of diagnostic
* src/xen/xend_internal.c (xenDaemonDomainDefineXML): Remove \n.
* src/network/bridge_driver.c (networkAddMasqueradingIptablesRules):
Likewise.
2010-05-20 15:44:40 +02:00
6aacf84a3b qemudDomainMigrateFinish2: handle a case of virDomainSaveStatus failure
* src/qemu/qemu_driver.c (qemudDomainMigrateFinish2): Don't ignore
virDomainSaveStatus failure.
* src/conf/domain_conf.h (virDomainSaveStatus): Use
ATTRIBUTE_RETURN_CHECK, so this doesn't happen again.
2010-05-20 07:51:21 +02:00
33c721d323 docs: distribute more coding convention documentation
These files may be useful for anyone making modifications to
source files in a tarball distribution.

* src/Makefile.am (EXTRA_DIST): Add THREADS.txt.
* daemon/Makefile.am (EXTRA_DIST): Add THREADING.txt.
2010-05-19 16:28:50 -06:00
92036c2edf build: distribute missing file
Commit f30ccb2458 was incomplete.

* .gitignore: Ignore intermediate directory during failed 'make
distcheck'.
* tests/Makefile.am (qemuhelpdata): Distribute new file.
2010-05-19 16:28:49 -06:00
894baa0af8 esx: Make esxVI_*_CastFromAnyType dynamically dispatched
This will be used in the ESX storage driver in order to handle
the DatastoreInfo type and inheriting types properly.
2010-05-20 00:00:34 +02:00
90fce23f24 esx: Allow esxVI_X_DynamicCast to be called successfully on X objects
This semantic will be used in the ESX storage driver.
2010-05-20 00:00:31 +02:00
10c681622a tests: the remote_protocol check also accommodates older pdwtags
This test was failing on systems using pdwtags from dwarves-1.3.
Reported by Matthias Bolte.
Two-pronged fix:
  - use --verbose to work also with dwarves-1.3; adapt regular
    expressions to handle now-varying separators
  - require a minimum number of post-split clauses, in order to
    skip upon any future format change.
    Currently there are 318; if there are 300 or fewer,
    give a warning similar to when pdwtags is missing.
* src/Makefile.am (remote_protocol-structs): Use pdwtags' --verbose
option to make 1.3 emit member sizes and offsets.
Consistently output WARNING messages to stderr.
2010-05-19 19:12:44 +02:00
dcf30d9c25 initialize "meta" in virStorageFileGetMetadata, not in each caller
Do not require each caller of virStorageFileGetMetadata and
virStorageFileGetMetadataFromFD to first clear the storage of the
"meta" buffer.  Instead, initialize that storage in
virStorageFileGetMetadataFromFD.
* src/util/storage_file.c (virStorageFileGetMetadataFromFD): Clear
"meta" here, not before each of the following callers.
* src/qemu/qemu_driver.c (qemuSetupDiskCgroup): Don't clear "meta" here.
(qemuTeardownDiskCgroup): Likewise.
* src/qemu/qemu_security_dac.c (qemuSecurityDACSetSecurityImageLabel):
Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityImageLabel):
Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
2010-05-19 17:07:08 +02:00
e638a2461d (qemu*DiskCgroup): avoid dead code
* src/qemu/qemu_driver.c (qemuTeardownDiskCgroup): Remove
bogus empty-body while-loop.
(qemuSetupDiskCgroup): Likewise.
2010-05-19 17:07:08 +02:00
acd981e37f maint: more VIR_WARN corrections: now manually
* po/POTFILES.in: Remove src/util/logging.c and src/util/uuid.c.
* src/phyp/phyp_driver.c (phypUUIDTable_ReadFile): Correct more
VIR_WARN uses, now manually.
(phypUUIDTable_Init, phypUUIDTable_Pull): Likewise.
2010-05-19 13:03:35 +02:00
3f76a993c2 maint: use VIR_WARN0("...") rather than VIR_WARN("%s", "...")
Run this command:
  git grep -l 'VIR_WARN("%s", "'|xargs perl -pi -e \
    's/VIR_WARN\("%s", "/VIR_WARN0("/'
* src/phyp/phyp_driver.c (phypDomainGetInfo): Perform the above.
(phypDomainCreateAndStart, phypUUIDTable_ReadFile): Likewise.
2010-05-19 12:59:15 +02:00
052893cf66 maint: enforce no-markup policy wrt VIR_WARN-like macros
* cfg.mk (sc_prohibit_gettext_markup): New rule, to enforce
this policy.  Contrary to most diagnostic-emitting functions,
where we require _(...) markup, here, we require that _() *not*
be used for certain functions (or function-like macros).
2010-05-19 12:52:47 +02:00
feb93e9830 maint: remove _(...) from VIR_WARN arg manually
* src/util/uuid.c (virUUIDGenerate): Remove _(...) manually.
2010-05-19 12:52:47 +02:00
c5a2fe243b maint: don't mark VIR_WARN or VIR_WARN0 diagnostics for translation
Approximately 60 messages were marked.  Since these diagnostics are
intended solely for developers and maintainers, encouraging translation
is deemed to be counterproductive:
http://thread.gmane.org/gmane.comp.emulators.libvirt/25050/focus=25052

Run this command:
  git grep -l VIR_WARN|xargs perl -pi -e \
    's/(VIR_WARN0?)\s*\(_\((".*?")\)/$1($2/'
2010-05-19 12:00:18 +02:00
d54bad5d0e note a typo: VIR_MIGRATE_TUNNELLED should be VIR_MIGRATE_TUNNELED,
so that searches for properly spelled "TUNNELED" turn up
the surprising spelling of this public symbol.
* include/libvirt/libvirt.h.in: Add a comment.
2010-05-19 08:08:52 +02:00
b02db3518e Add support for SSE4.1 and SSE4.2 CPU features 2010-05-18 20:53:31 +02:00
272d5a9653 Fix potential NULL dereference in remoteDomainMigratePrepare2 2010-05-18 20:53:31 +02:00
49ed0a2e1b do not ignore qemuMonitorAddDrive failure; make uses identical
There were three very similar uses of qemuMonitorAddDrive.
This change makes the three 17-line sequences identical.
* src/qemu/qemu_driver.c (qemudDomainAttachPciDiskDevice): Detect
failure.  Add VIR_WARN and braces.
(qemudDomainAttachSCSIDisk): Add VIR_WARN and braces.
(qemudDomainAttachUsbMassstorageDevice): Likewise.
2010-05-18 19:23:33 +02:00
d564fcb3e1 ebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end
* src/util/ebtables.c (ebtablesAddRemoveRule): Don't skip
va_end(args) on an error path.
* src/util/iptables.c (iptablesAddRemoveRule): Identical change.
2010-05-18 19:23:33 +02:00
11eeabd71b qemudDomainRestore: handle a case of virDomainSaveStatus failure
* src/qemu/qemu_driver.c (qemudDomainRestore): Don't ignore
virDomainSaveStatus failure.
2010-05-18 19:23:33 +02:00
a23675d36d python: don't ignore virInitialize failure in module initialization
* python/libvirt-override.c (initlibvirtmod): Upon virInitialize
failure, skip the Py_InitModule call.
2010-05-18 19:23:33 +02:00
6ab131bae2 tests: do not ignore virInitialize failure
* tests/nodeinfotest.c (mymain): Do not ignore virInitialize failure.
Most other callers of virInitialize test for failure.
2010-05-18 19:23:32 +02:00
cff218f353 qemuMonitorTextMigrate: avoid leak on OOM-error path
* src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrate): Also
free "safedest" buffer when failing.
2010-05-18 19:23:32 +02:00
bc5443f4c6 virNWFilterDefParseXML: avoid leak on error paths
* src/conf/nwfilter_conf.c (virNWFilterDefParseXML): Also free "ret"
via cleanup.
2010-05-18 19:23:32 +02:00
43beb82eca linuxNodeInfoCPUPopulate: avoid used-uninitialized via a test
* tests/nodeinfotest.c (linuxTestCompareFiles): Don't use
nodeinfo->member uninitialized.  linuxNodeInfoCPUPopulate requires
that some of its nodeinfo members (including threads) be initialized
upon input.  The nodeinfotest.c program lacked the initialization,
while the only other use (nodeGetInfo) did perform it.
It's not trivial to move the initialization into the function,
since nodeGetInfo sets at least one member after clearing the
buffer but before calling linuxNodeInfoCPUPopulate.
2010-05-18 19:23:32 +02:00
4d2adaa1d5 virDomainNetDefParseXML: avoid leak upon multiple "filterref"
* src/conf/domain_conf.c (virDomainNetDefParseXML): Don't leak
memory when parsing two or more "filterref" elements.
2010-05-18 19:23:27 +02:00
0058184c4e ebiptablesWriteToTempFile: don't close a negative file descriptor
* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesWriteToTempFile):
Skip the close if "fd" is negative.
2010-05-18 16:55:26 +02:00
31e29fe524 Protect against NULL pointer flaws in monitor usage
History has shown that there are frequent bugs in the QEMU driver
code leading to the monitor being invoked with a NULL pointer.
Although the QEMU driver code should always report an error in
this case before invoking the monitor, as a safety net put in a
generic check in the monitor code entry points.

* src/qemu/qemu_monitor.c: Safety net to check for NULL monitor
  object
2010-05-18 06:03:06 -04:00
c4b2a93907 Fix multiple potential NULL pointer references in monitor usage
Any method which intends to invoke a monitor command must have
a check for virDomainObjIsActive() before using the monitor to
ensure that priv->mon != NULL.

There is one subtle edge case in this though. If a method invokes
multiple monitor commands, and calls qemuDomainObjExitMonitor()
in between two of these commands then there is no guarentee that
priv->mon != NULL anymore. This is because the QEMU process may
exit or die at any time, and because qemuDomainObjEnterMonitor()
releases the lock on virDomainObj, it is possible for the background
thread to close the monitor handle and thus qemuDomainObjExitMonitor
will release the last reference allowing priv->mon to become NULL.

This affects several methods, most notably migration but also some
hotplug methods. This patch takes a variety of approaches to solve
the problem, depending on the particular usage scenario. Generally
though it suffices to add an extra virDomainObjIsActive() check
if qemuDomainObjExitMonitor() was called during the method.

* src/qemu/qemu_driver.c: Fix multiple potential NULL pointer flaws
  in usage of the monitor
2010-05-18 06:03:06 -04:00
a986892e61 maint: add more free-like functions to the list and deal with fallout
* cfg.mk (useless_free_options): Add many vir*Free* function names,
and then remove the useless if-before-free tests exposed by running
make syntax-check.
* src/conf/interface_conf.c (virInterfaceDefFree): Remove useless "if".
(virInterfaceAssignDef): Likewise.
* src/conf/network_conf.c (virNetworkAssignDef): Likewise.
* src/conf/storage_conf.c (virStoragePoolObjAssignDef): Likewise.
* src/node_device/node_device_hal.c (dev_create): Likewise.
* src/security/virt-aa-helper.c (vahDeinit): Likewise.
* src/test/test_driver.c (testNodeDeviceCreateXML): Likewise.
* src/util/conf.c (virConfSetValue): Likewise.
2010-05-18 07:53:42 +02:00
933522a341 maint: add virCgroupFree to the list of free-like functions
This makes the useless-if-before-free test in maint.mk spot
uses of virCgroupFree just like it does for free and the other
listed functions.
* cfg.mk (useless_free_options): Add virCgroupFree.
Prompted by suggestion from Eric Blake.
2010-05-18 07:53:42 +02:00
20701b17e2 qemudDomainSetVcpus: avoid NULL-deref on failed uuid look-up
* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Upon look-up failure,
i.e., vm==NULL, goto cleanup, rather than to "endjob", superficially
since the latter would dereference vm, but more fundamentally because
we certainly don't want to call qemuDomainObjEndJob before we've
even attempted qemuDomainObjBeginJob.
2010-05-18 07:53:42 +02:00
93fedcf20f lxcFreezeContainer: avoid test-after-deref of never-NULL pointer
* src/lxc/lxc_driver.c (lxcFreezeContainer): Remove test-after-deref.
Correct indentation in expression.
2010-05-18 07:53:42 +02:00
61fb697977 Add CIFS to the list of network file systems
ESX supports NFS and CIFS. The ESX storage driver will reflect this.
2010-05-18 01:34:34 +02:00
32d9e0707c Add VIR_STORAGE_POOL_INACCESSIBLE to denote inaccessible storage pools
This status will be used by the ESX storage driver.

For example a running NFS pool is inaccessible when the NFS server is
currently unreachable.
2010-05-18 01:34:34 +02:00
f30ccb2458 qemu_conf: fix flag value
(gdb) p/x QEMUD_CMD_FLAG_VNET_HOST
$7 = 0xffffffff80000000

Oops - that meant we were incorrectly setting QEMU_CMD_FLAG_RTC_TD_HACK
for qemu-kvm-0.12.3 (and probably botching a few other settings as well).

Fixes Red Hat BZ#592070

* src/qemu/qemu_conf.h (QEMUD_CMD_FLAG_VNET_HOST): Avoid sign
extension.
* tests/qemuhelpdata/qemu-kvm-0.12.3: New file.
* tests/qemuhelptest.c (mymain): Add another case.
2010-05-17 16:28:02 -06:00
07c621d09c qemu: Clarify a couple error messages
A fedora translator filed:

https://bugzilla.redhat.com/show_bug.cgi?id=580816

Pointing out these two error messages as unclear: "write save" sounds
like a typo without context, and lack of a colon made the second message
difficult to parse.
2010-05-17 17:22:08 -04:00
d533a98ed6 virFileResolveLink: fix return value
virFileResolveLink was returning a positive value on error,
thus confusing callers that assumed failure was < 0.  The
confusion is further evidenced by callers that would have
ended up calling virReportSystemError with a negative value
instead of a valid errno.

Fixes Red Hat BZ #591363.

* src/util/util.c (virFileResolveLink): Live up to documentation.
* src/qemu/qemu_security_dac.c
(qemuSecurityDACRestoreSecurityFileLabel): Adjust callers.
* src/security/security_selinux.c
(SELinuxRestoreSecurityFileLabel): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskDeleteVol): Likewise.
2010-05-17 14:48:27 -06:00
df5944ff02 tests: Skip daemon-conf test if dir exceeds UNIX_PATH_MAX
The max path length for unix sockets is pretty small (108, see man 7 unix).
If 'make check' is run from a directory that exceeds this, one of the tests
will fail, and in such a way that requires manually editting the test to
determine why.

There are certainly other ways to handle this, but I've chosen just to skip
the offending test if we will exceed the length limitation.

v2: Drop bashism, use test infrastructure to warn and skip
2010-05-17 15:01:59 -04:00
5679c844de pci: Give an explicit error if device not found
v2: Use intended F_OK. Drop devdir param, just check dev->path for device
existence.

v3: Use virReportSystemError, include dev->path in error message.
2010-05-17 15:01:59 -04:00
b0aaed65ea build: fix cygwin build, correctly this time
Fix the cygwin regression introduced in commit 48445ccff, but
without repeating the fresh build regression of commit
2d550542e.

* src/Makefile.am (libvirt_test_la_LIBADD): Split out subset of
locally-built libraries...
(libvirt_test_la_BUILT_LIBADD): ...into new variable.
(libvirt_test_la_DEPENDENCIES): Depend only on the subset that
automake would have given us for free if we didn't have to add our
own extra file.
2010-05-17 12:15:44 -06:00
8e8bda2614 umlAutostartDomain: avoid NULL-deref upon virGetLastError failure
* src/uml/uml_driver.c (umlAutostartDomain): Handle a NULL return
from virGetLastError.
2010-05-17 18:49:36 +02:00
6e5b5bbc0a build: fix up some compiler flags
Matthias noted that the line:
virt_aa_helper_LDFLAGS = $(WARN_CFLAGS)
looks inconsistent, so I did an audit.

Currently, the set of compiler warning flags passed to gcc as $CC are
equally permitted as the set of linker flags passed to gcc as $LD, so
there was no problem with that usage.  But if we ever get in a
situation where $CC and $LD treat particular flags differently, using
the right variable form will make it easier.

In the process, I spotted a couple of typos that were omitting useful
flags, as well as specifying a -l under the wrong variable.

* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Define WARN_LDFLAGS as
an alias for WARN_CFLAGS.
* tools/Makefile.am (virsh_LDFLAGS): Use more canonical spelling.
* proxy/Makefile.am (libvirt_proxy_LDFLAGS): Likewise. Move
library...
(libvirt_proxy_LDADD): ...here.
* src/Makefile.am (virt_aa_helper_LDFLAGS): Use more canonical
spelling of WARN_LDFLAGS.
(libvirt_parthelper_LDFLAGS, libvirt_lxc_LDFLAGS): Likewise.  Use
correct spelling of COVERAGE_LDFLAGS.
Reported by Matthias Bolte.
2010-05-17 09:12:42 -06:00
0641f0f72c build: avoid compile failure on linux kernels older than 2.6.19
* configure.ac: Check for <linux/magic.h>.
* src/util/storage_file.c: Include <linux/magic.h> only if present.
Linux kernels prior to 2.6.19 lacked it.
[__linux__] (NFS_SUPER_MAGIC): Define if not already defined.
2010-05-17 16:50:36 +02:00
258d59cff9 x86ModelHasFeature: avoid NULL-dereference for unmatched CPU "feature"
* src/cpu/cpu_x86.c (x86ModelHasFeature): Do not dereference the pointer
returned by x86cpuidFind without first ensuring it is non-NULL.
2010-05-17 16:50:36 +02:00
83be64034a qemu: Report cmdline output if VM dies early
qemuReadLogOutput early VM death detection is racy and won't always work.
Startup then errors when connecting to the VM monitor. This won't report
the emulator cmdline output which is typically the most useful diagnostic.

Check if the VM has died at the very end of the monitor connection step,
and if so, report the cmdline output.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=581381
2010-05-17 10:15:53 -04:00
d536f6b177 qemu: Fix previous commit, use comparision in if() 2010-05-17 09:39:11 -04:00
560758c900 qemu_driver: avoid NULL dereference
* src/qemu/qemu_driver.c (qemudDomainStart): After setting vm to NULL,
goto cleanup, rather than dereferencing the NULL pointer.
2010-05-17 13:47:45 +02:00
2d665c9e2d Remove debugging fprintf() calls
* src/qemu/qemu_driver.c: Remove debugging fprintf() calls
  accidentally left in code
2010-05-17 10:44:49 +01:00
b48fb801dd qemudDomainSetVcpus: avoid NULL-deref
* src/qemu/qemu_driver.c (qemudDomainSetVcpus): Avoid NULL-deref
upon unknown UUID.  Call qemuDomainObjBeginJob(vm) only after
ensuring that vm != NULL, not before.  This potential NULL-deref
was introduced by commit 2c555d87b0.
2010-05-15 09:02:54 +02:00
39b3845fd7 Revert "build: fix cygwin build"
This reverts commit 2d550542ee.

The patch worked for incremental builds, but broke fresh
builds, because it interfered with automake's automatic
dependency generation.  Until I figure out how to make
automake do what we want, I'd rather leave cygwin broken
but fresh Linux builds working.
2010-05-14 17:46:47 -06:00
2d550542ee build: fix cygwin build
make[3]: *** No rule to make target `-lxml2', needed by `libvirt.la'.  Stop.

Due to treating the wrong string as a dependency.

* src/Makefile.am (libvirt_la_DEPENDENCIES): Depend only on
locally-built file, not on strings that might resolve as '-lxml2'.
2010-05-14 16:03:57 -06:00
ba99a1b637 nwfilter: Add missing driver lock in qemu driver
This adds a missing driver lock in the qemu driver to protect
the list of domains.
2010-05-14 14:22:39 -04:00
d6644013d2 Fix a misuse of virAsprintf in qemudDomainMemoryPeek
The code specifies driver->cacheDir as the format string,
but it usually doesn't contain '%s', so the subsequent
argument, "/qemu.mem.XXXXXX", is always ignored.

The patch fixes the misuse.
2010-05-14 10:45:58 -06:00
de4d70873a Make domain save work when dynamic_ownership=0
Setting dynamic_ownership=0 in /etc/libvirt/qemu.conf prevents
libvirt's DAC security driver from setting uid/gid on disk
files when starting/stopping QEMU, allowing the admin to manage
this manually. As a side effect it also stopped setting of
uid/gid when saving guests to a file, which completely breaks
save when QEMU is running non-root. Thus saved state labelling
code must ignore the dynamic_ownership parameter

* src/qemu/qemu_security_dac.c: Ignore dynamic_ownership=0 when
  doing save/restore image labelling
2010-05-14 09:21:33 -04:00
02ddaddfa8 Don't reset user/group/security label on shared filesystems during migrate
When QEMU runs with its disk on NFS, and as a non-root user, the
disk is chownd to that non-root user. When migration completes
the last step is shutting down the QEMU on the source host. THis
normally resets user/group/security label. This is bad when the
VM was just migrated because the file is still in use on the dest
host. It is thus neccessary to skip the reset step for any files
found to be on a shared filesystem

* src/libvirt_private.syms: Export virStorageFileIsSharedFS
* src/util/storage_file.c, src/util/storage_file.h: Add a new
  method virStorageFileIsSharedFS() to determine if a file is
  on a shared filesystem (NFS, GFS, OCFS2, etc)
* src/qemu/qemu_driver.c: Tell security driver not to reset
  disk labels on migration completion
* src/qemu/qemu_security_dac.c, src/qemu/qemu_security_stacked.c,
  src/security/security_selinux.c, src/security/security_driver.h,
  src/security/security_apparmor.c: Add ability to skip disk
  restore step for files on shared filesystems.
2010-05-14 09:21:24 -04:00
117d04fb1d Fix handling of disk backing stores with cgroups
The cgroups ACL code was only allowing the primary disk image.
It is possible to chain images together, so we need to search
for backing stores and add them to the ACL too. Since the ACL
only handles block devices, we ignore the EINVAL we get from
plain files. In addition it was missing code to teardown the
cgroup when hot-unplugging a disk

* src/qemu/qemu_driver.c: Allow backing stores in cgroup ACLs
  and add missing teardown code in unplug path
2010-05-14 09:20:13 -04:00
abb7694211 Fix possible crash in handling IO Error event
If the IO error event does not include a reason, then there
is a possible crash dispatching the event

* src/conf/domain_event.c: Missing check for a NULL reason before
  strduping allows for a crash
2010-05-14 09:18:51 -04:00
ff45b4c26f Add support for NIC hotplug using netdev_add in QEMU
QEMU is gaining a new monitor command netdev_add for hotplugging
NICs using the netdev backend code. We already support this on
the command this, though it is disabled. This adds support for
hotplug too, also to remain disabled until 0.13 QEMU is released

* src/qemu/qemu_driver.c: Support netdev hotplug for NICs
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
  support for netdev_add and netdev_remove commands
2010-05-14 09:16:36 -04:00
152ccceb61 datatypes: fix comment typo
* src/datatypes.c: Use correct word.
2010-05-12 12:18:22 -06:00
d84bb6d6a3 Fix monitor ref counting when adding event handle
When closing a monitor using qemuMonitorClose(), we are aware of
the possibility the monitor is still being used somewhere:

    /* NB: ordinarily one might immediately set mon->watch to -1
     * and mon->fd to -1, but there may be a callback active
     * that is still relying on these fields being valid. So
     * we merely close them, but not clear their values and
     * use this explicit 'closed' flag to track this state */

but since we call virEventAddHandle() on that monitor without increasing
its ref counter, the monitor is still freed which makes possible users
of it quite unhappy. The unhappiness can lead to a hang if qemuMonitorIO
tries to lock mutex which no longer exists.
2010-05-12 16:07:42 +02:00
6ef9d9da5e Remove watches before calling REMOTE_PROC_CLOSE
First calling REMOTE_PROC_CLOSE and then removing watches might lead to
a hang as HANGUP event can be triggered before the watches are actually
removed but after virConnectPtr is already freed. As a result of that
remoteDomainEventFired() would try to lock uninitialized mutex, which
would hang for ever.
2010-05-12 16:07:08 +02:00
c2c4abb43b tests: use GPLv2+, not GPLv3
* tests/cpuset: Change from GPLv3 to GPLv2+
* tests/read-bufsiz: Likewise.
* tests/read-non-seekable: Likewise.
* tests/start: Likewise.
* tests/undefine: Likewise.
* tests/vcpupin: Likewise.
* tests/virsh-all: Likewise.
* tests/virsh-schedinfo: Likewise.
* tests/virsh-synopsis: Likewise.
2010-05-12 08:41:10 +02:00
ff1d6f859c libvirt_proxy: link with -lpthread if needed
Continuation of earlier patches to fix LIB_PTHREAD, only
triggered by ./configure --with-xen-proxy (a la autobuild.sh).

* proxy/Makefile.am (libvirt_proxy_LDADD): Add LIB_PTHREAD.
2010-05-11 16:13:16 -06:00
74c7a3463d node_device: udev: Fix PCI product/vendor swappage
Product and vendor values were swapped in the XML, which made virt-manager
PCI device listing kinda useless.
2010-05-11 16:55:56 -04:00
e8a1a730fe build: update gnulib
* .gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Import netdb.
* src/esx/esx_util.c (AI_ADDRCONFIG): Rely on gnulib.
* src/remote/remote_driver.c (AI_ADDRCONFIG): Likewise.
* tools/virsh.c (WEXITSTATUS, O_SYNC): Likewise.
2010-05-11 10:03:48 -06:00
03ae900f02 build: allow older gettext
* bootstrap.conf (gnulib_modules): Use gettext-h, not gettext,
since the latter drags in a depedency on gettext 0.18.
Suggested by Bruno Haible.
2010-05-11 10:03:48 -06:00
e915962a04 tests: correct PATH in new test, for when running manually
* tests/virsh-schedinfo: This test sets PATH internally, just in
case you're running it manually.  Normally, the PATH setting from
tests/Makefile.am's TESTS_ENVIRONMENT is sufficient.  Prepend the
correct directory, and take advantage of the PATH setting in one
more case.
2010-05-11 18:01:11 +02:00
36a03bd2ee Add env variable for debugging gnutls usage
Allow debugging of GNUTLS interactions by setting

  LIBVIRT_GNUTLS_DEBUG=10 LIBVIRT_DEBUG=1 virsh

* src/remote/remote_driver.c: Use LIBVIRT_GNUTLS_DEBUG to
  enable gnutls debugging
2010-05-11 15:54:38 +01:00
c5be8bcb8f tests: adjust copyrights on scripts: s/FSF/Red Hat/
* tests/cpuset: Change copyright holder from FSF to Red Hat, Inc.
* tests/read-bufsiz: Likewise.
* tests/read-non-seekable: Likewise.
* tests/start: Likewise.
* tests/undefine: Likewise.
* tests/vcpupin: Likewise.
* tests/virsh-all: Likewise.
* tests/virsh-synopsis: Likewise.
2010-05-11 16:43:07 +02:00
9a641564fb virsh: schedinfo --set invalid=value would simply ignore the option
For example, virsh -c test:///default schedinfo 1 --set P=k would
mistakenly exit successfully, giving no indication that it had failed
to set the scheduling parameter "P".
* tools/virsh.c (cmdSchedinfo): Diagnose an invalid --set j=k option,
rather than silently ignoring it.
* tests/virsh-schedinfo: New test for the above.
* tests/Makefile.am (test_scripts): Add it.
Reported by Jintao Yang in http://bugzilla.redhat.com/586632
2010-05-11 16:37:15 +02:00
5603515127 virsh: fix a typo in a diagnostic
* tools/virsh.c (cmdSchedInfoUpdate): Fix typo in a diagnostic:
s/an long long/a long long/.  One in a comment, too.
2010-05-11 16:06:53 +02:00
78a6af1ff9 delMacvtap: typo fix
* src/util/macvtap.c (delMacvtap): Fix documentation.
2010-05-10 17:12:22 -06:00
3876e010eb maint: allow VPATH use of remote_protocol-structs
* src/Makefile.am (remote_protocol-structs): Ensure file lives in srcdir.
2010-05-10 15:17:31 -06:00
1c5891204d docs/Makefile.am: remove unnecessary subshells
* docs/Makefile.am (ChangeLog.html.in, %.html.tmp, %.html)
(html/index.html, $(devhelphtml)): Avoid spurious subshells.
2010-05-10 14:59:25 -06:00
7cdf26637e maint: avoid spurious output if program not present
Some shells warn about missing programs before redirection;
the idiomatic way to silence them is to run the program check
inside a subshell, with the redirections outside the subshell.
But a subshell is only needed in places where it is reasonable
to expect the use of such a noisy shell in the first place.

* src/Makefile.am (remote_protocol-structs): Use subshell, for
FreeBSD 8.0 /bin/sh.
* cfg.mk (sc_preprocessor_indentation): Avoid subshell, since the
only users running cfg.mk can be assumed to have decent tools.
2010-05-10 14:56:37 -06:00
23958aedf4 storage_encryption: silence clang warning
For printf("%*s",foo,bar), clang complains if foo is not int:

warning: field width should have type 'int', but argument has
type 'unsigned int' [-Wformat]

* src/conf/storage_encryption_conf.c
(virStorageEncryptionSecretFormat, virStorageEncryptionFormat):
Use correct type.
* src/conf/storage_encryption_conf.h (virStorageEncryptionFormat):
Likewise.
2010-05-10 13:53:12 -06:00
180d4b2b3b help avoid accidental remote_protocol.x changes
Now, if you update remote_protocol.x without also updating
remote_protocol-structs to match, then "make check" will fail.
* src/Makefile.am (remote_protocol-structs): Extract list of
structs and member names from remote_protocol.o.
(check-local): Depend on it.
* src/remote_protocol-structs: New file.
2010-05-08 10:56:52 +02:00
d0616e354d mingw32-libvirt.spec: bring up to date
Right now, mingw32-portablexdr is not available in Fedora, but is
present in fedora-mingw.git.  With that package, plus
redhat-rpm-config and this patch, it is once again possible to build
mingw32-libvirt from a Fedora 12 host.

* mingw32-libvirt.spec.in (__debug_install_post): Override.
(%files): Mention recent additions.
2010-05-07 13:11:25 -06:00
cc04c4ca95 Manually revert "Fix pthread related link error for virt-aa-helper"
This reverts commit b5b8a6db69.

That commit was not necessary. The problem is fixed by commit
0e9b3a269b, but I didn't rebuild
it properly after pulling in the commit and didn't notice it.
2010-05-07 20:07:37 +02:00
563d7ee3a9 Fix a typo in docs 2010-05-07 19:52:35 +02:00
48445ccff9 build: use LIBADD, not LDFLAGS, for adding libraries
Per automake, LDFLAGS is used early in the line, and LIBADD
(libraries) or LDADD (programs) is used late.  On platforms like
cygwin, without lazy linking, this order matters.  Therefore, libtool
commands, -L, and similar should be in LDFLAGS, but -l should be in
L*ADD.

* src/Makefile.am (*_LDFLAGS): Move libraries...
(*_LIBADD): ...to their LIBADD counterpart.
2010-05-07 11:12:09 -06:00
e6125e4938 maint: whitespace cleanups
* src/Makefile.am: Fix some space-tab issues.
2010-05-07 11:11:02 -06:00
b5b8a6db69 Fix pthread related link error for virt-aa-helper
Link virt-aa-helper explicitly with pthread. This is at least
required on Ubuntu 10.04.
2010-05-07 17:52:37 +02:00
ea8d236b73 qemu: Fix warning about a non-literal format string 2010-05-07 17:47:16 +02:00
0e9b3a269b avoid link error in tests using libvirt_util; due to pthread_sigmask
* src/Makefile.am (libvirt_util_la_LDFLAGS): Add $(LIB_PTHREAD),
required, now that we're using gnulib's pthread module.
2010-05-07 16:55:42 +02:00
34a7f3f6be Remove unused nwfilter field from struct remote_error
Change 965466c1 added a new field to struct remote_error, which broke
the RPC protocol. Fortunately the new field is unused, so this change
simply removes it again.

* src/remote/remote_protocol.(c|h|x): Remove remote_nwfilter from struct
  remote_error
2010-05-07 16:38:05 +02:00
6bc4ea5af0 Implement SCSI disk unplugging
With the introduction of the generic qemu device model, unplugging
SCSI disks works like a charm, so support it in libvirt.

* src/qemu/qemu_driver.c: Add qemudDomainDetachSCSIDiskDevice() to do the
  unplugging, extend qemudDomainDetachDeviceAdd().

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-05-06 15:55:29 -06:00
697426e440 qemu: use better types
* src/qemu/qemu_driver.c (qemudFindDisk): Mark parameter const.
(qemudShrinkDisks): Mark parameter unsigned.
2010-05-06 15:32:56 -06:00
dc1a2fcce6 Refactor disk unplugging
We can reuse some of the code for other purposes.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
2010-05-06 15:19:39 -06:00
2de2d525fc build: simplify checks for sched.h
* configure.ac: Remove redundant checks.
2010-05-06 14:35:38 -06:00
062a25f078 build: update gnulib
81 patches to gnulib, picks up several new syntax checks.

* .gnulib: Update to latest.
* .x-sc_prohibit_always_true_header_tests: New file.
* bootstrap.conf (gnulib_modules): Add sched.
* src/util/processinfo.c (includes): <sched.h> is now guaranteed.
* src/network/bridge_driver.c (includes): Drop useless
<strings.h>.
* src/openvz/openvz_conf.c (includes): Likewise.
* src/openvz/openvz_driver.c (includes): Likewise.
* src/phyp/phyp_driver.c (includes): Likewise.
* src/qemu/qemu_driver.c (includes): Likewise.
* src/uml/uml_driver.c (includes): Likewise.
2010-05-06 14:35:38 -06:00
70e05fa6d0 build: drop more redundant configure checks
* configure.ac (AC_CHECK_FUNCS_ONCE, AC_SYS_LARGEFILE): Rely on
gnulib for strtok_r and large file support.
(AC_OBJEXT): Drop call now done by AC_PROG_CC.
(m4_foreach_w): Drop macro guaranteed by gnulib.
(AC_C_CONST): Drop call declared obsolete by autoconf.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-05-06 14:35:38 -06:00
8acaeb730b build: use gnulib's sys/wait.h
* configure.ac: Drop sys/wait.h check.
* src/libvirt.c (includes): Use header unconditionally.
* src/remote/remote_driver.c (includes): Likewise.
* src/storage/storage_backend.c (includes): Likewise.
* src/util/ebtables.c (includes): Likewise.
* src/util/hooks.c (includes): Likewise.
* src/util/iptables.c (includes): Likewise.
* src/util/util.c (includes): Likewise.
2010-05-06 14:35:38 -06:00
5349cf1ed2 build: use gnulib's uname
* bootstrap.conf (gnulib_modules): Add uname.
* configure.ac: Drop uname and sys/utsname.h checks.
* src/nodeinfo.c (nodeGetInfo): Use uname unconditionally.
2010-05-06 14:35:37 -06:00
9017b9bcaf build: rely on gnulib's pthread module
Gnulib can guarantee that pthread.h exists, but for now, it is a dummy
header with no support for most pthread_* functions.  Modify our
use of pthread to use function checks, rather than header checks,
to determine how much pthread support is present.

* bootstrap.conf (gnulib_modules): Add pthread.
* configure.ac: Drop all pthread.h checks.  Optimize function
checks.  Add check for pthread functions.
* src/Makefile.am (libvirt_lxc_LDADD): Ensure proper link.
* src/remote/remote_driver.c (remoteIOEventLoop): Depend on
pthread_sigmask, now that gnulib guarantees pthread.h.
* src/util/util.c (virFork): Likewise.
* src/util/threads.c (threads-pthread.c): Depend on
pthread_mutexattr_init, as a witness of full pthread support.
* src/util/threads.h (threads-pthread.h): Likewise.
2010-05-06 14:35:37 -06:00
2256d8b86e build: silence a clang false positive
* src/qemu/qemu_monitor.c (qemuMonitorIOWriteWithFD): Work around
recent clang shortcoming in analysis.
2010-05-05 14:46:41 -06:00
beccb0deca rpmbuild: add ebtables & ip(6)tables dependency for rpm
Add ebtables,iptables & iptables-ipv6 dependency to rpm.

Changes from V1 to V2:
  -passing --without-libpcap to configure script, if libpcap is not to be used
2010-05-05 12:20:28 -04:00
62ee19c763 util: fix va_start usage bug
Detected by clang.  POSIX requires that the second argument to
va_start be the name of the last variable; and in some implementations,
passing *path instead of path would dereference bogus memory instead
of pulling arguments off the stack.

* src/util/util.c (virBuildPathInternal): Use correct argument to
va_start.
2010-05-04 16:07:18 -06:00
b0a3f8b6c5 qemu: live migration with non-shared storage for kvm
Support for live migration between hosts that do not share storage was
added to qemu-kvm release 0.12.1.
It supports two flags:
-b migration without shared storage with full disk copy
-i migration without shared storage with incremental copy (same base image
shared between source and destination).

I tested the live migration without shared storage (both flags) for native
and p2p with and without tunnelling.  I also verified that the fix doesn't
affect normal migration with shared storage.
2010-05-04 16:03:36 -06:00
9537c3d0c2 configure.ac: Avoid uname, which breaks cross-compilation
When cross-compiling on Linux, configure will misdetect the target as
Linux because it uses uname instead of relying on the $host variable.
This results in including libvirt_linux.syms into libvirt.syms and
therefore trying to export undefined symbols.

Replace uname checks with $host checks to fix this.
2010-05-04 10:39:12 -06:00
362bc09a4d Don't wipe generated iface target in active domains
Wipe generated interface target only when reading configuration of
inactive domains.
2010-05-04 17:01:51 +02:00
7efa3937f0 Various fixes for the spec file
This includes various things:
 - fix the Requires: libvirt-client to use %{name} to allow easy
   renaming
 - when building ESX support one need libcurl-devel
 - remove Makefile[.in] from xml/nwfilter in the docs, as this breaks
   parallel install ation of i686 and x86_64 packages
 - don't include nwfilter config files if not building with the daemon
all relatively trivial which is why I packed them together
* libvirt.spec.in: fix various small bugs
2010-05-04 16:13:55 +02:00
44258473b8 docs: hacking: explain why using curly braces well is important
* docs/hacking.html.in: Use the "curly braces" section from coreutils'
HACKING, adapting for libvirt's different formatting style.
* HACKING: Sync from the above, still mostly manually.
2010-05-04 15:41:21 +02:00
eca81e08be lxc: Check domain is active/inactive as required by operation
Report VIR_ERR_OPERATION_INVALID when operation which requires running
domain is called on inactive domain and vice versa.
2010-05-04 13:36:56 +02:00
b94b72b457 lxc: Make SetMemory work for active domains only 2010-05-04 13:34:54 +02:00
e1fa3fb0fc lxc: Use virDomainFindByUUID for domain lookup
Consistently use virDomainFindByUUID instead of virDomainFindByID and
virDomainFindByName and report VIR_ERR_NO_DOMAIN when domain cannot be
found.
2010-05-04 13:33:30 +02:00
ee234bfd5b mingw: Fix two undefined symbols
Add an empty body for virCondWaitUntil and move virPipeReadUntilEOF
out of the '#ifndef WIN32' block, because it compiles fine with MinGW
in combination with gnulib.
2010-05-04 01:44:35 +02:00
7f31e28c6e build: avoid compiler warning
Necessary on cygwin, where uid_t and gid_t are 4-byte long rather
than int, causing gcc -Wformat warnings.

* src/util/util.c (virFileOperationNoFork, virDirCreateNoFork)
(virFileOperation, virDirCreate, virGetUserEnt): Cast uid_t and
gid_t before passing to printf.
* .gitignore: Ignore Windows executables.
2010-05-03 17:07:39 -06:00
018fd697b6 nwfilter: skip some interfaces on filter update
When a filter is updated, only those interfaces must have their old
rules cleared that either reference the filter directly or indirectly
through another filter. Remember between the different steps of the
instantiation of the filters which interfaces must be skipped. I am
using a hash map to remember the names of the interfaces and store a
bogus pointer to ~0 into it that need not be freed.
2010-05-03 18:14:58 -04:00
5c77fddf4e pass info where request stems from to have rules applied
For the decision on whether to instantiate the rules, the check for a
pending IP address learn request is not sufficient since then only the
thread could instantiate the rules. So, a boolean needs to be passed
when the thread instantiates the filter rules late and the IP address
learn request is still pending in order to override the check for the
pending learn request. If the rules are to be updated while the thread
is active, this will not be done immediately but the thread will do that
later on.
2010-05-03 18:11:48 -04:00
9f87b631ce build: prefer WIN32 over __MINGW32__ checks
WIN32 is always defined when __MINGW32__ is defined, but the
converse is not true.  WIN32 is more generic, if someone were
to ever attempt porting to a microsoft compiler.  This does
not affect Cygwin, which intentionally does not define WIN32.

* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Use more
generic flag macro.
* src/storage/storage_backend.c
(virStorageBackendUpdateVolTargetInfoFD)
(virStorageBackendRunProgRegex): Likewise.
* tools/console.h (vshRunConsole): Likewise.
2010-05-03 16:03:24 -06:00
c4157e5272 cgroup: Fix possible memory leak in virCgroupMakeGroup
* src/util/cgroup.c: free temporal path string before breaking loop
2010-05-03 15:01:12 -06:00
b9c4db0d70 dnsmasqReload: avoid mingw link failure
* src/util/dnsmasq.c (dnsmasqReload): Mingw lacks kill, but is not
running a dnsmasq daemon either.
2010-05-03 14:21:07 -06:00
38eb50ae76 mingw: Fix symbol export
In commit 98fb83ce25 I changed the
version script handling. But it seems that I didn't test this properly
and broke it. The .def file is passed to the compiler directly, but it
should get passed to the linker instead.

Set VERSION_SCRIPT_FLAGS to -Wl, to pass the .def file correctly to
the linker.

This fixes the undefined symbol errors while linking virsh.
2010-05-03 22:05:04 +02:00
254ade373d dnsmasq.c: Fix OOM error reporting
Also do some indentation clean up.
2010-05-03 21:59:16 +02:00
2b50cae54e Fix memory leaks in cmdInterfaceEdit and cmdNWFilterEdit.
This applies a fix to thos functions similar to that made to cmdEdit
in 270895063d, thus fnixing a memory
leak - if tmp is unlinked and NULLed early in the function, the memory
used by tmp is never freed. Since we will always unlink tmp prior to
freeing its memory at the end of the function, just remove the earlier
code and let cleanup: do the cleanup.
2010-05-03 11:16:08 -04:00
d2ac3c2fdd lxc: Fix failure on starting a domain with multiple interfaces
[Error message]
error: Failed to start domain lxc_test1
error: internal error Failed to create veth device pair: 512

The reason of the failure is that lxc driver unexpectedly re-uses
an auto-assigned veth name and tries to create the created veth
again. The failure will happen when a domain has multiple network
interfaces and the names of those are not specified in XML.

The patch fixes the problem by resetting buffers of veth names
in every iteration of creating veth.

* src/lxc/lxc_driver.c: prevent re-using auto-assigned veth name
  Reported by Kumar L Srikanth-B22348.
2010-05-03 11:13:26 +02:00
94f7144183 autobuild.sh: provide default prefix
Without this patch and with a clean environment, ./autobuild.sh
tried to use ./configure --prefix=/, and fails.

* autobuild.sh (AUTOBUILD_INSTALL_ROOT): Provide sensible
default.  Suggested by Daniel P. Berrange.
2010-04-30 11:13:06 -06:00
5d65d32f2c Release of libvirt-0.8.1
* configure.ac docs/news.html.in libvirt.spec.in: updates for release
* po/*.po*: updated localizations and regenerated
2010-04-30 18:55:08 +02:00
e984019688 domain: Fix PCI address decimal parsing regression
<hostdev> address parsing previously attempted to detect the number
base: currently it is hardcoded to base 16, which can break PCI
assignment via virt-manager. Revert to the previous behavior.

* src/conf/domain_conf.c: virDomainDevicePCIAddressParseXML, switch to
  virStrToLong_ui(bus, NULL, 0, ...) to autodetect base
2010-04-30 18:14:35 +02:00
34dcbbb470 Add support for another explicit IO error event
This introduces a new event type

   VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON

This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.

Thus there is a new callback definition for this event type

typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
                                                           virDomainPtr dom,
                                                           const char *srcPath,
                                                           const char *devAlias,
                                                           int action,
                                                           const char *reason,
                                                           void *opaque);

This is currently wired up to the QEMU block IO error events

* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
  IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
  and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
  from QEMU monitor
2010-04-30 15:52:59 +01:00
c90a1ad7d0 Report all errors in SELinuxRestoreSecurityFileLabel 2010-04-30 14:27:42 +02:00
5054e89272 Prevent updates while IP address learn thread is running
Prevent updating and tearing down of filter while the IP
address learning thread is running and has its own filtering
rules applied.
2010-04-30 08:12:26 -04:00
ebacb31fb5 Syncronize the teardown of rules with the thread
Introduce a function to notify the IP address learning
thread to terminate and thus release the lock on the interface.
Notify the thread before grabbing the lock on the interface
and tearing down the rules. This prevents a 'virsh destroy' to
tear down the rules that the IP address learning thread has
applied.
2010-04-30 08:10:12 -04:00
59fe163f2f Clean all tables before applying 'basic' rules
The functions invoked by the IP address learning thread
that apply some basic filtering rules did not clean up
any previous filtering rules that may still be there
(due to a libvirt restart for example). With the
patch below all the rules are cleaned up first.

Also, I am introducing a function to drop all traffic
in case the IP address learning thread could not apply
the rules.
2010-04-30 08:06:18 -04:00
b9efc7dc3b MAke virFileHasSuffix case insensitive
* src/util/util.c: as it's used for checking things like .iso suffixes
2010-04-30 14:03:41 +02:00
7c66c033a9 nwfilter: Also pick IP address from a DHCP ACK message
The local DHCP server on virtbr0 sends DHCP ACK messages when a VM is
started and requests an IP address while the initial DHCP lease on the
VM's MAC address hasn't expired. So, also pick the IP address of the VM
if that type of message is seen.
Thanks to Gerhard Stenzel for providing a test case for this.

Changes from V1 to V2:
- cleanup: replacing DHCP option numbers through constants
2010-04-30 07:51:47 -04:00
c179a0f63c Fix virt-pki-validate's determination of CN
Ubuntu's gntls package generates an Issuer line that looks like this:
        Issuer: C=US,ST=NY,L=Rochester,O=example.com,CN=example.com CA,EMAIL=hostmaster@example.com

While Red Hat's looks like this
Issuer: CN=Red Hat Emerging Technologies

Note the leading whitespace, and the additional fields in the former.

This patch updates the regular expression to:
 * trim leading characters before "Issuer:"
 * trim anything between Issuer: and CN=
 * trim anything after the next ,

I've tested this against the certool output of both RH and Ubuntu
generated certs.

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-04-29 20:10:46 -06:00
5b0aed68b0 qemudDomainSaveFlag: remove dead store
* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Remove dead store to "rc".
2010-04-29 22:13:24 +02:00
0eecdd685a Fix detection of disk in IO events
When using -device syntax, the IO event will have a different
prefix, 'drive-' that needs to be skipped over before matching
against the libvirt disk alias

* src/qemu/qemu_driver.c: Skip QEMU_DRIVE_HOST_PREFIX in IO event
2010-04-29 17:43:41 +01:00
05776e09fc Implement python binding for virDomainGetBlockInfo
This binds the virDomainGetBlockInfo API to python's blockInfo
method on the domain object

>>> c = libvirt.openReadOnly('qemu:///session')
>>> d = c.lookupByName('demo')
>>> f = d.blockInfo("/dev/loop0", 0)
>>> print f
[1048576000L, 104857600L, 104857600L]

* python/libvirt-override-api.xml: Define override signature
* python/generator.py: Skip C impl generator for virDomainGetBlockInfo
* python/libvirt-override.c: Manual impl of virDomainGetBlockInfo
2010-04-29 17:21:32 +01:00
7703c2c90a Add new domblkinfo command to virsh
virsh # domblkinfo demoguest /dev/hda2
  Capacity:       1048576000
  Allocation:     104857600
  Physical:       104857600

* tools/virsh.c: Implement domblkinfo command mapping to the
  new virDomainGetBlockInfo API
2010-04-29 17:21:32 +01:00
db57a7bed8 Implement virDomainGetBlockInfo in QEMU driver
* src/qemu/qemu_driver.c: Implementation of virDomainGetBlockInfo
* src/util/storage_file.h: Add DEV_BSIZE
* src/storage/storage_backend.c: Remove DEV_BSIZE
2010-04-29 17:21:26 +01:00
84a3269a15 Remote protocol impl for virDomainGetBlockInfo
* daemon/remote.c: Server side dispatcher
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h: Update
  with new API
* src/remote/remote_driver.c: Client side dispatcher
* src/remote/remote_protocol.c, src/remote/remote_protocol.h: Update
* src/remote/remote_protocol.x: Define new wire protocol
2010-04-29 17:20:24 +01:00
46bad5121f Internal driver API infrastructure for virDomainGetBlockInfo
This defines the internal driver API and stubs out each driver

* src/driver.h: Define virDrvDomainGetBlockInfo signature
* src/libvirt.c, src/libvirt_public.syms: Glue public API to drivers
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub out driver
2010-04-29 17:20:24 +01:00
24aad9f7be Add virDomainGetBlockInfo API to query disk sizing
Some applications need to be able to query a guest's disk info,
even for paths not managed by the storage pool APIs. This adds
a very simple API to get this information, modelled on the
virStorageVolGetInfo API, but with an extra field 'physical'.
Normally 'physical' and 'allocation' will be identical, but
in the case of a qcow2-like file stored inside a block device
'physical' will give the block device size, while 'allocation'
will give the qcow2 image size

* include/libvirt/libvirt.h.in: Define virDomainGetBlockInfo
2010-04-29 17:20:24 +01:00
270895063d Fix a virsh edit memory leak
When running virsh edit, we are unlinking and setting
the tmp variable to NULL before going to the end of the
function, meaning that we never free tmp.  Since the
exit to the function will always unlink and free tmp,
just remove this bit of code and let it get done at the
end.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-29 09:16:33 -04:00
87d2e4ba56 Fix a qemuDomainPCIAddressSetFree memory leak
qemuDomainPCIAddressSetFree was freeing up the hash
table for the pci addresses, but not freeing up the addr
structure.  Looking over the callers of this function, it
seems like they expect it to also free up the structure,
so do that here.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-29 09:16:14 -04:00
18b3096c40 Fix a memory leak in the node_device_udev code
We were over-writing a pointer without freeing it in
case of a disk device, leading to a memory leak.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-29 09:15:54 -04:00
50250aba36 Fix build on Ubuntu.
When building on Ubuntu with make -j3 (or more), it would always
fail when trying to build virt-aa-helper.  I'm not an expert in
automake by any means, but I think the entry for virt-aa-helper
is mis-using LDADD; it shouldn't be putting direct paths to
libvirt_conf.la and libvirt_util.la, but instead referencing those
names.  With this patch in place, I'm able to successfully build
on Ubuntu 9.04 with make -j3.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-29 09:15:30 -04:00
34b3c64a98 Report better error if qemuSnapshotIsAllowed failed.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-29 09:15:07 -04:00
bdb844e996 Remove unused goto label from qemudDomainCreate
The previous commit changes a goto from 'endjob' to 'cleanup',
leaving the endjob label unused. Remove it to avoid compile
warning.

* src/qemu/qemu_driver.c: Remove 'endjob' label
2010-04-29 12:13:02 +01:00
f7366d84f4 nwfilter: python bindings for nwfilter
I have primarily followed the pattern of the 'secret' driver to provide
support for the missing python bindings for the network filter API.
2010-04-29 06:46:01 -04:00
ba1072f0ac qemuDomainSnapshotCreateXML: avoid NULL dereferences
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): When setting
"vm" to NULL, jump over vm-dereferencing code to "cleanup".
(qemuDomainRevertToSnapshot): Likewise.
2010-04-29 11:16:04 +02:00
5eec84aaa3 qemudDomainCreate: correct a slightly misdirected goto
* src/qemu/qemu_driver.c (qemudDomainCreate): Goto cleanup,
not "endjob", since we know "vm" is already NULL.  No semantic change.
2010-04-29 11:16:03 +02:00
98fb83ce25 cygwin/mingw: Fix version script handling
Let configure detect ld instead of hardcoding /usr/bin/ld, because
MinGW may have ld in /bin.

Only use a .def file to export symbols on MinGW. Cygwin's ld supports
the normal .syms file used on Linux.
2010-04-28 23:49:00 +02:00
5fe816eccd build: fix autogen rule for VPATH build
* cfg.mk (gnulib_srcdir): Override maint.mk default.
(_update_required): Run in correct directory.
2010-04-28 08:15:12 -06:00
4e041189f8 Move dnsmasq host file to a separate directory
use /var/lib/libvirt/dnsmasq since /var/lib/libvirt/network is
unreadable by the dnsmasq binary

* src/network/bridge_driver.c: update DNSMASQ_STATE_DIR
* src/Makefile.am: create it on make install
* libvirt.spec.in: take the new directory into account
2010-04-28 15:53:09 +02:00
42f8b25b66 nwfilter: allow to mix filterrefs and rules in the schema
So far the references to other filters needed to appear before filtering
rules. With the below patch they can now appear in any order.

Also I forgot to add a couple of 'rarp's.
2010-04-28 09:12:39 -04:00
51cd0196e5 Fix handling of security driver restore failures in QEMU domain save
In cases where the security driver failed to restore a label after a
guest has saved, we mistakenly jumped to the error cleanup paths.
This is not good, because the operation has in fact completed and
cannot be rolled back completely. Label restore is non-critical, so
just log the problem instead. Also add a missing restore call in
the error cleanup path

* src/qemu/qemu_driver.c: Fix handling of security driver
  restore failures in QEMU domain save
2010-04-28 13:51:55 +01:00
712048bd9a Fix QEMU domain save to block devices with cgroups enabled
When cgroups is enabled, access to block devices is likely to be
restricted to a whitelist. Prior to saving a guest to a block device,
it is necessary to add the block device to the whitelist. This is
not required upon restore, since QEMU reads from stdin

* src/qemu/qemu_driver.c: Add block device to cgroups whitelist
  if neccessary during domain save.
2010-04-28 13:51:55 +01:00
93e0b3c8d6 Fix QEMU save/restore with block devices
The save process was relying on use of the shell >> append
operator to ensure the save data was placed after the libvirt
header + XML. This doesn't work for block devices though.
Replace this code with use of 'dd' and its 'seek' parameter.
This means that we need to pad the header + XML out to a
multiple of dd block size (in this case we choose 512).

The qemuMonitorMigateToCommand() monitor API is used for both
save/coredump, and migration via UNIX socket. We can't simply
switch this to use 'dd' since this causes problems with the
migration usage. Thus, create a dedicated qemuMonitorMigateToFile
which can accept an filename + offset, and remove the filename
from the current qemuMonitorMigateToCommand() API

* src/qemu/qemu_driver.c: Switch to qemuMonitorMigateToFile
  for save and core dump
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Create
  a new qemuMonitorMigateToFile, separate from the existing
  qemuMonitorMigateToCommand to allow handling file offsets
2010-04-28 13:51:48 +01:00
ae42979a74 Avoid create/unlink with block devs used for QEMU save
It is possible to use block devices with domain save/restore. Upon
failure QEMU unlinks the path being saved to. This isn't good when
it is a block device !

* src/qemu/qemu_driver.c: Don't unlink block devices if save fails
2010-04-28 13:47:49 +01:00
d7e0fe6e9f Fix crash when cleaning up from failed save attempt
If a transient QEMU crashes during save attempt, then the virDomainPtr
object may be freed. If a persistent QEMU crashes during save, then
the 'priv->mon' field is no longer valid since it will be inactive.

* src/qemu/qemu_driver.c: Fix two crashes when QEMU exits
  during a save attempt
2010-04-28 13:45:34 +01:00
ed7813d28d nwfilter: let qemu's after-migration packet pass
Qemu currently sends an Ethernet packet with protocol id 0x835 once a VM
was successfully migrated. The content of the packet looks like a
gratuitous RARP, just with the wrong protocol ID, which should be
0x8035. I wrote some filters to let either one of the packets pass and
am adapting the clean-traffic sample filter to use it. I am also
doing some changes on the existing ARP filter which was lacking a
test for source MAC address.
2010-04-27 14:50:35 -04:00
71f99af5a4 Fix up the error message if we can't parse the snapshot XML.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-27 14:11:36 -04:00
75d88455f5 The base used for conversion of USB values should be 16 not 10.
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2010-04-27 19:47:54 +02:00
b69bbebbba Fix up the locking in the snapshot code.
In particular I was forgetting to take the qemuMonitorPrivatePtr
lock (via qemuDomainObjBeginJob), which would cause problems
if two users tried to access the same domain at the same time.
This patch also fixes a problem where I was forgetting to remove
a transient domain from the list of domains.

Thanks to Stephen Shaw for pointing out the problem and testing
out the initial patch.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-27 10:40:36 -04:00
0c4010a1d7 cleanup the download section of the documentation
Just removing reverences to the deprecated CVS server and the old git
on et.redhat.com
2010-04-27 14:20:51 +02:00
aea68ce906 nwfilter: add support for RAPR protocol
This patch adds support for the RARP protocol. This may be needed due to
qemu sending out a RARP packet (at least that's what it seems to want to
do even though the protocol id is wrong) when migration finishes and
we'd need a rule to let the packets pass.

Unfortunately my installation of ebtables does not understand -p RARP
and also seems to otherwise depend on strings in /etc/ethertype
translated to protocol identifiers. Therefore I need to pass -p 0x8035
for RARP. To generally get rid of the dependency of that file I switch
all so far supported protocols to use their protocol identifier in the
-p parameter rather than the string.

I am also extending the schema and added a test case.

changes from v1 to v2:
- added test case into patch
2010-04-27 07:26:12 -04:00
35b6137696 Ignore qemu STOP event when stopping CPUs
With JSON qemu monitor, we get a STOP event from qemu whenever qemu
stops guests CPUs. The downside of it is that vm->state is changed to
PAUSED and a new generic paused event is send to applications. However,
when we ask qemu to stop the CPUs we are not really interested in qemu
event and we usually want to issue a more specific event.

By setting vm->status to PAUSED before actually sending the request to
qemu (and resetting it back if the request fails) we can ignore the
event since the event handler does nothing when the guest is already
paused. This solution is quite hacky but unfortunately it's the best
solution which I was able to come up with and it doesn't introduce a
race condition.
2010-04-27 12:14:47 +02:00
29bca037aa Fix build with DEBUG_RAW_IO=1 2010-04-27 12:09:35 +02:00
1b9347b5f1 Fix indentation for storage conf XML
* virStorageEncryptionFormat is called from both
  virDomainDiskDefFormat and virStorageVolTargetDefFormat.  The proper
  indentation in the generated XML depends on the caller.  My earlier
  patch to fix the incorrect indentation for the domain XML broke the
  indentation for the storage XML.  This patch adopts Laine's
  suggestion of requring the caller of virStorageEncryptionFormat to
  provide an unsigned int with the number of spaces the output should
  be indented.  The patch modifies both callers to provide the
  additional argument.

* Add a regression test for the domain XML

* src/conf/domain_conf.c src/conf/storage_conf.c
  src/conf/storage_encryption_conf.c src/conf/storage_encryption_conf.h:
  change the indentation code
* tests/qemuxml2xmltest.c
  tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.args
  tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.xml: add a regression test
2010-04-27 12:01:32 +02:00
6b3ce82d98 Don't try to build qemu and lxc on non-Linux platforms
as their drivers requires linux only headers
2010-04-27 10:11:21 +02:00
d707c86633 cygwin: Handle differences in the XDR implementation
Cygwin's XDR implementation defines xdr_u_int64_t instead of
xdr_uint64_t and lacks IXDR_PUT_INT32/IXDR_GET_INT32.

Alter the IXDR_GET_LONG regex in rpcgen_fix.pl so it doesn't destroy
the #define IXDR_GET_INT32 IXDR_GET_LONG in remote_protocol.x.

Also fix the remote_protocol.h regex in rpcgen_fix.pl.
2010-04-27 09:31:28 +02:00
56c33caaec Cygwin's GCC doesn't like this .sa_handler initialization for some reason 2010-04-26 21:13:47 +02:00
fe4ff24af8 linux/if.h header is not available on non-Linux platforms 2010-04-26 21:07:11 +02:00
5c7c755f50 nwfilter: enable hex number inputs in filter XML
With this patch I want to enable hex number inputs in the filter XML. A
number that was entered as hex is also printed as hex unless a string
representing the meaning can be found.

I am also extending the schema and adding a test case. A problem with
the DSCP value is fixed on the way as well.

Changes from V1 to V2:

- using asHex boolean in all printf type of functions to select the
output format in hex or decimal format
2010-04-26 13:50:40 -04:00
8fa9c22142 Starts dnsmasq from libvirtd with --dhcp-hostsfile option
This patch makes libvirtd start the dnsmasq daemon with a
--dhcp-hostsfile option instead of --dhcp-host options for each
'//ip/dhcp/host' entries defined in network xml file.

the dnsmasq host file is stored into /var/lib/libvirt/network

* src/network/bridge_driver.c: define the directory for the hostfiles
  and save/delete them to be used by dnsmasq
2010-04-26 17:20:02 +02:00
51d203c676 Add build support for dnsmasq module
* po/POTFILES.in: the new module contains translatable strings
* src/Makefile.am: include the files in the utils set
* src/libvirt_private.syms: exports the symbols internally
2010-04-26 17:20:02 +02:00
4ad65ab86a Add dnsmasq module files
It implements an idea to save dhcp hosts' macaddr vs. ipaddr mappings to
static file and make dnsmasq loading it with "--dhcp-hostsfile" option,
originally suggested by Dan, and can address the problem that too
many "--dhcp-host" args hitting ARG_MAX limit

* src/util/dnsmasq.h src/util/dnsmasq.c: adds the 2 new files
2010-04-26 17:20:02 +02:00
4ce54ef5c7 Fix make dist missing ESX generated files
new method generated files are missing from dist tarball.
2010-04-26 16:59:50 +02:00
52ae076a94 Fix memory leak in virsh snapshot-list.
We were forgetting to release the memory allocated by
virDomainSnapshotListNames.  Free the memory properly.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-23 14:23:27 -04:00
21c6cfc213 Fix printing of pathnames on error in qemuDomainSnapshotLoad.
While doing some testing of the snapshot code I noticed that
if qemuDomainSnapshotLoad failed, it would print a NULL as
part of the error.  That's not desirable, so leave the
full_path variable around until after we are done printing
errors.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-23 14:22:48 -04:00
5993321dc5 Fix virDomainSnapshotObjFree memory leak.
We were freeing the virDomainSnapshotDefPtr, but not
the virDomainSnapshotObjPtr in virDomainSnapshotObjFree.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-23 14:21:34 -04:00
e129a63775 Make virDomainSnapshotObjListDeinit static.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-23 14:20:56 -04:00
4aa36a68a6 Fix a memory leak in the snapshot code in libvirtd.
While running libvirtd under valgrind and doing some
snapshot testing I noticed that we would always leak a
connection reference.  The problem was actually that we
were leaking a domain reference in the libvirtd remote
snapshot code, which was in turn causing a leaked
connection reference.  Fix the situation by explicitly
taking and dropping a domain reference where we need it.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-23 14:20:11 -04:00
40648b156b cygwin: Check explicitly for getmntent_r
Cygwin has mntent.h but lacks getmntent_r. Update preprocessor
checks to catch this combination.
2010-04-23 20:15:53 +02:00
d1be0aefa9 Some NWFilter symbols are conditional and have to be exported conditional 2010-04-23 19:51:00 +02:00
87506c2bcf xen: Fix inside_daemon beeing unused when libvirtd is disabled
The defined __sun is there, because inside_daemon is used in xenUnifiedOpen
if __sun is defined.
2010-04-23 19:51:00 +02:00
258923f2eb Disable stateful OpenNebula driver if libvirtd is disabled
Also move the equivalent checks for LXC and UML before their header
checks. This way configure doesn't check for the headers when the driver
gets disabled anyway.
2010-04-23 19:51:00 +02:00
8d319a2f2d Improve configure error message about missing Linux headers 2010-04-23 19:51:00 +02:00
d6daeb124b build: fix typo in previous commit
* configure.ac: Avoid syntax error.
2010-04-23 11:24:52 -06:00
004aee6346 build: don't include winsock2.h on cygwin
Under cygwin, winsock2.h is intentionally incompatible with,
<sys/socket.h>, and checking for existence is wrong.

Under mingw, HAVE_WINSOCK2_H is defined on our behalf by
gnulib, in a way that does not interfere with cygwin.

* configure.ac: Drop unnecessary header check.
Reported by Matthias Bolte.
2010-04-23 11:06:33 -06:00
eb9b653243 QEmu JSON drop timestamp from command object
It's not needed and is currently ignored, but this is a bug.

It will get fixed soon and QMP will return an error for keys
it doesn't know about, this will break libvirt.

* src/qemu/qemu_monitor_json.c: remove qemuMonitorJSONCommandAddTimestamp()
  and the place where it's invoked in qemuMonitorJSONMakeCommand()
2010-04-23 18:06:18 +02:00
9db01465e5 nwfilter: extend schema + add testcase w/ connlimit-above
I am extending the schema with the recently added connlimit-above
attribute and adding a test case for it to the test suite.
2010-04-23 11:42:39 -04:00
2aed290ee9 maint: update AUTHORS
* AUTHORS: Use preferred name.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-04-23 07:48:10 -06:00
98bd5e6c5a Fix crash in nwfilter driver check
The nwfilterDriverActive() could de-reference a NULL pointer
if it hadn't be started at the point it was called. It was
also not thread safe, since it lacked locking around data
accesses.

* src/nwfilter/nwfilter_driver.c: Fix locking & NULL checks
  in nwfilterDriverActive()
2010-04-23 11:06:30 +01:00
3022375da3 addrToString: give better error message
The user probably doesn't care what the gai error numbers are, as
much as what the failed conversion IP address was.

* src/remote/remote_driver.c (addrToString): Mention which address
could not be converted.
* daemon/remote.c (addrToString): Likewise.
2010-04-22 14:46:55 -06:00
2a82a33ee4 maint: update AUTHORS with recent contributors
git shortlog $(git log -1 --format=%H AUTHORS).. | grep -v "^ "

then add missing entries to AUTHORS.

* AUTHORS: Update.
2010-04-22 14:13:03 -06:00
c85c9b3a26 qemu: fix security context references in DAC code
* The error messages coming from qemu's DAC support contain strings
  from the original SELinux security driver code.  This just removes
  references to "security context" and other SELinux-isms from the DAC
  code.

Signed-off-by: Spencer Shimko <sshimko@tresys.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-04-22 13:54:41 -06:00
647c26c886 Changes from V1 to V2:
- using INT_BUFSIZE_BOUND() to determine the length of the buffersize
for printing and integer into

 - not explicitly initializing static var threadsTerminate to false
anymore, since that's done automatically

Changes after V2:
  - removed while looks in case of OOM error
  - removed on ifaceDown() call
  - preceding one ifaceDown() call with an ifaceCheck() call

Since the name of an interface can be the same between stops and starts
of different VMs I have to switch the IP address learning thread to use
the index of the interface to determine whether an interface is still
available or not - in the case of macvtap the thread needs to listen for
traffic on the physical interface, thus having to time out periodically
to check whether the VM's macvtap device is still there as an indication
that the VM is still alive. Previously the following sequence of 2 VMs
with macvtap device

virsh start testvm1; virsh destroy testvm1 ; virsh start testvm2

would not terminate the thread upon testvm1's destroy since the name of
the interface on the host could be the same (i.e, macvtap0) on testvm1
and testvm2, thus it was easily race-able. The thread would then
determine the IP address parameter for testvm2 but apply the rule set
for testvm1. :-(
I am also introducing a lock for the interface (by name) that the thread
must hold while it listens for the traffic and releases when it
terminates upon VM termination or 0.5 second thereafter. Thus, the new
thread for a newly started VM with the same interface name will not
start while the old one still holds the lock. The only other code that I
see that also needs to grab the lock to serialize operation is the one
that tears down the firewall that were established on behalf of an
interface.

I am moving the code applying the 'basic' firewall rules during the IP
address learning phase inside the thread but won't start the thread
unless it is ensured that the firewall driver has the ability to apply
the 'basic' firewall rules.
2010-04-22 14:58:57 -04:00
68529bc596 Properly indent encryption tags
* Fix for the bug reported at:

https://bugzilla.redhat.com/show_bug.cgi?id=573908
2010-04-22 14:26:55 -04:00
96ac18591a Fix locking in qemudDomainCoreDump
The hang fix in d376b7d63e was incomplete
since it left quite a few {Enter,Exit}Monitor calls which require driver
to be unlocked. Since the driver is locked throughout the whole
function, {Enter,Exit}MonitorWithDriver need to be used instead to
ensure driver is not locked when issuing monitor commands.
2010-04-22 19:41:24 +02:00
e2c059485c Poll for migration end every 50ms instead of 50us
The comment in qemuDomainWaitForMigrationComplete says we are polling
every 50ms but the code sleeps only for 50us. This was already discussed
during review but apparently forgotten when the series was pushed.
2010-04-22 19:41:18 +02:00
e5c668a021 configure.ac SELinux fixes
* Fix a logic error in configure.ac that prevented --with-selinux=no
  from being used with --with-secdriver-selinux=no.

* Fix some strings to clarify the difference between --with-selinux
  and --with-secdriver-selinux.

Signed-off-by: Spencer Shimko <sshimko@tresys.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-04-22 10:50:49 -06:00
9772bebab7 Fix QEMU text monitor command error checking
The text monitor code was checking for a '\n' prefix on several
places. Previously this would work, but since the monitor code
re-write the '\n' is already stripped off, so mustn't be checked
for.

* src/qemu/qemu_monitor_text.c: Fix monitor error checking
2010-04-22 17:15:48 +01:00
a980d123b5 Fix CPU hotplug command names
Probably as a result of a merge error, the CPU hotplug command
names were completely wrong.

* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_text.c: Fix
  the CPU hotplug command names
2010-04-22 17:15:48 +01:00
de8ecb12cb Fix printing of event detail in python events demo program
The events demo program is slightly misleading printing

  myDomainEventCallback1 EVENT: Domain f14i686(-1) Added

which is not distinguishing Add vs Update events. It should have
been doing

  myDomainEventCallback1 EVENT: Domain f14i686(-1) Defined Updated

* examples/domain-events/events-python/event-test.py: Fully print
  event detail info string
2010-04-22 17:15:48 +01:00
cb06a9bfe5 portability fixes to tools/virt-pki-validate.in
A few fixes will help make tools/virt-pki-validate.in useful on Debian
and Ubuntu.  And one fix should be useful to everyone (see #3).

 1) note our gnutls-bin package (in addition to your gnutls-utils
package) in the no-certtool error text

 2) fix a bashism, == should be = in the case where /bin/sh is a symlink
to dash

 3) $(SYSCONFDIR) cannot evaluate; set a single shell SYSCONFDIR
variable to the autoconf @SYSCONFDIR@ value, and use $SYSCONFDIR
everywhere

Bug report:
 * https://bugs.edge.launchpad.net/ubuntu/+source/libvirt/+bug/562266

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-04-22 09:06:30 -06:00
1f7560e25d maint: enforce whitespace on shell scripts
Noticed because virt-pki-validate was very inconsistent on
using tabs vs. 8 spaces, sometimes mixing both paradigms on
a single line.

'git diff -b' shows significant changes only in cfg.mk.

* cfg.mk (sc_TAB_in_indentation): Add a few files.
* daemon/libvirtd.init.in: Avoid tabs.
* tools/virt-pki-validate.in: Likewise.
2010-04-22 09:06:30 -06:00
2788f4d1d4 testutilsqemu: avoid uninitialized variable
* tests/testutilsqemu.c (testQemuCapsInit): Initialize variables.
2010-04-22 09:00:30 -06:00
b34e082079 Fake host CPU for qemu tests 2010-04-22 10:21:05 +02:00
b9a2552d2a Use configured CPU model if possible
Adds ability to provide a preferred CPU model for CPUID data decoding.
Such model would be considered as the best possible model (if it's
supported by hypervisor) regardless on number of features which have to
be added or removed for describing required CPU.
2010-04-22 10:20:50 +02:00
53c4f9fa1c Support removing features when converting data to CPU
So far, when CPUID data were converted into CPU model and features, the
features can only be added to the model. As a result, when a guest asked
for something like "qemu64,-svm" it would get a qemu32 plus a bunch of
additional features instead.

This patch adds support for removing feature from the base model.
Selection algorithm remains the same: the best CPU model is the model
which requires lowest number of features to be added/removed from it.
2010-04-22 10:20:41 +02:00
60aef9e467 Move MIN macro to util.h so that others can use it 2010-04-22 10:20:32 +02:00
e07314f4c1 Deal with CPU models in []
Qemu committed a patch which list some CPU names in [] when asked for
supported CPUs (qemu -cpu ?). Yet, it needs such CPUs to be passed
without those square braces. When probing for supported CPU models, we
can just strip the square braces and pretend we have never seen them.
2010-04-22 10:20:25 +02:00
9fbb810cf4 Fix initial VCPU pinning in qemu driver
First, inital VCPU pinning is set correctly but then it is reset by
assigning qemu process to a new cgroup (which contains all CPUs). It's
easily fixed by swapping these two actions.
2010-04-22 09:30:34 +02:00
871aa6e3c1 maint: ignore 'make syntax-check' failure files
* .gitignore: Add exemption.
* cfg.mk (local-checks-to-skip): Ignore a test to silence a skip
warning.
2010-04-21 14:32:08 -06:00
8274993f29 Make avahi startup more robust.
If the hostname of the current virtualization machine
could not be resolved, then libvirtd would fail to
start.  However, for disconnected operation (on a laptop,
for instance) the hostname may very legitimately not
be resolvable.  This patch makes it so that if we can't
resolve the hostname, avahi doesn't fail, it just uses
a less useful MDNS string.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-21 16:16:36 -04:00
ce380b8e6f Ignore empty type attribute in driver element of virtual disks
Fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578347
2010-04-21 20:49:47 +02:00
84bc7ac06b build: fix preprocessor indentation
* src/esx/esx_vi.h: Placate cppi.
2010-04-21 10:05:01 -06:00
b1fab0c21c esx: Don't treat an empty root snapshot list as error
An empty root snapshot list was considered as error condition. Creating a
new snapshot would fail if the domain didn't have snapshots yet, because
the snapshot-create function tries to lookup the list of existing snapshots
in order to verify that the snapshot name is unique. This fails if the
domain doesn't have snapshots yet.

Removing the NULL check from esxVI_LookupRootSnapshotTreeList fixes this.
2010-04-21 11:47:15 +02:00
3f52921d43 esx: Gather some XML generation macros in esx_vi.h 2010-04-21 00:44:24 +02:00
7a056d0648 esx: Fix FindByIp response handling
FindByIp may return nothing if there is no host or virtual machine
with the given IP address. Handle that case properly.
2010-04-21 00:44:18 +02:00
1d8099f4b6 esx: Fix virtualHW.version generation
The supported virtualHW.version doesn't depend on the API version,
but on the product version.
2010-04-21 00:37:46 +02:00
abce152a49 nwfilter: add support for connlimit match
This patch adds support for the connlimit match in iptables that is used
to limit the number of outgoing directions.
2010-04-20 17:14:38 -04:00
c8f4dcca6a Extend fwall-drv interface and call functions via interface
I am moving some of the eb/iptables related functions into the interface
of the firewall driver and am making them only accessible via the driver's
interface. Otherwise exsiting code is adapted where needed. I am adding one
new function to the interface that checks whether the 'basic' rules can be
applied,  which will then be used by a subsequent patch.
2010-04-20 17:07:15 -04:00
8f342c6f9a build: avoid compiler warning
According to GCC, ATTRIBUTE_UNUSED means that an attribute _might_
be unused, not _must_ be unused.  Therefore, it is easier to
blindly mark a variable, than to try and do preprocessor limiting
of when we know it is unused.

* src/remote/remote_driver.c (remoteAuthenticate): Mark attribute
as potentially unused.
Reported by Gustovo Morozowski.
2010-04-20 13:44:31 -06:00
8138ec8693 Explicitly set virStoragePoolTypeInfo FS and NETFS defaults
No semantic change, the now explicitly set default are all zero and
that's what GCC sets unspecified struct members to.
2010-04-20 21:22:51 +02:00
c6375aa796 esx: Add support for the VMXNET 2 (Enhanced) NIC model
Add a test case and document it.
2010-04-20 20:58:24 +02:00
cad913060c Mark in_open parameter of remoteAuthenticate as unused when it's unused
Otherwise compiling with -Werror will fail.
2010-04-20 20:35:23 +02:00
8b3a89c486 Install nwfilter xml files from source directory.
During an out-of-tree build, the current working directory is the build
directory. Since the FILTERS are static and not modified or
auto-generated during the build process, they need to be explicitly
fetched from the source directory during install.

Prefix the files with $(srcdir), which gets expanded to the absolute or
relative path to the source directory, even when duing out-of-tree
builds.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-04-20 08:14:23 -06:00
5d4009b0d1 Don't ship generated python/libvirt.? files.
libvirt.c and libvirt.h are auto-generated files. Mentioning their names
in *_SOURCES includes them in the distribution. During an out-of-tree
build these shipped files are included instead of the auto-generated
version, potentially breaking the build (as it happend in 0.8.0, because
the shipped libvirt.h was missing the declaration for
'libvirt_virDomainUpdateDeviceFlags')

Use the nodist_*_SOURCES automake variable instead.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-04-20 08:13:06 -06:00
90302e7f8d Fixup python binding for virDomainSnapshot APIs
The generator code was totally wrong for the virDomainSnapshot
APIs, not generating the wrapper class, and giving methods the
wrong names

* generator.py: Set metadata for virDomainSnapshot type & APIs
* libvirt-override-api.xml, libvirt-override.c: Hand-code the
  virDomainSnapshotListNames glue layer
2010-04-20 11:49:27 +02:00
f3e098f3d8 Fix network hotplug to use device_add in QEMU
The initial boot of VMs uses -device for NICs where available. The
corresponding monitor command is device_add, but the network hotplug
code was still using device_del by mistake.

* src/qemu/qemu_driver.c: Use device_add for NIC hotplug where
  available
2010-04-19 12:11:30 +01:00
9417eb0337 Fix error reporting for getfd + host_net_add in QEMU
If either of the getfd or host_net_add monitor commands return
any text, this indicates an error condition. Don't ignore this!

* src/qemu/qemu_monitor_text.c: Report errors for getfd and
  host_net_add
2010-04-19 12:11:24 +01:00
e699a82474 Fix device_del in JSON mode for QEMU
The 'device_del' command expects a parameter called 'id' but we
were passing 'config'.

* src/qemu/qemu_monitor_json.c: Fix device_del command parameter
2010-04-19 12:11:17 +01:00
c35b5269af nwfilter: Free nwfilter hash of virConnectPtr
And close the driver on connection close.
2010-04-17 18:20:15 +02:00
051df19e0e Replace printf with logging macros 2010-04-17 15:02:28 +02:00
39f3fee4a4 Mark internal.h for translation 2010-04-16 19:21:10 +02:00
7a2c6222a9 Use virCheckFlags for APIs added in 0.8.0 2010-04-16 14:05:50 +02:00
070da02fb5 Introduce virCheckFlags for consistent flags checking
The idea is that every API implementation in driver which has flags
parameter should first call virCheckFlags() macro to check the function
was called with supported flags:

    virCheckFlags(VIR_SUPPORTED_FLAG_1 |
                  VIR_SUPPORTED_FLAG_2 |
                  VIR_ANOTHER_SUPPORTED_FLAG, -1);

The error massage which is printed when unsupported flags are passed
looks like:

    invalid argument in virFooBar: unsupported flags (0x2)

Where the unsupported flags part only prints those flags which were
passed but are not supported rather than all flags passed.
2010-04-16 14:05:50 +02:00
d2327278fb nwfilter: Clear all state tracking from a drop rule
Don't use state-matching in a drop rule.
2010-04-16 07:34:36 -04:00
3a7f2fc3b2 esx: Replace scanf with STRSKIP and strtok_r
This also fixes a portability problem with the %a format modifier.
%a is not portable and made esxDomainDumpXML fail at runtime in
MinGW builds.
2010-04-15 19:52:38 +02:00
7ca6a0996d Update to latest gnulib to get strtok_r relaxed to LGPLv2+
strtok_r will be used in the ESX driver to replace scanf-based code.

MinGW lacks strtok_r, so we need gnulib to provide it, but until now
strtok_r was licensed LGPL3.
2010-04-15 19:52:38 +02:00
77408cc0e1 esx: Add nwfilter driver stub
This stops libvirt trying to connect to a non-existing libvirtd on the
ESX server in order to find a nwfilter driver.
2010-04-15 19:52:38 +02:00
ec724071e9 remote: react to failures on wakeupFD
* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Report
failures on pipe used for wakeup.
Reported by Chris Lalancette.
2010-04-15 11:40:08 -06:00
f9f6c34c5c util: ensure safe{read,write,zero} return is checked
Based on a warning from coverity.  The safe* functions
guarantee complete transactions on success, but don't guarantee
freedom from failure.

* src/util/util.h (saferead, safewrite, safezero): Add
ATTRIBUTE_RETURN_CHECK.
* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Ignore
some failures.
(remoteIOReadBuffer): Adjust error messages on read failure.
* daemon/event.c (virEventHandleWakeup): Ignore read failure.
2010-04-15 11:40:08 -06:00
cf4dee3615 maint: another preprocessor fix
Regression introduced in commit 62170b995.

* src/util/memory.h: Placate cppi, and fit 80 columns.
2010-04-15 11:39:10 -06:00
c4896d378b Fix CDROM media change for QEMU when using -device syntax
Disk devices in QEMU have two parts, the guest device and the host
backend driver. Historically these two parts have had the same
"unique" name. With the switch to using -device though, they now
have separate names. Thus when changing CDROM media, for guests
using -device syntax, we need to prepend the QEMU_DRIVE_HOST_PREFIX
constant

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add helper function
  qemuDeviceDriveHostAlias() for building a host backend alias
* src/qemu/qemu_driver.c: Use qemuDeviceDriveHostAlias() to determine
  the host backend alias for performing eject/change commands in the
  monitor
2010-04-15 18:09:42 +01:00
db336caa58 Update QEMU device_add command in JSON mode
The device_add command was added in JSON mode in a way I didn't
expect. Instead of passing the normal device string to the JSON
command:

    { "execute": "device_add", "arguments": { "device": "ne2k_pci,id=nic.1,netdev=net.1" } }

We need to split up the device string into a full JSON object

    { "execute": "device_add", "arguments": { "driver": "ne2k_pci", "id": "nic.1", "netdev": "net.1" } }

* src/qemu/qemu_conf.h, src/qemu/qemu_conf.c: Rename the
  qemuCommandLineParseKeywords method to qemuParseKeywords
  and export it to monitor
* src/qemu/qemu_monitor_json.c: Split up device string into
  a JSON object for device_add command
2010-04-15 18:08:04 +01:00
fde060b8f5 Rename parameter in qemuMonitorDeviceDel
The parameter for the qemuMonitorDeviceDel() is a device alias,
not a device config string. Rename the parameter reflect this
and avoid confusion to readers.

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Rename devicestr to devalias in qemuMonitorDeviceDel()
2010-04-15 17:57:59 +01:00
efd4ee7871 Remove code from JSON monitor for commands that won't be ported
The QEMU developers have stated that they will not be porting
the commands 'pci_add', 'pci_del', 'usb_add', 'usb_del' to the
JSON mode monitor, since they're obsoleted by 'device_add'
and 'device_del'. libvirt has (untested) code that would have
supported those commands in theory, but since we already use
device_add/del where available, there's no need to keep the
legacy stuff anymore.

The text mode monitor keeps support for all commands for sake
of historical compatability.

* src/qemu/qemu_monitor_json.c: Remove 'pci_add', 'pci_del',
  'usb_add', 'usb_del' commands
2010-04-15 17:57:50 +01:00
f6770e8665 Run test suite as part of RPM build process
To ensure that patches in the RPM don't break any functionality
it is neccessary to run the test suites during build. It currently
has 3 tests disabled

 - daemon-conf: this is totally broken, since it relies on
   being able to resolve the 'libvirt' group & being able to
   resolve hostnames at daemon startup. This isn't possible
   in a mock build root
 - seclabeltest: fails to initialize selinux in the mock
   build root. Possibly fixable
 - nodeinfotest: broken on s390 + ppc - this is a real bug

* libvirt.spec.in: Add a %check section, with 3 tests
   temporarily disabled
2010-04-15 17:56:06 +01:00
4f81919ad2 Fix QEMU memory stats JSON mode
The QEMU driver is mistakenly calling directly into the text
mode monitor for the domain memory stats query.

* src/qemu/qemu_driver.c: Replace qemuMonitorTextGetMemoryStats with
  qemuMonitorGetMemoryStats
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add the new
  wrapper for qemuMonitorGetMemoryStats
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h: Add
  qemuMonitorJSONGetMemoryStats implementation
2010-04-15 17:55:58 +01:00
3fb992c659 Fix QEMU command building errors to reflect unsupported configuration
Instead of reporting VIR_ERR_INTERNAL_ERROR use the more specific
VIR_ERR_CONFIG_UNSUPPORTED

* src/qemu/qemu_conf.c: Report VIR_ERR_CONFIG_UNSUPPORTED for
  unsupported video adapters
2010-04-15 17:55:38 +01:00
41b087198d nwfilter: fix tear down order and consolidate functions
To avoid race-conditions, the tear down of a filter has to happen before
the tap interface disappears and another tap interface with the same
name can re-appear. This patch tries to fix this. In one place, where
communication with the qemu monitor may fail, I am only tearing the
filters down after knowing that the function did not fail.

I am also moving the tear down functions into an include file for other
drivers to reuse.
2010-04-15 10:49:24 -04:00
c41873f40e Trivial fix: Add braces to for statement to avoid crashes
I am adding braces around the for statement that are now needed to due the
new sa_assert immediately following the for statement.
2010-04-14 21:24:21 -04:00
2d73466f03 Fix close_used_without_including_unistd_h error
Triggered by gnulib when compiling with MinGW.
2010-04-15 01:41:00 +02:00
4aeb0e45e9 Fix apibuild.py warnings about missing ':' 2010-04-15 01:00:46 +02:00
62170b9952 Implement variable length structure allocator
* This patch implements a memory allocator to obtain memory for
  structures whose last member is a variable length array.  C99 refers
  to these variable length objects as structs containing flexible
  array members.
* Fixed macro parentheses per Eric Blake
2010-04-14 00:46:13 -04:00
c593aef7bc qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
* src/util/conf.c (virConfParseValue): Add an sa_assert.
2010-04-14 20:10:19 +02:00
18fa9b18bc xend_internal.c: assure clang that we do not dereference NULL
* src/xen/xend_internal.c (xend_parse_sexp_desc_char): Add three
uses of sa_assert, each preceding a strchr(value,... to assure
clang that "value" is non-NULL.
2010-04-14 20:10:19 +02:00
a0dc452172 qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
* src/qemu/qemu_driver.c (qemudDomainAttachSCSIDisk):
Initialize "cont" to NULL, so clang knows it's set.
Add an sa_assert so it knows it's non-NULL when dereferenced.
2010-04-14 20:10:19 +02:00
6e2f811443 virGetHostnameLocalhost: avoid FP NULL-ptr-deref from clang
* src/util/util.c (virGetHostnameLocalhost): Add an sa_assert
to tell clang it's ok to dereference "info" after a non-failing
getaddrinfo call.
2010-04-14 20:10:19 +02:00
b6719eab9e nwfilter_ebiptables_driver.c: avoid NULL dereference
* src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesApplyNewRules):
Don't dereference a NULL or uninitialized pointer when given
an empty list of rules.  Add an sa_assert(inst) in each loop to
tell clang that the uses of "inst[i]" are valid.
2010-04-14 20:10:18 +02:00
53896e5f44 build: set STATIC_ANALYSIS when running via clang or coverity
* configure.ac (STATIC_ANALYSIS): Define when run via clang's
scan-build or coverity-prevent's cov-build.
Use the CLANG_CC and COVERITY_BUILD_COMMAND envvars as witnesses.
2010-04-14 20:10:18 +02:00
e078fa3cec sa_assert: assert-like macro, enabled only for use with static analyzers
Among some here, there is a strong aversion to the use of "assert", yet
some others think it is essential (when applied judiciously) even --
perhaps "especially" -- at the heart of libraries and core hypervisor-
related code.
Here is a compromise that lets us make assertions about the code (e.g.,
to tell static analyzers about invariants) without even a hint of risk
of an abort.
* src/internal.h [STATIC_ANALYSIS]: Include <assert.h>.
(sa_assert): Define.  A no-op most of the time, but equivalent
to classical assert when STATIC_ANALYSIS is nonzero.
2010-04-14 20:10:18 +02:00
cffe619bdf build: fix recent 'make syntax-check' failure
* src/esx/esx_vi_methods.h: Placate cppi.
2010-04-14 11:23:09 -06:00
5e06ef743a virt-aa-helper-test: avoid non-portable echo -n
* tests/virt-aa-helper-test (testme): Use printf instead.
2010-04-14 11:17:18 -06:00
ad896a1cdd schematestutils.sh: improve shell portability: avoid "echo -e"
* tests/schematestutils.sh: Use printf rather than echo -e.
2010-04-14 17:34:12 +02:00
50bf3101a3 virStorageBackendFileSystemMount: prefer strdup over virAsprintf
* src/storage/storage_backend_fs.c (virStorageBackendFileSystemMount):
Use virAsprintf only when needed.  In this case, strdup works fine.
2010-04-14 17:17:54 +02:00
5cff81b147 virStorageBackendFileSystemMount: placate clang
* src/storage/storage_backend_fs.c (virStorageBackendFileSystemMount):
Clang was not smart enough, and mistakenly reported that "options"
could be used uninitialized.  Initialize it.
2010-04-14 17:17:47 +02:00
9ec1825982 Implement forgotten backend of virInterfaceIsActive()
Somehow the backend of this function was never implemented in
libvirt's netcf driver, and nobody noticed until now. (The required
netcf function was already in place, so nothing needs to change
there.)
* src/interface/netcf_driver.c: add in the backend function, and point
                                to it from the table of driver functions.
2010-04-14 10:38:18 -04:00
353dd14762 openvzGetProcessInfo: address clang-detected low-probability flaw
* src/openvz/openvz_driver.c (openvzGetProcessInfo): Reorganize
so that unexpected /proc/vz/vestat content cannot make us use
uninitialized variables.  Without this change, an input line with
a matching "readvps", but fewer than 4 numbers would result in our
using at least "systime" uninitialized.
2010-04-14 16:20:44 +02:00
cd7ee20a68 vshCommandRun: avoid used-uninitialized timing-related report from clang
* tools/virsh.c (vshCommandRun): Test only the initial value of
ctl->timing, so that static analyzers don't have to consider that
it might be changed by cmd->def->handler.
2010-04-14 16:17:56 +02:00
274f09cbc5 nwfilter: use virFindFileInPath for needed CLI tools
I am getting rid of determining the path to necessary CLI tools at
compile time. Instead, now the firewall driver has an initialization
function that uses virFindFileInPath() to determine the path to
necessary CLI tools and a shutdown function to free allocated memory.
The rest of the patch mostly deals with availability of the CLI tools
and to not call certain code blocks if a tool is not available and that
strings now have to be built slightly differently.
2010-04-14 06:29:55 -04:00
71057b1c58 esx: Extend esx_vi_generator.py to cover methods too
Generate almost all SOAP method mapping code.

Update the driver code to use the complete paramater list of some methods
that had parameters skipped before.

Improve the ESX_VI__METHOD marco to do automatic output deserialization
based on output occurrence. Also incorporate automatic _this binding and
output pointer check.
2010-04-14 12:01:33 +02:00
dc8dd7f8db esxVMX_GatherSCSIControllers: avoid NULL dereference
* src/esx/esx_vmx.c (esxVMX_GatherSCSIControllers): Do not dereference
a NULL disk->driverName.  We already detect this condition in another
case.  Check for it here, too.
2010-04-14 11:59:18 +02:00
29045d88ed Fix build of openvz on RHEL-5.
When building libvirt on RHEL-5, I saw this error:

cc1: warnings being treated as errors
openvz/openvz_conf.c: In function 'openvzGetVPSUUID':
openvz/openvz_conf.c:835: warning: 'saveptr' may be used uninitialized in this function
make[3]: *** [libvirt_driver_openvz_la-openvz_conf.lo] Error 1

gcc in RHEL-5 gets upset about this usage of strtok_r (even though
it is perfectly valid).  Just set *saveptr to NULL at the
start to quiet it down.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 16:28:10 -04:00
df032bab12 Fix up formatting of remote protocol stuff.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:47 -04:00
fa30eaf3d3 Fix messsage -> message.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:39 -04:00
1be3c3c8ee Fix up a debug typo.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:32 -04:00
f5926b54c0 Remove some debugging leftovers.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:23 -04:00
5174b02fb9 Consolidate interface related functions in interface.c
Changes from v1 to v2:
- changed function name prefixes to 'iface' from previous 'Iface'

- Further to make make syntax-check pass:
 - indentation fix in interface.h
 - added entry to POTFILES.in

I am consolidating network interface related functions used in nwfilter
and macvtap code in utils/interface.c. All function names are prefixed
with 'Iface'. The following functions are now available through
interface.h:

int ifaceCtrl(const char *name, bool up);
int ifaceUp(const char *name);
int ifaceDown(const char *name);

int ifaceCheck(bool reportError, const char *ifname,
               const unsigned char *macaddr, int ifindex);

int ifaceGetIndex(bool reportError, const char *ifname, int *ifindex);

I added 'int ifindex' as parameter to ifaceCheck to the original
function and modified the code accordingly.
2010-04-13 10:57:11 -04:00
e7ebe9f357 Fix nodeinfotest on NUMA machines
The nodeinfotest was reliant on the host NUMA topology, but all
the test data files assumed 1 single NUMA node. This test thus
failed on any NUMA machine with > 1 node

* tests/nodeinfotest.c: Hardcode 1 single numa node
2010-04-13 15:50:07 +01:00
9819b41a20 build: include usleep gnulib module
Without this module, attempts to sleep for 1 or more seconds
on mingw instead become a no-delay no-op.

* bootstrap.conf (gnulib_modules): Add usleep.
2010-04-13 07:58:01 -06:00
505242f817 Fix spec file for builds without lxc
* libvirt.spec.in: fix a cut and paste error
2010-04-13 10:40:21 +02:00
babaae9256 build: fix syntax-check problems
* .x-sc_prohibit_gettext_noop: Add new exemption.
* .x-sc_prohibit_test_minus_ao: Likewise.
* Makefile.am (EXTRA_DIST): Distribute new files.
* .gitignore: Ignore built file.
2010-04-12 16:43:05 -06:00
281c3c649b add nwfilter functions to virsh man page
With Eric Blake's spelling corrections applied.

Unfortunately after the 0.8.0 release, but here's a beginning of the
documentation of the nwfilter functionality.
2010-04-12 17:50:31 -04:00
bfcca58787 Release of libvirt-0.8.0
* configure.ac docs/news.html.in libvirt.spec.in src/libvirt_public.syms:
  updates for release of 0.8.0
* po/*.po po/libvirt.pot: updated a lar set of localizations, and merge
  the messages
2010-04-12 19:39:20 +02:00
22de841a76 Add documentation for synchronous hooks
* docs/sitemap.html.in: add in navigation under
  Documentation/Deployment/Hooks
* docs/hooks.html.in: new doc describing current support for 0.8.0
2010-04-12 18:03:35 +02:00
e2e000cf1b Rename virsh "revert-to-snapshot" to "snapshot-revert"
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-12 10:09:55 -04:00
3b106cead5 Small fixes to virsh man page
* tools/virsh.pod: add two missing 's' and section about 'dominfo' is
  duplicated
2010-04-12 14:23:18 +02:00
c5337e8e43 nwfilter: Fix memory leak on daemon init and shutdown
This patch fixes a memory leak on daemon init and shutdown. The module
was initialized twice and not shut down.
2010-04-12 08:19:11 -04:00
55d444cc10 nwfilter: Process DHCP option to determine whether packet is a DHCP_OFFER
I mistakenly took the op field in the DHCP message as the DHCP_OFFER
type. Rather than basing the decision to read the VM's IP address on
that field, process the appended DHCP options where option 53 indicates
the actual type of the packet. I am also reading the broadcast address
of the VM, but don't use it so far.
2010-04-09 15:54:29 -04:00
cddd3ac8b0 Add enospace option to qemu disk error policy
* Dan Kenigsberg requested explicit support for the qemu default disk error policy which is enospace
2010-04-09 03:35:47 -04:00
631c4ce855 More event callback fixes
In a couple of cases typos meant we were firing the wrong type
of event. In the python code my previous commit accidentally
missed some chunks of the code.

* python/libvirt-override-virConnect.py: Add missing python glue
  accidentally left out of previous commit
* src/conf/domain_event.c, src/qemu/qemu_monitor_json.c: Fix typos
  in event name / method name to invoke
2010-04-09 16:24:28 +01:00
1670df676a Undoing 2nd application of the patch... 2010-04-09 10:05:59 -04:00
39367b5674 Fix error in nwfilter test driver
Trivial fix for the c&p error in the nwfilter test driver.
2010-04-09 09:55:22 -04:00
f21c6c6890 Fix error in nwfilter test driver
Trivial fix for the c&p error in the nwfilter test driver.
2010-04-09 09:53:47 -04:00
c7f70f4357 Fix some cppi prepocessor indentation issues
* src/conf/nwfilter_conf.c src/util/hooks.c: added spaces to avoid
  "make syntax-check" failures
2010-04-09 15:10:46 +02:00
4a2dd00e76 qemu: catch cdrom change error
Currently when we attempt to change the cdrom in a qemu VM the monitor
doesn't generate an error if the target filename doesn't exist.  I've
submitted a patch[1] for this.  This patch is the libvirt qemu-driver
side which catches the error message from the monitor and reportes the
error to libvirt.  This means that virsh attach-disk cdrom commands
won't appear to succeed when qemu change command actually failed.

* src/qemu/qemu_monitor_text.c: in qemuMonitorTextChangeMedia() look
  for failure to access the new data
2010-04-09 15:07:16 +02:00
aed4c08d4c Avoid using multicast addresses for Ethernet MAC examples
* docs/formatdomain.html.in: use '00:11:22:33:44:55' instead of
  '11:22:33:44:55:66'
2010-04-09 14:38:12 +02:00
b5cc01ef2e nwfilter: More XML parser test cases
This patch adds a couple more nwfilter test cases for the XML parser tests.
2010-04-09 07:25:02 -04:00
98caf6db76 Cleanup the msg_gen_function list in cfg.mk
Remove symbols that don't exist anymore (e.g. ERROR0) or aren't
message generating functions (e.g. VIR_FREE) or are now reported
as unmarked because the grep command is different, but that should
not be marked at all (e.g. DEBUG0).

Also don't restrict one of the grep lines in the
libvirt_unmarked_diagnostics rule to match exactly one space
between function name and opening parenthesis.
2010-04-09 02:34:25 +02:00
ddf877cd9e remote: Replace some virRaiseError with remoteError 2010-04-09 02:23:40 +02:00
9455323530 remote: Remove virConnectPtr from error/errorf
Also unify error/errorf to remoteError and update cfg.mk accordingly.
2010-04-09 01:56:27 +02:00
564f4c2f9a Remove undefined symbols from symbols file 2010-04-08 22:08:01 +02:00
1aaa909116 esx: Add domain snapshot support
Fix invalid code generating in esx_vi_generator.py regarding deep copy
types that contain enum properties.

Add strptime and timegm to bootstrap.conf. Both are used to convert a
xsd:dateTime to calendar time.

Add a testcase of the xsd:dateTime conversion.
2010-04-08 21:54:43 +02:00
1787fdff57 Generate libvirt.def from libvirt.syms
The MinGW linker needs the libvirt.def file.
2010-04-08 20:12:09 +02:00
7ea025aed0 Fix unterminated B<...> in virsh man page 2010-04-08 14:51:46 +02:00
6df7d55d39 Fix up python bindings for new event callbacks
The generator was disabled for the new event callbacks, since they
need to be hand written. This patch  adds the C and python glue to
expose the new APIs in the python binding. The python example
program is extended to demonstrate of the code

* python/libvirt-override.c: Registration and dispatch of events
   at the C layer
* python/libvirt-override-virConnect.py: Python glue for events
* examples/domain-events/events-python/event-test.py: Demo use
  of new event callbacks
2010-04-08 12:41:40 +01:00
df62337289 Add missing nwfilter_learnipaddr.c to POTFILES.in
* po/POTFILES.in: Add src/nwfilter/nwfilter_learnipaddr.c
2010-04-08 12:01:57 +01:00
3d3af08879 Fix Win32 portability problems
The network filter / snapshot / hooks code introduced some
non-portable pices that broke the win32 build

* configure.ac: Check for net/ethernet.h required by nwfile config
   parsing code
* src/conf/nwfilter_conf.c: Define ethernet protocol  constants
  if net/ethernet.h is missing
* src/util/hooks.c: Disable hooks build on Win32 since it lacks
  fork/exec/pipe
* src/util/threads-win32.c: Fix unchecked return value
* tools/virsh.c: Disable SIGPIPE on Win32 since it doesn't exist.
  Fix non-portable strftime() formats
2010-04-08 12:01:57 +01:00
9fd54a78dc nwfilter: fix for directionality of ICMP traffic
Changes from V1 to V2 of this patch
- I had reversed the logic thinking that icmp type 0 is a echo
request,but it's reply -- needed to reverse the logic
- Found that ebtables takes the --ip-tos argument only as a hex number

This patch enables the skipping of some of the ICMP traffic rules on the
iptables level under certain circumstances so that the following filter
properly enables unidirectional pings:

<filter name='testcase'>
    <uuid>d6b1a2af-def6-2898-9f8d-4a74e3c39558</uuid>
    <!-- allow incoming ICMP Echo Request -->
    <rule action='accept' direction='in' priority='500'>
        <icmp type='8'/>
    </rule>
    <!-- allow outgoing ICMP Echo Reply -->
    <rule action='accept' direction='out' priority='500'>
        <icmp type='0'/>
    </rule>
    <!-- drop all other ICMP traffic -->
    <rule action='drop' direction='inout' priority='600'>
        <icmp/>
    </rule>
</filter>
2010-04-08 06:25:38 -04:00
4acab37f56 esx: Allow 'lsisas1068' as SCSI controller type
Extend tests to cover all SCSI controller types and document the
new type.

The lsisas1068 SCSI controller type was added in ESX 4.0. The VMX
parser reports an error when this controller type is present. This
makes virsh dumpxml fail for every domain that uses this controller
type.

This patch fixes this and adds lsisas1068 to the list of accepted
SCSI controller types.

Reported by Jonathan Kelley.
2010-04-08 12:05:51 +02:00
fba503c368 esx: Report an error for invalid arguments in esxList(Defined)Domains 2010-04-08 11:58:33 +02:00
9cea2af3fc Avoid searching for windres when not building for Windows
Just checking for a windres tool might hit even on Linux systems when
building for Linux (e.g.: when using Gentoo and having built binutils
with multitarget support), and will then fail to link properly at the
end of the build.

* configure.ac: Avoid searching for windres on non windows target
2010-04-08 11:52:46 +02:00
edb9d54bd1 Executable does not belong into repository.
Removing the tests/nwfilterxml2xmltest executable that got in with a previous patch.
2010-04-07 19:52:25 -04:00
3bf24abc8c nwfilter: Support for learning a VM's IP address
This patch implements support for learning a VM's IP address. It uses
the pcap library to listen on the VM's backend network interface (tap)
or the physical ethernet device (macvtap) and tries to capture packets
with source or destination MAC address of the VM and learn from DHCP
Offers, ARP traffic, or first-sent IPv4 packet what the IP address of
the VM's interface is. This then allows to instantiate the network
traffic filtering rules without the user having to provide the IP
parameter somewhere in the filter description or in the interface
description as a parameter. This only supports to detect the parameter
IP, which is for the assumed single IPv4 address of a VM. There is not
support for interfaces that may have multiple  IP addresses (IP
aliasing) or IPv6 that may then require more than one valid IP address
to be detected. A VM can have multiple independent interfaces that each
uses a different IP address and in that case it will be attempted to
detect each one of the address independently.

So, when for example an interface description in the domain XML has
looked like this up to now:

    <interface type='bridge'>
      <source bridge='mybridge'/>
      <model type='virtio'/>
      <filterref filter='clean-traffic'>
        <parameter name='IP' value='10.2.3.4'/>
      </filterref>
    </interface>

you may omit the IP parameter:

    <interface type='bridge'>
      <source bridge='mybridge'/>
      <model type='virtio'/>
      <filterref filter='clean-traffic'/>
    </interface>

Internally I am walking the 'tree' of a VM's referenced network filters
and determine with the given variables which variables are missing. Now,
the above IP parameter may be missing and this causes a libvirt-internal
thread to be started that uses the pcap library's API to listen to the
backend interface  (in case of macvtap to the physical interface) in an
attempt to determine the missing IP parameter. If the backend interface
disappears the thread terminates assuming the VM was brought down. In
case of a macvtap device a timeout is being used to wait for packets
from the given VM (filtering by VM's interface MAC address). If the VM's
macvtap device disappeared the thread also terminates. In all other
cases it tries to determine the IP address of the VM and will then apply
the rules late on the given interface, which would have happened
immediately if the IP parameter had been explicitly given. In case an
error happens while the firewall rules are applied, the VM's backend
interface is 'down'ed preventing it to communicate. Reasons for failure
for applying the network firewall rules may that an ebtables/iptables
command failes or OOM errors. Essentially the same failure reasons may
occur as when the firewall rules are applied immediately on VM start,
except that due to the late application of the filtering rules the VM
now is already running and cannot be hindered anymore from starting.
Bringing down the whole VM would probably be considered too drastic.
While a VM's IP address is attempted to be determined only limited
updates to network filters are allowed. In particular it is prevented
that filters are modified in such a way that they would introduce new
variables.

A caveat: The algorithm does not know which one is the appropriate IP
address of a VM. If the VM spoofs an IP address in its first ARP traffic
or IPv4 packets its filtering rules will be instantiated for this IP
address, thus 'locking' it to the found IP address. So, it's still
'safer' to explicitly provide the IP address of a VM's interface in the
filter description if it is known beforehand.

* configure.ac: detect libpcap
* libvirt.spec.in: require libpcap[-devel] if qemu is built
* src/internal.h: add the new ATTRIBUTE_PACKED define
* src/Makefile.am src/libvirt_private.syms: add the new modules and symbols
* src/nwfilter/nwfilter_learnipaddr.[ch]: new module being added
* src/nwfilter/nwfilter_driver.c src/conf/nwfilter_conf.[ch]
  src/nwfilter/nwfilter_ebiptables_driver.[ch]
  src/nwfilter/nwfilter_gentech_driver.[ch]: plu the new functionality in
* tests/nwfilterxml2xmltest: extend testing
2010-04-07 23:12:21 +02:00
7be5c26d74 xenXMDomainDefineXML: remove dead store and useless/leaky virGetDomain
* src/xen/xm_internal.c (xenXMDomainDefineXML): Remove useless and
leak-inducing call to virGetDomain, as well as decl of now-unused local.
2010-04-07 21:49:15 +02:00
2cdf29eda9 createRawFileOpHook: avoid dead stores
* src/storage/storage_backend.c (createRawFileOpHook): Remove dead
stores and declaration of each stored-to variable.
2010-04-07 21:49:07 +02:00
5874c6de5c qemudDomainGetSecurityLabel: avoid dead store to "type"
* src/qemu/qemu_driver.c (qemudDomainGetSecurityLabel): Remove store
and declaration.
2010-04-07 21:48:55 +02:00
e26997f62b Fix CPU comparison for x86 arch
When comparing a CPU to host CPU, the result would be
VIR_CPU_COMPARE_SUPERSET (or even VIR_CPU_COMPARE_INCOMPATIBLE if strict
match was required) even though the two CPUs were identical.
2010-04-07 21:33:04 +02:00
ce4c82f116 Cleanup x86Compute()
No change in semantics.
2010-04-07 21:32:57 +02:00
71d5686f78 Properly advertise cpuselection guest capability
There's no sense in advertising cpuselection capability when host CPU
is not properly detected and advertised in host capabilities.
2010-04-07 21:32:46 +02:00
f599156641 Don't ignore guest CPU selection when unsupported by HV
When qemu libvirt driver doesn't support guest CPU selection with given
qemu binary, guests requiring specific CPU should fail to start instead
of being silently supplied with a default CPU.
2010-04-07 21:32:46 +02:00
6c5450646c Document all options of virsh dumpxml 2010-04-07 21:32:46 +02:00
60466abbd6 qemuDomainSnapshotLoad: avoid dead store
* src/qemu/qemu_driver.c (qemuDomainSnapshotLoad): Remove dead store
into "snap", as well as its declaration.
2010-04-07 20:39:50 +02:00
dd1a186f77 maint: s/initialis/initializ/
git grep found 12 of the former but 100 of the latter in src/.

* src/remote/remote_driver.c (initialise_gnutls): Rename...
(initialize_gnutls): ...to this.
(doRemoteOpen): Adjust caller.
* src/xen/xen_driver.c (xenUnifiedOpen): Adjust output string.
* src/util/network.c: Adjust comments.
Suggested by Matthias Bolte.
2010-04-07 09:48:07 -06:00
3c8877e743 domain_event.c: don't deref NULL on an OOM error path
* src/conf/domain_event.c (virDomainEventGraphicsNewFromDom):
Return NULL when handling out-of-memory error, rather than
falling through with ev=NULL and then assigning to ev->member.
(virDomainEventGraphicsNewFromObj): Likewise.
2010-04-07 16:20:28 +02:00
f8352e221f nwfiler: fix due to non-symmetric src mac address match in iptables
The attached patch fixes a problem due to the mac match in iptables only
supporting --mac-source and no --mac-destination, thus it not being
symmetric. Therefore a rule like this one

<rule action='drop' direction='out'>
  <all match='no' srcmacaddr='$MAC'/>
</rule>

should only have the MAC match on traffic leaving the VM and not test
for the same source MAC address on traffic that the VM receives.
2010-04-07 06:28:16 -04:00
d33b87268d qemu_driver.c: don't close an arbitrary file descriptor
* src/qemu/qemu_driver.c (qemudStartVMDaemon): Initialize "logfile"
to ensure that we don't use it uninitialized -- thus closing an
arbitrary file descriptor -- in the cleanup block.
2010-04-07 11:19:16 +02:00
2a788c6439 Fix a typo in comment 2010-04-07 10:30:28 +02:00
ef962afb74 Update of the apparmore regression tests
* tests/virt-aa-helper-test: test augmented with hostdev and sdl display
  checks
2010-04-06 23:01:24 +02:00
2df320609a Improve the apparmor example
* examples/apparmor/libvirt-qemu examples/apparmor/usr.sbin.libvirtd
  examples/apparmor/usr.lib.libvirt.virt-aa-helper: Update the examples
2010-04-06 23:01:24 +02:00
1a253b38e2 Improve virt-aa-helper to handle SDL graphics and cleanups
* src/security/virt-aa-helper.c: add support for SDL devices and 3
  code cleanups
2010-04-06 23:01:23 +02:00
1efb623674 Adjust virt-aa-helper to handle pci devices
* src/security/virt-aa-helper.c: adjust virt-aa-helper to handle pci
  devices. Update valid_path() to have an override array to check against,
  and add "/sys/devices/pci" to it. Then rename file_iterate_cb() to
  file_iterate_hostdev_cb() and create file_iterate_pci_cb() based on it
2010-04-06 23:01:23 +02:00
2aca94bfd3 Add backingstore support to apparmor
adjust virt-aa-helper to handle backing store
* src/security/virt-aa-helper.c: look for backing store metadata
  for disk definitions.
2010-04-06 23:01:23 +02:00
a331b909c5 Add VIR_DOMAIN_XML_INACTIVE flag when parsing domain XML
To avoid an error when hitting the <seclabel...> definition
* src/security/virt-aa-helper.c: add VIR_DOMAIN_XML_INACTIVE flag
  to virDomainDefParseString
2010-04-06 23:01:23 +02:00
ba32e11d41 virt-aa-helper should not fail if profile was removed
Don't exit with error if the user unloaded the profile outside of
 libvirt
* src/security/virt-aa-helper.c: check the exit error from apparmor_parser
  before exiting with a failure
2010-04-06 23:01:23 +02:00
e68792c112 Do nor clear caps when invoking virt-aa-helper
The calls to virExec() in security_apparmor.c when
invoking virt-aa-helper use VIR_EXEC_CLEAR_CAPS. When compiled without
libcap-ng, this is not a problem (it's effectively a no-op) but with
libcap-ng this causes MAC_ADMIN to be cleared. MAC_ADMIN is needed by
virt-aa-helper to manipulate apparmor profiles and without it VMs will
not start[1]. This patch calls virExec with the default VIR_EXEC_NONE
instead.
* src/security/security_apparmor.c: fallback to VIR_EXEC_NONE flags for
  virExec of virt_aa_helper
2010-04-06 23:01:23 +02:00
94dcf953ff Fix 'avialable' typo
Reported by Paul Jenner
2010-04-06 22:57:39 +02:00
36bcd7026b build: avoid autogen on 'make clean'
Tested by running 'git submodule foreach git pull origin master' and
'git add .gnulib', then seeing that 'make clean' skips autogen
although 'make' properly runs it.

* cfg.mk (_clean_requested): New check, to speed up 'make clean'
even if gnulib submodule is outdated.
Suggested by Daniel P. Berrange.
2010-04-06 14:43:47 -06:00
479dfbb084 Fix for nwfilter: Add filter schema for nwfilter XML, extend domain XML schema
Fixing the regular expressions for variables where the first letter must be a $.
2010-04-06 16:40:49 -04:00
0d7d699795 macvtap: Remove virConnectPtr from ReportError
Also rename ReportError to macvtapError.
2010-04-06 20:00:30 +02:00
1870e70707 phyp: Remove virConnectPtr from PHYP_ERROR 2010-04-06 19:48:51 +02:00
ed510fce9c virterror.c: avoid erroneous case "fall-through"
* src/util/virterror.c (virErrorMsg): Insert missing "break;"
2010-04-06 19:34:20 +02:00
028db0bf5d esx: Mark error messages for translation
Also define ESX_ERROR and ESX_VI_ERROR in a central place, instead of
defining them in each source file.

Add ESX_ERROR and ESX_VI_ERROR to the msg_gen_function list in cfg.mk.

Update po/POTFILES.in accordingly.
2010-04-06 19:24:24 +02:00
dbfa2ff572 vbox: Mark all error messages for translation
Add vboxError to the msg_gen_function list in cfg.mk.
2010-04-06 19:02:58 +02:00
8cf0ed02be nwfilter: Add filter schema for nwfilter XML, extend domain XML schema
This patch adds a relaxng nwfilter schema along with a test that
verifies all the test output XML against the schema. The input XMLs
contain a lot of intentional out-of-range values that make them fail the
schema verification, so I am not verifying against those.
2010-04-06 11:09:46 -04:00
552bdb9b35 nwfilter: Fix instantiated layer 2 rules for 'inout' direction
With Eric Blake's suggestions applied.

The following rule for direction 'in'

<rule direction='in' action='drop'>
  <mac srcmacaddr='1:2:3:4:5:6'/>
</rule>

drops all traffic from the given mac address.
The following rule for direction 'out'

<rule direction='out' action='drop'>
  <mac dstmacaddr='1:2:3:4:5:6'/>
</rule>

drops all traffic to the given mac address.
The following rule in direction 'inout'

<rule direction='inout' action='drop'>
  <mac srcmacaddr='1:2:3:4:5:6'/>
</rule>

now drops all traffic from and to the given MAC address.
So far it would have dropped traffic from the given MAC address
and outgoing traffic with the given source MAC address, which is not useful
since the packets will always have the VM's MAC address as source
MAC address. The attached patch fixes this.

This is the last bug I currently know of and want to fix.
2010-04-06 10:40:35 -04:00
9f337ef752 virsh: improve documentation
Document several missing commands.  There's more work that could be
done, but incremental improvements is better than no patch at all.

* tools/virsh.pod (autostart, connect): Improve grammar.
(create): Improve example.
(domjobabort, domjobinfo, domxml-from-native, domxml-to-native):
Document.
(storage pool commands): New section.
2010-04-06 08:00:25 -06:00
28b9a6c769 Clarify an error message in setmem.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:56:44 -04:00
6f17a5d166 Fix up comments for isEncrypted, isSecure, domainIsActive,
and domainIsPersistent.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:51:24 -04:00
6449cb9014 Document snapshot virsh commands in the man page.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:50:43 -04:00
23b1e5c0b0 Better error reporting in virsh.
When hitting failures in virsh, a common idiom is
to jump to a cleanup label, free some resources, and
then return a FALSE error code to vshCommandRun.
In theory, vshCommandRun is then supposed to print
out the last error.  The problem is that many of
the cleanup paths have library calls to free resources,
and all of those library calls clear out the last error.
This is leading to situations where no error is being
reported at all.

This patch remedies the situation somewhat by
printing out the errors inside the command methods
themselves when we know it will go through a cleanup
path that will lose the error.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:48:13 -04:00
86fe2ba6dc Website documentation for the snapshot XML.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:44:03 -04:00
fbf9fcbff4 Increase the number of available VNC ports.
When starting up qemu VNC autoport guests, we were
only looking through ports 5900 to 6000, meaning we
were limited to 100 total clients.  Increase that
limit to 65535 (the last available port), so we can
have up to 59635 VNC autoport guests.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-06 09:40:17 -04:00
f7d32ce260 This patch fixes some compilation issues for the RHEL5 build. I am also removing the IPV6 constant where it appears in the wrong place. 2010-04-06 06:29:00 -04:00
84fa113217 Fix compiler warning about unused conn parameter
This only affects builds without NUMA support.
2010-04-06 11:47:28 +02:00
fcd103bb2a openvz: Remove virConnectPtr from openvzError
Also remove unused enum values OPENVZ_WARN and OPENVZ_ERR.
2010-04-06 02:04:50 +02:00
a4f9af057a one: Remove virConnectPtr from oneError 2010-04-06 02:03:36 +02:00
a6c77af617 uml: Remove virConnectPtr from umlReportError 2010-04-06 02:03:34 +02:00
e9125be594 Remove virConnectPtr from eventReportError 2010-04-06 02:02:24 +02:00
5a19c24611 Remove virConnectPtr from virLibConnError 2010-04-06 02:01:51 +02:00
b290e48cf7 xen: Remove virConnectPtr from xenUnifiedError 2010-04-06 01:56:01 +02:00
6c175fa3d1 Remove virConnectPtr from nodeReportError 2010-04-06 01:47:51 +02:00
8bd8bcaca8 netcf: Remove virConnectPtr from interfaceReportError 2010-04-06 01:47:02 +02:00
7ece483dce xen: Remove virConnectPtr from virXenInotifyError 2010-04-06 01:46:42 +02:00
67f34cd67b xen: Remove virConnectPtr from virXenStoreError 2010-04-06 01:46:02 +02:00
68d5d96bce xen: Remove virConnectPtr from virXenError/virXenErrorFunc 2010-04-06 01:45:47 +02:00
f2192637b0 xen: Remove virConnectPtr from virXMError 2010-04-06 01:44:51 +02:00
5cec7af469 xen: Remove virConnectPtr from virXendError 2010-04-06 01:43:51 +02:00
2127b42b46 proxy: Remove virConnectPtr from virProxyError 2010-04-06 01:43:23 +02:00
a3884f8705 vbox: Remove virConnectPtr from vboxError 2010-04-06 01:41:58 +02:00
1c91a0b44e test: Remove virConnectPtr from testError 2010-04-06 01:41:58 +02:00
49411f029a Remove unnecessary trailing \n in log messages 2010-04-06 01:41:58 +02:00
d2e0bd1779 Fix compiler warning about non-literal format string 2010-04-06 01:38:53 +02:00
45274d4121 This patch removes the virConnectPtr parameter from all functions where it's not necessary starting out with removing it as a parameter to the error reporting function. 2010-04-05 12:34:55 -04:00
88151c7cbc Snapshot virsh implementation.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:25:02 -04:00
c572222a14 Snapshots for VBox 2010-04-05 10:24:57 -04:00
462c74c38a Snapshot QEMU driver.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:51 -04:00
32c3c1f0b7 Only assign newDef when we have a new def.
While playing around with def/newDef with the qemu code,
I noticed that newDef was *always* getting set to a value,
even when I didn't redefine the domain.  I think the problem
is the virDomainLoadConfig is always doing virDomainAssignDef
regardless of whether the domain already exists in the hashtable.
In turn, virDomainAssignDef is assigning the definition (which
is actually a duplicate) to newDef.  Fix this so that newDef stays
NULL until we actually have a new def.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:44 -04:00
9b55a52b4f Snapshot internal methods.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:38 -04:00
2f992d4be4 Snapshot API framework.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-05 10:24:34 -04:00
1bbe12de44 Clarified error message
* Since the file pattern matches RNG schemas as well as C sources, the error message should mention both.
2010-04-05 10:24:13 -04:00
5dac5970a5 Eliminate compiler warning about non-const format string 2010-04-04 22:58:33 -04:00
905709500a xenapi: Add managedsave entries to the driver struct
Commit 15c647a91e added the new
managedsave entries to all driver structs except the XenAPI one.
2010-04-04 18:23:52 +02:00
a44b23ba63 Get rid of the regular expressions when evaluating variable names and
values. Rather use the strspn() function. Along with this cleanup the
initialization function for the code that used the regular expression
can also be removed.
2010-04-04 10:34:52 -04:00
5288b2ad8e nwfilter: Fix random index in virNWFilterRuleDefDetailsFormat
An uninitialized int value was used to index an array. This can
result in a segfault in nwfilterxml2xmltest.
2010-04-04 16:06:56 +02:00
1b747f0ded xenapi: Fix uninitialized variable warning 2010-04-04 16:06:39 +02:00
d068f9609c Add a managedsave command to virsh
This command implements the managed save operation

* tools/virsh.c: new command
* tools/virsh.pod: documentation
2010-04-04 11:36:59 +02:00
6e41f30efc Implement managed save operations for qemu driver
The images are saved in /var/lib/libvirt/qemu/save/
and named $domainname.save . The directory is created appropriately
at daemon startup. When a domain is started while a saved image is
available, libvirt will try to load this saved image, and start the
domain as usual in case of failure. In any case the saved image is
discarded once the domain is created.

* src/qemu/qemu_conf.h: adds an extra save path to the driver config
* src/qemu/qemu_driver.c: implement the 3 new operations and handling
  of the image directory
2010-04-04 11:36:46 +02:00
7a3da17a58 Implement remote protocol for managed save
* src/remote/remote_protocol.x src/remote/remote_protocol.h
  src/remote/remote_protocol.c src/remote/remote_driver.c: add the entry
  points in the remote driver
* daemon/remote.c daemon/remote_dispatch_args.h
  daemon/remote_dispatch_prototypes.h daemon/remote_dispatch_table.h:
  and implement the daemon counterpart
2010-04-04 11:36:33 +02:00
15c647a91e Add managed save API entry points
virDomainManagedSave() is to be run on a running domain. Once the call
complete, as in virDomainSave() the domain is stopped upon completion,
but there is no restore counterpart as any order to start the domain
from the API would load the state from the managed file, similary if
the domain is autostarted when libvirtd starts.
Once a domain has restarted his managed save image is destroyed,
basically managed save image can only exist for a stopped domain,
for a running domain that would be by definition outdated data.

* include/libvirt/libvirt.h.in src/libvirt.c src/libvirt_public.syms:
  adds the new entry points virDomainManagedSave(),
  virDomainHasManagedSaveImage() and virDomainManagedSaveRemove()
* src/driver.h src/esx/esx_driver.c src/lxc/lxc_driver.c
  src/opennebula/one_driver.c  src/openvz/openvz_driver.c
  src/phyp/phyp_driver.c src/qemu/qemu_driver.c src/vbox/vbox_tmpl.c
  src/remote/remote_driver.c src/test/test_driver.c src/uml/uml_driver.c
  src/xen/xen_driver.c: add corresponding new internal drivers entry
  points
2010-04-04 11:07:48 +02:00
d002c250cd build: improve check for out-of-date .gnulib submodule
git reset --hard 96e5a2d4d5
./autogen.sh
make -s
git pull
make -s    <-- expecting auto-bootstrap here, doesn't happen

Use git diff to expose whether the submodule has untracked changes,
which are typical on an incremental pull if .gnulib was updated but
the user did not manually run 'git submodule update'.

After this patch is applied, I encountered a new problem when
following the reproducing pattern.  Basically, the change to .gnulib
between libvirt's commit 96e5a2d4 and this patch introduced a change
to sys_ioctl.in.h, but gnulib (intentionally) does not make the
replacement headers depend on Makefile changes.  Therefore, I ended up
with the generated replacement header being broken:
gnulib/lib/sys/ioctl.h complained about a use of @.  But that seems
like something that should be fixed upstream in gnulib's bootstrap
script (that is, when doing a gnulib update, all files created from
.in.h file should probably be deleted).  Without the benefit of that
proposed gnulib fix, I worked around the problem by manually removing
the stale gnulib/lib/sys/ioctl.h.

* autogen.sh (t): Also run bootstrap if the gnulib submodule needs
to be updated.
* cfg.mk (_autogen): Likewise.
Reported by Matthias Bolte.
2010-04-02 15:49:32 -06:00
8d30e5f74d Use the virStrToLong_ui() function rather than the virStrToLong_i()
where possible.
2010-04-02 15:02:27 -04:00
d9292cfefb The attached patch optimizes the validation of the name of an interface. 2010-04-02 14:57:01 -04:00
8459218cbc This patch adds a couple of test cases for the XML parsing test suite covering various filterable protocols. For each test case an input XML and an output XML is provided checking the input XML after parsing and converting back into XML against the exepcted output XML.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-04-02 13:28:28 -04:00
b3e8f9f415 The following issues are fixed in the patch below:
- ebtables requires that some of the command line parameters are passed as hex numbers; so have those attributes call a function that prints 16 and 8 bit integers as hex nunbers.

- ip6tables requires '--icmpv6-type' rather than '--icmp-type'

- ebtables complains about protocol identifiers lower than 0x600, so already discard anything lower than 0x600 in the parser

- make the protocol entry types more readable using a #define for its entries

- continue parsing a filtering rule even if a faulty entry is encountered; return an error value at the end and let the caller decide what to do with the rule's object

- fix an error message
2010-04-02 13:21:10 -04:00
e7168f7965 build: import latest gnulib
A lot of syntax check rules have to be rewritten, but the
result is easier to maintain.  I tested each syntax rule
by intentionally introducing a temporary violation of the rule.
Additionally, some false positives for unmarked_diagnostics
crept in, and an improved copyright_format test caught some bugs.

* .gnulib: Update to latest.
* cfg.mk (sc_prohibit_test_minus_ao): Delete, it was moved into
gnulib's maint.mk.
(sc_avoid_write, sc_prohibit_strcmp_and_strncmp)
(sc_prohibit_asprintf, sc_prohibit_strncpy, sc_prohibit_readlink)
(sc_prohibit_gethostname, sc_prohibit_gettext_noop)
(sc_prohibit_VIR_ERR_NO_MEMORY, sc_prohibit_nonreentrant)
(sc_prohibit_ctype_h, sc_TAB_in_indentation)
(sc_avoid_ctype_macros)
(sc_prohibit_virBufferAdd_with_string_literal)
(sc_prohibit_gethostby, sc_copyright_format): Rewrite in terms of
new maint.mk macros.
(sc_libvirt_unmarked_diagnostics): Fix whitespace.
* .x-sc_unmarked_diagnostics: New file.
* tests/object-locking.ml: Fix copyright.
* tools/virt-pki-validate.in: Likewise.
* tools/virt-xml-validate.in: Likewise.
2010-04-02 10:18:55 -06:00
96e5a2d4d5 Add a missing break statement to nwfilter errors.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-02 10:13:44 -04:00
fba3dfd156 Make virDomainLoadConfig static.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-02 10:13:07 -04:00
f76c3493d8 VBox: Fix use of uninitialized value 2010-04-02 15:59:23 +02:00
4ee2b31804 Changes to clock timer XML to match final design.
The clock timer XML is being updated in the following ways (based on
further off-list discussion that was missed during the initial
implementation):

1) 'wallclock' is changed to 'track', and the possible values are 'boot'
 (corresponds to old 'host'), 'guest', and 'wall'.

2) 'mode' has an additional value 'smpsafe'

3) when tickpolicy='catchup', there can be an optional sub-element of
   timer called 'catchup':

   <catchup threshold=123 slew=120 limit=10000/>

Those three values are all longs, always optional, and if they are present,
they are positive. Internally, 0 indicates "unspecified".

* docs/schemas/domain.rng: updated RNG definition to account for changes

* src/conf/domain_conf.h: change the C struct and enums to match changes.

* src/conf/domain_conf.c: timer parse and format functions changed to
                          handle the new selections and new element.

* src/libvirt_private.syms: *TimerWallclock* changes to *TimerTrack*

* src/qemu/qemu_conf.c: again, account for Wallclock --> Track change.
2010-04-02 09:50:29 -04:00
8a7b4be5ab Allow domain disk images on root-squash NFS to coexist with security driver.
(suggested by Daniel Berrange, tested by Dan Kenigsberg)

virStorageFileGetMetadata will fail for disk images that are stored on
a root-squash NFS share that isn't world-readable.
SELinuxSetSecurityImageLabel is called during the startup of every
domain (as long as security_driver != "none"), and it will propogate
the error from virStorageFileGetMetadata, causing the domain startup
to fail. This is, however, a common scenario when qemu is run as a
non-root user and the disk image is stored on NFS.

Ignoring this failure (which doesn't matter in this case, since the
next thing done by SELinuxSetSecurityImageLabel - setting the file
context - will also fail (and that function already ignores failures
due to root-squash NFS) will allow us to continue bringing up the
domain. The result is that we don't need to disable the entire
security driver just because a domain's disk image is stored on
root-squashed NFS.
2010-04-02 09:39:20 -04:00
78151ec96e Eliminate compile warnings in nwfilter error log calls 2010-04-02 09:39:00 -04:00
d62f4c36c2 Don't use virFileReadLimFD in qemuDomainRestore.
virFileReadLimFD is a poor fit for reading the header
of the restore file.  The problem is that virFileReadLimFD
returns an error when there is more data after the amount
you ask to read, but that is *expected* in this case.

This patch is essentially a revert of
1a4d5c9543, but I don't think
that commit does what it says anyway.  It purports to prevent
an unwarranted OOM error, but since virFileReadLimFD will
allocate memory up to the maximum anyway, the upper limit
on the total amount of memory allocated is the same for either
the old version or the new version.  Since the old saferead
actually works and virFileReadLimFD does not, revert to
using saferead.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-02 09:23:41 -04:00
320ea3a47e Only parse 'CPU XML' in virCPUDefParseXML()
Received report of user crashing libvirtd with

virsh capabilities > capabilities.xml
virsh cpu-compare capabilities.xml

While user has been informed about proper usage of cpu-compare,
segfaulting libvirt should be avoided.

Do not parse CPU definition in virCPUDefParseXML() if XML is not
a 'cpu' node.
2010-04-01 14:04:43 +02:00
f983c32675 Keep build quiet for generated file
Adds $(AM_V_GEN) to many more manual makefile.am rules that
were generating files
2010-04-01 12:35:51 +01:00
cd2404a3c3 Keep track of guest paused state after disk IO / watchdog events
When a watchdog/IO error occurs, one of the possible actions that
QEMU might take is to pause the guest. In this scenario libvirt
needs to update its internal state for the VM, and emit a
lifecycle event:

  VIR_DOMAIN_EVENT_SUSPENDED

with a detail being one of:

  VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
  VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG

To future proof against possible QEMU support for multiple monitor
consoles, this patch also hooks into the 'STOPPED' event in QEMU
and emits a generic VIR_DOMAIN_EVENT_SUSPENDED_PAUSED event

* include/libvirt/libvirt.h.in: Add VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
* src/qemu/qemu_driver.c: Update VM state to paused when IO error
  or watchdog events occurrs
* src/qemu/qemu_monitor_json.c: Fix typo in disk IO event name
2010-04-01 12:35:46 +01:00
d13eb9fc95 Replace sscanf in PCI device address parsing
This also fixes a problem with MinGW's GCC on Windows. GCC complains
about the L modifier being unknown.

Parsing in pciIterDevices is stricter now and doesn't accept trailing
characters after the actual <domain>:<bus>:<slot>.<function> sequence
anymore.

Parsing in pciWaitForDeviceCleanup is also stricter now and expects
the <start>-<end> : <domain>:<bus>:<slot>.<function> sequence to be
terminated by \n.

Change domain from unsigned long long to unsigned int in
pciWaitForDeviceCleanup, because everywhere else domain is handled as
unsigned int too.
2010-04-01 12:53:41 +02:00
57dab74804 xen: Use virStrToLong_i instead of sscanf for XenD port parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
82cb2e73aa xenapi: Use virStrToLong_i instead of sscanf for CPU map parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
1778da7185 openvz: Use strtok_r instead of sscanf for VPS UUID parsing
Also free 2k stack space.
2010-04-01 12:53:41 +02:00
00e00510c5 xen: Use virParseMacAddr instead of sscanf
This also fixes a bug in xenXMDomainConfigParse where uninitialized
memory would be used as MAC address if sscanf fails.
2010-04-01 12:53:41 +02:00
2f047d4816 vbox: Replace atoi with virStrToLong_i
Parsing is stricter now and doesn't accept trailing characters
after the actual value or non-number strings anymore. atoi just
returns 0 in case it cannot parse a number from the given string.
Now an error is reported for such a string.
2010-04-01 12:53:41 +02:00
73b45bfbff cgroup: Replace sscanf with virStrToLong_ll
The switch from %lli to %lld in virCgroupGetValueI64 is intended,
as virCgroupGetValueU64 uses base 10 too, and virCgroupSetValueI64
uses %lld to format the number to string.

Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
56bac4a221 Refactor major.minor.micro version parsing into a function
virParseVersionString uses virStrToLong_ui instead of sscanf.

This also fixes a bug in the UML driver, that always returned 0
as version number.

Introduce STRSKIP to check if a string has a certain prefix and
to skip this prefix.
2010-04-01 12:53:41 +02:00
ea54570efb Replace sscanf in nwfilter rule parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.
2010-04-01 12:53:41 +02:00
2072d63c5b Replace sscanf in legacy device address parsing
Parsing is stricter now and doesn't accept trailing characters
after the actual <domain>:<bus>:<slot> sequence anymore.
2010-04-01 12:52:19 +02:00
e813200714 While writing a couple of test cases for the nwfilter's XML parser I
found some cases where the output ended up not looking as expected. So
the following changes are in the patch below:

- if the protocol ID in the MAC header is an integer, just write it into
the datastructure without trying to find a corresponding string for it
and if none is found failing
- when writing the protocol ID as string, simply write it as integer if
no corresponding string can be found
- same changes for arpOpcode parsing and printing
- same changes for protocol ID in an IP packet
- DSCP value needs to be written into the data structure
- IP protocol version number is redundant at this level, so remove it
- parse the protocol ID found inside an IP packet not only as string but
also as uint8
- arrange the display of the src and destination masks to be shown after
the src and destination ip address respectively in the XML
- the existing libvirt IP address parser accepts for example '25' as an
IP address. I want this to be parsed as a CIDR type netmask. So try to
parse it as an integer first (CIDR netmask) and if that doesn't work as
a dotted IP address style netmask.
- instantiation of rules with MAC masks didn't work because they weren't
printed into a buffer, yet.
2010-04-01 06:37:26 -04:00
6cbc33063a ESX test case needs '/' in interface name
To fix an ESX test case, valid interface names need '/' as valid letter.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-04-01 12:15:11 +02:00
a77821c864 Fix linker errors in proxy
domain_conf.c:494: undefined reference to 'virNWFilterHashTableFree'
domain_conf.c:5107: undefined reference to 'virNWFilterFormatParamAttributes'

Add missing source to the proxy and disable XML parsing code in
nwfilter_params.c for a proxy build.
2010-03-31 23:21:34 +02:00
a792bf240f build: more fallout from test -a
* cfg.mk (sc_prohibit_test_minus_ao): Also check for [.
* docs/Makefile.am (%.html, html/index.html): Avoid non-portable
test usage.
* libvirt.spec.in (%post): Likewise.
* tools/virt-pki-validate.in (servercert.pem): Likewise.
* configure.ac (LOGNAME): Use test, not [, in files processed by
autoconf.
Detected by Matthias Bolte.
2010-03-31 15:18:13 -06:00
eff24046d8 Fix apibuild.py warning about virNWFilterLookupByUUIDString
The function name was written with capital I in the Filter part.
2010-03-31 18:11:06 +02:00
6fc93f1e75 website: Add archive link for libvirt-users list 2010-03-31 18:11:06 +02:00
9d6614df86 maint: remove redundant tests after virStrToLong
virStrToLong* guarantees (via strtol) that the end pointer will be set
to the point at which parsing stopped (even on failure, this point is
the start of the input string).

* src/esx/esx_driver.c (esxGetVersion): Remove pointless
conditional.
* src/qemu/qemu_conf.c (qemuParseCommandLinePCI)
(qemuParseCommandLineUSB, qemuParseCommandLineSmp): Likewise.
* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetMigrationStatus): Likewise.
2010-03-31 08:58:46 -06:00
8d773c0f4f maint: update AUTHORS
* AUTHORS: Add recent contributors.
2010-03-31 08:50:42 -06:00
0327ed8718 virConnectGetLibVersion: Avoid error message on success.
* src/libvirt.c (virConnectGetLibVersion): Don't emit error on
success.
2010-03-31 08:47:33 -06:00
890af4ca8f virsh: add 'exit' as an alias for 'quit'
Call me lazy: some shells use exit (e.g. sh), others use quit (e.g. ftp),
but I never remember which.  So it's faster to write a patch to make
virsh take both than it is to take a 50-50 guess, and get it wrong
in half of my attempts.

* tools/virsh.c (commands): Add 'exit'.
* tools/virsh.pod: Document it.
2010-03-31 08:40:06 -06:00
3cda0eb487 maint: fix cpp indentation syntax-check failure
* src/esx/esx_vi_types.h: Filter through cppi.
2010-03-31 16:32:38 +02:00
00195f9f8d maint: mark xenapiSessionErrorHandler messages for translation
* cfg.mk (msg_gen_function): Add xenapiSessionErrorHandler.
* po/POTFILES.in: Add src/xenapi/xenapi_driver.c
* src/xenapi/xenapi_driver.c: Mark strings for translation.
* src/xenapi/xenapi_utils.c (xenapiUtil_ParseQuery):
2010-03-31 16:30:41 +02:00
2f646237da Blank out invalid interface names with escaped letters etc.
Check that interface names only contain valid characters. Blank them out
otherwise.
Valid characters in this code are currently a-z,A-Z,0-9, '-' and '_'.
2010-03-31 10:22:10 -04:00
ffbfd2c813 Add virt-aa-helper and secaatest to .gitignore 2010-03-31 13:36:54 +02:00
63c0c9a77f esx: Remove redundant semicolons 2010-03-31 13:36:54 +02:00
50723581b0 esx: Generate most SOAP mapping and improve inheritance handling
The Python script generates the mappings based on the type descriptions
in the esx_vi_generator.input file.

This also improves the inheritance handling and allows to get rid of the
ugly, inflexible, and error prone _base/_super approach. Now every struct
that represents a SOAP type contains a _type member, that allows to
recreate C++-like dynamic dispatch for "method" calls in C.
2010-03-31 13:36:54 +02:00
b4b0949dd7 Distribute nwfilter xml files and add them to rpm
* examples/xml/nwfilter/Makefile.am: add all xml to the distribution
* libvirt.spec.in: reference them from the rpm spec file to have them
  available in the main libvirt package
2010-03-31 10:20:22 +02:00
25d5e16e9e Make sure nwfilter headers are part of distribution
* src/Makefile.am: adds a few missing header files in the associated
  file variables, it's needed otherwise the missing headers breaks
  compilation from a distribution tarball
2010-03-31 10:19:06 +02:00
7b5114f62b maint: show which compiler warning triggered
* acinclude.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-fdiagnostics-show-option.
2010-03-30 11:29:09 -06:00
4eb8022260 build: automate the rerun of autogen.sh
Automate the reuse of autogen.sh, rather than just erroring out.

* cfg.mk (_update_required): Run autogen.sh, rather than just
warning about it.
(_autogen): New target.
2010-03-30 11:29:09 -06:00
062b0aa33b A cosmetic change that makes the entries in the int-2-string maps look
more readable. Add some missing entries: ipv6 and icmpv6.
2010-03-30 11:42:03 -04:00
0e0f6021ce Use libvirt's existing ipv6/ipv4 parser/printer rather than self-written ones
This patch changes the network filtering code to use libvirt's existing
IPv4 and IPv6 address parsers/printers rather than my self-written ones.

I am introducing a new function in network.c that counts the number of
bits in a netmask and ensures that the given address is indeed a netmask,
return -1 on error or values of 0-32 for IPv4 addresses and 0-128 for
IPv6 addresses. I then based the function checking for valid netmask
on invoking this function.
2010-03-30 11:18:04 -04:00
bc2102104f Add ip6tables support for IPv6 filtering
This patch adds IPv6 filtering support for the following protocols:
- tcp-ipv6
- udp-ipv6
- udplite-ipv6
- esp-ipv6
- ah-ipv6
- sctp-ipv6
- all-ipv6
- icmpv6

Many of the IPv4 data structure could be re-used for IPv6 support.
Since ip6tables also supports pretty much the same command line parameters
as iptables does, also much of the code could be re-used and now
command lines are invoked with the ip(6)tables tool parameter passed
through the functions as a parameter.
2010-03-30 10:36:35 -04:00
0af0ded038 Remove driver dependency from nwfilter_conf.c
This patch removes the driver dependency from nwfilter_conf.c and moves
a callback function calling into the driver into
nwfilter_gentech_driver.c and passes a pointer to that callback function
upon initialization of nwfilter_conf.c.
2010-03-30 10:25:22 -04:00
285d38931f Add support for so-far missing protocols for iptables filtering
This patch adds filtering support for the so-far missing protocols 'ah',
'esp' and 'udplite'.
2010-03-30 10:16:40 -04:00
0ec5cd0704 Fix daemon hook script initialization
* daemon/libvirtd.c: we should error out only if virHookInitialize()
  return value is negative
2010-03-30 15:06:13 +02:00
8bf6799b09 Implement the qemu-kvm backend of clock timer elements
Since the timers are defined to cover all possible config cases for
several different hypervisors, many of these possibilities generate an
error on qemu. Here is what is currently supported:

RTC: If the -rtc commandline option is available, allow setting
"clock=host"
     or "clock=vm" based on the rtc timer clock='host|guest' value. Also
     add "driftfix=slew" if the tickpolicy is 'catchup', or add nothing
if
     tickpolicy is 'delay'. (Other tickpolicies will raise an error).

     If -rtc isn't available, but -rtc-td-hack is, add that option
     if the tickpolicy is 'catchup', add -rtc-td-hack, if it is 'delay'
     add nothing, and if it's anything else, raise an error.

PIT: If -no-kvm-pit-reinjection is available, and tickpolicy is
     'delay', add that option. if tickpolicy is 'catchup', do
     nothing. Anything else --> raise an error.

     If -no-kvm-pit-reinjection *isn't* available, but -tdf is, when
     tickpolicy is 'catchup' add -tdf. If it's 'delay', do
     nothing. Anything else --> raise an error.

     If neither of those commandline options is available, and
     tickpolicy is anything other than 'delay' (or unspecified), raise
     an error.

HPET: If -no-hpet flag is available and present='no', add -no-hpet.
      If -no-hpet is not available, and present='yes', raise an error.
      If present is unspecified, the default is to do whatever this
      particular qemu does by default, so don't raise an error.

All other timer types are unsupported by QEMU, so they will raise an
error.

* src/qemu/qemu_conf.c: extend qemuBuildClockArgStr() to generate the
  command line arguments for the new options
2010-03-30 13:57:40 +02:00
0fdf649672 Add flags to indicate presence of timekeeping-related qemu options
* src/qemu/qemu_conf.h: define 4 new flags
* src/qemu/qemu_conf.c: check the help text of qemu for presence of
                        features indicated by each flag.
* tests/qemuhelptest.c: add appropriate flags into the masks for each test
2010-03-30 13:57:40 +02:00
188af565dd Add timer element to domain schema
timers are sub-elements of clocks. A clock can have zero or more
instances of timer. Within the timer, only the name attribute is
required; all other attributes are optional.

A simpler representation of a timer element is:

  <timer name='platform|pit|rtc|hpet|tsc'
         wallclock='host|guest'
         tickpolicy='delay|catchup|merge|discard'
         frequency='123'
         mode='auto|native|emulate|paravirt'
         present='yes|no'/>

frequency is a ulong. All other attributes are simple enums.
2010-03-30 13:57:40 +02:00
92a9e5df63 Implement XML parser/formatter for "timer" subelement of domain clock
This extension is described in

http://www.redhat.com/archives/libvir-list/2010-March/msg00304.html

Currently all attributes are optional, except name.

* src/conf/domain_conf.h: add data definition for virDomainTimerDef
  and add a list of them to virDomainClockDef
* src/conf/domain_conf.c: XML parser and formatter for a timer inside a clock
* src/libvirt_private.syms: add new Timer enum helper functions to symbols
2010-03-30 13:57:40 +02:00
99123ba012 Fix QEMU cpu affinity at startup to include all threads
The QEMU cpu affinity is used in NUMA scenarios to ensure that
guest memory is allocated from a specific node. Normally memory
is allocate on demand in vCPU threads, but when using hugepages
the initial thread leader allocates memory upfront. libvirt was
not setting affinity of the thread leader, or I/O threads. This
patch changes the code to set the process affinity in between
the fork()/exec() of QEMU. This ensures that every single QEMU
thread gets the affinity

* src/qemu/qemu_driver.c: Set affinity on entire QEMU process
  at startup
2010-03-30 12:03:37 +01:00
05e15ff812 Updating the commiters list
Laine Stump, Stefan Berger, Eric Blake now have commit rights !
2010-03-30 11:32:06 +02:00
f3661756c1 virsh: support VISUAL, and allow metacharacters in EDITOR
Common Unix practice is to prefer VISUAL over EDITOR, particularly if
the editor of choice spawns a new window.  Thus, it is also common to
see settings like EDITOR='emacs -nw', with the expectation that the
shell will parse this as an argument to 'emacs' and not try to invoke
a file containing a space.

If a user puts junk in EDITOR, they deserve what they get (much more
than virsh will misbehave); furthermore, sudo scrubs EDITOR by
default.  So the blind use of metacharacters in EDITOR should not be
considered too much of a security issue.

* tools/virsh.c (editFile): Prefer VISUAL over EDITOR.  Don't
reject shell metacharacters in EDITOR.
* tools/virsh.pod (edit, net-edit, ENVIRONMENT): Document VISUAL.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=487738.
2010-03-29 16:38:51 -06:00
b522264b40 virsh: improve man page
* tools/virsh.pod: (DESCRIPTION): Improve grammar.  Mention other drivers.
(ENVIRONMENT): Document EDITOR.
(COPYRIGHT): Bump.
2010-03-29 16:38:51 -06:00
7fb3e43d36 Add dummy nwfilter driver to test driver
This patch adds a dummy nwfilter driver to the test driver so that the
int-overflow test passes without modifications.
2010-03-29 17:09:20 -04:00
ad8bf13f7d Fix "make check" run requesting authentication
This patch fixes the 'make check' runs for me which, under certain
circumstances and login configurations, did invoke popups requesting
authentication. I removed the parameter conn from being passed into the
error reporting function.

* src/conf/nwfilter_conf.h src/conf/nwfilter_conf.c: remove conn from
  error reporting parameters.
2010-03-29 19:23:53 +02:00
5bbde877e7 Fix a merge error leftover 2010-03-29 18:27:12 +02:00
86415b2d26 Add script hook support to the LXC driver
Right now this implements only 2 basic hooks:
- before the lxc control process is being launched
- after the lxc control process is terminated
the XML description of the domain is passed to the hook script stdin
/etc/libvirt/hook/lxc

* src/lxc/lxc_driver.c: implement synchronous script hooks for LXC
  at domain startup and end
2010-03-29 18:21:26 +02:00
668150fc3d Add script hook support to the QEmu driver
Right now this implements only 2 basic hooks:
- before the qemu process is being launched
- after the qemu process is terminated
the XML description of the domain is passed to the hook script stdin
/etc/libvirt/hook/qemu

* src/qemu/qemu_driver.c: implement synchronous script hooks for QEmu
  at domain startup and end
2010-03-29 18:21:26 +02:00
53456e62ed Add the script hook support to the libvirt daemon
It supports 3 kind of probing times, at daemon startup, when the
daemon reloads its drivers on SIGHUP and when the daemon exits

* daemon/libvirtd.c: daemon hooks for startup, reload and exit
2010-03-29 18:21:04 +02:00
2b4e353168 Add hook utilities
This exports 3 basic routines:
  - virHookInitialize() initializing the hook support by looking for
    scripts availability
  - virHookPresent() used to test if there is a hook for a given driver
  - virHookCall() which actually calls a synchronous script hook with
    the needed parameters
Note that this doesn't expose any public API except for the locations
and arguments passed to the scripts

* src/Makefile.am: add the 2 new files
* src/util/hooks.h src/util/hooks.c: implements the 3 functions
* src/libvirt_private.syms: export the 3 symbols internally
* po/POTFILES.in: add src/util/hooks.c to translatables modules
2010-03-29 18:21:04 +02:00
bf7354072f Add an error module and message for the hooks subsystem
* include/libvirt/virterror.h: add VIR_FROM_HOOK and VIR_ERR_HOOK_SCRIPT_FAILED
* src/util/virterror.c: associated strings
2010-03-29 18:21:04 +02:00
b3bff9546b Export virPipeReadUntilEOF internally
used to read the data from virExec stdout/err file descriptors

* src/util/util.c src/util/util.h: not static anymore and export it
* src/libvirt_private.syms: allow access internally
2010-03-29 18:19:23 +02:00
e455b221be Introduce UPDATE_CPU flag for virDomainGetXMLDesc
This flag is used in migration prepare step to send updated XML
definition of a guest.

Also ``virsh dumpxml --update-cpu [--inactive] guest'' command can be
used to see the updated CPU requirements.
2010-03-26 23:05:23 +01:00
284805e666 Helper function for making a copy of virCPUDefPtr 2010-03-26 23:03:17 +01:00
661ae104c2 cpuUpdate() for updating guest CPU according to host CPU
Useful mainly for migration. cpuUpdate changes guest CPU requirements in
the following way:

- match == "strict" || match == "exact"
    - optional features which are supported by host CPU are changed into
      required features
    - optional features which are not supported by host CPU are disabled
    - all other features remain untouched
- match == "minimum"
    - match is changed into "exact"
    - optional features and all features not mentioned in guest CPU
      specification which are supported by host CPU become required
      features
    - other optional features are disabled
    - all other features remain untouched

This ensures that no feature will suddenly disappear from the guest
after migration.
2010-03-26 23:01:58 +01:00
5982168290 Don't replace persistent domain config with migrated config
When a domain is defined on host1, migrated to host2 and then migrated
back to host1, its current configuration would overwrite the libvirtd's
in-memory copy of persistent configuration of that domain. This is not
desired as we want to preserve the persistent configuration untouched.

This patch introduces new 'live' parameter to virDomainAssignDef.
Passing 'true' for 'live' means the configuration passed to
virDomainAssignDef describes a configuration of live instance of the
domain. This applies for saved domains which are being restored or for
incoming domains during migration.

All callers have been changed to pass the appropriate value.
2010-03-26 22:57:34 +01:00
19a863c435 filter new files through cppi, so syntax-check passes once again
* src/conf/nwfilter_conf.h: Indent cpp directives.
* src/conf/nwfilter_params.h: Likewise.
* src/datatypes.h: Likewise.
* src/nwfilter/nwfilter_driver.h: Likewise.
* src/nwfilter/nwfilter_ebiptables_driver.h: Likewise.
* src/nwfilter/nwfilter_gentech_driver.h: Likewise.
2010-03-26 22:47:30 +01:00
447c586a0d Add disk error policy to domain XML
* Fixes per feedback from Dan and Daniel
* Added test datafiles
* Re-disabled JSON flags
* Added code to print the error policy attribute when generating XML
* Re-add empty tag
2010-03-26 16:35:18 -04:00
508da563b9 build: don't lose prior configure args on autogen.sh
My prior patch forced an autogen.sh run, and I was surprised that the
suggested './autogen.sh' lost the fact that I had previously used
'./autogen.sh -C' for speed.

* autogen.sh: Use config.status, if present and there were no arguments.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-03-26 19:16:37 +01:00
f0dc84d83f build: update gnulib
Picks up fixes for gethostname compilation problems on mingw.

* .gnulib: Update to latest.
* build-aux/.gitignore: Regenerate.
* cfg.mk (local-checks-to-skip): Avoid new test not relevent to
libvirt.
2010-03-26 19:16:37 +01:00
e3a7137ac2 Add some examples filters
This patch adds some example filters to libvirt. They are automatically
installed into the proper directory for libvirt to pick them up.
2010-03-26 18:01:17 +00:00
1130085cf0 Extensions for iptables rules
This patch adds support for L3/L4 filtering using iptables. This adds
support for 'tcp', 'udp', 'icmp', 'igmp', 'sctp' etc. filtering.

As mentioned in the introduction, a .c file provided by this patch
is #include'd into a .c file. This will need work, but should be alright
for review.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:17 +00:00
f85208eec6 Add IPv6 support for the ebtables layer
This patch adds IPv6 support for the ebtables layer. Since the parser
etc. are all parameterized, it was fairly easy to add this...

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:17 +00:00
d498175aad Add qemu support
Add support for Qemu to have firewall rules applied and removed on VM
startup and shutdown respectively. This  patch also provides support for
the updating of a filter that causes all VMs that reference the filter
to have their ebtables/iptables rules updated.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:16 +00:00
065b6571bf Core driver implementation with ebtables support
This patch implements the core driver and provides
- management functionality for managing the filter XMLs
- compiling the internal filter representation into ebtables rules
- applying ebtables rules on a network (tap,macvtap) interface
- tearing down ebtables rules that were applied on behalf of an
interface
- updating of filters while VMs are running and causing the firewalls to
be rebuilt
- other bits and pieces

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:16 +00:00
e4e20423ff Add XML parser extensions for network filtering
This patch adds XML processing for the network filter schema
and extends the domain XML processing to parse the top level
referenced filter along with potentially provided parameters

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Gerhard Stenzel <gerhard.stenzel@de.ibm.com>
2010-03-26 18:01:16 +00:00
929560384d Add virsh support for new CLI commands
This patch adds virsh support for the five new CLI commands to manage
network filters.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:16 +00:00
965466c1ee Definition of the wire format, RPC client & server
This patch adds the definition of the wire format for RPC calls
and implementation of the RPC client & server code

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:16 +00:00
46e9b0fb4e Implementation of the public API
This patch adds the implementation of the public API for the network
filtering (ACL) extensions to libvirt.c .

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:15 +00:00
f0c1c3f86a Add internal API
This patch adds the internal API extensions for network filtering (ACL) support.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:15 +00:00
c71a2100b1 Add public API
This patch adds extensions to libvirt's public API necessary for
controlling the new functionality from remote for example.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:15 +00:00
f895e611df Add recursive locks
This patch adds recursive locks necessary due to the processing of
network filter XML that can reference other network filters, including
references that cause looks. Loops in the XML are prevented but their
detection requires recursive locks.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
2010-03-26 18:01:15 +00:00
67253251c5 Fix build break
* Add types to switch; the switch is only exectuted for known types because of a preceding conditional, so this fix is merely to placate the compiler.
2010-03-26 13:11:20 -04:00
9bcad69093 Use enum of virDomainNetType
To find out where the net type 'direct' needs to be handled I introduced
the 'enum virDomainNetType' in the virDomainNetDef structure and let the
compiler tell me where the case statement is missing. Then I added the
unhandled device statement to the UML driver.

* src/conf/domain_conf.h: change _virDomainNetDef type from int to
  virDomainNetType enum
* src/conf/domain_conf.c src/lxc/lxc_driver.c src/qemu/qemu_conf.c
  src/uml/uml_conf.c: make sure all enum cases are properly handled
  in switches
2010-03-26 17:01:35 +01:00
67203f6780 Silence cppi syntax-check warning 2010-03-26 17:00:50 +01:00
5607db6788 Mention direct device support since 0.7.7 in docs
In the documentation mention that the direct device support is there
since libvirt 0.7.7. A Linux kernel 2.6.34 is required for macvtap to be
available as standard device.
2010-03-26 16:53:32 +01:00
ab952024f4 Implement VNC password change in QEMU
Use the new virDomainUpdateDeviceFlags API to allow the VNC password
to be changed on the fly

* src/internal.h: Define STREQ_NULLABLE() which is like STREQ()
  but does not crash if either argument is NULL, and treats two
  NULLs as equal.
* src/libvirt_private.syms: Export virDomainGraphicsTypeToString
* src/qemu/qemu_driver.c: Support VNC password change on a live
  machine
* src/qemu/qemu_monitor.c: Disable crazy debugging info. Treat a
  NULL password as "" (empty string), allowing passwords to be
  disabled in the monitor
2010-03-26 14:17:35 +00:00
c85f641390 Allow parsing <graphics> in device XML
Expand the parser for the standalone <device> XML format to
allow inclusion of the <graphics> device type

* src/conf/domain_conf.h: Add virDomainGraphicsDef to
  the virDomainDeviceDef struct
* src/conf/domain_conf.c: Wire up parser for virDomainGraphicsDef
  to virDomainDeviceDefParse method
2010-03-26 14:17:35 +00:00
ced154cb54 Introduce a update-device command in virsh
Support the new virDomainUpdateDeviceFlags API in virsh by adding
a new 'update-device' command. In the future this should be augmented
with an explicit 'change-disk' command for media change to make it
end user discoverable, as attach-disk is.

* tools/virsh.c: Add 'update-device' command
2010-03-26 14:17:35 +00:00
6bb4986b0b Implement virDomainUpdateDeviceFlags API in all drivers with media change
To allow the new virDomainUpdateDeviceFlags() API to be universally
used with all drivers, this patch adds an impl to all the current
drivers which support CDROM or Floppy disk media change via the
current virDomainAttachDeviceFlags API

* src/qemu/qemu_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/proxy_internal.c, src/xen/xen_driver.c,
  src/xen/xend_internal.c: Implement media change via the
  virDomainUpdateDeviceFlags API
* src/xen/xen_driver.h, src/xen/xen_hypervisor.c,
  src/xen/xen_inotify.c, src/xen/xm_internal.c,
  src/xen/xs_internal.c: Stubs for Xen driver entry points
2010-03-26 14:17:34 +00:00
ee9083aba5 Remote protocol impl for virDomainUpdateDeviceFlags
This defines the wire format for the new virDomainUpdateDeviceFlags()
API, and implements the server & client side of the marshalling code.

* daemon/remote.c: Server side dispatch for virDomainUpdateDeviceFlags
* src/remote/remote_driver.c: Client side serialization for
  virDomainUpdateDeviceFlags
* src/remote/remote_protocol.x: Define wire format for
  virDomainUpdateDeviceFlags
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_table.h, src/remote/remote_protocol.c,
  src/remote/remote_protocol.h: Re-generate code
2010-03-26 14:17:34 +00:00
46a2ea3689 Introduce a new virDomainUpdateDeviceFlags public API
The current virDomainAttachDevice API can be (ab)used to change
the media of an existing CDROM/Floppy device. Going forward there
will be more devices that can be configured on the fly and overloading
virDomainAttachDevice for this is not too pleasant. This patch adds
a new virDomainUpdateDeviceFlags() explicitly just for modifying
existing devices.

* include/libvirt/libvirt.h.in: Add virDomainUpdateDeviceFlags
* src/driver.h: Internal API for virDomainUpdateDeviceFlags
* src/libvirt.c, src/libvirt_public.syms: Glue public API to
  driver API
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Add
  stubs for new driver entry point
2010-03-26 14:13:28 +00:00
987e31edc9 Add domain events for graphics network clients
This introduces a new event type

   VIR_DOMAIN_EVENT_ID_GRAPHICS

The same event can be emitted in 3 scenarios

  typedef enum {
      VIR_DOMAIN_EVENT_GRAPHICS_CONNECT = 0,
      VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE,
      VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT,
  } virDomainEventGraphicsPhase;

Connect/disconnect are triggered at socket accept/close.
The initialize phase is immediately after the protocol
setup and authentication has completed. ie when the
client is authorized and about to start interacting with
the graphical desktop

This event comes with *a lot* of potential information

 - IP address, port & address family of client
 - IP address, port & address family of server
 - Authentication scheme (arbitrary string)
 - Authenticated subject identity. A subject may have
   multiple identities with some authentication schemes.
   For example, vencrypt+sasl results in a x509dname
   and saslUsername identities.

This results in a very complicated callback :-(

   typedef enum {
      VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4,
      VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6,
   } virDomainEventGraphicsAddressType;

   struct _virDomainEventGraphicsAddress {
       int family;
       const char *node;
       const char *service;
   };
   typedef struct _virDomainEventGraphicsAddress virDomainEventGraphicsAddress;
   typedef virDomainEventGraphicsAddress *virDomainEventGraphicsAddressPtr;

   struct _virDomainEventGraphicsSubject {
      int nidentity;
      struct {
          const char *type;
          const char *name;
      } *identities;
   };
   typedef struct _virDomainEventGraphicsSubject virDomainEventGraphicsSubject;
   typedef virDomainEventGraphicsSubject *virDomainEventGraphicsSubjectPtr;

   typedef void (*virConnectDomainEventGraphicsCallback)(virConnectPtr conn,
                                                         virDomainPtr dom,
                                                         int phase,
                                                         virDomainEventGraphicsAddressPtr local,
                                                         virDomainEventGraphicsAddressPtr remote,
                                                         const char *authScheme,
                                                         virDomainEventGraphicsSubjectPtr subject,
                                                         void *opaque);

The wire protocol is similarly complex

   struct remote_domain_event_graphics_address {
     int family;
     remote_nonnull_string node;
     remote_nonnull_string service;
   };

   const REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX = 20;

   struct remote_domain_event_graphics_identity {
     remote_nonnull_string type;
     remote_nonnull_string name;
   };

   struct remote_domain_event_graphics_msg {
     remote_nonnull_domain dom;
     int phase;
     remote_domain_event_graphics_address local;
     remote_domain_event_graphics_address remote;
     remote_nonnull_string authScheme;
     remote_domain_event_graphics_identity subject<REMOTE_DOMAIN_EVENT_GRAPHICS_IDENTITY_MAX>;
   };

This is currently implemented in QEMU for the VNC graphics
protocol, but designed to be usable with SPICE graphics in
the future too.

* daemon/remote.c: Dispatch graphics events to client
* examples/domain-events/events-c/event-test.c: Watch for
  graphics events
* include/libvirt/libvirt.h.in: Define new graphics event ID
  and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle graphics events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for VNC events and emit a libvirt graphics event
* src/remote/remote_driver.c: Receive and dispatch graphics
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  graphics events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for VNC_CONNECTED,
  VNC_INITIALIZED & VNC_DISCONNETED events from QEMU monitor
2010-03-26 13:53:20 +00:00
71d793faaf Add support for an explicit IO error event
This introduces a new event type

   VIR_DOMAIN_EVENT_ID_IO_ERROR

This event includes the action that is about to be taken
as a result of the watchdog triggering

  typedef enum {
     VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
     VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
     VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
  } virDomainEventIOErrorAction;

In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)

Thus there is a new callback definition for this event type

typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
                                                     virDomainPtr dom,
                                                     const char *srcPath,
                                                     const char *devAlias,
                                                     int action,
                                                     void *opaque);

This is currently wired up to the QEMU block IO error events

* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
  IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
  and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
  from QEMU monitor
2010-03-26 13:53:11 +00:00
c5728cd618 Add support for an explicit watchdog event
This introduces a new event type

   VIR_DOMAIN_EVENT_ID_WATCHDOG

This event includes the action that is about to be taken
as a result of the watchdog triggering

 typedef enum {
     VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
     VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
     VIR_DOMAIN_EVENT_WATCHDOG_RESET,
     VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
     VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
     VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
 } virDomainEventWatchdogAction;

Thus there is a new callback definition for this event type

 typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
                                                       virDomainPtr dom,
                                                       int action,
                                                       void *opaque);

* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
  watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
  and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
  from QEMU monitor
2010-03-26 13:53:01 +00:00
32e6ac9c26 Add support for an explicit RTC change event
This introduces a new event type

   VIR_DOMAIN_EVENT_ID_RTC_CHANGE

This event includes the new UTC offset measured in seconds.
Thus there is a new callback definition for this event type

 typedef void (*virConnectDomainEventRTCChangeCallback)(virConnectPtr conn,
                                                        virDomainPtr dom,
                                                        long long utcoffset,
                                                        void *opaque);

If the guest XML configuration for the <clock> is set to
offset='variable', then the XML will automatically be
updated with the new UTC offset value. This ensures that
during migration/save/restore the new offset is preserved.

* daemon/remote.c: Dispatch RTC change events to client
* examples/domain-events/events-c/event-test.c: Watch for
  RTC change events
* include/libvirt/libvirt.h.in: Define new RTC change event ID
  and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle RTC change events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for RTC changes and emit a libvirt RTC change event
* src/remote/remote_driver.c: Receive and dispatch RTC change
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  RTC change events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for RTC_CHANGE event
  from QEMU monitor
2010-03-26 13:52:50 +00:00
8613273458 Add support for an explicit guest reboot event
The reboot event is not a normal lifecycle event, since the
virtual machine on the host does not change state. Rather the
guest OS is resetting the virtual CPUs. ie, the QEMU process
does not restart. Thus, this does not belong in the current
lifecycle events callback.

This introduces a new event type

    VIR_DOMAIN_EVENT_ID_REBOOT

It takes no parameters, besides the virDomainPtr, so it can
use the generic callback signature.

* daemon/remote.c: Dispatch reboot events to client
* examples/domain-events/events-c/event-test.c: Watch for
  reboot events
* include/libvirt/libvirt.h.in: Define new reboot event ID
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle reboot events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for reboots and emit a libvirt reboot event
* src/remote/remote_driver.c: Receive and dispatch reboot
  events to application
* src/remote/remote_protocol.x: Wire protocol definition for
  reboot events
2010-03-26 13:52:43 +00:00
d51638d0ad Rename domain lifecycle event message
To avoid confusion, rename the current REMOTE_PROC_DOMAIN_EVENT
message to REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE. This does not
cause ABI problems, since the names are only relevant at the source
code level. On the wire they encoding is a plain integer whose
value does not change

* src/remote/remote_protocol.x: Rename REMOTE_PROC_DOMAIN_EVENT
  to REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE.
* daemon/remote.c, src/remote/remote_driver.c: Update code for
  renamed event
2010-03-26 13:52:39 +00:00
6bae6677c8 Convert domain events example to new API
Convert the domain events example program to use the new
events APIs for one of its callback registrations to demo the
new API and interoperability with the old API.

* examples/domain-events/events-c/event-test.c: Convert to
  new events API
2010-03-26 13:52:34 +00:00
097e07a63a Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this

 - Register multiple callbacks with the remote daemon, each
   with filtering as needed
 - Register only one callback per event type, with no filtering

Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.

* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
  is no longer needed for unregistering callbacks, instead the
  unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
  callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
  instead of legacy virConnectDomainEventRegister function. Refactor
  remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
  instead of header, to avoid polluting the global namespace with
  the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
  registration. Refactor processCallDispatchMessage() to cope
  with arbitrary incoming event types. Merge remoteDomainQueueEvent()
  into processCallDispatchMessage() to avoid duplication of code.
  Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
  virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
  functions
2010-03-26 13:52:29 +00:00
cef0967e02 Support new event register/deregister APis in all drivers except remote
The libvirtd daemon impl will need to switch over to using the
new event APIs. To make this simpler, ensure all drivers currently
providing events support both the new APIs and old APIs.

* src/lxc/lxc_driver.c, src/qemu/qemu_driver.c, src/test/test_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Implement the new
  virConnectDomainEvent(Dereg|Reg)isterAny driver entry points
2010-03-26 13:52:24 +00:00
b7d4c300c3 Add new internal domain events APIs for handling other event types
The current internal domain events API tracks callbacks based on
the function pointer, and only supports lifecycle events. This
adds new internal APIs for registering callbacks for other event
types. These new APIs are postfixed with the word 'ID' to indicate
that they operated based on event ID, instead of hardcoded to
lifecycle events

* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Add new APIs for handling callbacks
  for non-lifecycle events
2010-03-26 13:52:19 +00:00
747c536370 Refactor domain events to handle multiple event types
The internal domain events APIs are designed to handle the lifecycle
events. This needs to be refactored to allow arbitrary new event
types to be handled.

 * The signature of virDomainEventDispatchFunc changes to use
   virConnectDomainEventGenericCallback instead of the lifecycle
   event specific virConnectDomainEventCallback
 * Every registered callback gains a unique ID to allow its
   removal based on ID, instead of function pointer
 * Every registered callback gains an 'eventID' to allow callbacks
   for different types of events to be distinguished
 * virDomainEventDispatch is adapted to filter out callbacks
   whose eventID does not match the eventID of the event being
   dispatched
 * virDomainEventDispatch is adapted to filter based on the
   domain name and uuid, if this filter is set for a callback.
 * virDomainEvent type/detail fields are moved into a union to
   allow different data fields for other types of events to be
   added later

* src/conf/domain_event.h, src/conf/domain_event.c: Refactor
  to allow handling of different types of events
* src/lxc/lxc_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/xen/xen_driver.c: Change dispatch function signature
  to use virConnectDomainEventGenericCallback
2010-03-26 13:52:14 +00:00
ea7dc33786 Make internal domain events struct definitions private
The virtual box driver was directly accesing the domain events
structs instead of using the APIs provided. To prevent this kind
of abuse, make the struct definitions private, forcing use of the
internal APIs. This requires adding one extra internal API.

* src/conf/domain_event.h, src/conf/domain_event.c: Move
  virDomainEventCallback and virDomainEvent structs into
  the source file instead of header
* src/vbox/vbox_tmpl.c: Use official APIs for dispatching domain
  events instead of accessing structs directly.
2010-03-26 13:52:09 +00:00
4445723811 Introduce a new public API for domain events
The current API for domain events has a number of problems

 - Only allows for domain lifecycle change events
 - Does not allow the same callback to be registered multiple times
 - Does not allow filtering of events to a specific domain

This introduces a new more general purpose domain events API

  typedef enum {
     VIR_DOMAIN_EVENT_ID_LIFECYCLE = 0,       /* virConnectDomainEventCallback */
      ...more events later..
  }

  int virConnectDomainEventRegisterAny(virConnectPtr conn,
                                       virDomainPtr dom, /* Optional, to filter */
                                       int eventID,
                                       virConnectDomainEventGenericCallback cb,
                                       void *opaque,
                                       virFreeCallback freecb);

  int virConnectDomainEventDeregisterAny(virConnectPtr conn,
                                         int callbackID);

Since different event types can received different data in the callback,
the API is defined with a generic callback. Specific events will each
have a custom signature for their callback. Thus when registering an
event it is neccessary to cast the callback to the generic signature

eg

  int myDomainEventCallback(virConnectPtr conn,
                            virDomainPtr dom,
                            int event,
                            int detail,
                            void *opaque)
  {
    ...
  }

  virConnectDomainEventRegisterAny(conn, NULL,
                                   VIR_DOMAIN_EVENT_ID_LIFECYCLE,
                                   VIR_DOMAIN_EVENT_CALLBACK(myDomainEventCallback)
                                   NULL, NULL);

The VIR_DOMAIN_EVENT_CALLBACK() macro simply does a "bad" cast
to the generic signature

* include/libvirt/libvirt.h.in: Define new APIs for registering
  domain events
* src/driver.h: Internal driver entry points for new events APIs
* src/libvirt.c: Wire up public API to driver API for events APIs
* src/libvirt_public.syms: Export new APIs
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c,
  src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
  src/qemu/qemu_driver.c, src/remote/remote_driver.c,
  src/test/test_driver.c, src/uml/uml_driver.c,
  src/vbox/vbox_tmpl.c, src/xen/xen_driver.c,
  src/xenapi/xenapi_driver.c: Stub out new API entries
2010-03-26 13:52:03 +00:00
271945a148 maint: update syntax-check rule to also catch test's -o operator
* cfg.mk (sc_prohibit_test_minus_a): Rename...
(sc_prohibit_test_minus_ao): ...and flag '-o', too.
2010-03-26 08:50:14 +01:00
156133597d tests: teach syntax-check that virDomainDefFree has free-like semantics
* cfg.mk (useless_free_options): Add virDomainDefFree to the list
of free-like functions.
* src/test/test_driver.c (testDomainCreateXML): Remove useless-if-
before-virDomainDefFree.
* src/conf/domain_conf.c (virDomainAssignDef): Likewise
2010-03-26 08:16:54 +01:00
e36be6e7c7 Add entry point logging for cpu functions 2010-03-25 14:51:52 +01:00
e07cf19fe5 build: don't use "test cond1 -o cond2": it's not portable
* configure.ac: Use "test cond1 || test cond2" instead.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Likewise.
* tests/test-lib.sh (verbose): Likewise.
2010-03-25 09:28:24 +01:00
5edaf95599 esx: Make the conf parser compare names case insensitive in VMX mode
The keys of entries in a VMX file are case insensitive. Both scsi0:1.fileName
and scsi0:1.filename are valid. Therefore, make the conf parser compare names
case insensitive in VMX mode to accept every capitalization variation.

Also add test cases for this.
2010-03-24 21:03:37 +01:00
f66636e3ca vbox: Fix segfault on empty device source
<source file=''/> results in def->disks[i]->src == NULL. But
vboxDomainDefineXML and vboxDomainAttachDevice didn't check
def->disks[i]->src for NULL and expected it to be a valid string.

Add checks for def->disks[i]->src != NULL to fix the segfault.
2010-03-24 21:00:53 +01:00
1cfbfaa697 python example: poll(-0.001) does not sleep forever
The conversion from seconds to milliseconds should only be done for
actual delays >= 0, not for the magic -1 value used for infinite
timeouts.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-03-24 10:26:23 +01:00
84eb6effdd build: suppress distracting build output
* src/Makefile.am (augeas-check): New target, just to give the existing
rule a name.  At the same time, prefix the commands with $(AM_V_GEN),
to avoid unexpected build output with V=0 which is the default.
2010-03-24 09:45:24 +01:00
95c8ddd2ec maint: add syntax-check rule to prohibit use of test's -a operator
* cfg.mk (sc_prohibit_test_minus_a): New rule.
2010-03-24 09:32:43 +01:00
7998714d60 build: don't use "test cond1 -a cond2" in configure: it's not portable
* configure.ac: Use "test cond1 && test cond2" instead.
2010-03-24 09:23:46 +01:00
ca7db6cb80 tests: shell script portability and clean-up
* tests/test-lib.sh: "echo -n" is not portable.  Use printf instead.
Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient).
Remove uses of tests' -a operator; it is not portable.
Instead, use "test cond && test cond2".
* tests/schematestutils.sh: Replace use of test's -a.
2010-03-24 09:23:01 +01:00
8a7783c163 tests: Don't add extra padding if counter mod 40 is 0
This change only affects the output of tests that have an exact
multiple of 40 test cases. For example the domainschematest currently:

TEST: domainschematest
      ........................................ 40
      ........................................ 80
      ........................................ 120
      ........................................ 160
      ........................................                                         200 OK
PASS: domainschematest

It outputs additional 40 spaces on the last line.

The domainschematest output is fixed by the change in test-lib.sh. The
change in testutils.c fixes this for tests written in C. Currently no
C test has an exact multiple of 40 test cases, but I checked it and
the same problem exists there.

This patch stops that in both cases.
2010-03-24 01:07:57 +01:00
81e99f014b Fix error reporting when parsing CPU XML strings 2010-03-23 15:40:10 +01:00
8d8815ea2a Use common XML parsing functions 2010-03-23 15:40:10 +01:00
26be7a0a24 Introduce XML parsing utility functions 2010-03-23 15:40:04 +01:00
c390bcfec5 virDomainDiskDefAssignAddress: return int, not void
Before, this function would blindly accept an invalid def->dst
and then abuse the idx=-1 it would get from virDiskNameToIndex,
when passing it invalid strings like "xvda:disk" and "sda1".
Now, this function returns -1 upon failure.
* src/conf/domain_conf.c (virDomainDiskDefAssignAddress): as above.
Update callers.
* src/conf/domain_conf.h: Update prototype.
* src/qemu/qemu_conf.c: Update callers.
2010-03-23 11:22:26 +01:00
67904847f0 tests: do not use the ":disk" suffix in sample xml input
* tests/xml2sexprdata/xml2sexpr-curmem.xml: Remove ":disk" suffix from
"<target dev=" value.
* tests/xml2sexprdata/xml2sexpr-pv-localtime.xml: Likewise.
* tests/xml2sexprdata/xml2sexpr-curmem.sexpr: Update expected output
to match.
* tests/xml2sexprdata/xml2sexpr-pv-localtime.sexpr: Likewise.
2010-03-23 11:22:26 +01:00
67ef701779 virDiskNameToIndex: ignore trailing digits
* src/util/util.c (virDiskNameToIndex): Accept sda1, and map it to "sda".
I.e., accept and ignore any string of trailing digits.
2010-03-23 11:22:26 +01:00
b9a3287e80 util: Add stubs for some functions on Windows
virSetCloseExec and virExecDaemonize were missing a body on Windows.
2010-03-23 02:14:20 +01:00
7233dc170f Add HAVE_PTHREAD_H guard for pthread_sigmask
Correctly disable pthread related code if pthread is not avialable,
in order to get it compile with MinGW on Windows.
2010-03-23 02:13:19 +01:00
2f80b2a013 bootstrap: Enable copy-mode for MinGW builds
MSYS' ln doesn't work well in the way bootstrap uses it with relative paths.
2010-03-23 02:12:07 +01:00
e77ee32357 util: Handle lack of (f)chmod and (f)chown on Windows
Even if gnulib can provide stubs, it won't help that much. So just
replace affected util functions (virFileOperation and virDirCreate)
with stubs on Windows. Both functions aren't used on libvirt's
client side, so this is fine for MinGW builds.
2010-03-23 02:11:21 +01:00
17f7220891 bootstrap: Remove rsync from buildreq list
rsync is used to download .po files, but SKIP_PO=true is set and
downloading .po files is skipped.

This also fixes a problem with MinGW builds, because rsync is not
available for MinGW.
2010-03-23 02:10:14 +01:00
0f7ba8c21c util: Make some conditional symbols unconditional
Add dummy bodies for HAVE_GETPWUID_R and HAVE_MNTENT_H dependent
functions for MinGW builds.
2010-03-23 02:09:29 +01:00
3528d66641 Make sure virtTestCaptureProgramOutput has a body on Windows
Now the virsh tests compile at least.
2010-03-23 02:08:14 +01:00
190aaa2627 Fix export of virConnectAuthPtrDefault for MinGW builds
Use the __declspec(dllexport/dllimport) stuff to export the symbol,
otherwise accessing virConnectAuthPtrDefault triggers a segfault.
2010-03-23 02:07:38 +01:00
460e7b6a94 Remove interfaceRegister from libvirt_private.syms
This symbol is conditional, it would need to be exported conditional to
work properly with MinGW. So just remove it, as no other driver register
function is listed in the symbols files.
2010-03-23 02:06:07 +01:00
6d45d5855d Export conditional state driver symbols only when they are defined
This is necessary for MinGW builds.
2010-03-23 02:05:18 +01:00
91da9a7689 Make sure uid_t and gid_t are available 2010-03-23 02:04:03 +01:00
041a18be17 esx: Add esxVI_LookupVirtualMachineByName
Used in esxDomainLookupByName and to be used in esxDomainDefineXML later.
2010-03-23 01:28:08 +01:00
bba36f7fc7 esx: Fix potential memory leak in esxVI_BuildFullTraversalSpecItem
If esxVI_String_DeepCopyValue or esxVI_SelectionSpec_AppendToList fail
then selectionSpec would leak. Add a free call in the failure path to
fix the leak.
2010-03-23 01:28:08 +01:00
055d21d254 esx: Cleanup file header comments
Replace 'method' with 'function' and get the filename's suffix right.
2010-03-23 01:28:08 +01:00
d304352b19 esx: Generate method mappings via macros
This is actually a consequence of the reworked required parameter
checking: Unify the required parameter check into a Validate function
instead of doing it separately im the (de)serialization part.

The required parameter checking for the mapped methods parameter was
done in the (de)serialize functions before. Now it's explicitly done
in the mapped method itself.
2010-03-23 01:28:08 +01:00
09fafa1e21 Avoid libvirtd crash when cgroups is not configured on host
Invoking virDomainSetMemory() on lxc driver results in libvirtd
segfault when cgroups has not been configured on the host.

Ensure driver->cgroup is non-null before invoking
virCgroupForDomain().  To prevent similar segfaults in the future,
ensure driver parameter to virCgroupForDomain() is non-null before
dereferencing.
2010-03-22 09:42:14 -06:00
65e97240e6 security: selinux: Fix crash when releasing non-existent label
This can be triggered by the qemuStartVMDaemon cleanup path if a
VM references a non-existent USB device (by product) in the XML.
2010-03-22 10:45:36 -04:00
b7a7b33651 Don't crash without a security driver
"virsh dominfo <vm>" crashes if there's no primary security driver set
since we only intialize the secmodel.model and secmodel.doi if we have
one. Attached patch checks for securityPrimaryDriver instead of
securityDriver since the later is always set in qemudSecurityInit().

Closes: http://bugs.debian.org/574359
2010-03-22 10:43:45 +01:00
5ee592208c Add migrate-setmaxdowntime command to virsh 2010-03-19 22:57:10 +01:00
7f4f1dd416 Implement virDomainMigrateSetMaxDowntime in qemu driver 2010-03-19 22:47:45 +01:00
0ab6423579 Implement virDomainMigrateSetMaxDowntime in remote driver 2010-03-19 22:45:55 +01:00
20ffaf59dc Wire protocol and dispatcher for virDomainMigrateSetMaxDowntime 2010-03-19 22:42:25 +01:00
68f63673da Public virDomainMigrateSetMaxDowntime API 2010-03-19 22:33:09 +01:00
7f7849c996 Internal driver API for virDomainMigrateSetMaxDowntime 2010-03-19 22:20:42 +01:00
3535092f3a Virsh support for vol wiping 2010-03-19 14:44:47 -04:00
73adc0e5b7 Simplified version of volume wiping based on feedback from the list. 2010-03-19 14:43:40 -04:00
3fdb9ba760 Implement remote bits for vol wiping 2010-03-19 14:43:02 -04:00
d36b4e92ac Implement the public API for vol wiping 2010-03-19 14:37:51 -04:00
b50ab42d41 Define the internal driver API for vol wiping
Also add vol wiping to ESX storage driver struct
2010-03-19 14:35:58 -04:00
e10dc8666e Add public API for volume wiping 2010-03-19 14:31:48 -04:00
598a0c00dc Support vhost-net mode at qemu startup for virtio network devices
Attempt to turn on vhost-net mode for devices of type NETWORK, BRIDGE,
and DIRECT (macvtap).

* src/qemu/qemu_conf.h: add vhostfd to qemuBuildHostNetStr prototype
  add qemudOpenVhostNet prototype new flag to set when :,vhost=" found in
  qemu help
* src/qemu/qemu_conf.c: * set QEMUD_CMD_FLAG_VNET_HOST is ",vhost=" found
  in qemu help
   - qemudOpenVhostNet - opens /dev/vhost-net to pass to qemu if everything
     is in place to use it.
   - qemuBuildHostNetStr - add vhostfd to commandline if it's not empty
     (higher levels decide whether or not to fill it in)
   - qemudBuildCommandLine - if /dev/vhost-net is successfully opened, add
     its fd to tapfds array so it isn't closed on qemu exec, and populate
     vhostfd_name to be passed in to commandline builder.
* src/qemu/qemu_driver.c: add filler 0 for new arg to qemuBuildHostNetStr,
  along with a note that this must be implemented in order for hot-plug of
  vhost-net virtio devices to work properly (once qemu "netdev_add" monitor
  command is implemented).
2010-03-19 16:58:14 +01:00
caad0a8783 qemu: Fix FD leak in qemudStartVMDaemon
The logfile FD is dup2'ed in __virExec in the child. The FD needs to
be closed in the parent, otherwise it leaks.
2010-03-18 23:45:11 +01:00
336fd879c0 util: ensure virMutexInit is not recursive
POSIX states that creation of a mutex with default attributes
is unspecified whether the mutex is recursive or non-recursive.
We specifically want non-recursive (deadlock is desirable in
flushing out coding bugs that used our mutex incorrectly).

* src/util/threads-pthread.c (virMutexInit): Specifically request
non-recursive mutex, rather than relying on unspecified default.
2010-03-18 21:37:32 +01:00
fc148ca133 maint: enforce recent copyright style
* cfg.mk (sc_copyright_format): New rule.
2010-03-18 21:20:32 +01:00
0a33633579 maint: make Red Hat copyright notices consistent
Spell out 'Red Hat, Inc.':
 git grep -i 'Copyright.*Red Hat' | grep -v Inc

Include (C) consistently:
 git grep -i 'Copyright [^(].*Red Hat'

* src/lxc/lxc_container.c: Update copyright formatting.
* src/node_device/node_device_udev.c: Likewise.
* src/node_device/node_device_udev.h: Likewise.
* src/xen/xend_internal.h: Likewise.
* src/xen/xm_internal.c: Likewise.
* src/xen/xm_internal.h: Likewise.
* tests/xmconfigtest.c: Likewise.
* tests/object-locking.ml: Likewise.
* tools/virt-pki-validate.in: Likewise.
* tools/virt-xml-validate.in: Likewise.
2010-03-18 16:48:05 +01:00
257d90f3fb maint: fix typo
* cfg.mk (sc_prohibit_gettext_noop): Fix typo
2010-03-18 16:26:06 +01:00
bc3f582bb0 maint: enforce recent N_ usage
* cfg.mk (sc_prohibit_gettext_noop): New rule applied in "make syntax-check"
2010-03-18 14:05:44 +01:00
e7d29e234c Fix logroate rpm build breakage
related to fix of bug https://bugzilla.redhat.com/show_bug.cgi?id=547514
2010-03-18 13:50:08 +01:00
1216398da9 Fix LSB compliance of init script
https://bugzilla.redhat.com/show_bug.cgi?id=538701

* daemon/libvirtd.init.in: daemon/libvirtd.init.in were not mentionned
  in the usage message and if a missing or wrong argument is given it
  should return 2, not 1
2010-03-18 13:30:16 +01:00
b62cab6e09 docs: <pre> cannot be nested in <p>
xsltproc complained about this.
2010-03-17 22:37:45 +01:00
2ef091efcc python: Fix networkLookupByUUID
According to:

http://libvirt.org/html/libvirt-libvirt.html#virNetworkLookupByUUID

virNetworkLookupByUUID() expects a virConnectPtr as its first argument,
thus making it a method of the virConnect Python class.

Currently it's a method of libvirt.virNetwork.

@@ -805,13 +805,6 @@ class virNetwork:
         if ret == -1: raise libvirtError ('virNetworkGetAutostart() failed', net=self)
         return ret

-    def networkLookupByUUID(self, uuid):
-        """Try to lookup a network on the given hypervisor based on its UUID. """
-        ret = libvirtmod.virNetworkLookupByUUID(self._o, uuid)
-        if ret is None:raise libvirtError('virNetworkLookupByUUID() failed', net=self)
-        __tmp = virNetwork(self, _obj=ret)
-        return __tmp
-
 class virInterface:
     def __init__(self, conn, _obj=None):
         self._conn = conn
@@ -1689,6 +1682,13 @@ class virConnect:
         __tmp = virDomain(self,_obj=ret)
         return __tmp

+    def networkLookupByUUID(self, uuid):
+        """Try to lookup a network on the given hypervisor based on its UUID. """
+        ret = libvirtmod.virNetworkLookupByUUID(self._o, uuid)
+        if ret is None:raise libvirtError('virNetworkLookupByUUID() failed', conn=self)
+        __tmp = virNetwork(self, _obj=ret)
+        return __tmp
+
2010-03-17 12:34:04 -04:00
0ef58c3155 .gitignore: Ignore generated daemon/libvirtd.logrotate 2010-03-17 12:27:41 -04:00
89d8cdfc7e Fix make dist with XenAPI changes 2010-03-17 12:25:50 -04:00
0c842417ef Allow suspend during live migration
Currently no command can be sent to a qemu process while another job is
active. This patch adds support for signaling long-running jobs (such as
migration) so that other threads may request predefined operations to be
done during such jobs. Two signals are defined so far:
    - QEMU_JOB_SIGNAL_CANCEL
    - QEMU_JOB_SIGNAL_SUSPEND

The first one is used by qemuDomainAbortJob.

The second one is used by qemudDomainSuspend for suspending a domain
during migration, which allows for changing live migration into offline
migration. However, there is a small issue in the way qemudDomainSuspend
is currently implemented for migrating domains. The API calls returns
immediately after signaling migration job which means it is asynchronous
in this specific case.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-03-17 14:38:46 +01:00
be7780b035 do not require two ./autogen.sh runs to permit "make"
* autogen.sh (bootstrap_hash): New function.
Running bootstrap may update the gnulib SHA1, yet we were computing
t=$(git submodule status ...) *prior* to running bootstrap, and
then recording that sometimes-stale value in the stamp file upon
a successful bootstrap run.  That would require two (lengthy!)
bootstrap runs to update the stamp file.
2010-03-16 21:42:56 +01:00
fe2f1ba1db phyp: Use virRequestUsername and virRequestPassword 2010-03-16 20:17:54 +01:00
b97befb6a2 xenapi: Don't leak url and caps in case of error 2010-03-16 20:17:50 +01:00
2969eff86a xenapi: Check for NULL before accessing the scheme 2010-03-16 20:17:45 +01:00
2ed0b3f935 xenapi: Request a username if there is non in the URI
Use virRequestUsername and virRequestPassword.
2010-03-16 20:17:40 +01:00
45b6e68e09 xenapi: Check for valid private data in xenapiSessionErrorHandle 2010-03-16 20:17:35 +01:00
3cdc4cb613 esx: Move username and password helper functions to authhelper.c 2010-03-16 20:15:32 +01:00
a31bc67503 fix two "make syntax check" failures
* src/xenapi/xenapi_driver.c (xenapiOpen): Remove useless-if-before-free.
* po/POTFILES.in: Add src/xenapi/xenapi_utils.c.
2010-03-16 19:32:05 +01:00
db481dca94 Use WARN_CFLAGS when compiling virsh.c 2010-03-16 16:09:12 +01:00
e3c36a2575 Use fsync() at the end of file allocation instead of O_DSYNC
Instead of opening storage file with O_DSYNC, make sure data are written
to a disk only before we claim allocation has finished.
2010-03-16 16:04:39 +01:00
c78c9f5a9b Revert f5a6ce44ce
* src/qemu/qemu_driver.c (qemudDomainAttachSCSIDisk): The ".controller"
member is an index, and *may* be 0.  As such, the commit that we're
reverting broke SCSI disk hot-plug on controller 0.
Reported by Wolfgang Mauerer.
2010-03-15 18:24:38 +01:00
3f1aa08af6 security: Set permissions for kernel/initrd
Fixes URL installs when running virt-install as root on Fedora.
2010-03-15 12:36:50 -04:00
6d5c8a8f51 qemu: Fix USB by product with security enabled
We need to call PrepareHostdevs to determine the USB device path before
any security calls. PrepareHostUSBDevices was also incorrectly skipping
all USB devices.
2010-03-15 12:36:47 -04:00
3a44152201 qemu: Add some debugging at domain startup 2010-03-15 12:35:49 -04:00
f92c041a1c qemu: pass the information when disks are read-only
* src/qemu/qemu_conf.c: add the ",readonly=on" for read-only disks
  and also parse it back in qemuParseCommandLineDisk()
* tests/qemuxml2argvtest.c
  tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.args
  tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.xml:
  add a specific regression test
2010-03-15 17:03:26 +01:00
95a515fc44 Fix syntax-check errors
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-03-15 15:10:27 +01:00
e6458393ab Fix error messages in qemu text monitor
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-03-15 15:10:27 +01:00
eb9945d9ae xenapi: Initial commit of the new driver 2010-03-14 19:30:00 +01:00
102d25a822 esx: Improve documentation about remote URIs 2010-03-13 15:23:13 +01:00
5541cade86 macvtap: Only export symbols if support is enabled 2010-03-13 14:48:25 +01:00
74383bfc42 Only use the numa functions when they are available.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-12 11:07:25 -05:00
83988bd43b Make nodeGetInfo report the correct number of NUMA nodes.
The nodeGetInfo code was always assuming that machine had a
single NUMA node, which is not correct.  The good news is that
libnuma gives us this information pretty easily, so let's
properly report it.

NOTE: With recent hardware starting to support CPU hot-add
and hot-remove, both this code and the nodeCapsInitNUMA()
code are quickly going to become obsolete.  We'll have to
think of a more dynamic solution for dealing with NUMA
nodes and CPUs that can come and go at will.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-12 08:38:34 -05:00
3ebbc241a1 Fix crash in virsh after bogus command
If you ran virsh in interactive mode and ran a command
that virsh could not parse, it would then SEGV
on subsequent commands.  The problem is that we are
freeing the vshCmd structure in the syntaxError label
at the end of vshCommandParse, but forgetting to
set ctl->cmd to NULL.  This means that on the next command,
we would try to free the same structure again, leading
to badness.

* tools/virsh.c: Make sure to set ctl->cmd to NULL after
  freeing it in vshCommandParse()
2010-03-12 12:00:46 +01:00
be2a53e6e0 Fix virsh command 'cd'
* tools/virsh.c: cmdCd was returning a 0 on success and -1 on error,
  when the rest of the code expected a TRUE on success and a
  FALSE on error.
2010-03-12 11:49:16 +01:00
7fbc2e37b8 Fix compiler warnings in virsh.c
No functional change. These all generated compiler warnings which, for
some reason weren't converted to errors by
--enable-compiler-warnings=error.

* tools/virsh.c:
  - change return type from int to void on two functions that don't
    return a value.
  - remove unused variables/labels from two functions
  - eliminate non-literal format strings
  - typecast char* into xmlChar* when calling
  - xmlParseBalancedChunkMemory
2010-03-12 11:39:24 +01:00
ca842a6bcb Silence compiler complaints about non-literal format strings
* src/util/macvtap.c: replace _("....") with "%s", _("...") in two places
2010-03-12 11:36:05 +01:00
f60e0150b8 Update commiters list 2010-03-12 11:30:07 +01:00
d376b7d63e Fix hang in qemudDomainCoreDump.
Currently if you dump the core of a qemu guest with
qemudDomainCoreDump, subsequent commands will hang
up libvirtd.  This is because qemudDomainCoreDump
uses qemuDomainWaitForMigrationComplete, which expects
the qemuDriverLock to be held when it's called.  This
patch does the simple thing and moves the qemuDriveUnlock
to the end of the qemudDomainCoreDump so that the driver
lock is held for the entirety of the call (as it is done
in qemudDomainSave).  We will probably want to make the
lock more fine-grained than that in the future, but
we can fix both qemudDomainCoreDump and qemudDomainSave
at the same time.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-11 12:45:05 -05:00
2c555d87b0 Make sure qemudDomainSetVcpus doesn't hang.
The code to add job support into libvirtd caused a problem
in qemudDomainSetVcpus.  In particular, a qemuDomainObjEndJob()
call was added at the end of the function, but a
corresponding qemuDomainObjBeginJob() was not.  Additionally,
a call to qemuDomainObj{Enter,Exit}Monitor() was also missed
in qemudDomainHotplugVcpus().  These missing calls conspired to
cause a hang in the libvirtd process after the command was
finished.  Fix this by adding the missing calls.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-11 12:44:53 -05:00
8a7f4b8dc1 Remove qemudDomainSetMaxMemory.
As previously discussed[1], this patch removes the
qemudDomainSetMaxMemory() function, since it doesn't
work.  This means that instead of getting somewhat
cryptic errors, you will now get:

error: Unable to change MaxMemorySize
error: this function is not supported by the hypervisor: virDomainSetMaxMemory

Which describes the situation perfectly.

[1] https://www.redhat.com/archives/libvir-list/2010-February/msg00928.html

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-11 10:39:29 -05:00
ed3d86c9a9 Fix a JSON CPU information bug.
When using the JSON monitor, qemuMonitorJSONExtractCPUInfo
was returning 0 on success.  Unfortunately, higher levels of
the cpuinfo code expect that it returns the number of CPUs
it found on success.  This one-line patch fixes it so that
it returns the correct number.  This makes "virsh vcpuinfo <domain>"
work when using the JSON monitor.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-11 10:39:18 -05:00
e29439bd14 Allow devices without a parent
* Allow devices without parent links to be created and set their parent to the root "computer" node
2010-03-10 17:25:54 -05:00
3b04f3bb0f build: change to gnulib module list should rerun bootstrap
* autogen.sh (curr_status): Also include hash of bootstrap.conf
when checking for changes that require bootstrap rerun.
* cfg.mk (_update_required): Likewise.
2010-03-10 18:14:15 +01:00
89a08ba63a build: enforce preprocessor indentation
Since cppi is not part of Fedora Core 12, the check is conditional:
without cppi, running 'make syntax-check' merely warns:

$ make sc_preprocessor_indentation
preprocessor_indentation
maint.mk: skipping test sc_preprocessor_indentation: cppi not installed

* cfg.mk (sc_preprocessor_indentation): New syntax-check rule.
(preprocessor_exempt): New macro, with first exemption.
2010-03-10 18:00:26 +01:00
12023373cd build: update gnulib submodule to newer (but not latest)
This is a stop-gap measure to make autogen.sh rerun ./bootstrap,
(required due to recent bootstrap.conf addition) while we prepare
the fix to automatically detect the case of an updated modules list.
2010-03-10 17:46:27 +01:00
b978f31a93 Free resources on error in udev startup
* The udev driver didn't properly free resources that it allocates when setting up the 'computer' device in the error case.
2010-03-10 11:38:37 -05:00
056623f3d7 Make virsh reconnect when losing connection
When the daemon libvirtd restarts, a connected virsh gets a SIGPIPE
and dies. This change the behaviour to try to reconnect if the
signal was received or command error indicated a connection or RPC
failure. Note that the failing command is not restarted.

* tools/virsh.c: catch SIGPIPE signals as well as connection related
  failures, add some automatic reconnection code and appropriate error
  messages.
2010-03-10 17:03:07 +01:00
7be9270c24 Fix up nodeinfo parsing code.
As pointed out by eblake, I made a real hash of the
nodeinfo code with commit
aa2f6f96dd.  This patch
cleans it up:

1)  Do more work at compile time instead of runtime (minor)
2)  Properly handle the hex digits that come from
/sys/devices/system/cpu/cpu*/topology/thread_siblings
3)  Fix up some error paths that could cause SEGV
4)  Used unsigned's for the cpu numbers (cpu -1 doesn't
make any sense)

Along with the recent patch from jdenemar to zero out
the nodeinfo structure, I've re-tested this on the
machines having the problems, and it seems to be good.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-10 08:49:37 -05:00
89bf843a6d Change logrotate to be per-hypervisor logs
Having a single logrotate configuration file for all hypervisors
did not work as logrotate would get confused if an hypervisor not
supported on that platform was still listed. Simplest is to split
the logrotate as separate per hypervisor files and change the
spec file to only install the ones compiled in.
* daemon/libvirtd.lxc.logrotate.in daemon/libvirtd.qemu.logrotate.in
  daemon/libvirtd.uml.logrotate.in: copy and split the original
  daemon/libvirtd.logrotate.in file
* daemon/Makefile.am: update to support the different files and
  cleanup in sed suggested by Eric Blake
* libvirt.spec.in: only install the relevant logrotate configs
* daemon/.gitignore: update logrotate generated list
2010-03-10 11:27:02 +01:00
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
0c39adef95 virsh: use N_ rather than gettext_noop
With N_() in place, we can use it for a smaller file.

* doc/api-extension/0008-Step-8-of-8-Add-virsh-support.patch:
Replace all uses of gettext_noop with N_.
* tools/virsh.c: Likewise, throughout the file.
2010-03-09 18:24:02 +01:00
f6876e10cf virsh: fix existing N_ uses
It is a bad idea to call gettext on an already-translated
string.  In cases where a string must be translated separately
from where it is exposed to xgettext, the gettext manual
recommends the idiom of N_() wrapping gettext_noop for
marking the string.

* src/internal.h (N_): Fix definition to match gettext manual.
* tools/virsh.c: (cmdHelp, cmdList, cmdDomstate, cmdDominfo)
(cmdVcpuinfo, vshUsage): Replace incorrect use of N_ with _.
(vshCmddefHelp): Likewise.  Mark C format strings appropriately.
2010-03-09 18:23:44 +01:00
d1c754168a doc: fix typos in hacking.html.in; mark HACKING as read-only
* HACKING: Mark as read-only.  Soon we'll generate it from...
* docs/hacking.html.in: ... this file.  More typo fixes.
2010-03-09 18:18:20 +01:00
06b835607f Fix copy&paste typos in virProcessInfoGetAffinity
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-03-09 17:31:15 +01:00
22e39d0ee4 Wipe nodeinfo structure before filling it
The nodeinfo structure wasn't initialized in qemu driver and with the
recent change in CPU topology parsing, old value of nodeinfo->sockets
could be used and incremented giving totally bogus results.

Let's just wipe the structure completely.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-03-09 17:31:15 +01:00
2a13ecc9be doc: fix more typos in HACKING
* HACKING: More spelling/typo fixes.
2010-03-09 17:26:24 +01:00
e839e33a96 AUTHORS: add recent contributors 2010-03-09 17:10:06 +01:00
095375925e hacking: add a section on preprocessor conventions
* doc/hacking.html.in (preprocessor): New section to document
recently-discussed style issues.

Signed-off-by: Eric Blake <eblake@redhat.com>
2010-03-09 17:07:15 +01:00
0be3783316 hacking: fix typos
* docs/hacking.html.in (committers): Fix spelling and grammar.
2010-03-09 17:01:20 +01:00
618dc80c2f Fix format string warnings
A few more non-literal format strings in error log messages have crept
in. Fix them in the standard way - turn the format string into "%s"
with the original string as the arg.
2010-03-09 14:32:06 +01:00
d3b6fe5f9c macvtap build detection fix
* configure.ac: fix the header test used for macvtap availability
  detection
2010-03-09 14:14:48 +01:00
1c36d0682a Fix virDomainGetXMLDesc cache settings output
If a special cache strategy for a disk has been specified in a domain
definition, but no driverName has been set, virDomainGetXMLDesc would not
include the <driver> tag at all.

* src/conf/domain_conf.c: make sure any <driver> tag setting is
  serialized if set.
2010-03-09 13:59:51 +01:00
785d8580b3 Update hacking.html.in
* Added section on use of goto
* Added missing content from HACKING document
2010-03-08 10:28:43 -05:00
aa2f6f96dd Get thread and socket information in virsh nodeinfo.
The current code for "nodeinfo" is pretty naive
about socket and thread information.  To determine the
sockets, it just takes the number of cpus and divides
by the number of cores.  For the thread count, it always
sets it to 1.  With more recent Intel machines, however,
hyperthreading is again an option, meaning that these
heuristics no longer work and give bogus numbers.  This
patch goes through /sys to get the additional
information so we properly report it.

Note that I had to edit the tests not to report on
socket and thread counts, since these are determined
dynamically now.

v2: As pointed out by Eric Blake, gnulib provides
    count-one-bits (which is LGPLv2+).  Use it instead
    of a hand-coded popcnt.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-03-08 09:26:04 -05:00
5140a2f626 Fix locking in qemudDomainMemoryStats
When adding domainMemoryStats API support for the qemu driver, I didn't
follow the locking rules exactly.  The job condition must be held when
executing monitor commands.  This corrects the segfaults I was seeing
when calling domainMemoryStats in a multi-threaded environment.

* src/qemu/qemu_driver.c: in qemudDomainMemoryStats() add missing
  calls to qemuDomainObjBeginJob/qemuDomainObjEndJob
2010-03-08 15:15:44 +01:00
ecb5cf7cb2 Eliminate large stack buffer in doTunnelSendAll
doTunnelSendAll function (used by QEMU migration) uses a 64k buffer on
the stack, which could be problematic. This patch replaces that with a
buffer from the heap.

While in the neighborhood, this patch also improves error reporting in
the case that saferead fails - previously, virStreamAbort() was called
(resetting errno) before reporting the error. It's been changed to
report the error first.

* src/qemu/qemu_driver.c: fix doTunnelSendAll() to use a malloc'ed
  buffer
2010-03-08 15:01:52 +01:00
2e56fb2bcc build: consistently use C99 varargs macros
Prior to this patch, there was an inconsistent mix between GNU and C99.

For consistency, and potential portability to other compilers, stick
with the C99 vararg macro syntax.

* src/conf/cpu_conf.c (virCPUReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/conf/domain_conf.c (virDomainReportError): Likewise.
* src/conf/domain_event.c (eventReportError): Likewise.
* src/conf/interface_conf.c (virInterfaceReportError): Likewise.
* src/conf/network_conf.c (virNetworkReportError): Likewise.
* src/conf/node_device_conf.h (virNodeDeviceReportError): Likewise.
* src/conf/secret_conf.h (virSecretReportError): Likewise.
* src/conf/storage_conf.h (virStorageReportError): Likewise.
* src/esx/esx_device_monitor.c (ESX_ERROR): Use C99 rather than
  GNU vararg macro syntax.
* src/esx/esx_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_interface_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_network_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_secret_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_storage_driver.c (ESX_ERROR): Likewise.
* src/esx/esx_util.c (ESX_ERROR): Likewise.
* src/esx/esx_vi.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vi_methods.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vi_types.c (ESX_VI_ERROR): Likewise.
* src/esx/esx_vmx.c (ESX_ERROR): Likewise.
* src/util/hostusb.c (usbReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/util/json.c (virJSONError): Likewise.
* src/util/macvtap.c (ReportError): Likewise.
* src/util/pci.c (pciReportError): Likewise.
* src/util/stats_linux.c (virStatsError): Likewise.
* src/util/util.c (virUtilError): Likewise.
* src/util/xml.c (virXMLError): Likewise.
* src/xen/proxy_internal.c (virProxyError): Use C99 rather than
  GNU vararg macro syntax.
* src/xen/sexpr.c (virSexprError): Likewise.
* src/xen/xen_driver.c (xenUnifiedError): Likewise.
* src/xen/xen_hypervisor.c (virXenError): Likewise.
* src/xen/xen_inotify.c (virXenInotifyError): Likewise.
* src/xen/xend_internal.c (virXendError): Likewise.
* src/xen/xm_internal.c (xenXMError): Likewise.
* src/xen/xs_internal.c (virXenStoreError): Likewise.
* src/cpu/cpu.h (virCPUReportError): Use C99 rather than GNU
  vararg macro syntax.
* src/datatypes.c (virLibConnError): Likewise.
* src/interface/netcf_driver.c (interfaceReportError): Likewise.
* src/libvirt.c (virLibStreamError): Likewise.
* src/lxc/lxc_conf.h (lxcError): Likewise.
* src/network/bridge_driver.c (networkReportError): Likewise.
* src/nodeinfo.c (nodeReportError): Likewise.
* src/opennebula/one_conf.h (oneError): Likewise.
* src/openvz/openvz_conf.h (openvzError): Likewise.
* src/phyp/phyp_driver.c (PHYP_ERROR): Likewise.
* src/qemu/qemu_conf.h (qemuReportError): Likewise.
* src/remote/remote_driver.c (errorf): Likewise.
* src/security/security_driver.h (virSecurityReportError): Likewise.
* src/test/test_driver.c (testError): Likewise.
* src/uml/uml_conf.h (umlReportError): Likewise.
* src/vbox/vbox_driver.c (vboxError): Likewise.
* src/vbox/vbox_tmpl.c (vboxError): Likewise.
2010-03-08 13:32:27 +01:00
4dbed7d9c4 ebtablesAddRemoveRule: avoid dead store
* src/util/ebtables.c (ebtablesAddRemoveRule): Avoid dead store
to local, "s".
2010-03-05 23:24:52 +01:00
c101092adf virInterfaceDefParseBond: avoid dead stores
* src/conf/interface_conf.c (virInterfaceDefParseBond): Avoid dead stores
to local, "node".  Remove declaration, too.
2010-03-05 23:24:47 +01:00
fbe65e5e1c xenXMDomainConfigParse: avoid dead store
* src/xen/xm_internal.c (xenXMDomainConfigParse): Avoid dead store
to local, "data".  Remove declaration, too.
2010-03-05 23:24:42 +01:00
f5a6ce44ce qemudDomainAttachSCSIDisk: handle empty controller list
* src/qemu/qemu_driver.c (qemudDomainAttachSCSIDisk): Handle
the (theoretical) case of an empty controller list, so that
clang does not think the subsequent dereference of "cont"
would dereference an undefined variable (due to preceding
loop not iterating even once).
2010-03-05 18:42:30 +01:00
1a4d5c9543 qemu restore: don't let corrupt input provoke unwarranted OOM
* src/qemu/qemu_driver.c (qemudDomainRestore): A corrupt save file
(in particular, a too-large header.xml_len value) would cause an
unwarranted out-of-memory error.  Do not trust the just-read
header.xml_len.  Instead, merely use that as a hint, and
read/allocate up to that number of bytes from the file.
Also verify that header.xml_len is positive; if it were negative,
passing it to virFileReadLimFD could cause trouble.
2010-03-05 18:32:34 +01:00
32884a7ef6 virFileReadLimFD: diagnose maxlen <= 0, rather than passing it on...
to saferead_lim, which interprets it as a size_t.
* src/util/util.c (virFileReadLimFD): Do not malfunction when
maxlen < -1.  Return -1,EINVAL in that case.  Handle maxlen==0
in the same manner.
2010-03-05 18:31:26 +01:00
ba918ac1b4 xen: don't let bogus packets trigger over-allocation and segfault
* src/xen/proxy_internal.c (xenProxyDomainDumpXML): An invalid packet
could include a too-large "ans.len" value, which would make us allocate
too much memory and then copy data from beyond the end of "ans",
possibly evoking a segfault.  Ensure that the value we use is no
larger than the remaining portion of "ans".
Also, change unnecessary memmove to memcpy (src and dest obviously
do not overlap, so no need to use memmove).
(xenProxyDomainGetOSType): Likewise.
(xenProxyGetCapabilities): Likewise.
2010-03-05 18:30:57 +01:00
4697def66b qemuMonitorTextGetMemoryStats: decrease risk of false positive in parsing
The code erroneously searched the entire "reply" for a comma, when
its intent was to search only that portion after "balloon: actual="
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetMemoryStats):
Search for "," only starting *after* the BALLOON_PREFIX string.
Otherwise, we'd be more prone to false positives.
2010-03-05 18:28:56 +01:00
829 changed files with 680066 additions and 308060 deletions

7
.gitignore vendored
View File

@ -1,13 +1,19 @@
*#*#
*.#*#
*.a
*.exe
*.gcda
*.gcno
*.gcov
*.o
*.orig
*.rej
*~
.git
.git-module-status
.sc-start-sc_*
/GNUmakefile
/libvirt-[0-9]*
/maint.mk
ABOUT-NLS
COPYING
@ -44,4 +50,5 @@ stamp-h
stamp-h.in
stamp-h1
tests/*.log
tests/nwfilterxml2xmltest
update.log

Submodule .gnulib updated: 80cd995cdc...1629006348

298
.hgignore
View File

@ -1,298 +0,0 @@
syntax: glob
*.a
*.o
*~
.git
ABOUT-NLS
COPYING
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache
build-aux/compile
build-aux/config.guess
build-aux/config.rpath
build-aux/config.sub
build-aux/depcomp
build-aux/install-sh
build-aux/ltmain.sh
build-aux/missing
build-aux/mkinstalldirs
build-aux/mktempd
config.cache
config.guess
config.h
config.h.in
config.log
config.rpath
config.status
config.sub
configure
coverage
docs/.memdump
docs/Makefile
docs/Makefile.in
docs/apibuild.pyc
docs/devhelp/Makefile
docs/devhelp/Makefile.in
docs/devhelp/libvirt.devhelp
docs/examples/.deps
docs/examples/.libs
docs/examples/.memdump
docs/examples/Makefile
docs/examples/Makefile.in
docs/examples/info1
docs/examples/python/Makefile
docs/examples/python/Makefile.in
docs/examples/suspend
docs/schemas/Makefile
docs/schemas/Makefile.in
examples/domain-events/events-c/*.exe
examples/domain-events/events-c/.deps
examples/domain-events/events-c/.libs
examples/domain-events/events-c/Makefile
examples/domain-events/events-c/Makefile.in
examples/domain-events/events-c/event-test
examples/hellolibvirt/.deps
examples/hellolibvirt/.libs
examples/hellolibvirt/Makefile
examples/hellolibvirt/Makefile.in
examples/hellolibvirt/hellolibvirt
gnulib/lib/*.la
gnulib/lib/*.lo
gnulib/lib/.deps
gnulib/lib/.libs
gnulib/lib/Makefile
gnulib/lib/Makefile.in
gnulib/lib/alloca.h
gnulib/lib/arpa/inet.h
gnulib/lib/arpa_inet.h
gnulib/lib/errno.h
gnulib/lib/float.h
gnulib/lib/netdb.h
gnulib/lib/netinet/in.h
gnulib/lib/netinet_in.h
gnulib/lib/poll.h
gnulib/lib/stdbool.h
gnulib/lib/stdint.h
gnulib/lib/stdio.h
gnulib/lib/stdlib.h
gnulib/lib/string.h
gnulib/lib/sys/select.h
gnulib/lib/sys/socket.h
gnulib/lib/sys/stat.h
gnulib/lib/sys/time.h
gnulib/lib/sys_ioctl.h
gnulib/lib/sys_select.h
gnulib/lib/sys_socket.h
gnulib/lib/sys_stat.h
gnulib/lib/sys_time.h
gnulib/lib/time.h
gnulib/lib/unistd.h
gnulib/lib/wchar.h
gnulib/tests/.deps
gnulib/tests/.libs
gnulib/tests/Makefile
gnulib/tests/Makefile.in
gnulib/tests/sys
gnulib/tests/test-EOVERFLOW
gnulib/tests/test-alloca-opt
gnulib/tests/test-arpa_inet
gnulib/tests/test-c-ctype
gnulib/tests/test-errno
gnulib/tests/test-fseeko
gnulib/tests/test-getaddrinfo
gnulib/tests/test-getdelim
gnulib/tests/test-gethostname
gnulib/tests/test-getline
gnulib/tests/test-gettimeofday
gnulib/tests/test-lseek
gnulib/tests/test-lstat
gnulib/tests/test-netdb
gnulib/tests/test-netinet_in
gnulib/tests/test-perror
gnulib/tests/test-poll
gnulib/tests/test-random_r
gnulib/tests/test-snprintf
gnulib/tests/test-sockets
gnulib/tests/test-stdbool
gnulib/tests/test-stdint
gnulib/tests/test-stdio
gnulib/tests/test-stdlib
gnulib/tests/test-strerror
gnulib/tests/test-string
gnulib/tests/test-sys_select
gnulib/tests/test-sys_socket
gnulib/tests/test-sys_stat
gnulib/tests/test-sys_time
gnulib/tests/test-time
gnulib/tests/test-unistd
gnulib/tests/test-vasnprintf
gnulib/tests/test-vasprintf
gnulib/tests/test-wchar
include/Makefile
include/Makefile.in
include/libvirt/Makefile
include/libvirt/Makefile.in
libtool
libvirt-*.tar.gz
libvirt.pc
libvirt.spec
ltconfig
ltmain.sh
m4/Makefile
m4/Makefile.in
m4/acinclude.m4
m4/aclocal.m4
m4/codeset.m4
m4/gettext.m4
m4/glibc21.m4
m4/iconv.m4
m4/intdiv0.m4
m4/intmax.m4
m4/inttypes-pri.m4
m4/inttypes.m4
m4/inttypes_h.m4
m4/isc-posix.m4
m4/lcmessage.m4
m4/lib-ld.m4
m4/lib-link.m4
m4/lib-prefix.m4
m4/libtool.m4
m4/longdouble.m4
m4/longlong.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
m4/nls.m4
m4/po.m4
m4/printf-posix.m4
m4/progtest.m4
m4/signed.m4
m4/size_max.m4
m4/stdint_h.m4
m4/uintmax_t.m4
m4/ulonglong.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/xsize.m4
mingw32-libvirt.spec
mkinstalldirs
po/*.gmo
po/Makefile
po/Makefile.in
po/Makefile.in.in
po/Makevars.template
po/POTFILES
po/Rules-quot
po/boldquot.sed
po/en@boldquot.header
po/en@quot.header
po/insert-header.sin
po/quot.sed
po/remove-potcdate.sed
po/remove-potcdate.sin
po/stamp-po
proxy/.deps
proxy/.libs
proxy/Makefile
proxy/Makefile.in
proxy/libvirt_proxy
python/*.la
python/*.lo
python/*.loT
python/*.pyc
python/.deps
python/.libs
python/Makefile
python/Makefile.in
python/gen_prog
python/generated.stamp
python/libvirt-export.c
python/libvirt-py.[ch]
python/libvirt.py
python/libvirtclass.py
python/libvirtclass.txt
python/tests/Makefile
python/tests/Makefile.in
qemud/*.gcda
qemud/*.gcno
qemud/*.la
qemud/*.lo
qemud/.deps
qemud/.libs
qemud/Makefile
qemud/Makefile.in
qemud/libvirt_qemud
qemud/libvirtd
qemud/libvirtd.init
qemud/libvirtd.logrotate
results.log
src/*.cov
src/*.exe
src/*.gcda
src/*.gcno
src/*.gcov
src/*.i
src/*.la
src/*.lo
src/*.loT
src/*.s
src/.deps
src/.libs
src/Makefile
src/Makefile.in
src/libvirt.syms
src/libvirt_lxc
src/libvirt_parthelper
src/virsh
src/virsh-net-edit.c
src/virsh-pool-edit.c
stamp-h
stamp-h.in
stamp-h1
tests/*.exe
tests/*.gcda
tests/*.gcno
tests/.deps
tests/.libs
tests/Makefile
tests/Makefile.in
tests/confdata/Makefile
tests/confdata/Makefile.in
tests/conftest
tests/eventtest
tests/nodedevxml2xmltest
tests/nodeinfotest
tests/object-locking
tests/object-locking-files.txt
tests/object-locking.cmi
tests/object-locking.cmx
tests/qemuargv2xmltest
tests/qemuhelptest
tests/qemuxml2argvtest
tests/qemuxml2xmltest
tests/qparamtest
tests/reconnect
tests/seclabeltest
tests/sexpr2xmldata/Makefile
tests/sexpr2xmldata/Makefile.in
tests/sexpr2xmltest
tests/statstest
tests/virshtest
tests/xencapsdata/Makefile
tests/xencapsdata/Makefile.in
tests/xencapstest
tests/xmconfigdata/Makefile
tests/xmconfigdata/Makefile.in
tests/xmconfigtest
tests/xml2sexprdata/Makefile
tests/xml2sexprdata/Makefile.in
tests/xml2sexprtest
tools/Makefile
tools/Makefile.in
tools/virt-xml-validate
tools/virt-xml-validate.1
update.log

15
.mailmap Normal file
View File

@ -0,0 +1,15 @@
<amy.griffis@hp.com> <aron.griffis@hp.com>
<bozzolan@gmail.com> <redshift@gmx.com>
<charles_duffy@messageone.com> <charles@dyfis.net>
<dfj@redhat.com> <dfj@dfj.bne.redhat.com>
<eblake@redhat.com> <ebb9@byu.net>
<gdolley@arpnetworks.com> <gdolley@ucla.edu>
<gerhard.stenzel@de.ibm.com> <gstenzel@linux.vnet.ibm.com>
<jamie@canonical.com> <jamie@ubuntu.com>
<laine@redhat.com> <laine@laine.org>
<meyering@redhat.com> <jim@meyering.net>
<socketpair@gmail.com> <socketpair gmail com>
<soren@canonical.com> <soren@ubuntu.com>
<jfehlig@novell.com> <jfehlig@linux-ypgk.site>
<jclift@redhat.com> <justin@salasaga.org>
<berrange@redhat.com> <dan@berrange.com>

View File

@ -0,0 +1,4 @@
ChangeLog*
docs/news.html.in
python/libvirt-override.c
python/typewrappers.c

View File

@ -0,0 +1,2 @@
ChangeLog*
docs/news.html.in

View File

@ -0,0 +1 @@
docs/news.html.in

View File

@ -0,0 +1,2 @@
docs/apibuild.py
tests/virt-aa-helper-test

42
AUTHORS
View File

@ -24,6 +24,10 @@ The primary maintainers and people with commit access rights:
John Levon <john.levon@sun.com>
Matthias Bolte <matthias.bolte@googlemail.com>
Jiri Denemark <jdenemar@redhat.com>
Dave Allan <dallan@redhat.com>
Laine Stump <laine@redhat.com>
Stefan Berger <stefanb@us.ibm.com>
Eric Blake <eblake@redhat.com>
Patches have also been contributed by:
@ -59,7 +63,6 @@ Patches have also been contributed by:
Shigeki Sakamoto <fj0588di@aa.jp.fujitsu.com>
Gerd von Egidy <lists@egidy.de>
Itamar Heim <iheim@redhat.com>
Dave Allan <dallan@redhat.com>
Markus Armbruster <armbru@redhat.com>
Ryota Ozaki <ozaki.ryota@gmail.com>
James Morris <jmorris@namei.org>
@ -71,7 +74,6 @@ Patches have also been contributed by:
Takahashi Tomohiro <takatom@jp.fujitsu.com>
Serge E. Hallyn <serue@us.ibm.com>
Soren Hansen <soren@canonical.com>
Laine Stump <laine@redhat.com>
Abel Míguez Rodríguez<amiguezr@pdi.ucm.es>
Doug Goldstein <cardoe@gentoo.org>
Javier Fontan <jfontan@gmail.com>
@ -89,6 +91,42 @@ Patches have also been contributed by:
Steve Yarmie <steve.yarmie@gmail.com>
Dan Kenigsberg <danken@redhat.com>
Yuji NISHIDA <nishidy@nict.go.jp>
Dustin Xiong <x_k_123@hotmail.com>
Rolf Eike Beer <eike@sf-mail.de>
Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Philipp Hahn <hahn@univention.de>
Ed Swierk <eswierk@aristanetworks.com>
Paolo Smiraglia <paolo.smiraglia@gmail.com>
Sharadha Prabhakar <sharadha.prabhakar@citrix.com>
Chris Wong <wongc-redhat@hoku.net>
Daniel Berteaud <daniel@firewall-services.com>
Dustin Kirkland <kirkland@canonical.com>
Luiz Capitulino <lcapitulino@redhat.com>
Ryan Harper <ryanh@us.ibm.com>
Spencer Shimko <sshimko@tresys.com>
Marco Bozzolan <bozzolan@gmail.com>
Alex Williamson <alex.williamson@redhat.com>
Ersek Laszlo <lacos@caesar.elte.hu>
Kenneth Nagin <NAGIN@il.ibm.com>
Klaus Ethgen <Klaus@Ethgen.de>
Bryan Kearney <bkearney@redhat.com>
Darry L. Pierce <dpierce@redhat.com>
David Jorm <dfj@redhat.com>
Eduardo Otubo <otubo@linux.vnet.ibm.com>
Garry Dolley <gdolley@arpnetworks.com>
Harshavardhana <harsha@gluster.com>
Jonas Eriksson <jonas.j.eriksson@ericsson.com>
Jun Koi <junkoi2004@gmail.com>
Olivier Fourdan <ofourdan@redhat.com>
Ron Yorston <rmy@tigress.co.uk>
Shahar Klein <shaharklein@yahoo.com>
Taizo ITO <taizo.ito@hde.co.jp>
Thomas Treutner <thomas@scripty.at>
Jean-Baptiste Rouault <jean-baptiste.rouault@diateam.net>
Марк Коренберг <socketpair@gmail.com>
Justin Clift <jclift@redhat.com>
Alan Pevec <apevec@redhat.com>
Aurelien Rougemont <beorn@binaries.fr>
[....send patches to get your name here....]

130
HACKING
View File

@ -1,3 +1,6 @@
-*- buffer-read-only: t -*- vi: set ro:
DO NOT EDIT THIS FILE! IT IS GENERATED AUTOMATICALLY!
Libvirt contributor guidelines
==============================
@ -96,12 +99,117 @@ around operators and keywords:
--no-tabs "$@"
}
Note that sometimes you'll have to postprocess that output further, by
Note that sometimes you'll have to post-process that output further, by
piping it through "expand -i", since some leading TABs can get through.
Usually they're in macro definitions or strings, and should be converted
anyhow.
Curly braces
============
Omit the curly braces around an "if", "while", "for" etc. body only when that
body occupies a single line. In every other case we require the braces. This
ensures that it is trivially easy to identify a single-*statement* loop: each
has only one *line* in its body.
Omitting braces with a single-line body is fine:
while (expr) // one-line body -> omitting curly braces is ok
single_line_stmt ();
However, the moment your loop/if/else body extends onto a second line, for
whatever reason (even if it's just an added comment), then you should add
braces. Otherwise, it would be too easy to insert a statement just before that
comment (without adding braces), thinking it is already a multi-statement
loop:
while (true) // BAD! multi-line body with no braces
/* comment... */
single_line_stmt ();
Do this instead:
while (true) { // Always put braces around a multi-line body.
/* comment... */
single_line_stmt ();
}
There is one exception: when the second body line is not at the same
indentation level as the first body line:
if (expr)
die ("a diagnostic that would make this line"
" extend past the 80-column limit"));
It is safe to omit the braces in the code above, since the further-indented
second body line makes it obvious that this is still a single-statement body.
To reiterate, don't do this:
if (expr) // BAD: no braces around...
while (expr_2) { // ... a multi-line body
...
}
Do this, instead:
if (expr) {
while (expr_2) {
...
}
}
However, there is one exception in the other direction, when even a one-line
block should have braces. That occurs when that one-line, brace-less block is
an "else" block, and the corresponding "then" block *does* use braces. In that
case, either put braces around the "else" block, or negate the "if"-condition
and swap the bodies, putting the one-line block first and making the longer,
multi-line block be the "else" block.
if (expr) {
...
...
}
else
x = y; // BAD: braceless "else" with braced "then"
This is preferred, especially when the multi-line body is more than a few
lines long, because it is easier to read and grasp the semantics of an if-
then-else block when the simpler block occurs first, rather than after the
more involved block:
if (!expr)
x = y; // putting the smaller block first is more readable
else {
...
...
}
If you'd rather not negate the condition, then at least add braces:
if (expr) {
...
...
} else {
x = y;
}
Preprocessor
============
For variadic macros, stick with C99 syntax:
#define vshPrint(_ctl, ...) fprintf(stdout, __VA_ARGS__)
Use parenthesis when checking if a macro is defined, and use
indentation to track nesting:
#if defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_FALLOCATE)
# define fallocate(a,ignored,b,c) posix_fallocate(a,b,c)
#endif
C types
=======
Use the right type.
@ -328,7 +436,7 @@ complexity it's best to stick to the following general plan for all
#include <limits.h>
#if HAVE_NUMACTL Some system includes aren't supported
#include <numa.h> everywhere so need these #if defences.
# include <numa.h> everywhere so need these #if guards.
#endif
#include "internal.h" Include this first, after system includes.
@ -363,18 +471,18 @@ of arguments.
Libvirt commiters guidelines
Libvirt committer guidelines
============================
The AUTHORS files indicates the list of people with commit acces right
The AUTHORS files indicates the list of people with commit access right
who can actually merge the patches.
The general rule for commiting patches is to make sure it has been reviewed
properly in the mailing-list first, usually if a couple of persons gave an
The general rule for committing a patch is to make sure it has been reviewed
properly in the mailing-list first, usually if a couple of people gave an
ACK or +1 to a patch and nobody raised an objection on the list it should
be good to go. If the patch touches a part of the code where you're not the
main maintainer or not have a very clear idea of how things work, it's better
to wait for a more authoritative feedback though. Before commiting please
to wait for a more authoritative feedback though. Before committing please
also rebuild locally and run 'make check syntax-check' and make sure they
don't raise error. Try to look for warnings too for example configure with
--enable-compile-warnings=error
@ -382,13 +490,13 @@ which adds -Werror to compile flags, so no warnings get missed
Exceptions to that 'review and approval on the list first' is fixing failures
to build:
- if a recently commited patch breaks compilation on a platform
- if a recently committed patch breaks compilation on a platform
or for a given driver then it's fine to commit a minimal fix
directly without getting the review feedback first
- similary if make check or make syntax-check breaks, if there is
- similarly, if make check or make syntax-check breaks, if there is
an obvious fix, it's fine to commit immediately
The patch should still be sent to the list (or tell what the fix was if
trivial) and 'make check syntax-check' should pass too before commiting
trivial) and 'make check syntax-check' should pass too before committing
anything
Similary fixes for documentation and code comments can be managed
Similar fixes for documentation and code comments can be managed
in the same way, but still make sure they get reviewed if non-trivial.

View File

@ -5,7 +5,8 @@ GENHTML = genhtml
SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \
python tests po examples/domain-events/events-c examples/hellolibvirt \
examples/dominfo examples/domsuspend examples/python examples/apparmor
examples/dominfo examples/domsuspend examples/python examples/apparmor \
examples/xml/nwfilter examples/openauth
ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4
@ -26,12 +27,14 @@ EXTRA_DIST = \
.x-sc_prohibit_asprintf \
.x-sc_prohibit_gethostby \
.x-sc_prohibit_gethostname \
.x-sc_prohibit_gettext_noop \
.x-sc_prohibit_have_config_h \
.x-sc_prohibit_HAVE_MBRTOWC \
.x-sc_prohibit_nonreentrant \
.x-sc_prohibit_strcmp \
.x-sc_prohibit_strcmp_and_strncmp \
.x-sc_prohibit_strncpy \
.x-sc_prohibit_test_minus_ao \
.x-sc_prohibit_VIR_ERR_NO_MEMORY \
.x-sc_require_config_h \
.x-sc_require_config_h_first \
@ -65,10 +68,14 @@ tests:
cov: clean-cov
mkdir $(top_builddir)/coverage
$(LCOV) -c -o $(top_builddir)/coverage/libvirt.info.tmp -d $(top_srcdir)/src -d $(top_srcdir)/daemon -d $(top_srcdir)/tests
$(LCOV) -r $(top_builddir)/coverage/libvirt.info.tmp -o $(top_builddir)/coverage/libvirt.info *usr*
$(LCOV) -c -o $(top_builddir)/coverage/libvirt.info.tmp \
-d $(top_builddir)/src -d $(top_builddir)/daemon \
-d $(top_builddir)/tests
$(LCOV) -r $(top_builddir)/coverage/libvirt.info.tmp \
-o $(top_builddir)/coverage/libvirt.info
rm $(top_builddir)/coverage/libvirt.info.tmp
$(GENHTML) -s -t "libvirt" -o $(top_builddir)/coverage --legend $(top_builddir)/coverage/libvirt.info
$(GENHTML) --show-details -t "libvirt" -o $(top_builddir)/coverage \
--legend $(top_builddir)/coverage/libvirt.info
clean-cov:
rm -rf $(top_builddir)/coverage

View File

@ -13,13 +13,17 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dnl ******************************
AC_ARG_ENABLE(compile-warnings,
AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
[Turn on compiler warnings]),,
[AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
[Turn on compiler warnings])],,
[enable_compile_warnings="m4_default([$1],[maximum])"])
warnCFLAGS=
common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
common_flags=
common_flags="$common_flags -Wp,-D_FORTIFY_SOURCE=2"
common_flags="$common_flags -fexceptions"
common_flags="$common_flags -fasynchronous-unwind-tables"
common_flags="$common_flags -fdiagnostics-show-option"
case "$enable_compile_warnings" in
no)
@ -32,9 +36,19 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes $common_flags"
;;
maximum|error)
try_compiler_flags="-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
try_compiler_flags="-Wall -Wformat -Wformat-security"
try_compiler_flags="$try_compiler_flags -Wmissing-prototypes"
try_compiler_flags="$try_compiler_flags -Wnested-externs "
try_compiler_flags="$try_compiler_flags -Wpointer-arith"
try_compiler_flags="$try_compiler_flags -Wextra -Wshadow"
try_compiler_flags="$try_compiler_flags -Wcast-align"
try_compiler_flags="$try_compiler_flags -Wwrite-strings"
try_compiler_flags="$try_compiler_flags -Waggregate-return"
try_compiler_flags="$try_compiler_flags -Wstrict-prototypes"
try_compiler_flags="$try_compiler_flags -Winline"
try_compiler_flags="$try_compiler_flags -Wredundant-decls"
try_compiler_flags="$try_compiler_flags -Wno-sign-compare"
try_compiler_flags="$try_compiler_flags -Wlogical-op"
try_compiler_flags="$try_compiler_flags $common_flags"
if test "$enable_compile_warnings" = "error" ; then
try_compiler_flags="$try_compiler_flags -Werror"
@ -74,7 +88,9 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
AC_MSG_RESULT($complCFLAGS)
WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
AC_SUBST(WARN_CFLAGS)
WARN_LDFLAGS=$WARN_CFLAGS
AC_SUBST([WARN_CFLAGS])
AC_SUBST([WARN_LDFLAGS])
dnl Needed to keep compile quiet on python 2.4
COMPILER_FLAGS=

View File

@ -6,6 +6,7 @@ set -v
# Make things clean.
test -n "$1" && RESULTS=$1 || RESULTS=results.log
: ${AUTOBUILD_INSTALL_ROOT=$HOME/builder}
test -f Makefile && make -k distclean || :
rm -rf coverage
@ -34,9 +35,14 @@ esac
make
make install
set -o pipefail
make check 2>&1 | tee "$RESULTS"
make syntax-check 2>&1 | tee -a "$RESULTS"
# set -o pipefail is a bashism; this use of exec is the POSIX alternative
exec 3>&1
st=$(
exec 4>&1 >&3
{ make check syntax-check 2>&1; echo $? >&4; } | tee "$RESULTS"
)
exec 3>&-
test $st = 0
test -x /usr/bin/lcov && make cov
rm -f *.tar.gz

View File

@ -56,25 +56,33 @@ if test "x$1" = "x--system"; then
EXTRA_ARGS="--prefix=/usr --sysconfdir=/etc --localstatedir=/var"
echo "Running ./configure with $EXTRA_ARGS $@"
else
if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
if test -z "$*" && test ! -f "$THEDIR/config.status"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
fi
# Compute the hash we'll use to determine whether rerunning bootstrap
# is required. The first is just the SHA1 that selects a gnulib snapshot.
# The second ensures that whenever we change the set of gnulib modules used
# by this package, we rerun bootstrap to pull in the matching set of files.
bootstrap_hash()
{
git submodule status | sed 's/^[ +-]//;s/ .*//'
git hash-object bootstrap.conf
}
# Ensure that whenever we pull in a gnulib update or otherwise change to a
# different version (i.e., when switching branches), we also rerun ./bootstrap.
curr_status=.git-module-status
t=$(git submodule status|sed 's/^[ +-]//;s/ .*//')
t=$(bootstrap_hash; git diff .gnulib)
if test "$t" = "$(cat $curr_status 2>/dev/null)"; then
: # good, it's up to date, all we need is autoreconf
autoreconf -if
else
echo running bootstrap...
./bootstrap && echo "$t" > $curr_status || {
echo "Failed to bootstrap gnulib, please investigate."
exit 1;
}
echo running bootstrap...
./bootstrap && bootstrap_hash > $curr_status \
|| { echo "Failed to bootstrap gnulib, please investigate."; exit 1; }
fi
cd "$THEDIR"
@ -84,7 +92,11 @@ if test "x$OBJ_DIR" != x; then
cd "$OBJ_DIR"
fi
$srcdir/configure $EXTRA_ARGS "$@" && {
if test -z "$*" && test -f config.status; then
./config.status --recheck
else
$srcdir/configure $EXTRA_ARGS "$@"
fi && {
echo
echo "Now type 'make' to compile libvirt."
}

View File

@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2010-02-24.17; # UTC
scriptversion=2010-05-17.18; # UTC
# Bootstrap this package from checked-out sources.
@ -409,6 +409,7 @@ git_modules_config () {
}
gnulib_path=`git_modules_config submodule.gnulib.path`
: ${gnulib_path=gnulib}
# Get gnulib files.
@ -424,7 +425,8 @@ case ${GNULIB_SRCDIR--} in
trap cleanup_gnulib 1 2 13 15
git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
shallow=
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
cleanup_gnulib
@ -437,7 +439,7 @@ case ${GNULIB_SRCDIR--} in
if test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule --help|grep reference > /dev/null; then
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
@ -488,7 +490,7 @@ update_po_files() {
test -d $ref_po_dir || mkdir $ref_po_dir || return
download_po_files $ref_po_dir $domain \
&& ls "$ref_po_dir"/*.po 2>/dev/null |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
test "$langs" = '*' && langs=x
@ -819,7 +821,7 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
}
' po/Makevars.template >po/Makevars
' po/Makevars.template >po/Makevars || exit 1
if test -d runtime-po; then
# Similarly for runtime-po/Makevars, but not quite the same.
@ -833,7 +835,7 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
}
' <po/Makevars.template >runtime-po/Makevars
' po/Makevars.template >runtime-po/Makevars || exit 1
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)

View File

@ -25,11 +25,14 @@ c-ctype
canonicalize-lgpl
close
connect
count-one-bits
dirname-lgpl
fcntl-h
getaddrinfo
gethostname
getpass
gettext
gettext-h
gettimeofday
gitlog-to-changelog
gnumakefile
ignore-value
@ -38,12 +41,15 @@ ioctl
maintainer-makefile
mkstemp
mktempd
netdb
perror
physmem
poll
posix-shell
pthread
recv
random_r
sched
send
setsockopt
socket
@ -51,10 +57,16 @@ stpcpy
strchrnul
strndup
strerror
strptime
strsep
strtok_r
sys_stat
sys_wait
time_r
timegm
uname
useless-if-before-free
usleep
vasprintf
verify
vc-list-files
@ -72,6 +84,12 @@ MSGID_BUGS_ADDRESS=libvir-list@redhat.com
COPYRIGHT_HOLDER='Red Hat, Inc.'
SKIP_PO=true
# Enable copy-mode for MSYS/MinGW. MSYS' ln doesn't work well in the way
# bootstrap uses it with relative paths.
if test -n "$MSYSTEM"; then
copy=true
fi
# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]"
# appears in configure.ac, exclude some unnecessary files.
# Without grep's -E option (not portable enough, pre-configure),
@ -128,7 +146,6 @@ git 1.5.5
gzip -
libtool -
perl 5.5
rsync -
tar -
"

View File

@ -6,6 +6,7 @@
/useless-if-before-free
/vc-list-files
arg-nonnull.h
c++defs.h
config.rpath
gitlog-to-changelog
mkinstalldirs

369
cfg.mk
View File

@ -24,6 +24,9 @@ gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
url_dir_list = \
ftp://$(gnu_rel_host)/gnu/coreutils
# We use .gnulib, not gnulib.
gnulib_dir = $(srcdir)/.gnulib
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
changelog-check \
@ -34,6 +37,7 @@ local-checks-to-skip = \
sc_GPL_version \
sc_always_defined_macros \
sc_cast_of_alloca_return_value \
sc_cross_check_PATH_usage_in_tests \
sc_dd_max_sym_length \
sc_error_exit_success \
sc_file_system \
@ -51,6 +55,7 @@ local-checks-to-skip = \
sc_space_tab \
sc_sun_os_names \
sc_system_h_headers \
sc_texinfo_acronym \
sc_tight_scope \
sc_two_space_separator_in_usage \
sc_error_message_uppercase \
@ -59,104 +64,258 @@ local-checks-to-skip = \
sc_makefile_check \
sc_useless_cpp_parens
useless_free_options = \
--name=sexpr_free \
--name=VIR_FREE \
--name=xmlFree \
--name=xmlXPathFreeContext \
useless_free_options = \
--name=VIR_FREE \
--name=sexpr_free \
--name=virBitmapFree \
--name=virCPUDefFree \
--name=virCapabilitiesFree \
--name=virCapabilitiesFreeGuest \
--name=virCapabilitiesFreeGuestDomain \
--name=virCapabilitiesFreeGuestFeature \
--name=virCapabilitiesFreeGuestMachine \
--name=virCapabilitiesFreeHostNUMACell \
--name=virCapabilitiesFreeMachines \
--name=virCgroupFree \
--name=virConfFreeList \
--name=virConfFreeValue \
--name=virDomainChrDefFree \
--name=virDomainControllerDefFree \
--name=virDomainDefFree \
--name=virDomainDeviceDefFree \
--name=virDomainDiskDefFree \
--name=virDomainEventCallbackListFree \
--name=virDomainEventFree \
--name=virDomainEventQueueFree \
--name=virDomainFSDefFree \
--name=virDomainGraphicsDefFree \
--name=virDomainHostdevDefFree \
--name=virDomainInputDefFree \
--name=virDomainNetDefFree \
--name=virDomainObjFree \
--name=virDomainSnapshotDefFree \
--name=virDomainSnapshotObjFree \
--name=virDomainSoundDefFree \
--name=virDomainVideoDefFree \
--name=virDomainWatchdogDefFree \
--name=virInterfaceDefFree \
--name=virInterfaceIpDefFree \
--name=virInterfaceObjFree \
--name=virInterfaceProtocolDefFree \
--name=virJSONValueFree \
--name=virLastErrFreeData \
--name=virNWFilterDefFree \
--name=virNWFilterEntryFree \
--name=virNWFilterHashTableFree \
--name=virNWFilterIPAddrLearnReqFree \
--name=virNWFilterIncludeDefFree \
--name=virNWFilterPoolObjFree \
--name=virNWFilterRuleDefFree \
--name=virNWFilterRuleInstFree \
--name=virNetworkDefFree \
--name=virNetworkObjFree \
--name=virNodeDeviceDefFree \
--name=virNodeDeviceObjFree \
--name=virSecretDefFree \
--name=virStorageEncryptionFree \
--name=virStorageEncryptionSecretFree \
--name=virStoragePoolDefFree \
--name=virStoragePoolObjFree \
--name=virStoragePoolSourceFree \
--name=virStorageVolDefFree \
--name=xmlFree \
--name=xmlXPathFreeContext \
--name=xmlXPathFreeObject
# The following template was generated by this command:
# make ID && aid free|grep '^vi'|sed 's/ .*//;s/^/# /'
# N virBufferFreeAndReset
# y virCPUDefFree
# y virCapabilitiesFree
# y virCapabilitiesFreeGuest
# y virCapabilitiesFreeGuestDomain
# y virCapabilitiesFreeGuestFeature
# y virCapabilitiesFreeGuestMachine
# y virCapabilitiesFreeHostNUMACell
# y virCapabilitiesFreeMachines
# N virCapabilitiesFreeNUMAInfo FIXME
# y virCgroupFree
# N virConfFree (diagnoses the "error")
# y virConfFreeList
# y virConfFreeValue
# y virDomainChrDefFree
# y virDomainControllerDefFree
# y virDomainDefFree
# y virDomainDeviceDefFree
# y virDomainDiskDefFree
# y virDomainEventCallbackListFree
# y virDomainEventFree
# y virDomainEventQueueFree
# y virDomainFSDefFree
# n virDomainFree
# n virDomainFreeName (can't fix -- returns int)
# y virDomainGraphicsDefFree
# y virDomainHostdevDefFree
# y virDomainInputDefFree
# y virDomainNetDefFree
# y virDomainObjFree
# y virDomainSnapshotDefFree
# n virDomainSnapshotFree (returns int)
# n virDomainSnapshotFreeName (returns int)
# y virDomainSnapshotObjFree
# y virDomainSoundDefFree
# y virDomainVideoDefFree
# y virDomainWatchdogDefFree
# n virDrvNodeGetCellsFreeMemory (returns int)
# n virDrvNodeGetFreeMemory (returns long long)
# n virFree (dereferences param)
# n virFreeError
# n virHashFree (takes 2 args)
# y virInterfaceDefFree
# n virInterfaceFree (returns int)
# n virInterfaceFreeName
# y virInterfaceIpDefFree
# y virInterfaceObjFree
# n virInterfaceObjListFree
# y virInterfaceProtocolDefFree
# y virJSONValueFree
# y virLastErrFreeData
# y virNWFilterDefFree
# y virNWFilterEntryFree
# n virNWFilterFree (returns int)
# y virNWFilterHashTableFree
# y virNWFilterIPAddrLearnReqFree
# y virNWFilterIncludeDefFree
# n virNWFilterPoolFreeName (returns int)
# y virNWFilterPoolObjFree
# n virNWFilterPoolObjListFree FIXME
# y virNWFilterRuleDefFree
# n virNWFilterRuleFreeInstanceData (typedef)
# y virNWFilterRuleInstFree
# y virNetworkDefFree
# n virNetworkFree (returns int)
# n virNetworkFreeName (returns int)
# y virNetworkObjFree
# n virNetworkObjListFree FIXME
# n virNodeDevCapsDefFree FIXME
# y virNodeDeviceDefFree
# n virNodeDeviceFree (returns int)
# y virNodeDeviceObjFree
# n virNodeDeviceObjListFree FIXME
# n virNodeGetCellsFreeMemory (returns int)
# n virNodeGetFreeMemory (returns non-void)
# y virSecretDefFree
# n virSecretFree (returns non-void)
# n virSecretFreeName (2 args)
# n virSecurityLabelDefFree FIXME
# n virStorageBackendDiskMakeFreeExtent (returns non-void)
# y virStorageEncryptionFree
# y virStorageEncryptionSecretFree
# n virStorageFreeType (enum)
# y virStoragePoolDefFree
# n virStoragePoolFree (returns non-void)
# n virStoragePoolFreeName (returns non-void)
# y virStoragePoolObjFree
# n virStoragePoolObjListFree FIXME
# y virStoragePoolSourceFree
# y virStorageVolDefFree
# n virStorageVolFree (returns non-void)
# n virStorageVolFreeName (returns non-void)
# n virStreamFree
# Avoid uses of write(2). Either switch to streams (fwrite), or use
# the safewrite wrapper.
sc_avoid_write:
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
grep '\<write *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$') && \
{ echo "$(ME): the above files use write;" \
" consider using the safewrite wrapper instead" \
1>&2; exit 1; } || :; \
else :; \
fi
@prohibit='\<write *\(' \
in_vc_files='\.c$$' \
halt='consider using safewrite instead of write' \
$(_sc_search_regexp)
# Use STREQ rather than comparing strcmp == 0, or != 0.
# Similarly, use STREQLEN or STRPREFIX rather than strncmp.
sc_prohibit_strcmp_and_strncmp:
@re='strn?cmp *\(' \
msg='use STREQ() in place of the above uses of str[n]cmp' \
$(_prohibit_regexp)
@prohibit='strn?cmp *\(' \
halt='use STREQ() in place of the above uses of str[n]cmp' \
$(_sc_search_regexp)
# Use virAsprintf rather than a'sprintf since *strp is undefined on error.
sc_prohibit_asprintf:
@re='\<[a]sprintf\>' \
msg='use virAsprintf, not a'sprintf \
$(_prohibit_regexp)
@prohibit='\<[a]sprintf\>' \
halt='use virAsprintf, not a'sprintf \
$(_sc_search_regexp)
sc_prohibit_strncpy:
@re='strncpy *\(' \
msg='use virStrncpy, not strncpy' \
$(_prohibit_regexp)
@prohibit='strncpy *\(' \
halt='use virStrncpy, not strncpy' \
$(_sc_search_regexp)
sc_prohibit_readlink:
@re='readlink *\(' \
msg='use virFileResolveLink, not readlink' \
$(_prohibit_regexp)
@prohibit='readlink *\(' \
halt='use virFileResolveLink, not readlink' \
$(_sc_search_regexp)
sc_prohibit_gethostname:
@re='gethostname *\(' \
msg='use virGetHostname, not gethostname' \
$(_prohibit_regexp)
@prohibit='gethostname *\(' \
halt='use virGetHostname, not gethostname' \
$(_sc_search_regexp)
sc_prohibit_gettext_noop:
@prohibit='gettext_noop *\(' \
halt='use N_, not gettext_noop' \
$(_sc_search_regexp)
sc_prohibit_VIR_ERR_NO_MEMORY:
@re='\<V''IR_ERR_NO_MEMORY\>' \
msg='use virReportOOMError, not V'IR_ERR_NO_MEMORY \
$(_prohibit_regexp)
@prohibit='\<V''IR_ERR_NO_MEMORY\>' \
halt='use virReportOOMError, not V'IR_ERR_NO_MEMORY \
$(_sc_search_regexp)
# Use a subshell for each function, to give the optimal warning message.
include $(srcdir)/Makefile.nonreentrant
sc_prohibit_nonreentrant:
@fail=0 ; \
for i in $(NON_REENTRANT) ; \
do \
grep --before 2 --after 1 -nE "\<$$i\>[:space:]*\(" $$($(VC_LIST_EXCEPT)) && \
fail=1 && echo "$(ME): use $${i}_r, not $${i}" || : ; \
(prohibit="\\<$$i *\\(" \
halt="use $${i}_r, not $$i" \
$(_sc_search_regexp) \
) || fail=1; \
done ; \
exit $$fail
# Prohibit the inclusion of <ctype.h>.
sc_prohibit_ctype_h:
@grep -E '^# *include *<ctype\.h>' $$($(VC_LIST_EXCEPT)) && \
{ echo "$(ME): don't use ctype.h; instead, use c-ctype.h" \
1>&2; exit 1; } || :
@prohibit='^# *include *<ctype\.h>' \
halt="don't use ctype.h; instead, use c-ctype.h" \
$(_sc_search_regexp)
# Ensure that no C source file uses TABs for indentation.
# Also match *.h.in files, to get libvirt.h.in.
# Exclude files in gnulib, since they're imported.
# Ensure that no C source file or rng schema uses TABs for
# indentation. Also match *.h.in files, to get libvirt.h.in. Exclude
# files in gnulib, since they're imported.
sc_TAB_in_indentation:
@grep -lE '^ * ' /dev/null \
$$($(VC_LIST_EXCEPT) \
| grep -E '\.(rng|[ch](\.in)?)$$' \
| grep -v '^gnulib/') && \
{ echo '$(ME): found TAB(s) used for indentation in C sources;'\
'use spaces' 1>&2; exit 1; } || :
@prohibit='^ * ' \
in_vc_files='(\.(rng|[ch](\.in)?)|(daemon|tools)/.*\.in)$$' \
halt='use spaces, not TAB, for indentation in C, sh, and RNG schemas' \
$(_sc_search_regexp)
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
sc_avoid_ctype_macros:
@grep -E '\b($(ctype_re)) *\(' /dev/null \
$$($(VC_LIST_EXCEPT)) && \
{ echo "$(ME): don't use ctype macros (use c-ctype.h)" \
1>&2; exit 1; } || :
@prohibit='\b($(ctype_re)) *\(' \
halt="don't use ctype macros (use c-ctype.h)" \
$(_sc_search_regexp)
sc_prohibit_virBufferAdd_with_string_literal:
@re='\<virBufferAdd *\([^,]+, *"[^"]' \
msg='use virBufferAddLit, not virBufferAdd, with a string literal' \
$(_prohibit_regexp)
@prohibit='\<virBufferAdd *\([^,]+, *"[^"]' \
halt='use virBufferAddLit, not virBufferAdd, with a string literal' \
$(_sc_search_regexp)
# Not only do they fail to deal well with ipv6, but the gethostby*
# functions are also not thread-safe.
sc_prohibit_gethostby:
@re='\<gethostby(addr|name2?) *\(' \
msg='use getaddrinfo, not gethostby*' \
$(_prohibit_regexp)
@prohibit='\<gethostby(addr|name2?) *\(' \
halt='use getaddrinfo, not gethostby*' \
$(_sc_search_regexp)
# Many of the function names below came from this filter:
# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
@ -164,36 +323,27 @@ sc_prohibit_gethostby:
# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
msg_gen_function =
msg_gen_function += DEBUG0
msg_gen_function += DISABLE_fprintf
msg_gen_function += ERROR
msg_gen_function += ERROR0
msg_gen_function += REMOTE_DEBUG
msg_gen_function += ReportError
msg_gen_function += VIR_FREE
msg_gen_function += VIR_INFO
msg_gen_function += VIR_USE_CPU
msg_gen_function += errorf
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
msg_gen_function += macvtapError
msg_gen_function += remoteError
msg_gen_function += lxcError
msg_gen_function += networkLog
msg_gen_function += networkReportError
msg_gen_function += oneError
msg_gen_function += openvzError
msg_gen_function += openvzLog
msg_gen_function += qemudDispatchClientFailure
msg_gen_function += qemudLog
msg_gen_function += qemudReportError
msg_gen_function += regerror
msg_gen_function += remoteDispatchFormatError
msg_gen_function += umlLog
msg_gen_function += umlReportError
msg_gen_function += vboxError
msg_gen_function += virConfError
msg_gen_function += virDomainReportError
msg_gen_function += virSecurityReportError
msg_gen_function += virHashError
msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError
msg_gen_function += virLog
msg_gen_function += virNetworkReportError
msg_gen_function += virNodeDeviceReportError
msg_gen_function += virProxyError
@ -201,20 +351,20 @@ msg_gen_function += virRaiseError
msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError
msg_gen_function += virSexprError
msg_gen_function += virStorageLog
msg_gen_function += virStorageReportError
msg_gen_function += virXMLError
msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError
msg_gen_function += vshCloseLogFile
msg_gen_function += xenapiSessionErrorHandler
msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
msg_gen_function += VIR_ERROR
msg_gen_function += VIR_ERROR0
# Uncomment the following and run "make syntax-check" to see diagnostics
# that are not yet marked for translation, but that need to be rewritten
# so that they are translatable.
# msg_gen_function += error
# msg_gen_function += fprintf
# msg_gen_function += testError
# msg_gen_function += virXenError
@ -231,7 +381,7 @@ func_re := ($(func_or))
# "%s", _("no storage vol w..."
sc_libvirt_unmarked_diagnostics:
@grep -nE \
'\<$(func_re) \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
'\<$(func_re) *\([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
| grep -v '_''(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
@ -242,6 +392,20 @@ sc_libvirt_unmarked_diagnostics:
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
# Like the above, but prohibit a newline at the end of a diagnostic.
# This is subject to false positives partly because it naively looks for
# `\n"', which may not be the end of the string, and also because it takes
# two lines of context (the -A2) after the line with the function name.
# FIXME: this rule might benefit from a separate function list, in case
# there are functions to which this one applies but that do not get marked
# diagnostics.
sc_prohibit_newline_at_end_of_diagnostic:
@grep -A2 -nE \
'\<$(func_re) *\(' $$($(VC_LIST_EXCEPT)) \
| grep '\\n"' \
&& { echo '$(ME): newline at end of message(s)' 1>&2; \
exit 1; } || :
# Disallow trailing blank lines.
sc_prohibit_trailing_blank_lines:
@$(VC_LIST_EXCEPT) | xargs perl -ln -0777 -e \
@ -251,6 +415,35 @@ sc_prohibit_trailing_blank_lines:
rm -f $@-t; \
test $$found = 0
# Regex for grep -E that exempts generated files from style rules.
preprocessor_exempt = ((qemu|remote)_(driver|protocol)\.h)$$
# Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation:
@if cppi --version >/dev/null 2>&1; then \
$(VC_LIST_EXCEPT) | grep '\.[ch]$$' \
| grep -vE '$(preprocessor_exempt)' | xargs cppi -a -c \
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
exit 1; }; \
else \
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
fi
sc_copyright_format:
@require='Copyright .*Red 'Hat', Inc\.' \
containing='Copyright .*Red 'Hat \
halt='Red Hat copyright is missing Inc.' \
$(_sc_search_regexp)
@prohibit='Copyright [^(].*Red 'Hat \
halt='consistently use (C) in Red Hat copyright' \
$(_sc_search_regexp)
# Some functions/macros produce messages intended solely for developers
# and maintainers. Do not mark them for translation.
sc_prohibit_gettext_markup:
@prohibit='\<VIR_(WARN|DEBUG)0? *\(_\(' \
halt='do not mark these strings for translation' \
$(_sc_search_regexp)
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
@ -266,13 +459,39 @@ ifeq (0,$(MAKELEVEL))
# b653eda3ac4864de205419d9f41eec267cb89eeb
_submodule_hash = sed 's/^[ +-]//;s/ .*//'
_update_required := $(shell \
actual=$$(git submodule status | $(_submodule_hash)); \
cd '$(srcdir)'; \
actual=$$(git submodule status | $(_submodule_hash); \
git hash-object bootstrap.conf; \
git diff .gnulib); \
stamp="$$($(_submodule_hash) $(_curr_status) 2>/dev/null)"; \
test "$$stamp" = "$$actual"; echo $$?)
ifeq (1,$(_update_required))
$(error gnulib update required; run ./autogen.sh first)
_clean_requested = $(filter %clean,$(MAKECMDGOALS))
ifeq (1,$(_update_required)$(_clean_requested))
$(info INFO: gnulib update required; running ./autogen.sh first)
Makefile: _autogen
endif
endif
# Give credit where due:
# Ensure that each commit author email address (possibly mapped via
# git log's .mailmap) appears in our AUTHORS file.
sc_check_author_list:
@fail=0; \
for i in $$(git log --pretty=format:%aE%n|sort -u|grep -v '^$$'); do \
sanitized=$$(echo "$$i"|LC_ALL=C sed 's/\([^a-zA-Z0-9_@-]\)/\\\1/g'); \
grep -iq "<$$sanitized>" $(srcdir)/AUTHORS \
|| { printf '%s\n' "$$i" >&2; fail=1; }; \
done; \
test $$fail = 1 \
&& echo '$(ME): committer(s) not listed in AUTHORS' >&2; \
test $$fail = 0
# It is necessary to call autogen any time gnulib changes. Autogen
# reruns configure, then we regenerate all Makefiles at once.
.PHONY: _autogen
_autogen:
$(srcdir)/autogen.sh
./config.status
# Exempt @...@ uses of these symbols.
_makefile_at_at_check_exceptions = ' && !/(SCHEMA|SYSCONF)DIR/'

View File

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([libvirt], [0.7.7])
AC_INIT([libvirt], [0.8.3])
AC_CONFIG_SRCDIR([src/libvirt.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
@ -41,26 +41,19 @@ XMLRPC_REQUIRED=1.14.0
HAL_REQUIRED=0.5.0
DEVMAPPER_REQUIRED=1.0.0
LIBCURL_REQUIRED="7.18.0"
LIBPCAP_REQUIRED="1.0.0"
LIBNL_REQUIRED="1.1"
dnl Checks for C compiler.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_CPP
AC_OBJEXT
dnl gl_INIT uses m4_foreach_w, yet that is not defined in autoconf-2.59.
dnl In order to accommodate developers with such old tools, here's a
dnl replacement definition.
m4_ifndef([m4_foreach_w],
[m4_define([m4_foreach_w],
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
gl_EARLY
gl_INIT
AM_PROG_CC_STDC
AC_C_CONST
AC_TYPE_UID_T
dnl Make sure we have an ANSI compiler
AM_C_PROTOTYPES
@ -71,11 +64,11 @@ AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AM_PROG_CC_C_O
AM_PROG_LD
VERSION_SCRIPT_FLAGS=-Wl,--version-script=
`/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null` || \
`$LD --help 2>&1 | grep -- --version-script >/dev/null` || \
VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
AC_SUBST(VERSION_SCRIPT_FLAGS)
LIBVIRT_COMPILE_WARNINGS([maximum])
@ -99,18 +92,24 @@ fi
AC_MSG_RESULT([$have_cpuid])
dnl Support large files / 64 bit seek offsets.
dnl Use --disable-largefile if you don't want this.
AC_SYS_LARGEFILE
dnl Availability of various common functions (non-fatal if missing).
AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid getgid posix_fallocate mmap])
AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \
posix_fallocate mmap])
dnl Availability of various not common threadsafe functions
AC_CHECK_FUNCS([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r])
AC_CHECK_FUNCS_ONCE([strerror_r getmntent_r getgrnam_r getpwuid_r])
dnl Availability of pthread functions (if missing, win32 threading is
dnl assumed). Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE.
dnl LIB_PTHREAD was set during gl_INIT by gnulib.
old_LIBS=$LIBS
LIBS="$LIBS $LIB_PTHREAD"
AC_CHECK_FUNCS([pthread_sigmask pthread_mutexattr_init])
LIBS=$old_libs
dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/utsname.h sys/wait.h winsock2.h sched.h termios.h sys/poll.h syslog.h mntent.h])
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h \
termios.h sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h])
dnl Where are the XDR functions?
dnl If portablexdr is installed, prefer that.
@ -121,6 +120,9 @@ AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
[AC_MSG_ERROR([Cannot find a XDR library])])
])
dnl check for cygwin's variation in xdr function names
AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include <rpc/xdr.h>])
AC_CHECK_LIB([intl],[gettext],[])
dnl Do we have rpcgen?
@ -131,14 +133,6 @@ AM_CONDITIONAL([HAVE_GLIBC_RPCGEN],
[test "x$ac_cv_path_RPCGEN" != "xno" &&
$ac_cv_path_RPCGEN -t </dev/null >/dev/null 2>&1])
dnl pthread?
AC_CHECK_HEADER([pthread.h],
[AC_CHECK_LIB([pthread],[pthread_join],[
AC_DEFINE([HAVE_LIBPTHREAD],[],[Define if pthread (-lpthread)])
AC_DEFINE([HAVE_PTHREAD_H],[],[Define if <pthread.h>])
LIBS="-lpthread $LIBS"
])])
dnl Miscellaneous external programs.
AC_PATH_PROG([RM], [rm], [/bin/rm])
AC_PATH_PROG([MV], [mv], [/bin/mv])
@ -196,13 +190,29 @@ dnl if --prefix is /usr, don't use /usr/var for localstatedir
dnl or /usr/etc for sysconfdir
dnl as this makes a lot of things break in testing situations
if test "$prefix" = "/usr" -a "$localstatedir" = '${prefix}/var' ; then
if test "$prefix" = "/usr" && test "$localstatedir" = '${prefix}/var' ; then
localstatedir='/var'
fi
if test "$prefix" = "/usr" -a "$sysconfdir" = '${prefix}/etc' ; then
if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then
sysconfdir='/etc'
fi
dnl lxc and qemu drivers require linux headers
case "$host" in
*-*-linux*)
# match linux here so the *) case will match anything non-linux
;;
*)
if test "x$with_lxc" != "xyes"
then
with_lxc=no
fi
if test "x$with_qemu" != "xyes"
then
with_qemu=no
fi
;;
esac
dnl Allow to build without Xen, QEMU/KVM, test or remote driver
AC_ARG_WITH([xen],
@ -219,8 +229,12 @@ AC_ARG_WITH([libssh2],
AC_HELP_STRING([--with-libssh2=@<:@PFX@:>@], [libssh2 location @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes])
AC_ARG_WITH([phyp],
AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check])
AC_ARG_WITH([xenapi],
AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=check@:>@]),[],[with_xenapi=check])
AC_ARG_WITH([vbox],
AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes])
AC_HELP_STRING([--with-vbox=@<:@PFX@:>@],
[VirtualBox XPCOMC location @<:@default=check@:>@]),[],
[with_vbox=check])
AC_ARG_WITH([lxc],
AC_HELP_STRING([--with-lxc], [add Linux Container support @<:@default=check@:>@]),[],[with_lxc=check])
AC_ARG_WITH([one],
@ -237,7 +251,7 @@ AC_ARG_WITH([libvirtd],
dnl
dnl specific tests to setup DV devel environments with debug etc ...
dnl
if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/libvirt" ]] ; then
if test "${LOGNAME}" = "veillard" && test "`pwd`" = "/u/veillard/libvirt" ; then
STATIC_BINARIES="-static"
else
STATIC_BINARIES=
@ -273,7 +287,7 @@ AC_MSG_CHECKING([for init script flavor])
AC_ARG_WITH([init-script],
[AC_HELP_STRING([--with-init-script=@<:@redhat|auto|none@:>@],
[Style of init script to install @<:@default=auto@:>@])])
if test "x$with_init_script" = "x" -o "x$with_init_script" = "xauto"; then
if test "x$with_init_script" = "x" || test "x$with_init_script" = "xauto"; then
if test -f /etc/redhat-release ; then
with_init_script=redhat
else
@ -297,11 +311,68 @@ AC_DEFINE_UNQUOTED([IPTABLES_PATH], "$IPTABLES_PATH", [path to iptables binary])
AC_PATH_PROG([EBTABLES_PATH], [ebtables], /sbin/ebtables, [/usr/sbin:$PATH])
AC_DEFINE_UNQUOTED([EBTABLES_PATH], "$EBTABLES_PATH", [path to ebtables binary])
if test "$with_openvz" = "yes"; then
AC_DEFINE_UNQUOTED([WITH_OPENVZ], 1, [whether OpenVZ driver is enabled])
fi
AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
dnl
dnl check for VirtualBox XPCOMC location
dnl
vbox_xpcomc_dir=
if test "x$with_vbox" = "xyes" || test "x$with_vbox" = "xcheck"; then
AC_MSG_CHECKING([for VirtualBox XPCOMC location])
for vbox in \
/usr/lib/virtualbox/VBoxXPCOMC.so \
/usr/lib/VirtualBox/VBoxXPCOMC.so \
/opt/virtualbox/VBoxXPCOMC.so \
/opt/VirtualBox/VBoxXPCOMC.so \
/opt/virtualbox/i386/VBoxXPCOMC.so \
/opt/VirtualBox/i386/VBoxXPCOMC.so \
/opt/virtualbox/amd64/VBoxXPCOMC.so \
/opt/VirtualBox/amd64/VBoxXPCOMC.so \
/usr/local/lib/virtualbox/VBoxXPCOMC.so \
/usr/local/lib/VirtualBox/VBoxXPCOMC.so \
/Application/VirtualBox.app/Contents/MacOS/VBoxXPCOMC.dylib \
; do
if test -f "$vbox"; then
vbox_xpcomc_dir=`AS_DIRNAME(["$vbox"])`
break
fi
done
if test -n "$vbox_xpcomc_dir"; then
AC_MSG_RESULT([$vbox_xpcomc_dir])
with_vbox=yes
else
if test "x$with_vbox" = "xcheck"; then
AC_MSG_RESULT([not found, disabling VirtualBox driver])
with_vbox=no
else
AC_MSG_RESULT([not found])
AC_MSG_ERROR([VirtualBox XPCOMC is required for the VirtualBox driver])
fi
fi
else
if test "x$with_vbox" != "xno"; then
if test -f ${with_vbox}/VBoxXPCOMC.so || \
test -f ${with_vbox}/VBoxXPCOMC.dylib; then
vbox_xpcomc_dir=$with_vbox
with_vbox=yes
else
AC_MSG_ERROR([$with_vbox does not contain VirtualBox XPCOMC])
fi
fi
fi
AC_DEFINE_UNQUOTED([VBOX_XPCOMC_DIR], ["$vbox_xpcomc_dir"],
[Location of directory containing VirtualBox XPCOMC library])
if test "x$with_vbox" = "xyes"; then
AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])])
case $ac_cv_search_dlopen in
@ -341,13 +412,53 @@ if test "$with_libvirtd" = "yes" ; then
fi
AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"])
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
LIBXENSERVER_LIBS=""
LIBXENSERVER_CFLAGS=""
dnl search for the XenServer library
if test "$with_xenapi" != "no" ; then
if test "$with_xenapi" != "yes" && test "$with_xenapi" != "check" ; then
LIBXENSERVER_CFLAGS="-I$with_xenapi/include"
LIBXENSERVER_LIBS="-L$with_xenapi"
fi
fail=0
CFLAGS="$CFLAGS $LIBXENSERVER_CFLAGS"
LIBS="$LIBS $LIBXENSERVER_LIBS"
AC_CHECK_LIB([xenserver], [xen_vm_start], [
with_xenapi=yes
LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenserver"
],[
if test "$with_xenapi" = "yes"; then
fail=1
fi
with_xenapi=no
])
fi
LIBS="$old_LIBS"
CFLAGS="$old_CFLAGS"
if test $fail = 1; then
AC_MSG_ERROR([You must install the XenServer Library to compile XenAPI driver with -lxenserver])
fi
if test "$with_xenapi" = "yes"; then
AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled])
fi
AC_SUBST([LIBXENSERVER_CFLAGS])
AC_SUBST([LIBXENSERVER_LIBS])
old_LIBS="$LIBS"
old_CFLAGS="$CFLAGS"
XEN_LIBS=""
XEN_CFLAGS=""
dnl search for the Xen store library
if test "$with_xen" != "no" ; then
if test "$with_xen" != "yes" -a "$with_xen" != "check" ; then
if test "$with_xen" != "yes" && test "$with_xen" != "check" ; then
XEN_CFLAGS="-I$with_xen/include"
XEN_LIBS="-L$with_xen/lib64 -L$with_xen/lib"
fi
@ -439,39 +550,25 @@ AC_CHECK_HEADERS([linux/kvm.h])
dnl
dnl check for sufficient headers for LXC
dnl
if test "$with_lxc" = "yes" -o "$with_lxc" = "check"; then
AC_CHECK_HEADER([sched.h],
dnl Header is there, check for unshare()
[
AC_TRY_LINK([#define _GNU_SOURCE
#include <sched.h>], [
unshare (1);
], [
with_lxc=yes
], [
if test "$with_lxc" = "check"; then
with_lxc=no
AC_MSG_NOTICE([Function unshare() not present in <sched.h> header but required for LXC driver, disabling it])
else
AC_MSG_ERROR([Function unshare() not present in <sched.h> header, but required for LXC driver])
fi
])
dnl Header is not there
],[
if test "$with_lxc" = "check"; then
with_lxc=no
AC_MSG_NOTICE([Header <sched.h> not found but required for LXC driver, disabling it])
else
AC_MSG_ERROR([Header <sched.h> not found but required for LXC driver])
fi
])
fi
if test "$with_libvirtd" = "no" ; then
with_lxc=no
fi
if test "$with_lxc" = "yes" || test "$with_lxc" = "check"; then
AC_TRY_LINK([#define _GNU_SOURCE
#include <sched.h>
], [
unshare (1);
], [
with_lxc=yes
], [
if test "$with_lxc" = "check"; then
with_lxc=no
AC_MSG_NOTICE([Function unshare() not present in <sched.h> header but required for LXC driver, disabling it])
else
AC_MSG_ERROR([Function unshare() not present in <sched.h> header, but required for LXC driver])
fi
])
fi
if test "$with_lxc" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_LXC], 1, [whether LXC driver is enabled])
fi
@ -481,9 +578,9 @@ AM_CONDITIONAL([WITH_LXC], [test "$with_lxc" = "yes"])
dnl
dnl check for kernel headers required by src/bridge.c
dnl
if test "$with_qemu" = "yes" -o "$with_lxc" = "yes" ; then
if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then
AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],,
AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt]))
AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support]))
fi
@ -493,9 +590,12 @@ PKG_PROG_PKG_CONFIG
dnl OpenNebula driver Compilation setting
dnl
if test "$with_libvirtd" = "no" ; then
with_one=no
fi
XMLRPC_CFLAGS=
XMLRPC_LIBS=
if test "x$with_one" = "xyes" -o "x$with_one" = "xcheck"; then
if test "x$with_one" = "xyes" || test "x$with_one" = "xcheck"; then
PKG_CHECK_MODULES(XMLRPC, xmlrpc_client >= $XMLRPC_REQUIRED,
[with_one=yes], [
if test "x$with_one" = "xcheck" ; then
@ -528,7 +628,7 @@ AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 locat
if test "x$with_libxml" = "xno" ; then
AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_REQUIRED)
AC_MSG_ERROR([libxml2 >= $LIBXML_REQUIRED is required for libvirt])
elif test "x$with_libxml" = "x" -a "x$PKG_CONFIG" != "x" ; then
elif test "x$with_libxml" = "x" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
fi
if test "$LIBXML_FOUND" = "no" ; then
@ -618,7 +718,7 @@ AC_ARG_WITH([sasl],
SASL_CFLAGS=
SASL_LIBS=
if test "x$with_sasl" != "xno"; then
if test "x$with_sasl" != "xyes" -a "x$with_sasl" != "xcheck"; then
if test "x$with_sasl" != "xyes" && test "x$with_sasl" != "xcheck"; then
SASL_CFLAGS="-I$with_sasl"
SASL_LIBS="-L$with_sasl"
fi
@ -673,7 +773,7 @@ AC_ARG_WITH([yajl],
YAJL_CFLAGS=
YAJL_LIBS=
if test "x$with_yajl" != "xno"; then
if test "x$with_yajl" != "xyes" -a "x$with_yajl" != "xcheck"; then
if test "x$with_yajl" != "xyes" && test "x$with_yajl" != "xcheck"; then
YAJL_CFLAGS="-I$with_yajl/include"
YAJL_LIBS="-L$with_yajl/lib"
fi
@ -725,7 +825,7 @@ AC_ARG_WITH([polkit],
with_polkit0=no
with_polkit1=no
if test "x$with_polkit" = "xyes" -o "x$with_polkit" = "xcheck"; then
if test "x$with_polkit" = "xyes" || test "x$with_polkit" = "xcheck"; then
dnl Check for new polkit first - just a binary
AC_PATH_PROG([PKCHECK_PATH],[pkcheck], [], [/usr/sbin:$PATH])
if test "x$PKCHECK_PATH" != "x" ; then
@ -783,7 +883,7 @@ AC_ARG_WITH([avahi],
AVAHI_CFLAGS=
AVAHI_LIBS=
if test "x$with_avahi" = "xyes" -o "x$with_avahi" = "xcheck"; then
if test "x$with_avahi" = "xyes" || test "x$with_avahi" = "xcheck"; then
PKG_CHECK_MODULES(AVAHI, avahi-client >= $AVAHI_REQUIRED,
[with_avahi=yes], [
if test "x$with_avahi" = "xcheck" ; then
@ -824,14 +924,14 @@ if test "$with_selinux" != "no"; then
AC_CHECK_HEADER([selinux/selinux.h],[],[fail=1])
AC_CHECK_LIB([selinux], [fgetfilecon],[],[fail=1])
test $fail = 1 &&
AC_MSG_ERROR([You must install the SELinux development package in order to compile libvirt])
AC_MSG_ERROR([You must install the libselinux development package in order to compile libvirt with basic SELinux support])
fi
CFLAGS="$old_cflags"
LIBS="$old_libs"
fi
if test "$with_selinux" = "yes"; then
SELINUX_LIBS="-lselinux"
AC_DEFINE_UNQUOTED([HAVE_SELINUX], 1, [whether SELinux is available for security])
AC_DEFINE_UNQUOTED([HAVE_SELINUX], 1, [whether basic SELinux functionality is available])
fi
AM_CONDITIONAL([HAVE_SELINUX], [test "$with_selinux" != "no"])
AC_SUBST([SELINUX_CFLAGS])
@ -846,8 +946,8 @@ AC_ARG_WITH([secdriver-selinux],
if test "$with_selinux" != "yes" ; then
if test "$with_secdriver_selinux" = "check" ; then
with_secdriver_selinux=no
else
AC_MSG_ERROR([You must install the SELinux development package in order to compile libvirt])
elif test "$with_secdriver_selinux" = "yes"; then
AC_MSG_ERROR([You must install the libselinux development package and enable SELinux with the --with-selinux=yes in order to compile libvirt --with-secdriver-selinux=yes])
fi
else
old_cflags="$CFLAGS"
@ -865,7 +965,7 @@ else
if test "$with_secdriver_selinux" = "check" ; then
with_secdriver_selinux=no
else
AC_MSG_ERROR([You must install the SELinux development package in order to compile libvirt])
AC_MSG_ERROR([You must install libselinux development package >= 2.0.82 in order to compile libvirt --with-secdriver-selinux=yes])
fi
else
with_secdriver_selinux=yes
@ -961,7 +1061,7 @@ AC_ARG_WITH([numactl],
NUMACTL_CFLAGS=
NUMACTL_LIBS=
if test "$with_qemu" = "yes" -a "$with_numactl" != "no"; then
if test "$with_qemu" = "yes" && test "$with_numactl" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
if test "$with_numactl" = "check"; then
@ -989,11 +1089,47 @@ AC_SUBST([NUMACTL_CFLAGS])
AC_SUBST([NUMACTL_LIBS])
dnl pcap lib
LIBPCAP_CONFIG="pcap-config"
LIBPCAP_CFLAGS=""
LIBPCAP_LIBS=""
LIBPCAP_FOUND="no"
AC_ARG_WITH([libpcap], AC_HELP_STRING([--with-libpcap=@<:@PFX@:>@], [libpcap location]))
if test "$with_qemu" = "yes"; then
if test "x$with_libpcap" != "xno" ; then
if test "x$with_libpcap" != "x" ; then
LIBPCAP_CONFIG=$with_libpcap/bin/$LIBPCAP_CONFIG
fi
AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED )
if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then
AC_MSG_RESULT(no)
else
LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`"
LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`"
LIBPCAP_FOUND="yes"
AC_MSG_RESULT(yes)
fi
fi
fi
if test "x$LIBPCAP_FOUND" = "xyes"; then
AC_DEFINE_UNQUOTED([HAVE_LIBPCAP], 1, [whether libpcap can be used])
fi
AC_SUBST([LIBPCAP_CFLAGS])
AC_SUBST([LIBPCAP_LIBS])
dnl
dnl Checks for the UML driver
dnl
if test "$with_uml" = "yes" -o "$with_uml" = "check"; then
if test "$with_libvirtd" = "no" ; then
with_uml=no
fi
if test "$with_uml" = "yes" || test "$with_uml" = "check"; then
AC_CHECK_HEADER([sys/inotify.h], [
with_uml=yes
], [
@ -1005,9 +1141,6 @@ if test "$with_uml" = "yes" -o "$with_uml" = "check"; then
fi
])
fi
if test "$with_libvirtd" = "no" ; then
with_uml=no
fi
if test "$with_uml" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_UML], 1, [whether UML driver is enabled])
fi
@ -1019,7 +1152,7 @@ dnl
dnl libssh checks
dnl
if test "$with_libssh2" != "yes" -a "$with_libssh2" != "no"; then
if test "$with_libssh2" != "yes" && test "$with_libssh2" != "no"; then
libssh2_path="$with_libssh2"
elif test "$with_libssh2" = "yes"; then
libssh2_path="/usr/local/lib/"
@ -1100,7 +1233,7 @@ dnl introduced in 0.4.0 release which need as minimum
dnl
CAPNG_CFLAGS=
CAPNG_LIBS=
if test "$with_qemu" = "yes" -a "$with_capng" != "no"; then
if test "$with_qemu" = "yes" && test "$with_capng" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
if test "$with_capng" = "check"; then
@ -1196,7 +1329,7 @@ AC_ARG_WITH([netcf],
NETCF_CFLAGS=
NETCF_LIBS=
if test "$with_netcf" = "yes" -o "$with_netcf" = "check"; then
if test "$with_netcf" = "yes" || test "$with_netcf" = "check"; then
PKG_CHECK_MODULES(NETCF, netcf >= $NETCF_REQUIRED,
[with_netcf=yes], [
if test "$with_netcf" = "check" ; then
@ -1225,6 +1358,15 @@ if test "$with_secrets" = "yes" ; then
fi
AM_CONDITIONAL([WITH_SECRETS], [test "$with_secrets" = "yes"])
with_nwfilter=yes
if test "$with_libvirtd" = "no"; then
with_nwfilter=no
fi
if test "$with_nwfilter" = "yes" ; then
AC_DEFINE([WITH_NWFILTER], 1, [whether local network filter management driver is available])
fi
AM_CONDITIONAL([WITH_NWFILTER], [test "$with_nwfilter" = "yes"])
AC_ARG_WITH([storage-fs],
AC_HELP_STRING([--with-storage-fs], [with FileSystem backend for the storage driver @<:@default=check@:>@]),[],[with_storage_fs=check])
@ -1255,7 +1397,7 @@ fi
AM_CONDITIONAL([WITH_STORAGE_DIR], [test "$with_storage_dir" = "yes"])
if test "$with_storage_fs" = "yes" -o "$with_storage_fs" = "check"; then
if test "$with_storage_fs" = "yes" || test "$with_storage_fs" = "check"; then
AC_PATH_PROG([MOUNT], [mount], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([UMOUNT], [umount], [], [$PATH:/sbin:/usr/sbin])
if test "$with_storage_fs" = "yes" ; then
@ -1283,7 +1425,7 @@ if test "$with_storage_fs" = "yes"; then
[Location or name of the showmount program])
fi
if test "$with_storage_lvm" = "yes" -o "$with_storage_lvm" = "check"; then
if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
AC_PATH_PROG([PVCREATE], [pvcreate], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([VGCREATE], [vgcreate], [], [$PATH:/sbin:/usr/sbin])
AC_PATH_PROG([LVCREATE], [lvcreate], [], [$PATH:/sbin:/usr/sbin])
@ -1343,7 +1485,7 @@ AM_CONDITIONAL([WITH_STORAGE_LVM], [test "$with_storage_lvm" = "yes"])
if test "$with_storage_iscsi" = "yes" -o "$with_storage_iscsi" = "check"; then
if test "$with_storage_iscsi" = "yes" || test "$with_storage_iscsi" = "check"; then
AC_PATH_PROG([ISCSIADM], [iscsiadm], [], [$PATH:/sbin:/usr/sbin])
if test "$with_storage_iscsi" = "yes" ; then
if test -z "$ISCSIADM" ; then AC_MSG_ERROR([We need iscsiadm for iSCSI storage driver]) ; fi
@ -1401,7 +1543,7 @@ AC_SUBST([DEVMAPPER_LIBS])
LIBPARTED_CFLAGS=
LIBPARTED_LIBS=
if test "$with_storage_disk" = "yes" -o "$with_storage_disk" = "check"; then
if test "$with_storage_disk" = "yes" || test "$with_storage_disk" = "check"; then
AC_PATH_PROG([PARTED], [parted], [], [$PATH:/sbin:/usr/sbin])
if test -z "$PARTED" ; then
with_storage_disk=no
@ -1410,7 +1552,7 @@ if test "$with_storage_disk" = "yes" -o "$with_storage_disk" = "check"; then
PARTED_FOUND=yes
fi
if test "$with_storage_disk" != "no" -a "x$PKG_CONFIG" != "x" ; then
if test "$with_storage_disk" != "no" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(LIBPARTED, libparted >= $PARTED_REQUIRED, [], [PARTED_FOUND=no])
fi
if test "$PARTED_FOUND" = "no"; then
@ -1446,31 +1588,56 @@ AC_SUBST([LIBPARTED_CFLAGS])
AC_SUBST([LIBPARTED_LIBS])
dnl
dnl check for libcurl (ESX)
dnl check for libcurl (ESX/XenAPI)
dnl
LIBCURL_CFLAGS=""
LIBCURL_LIBS=""
LIBCURL_FOUND="no"
if test "$with_esx" = "yes" -o "$with_esx" = "check"; then
if test "$with_esx" = "yes" || test "$with_esx" = "check" || test "$with_xenapi" = "yes" || test "$with_xenapi" = "check"; then
PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [
LIBCURL_FOUND=yes
with_esx="yes"
if test "$with_esx" = "check"; then
with_esx=yes
fi
if test "$with_xenapi" = "check"; then
with_xenapi=yes
fi
], [
if test "$with_esx" = "check"; then
with_esx=no
AC_MSG_NOTICE([libcurl is required for ESX driver, disabling it])
else
AC_MSG_NOTICE([libcurl is required for the ESX driver, disabling it])
elif test "$with_esx" = "yes"; then
AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the ESX driver])
fi
if test "$with_xenapi" = "check"; then
with_xenapi=no
AC_MSG_NOTICE([libcurl is required for the XenAPI driver, disabling it])
elif test "$with_xenapi" = "yes"; then
AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the XenAPI driver])
fi
])
fi
if test "$with_esx" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_ESX], 1, [whether ESX driver is enabled])
fi
AM_CONDITIONAL([WITH_ESX], [test "$with_esx" = "yes"])
if test "$with_xenapi" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled])
fi
AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"])
# XXX as of libcurl-devel-7.20.1-3.fc13.x86_64, curl ships a version
# of <curl/curl.h> that #defines several wrapper macros around underlying
# functions to add type safety for gcc only. However, these macros
# spuriously trip gcc's -Wlogical-op warning. Avoid the warning by
# disabling the wrappers; even if it removes some type-check safety.
LIBCURL_CFLAGS="-DCURL_DISABLE_TYPECHECK $LIBCURL_CFLAGS"
AC_SUBST([LIBCURL_CFLAGS])
AC_SUBST([LIBCURL_LIBS])
@ -1573,7 +1740,7 @@ else
fi
AC_MSG_RESULT($RUNNING_XEND)
AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" -a "$RUNNING_XEND" != "no"])
AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" && test "$RUNNING_XEND" != "no"])
AC_ARG_ENABLE([test-coverage],
AC_HELP_STRING([--enable-test-coverage], [turn on code coverage instrumentation @<:@default=no@:>@]),
@ -1585,6 +1752,7 @@ AC_ARG_ENABLE([test-coverage],
enable_coverage=$enableval
if test "${enable_coverage}" = yes; then
COMPILER_FLAGS=
gl_COMPILER_FLAGS(-fprofile-arcs)
gl_COMPILER_FLAGS(-ftest-coverage)
AC_SUBST([COVERAGE_CFLAGS], [$COMPILER_FLAGS])
@ -1670,6 +1838,9 @@ CYGWIN_EXTRA_LDFLAGS=
CYGWIN_EXTRA_LIBADD=
CYGWIN_EXTRA_PYTHON_LIBADD=
MINGW_EXTRA_LDFLAGS=
WIN32_EXTRA_CFLAGS=
LIBVIRT_SYMBOL_FILE=libvirt.syms
LIBVIRT_QEMU_SYMBOL_FILE='$(srcdir)/libvirt_qemu.syms'
case "$host" in
*-*-cygwin*)
CYGWIN_EXTRA_LDFLAGS="-no-undefined"
@ -1682,15 +1853,44 @@ case "$host" in
MINGW_EXTRA_LDFLAGS="-no-undefined"
;;
esac
case "$host" in
*-*-mingw* | *-*-cygwin* | *-*-msvc* )
# If the host is Windows, and shared libraries are disabled, we
# need to add -DLIBVIRT_STATIC to the CFLAGS for proper linking
if test "x$enable_shared" = "xno"; then
WIN32_EXTRA_CFLAGS="-DLIBVIRT_STATIC"
fi
esac
case "$host" in
*-*-mingw* | *-*-msvc* )
# Also set the symbol file to .def, so src/Makefile generates libvirt.def
# from libvirt.syms and passes libvirt.def instead of libvirt.syms to the linker
LIBVIRT_SYMBOL_FILE=libvirt.def
# mingw's ld has the --version-script parameter, but it requires a .def file
# instead to work properly, therefore clear --version-script here and use
# -Wl, to pass the .def file to the linker
# cygwin's ld has the --version-script parameter too, but for some reason
# it's working there as expected
VERSION_SCRIPT_FLAGS="-Wl,"
;;
esac
AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
AC_SUBST([CYGWIN_EXTRA_LIBADD])
AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
AC_SUBST([MINGW_EXTRA_LDFLAGS])
AC_SUBST([WIN32_EXTRA_CFLAGS])
AC_SUBST([LIBVIRT_SYMBOL_FILE])
AC_SUBST([LIBVIRT_QEMU_SYMBOL_FILE])
AC_SUBST([VERSION_SCRIPT_FLAGS])
dnl Look for windres to build a Windows icon resource.
AC_CHECK_TOOL([WINDRES], [windres], [no])
AM_CONDITIONAL([WITH_WIN_ICON], [test "$WINDRES" != "no"])
case "$host" in
*-*-mingw* | *-*-cygwin* | *-*-msvc* )
AC_CHECK_TOOL([WINDRES], [windres], [])
;;
esac
AM_CONDITIONAL([WITH_WIN_ICON], [test "$WINDRES" != ""])
dnl Driver-Modules library
@ -1744,7 +1944,7 @@ AC_ARG_WITH([hal],
if test "$with_libvirtd" = "no" ; then
with_hal=no
fi
if test "x$with_hal" = "xyes" -o "x$with_hal" = "xcheck"; then
if test "x$with_hal" = "xyes" || test "x$with_hal" = "xcheck"; then
PKG_CHECK_MODULES(HAL, hal >= $HAL_REQUIRED,
[with_hal=yes], [
if test "x$with_hal" = "xcheck" ; then
@ -1787,7 +1987,7 @@ AC_ARG_WITH([udev],
if test "$with_libvirtd" = "no" ; then
with_udev=no
fi
if test "x$with_udev" = "xyes" -o "x$with_udev" = "xcheck"; then
if test "x$with_udev" = "xyes" || test "x$with_udev" = "xcheck"; then
PKG_CHECK_MODULES(UDEV, libudev >= $UDEV_REQUIRED,
[], [
if test "x$with_udev" = "xcheck" ; then
@ -1821,14 +2021,20 @@ AC_SUBST([PCIACCESS_CFLAGS])
AC_SUBST([PCIACCESS_LIBS])
with_nodedev=no;
if test "$with_hal" = "yes" -o "$with_udev" = "yes";
if test "$with_hal" = "yes" || test "$with_udev" = "yes";
then
with_nodedev=yes
AC_DEFINE_UNQUOTED([WITH_NODE_DEVICES], 1, [with node device driver])
fi
AM_CONDITIONAL([WITH_NODE_DEVICES], [test "$with_nodedev" = "yes"])
AM_CONDITIONAL([WITH_LINUX], [test `uname -s` = "Linux"])
with_linux=no
case "$host" in
*-*-linux*)
with_linux=yes
;;
esac
AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" = "yes"])
AC_ARG_WITH([qemu-user],
@ -1849,7 +2055,8 @@ AC_ARG_WITH([macvtap],
[with_macvtap=check])
if test "$with_macvtap" != "no" ; then
AC_TRY_COMPILE([ #include <linux/if_link.h> ],
AC_TRY_COMPILE([ #include <sys/socket.h>
#include <linux/rtnetlink.h> ],
[ int x = MACVLAN_MODE_BRIDGE; ],
[ with_macvtap=yes ],
[ if test "$with_macvtap" = "yes" ; then
@ -1865,6 +2072,38 @@ if test "$with_macvtap" != "no" ; then
fi
AM_CONDITIONAL([WITH_MACVTAP], [test "$with_macvtap" = "yes"])
AC_TRY_COMPILE([ #include <sys/socket.h>
#include <linux/rtnetlink.h> ],
[ int x = IFLA_PORT_MAX; ],
[ with_virtualport=yes ],
[ with_virtualport=no ])
if test "$with_virtualport" = "yes"; then
val=1
else
val=0
fi
AC_DEFINE_UNQUOTED([WITH_VIRTUALPORT], $val,
[whether vsi vepa support is enabled])
AM_CONDITIONAL([WITH_VIRTUALPORT], [test "$with_virtualport" = "yes"])
dnl netlink library
LIBNL_CFLAGS=""
LIBNL_LIBS=""
if test "$with_macvtap" = "yes" || test "$with_virtualport" = "yes"; then
PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
], [
AC_MSG_ERROR([libnl >= $LIBNL_REQUIRED is required for macvtap support])
])
fi
AC_SUBST([LIBNL_CFLAGS])
AC_SUBST([LIBNL_LIBS])
# Only COPYING.LIB is under version control, yet COPYING
# is included as part of the distribution tarball.
@ -1873,6 +2112,12 @@ AM_CONDITIONAL([WITH_MACVTAP], [test "$with_macvtap" = "yes"])
test "x$srcdir" = x. && ! test -f COPYING &&
cp -f COPYING.LIB COPYING
# Detect when running under the clang static analyzer's scan-build driver
# or Coverity-prevent's cov-build. Define STATIC_ANALYSIS accordingly.
test -n "$CCC_ANALYZER_ANALYSIS$COVERITY_BUILD_COMMAND" && t=1 || t=0
AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
[Define to 1 when performing static analysis.])
AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
docs/schemas/Makefile \
gnulib/lib/Makefile \
@ -1893,8 +2138,10 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
examples/domain-events/events-c/Makefile \
examples/domsuspend/Makefile \
examples/dominfo/Makefile \
examples/openauth/Makefile \
examples/python/Makefile \
examples/hellolibvirt/Makefile)
examples/hellolibvirt/Makefile \
examples/xml/nwfilter/Makefile)
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Configuration summary])
@ -1908,6 +2155,7 @@ AC_MSG_NOTICE([ QEMU: $with_qemu])
AC_MSG_NOTICE([ UML: $with_uml])
AC_MSG_NOTICE([ OpenVZ: $with_openvz])
AC_MSG_NOTICE([ VBox: $with_vbox])
AC_MSG_NOTICE([ XenAPI: $with_xenapi])
AC_MSG_NOTICE([ LXC: $with_lxc])
AC_MSG_NOTICE([ PHYP: $with_phyp])
AC_MSG_NOTICE([ ONE: $with_one])
@ -1918,6 +2166,7 @@ AC_MSG_NOTICE([ Network: $with_network])
AC_MSG_NOTICE([Libvirtd: $with_libvirtd])
AC_MSG_NOTICE([ netcf: $with_netcf])
AC_MSG_NOTICE([ macvtap: $with_macvtap])
AC_MSG_NOTICE([virtport: $with_virtualport])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Storage Drivers])
AC_MSG_NOTICE([])
@ -2006,6 +2255,11 @@ AC_MSG_NOTICE([ xen: $XEN_CFLAGS $XEN_LIBS])
else
AC_MSG_NOTICE([ xen: no])
fi
if test "$with_xenapi" = "yes" ; then
AC_MSG_NOTICE([ xenapi: $LIBXENSERVER_CFLAGS $LIBXENSERVER_LIBS])
else
AC_MSG_NOTICE([ xenapi: no])
fi
if test "$with_hal" = "yes" ; then
AC_MSG_NOTICE([ hal: $HAL_CFLAGS $HAL_LIBS])
else
@ -2026,6 +2280,16 @@ AC_MSG_NOTICE([ xmlrpc: $XMLRPC_CFLAGS $XMLRPC_LIBS])
else
AC_MSG_NOTICE([ xmlrpc: no])
fi
if test "$with_qemu" = "yes" ; then
AC_MSG_NOTICE([ pcap: $LIBPCAP_CFLAGS $LIBPCAP_LIBS])
else
AC_MSG_NOTICE([ pcap: no])
fi
if test "$with_macvtap" = "yes" ; then
AC_MSG_NOTICE([ nl: $LIBNL_CFLAGS $LIBNL_LIBS])
else
AC_MSG_NOTICE([ nl: no])
fi
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Test suite])
AC_MSG_NOTICE([])

7
daemon/.gitignore vendored
View File

@ -1,5 +1,3 @@
*.gcda
*.gcno
*.la
*.lo
.deps
@ -9,4 +7,7 @@ Makefile.in
libvirt_qemud
libvirtd
libvirtd.init
libvirtd.logrotate
libvirt-guests.init
libvirtd*.logrotate
libvirtd.pod
libvirtd.8

View File

@ -10,7 +10,12 @@ DAEMON_SOURCES = \
remote_dispatch_table.h \
remote_dispatch_args.h \
remote_dispatch_ret.h \
../src/remote/remote_protocol.c
qemu_dispatch_prototypes.h \
qemu_dispatch_table.h \
qemu_dispatch_args.h \
qemu_dispatch_ret.h \
../src/remote/remote_protocol.c \
../src/remote/qemu_protocol.c
AVAHI_SOURCES = \
mdns.c mdns.h
@ -25,11 +30,19 @@ EXTRA_DIST = \
libvirtd.sasl \
libvirtd.sysconf \
libvirtd.aug \
libvirtd.logrotate.in \
libvirtd.qemu.logrotate.in \
libvirtd.lxc.logrotate.in \
libvirtd.uml.logrotate.in \
test_libvirtd.aug \
THREADING.txt \
libvirt-guests.init.in \
libvirt-guests.sysconf \
libvirtd.pod.in \
$(AVAHI_SOURCES) \
$(DAEMON_SOURCES)
man_MANS = libvirtd.8
BUILT_SOURCES =
if WITH_LIBVIRTD
@ -45,6 +58,20 @@ augeas_DATA = libvirtd.aug
augeastestsdir = $(datadir)/augeas/lenses/tests
augeastests_DATA = test_libvirtd.aug
POD2MAN = pod2man -c "Virtualization Support" \
-r "$(PACKAGE)-$(VERSION)" -s 8
libvirtd.pod: libvirtd.pod.in
sed \
-e 's![@]sysconfdir[@]!$(sysconfdir)!g' \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
-e 's![@]remote_pid_file[@]!$(REMOTE_PID_FILE)!g' \
< $< > $@-t
mv $@-t $@
libvirtd.8: libvirtd.pod
$(AM_V_GEN)$(POD2MAN) $< $@
libvirtd_SOURCES = $(DAEMON_SOURCES)
#-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
@ -74,7 +101,7 @@ libvirtd_LDADD = \
$(SASL_LIBS) \
$(POLKIT_LIBS)
libvirtd_LDADD += ../src/libvirt_util.la
libvirtd_LDADD += ../src/libvirt_util.la ../src/libvirt-qemu.la
if WITH_DRIVER_MODULES
libvirtd_LDADD += ../src/libvirt_driver.la
@ -114,6 +141,10 @@ endif
if WITH_SECRETS
libvirtd_LDADD += ../src/libvirt_driver_secret.la
endif
if WITH_NWFILTER
libvirtd_LDADD += ../src/libvirt_driver_nwfilter.la
endif
endif
libvirtd_LDADD += ../src/libvirt.la
@ -161,60 +192,100 @@ endif
remote.c: remote_dispatch_prototypes.h \
remote_dispatch_table.h \
remote_dispatch_args.h \
remote_dispatch_ret.h
remote_dispatch_ret.h \
qemu_dispatch_prototypes.h \
qemu_dispatch_table.h \
qemu_dispatch_args.h \
qemu_dispatch_ret.h
REMOTE_PROTOCOL = $(top_srcdir)/src/remote/remote_protocol.x
QEMU_PROTOCOL = $(top_srcdir)/src/remote/qemu_protocol.x
remote_dispatch_prototypes.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
perl -w $(srcdir)/remote_generate_stubs.pl -p $(REMOTE_PROTOCOL) > $@
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -c -p remote $(REMOTE_PROTOCOL) > $@
remote_dispatch_table.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
perl -w $(srcdir)/remote_generate_stubs.pl -t $(REMOTE_PROTOCOL) > $@
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -c -t remote $(REMOTE_PROTOCOL) > $@
remote_dispatch_args.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
perl -w $(srcdir)/remote_generate_stubs.pl -a $(REMOTE_PROTOCOL) > $@
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -c -a remote $(REMOTE_PROTOCOL) > $@
remote_dispatch_ret.h: $(srcdir)/remote_generate_stubs.pl $(REMOTE_PROTOCOL)
perl -w $(srcdir)/remote_generate_stubs.pl -r $(REMOTE_PROTOCOL) > $@
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -c -r remote $(REMOTE_PROTOCOL) > $@
BUILT_SOURCES += libvirtd.logrotate
qemu_dispatch_prototypes.h: $(srcdir)/remote_generate_stubs.pl $(QEMU_PROTOCOL)
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -p qemu $(QEMU_PROTOCOL) > $@
libvirtd.logrotate: libvirtd.logrotate.in
sed \
-e s!\@localstatedir\@!@localstatedir@!g \
qemu_dispatch_table.h: $(srcdir)/remote_generate_stubs.pl $(QEMU_PROTOCOL)
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -t qemu $(QEMU_PROTOCOL) > $@
qemu_dispatch_args.h: $(srcdir)/remote_generate_stubs.pl $(QEMU_PROTOCOL)
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -a qemu $(QEMU_PROTOCOL) > $@
qemu_dispatch_ret.h: $(srcdir)/remote_generate_stubs.pl $(QEMU_PROTOCOL)
$(AM_V_GEN)perl -w $(srcdir)/remote_generate_stubs.pl -r qemu $(QEMU_PROTOCOL) > $@
LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \
libvirtd.uml.logrotate
BUILT_SOURCES += $(LOGROTATE_CONFS)
libvirtd.qemu.logrotate: libvirtd.qemu.logrotate.in
sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
< $< > $@-t
mv $@-t $@
install-logrotate: libvirtd.logrotate
libvirtd.lxc.logrotate: libvirtd.lxc.logrotate.in
$(AM_V_GEN)sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
< $< > $@-t && \
mv $@-t $@
libvirtd.uml.logrotate: libvirtd.uml.logrotate.in
$(AM_V_GEN)sed \
-e 's![@]localstatedir[@]!$(localstatedir)!g' \
< $< > $@-t && \
mv $@-t $@
install-logrotate: $(LOGROTATE_CONFS)
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/qemu/
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/lxc/
mkdir -p $(DESTDIR)$(localstatedir)/log/libvirt/uml/
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/
$(INSTALL_DATA) $< $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd
$(INSTALL_DATA) libvirtd.qemu.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.qemu
$(INSTALL_DATA) libvirtd.lxc.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.lxc
$(INSTALL_DATA) libvirtd.uml.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.uml
if LIBVIRT_INIT_SCRIPT_RED_HAT
install-init: libvirtd.init
install-init: libvirtd.init libvirt-guests.init
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
$(INSTALL_SCRIPT) libvirtd.init \
$(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd
$(INSTALL_SCRIPT) libvirt-guests.init \
$(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests
mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
$(INSTALL_SCRIPT) $(srcdir)/libvirtd.sysconf \
$(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
$(INSTALL_SCRIPT) $(srcdir)/libvirt-guests.sysconf \
$(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
uninstall-init:
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd \
$(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
$(DESTDIR)$(sysconfdir)/sysconfig/libvirtd \
$(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirt-guests \
$(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
BUILT_SOURCES += libvirtd.init
BUILT_SOURCES += libvirtd.init libvirt-guests.init
libvirtd.init: libvirtd.init.in
sed \
%.init: %.init.in $(top_builddir)/config.status
$(AM_V_GEN)sed \
-e s!\@localstatedir\@!@localstatedir@!g \
-e s!\@sbindir\@!@sbindir@!g \
-e s!\@sysconfdir\@!@sysconfdir@!g \
< $< > $@-t
chmod a+x $@-t
mv $@-t $@
< $< > $@-t && \
chmod a+x $@-t && \
mv $@-t $@
check-local:
test -x '$(AUGPARSE)' \
@ -253,5 +324,5 @@ uninstall-data-sasl:
endif
CLEANFILES = $(BUILT_SOURCES)
CLEANFILES = $(BUILT_SOURCES) $(man_MANS) libvirtd.pod
CLEANFILES += *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda

View File

@ -23,6 +23,10 @@
#include <config.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include "dispatch.h"
#include "remote.h"
@ -336,10 +340,11 @@ cleanup:
}
int
static int
remoteDispatchClientCall (struct qemud_server *server,
struct qemud_client *client,
struct qemud_client_message *msg);
struct qemud_client_message *msg,
bool qemu_protocol);
/*
@ -348,7 +353,7 @@ remoteDispatchClientCall (struct qemud_server *server,
* @msg: the complete incoming message packet, with header already decoded
*
* This function gets called from qemud when it pulls a incoming
* remote protocol messsage off the dispatch queue for processing.
* remote protocol message off the dispatch queue for processing.
*
* The @msg parameter must have had its header decoded already by
* calling remoteDecodeClientMessageHeader
@ -356,36 +361,48 @@ remoteDispatchClientCall (struct qemud_server *server,
* Returns 0 if the message was dispatched, -1 upon fatal error
*/
int
remoteDispatchClientRequest (struct qemud_server *server,
struct qemud_client *client,
struct qemud_client_message *msg)
remoteDispatchClientRequest(struct qemud_server *server,
struct qemud_client *client,
struct qemud_client_message *msg)
{
int ret;
remote_error rerr;
bool qemu_call;
DEBUG("prog=%d ver=%d type=%d satus=%d serial=%d proc=%d",
DEBUG("prog=%d ver=%d type=%d status=%d serial=%d proc=%d",
msg->hdr.prog, msg->hdr.vers, msg->hdr.type,
msg->hdr.status, msg->hdr.serial, msg->hdr.proc);
memset(&rerr, 0, sizeof rerr);
/* Check version, etc. */
if (msg->hdr.prog != REMOTE_PROGRAM) {
if (msg->hdr.prog == REMOTE_PROGRAM)
qemu_call = false;
else if (msg->hdr.prog == QEMU_PROGRAM)
qemu_call = true;
else {
remoteDispatchFormatError (&rerr,
_("program mismatch (actual %x, expected %x)"),
msg->hdr.prog, REMOTE_PROGRAM);
_("program mismatch (actual %x, expected %x or %x)"),
msg->hdr.prog, REMOTE_PROGRAM, QEMU_PROGRAM);
goto error;
}
if (msg->hdr.vers != REMOTE_PROTOCOL_VERSION) {
if (!qemu_call && msg->hdr.vers != REMOTE_PROTOCOL_VERSION) {
remoteDispatchFormatError (&rerr,
_("version mismatch (actual %x, expected %x)"),
msg->hdr.vers, REMOTE_PROTOCOL_VERSION);
goto error;
}
else if (qemu_call && msg->hdr.vers != QEMU_PROTOCOL_VERSION) {
remoteDispatchFormatError (&rerr,
_("version mismatch (actual %x, expected %x)"),
msg->hdr.vers, QEMU_PROTOCOL_VERSION);
goto error;
}
switch (msg->hdr.type) {
case REMOTE_CALL:
return remoteDispatchClientCall(server, client, msg);
return remoteDispatchClientCall(server, client, msg, qemu_call);
case REMOTE_STREAM:
/* Since stream data is non-acked, async, we may continue to received
@ -427,10 +444,11 @@ error:
*
* Returns 0 if the reply was sent, or -1 upon fatal error
*/
int
static int
remoteDispatchClientCall (struct qemud_server *server,
struct qemud_client *client,
struct qemud_client_message *msg)
struct qemud_client_message *msg,
bool qemu_protocol)
{
XDR xdr;
remote_error rerr;
@ -469,7 +487,10 @@ remoteDispatchClientCall (struct qemud_server *server,
}
}
data = remoteGetDispatchData(msg->hdr.proc);
if (qemu_protocol)
data = qemuGetDispatchData(msg->hdr.proc);
else
data = remoteGetDispatchData(msg->hdr.proc);
if (!data) {
remoteDispatchFormatError (&rerr, _("unknown procedure: %d"),

View File

@ -22,10 +22,10 @@
*/
#ifndef __LIBVIRTD_DISPATCH_H__
#define __LIBVIRTD_DISPATCH_H__
# define __LIBVIRTD_DISPATCH_H__
#include "libvirtd.h"
# include "libvirtd.h"
int
@ -60,16 +60,6 @@ remoteSerializeStreamError(struct qemud_client *client,
int proc,
int serial);
/* Having this here is dubious. It should be in remote.h
* but qemud.c shouldn't depend on that header directly.
* Refactor this later to deal with this properly.
*/
int remoteRelayDomainEvent (virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int event,
int detail,
void *opaque);
int
remoteSendStreamData(struct qemud_client *client,

View File

@ -1,8 +1,8 @@
/*
* event.c: event loop for monitoring file handles
*
* Copyright (C) 2007, 2010 Red Hat, Inc.
* Copyright (C) 2007 Daniel P. Berrange
* Copyright (C) 2007 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
@ -35,6 +35,7 @@
#include "event.h"
#include "memory.h"
#include "util.h"
#include "ignore-value.h"
#define EVENT_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
@ -630,7 +631,7 @@ static void virEventHandleWakeup(int watch ATTRIBUTE_UNUSED,
{
char c;
virEventLock();
saferead(fd, &c, sizeof(c));
ignore_value(saferead(fd, &c, sizeof(c)));
virEventUnlock();
}

View File

@ -22,9 +22,9 @@
*/
#ifndef __VIRTD_EVENT_H__
#define __VIRTD_EVENT_H__
# define __VIRTD_EVENT_H__
#include "internal.h"
# include "internal.h"
/**
* virEventAddHandleImpl: register a callback for monitoring file handle events

View File

@ -0,0 +1,341 @@
#!/bin/sh
# the following is the LSB init header
#
### BEGIN INIT INFO
# Provides: libvirt-guests
# Required-Start: libvirtd
# Required-Stop: libvirtd
# Default-Start: 3 4 5
# Short-Description: suspend/resume libvirt guests on shutdown/boot
# Description: This is a script for suspending active libvirt guests
# on shutdown and resuming them on next boot
# See http://libvirt.org
### END INIT INFO
# the following is chkconfig init header
#
# libvirt-guests: suspend/resume libvirt guests on shutdown/boot
#
# chkconfig: 345 98 02
# description: This is a script for suspending active libvirt guests \
# on shutdown and resuming them on next boot \
# See http://libvirt.org
#
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
libvirtd=@sbindir@/libvirtd
# Source function library.
. "$sysconfdir"/rc.d/init.d/functions
URIS=default
ON_BOOT=start
ON_SHUTDOWN=suspend
SHUTDOWN_TIMEOUT=0
test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests
LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
RETVAL=0
retval() {
"$@"
if [ $? -ne 0 ]; then
RETVAL=1
return 1
else
return 0
fi
}
run_virsh() {
uri=$1
shift
if [ "x$uri" = xdefault ]; then
conn=
else
conn="-c $uri"
fi
virsh $conn "$@" </dev/null
}
run_virsh_c() {
( export LC_ALL=C; run_virsh "$@" )
}
list_guests() {
uri=$1
list=$(run_virsh_c $uri list)
if [ $? -ne 0 ]; then
RETVAL=1
return 1
fi
uuids=
for id in $(echo "$list" | awk 'NR > 2 {print $1}'); do
uuid=$(run_virsh_c $uri dominfo $id | awk '/^UUID:/{print $2}')
if [ -z "$uuid" ]; then
RETVAL=1
return 1
fi
uuids="$uuids $uuid"
done
echo $uuids
}
guest_name() {
uri=$1
uuid=$2
name=$(run_virsh_c $uri dominfo $uuid 2>/dev/null | \
awk '/^Name:/{print $2}')
[ -n "$name" ] || name=$uuid
echo "$name"
}
guest_is_on() {
uri=$1
uuid=$2
guest_running=false
info=$(run_virsh_c $uri dominfo $uuid)
if [ $? -ne 0 ]; then
RETVAL=1
return 1
fi
id=$(echo "$info" | awk '/^Id:/{print $2}')
[ -n "$id" ] && [ "x$id" != x- ] && guest_running=true
return 0
}
started() {
touch "$VAR_SUBSYS_LIBVIRT_GUESTS"
}
start() {
[ -f "$LISTFILE" ] || { started; return 0; }
if [ "x$ON_BOOT" != xstart ]; then
echo $"libvirt-guests is configured not to start any guests on boot"
rm -f "$LISTFILE"
started
return 0
fi
while read uri list; do
configured=false
for confuri in $URIS; do
if [ $confuri = $uri ]; then
configured=true
break
fi
done
if ! $configured; then
echo $"Ignoring guests on $uri URI"
continue
fi
echo $"Resuming guests on $uri URI..."
for guest in $list; do
name=$(guest_name $uri $guest)
echo -n $"Resuming guest $name: "
if guest_is_on $uri $guest; then
if $guest_running; then
echo $"already active"
else
retval run_virsh $uri start "$name" >/dev/null && \
echo $"done"
fi
fi
done
done <"$LISTFILE"
rm -f "$LISTFILE"
started
}
suspend_guest()
{
uri=$1
guest=$2
name=$(guest_name $uri $guest)
label=$"Suspending $name: "
echo -n "$label"
run_virsh $uri managedsave $guest >/dev/null &
virsh_pid=$!
while true; do
sleep 1
kill -0 $virsh_pid >&/dev/null || break
progress=$(run_virsh_c $uri domjobinfo $guest 2>/dev/null | \
awk '/^Data processed:/{print $3, $4}')
if [ -n "$progress" ]; then
printf '\r%s%12s ' "$label" "$progress"
else
printf '\r%s%-12s ' "$label" "..."
fi
done
retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done"
}
shutdown_guest()
{
uri=$1
guest=$2
name=$(guest_name $uri $guest)
label=$"Shutting down $name: "
echo -n "$label"
retval run_virsh $uri shutdown $guest >/dev/null || return
timeout=$SHUTDOWN_TIMEOUT
while [ $timeout -gt 0 ]; do
sleep 1
timeout=$[timeout - 1]
guest_is_on $uri $guest || return
$guest_running || break
printf '\r%s%-12d ' "$label" $timeout
done
if guest_is_on $uri $guest; then
if $guest_running; then
printf '\r%s%-12s\n' "$label" $"failed to shutdown in time"
else
printf '\r%s%-12s\n' "$label" $"done"
fi
fi
}
stop() {
# last stop was not followed by start
[ -f "$LISTFILE" ] && return 0
suspending=true
if [ "x$ON_SHUTDOWN" = xshutdown ]; then
suspending=false
if [ $SHUTDOWN_TIMEOUT -le 0 ]; then
echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set"
RETVAL=6
return
fi
fi
: >"$LISTFILE"
for uri in $URIS; do
echo -n $"Running guests on $uri URI: "
if [ "x$uri" = xdefault ] && [ ! -x "$libvirtd" ]; then
echo $"libvirtd not installed; skipping this URI."
continue
fi
list=$(list_guests $uri)
if [ $? -eq 0 ]; then
empty=true
for uuid in $list; do
$empty || printf ", "
echo -n $(guest_name $uri $uuid)
empty=false
done
if $empty; then
echo $"no running guests."
else
echo
echo $uri $list >>"$LISTFILE"
fi
fi
done
while read uri list; do
if $suspending; then
echo $"Suspending guests on $uri URI..."
else
echo $"Shutting down guests on $uri URI..."
fi
for guest in $list; do
if $suspending; then
suspend_guest $uri $guest
else
shutdown_guest $uri $guest
fi
done
done <"$LISTFILE"
rm -f "$VAR_SUBSYS_LIBVIRT_GUESTS"
}
gueststatus() {
for uri in $URIS; do
echo "* $uri URI:"
retval run_virsh $uri list || echo
done
}
# rh_status
# Display current status: whether saved state exists, and whether start
# has been executed. We cannot use status() from the functions library,
# since there is no external daemon process matching this init script.
rh_status() {
if [ -f "$LISTFILE" ]; then
echo $"stopped, with saved guests"
RETVAL=3
else
if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then
echo $"started"
else
echo $"stopped, with no saved guests"
fi
RETVAL=0
fi
}
# usage [val]
# Display usage string, then exit with VAL (defaults to 2).
usage() {
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"
exit ${1-2}
}
# See how we were called.
if test $# != 1; then
usage
fi
case "$1" in
--help)
usage 0
;;
start|stop|gueststatus)
$1
;;
restart)
stop && start
;;
condrestart|try-restart)
[ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ] && stop && start
;;
reload|force-reload)
# Nothing to do; we reread configuration on each invocation
;;
status)
rh_status
;;
shutdown)
ON_SHUTDOWN=shutdown
stop
;;
*)
usage
;;
esac
exit $RETVAL

View File

@ -0,0 +1,24 @@
# URIs to check for running guests
# example: URIS='default xen:/// vbox+tcp://host/system lxc:///'
#URIS=default
# action taken on host boot
# - start all guests which were running on shutdown are started on boot
# regardless on their autostart settings
# - ignore libvirt-guests init script won't start any guest on boot, however,
# guests marked as autostart will still be automatically started by
# libvirtd
#ON_BOOT=start
# action taken on host shutdown
# - suspend all running guests are suspended using virsh managedsave
# - shutdown all running guests are asked to shutdown. Please be careful with
# this settings since there is no way to distinguish between a
# guest which is stuck or ignores shutdown requests and a guest
# which just needs a long time to shutdown. When setting
# ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a
# value suitable for your guests.
#ON_SHUTDOWN=suspend
# number of seconds we're willing to wait for a guest to shut down
#SHUTDOWN_TIMEOUT=0

View File

@ -57,66 +57,71 @@
#include "dispatch.h"
#include "util.h"
#include "uuid.h"
#include "remote_driver.h"
#include "conf.h"
#include "event.h"
#include "memory.h"
#include "stream.h"
#include "hooks.h"
#ifdef HAVE_AVAHI
#include "mdns.h"
# include "mdns.h"
#endif
#ifdef WITH_DRIVER_MODULES
#include "driver.h"
# include "driver.h"
#else
#ifdef WITH_QEMU
#include "qemu/qemu_driver.h"
#endif
#ifdef WITH_LXC
#include "lxc/lxc_driver.h"
#endif
#ifdef WITH_UML
#include "uml/uml_driver.h"
#endif
#ifdef WITH_ONE
#include "opennebula/one_driver.h"
#endif
#ifdef WITH_NETWORK
#include "network/bridge_driver.h"
#endif
#ifdef WITH_NETCF
#include "interface/netcf_driver.h"
#endif
#ifdef WITH_STORAGE_DIR
#include "storage/storage_driver.h"
#endif
#ifdef WITH_NODE_DEVICES
#include "node_device/node_device_driver.h"
#endif
#ifdef WITH_SECRETS
#include "secret/secret_driver.h"
#endif
# ifdef WITH_QEMU
# include "qemu/qemu_driver.h"
# endif
# ifdef WITH_LXC
# include "lxc/lxc_driver.h"
# endif
# ifdef WITH_UML
# include "uml/uml_driver.h"
# endif
# ifdef WITH_ONE
# include "opennebula/one_driver.h"
# endif
# ifdef WITH_NETWORK
# include "network/bridge_driver.h"
# endif
# ifdef WITH_NETCF
# include "interface/netcf_driver.h"
# endif
# ifdef WITH_STORAGE_DIR
# include "storage/storage_driver.h"
# endif
# ifdef WITH_NODE_DEVICES
# include "node_device/node_device_driver.h"
# endif
# ifdef WITH_SECRETS
# include "secret/secret_driver.h"
# endif
# ifdef WITH_NWFILTER
# include "nwfilter/nwfilter_driver.h"
# endif
#endif
#ifdef __sun
#include <ucred.h>
#include <priv.h>
# include <ucred.h>
# include <priv.h>
#ifndef PRIV_VIRT_MANAGE
#define PRIV_VIRT_MANAGE ((const char *)"virt_manage")
#endif
# ifndef PRIV_VIRT_MANAGE
# define PRIV_VIRT_MANAGE ((const char *)"virt_manage")
# endif
#ifndef PRIV_XVM_CONTROL
#define PRIV_XVM_CONTROL ((const char *)"xvm_control")
#endif
# ifndef PRIV_XVM_CONTROL
# define PRIV_XVM_CONTROL ((const char *)"xvm_control")
# endif
#define PU_RESETGROUPS 0x0001 /* Remove supplemental groups */
#define PU_CLEARLIMITSET 0x0008 /* L=0 */
# define PU_RESETGROUPS 0x0001 /* Remove supplemental groups */
# define PU_CLEARLIMITSET 0x0008 /* L=0 */
extern int __init_daemon_priv(int, uid_t, gid_t, ...);
#define SYSTEM_UID 60
# define SYSTEM_UID 60
static gid_t unix_sock_gid = 60; /* Not used */
static int unix_sock_rw_mask = 0666;
@ -186,6 +191,7 @@ static int max_client_requests = 5;
static sig_atomic_t sig_errors = 0;
static int sig_lasterrno = 0;
static const char *argv0;
enum {
VIR_DAEMON_ERR_NONE = 0,
@ -196,6 +202,7 @@ enum {
VIR_DAEMON_ERR_PRIVS,
VIR_DAEMON_ERR_NETWORK,
VIR_DAEMON_ERR_CONFIG,
VIR_DAEMON_ERR_HOOKS,
VIR_DAEMON_ERR_LAST
};
@ -209,7 +216,8 @@ VIR_ENUM_IMPL(virDaemonErr, VIR_DAEMON_ERR_LAST,
"Unable to setup signal handlers",
"Unable to drop privileges",
"Unable to initialize network sockets",
"Unable to load configuration file")
"Unable to load configuration file",
"Unable to look for hook scripts")
static void sig_handler(int sig, siginfo_t * siginfo,
void* context ATTRIBUTE_UNUSED) {
@ -375,14 +383,17 @@ qemudDispatchSignalEvent(int watch ATTRIBUTE_UNUSED,
switch (siginfo.si_signo) {
case SIGHUP:
VIR_INFO0(_("Reloading configuration on SIGHUP"));
virHookCall(VIR_HOOK_DRIVER_DAEMON, "-",
VIR_HOOK_DAEMON_OP_RELOAD, SIGHUP, "SIGHUP", NULL);
if (virStateReload() < 0)
VIR_WARN0(_("Error while reloading drivers"));
VIR_WARN0("Error while reloading drivers");
break;
case SIGINT:
case SIGQUIT:
case SIGTERM:
VIR_WARN(_("Shutting down on signal %d"), siginfo.si_signo);
VIR_WARN("Shutting down on signal %d", siginfo.si_signo);
server->quitEventThread = 1;
break;
@ -475,8 +486,8 @@ static int daemonForkIntoBackground(void) {
if (ret == 1 && status != 0) {
fprintf(stderr,
"error: %s. Check /var/log/messages or run without "
"--daemon for more info.\n",
_("%s: error: %s. Check /var/log/messages or run without "
"--daemon for more info.\n"), argv0,
virDaemonErrTypeToString(status));
}
_exit(ret == 1 && status == 0 ? 0 : 1);
@ -506,15 +517,15 @@ static int qemudWritePidFile(const char *pidFile) {
}
if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
VIR_ERROR(_("Failed to write to pid file '%s' : %s"),
pidFile, virStrerror(errno, ebuf, sizeof ebuf));
VIR_ERROR(_("%s: Failed to write to pid file '%s' : %s"),
argv0, pidFile, virStrerror(errno, ebuf, sizeof ebuf));
fclose(fh);
return -1;
}
if (fclose(fh) == EOF) {
VIR_ERROR(_("Failed to close pid file '%s' : %s"),
pidFile, virStrerror(errno, ebuf, sizeof ebuf));
VIR_ERROR(_("%s: Failed to close pid file '%s' : %s"),
argv0, pidFile, virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
@ -522,7 +533,7 @@ static int qemudWritePidFile(const char *pidFile) {
}
static int qemudListenUnix(struct qemud_server *server,
const char *path, int readonly, int auth) {
char *path, int readonly, int auth) {
struct qemud_socket *sock;
struct sockaddr_un addr;
mode_t oldmask;
@ -530,7 +541,7 @@ static int qemudListenUnix(struct qemud_server *server,
char ebuf[1024];
if (VIR_ALLOC(sock) < 0) {
VIR_ERROR("%s", _("Failed to allocate memory for struct qemud_socket"));
VIR_ERROR0(_("Failed to allocate memory for struct qemud_socket"));
return -1;
}
@ -538,6 +549,7 @@ static int qemudListenUnix(struct qemud_server *server,
sock->port = -1;
sock->type = QEMUD_SOCK_TYPE_UNIX;
sock->auth = auth;
sock->path = path;
if ((sock->fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
VIR_ERROR(_("Failed to create socket: %s"),
@ -732,17 +744,30 @@ cleanup:
}
static int qemudInitPaths(struct qemud_server *server,
char *sockname,
char *roSockname,
int maxlen)
char **sockname,
char **roSockname)
{
char *sock_dir;
char *dir_prefix = NULL;
int ret = -1;
char *base_dir_prefix = NULL;
char *sock_dir_prefix = NULL;
int ret = -1;
/* The base_dir_prefix is the base under which all libvirtd
* files live */
if (server->privileged) {
if (!(base_dir_prefix = strdup (LOCAL_STATE_DIR)))
goto no_memory;
} else {
uid_t uid = geteuid();
if (!(base_dir_prefix = virGetUserDirectory(uid)))
goto cleanup;
}
/* The unix_sock_dir is the location under which all
* unix domain sockets live */
if (unix_sock_dir) {
sock_dir = unix_sock_dir;
if (!(sock_dir_prefix = strdup(unix_sock_dir)))
goto no_memory;
/* Change the group ownership of /var/run/libvirt to unix_sock_gid */
if (server->privileged) {
if (chown(unix_sock_dir, -1, unix_sock_gid) < 0)
@ -750,69 +775,53 @@ static int qemudInitPaths(struct qemud_server *server,
unix_sock_dir);
}
} else {
sock_dir = sockname;
if (server->privileged) {
dir_prefix = strdup (LOCAL_STATE_DIR);
if (dir_prefix == NULL) {
virReportOOMError();
goto cleanup;
}
if (snprintf (sock_dir, maxlen, "%s/run/libvirt",
dir_prefix) >= maxlen)
goto snprintf_error;
if (virAsprintf(&sock_dir_prefix, "%s/run/libvirt",
base_dir_prefix) < 0)
goto no_memory;
} else {
uid_t uid = geteuid();
dir_prefix = virGetUserDirectory(uid);
if (dir_prefix == NULL) {
/* Do not diagnose here; virGetUserDirectory does that. */
goto snprintf_error;
}
if (snprintf(sock_dir, maxlen, "%s/.libvirt", dir_prefix) >= maxlen)
goto snprintf_error;
if (virAsprintf(&sock_dir_prefix, "%s/.libvirt",
base_dir_prefix) < 0)
goto no_memory;
}
}
sock_dir_prefix = strdup (sock_dir);
if (!sock_dir_prefix) {
virReportOOMError();
goto cleanup;
if (server->privileged) {
if (virAsprintf(sockname, "%s/libvirt-sock",
sock_dir_prefix) < 0)
goto no_memory;
if (virAsprintf(roSockname, "%s/libvirt-sock-ro",
sock_dir_prefix) < 0)
goto no_memory;
unlink(*sockname);
unlink(*roSockname);
} else {
if (virAsprintf(sockname, "@%s/libvirt-sock",
sock_dir_prefix) < 0)
goto no_memory;
/* There is no RO socket in unprivileged mode,
* since the user always has full RW access
* to their private instance */
}
if (server->privileged) {
if (snprintf (sockname, maxlen, "%s/libvirt-sock",
sock_dir_prefix) >= maxlen
|| (snprintf (roSockname, maxlen, "%s/libvirt-sock-ro",
sock_dir_prefix) >= maxlen))
goto snprintf_error;
unlink(sockname);
unlink(roSockname);
if (virAsprintf(&server->logDir, "%s/log/libvirt",
base_dir_prefix) < 0)
goto no_memory;
} else {
if (snprintf(sockname, maxlen, "@%s/libvirt-sock",
sock_dir_prefix) >= maxlen)
goto snprintf_error;
if (virAsprintf(&server->logDir, "%s/.libvirt/log",
base_dir_prefix) < 0)
goto no_memory;
}
if (server->privileged) {
if (!(server->logDir = strdup (LOCAL_STATE_DIR "/log/libvirt")))
virReportOOMError();
} else {
if (virAsprintf(&server->logDir, "%s/.libvirt/log", dir_prefix) < 0)
virReportOOMError();
}
if (server->logDir == NULL)
goto cleanup;
ret = 0;
snprintf_error:
if (ret)
VIR_ERROR("%s",
_("Resulting path too long for buffer in qemudInitPaths()"));
no_memory:
if (ret != 0)
virReportOOMError();
cleanup:
VIR_FREE(dir_prefix);
VIR_FREE(base_dir_prefix);
VIR_FREE(sock_dir_prefix);
return ret;
}
@ -835,12 +844,12 @@ static struct qemud_server *qemudInitialize(void) {
server->sigread = server->sigwrite = -1;
if (virMutexInit(&server->lock) < 0) {
VIR_ERROR("%s", _("cannot initialize mutex"));
VIR_ERROR0(_("cannot initialize mutex"));
VIR_FREE(server);
return NULL;
}
if (virCondInit(&server->job) < 0) {
VIR_ERROR("%s", _("cannot initialize condition variable"));
VIR_ERROR0(_("cannot initialize condition variable"));
virMutexDestroy(&server->lock);
VIR_FREE(server);
return NULL;
@ -876,34 +885,38 @@ static struct qemud_server *qemudInitialize(void) {
virDriverLoadModule("lxc");
virDriverLoadModule("uml");
virDriverLoadModule("one");
virDriverLoadModule("nwfilter");
#else
#ifdef WITH_NETWORK
# ifdef WITH_NETWORK
networkRegister();
#endif
#ifdef WITH_NETCF
# endif
# ifdef WITH_NETCF
interfaceRegister();
#endif
#ifdef WITH_STORAGE_DIR
# endif
# ifdef WITH_STORAGE_DIR
storageRegister();
#endif
#if defined(WITH_NODE_DEVICES)
# endif
# if defined(WITH_NODE_DEVICES)
nodedevRegister();
#endif
#ifdef WITH_SECRETS
# endif
# ifdef WITH_SECRETS
secretRegister();
#endif
#ifdef WITH_QEMU
# endif
# ifdef WITH_NWFILTER
nwfilterRegister();
# endif
# ifdef WITH_QEMU
qemuRegister();
#endif
#ifdef WITH_LXC
# endif
# ifdef WITH_LXC
lxcRegister();
#endif
#ifdef WITH_UML
# endif
# ifdef WITH_UML
umlRegister();
#endif
#ifdef WITH_ONE
# endif
# ifdef WITH_ONE
oneRegister();
#endif
# endif
#endif
virEventRegisterImpl(virEventAddHandleImpl,
@ -917,22 +930,22 @@ static struct qemud_server *qemudInitialize(void) {
}
static int qemudNetworkInit(struct qemud_server *server) {
char sockname[PATH_MAX];
char roSockname[PATH_MAX];
char *sockname = NULL;
char *roSockname = NULL;
#if HAVE_SASL
int err;
#endif /* HAVE_SASL */
roSockname[0] = '\0';
if (qemudInitPaths(server, sockname, roSockname, PATH_MAX) < 0)
if (qemudInitPaths(server, &sockname, &roSockname) < 0)
goto cleanup;
if (qemudListenUnix(server, sockname, 0, auth_unix_rw) < 0)
goto cleanup;
sockname = NULL;
if (roSockname[0] != '\0' && qemudListenUnix(server, roSockname, 1, auth_unix_ro) < 0)
if (roSockname != NULL && qemudListenUnix(server, roSockname, 1, auth_unix_ro) < 0)
goto cleanup;
roSockname = NULL;
#if HAVE_SASL
if (auth_unix_rw == REMOTE_AUTH_SASL ||
@ -985,22 +998,34 @@ static int qemudNetworkInit(struct qemud_server *server) {
struct libvirtd_mdns_group *group;
struct qemud_socket *sock;
int port = 0;
int ret;
server->mdns = libvirtd_mdns_new();
if (!mdns_name) {
char groupname[64], *localhost, *tmp;
/* Extract the host part of the potentially FQDN */
char *groupname, *localhost, *tmp;
localhost = virGetHostname(NULL);
if (localhost == NULL)
goto cleanup;
if ((tmp = strchr(localhost, '.')))
*tmp = '\0';
snprintf(groupname, sizeof(groupname)-1, "Virtualization Host %s", localhost);
groupname[sizeof(groupname)-1] = '\0';
group = libvirtd_mdns_add_group(server->mdns, groupname);
/* we couldn't resolve the hostname; assume that we are
* running in disconnected operation, and report a less
* useful Avahi string
*/
ret = virAsprintf(&groupname, "Virtualization Host");
else {
/* Extract the host part of the potentially FQDN */
if ((tmp = strchr(localhost, '.')))
*tmp = '\0';
ret = virAsprintf(&groupname, "Virtualization Host %s",
localhost);
}
VIR_FREE(localhost);
if (ret < 0) {
virReportOOMError();
goto cleanup;
}
group = libvirtd_mdns_add_group(server->mdns, groupname);
VIR_FREE(groupname);
} else {
group = libvirtd_mdns_add_group(server->mdns, mdns_name);
}
@ -1031,6 +1056,8 @@ static int qemudNetworkInit(struct qemud_server *server) {
return 0;
cleanup:
VIR_FREE(sockname);
VIR_FREE(roSockname);
return -1;
}
@ -1054,6 +1081,7 @@ static int qemudNetworkEnable(struct qemud_server *server) {
return 0;
}
static gnutls_session_t
remoteInitializeTLSSession (void)
{
@ -1247,7 +1275,7 @@ remoteCheckAccess (struct qemud_client *client)
#if HAVE_POLKIT
int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid) {
#ifdef SO_PEERCRED
# ifdef SO_PEERCRED
struct ucred cr;
unsigned int cr_len = sizeof (cr);
@ -1260,10 +1288,10 @@ int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid) {
*pid = cr.pid;
*uid = cr.uid;
#else
# else
/* XXX Many more OS support UNIX socket credentials we could port to. See dbus ....*/
#error "UNIX socket credentials not supported/implemented on this platform yet..."
#endif
# error "UNIX socket credentials not supported/implemented on this platform yet..."
# endif
return 0;
}
#endif
@ -1275,6 +1303,7 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
socklen_t addrlen = (socklen_t) (sizeof addr);
struct qemud_client *client;
int no_slow_start = 1;
int i;
if ((fd = accept(sock->fd, (struct sockaddr *)&addr, &addrlen)) < 0) {
char ebuf[1024];
@ -1333,7 +1362,7 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
if (VIR_ALLOC(client) < 0)
goto cleanup;
if (virMutexInit(&client->lock) < 0) {
VIR_ERROR("%s", _("cannot initialize mutex"));
VIR_ERROR0(_("cannot initialize mutex"));
VIR_FREE(client);
goto cleanup;
}
@ -1346,6 +1375,10 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
memcpy (&client->addr, &addr, sizeof addr);
client->addrlen = addrlen;
for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++) {
client->domainEventCallbackID[i] = -1;
}
/* Prepare one for packet receive */
if (VIR_ALLOC(client->rx) < 0)
goto cleanup;
@ -1415,7 +1448,6 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
if (server->nclients > server->nactiveworkers &&
server->nactiveworkers < server->nworkers) {
int i;
for (i = 0 ; i < server->nworkers ; i++) {
if (!server->workers[i].hasThread) {
if (qemudStartWorker(server, &server->workers[i]) < 0)
@ -1454,9 +1486,17 @@ void qemudDispatchClientFailure(struct qemud_client *client) {
}
/* Deregister event delivery callback */
if (client->conn && client->domain_events_registered) {
DEBUG0("Deregistering to relay remote events");
virConnectDomainEventDeregister(client->conn, remoteRelayDomainEvent);
if (client->conn) {
int i;
for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++) {
if (client->domainEventCallbackID[i] != -1) {
DEBUG("Deregistering to relay remote events %d", i);
virConnectDomainEventDeregisterAny(client->conn,
client->domainEventCallbackID[i]);
}
client->domainEventCallbackID[i] = -1;
}
}
#if HAVE_SASL
@ -2283,7 +2323,7 @@ static void *qemudRunLoop(void *opaque) {
virMutexUnlock(&server->lock);
if (qemudOneLoop() < 0) {
virMutexLock(&server->lock);
DEBUG0("Loop iteration error, exiting\n");
DEBUG0("Loop iteration error, exiting");
break;
}
virMutexLock(&server->lock);
@ -2384,6 +2424,14 @@ static void qemudCleanup(struct qemud_server *server) {
if (sock->watch)
virEventRemoveHandleImpl(sock->watch);
close(sock->fd);
/* Unlink unix domain sockets which are not in
* the abstract namespace */
if (sock->path &&
sock->path[0] != '@')
unlink(sock->path);
VIR_FREE(sock->path);
VIR_FREE(sock);
sock = next;
}
@ -2457,7 +2505,7 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
for (i = 0, pp = p->list; pp; ++i, pp = pp->next) {
if (pp->type != VIR_CONF_STRING) {
VIR_ERROR(_("remoteReadConfigFile: %s: %s:"
" must be a string or list of strings\n"),
" must be a string or list of strings"),
filename, key);
VIR_FREE(list);
return -1;
@ -2480,7 +2528,7 @@ remoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg,
default:
VIR_ERROR(_("remoteReadConfigFile: %s: %s:"
" must be a string or list of strings\n"),
" must be a string or list of strings"),
filename, key);
return -1;
}
@ -2496,7 +2544,7 @@ checkType (virConfValuePtr p, const char *filename,
{
if (p->type != required_type) {
VIR_ERROR(_("remoteReadConfigFile: %s: %s: invalid type:"
" got %s; expected %s\n"), filename, key,
" got %s; expected %s"), filename, key,
virConfTypeName (p->type),
virConfTypeName (required_type));
return -1;
@ -2681,6 +2729,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
char *unix_sock_rw_perms = NULL;
char *unix_sock_group = NULL;
char *buf = NULL;
char *host_uuid = NULL;
#if HAVE_POLKIT
/* Change the default back to no auth for non-root */
@ -2724,7 +2773,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
GET_CONF_STR (conf, filename, unix_sock_group);
if (unix_sock_group) {
if (!server->privileged) {
VIR_WARN0(_("Cannot set group when not running as root"));
VIR_WARN0("Cannot set group when not running as root");
} else {
int ret;
struct group grpdata, *grp;
@ -2734,7 +2783,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
maxbuf = 1024;
if (VIR_ALLOC_N(buf, maxbuf) < 0) {
VIR_ERROR("%s", _("Failed to allocate memory for buffer"));
VIR_ERROR0(_("Failed to allocate memory for buffer"));
goto free_and_fail;
}
@ -2743,7 +2792,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
&grp)) == ERANGE) {
maxbuf *= 2;
if (maxbuf > 65536 || VIR_REALLOC_N(buf, maxbuf) < 0) {
VIR_ERROR("%s", _("Failed to reallocate enough memory for buffer"));
VIR_ERROR0(_("Failed to reallocate enough memory for buffer"));
goto free_and_fail;
}
}
@ -2803,11 +2852,20 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
GET_CONF_INT (conf, filename, max_requests);
GET_CONF_INT (conf, filename, max_client_requests);
GET_CONF_STR (conf, filename, host_uuid);
if (virSetHostUUIDStr(host_uuid)) {
VIR_ERROR(_("invalid host UUID: %s"), host_uuid);
goto free_and_fail;
}
VIR_FREE(host_uuid);
virConfFree (conf);
return 0;
free_and_fail:
virConfFree (conf);
VIR_FREE(host_uuid);
VIR_FREE(mdns_name);
VIR_FREE(unix_sock_ro_perms);
VIR_FREE(unix_sock_rw_perms);
@ -2832,7 +2890,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
/* Display version information. */
static void
version (const char *argv0)
version (void)
{
printf ("%s (%s) %s\n", argv0, PACKAGE_NAME, PACKAGE_VERSION);
}
@ -2858,7 +2916,7 @@ qemudSetupPrivs (void)
return 0;
}
#else
#define qemudSetupPrivs() 0
# define qemudSetupPrivs() 0
#endif
@ -2924,10 +2982,10 @@ error:
/* Print command-line usage. */
static void
usage (const char *argv0)
usage (void)
{
fprintf (stderr,
"\n\
_("\n\
Usage:\n\
%s [options]\n\
\n\
@ -2945,27 +3003,33 @@ libvirt management daemon:\n\
Default paths:\n\
\n\
Configuration file (unless overridden by -f):\n\
" SYSCONF_DIR "/libvirt/libvirtd.conf\n\
%s/libvirt/libvirtd.conf\n\
\n\
Sockets (as root):\n\
" LOCAL_STATE_DIR "/run/libvirt/libvirt-sock\n\
" LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro\n\
%s/run/libvirt/libvirt-sock\n\
%s/run/libvirt/libvirt-sock-ro\n\
\n\
Sockets (as non-root):\n\
$HOME/.libvirt/libvirt-sock (in UNIX abstract namespace)\n\
\n\
TLS:\n\
CA certificate: " LIBVIRT_CACERT "\n\
Server certificate: " LIBVIRT_SERVERCERT "\n\
Server private key: " LIBVIRT_SERVERKEY "\n\
CA certificate: %s\n\
Server certificate: %s\n\
Server private key: %s\n\
\n\
PID file (unless overridden by --pid-file):\n\
%s\n\
\n",
argv0,
REMOTE_PID_FILE[0] != '\0'
? REMOTE_PID_FILE
: "(disabled in ./configure)");
\n"),
argv0,
SYSCONF_DIR,
LOCAL_STATE_DIR,
LOCAL_STATE_DIR,
LIBVIRT_CACERT,
LIBVIRT_SERVERCERT,
LIBVIRT_SERVERKEY,
(REMOTE_PID_FILE[0] != '\0'
? REMOTE_PID_FILE
: _("(disabled in ./configure)")));
}
enum {
@ -2979,6 +3043,7 @@ int main(int argc, char **argv) {
const char *remote_config_file = NULL;
int statuswrite = -1;
int ret = 1;
argv0 = argv[0];
struct option opts[] = {
{ "verbose", no_argument, &verbose, 1},
@ -2992,7 +3057,10 @@ int main(int argc, char **argv) {
{0, 0, 0, 0}
};
virInitialize();
if (virInitialize() < 0) {
fprintf (stderr, _("%s: initialization failed\n"), argv0);
exit (EXIT_FAILURE);
}
while (1) {
int optidx = 0;
@ -3036,16 +3104,16 @@ int main(int argc, char **argv) {
break;
case OPT_VERSION:
version (argv[0]);
version ();
return 0;
case '?':
usage (argv[0]);
usage ();
return 2;
default:
fprintf (stderr, "libvirtd: internal error: unknown flag: %c\n",
c);
fprintf (stderr, _("%s: internal error: unknown flag: %c\n"),
argv0, c);
exit (EXIT_FAILURE);
}
}
@ -3124,9 +3192,23 @@ int main(int argc, char **argv) {
goto error;
}
/* setup the hooks if any */
if (virHookInitialize() < 0) {
ret = VIR_DAEMON_ERR_HOOKS;
goto error;
}
/* Disable error func, now logging is setup */
virSetErrorFunc(NULL, virshErrorHandler);
/*
* Call the daemon startup hook
* TODO: should we abort the daemon startup if the script returned
* an error ?
*/
virHookCall(VIR_HOOK_DRIVER_DAEMON, "-", VIR_HOOK_DAEMON_OP_START,
0, "start", NULL);
if (qemudNetworkInit(server) < 0) {
ret = VIR_DAEMON_ERR_NETWORK;
goto error;
@ -3148,7 +3230,7 @@ int main(int argc, char **argv) {
/* Start the event loop in a background thread, since
* state initialization needs events to be being processed */
if (qemudStartEventLoop(server) < 0) {
VIR_ERROR0("Event thread startup failed");
VIR_ERROR0(_("Event thread startup failed"));
goto error;
}
@ -3157,14 +3239,14 @@ int main(int argc, char **argv) {
* we're ready, since it can take a long time and this will
* seriously delay OS bootup process */
if (virStateInitialize(server->privileged) < 0) {
VIR_ERROR0("Driver state initialization failed");
VIR_ERROR0(_("Driver state initialization failed"));
goto shutdown;
}
/* Start accepting new clients from network */
virMutexLock(&server->lock);
if (qemudNetworkEnable(server) < 0) {
VIR_ERROR0("Network event loop enablement failed");
VIR_ERROR0(_("Network event loop enablement failed"));
goto shutdown;
}
virMutexUnlock(&server->lock);
@ -3187,6 +3269,9 @@ shutdown:
}
pthread_join(server->eventThread, NULL);
virHookCall(VIR_HOOK_DRIVER_DAEMON, "-", VIR_HOOK_DAEMON_OP_SHUTDOWN,
0, "shutdown", NULL);
error:
if (statuswrite != -1) {
if (ret != 0) {

View File

@ -312,3 +312,16 @@
# e.g.:
# log_outputs="3:syslog:libvirtd"
# to log all warnings and errors to syslog under the libvirtd ident
# UUID of the host:
# Provide the UUID of the host here in case the command
# 'dmidecode -s system-uuid' does not provide a valid uuid. In case
# 'dmidecode' does not provide a valid UUID and none is provided here, a
# temporary UUID will be generated.
# Keep the format of the example UUID below. UUID must not have all digits
# be the same.
# NB This default all-zeros UUID will not work. Replace
# it with the output of the 'uuidgen' command and then
# uncomment this entry
#host_uuid = "00000000-0000-0000-0000-000000000000"

View File

@ -23,53 +23,54 @@
#ifndef QEMUD_INTERNAL_H__
#define QEMUD_INTERNAL_H__
# define QEMUD_INTERNAL_H__
#include <config.h>
# include <config.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "gnutls_1_0_compat.h"
#if HAVE_SASL
#include <sasl/sasl.h>
#endif
# include <gnutls/gnutls.h>
# include <gnutls/x509.h>
# include "gnutls_1_0_compat.h"
# if HAVE_SASL
# include <sasl/sasl.h>
# endif
#if HAVE_POLKIT0
#include <dbus/dbus.h>
#endif
# if HAVE_POLKIT0
# include <dbus/dbus.h>
# endif
#ifdef HAVE_SYS_SYSLIMITS_H
#include <sys/syslimits.h>
#endif
# ifdef HAVE_SYS_SYSLIMITS_H
# include <sys/syslimits.h>
# endif
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "remote_protocol.h"
#include "logging.h"
#include "threads.h"
# include <rpc/types.h>
# include <rpc/xdr.h>
# include "remote_protocol.h"
# include "qemu_protocol.h"
# include "logging.h"
# include "threads.h"
#ifdef __GNUC__
#ifdef HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
# ifdef __GNUC__
# ifdef HAVE_ANSIDECL_H
# include <ansidecl.h>
# endif
#ifndef __GNUC_PREREQ
#if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
# ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
#define __GNUC_PREREQ(maj,min) 0
#endif
#endif
# else
# define __GNUC_PREREQ(maj,min) 0
# endif
# endif
/**
* ATTRIBUTE_UNUSED:
*
* Macro to flag conciously unused parameters to functions
*/
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__((__unused__))
#endif
# ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
# endif
/**
* ATTRIBUTE_FMT_PRINTF
@ -81,35 +82,35 @@
* printf format specifiers even on broken Win32 platforms
* hence we have to force 'gnu_printf' for new GCC
*/
#ifndef ATTRIBUTE_FMT_PRINTF
#if __GNUC_PREREQ (4, 4)
#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
#else
#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
#endif
#endif
# ifndef ATTRIBUTE_FMT_PRINTF
# if __GNUC_PREREQ (4, 4)
# define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
# else
# define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
# endif
# endif
#ifndef ATTRIBUTE_RETURN_CHECK
#if __GNUC_PREREQ (3, 4)
#define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
#else
#define ATTRIBUTE_RETURN_CHECK
#endif
#endif
# ifndef ATTRIBUTE_RETURN_CHECK
# if __GNUC_PREREQ (3, 4)
# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
# else
# define ATTRIBUTE_RETURN_CHECK
# endif
# endif
#else
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED
#endif
#ifndef ATTRIBUTE_FMT_PRINTF
#define ATTRIBUTE_FMT_PRINTF(...)
#endif
#ifndef ATTRIBUTE_RETURN_CHECK
#define ATTRIBUTE_RETURN_CHECK
#endif
#endif
# else
# ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED
# endif
# ifndef ATTRIBUTE_FMT_PRINTF
# define ATTRIBUTE_FMT_PRINTF(...)
# endif
# ifndef ATTRIBUTE_RETURN_CHECK
# define ATTRIBUTE_RETURN_CHECK
# endif
# endif
#define qemudDebug DEBUG
# define qemudDebug DEBUG
/* Whether we're passing reads & writes through a sasl SSF */
enum qemud_sasl_ssf {
@ -177,7 +178,7 @@ struct qemud_client {
int watch;
unsigned int readonly :1;
unsigned int closing :1;
unsigned int domain_events_registered :1;
int domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LAST];
struct sockaddr_storage addr;
socklen_t addrlen;
@ -186,7 +187,7 @@ struct qemud_client {
gnutls_session_t tlssession;
int auth;
unsigned int handshake :1; /* If we're in progress for TLS handshake */
#if HAVE_SASL
# if HAVE_SASL
sasl_conn_t *saslconn;
int saslSSF;
const char *saslDecoded;
@ -196,7 +197,7 @@ struct qemud_client {
unsigned int saslEncodedLength;
unsigned int saslEncodedOffset;
char *saslUsername;
#endif
# endif
/* Count of meages in 'dx' or 'tx' queue
* ie RPC calls in progress. Does not count
@ -229,10 +230,11 @@ struct qemud_client {
};
#define QEMUD_CLIENT_MAGIC 0x7788aaee
# define QEMUD_CLIENT_MAGIC 0x7788aaee
struct qemud_socket {
char *path;
int fd;
int watch;
int readonly;
@ -273,15 +275,15 @@ struct qemud_server {
pthread_t eventThread;
unsigned int hasEventThread :1;
unsigned int quitEventThread :1;
#ifdef HAVE_AVAHI
# ifdef HAVE_AVAHI
struct libvirtd_mdns *mdns;
#endif
#if HAVE_SASL
# endif
# if HAVE_SASL
char **saslUsernameWhitelist;
#endif
#if HAVE_POLKIT0
# endif
# if HAVE_POLKIT0
DBusConnection *sysbus;
#endif
# endif
};
void qemudLog(int priority, const char *fmt, ...)
@ -306,8 +308,8 @@ qemudClientMessageRelease(struct qemud_client *client,
struct qemud_client_message *msg);
#if HAVE_POLKIT
# if HAVE_POLKIT
int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid);
#endif
# endif
#endif

View File

@ -9,7 +9,7 @@
# Should-Start: $named
# Should-Start: xend
# Should-Start: hal
# Should-Start: avahi
# Should-Start: avahi-daemon
# Required-Stop: $network messagebus
# Should-Stop: $named
# Default-Start: 3 4 5
@ -24,8 +24,8 @@
# libvirtd: guest and virtual network management daemon
#
# chkconfig: 345 97 03
# description: This is a daemon for managing guest instances
# and libvirt virtual networks
# description: This is a daemon for managing guest instances \
# and libvirt virtual networks \
# See http://libvirt.org
#
# processname: libvirtd
@ -45,6 +45,9 @@ KRB5_KTNAME=/etc/libvirt/krb5.tab
test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd
export QEMU_AUDIO_DRV
export SDL_AUDIODRIVER
LIBVIRTD_CONFIG_ARGS=
if [ -n "$LIBVIRTD_CONFIG" ]
then
@ -72,7 +75,7 @@ stop() {
if [ $RETVAL -eq 0 ]; then
rm -f @localstatedir@/lock/subsys/$SERVICE
rm -f $PIDFILE
rm -rf @localstatedir@/cache/libvirt/*
rm -rf @localstatedir@/cache/libvirt/*
fi
}
@ -101,13 +104,13 @@ case "$1" in
;;
force-reload)
reload
;;
;;
condrestart|try-restart)
[ -f @localstatedir@/lock/subsys/$SERVICE ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload|try-restart}"
exit 2
;;
esac
exit $RETVAL

View File

@ -1,4 +1,4 @@
@localstatedir@/log/libvirt/qemu/*.log @localstatedir@/log/libvirt/uml/*.log @localstatedir@/log/libvirt/lxc/*.log {
@localstatedir@/log/libvirt/lxc/*.log {
weekly
missingok
rotate 4

168
daemon/libvirtd.pod.in Normal file
View File

@ -0,0 +1,168 @@
=head1 NAME
libvirtd - libvirtd management daemon
=head1 SYNOPSIS
B<libvirtd> [ -dlv ] [ -f config_file ] [ -p pid_file ] [ -t timeout_seconds ]
B<libvirtd> --version
=head1 DESCRIPTION
The B<libvirtd> program is the server side daemon component of the libvirt
virtualization management system.
This daemon runs on host servers and performs required management tasks for
virtualized guests. This includes activities such as starting, stopping
and migrating guests between host servers, configuring and manipulating
networking, and managing storage for use by guests.
The libvirt client libraries and utilities connect to this daemon to issue
tasks and collect information about the configuration and resources of the host
system and guests.
By default, the libvirtd daemon listens for requests on a local Unix domain
socket. Using the B<-l>|B<--listen> command line option, the libvirtd daemon
can be instructed to additionally listen on a TCP/IP socket. The TCP/IP socket
to use is defined in the libvirtd configuration file.
Restarting libvirtd does not impact running guests. Guests continue to operate
and will be picked up automatically if their XML configuration has been
defined. Any guests whose XML configuration has not been defined will be lost
from the configuration.
=head1 OPTIONS
=over
=item B<-d, --daemon>
Run as a daemon & write PID file.
=item B<-f, --config> I<FILE>
Use this configuration file, overriding the default value.
=item B<-l, --listen>
Listen for TCP/IP connections.
=item B<-p, --pid-file> I<FILE>
Use this name for the PID file, overriding the default value.
=item B<-t, --timeout> I<SECONDS>
Exit after timeout period (in seconds) expires.
=item B<-v, --verbose>
Enable output of verbose messages.
=item B< --version>
Display version information then exit.
=back
=head1 SIGNALS
On receipt of B<SIGHUP> libvirtd will reload its configuration.
=head1 FILES
=over
=item F<@sysconfdir@/libvirtd.conf>
The default configuration file used by libvirtd, unless overridden on the
command line using the B<-f>|B<--config> option.
=item F<@localstatedir@/run/libvirt/libvirt-sock>
=item F<@localstatedir@/run/libvirt/libvirt-sock-ro>
The sockets libvirtd will use when B<run as root>.
=item F<$HOME/.libvirt/libvirt-sock>
The socket libvirtd will use when run as a B<non-root> user.
=item F<@sysconfdir@/pki/CA/cacert.pem>
The TLS B<Certificate Authority> certificate libvirtd will use.
=item F<@sysconfdir@/pki/libvirt/servercert.pem>
The TLS B<Server> certificate libvirtd will use.
=item F<@sysconfdir@/pki/libvirt/private/serverkey.pem>
The TLS B<Server> private key libvirtd will use.
=item F<@remote_pid_file@>
The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
=back
=head1 EXAMPLES
To retrieve the version of libvirtd:
# libvirtd --version
libvirtd (libvirt) 0.8.2
#
To start libvirtd, instructing it to daemonize and create a PID file:
# libvirtd -d
# ls -la @remote_pid_file@
-rw-r--r-- 1 root root 6 Jul 9 02:40 @remote_pid_file@
#
=head1 BUGS
Please report all bugs you discover. This should be done via either:
=over
=item a) the mailing list
L<http://libvirt.org/contact.html>
=item or,
B<>
=item b) the bug tracker
L<http://libvirt.org/bugs.html>
=item Alternatively, you may report bugs to your software distributor / vendor.
=back
=head1 AUTHORS
Please refer to the AUTHORS file distributed with libvirt.
=head1 COPYRIGHT
Copyright (C) 2006-2010 Red Hat, Inc., and the authors listed in the
libvirt AUTHORS file.
=head1 LICENSE
libvirtd is distributed under the terms of the GNU LGPL v2.1+.
This is free software; see the source for copying conditions. There
is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE
=head1 SEE ALSO
L<virsh(1)>, L<virt-install(1)>, L<virt-xml-validate(1)>, L<virt-top(1)>,
L<virt-mem(1)>, L<virt-df(1)>, L<http://www.libvirt.org/>
=cut

View File

@ -0,0 +1,9 @@
@localstatedir@/log/libvirt/qemu/*.log {
weekly
missingok
rotate 4
compress
delaycompress
copytruncate
minsize 100k
}

View File

@ -11,7 +11,8 @@
# Override the QEMU/SDL default audio driver probing when
# starting virtual machines using SDL graphics
#
# NB these have no effect for VMs using VNC
# NB these have no effect for VMs using VNC, unless vnc_allow_host_audio
# is enabled in /etc/libvirt/qemu.conf
#QEMU_AUDIO_DRV=sdl
#
#SDL_AUDIODRIVER=pulse

View File

@ -0,0 +1,9 @@
@localstatedir@/log/libvirt/uml/*.log {
weekly
missingok
rotate 4
compress
delaycompress
copytruncate
minsize 100k
}

View File

@ -25,7 +25,7 @@
#include "internal.h"
#ifndef __VIRTD_MDNS_H__
#define __VIRTD_MDNS_H__
# define __VIRTD_MDNS_H__
struct libvirtd_mdns;
struct libvirtd_mdns_group;

View File

@ -0,0 +1,5 @@
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
qemu_monitor_command_args val_qemu_monitor_command_args;

View File

@ -0,0 +1,12 @@
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
static int qemuDispatchMonitorCommand(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
qemu_monitor_command_args *args,
qemu_monitor_command_ret *ret);

View File

@ -0,0 +1,5 @@
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
qemu_monitor_command_ret val_qemu_monitor_command_ret;

View File

@ -0,0 +1,14 @@
/* Automatically generated by remote_generate_stubs.pl.
* Do not edit this file. Any changes you make will be lost.
*/
{ /* (unused) => 0 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* MonitorCommand => 1 */
.fn = (dispatch_fn) qemuDispatchMonitorCommand,
.args_filter = (xdrproc_t) xdr_qemu_monitor_command_args,
.ret_filter = (xdrproc_t) xdr_qemu_monitor_command_ret,
},

File diff suppressed because it is too large Load Diff

View File

@ -22,19 +22,26 @@
*/
#ifndef __LIBVIRTD_REMOTE_H__
#define __LIBVIRTD_REMOTE_H__
# define __LIBVIRTD_REMOTE_H__
#include "libvirtd.h"
# include "libvirtd.h"
typedef union {
#include "remote_dispatch_args.h"
# include "remote_dispatch_args.h"
} dispatch_args;
typedef union {
#include "remote_dispatch_ret.h"
# include "remote_dispatch_ret.h"
} dispatch_ret;
typedef union {
# include "qemu_dispatch_args.h"
} qemu_dispatch_args;
typedef union {
# include "qemu_dispatch_ret.h"
} qemu_dispatch_ret;
@ -67,6 +74,7 @@ typedef struct {
const dispatch_data const *remoteGetDispatchData(int proc);
const dispatch_data const *qemuGetDispatchData(int proc);

View File

@ -140,3 +140,28 @@
remote_cpu_baseline_args val_remote_cpu_baseline_args;
remote_domain_get_job_info_args val_remote_domain_get_job_info_args;
remote_domain_abort_job_args val_remote_domain_abort_job_args;
remote_storage_vol_wipe_args val_remote_storage_vol_wipe_args;
remote_domain_migrate_set_max_downtime_args val_remote_domain_migrate_set_max_downtime_args;
remote_domain_events_register_any_args val_remote_domain_events_register_any_args;
remote_domain_events_deregister_any_args val_remote_domain_events_deregister_any_args;
remote_domain_update_device_flags_args val_remote_domain_update_device_flags_args;
remote_nwfilter_lookup_by_name_args val_remote_nwfilter_lookup_by_name_args;
remote_nwfilter_lookup_by_uuid_args val_remote_nwfilter_lookup_by_uuid_args;
remote_nwfilter_get_xml_desc_args val_remote_nwfilter_get_xml_desc_args;
remote_list_nwfilters_args val_remote_list_nwfilters_args;
remote_nwfilter_define_xml_args val_remote_nwfilter_define_xml_args;
remote_nwfilter_undefine_args val_remote_nwfilter_undefine_args;
remote_domain_managed_save_args val_remote_domain_managed_save_args;
remote_domain_has_managed_save_image_args val_remote_domain_has_managed_save_image_args;
remote_domain_managed_save_remove_args val_remote_domain_managed_save_remove_args;
remote_domain_snapshot_create_xml_args val_remote_domain_snapshot_create_xml_args;
remote_domain_snapshot_dump_xml_args val_remote_domain_snapshot_dump_xml_args;
remote_domain_snapshot_num_args val_remote_domain_snapshot_num_args;
remote_domain_snapshot_list_names_args val_remote_domain_snapshot_list_names_args;
remote_domain_snapshot_lookup_by_name_args val_remote_domain_snapshot_lookup_by_name_args;
remote_domain_has_current_snapshot_args val_remote_domain_has_current_snapshot_args;
remote_domain_snapshot_current_args val_remote_domain_snapshot_current_args;
remote_domain_revert_to_snapshot_args val_remote_domain_revert_to_snapshot_args;
remote_domain_snapshot_delete_args val_remote_domain_snapshot_delete_args;
remote_domain_get_block_info_args val_remote_domain_get_block_info_args;
remote_domain_create_with_flags_args val_remote_domain_create_with_flags_args;

View File

@ -122,6 +122,14 @@ static int remoteDispatchDomainCreate(
remote_error *err,
remote_domain_create_args *args,
void *ret);
static int remoteDispatchDomainCreateWithFlags(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_create_with_flags_args *args,
remote_domain_create_with_flags_ret *ret);
static int remoteDispatchDomainCreateXml(
struct qemud_server *server,
struct qemud_client *client,
@ -178,6 +186,14 @@ static int remoteDispatchDomainEventsDeregister(
remote_error *err,
void *args,
remote_domain_events_deregister_ret *ret);
static int remoteDispatchDomainEventsDeregisterAny(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_events_deregister_any_args *args,
void *ret);
static int remoteDispatchDomainEventsRegister(
struct qemud_server *server,
struct qemud_client *client,
@ -186,6 +202,14 @@ static int remoteDispatchDomainEventsRegister(
remote_error *err,
void *args,
remote_domain_events_register_ret *ret);
static int remoteDispatchDomainEventsRegisterAny(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_events_register_any_args *args,
void *ret);
static int remoteDispatchDomainGetAutostart(
struct qemud_server *server,
struct qemud_client *client,
@ -194,6 +218,14 @@ static int remoteDispatchDomainGetAutostart(
remote_error *err,
remote_domain_get_autostart_args *args,
remote_domain_get_autostart_ret *ret);
static int remoteDispatchDomainGetBlockInfo(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_get_block_info_args *args,
remote_domain_get_block_info_ret *ret);
static int remoteDispatchDomainGetInfo(
struct qemud_server *server,
struct qemud_client *client,
@ -266,6 +298,22 @@ static int remoteDispatchDomainGetVcpus(
remote_error *err,
remote_domain_get_vcpus_args *args,
remote_domain_get_vcpus_ret *ret);
static int remoteDispatchDomainHasCurrentSnapshot(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_has_current_snapshot_args *args,
remote_domain_has_current_snapshot_ret *ret);
static int remoteDispatchDomainHasManagedSaveImage(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_has_managed_save_image_args *args,
remote_domain_has_managed_save_image_ret *ret);
static int remoteDispatchDomainInterfaceStats(
struct qemud_server *server,
struct qemud_client *client,
@ -314,6 +362,22 @@ static int remoteDispatchDomainLookupByUuid(
remote_error *err,
remote_domain_lookup_by_uuid_args *args,
remote_domain_lookup_by_uuid_ret *ret);
static int remoteDispatchDomainManagedSave(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_managed_save_args *args,
void *ret);
static int remoteDispatchDomainManagedSaveRemove(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_managed_save_remove_args *args,
void *ret);
static int remoteDispatchDomainMemoryPeek(
struct qemud_server *server,
struct qemud_client *client,
@ -378,6 +442,14 @@ static int remoteDispatchDomainMigratePrepareTunnel(
remote_error *err,
remote_domain_migrate_prepare_tunnel_args *args,
void *ret);
static int remoteDispatchDomainMigrateSetMaxDowntime(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_migrate_set_max_downtime_args *args,
void *ret);
static int remoteDispatchDomainPinVcpu(
struct qemud_server *server,
struct qemud_client *client,
@ -410,6 +482,14 @@ static int remoteDispatchDomainResume(
remote_error *err,
remote_domain_resume_args *args,
void *ret);
static int remoteDispatchDomainRevertToSnapshot(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_revert_to_snapshot_args *args,
void *ret);
static int remoteDispatchDomainSave(
struct qemud_server *server,
struct qemud_client *client,
@ -466,6 +546,62 @@ static int remoteDispatchDomainShutdown(
remote_error *err,
remote_domain_shutdown_args *args,
void *ret);
static int remoteDispatchDomainSnapshotCreateXml(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_create_xml_args *args,
remote_domain_snapshot_create_xml_ret *ret);
static int remoteDispatchDomainSnapshotCurrent(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_current_args *args,
remote_domain_snapshot_current_ret *ret);
static int remoteDispatchDomainSnapshotDelete(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_delete_args *args,
void *ret);
static int remoteDispatchDomainSnapshotDumpXml(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_dump_xml_args *args,
remote_domain_snapshot_dump_xml_ret *ret);
static int remoteDispatchDomainSnapshotListNames(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_list_names_args *args,
remote_domain_snapshot_list_names_ret *ret);
static int remoteDispatchDomainSnapshotLookupByName(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_lookup_by_name_args *args,
remote_domain_snapshot_lookup_by_name_ret *ret);
static int remoteDispatchDomainSnapshotNum(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_snapshot_num_args *args,
remote_domain_snapshot_num_ret *ret);
static int remoteDispatchDomainSuspend(
struct qemud_server *server,
struct qemud_client *client,
@ -482,6 +618,14 @@ static int remoteDispatchDomainUndefine(
remote_error *err,
remote_domain_undefine_args *args,
void *ret);
static int remoteDispatchDomainUpdateDeviceFlags(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_domain_update_device_flags_args *args,
void *ret);
static int remoteDispatchDomainXmlFromNative(
struct qemud_server *server,
struct qemud_client *client,
@ -690,6 +834,14 @@ static int remoteDispatchListNetworks(
remote_error *err,
remote_list_networks_args *args,
remote_list_networks_ret *ret);
static int remoteDispatchListNwfilters(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_list_nwfilters_args *args,
remote_list_nwfilters_ret *ret);
static int remoteDispatchListSecrets(
struct qemud_server *server,
struct qemud_client *client,
@ -994,6 +1146,14 @@ static int remoteDispatchNumOfNetworks(
remote_error *err,
void *args,
remote_num_of_networks_ret *ret);
static int remoteDispatchNumOfNwfilters(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
void *args,
remote_num_of_nwfilters_ret *ret);
static int remoteDispatchNumOfSecrets(
struct qemud_server *server,
struct qemud_client *client,
@ -1010,6 +1170,46 @@ static int remoteDispatchNumOfStoragePools(
remote_error *err,
void *args,
remote_num_of_storage_pools_ret *ret);
static int remoteDispatchNwfilterDefineXml(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_nwfilter_define_xml_args *args,
remote_nwfilter_define_xml_ret *ret);
static int remoteDispatchNwfilterGetXmlDesc(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_nwfilter_get_xml_desc_args *args,
remote_nwfilter_get_xml_desc_ret *ret);
static int remoteDispatchNwfilterLookupByName(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_nwfilter_lookup_by_name_args *args,
remote_nwfilter_lookup_by_name_ret *ret);
static int remoteDispatchNwfilterLookupByUuid(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_nwfilter_lookup_by_uuid_args *args,
remote_nwfilter_lookup_by_uuid_ret *ret);
static int remoteDispatchNwfilterUndefine(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_nwfilter_undefine_args *args,
void *ret);
static int remoteDispatchOpen(
struct qemud_server *server,
struct qemud_client *client,
@ -1298,6 +1498,14 @@ static int remoteDispatchStorageVolLookupByPath(
remote_error *err,
remote_storage_vol_lookup_by_path_args *args,
remote_storage_vol_lookup_by_path_ret *ret);
static int remoteDispatchStorageVolWipe(
struct qemud_server *server,
struct qemud_client *client,
virConnectPtr conn,
remote_message_header *hdr,
remote_error *err,
remote_storage_vol_wipe_args *args,
void *ret);
static int remoteDispatchSupportsFeature(
struct qemud_server *server,
struct qemud_client *client,

View File

@ -119,3 +119,19 @@
remote_domain_memory_stats_ret val_remote_domain_memory_stats_ret;
remote_cpu_baseline_ret val_remote_cpu_baseline_ret;
remote_domain_get_job_info_ret val_remote_domain_get_job_info_ret;
remote_nwfilter_lookup_by_name_ret val_remote_nwfilter_lookup_by_name_ret;
remote_nwfilter_lookup_by_uuid_ret val_remote_nwfilter_lookup_by_uuid_ret;
remote_nwfilter_get_xml_desc_ret val_remote_nwfilter_get_xml_desc_ret;
remote_num_of_nwfilters_ret val_remote_num_of_nwfilters_ret;
remote_list_nwfilters_ret val_remote_list_nwfilters_ret;
remote_nwfilter_define_xml_ret val_remote_nwfilter_define_xml_ret;
remote_domain_has_managed_save_image_ret val_remote_domain_has_managed_save_image_ret;
remote_domain_snapshot_create_xml_ret val_remote_domain_snapshot_create_xml_ret;
remote_domain_snapshot_dump_xml_ret val_remote_domain_snapshot_dump_xml_ret;
remote_domain_snapshot_num_ret val_remote_domain_snapshot_num_ret;
remote_domain_snapshot_list_names_ret val_remote_domain_snapshot_list_names_ret;
remote_domain_snapshot_lookup_by_name_ret val_remote_domain_snapshot_lookup_by_name_ret;
remote_domain_has_current_snapshot_ret val_remote_domain_has_current_snapshot_ret;
remote_domain_snapshot_current_ret val_remote_domain_snapshot_current_ret;
remote_domain_get_block_info_ret val_remote_domain_get_block_info_ret;
remote_domain_create_with_flags_ret val_remote_domain_create_with_flags_ret;

View File

@ -537,7 +537,7 @@
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_remote_domain_events_deregister_ret,
},
{ /* Async event DomainEvent => 107 */
{ /* Async event DomainEventLifecycle => 107 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
@ -827,3 +827,163 @@
.args_filter = (xdrproc_t) xdr_remote_domain_abort_job_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* StorageVolWipe => 165 */
.fn = (dispatch_fn) remoteDispatchStorageVolWipe,
.args_filter = (xdrproc_t) xdr_remote_storage_vol_wipe_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainMigrateSetMaxDowntime => 166 */
.fn = (dispatch_fn) remoteDispatchDomainMigrateSetMaxDowntime,
.args_filter = (xdrproc_t) xdr_remote_domain_migrate_set_max_downtime_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainEventsRegisterAny => 167 */
.fn = (dispatch_fn) remoteDispatchDomainEventsRegisterAny,
.args_filter = (xdrproc_t) xdr_remote_domain_events_register_any_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainEventsDeregisterAny => 168 */
.fn = (dispatch_fn) remoteDispatchDomainEventsDeregisterAny,
.args_filter = (xdrproc_t) xdr_remote_domain_events_deregister_any_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* Async event DomainEventReboot => 169 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* Async event DomainEventRtcChange => 170 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* Async event DomainEventWatchdog => 171 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* Async event DomainEventIoError => 172 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* Async event DomainEventGraphics => 173 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainUpdateDeviceFlags => 174 */
.fn = (dispatch_fn) remoteDispatchDomainUpdateDeviceFlags,
.args_filter = (xdrproc_t) xdr_remote_domain_update_device_flags_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* NwfilterLookupByName => 175 */
.fn = (dispatch_fn) remoteDispatchNwfilterLookupByName,
.args_filter = (xdrproc_t) xdr_remote_nwfilter_lookup_by_name_args,
.ret_filter = (xdrproc_t) xdr_remote_nwfilter_lookup_by_name_ret,
},
{ /* NwfilterLookupByUuid => 176 */
.fn = (dispatch_fn) remoteDispatchNwfilterLookupByUuid,
.args_filter = (xdrproc_t) xdr_remote_nwfilter_lookup_by_uuid_args,
.ret_filter = (xdrproc_t) xdr_remote_nwfilter_lookup_by_uuid_ret,
},
{ /* NwfilterGetXmlDesc => 177 */
.fn = (dispatch_fn) remoteDispatchNwfilterGetXmlDesc,
.args_filter = (xdrproc_t) xdr_remote_nwfilter_get_xml_desc_args,
.ret_filter = (xdrproc_t) xdr_remote_nwfilter_get_xml_desc_ret,
},
{ /* NumOfNwfilters => 178 */
.fn = (dispatch_fn) remoteDispatchNumOfNwfilters,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_remote_num_of_nwfilters_ret,
},
{ /* ListNwfilters => 179 */
.fn = (dispatch_fn) remoteDispatchListNwfilters,
.args_filter = (xdrproc_t) xdr_remote_list_nwfilters_args,
.ret_filter = (xdrproc_t) xdr_remote_list_nwfilters_ret,
},
{ /* NwfilterDefineXml => 180 */
.fn = (dispatch_fn) remoteDispatchNwfilterDefineXml,
.args_filter = (xdrproc_t) xdr_remote_nwfilter_define_xml_args,
.ret_filter = (xdrproc_t) xdr_remote_nwfilter_define_xml_ret,
},
{ /* NwfilterUndefine => 181 */
.fn = (dispatch_fn) remoteDispatchNwfilterUndefine,
.args_filter = (xdrproc_t) xdr_remote_nwfilter_undefine_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainManagedSave => 182 */
.fn = (dispatch_fn) remoteDispatchDomainManagedSave,
.args_filter = (xdrproc_t) xdr_remote_domain_managed_save_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainHasManagedSaveImage => 183 */
.fn = (dispatch_fn) remoteDispatchDomainHasManagedSaveImage,
.args_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_has_managed_save_image_ret,
},
{ /* DomainManagedSaveRemove => 184 */
.fn = (dispatch_fn) remoteDispatchDomainManagedSaveRemove,
.args_filter = (xdrproc_t) xdr_remote_domain_managed_save_remove_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainSnapshotCreateXml => 185 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotCreateXml,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_create_xml_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_snapshot_create_xml_ret,
},
{ /* DomainSnapshotDumpXml => 186 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotDumpXml,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_dump_xml_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_snapshot_dump_xml_ret,
},
{ /* DomainSnapshotNum => 187 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotNum,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_num_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_snapshot_num_ret,
},
{ /* DomainSnapshotListNames => 188 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotListNames,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_list_names_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_snapshot_list_names_ret,
},
{ /* DomainSnapshotLookupByName => 189 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotLookupByName,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_lookup_by_name_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_snapshot_lookup_by_name_ret,
},
{ /* DomainHasCurrentSnapshot => 190 */
.fn = (dispatch_fn) remoteDispatchDomainHasCurrentSnapshot,
.args_filter = (xdrproc_t) xdr_remote_domain_has_current_snapshot_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_has_current_snapshot_ret,
},
{ /* DomainSnapshotCurrent => 191 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotCurrent,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_current_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_snapshot_current_ret,
},
{ /* DomainRevertToSnapshot => 192 */
.fn = (dispatch_fn) remoteDispatchDomainRevertToSnapshot,
.args_filter = (xdrproc_t) xdr_remote_domain_revert_to_snapshot_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainSnapshotDelete => 193 */
.fn = (dispatch_fn) remoteDispatchDomainSnapshotDelete,
.args_filter = (xdrproc_t) xdr_remote_domain_snapshot_delete_args,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainGetBlockInfo => 194 */
.fn = (dispatch_fn) remoteDispatchDomainGetBlockInfo,
.args_filter = (xdrproc_t) xdr_remote_domain_get_block_info_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_get_block_info_ret,
},
{ /* Async event DomainEventIoErrorReason => 195 */
.fn = NULL,
.args_filter = (xdrproc_t) xdr_void,
.ret_filter = (xdrproc_t) xdr_void,
},
{ /* DomainCreateWithFlags => 196 */
.fn = (dispatch_fn) remoteDispatchDomainCreateWithFlags,
.args_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
},

View File

@ -1,7 +1,16 @@
#!/usr/bin/perl -w
#
# This script parses remote_protocol.x and produces lots of boilerplate
# code for both ends of the remote connection.
# This script parses remote_protocol.x or qemu_protocol.x and produces lots of
# boilerplate code for both ends of the remote connection.
#
# The first non-option argument specifies the prefix to be searched for, and
# output to, the boilerplate code. The second non-option argument is the
# file you want to operate on. For instance, to generate the dispatch table
# for both remote_protocol.x and qemu_protocol.x, you would run the
# following:
#
# remote_generate_stubs.pl -c -t remote ../src/remote/remote_protocol.x
# remote_generate_stubs.pl -t qemu ../src/remote/qemu_protocol.x
#
# By Richard Jones <rjones@redhat.com>
@ -10,8 +19,12 @@ use strict;
use Getopt::Std;
# Command line options.
our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d);
getopts ('ptard');
our ($opt_p, $opt_t, $opt_a, $opt_r, $opt_d, $opt_c);
getopts ('ptardc');
my $structprefix = $ARGV[0];
my $procprefix = uc $structprefix;
shift;
# Convert name_of_call to NameOfCall.
sub name_to_ProcName {
@ -25,47 +38,50 @@ sub name_to_ProcName {
# opinion about the name, args and return type of each RPC.
my ($name, $ProcName, $id, %calls, @calls);
# REMOTE_PROC_CLOSE has no args or ret.
$calls{close} = {
name => "close",
ProcName => "Close",
UC_NAME => "CLOSE",
args => "void",
ret => "void",
};
# only generate a close method if -c was passed
if ($opt_c) {
# REMOTE_PROC_CLOSE has no args or ret.
$calls{close} = {
name => "close",
ProcName => "Close",
UC_NAME => "CLOSE",
args => "void",
ret => "void",
};
}
while (<>) {
if (/^struct remote_(.*)_args/) {
if (/^struct ${structprefix}_(.*)_args/) {
$name = $1;
$ProcName = name_to_ProcName ($name);
die "duplicate definition of remote_${name}_args"
die "duplicate definition of ${structprefix}_${name}_args"
if exists $calls{$name};
$calls{$name} = {
name => $name,
ProcName => $ProcName,
UC_NAME => uc $name,
args => "remote_${name}_args",
args => "${structprefix}_${name}_args",
ret => "void",
};
} elsif (/^struct remote_(.*)_ret/) {
} elsif (/^struct ${structprefix}_(.*)_ret/) {
$name = $1;
$ProcName = name_to_ProcName ($name);
if (exists $calls{$name}) {
$calls{$name}->{ret} = "remote_${name}_ret";
$calls{$name}->{ret} = "${structprefix}_${name}_ret";
} else {
$calls{$name} = {
name => $name,
ProcName => $ProcName,
UC_NAME => uc $name,
args => "void",
ret => "remote_${name}_ret"
ret => "${structprefix}_${name}_ret"
}
}
} elsif (/^struct remote_(.*)_msg/) {
} elsif (/^struct ${structprefix}_(.*)_msg/) {
$name = $1;
$ProcName = name_to_ProcName ($name);
@ -73,9 +89,9 @@ while (<>) {
name => $name,
ProcName => $ProcName,
UC_NAME => uc $name,
msg => "remote_${name}_msg"
msg => "${structprefix}_${name}_msg"
}
} elsif (/^\s*REMOTE_PROC_(.*?)\s+=\s+(\d+),?$/) {
} elsif (/^\s*${procprefix}_PROC_(.*?)\s+=\s+(\d+),?$/) {
$name = lc $1;
$id = $2;
$ProcName = name_to_ProcName ($name);
@ -111,7 +127,7 @@ elsif ($opt_p) {
# Skip things which are REMOTE_MESSAGE
next if $calls{$_}->{msg};
print "static int remoteDispatch$calls{$_}->{ProcName}(\n";
print "static int ${structprefix}Dispatch$calls{$_}->{ProcName}(\n";
print " struct qemud_server *server,\n";
print " struct qemud_client *client,\n";
print " virConnectPtr conn,\n";
@ -152,7 +168,7 @@ elsif ($opt_t) {
for ($id = 0 ; $id <= $#calls ; $id++) {
if (defined $calls[$id] && !$calls[$id]->{msg}) {
print "{ /* $calls[$id]->{ProcName} => $id */\n";
print " .fn = (dispatch_fn) remoteDispatch$calls[$id]->{ProcName},\n";
print " .fn = (dispatch_fn) ${structprefix}Dispatch$calls[$id]->{ProcName},\n";
if ($calls[$id]->{args} ne "void") {
print " .args_filter = (xdrproc_t) xdr_$calls[$id]->{args},\n";
} else {

View File

@ -22,9 +22,9 @@
#ifndef __LIBVIRTD_STREAM_H__
#define __LIBVIRTD_STREAM_H__
# define __LIBVIRTD_STREAM_H__
#include "libvirtd.h"
# include "libvirtd.h"

View File

@ -1,144 +0,0 @@
<?xml version="1.0"?>
<html>
<body>
<h1 >FAQ</h1>
<p>Table of Contents:</p>
<ul>
<li>
<a href="FAQ.html#License">License(s)</a>
</li>
<li>
<a href="FAQ.html#Installati">Installation</a>
</li>
<li>
<a href="FAQ.html#Compilatio">Compilation</a>
</li>
<li>
<a href="FAQ.html#Developer">Developer corner</a>
</li>
</ul>
<h3><a name="License" id="License">License</a>(s)</h3>
<ol>
<li>
<em>Licensing Terms for libvirt</em>
<p>libvirt is released under the <a href="http://www.opensource.org/licenses/lgpl-license.html">GNU Lesser
General Public License</a>, see the file COPYING.LIB in the distribution
for the precise wording. The only library that libvirt depends upon is
the Xen store access library which is also licenced under the LGPL.</p>
</li>
<li>
<em>Can I embed libvirt in a proprietary application ?</em>
<p>Yes. The LGPL allows you to embed libvirt into a proprietary
application. It would be graceful to send-back bug fixes and improvements
as patches for possible incorporation in the main development tree. It
will decrease your maintenance costs anyway if you do so.</p>
</li>
</ol>
<h3>
<a name="Installati" id="Installati">Installation</a>
</h3>
<ol>
<li><em>Where can I get libvirt</em> ?
<p>The original distribution comes from <a href="ftp://libvirt.org/libvirt/">ftp://libvirt.org/libvirt/</a>.</p>
</li>
<li>
<em>I can't install the libvirt/libvirt-devel RPM packages due to
failed dependencies</em>
<p>The most generic solution is to re-fetch the latest src.rpm , and
rebuild it locally with</p>
<p><code>rpm --rebuild libvirt-xxx.src.rpm</code>.</p>
<p>If everything goes well it will generate two binary rpm packages (one
providing the shared libs and virsh, and the other one, the -devel
package, providing includes, static libraries and scripts needed to build
applications with libvirt that you can install locally.</p>
<p>One can also rebuild the RPMs from a tarball:</p>
<p>
<code>rpmbuild -ta libdir-xxx.tar.gz</code>
</p>
<p>Or from a configured tree with:</p>
<p>
<code>make rpm</code>
</p>
</li>
<li>
<em>Failure to use the API for non-root users</em>
<p>Large parts of the API may only be accessible with root privileges,
however the read only access to the xenstore data doesnot have to be
forbidden to user, at least for monitoring purposes. If "virsh dominfo"
fails to run as an user, change the mode of the xenstore read-only socket
with:</p>
<p>
<code>chmod 666 /var/run/xenstored/socket_ro</code>
</p>
<p>and also make sure that the Xen Daemon is running correctly with local
HTTP server enabled, this is defined in
<code>/etc/xen/xend-config.sxp</code> which need the following line to be
enabled:</p>
<p>
<code>(xend-http-server yes)</code>
</p>
<p>If needed restart the xend daemon after making the change with the
following command run as root:</p>
<p>
<code>service xend restart</code>
</p>
</li>
</ol>
<h3>
<a name="Compilatio" id="Compilatio">Compilation</a>
</h3>
<ol>
<li>
<em>What is the process to compile libvirt ?</em>
<p>As most UNIX libraries libvirt follows the "standard":</p>
<p>
<code>gunzip -c libvirt-xxx.tar.gz | tar xvf -</code>
</p>
<p>
<code>cd libvirt-xxxx</code>
</p>
<p>
<code>./configure --help</code>
</p>
<p>to see the options, then the compilation/installation proper</p>
<p>
<code>./configure [possible options]</code>
</p>
<p>
<code>make</code>
</p>
<p>
<code>make install</code>
</p>
<p>At that point you may have to rerun ldconfig or a similar utility to
update your list of installed shared libs.</p>
</li>
<li>
<em>What other libraries are needed to compile/install libvirt ?</em>
<p>Libvirt requires libxenstore, which is usually provided by the xen
packages as well as the public headers to compile against libxenstore.</p>
</li>
<li>
<em>I use the GIT version and there is no configure script</em>
<p>The configure script (and other Makefiles) are generated. Use the
autogen.sh script to regenerate the configure script and Makefiles,
like:</p>
<p>
<code>./autogen.sh --prefix=/usr --disable-shared</code>
</p>
</li>
</ol>
<h3><a name="Developer" id="Developer">Developer</a> corner</h3>
<ol>
<li>
<em>Troubles compiling or linking programs using libvirt</em>
<p>To simplify the process of reusing the library, libvirt comes with
pkgconfig support, which can be used directly from autoconf support or
via the pkg-config command line tool, like:</p>
<p>
<code>pkg-config libvirt --libs</code>
</p>
</li>
</ol>
</body>
</html>

View File

@ -53,7 +53,7 @@ gif = \
architecture.gif \
node.gif
dot_html_in = $(wildcard *.html.in)
dot_html_in = $(notdir $(wildcard $(srcdir)/*.html.in))
dot_html = $(dot_html_in:%.html.in=%.html)
patches = $(wildcard api_extension/*.patch)
@ -70,8 +70,8 @@ fig = \
libvirt-object-model.fig
EXTRA_DIST= \
libvirt-api.xml libvirt-refs.xml apibuild.py \
site.xsl newapi.xsl news.xsl page.xsl ChangeLog.xsl \
apibuild.py \
site.xsl newapi.xsl news.xsl page.xsl ChangeLog.xsl \
$(dot_html) $(dot_html_in) $(gif) $(apihtml) $(apipng) \
$(devhelphtml) $(devhelppng) $(devhelpcss) $(devhelpxsl) \
$(xml) $(fig) $(png) \
@ -91,54 +91,66 @@ ChangeLog.xml: ../ChangeLog ChangeLog.awk
awk -f ChangeLog.awk < $< > $@
ChangeLog.html.in: ChangeLog.xml ChangeLog.xsl
@(if [ -x $(XSLTPROC) ] ; then \
@if [ -x $(XSLTPROC) ] ; then \
echo "Generating $@"; \
name=`echo $@ | sed -e 's/.tmp//'`; \
$(XSLTPROC) --nonet $(top_srcdir)/docs/ChangeLog.xsl $< > $@ || (rm $@ && exit 1) ; fi )
$(XSLTPROC) --nonet $(top_srcdir)/docs/ChangeLog.xsl $< > $@ \
|| { rm $@ && exit 1; }; fi
%.png: %.fig
convert -rotate 90 $< $@
%.html.tmp: %.html.in site.xsl page.xsl sitemap.html.in
@(if [ -x $(XSLTPROC) ] ; then \
@if [ -x $(XSLTPROC) ] ; then \
echo "Generating $@"; \
name=`echo $@ | sed -e 's/.tmp//'`; \
$(XSLTPROC) --stringparam pagename $$name --nonet --html $(top_srcdir)/docs/site.xsl $< > $@ || (rm $@ && exit 1) ; fi )
$(XSLTPROC) --stringparam pagename $$name --nonet --html \
$(top_srcdir)/docs/site.xsl $< > $@ \
|| { rm $@ && exit 1; }; fi
%.html: %.html.tmp
@(if [ -x $(XMLLINT) -a -x $(XMLCATALOG) ] ; then \
if $(XMLCATALOG) /etc/xml/catalog "-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \
@if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
if $(XMLCATALOG) /etc/xml/catalog \
"-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \
echo "Validating $@" ; \
$(XMLLINT) --nonet --format --valid $< > $@ || (rm $@ && exit 1) ; \
else echo "missing XHTML1 DTD" ; fi ; fi );
$(XMLLINT) --nonet --format --valid $< > $@ \
|| { rm $@ && exit 1; }; \
else echo "missing XHTML1 DTD" ; fi ; fi
html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in
-@(if [ -x $(XSLTPROC) ] ; then \
-@if [ -x $(XSLTPROC) ] ; then \
echo "Rebuilding the HTML pages from the XML API" ; \
$(XSLTPROC) --nonet $(srcdir)/newapi.xsl libvirt-api.xml ; fi )
-@(if [ -x $(XMLLINT) -a -x $(XMLCATALOG) ] ; then \
if $(XMLCATALOG) /etc/xml/catalog "-//W3C//DTD XHTML 1.0 Strict//EN" > /dev/null ; then \
$(XSLTPROC) --nonet $(srcdir)/newapi.xsl libvirt-api.xml ; fi
-@if test -x $(XMLLINT) && test -x $(XMLCATALOG) ; then \
if $(XMLCATALOG) /etc/xml/catalog "-//W3C//DTD XHTML 1.0 Strict//EN" \
> /dev/null ; then \
echo "Validating the resulting XHTML pages" ; \
$(XMLLINT) --nonet --valid --noout html/*.html ; \
else echo "missing XHTML1 DTD" ; fi ; fi );
else echo "missing XHTML1 DTD" ; fi ; fi
$(devhelphtml): libvirt-api.xml $(devhelpxsl)
-@(echo Rebuilding devhelp files)
-@(if [ -x $(XSLTPROC) ] ; then \
$(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl)
-@echo Rebuilding devhelp files
-@if [ -x $(XSLTPROC) ] ; then \
$(XSLTPROC) --nonet -o devhelp/libvirt.devhelp \
$(top_srcdir)/docs/devhelp/devhelp.xsl libvirt-api.xml ; fi );
$(top_srcdir)/docs/devhelp/devhelp.xsl libvirt-api.xml ; fi
html/%-%.html html/%-virterror.html %-api.xml %-refs.xml: $(srcdir)/apibuild.py
python_generated_files = \
$(srcdir)/html/libvirt-libvirt.html \
$(srcdir)/html/libvirt-virterror.html \
$(srcdir)/libvirt-api.xml \
$(srcdir)/libvirt-refs.xml
$(python_generated_files): $(srcdir)/apibuild.py \
$(srcdir)/../include/libvirt/*.h \
$(srcdir)/../src/libvirt.c \
$(srcdir)/../src/util/virterror.c
-srcdir=$(srcdir) $(srcdir)/apibuild.py
html/%-%.html html/%-virterror.html %-api.xml %-refs.xml: \
$(srcdir)/../include/%/*.h \
$(srcdir)/../src/%.c \
$(srcdir)/../src/util/virterror.c
check-local: all
clean-local:
rm -f *~ *.bak *.hierarchy *.signals *-unused.txt
rm -f *~ *.bak *.hierarchy *.signals *-unused.txt *.html
maintainer-clean-local: clean-local
rm -rf libvirt-api.xml libvirt-refs.xml
@ -147,8 +159,7 @@ rebuild: api all
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
-$(INSTALL) -m 0644 $(srcdir)/FAQ.html \
$(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(HTML_DIR)
-$(INSTALL) -m 0644 $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(HTML_DIR)
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/html
for h in $(apihtml); do \
$(INSTALL) -m 0644 $(srcdir)/$$h $(DESTDIR)$(HTML_DIR)/html; done

View File

@ -146,7 +146,7 @@ index b84729f..4f73baf 100644
+ goto cleanup;
+ }
+
+ VIR_DEBUG(_("Vport operation path is '%s'"), operation_path);
+ VIR_DEBUG("Vport operation path is '%s'", operation_path);
+
+ fd = open(operation_path, O_WRONLY);
+
@ -959,7 +959,7 @@ index 0000000..1deb6d2
+ char buf[64];
+ struct stat st;
+
+ VIR_DEBUG(_("Checking if host%d is an FC HBA"), d->scsi_host.host);
+ VIR_DEBUG("Checking if host%d is an FC HBA", d->scsi_host.host);
+
+ if (virAsprintf(&sysfs_path, "%s/host%d",
+ LINUX_SYSFS_FC_HOST_PREFIX,

View File

@ -11,24 +11,23 @@ diff --git a/src/virsh.c b/src/virsh.c
index cb32ede..ab2a2b7 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -2962,6 +2962,107 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
@@ -2962,6 +2962,106 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
/*
+ * "nodedev-create" command
+ */
+static const vshCmdInfo info_node_device_create[] = {
+ {"help", gettext_noop("create a device defined "
+ "by an XML file on the node")},
+ {"desc", gettext_noop("Create a device on the node. Note that this "
+ "command creates devices on the physical host "
+ "that can then be assigned to a virtual machine.")},
+ {"help", N_("create a device defined by an XML file on the node")},
+ {"desc", N_("Create a device on the node. Note that this "
+ "command creates devices on the physical host "
+ "that can then be assigned to a virtual machine.")},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_node_device_create[] = {
+ {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
+ gettext_noop("file containing an XML description of the device")},
+ N_("file containing an XML description of the device")},
+ {NULL, 0, 0, NULL}
+};
+
@ -72,15 +71,15 @@ index cb32ede..ab2a2b7 100644
+ * "nodedev-destroy" command
+ */
+static const vshCmdInfo info_node_device_destroy[] = {
+ {"help", gettext_noop("destroy a device on the node")},
+ {"desc", gettext_noop("Destroy a device on the node. Note that this "
+ "command destroys devices on the physical host ")},
+ {"help", N_("destroy a device on the node")},
+ {"desc", N_("Destroy a device on the node. Note that this "
+ "command destroys devices on the physical host")},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_node_device_destroy[] = {
+ {"name", VSH_OT_DATA, VSH_OFLAG_REQ,
+ gettext_noop("name of the device to be destroyed")},
+ N_("name of the device to be destroyed")},
+ {NULL, 0, 0, NULL}
+};
+

View File

@ -28,6 +28,7 @@ ignored_words = {
"ATTRIBUTE_UNUSED": (0, "macro keyword"),
"ATTRIBUTE_SENTINEL": (0, "macro keyword"),
"VIR_DEPRECATED": (0, "macro keyword"),
"VIR_EXPORT_VAR": (0, "macro keyword"),
"WINAPI": (0, "Windows keyword"),
"__declspec": (3, "Windows keyword"),
"__stdcall": (0, "Windows keyword"),

View File

@ -16,6 +16,7 @@ higher level kind of languages:</p>
<li><strong>Ruby</strong>: David Lutterkort provides <a href="http://libvirt.org/ruby/">bindings for Ruby</a>.</li>
<li><strong>Java</strong>: Daniel Veillard maintains <a href="java.html">Java bindings</a>.</li>
<li><strong>C#</strong>: Jarom&iacute;r &#x010C;ervenka maintains <a href="http://svn.i-tux.cz/listing.php?repname=SharpLibVirt">C# bindings here</a>.</li>
<li><strong>PHP</strong>: Radek Hladik is developing <a href="http://phplibvirt.cybersales.cz/">PHP bindings</a>.</li>
</ul>
<p>For information on using libvirt on <strong>Windows</strong>
<a href="windows.html">please see the Windows

View File

@ -21,7 +21,7 @@
</ul>
</dd>
<dt><a href="">libvirt-users@redhat.com</a></dt>
<dt><a href="https://www.redhat.com/archives/libvirt-users/">libvirt-users@redhat.com</a></dt>
<dd>This list a place for discussions involving libvirt <strong>users</strong>. Topics for discussion include
<ul>
<li>Usage of libvirt / virsh</li>

View File

@ -43,18 +43,34 @@
<a href="http://libvirt.org/git/?p=libvirt.git;a=summary">http://libvirt.org/git/?p=libvirt.git;a=summary</a>
</pre>
<h2>CVS repository access (Deprecated) </h2>
<p>
The master source repository used to be under <a href="http://ximbiot.com/cvs/cvshome/docs/">CVS</a>
with anonymous access at:
</p>
<pre>
# cvs -d :pserver:anoncvs@libvirt.org:2401/data/cvs co libvirt
</pre>
<p> The server is maintainened temporarilly for existing uses, but all
changes are only commited to git now and we expect to deprecate the CVS
server during summer 2009. </p>
<h1>Installation</h1>
<h2>
<a name="Compilatio" id="Compilatio">Compilation</a>
</h2>
<p>As most UNIX libraries libvirt follows the "standard":</p>
<p>
<code>gunzip -c libvirt-xxx.tar.gz | tar xvf -</code>
</p>
<p>
<code>cd libvirt-xxxx</code>
</p>
<p>
<code>./configure --help</code>
</p>
<p>to see the options, then the compilation/installation proper</p>
<p>
<code>./configure [possible options]</code>
</p>
<p>
<code>make</code>
</p>
<p>
<code>make install</code>
</p>
<p>At that point you may have to rerun ldconfig or a similar utility to
update your list of installed shared libs.
</p>
<h2>Building from a source code checkout</h2>
<p> The libvirt build process uses GNU autotools, so after obtaining a
@ -68,27 +84,5 @@
make
make install
</pre>
<h2>GIT repository mirror</h2>
<p>
Jim Mereying was maintaining a CVS to git mirror on
<a href="http://git.et.redhat.com/?p=libvirt.git">git.et.redhat.com</a>.
Existing users should migrate to the new libvirt.org git server, as the
old one is now deprecated. For the sake of old links including now-
rewritten SHA1s, we'll leave the old repository on-line for some time.
It is available as:
</p>
<pre>
git clone git://git.et.redhat.com/libvirt.git
</pre>
<p>
It can also be browsed at
</p>
<pre>
<a href="http://git.et.redhat.com/?p=libvirt.git;a=summary">http://git.et.redhat.com/?p=libvirt.git;a=summary</a>
</pre>
</body>
</html>

View File

@ -2,15 +2,16 @@
<h1>VMware ESX hypervisor driver</h1>
<ul id="toc"></ul>
<p>
The libvirt VMware ESX driver can manage VMware ESX/ESXi 3.5/4.0 and
The libvirt VMware ESX driver can manage VMware ESX/ESXi 3.5/4.x and
VMware GSX 2.0, also called VMware Server 2.0, and possibly later
versions.
versions. <span class="since">Since 0.8.3</span> the driver can also
connect to a VMware vCenter 2.5/4.x (VPX).
</p>
<h2><a name="prereq">Deployment pre-requisites</a></h2>
<p>
None. Any out-of-the-box installation of ESX/GSX should work. No
None. Any out-of-the-box installation of VPX/ESX(i)/GSX should work. No
preparations are required on the server side, no libvirtd must be
installed on the ESX server. The driver uses version 2.5 of the remote,
SOAP based
@ -27,33 +28,64 @@
Some example remote connection URIs for the driver are:
</p>
<pre>
esx://example.com (ESX over HTTPS)
gsx://example.com (GSX over HTTPS)
esx://example.com/?transport=http (ESX over HTTP)
esx://example.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the server's SSL certificate)
vpx://example-vcenter.com/dc1/srv1 (VPX over HTTPS, select ESX server 'srv1' in datacenter 'dc1')
esx://example-esx.com (ESX over HTTPS)
gsx://example-gsx.com (GSX over HTTPS)
esx://example-esx.com/?transport=http (ESX over HTTP)
esx://example-esx.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the server's SSL certificate)
</pre>
<p>
<strong>Note</strong>: In contrast to other drivers, the ESX driver is
a client-side-only driver. It connects to the ESX server using HTTP(S).
Therefore, the <a href="remote.html">remote transport mechanism</a>
provided by the remote driver and libvirtd will not work, and you
cannot use URIs like <code>esx+ssh://example.com</code>.
</p>
<h3><a name="uriformat">URI Format</a></h3>
<p>
URIs have this general form ('[...]' marks an optional part).
URIs have this general form (<code>[...]</code> marks an optional part).
</p>
<pre>
type://[username@]hostname[:port]/[?extraparameters]
type://[username@]hostname[:port]/[datacenter[/cluster]/server][?extraparameters]
</pre>
<p>
The <code>type://</code> is either <code>esx://</code> or
<code>gsx://</code> and the driver selects the default port depending
on it. For ESX the default HTTPS port is 443, for GSX it is 8333. If
the port parameter is given, it overrides the default port.
<code>gsx://</code> or <code>vpx://</code> <span class="since">since 0.8.3</span>.
The driver selects the default port depending on the <code>type://</code>.
For <code>esx://</code> and <code>vpx://</code> the default HTTPS port
is 443, for <code>gsx://</code> it is 8333.
If the port parameter is given, it overrides the default port.
</p>
<p>
A <code>vpx://</code> connection is currently restricted to a single
ESX server. This might be relaxed in the future. The path part of the
URI is used to specify the datacenter and the ESX server in it. If the
ESX server is part of a cluster then the cluster has to be specified too.
</p>
<p>
An example: ESX server <code>example-esx.com</code> is managed by
vCenter <code>example-vcenter.com</code> and part of cluster
<code>cluster1</code>. This cluster is part of datacenter <code>dc1</code>.
</p>
<pre>
vpx://example-vcenter.com/dc1/cluster1/example-esx.com
</pre>
<h4>Extra parameters</h4>
<p>
Extra parameters can be added to a URI as part of the query string
(the part following '?'). The driver understands the extra parameters
shown below.
(the part following <code>?</code>). A single parameter is formed by a
<code>name=value</code> pair. Multiple parameters are separated by
<code>&amp;</code>.
</p>
<pre>
?<span style="color: #E50000">no_verify=1</span>&amp;<span style="color: #00B200">auto_answer=1</span>&amp;<span style="color: #0000E5">proxy=socks://example-proxy.com:23456</span>
</pre>
<p>
The driver understands the extra parameters shown below.
</p>
<table class="top_table">
<tr>
@ -69,8 +101,9 @@ type://[username@]hostname[:port]/[?extraparameters]
<code>http</code> or <code>https</code>
</td>
<td>
Overrides the default HTTPS transport. For ESX the default
HTTP port is 80, for GSX it is 8222.
Overrides the default HTTPS transport. For <code>esx://</code>
and <code>vpx://</code> the default HTTP port is 80, for
<code>gsx://</code> it is 8222.
</td>
</tr>
<tr>
@ -84,6 +117,7 @@ type://[username@]hostname[:port]/[?extraparameters]
In order to perform a migration the driver needs to know the
VMware vCenter for the ESX server. If set to <code>*</code>,
the driver connects to the vCenter known to the ESX server.
This paramater in useful when connecting to an ESX server only.
</td>
</tr>
<tr>
@ -109,7 +143,25 @@ type://[username@]hostname[:port]/[?extraparameters]
If set to 1, the driver answers all
<a href="#questions">questions</a> with the default answer.
If set to 0, questions are reported as errors. The default
value it 0.
value it 0. <span class="since">Since 0.7.5</span>.
</td>
</tr>
<tr>
<td>
<code>proxy</code>
</td>
<td>
<code>[type://]hostname[:port]</code>
</td>
<td>
Allows to specify a proxy for HTTP and HTTPS communication.
<span class="since">Since 0.8.2</span>.
The optional <code>type</code> part may be one of:
<code>http</code>, <code>socks</code>, <code>socks4</code>,
<code>socks4a</code> or <code>socks5</code>. The default is
<code>http</code> and <code>socks</code> is synonymous for
<code>socks5</code>. The optional <code>port</code> allows to
override the default port 1080.
</td>
</tr>
</table>
@ -192,7 +244,7 @@ type://[username@]hostname[:port]/[?extraparameters]
To define a new domain the driver converts the domain XML into a
VMware VMX file and uploads it to a datastore known to the ESX server.
Because multiple datastores may be known to an ESX server the driver
needs to decide to which datastores the VMX file should be uploaded.
needs to decide to which datastore the VMX file should be uploaded.
The driver deduces this information from the path of the source of the
first file-based harddisk listed in the domain XML.
</p>
@ -267,6 +319,15 @@ ethernet0.checkMACAddress = "false"
<h4>SCSI controller models</h4>
<dl>
<dt><code>auto</code></dt>
<dd>
This isn't a actual controller model. If specified the ESX driver
tries to detect the SCSI controller model referenced in the
<code>.vmdk</code> file and use it. Autodetection fails when a
SCSI controller has multiple disks attached and the SCSI controller
models referenced in the <code>.vmdk</code> files are inconsistent.
<span class="since">Since 0.8.3</span>
</dd>
<dt><code>buslogic</code></dt>
<dd>
BusLogic SCSI controller for older guests.
@ -275,10 +336,35 @@ ethernet0.checkMACAddress = "false"
<dd>
LSI Logic SCSI controller for recent guests.
</dd>
<dt><code>lsisas1068</code></dt>
<dd>
LSI Logic SAS 1068 controller. <span class="since">Since 0.8.0</span>
</dd>
<dt><code>vmpvscsi</code></dt>
<dd>
Special VMware Paravirtual SCSI controller, requires VMware tools inside
the guest. See <a href="http://kb.vmware.com/kb/1010398">VMware KB1010398</a>
for details. <span class="since">Since 0.8.3</span>
</dd>
</dl>
<p>
Here a domain XML snippet:
</p>
<pre>
...
&lt;disk type='file' device='disk'&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0' model='<strong>lsilogic</strong>'/&gt;
...
</pre>
<p>
The controller element is supported <span class="since">since 0.8.2</span>.
Prior to this <code>&lt;driver name='lsilogic'/&gt;</code> was abused to
specify the SCSI controller model. This attribute usage is deprecated now.
</p>
<pre>
...
&lt;disk type='file' device='disk'&gt;
@ -296,10 +382,11 @@ ethernet0.checkMACAddress = "false"
<dd>
AMD PCnet32 network card for older guests.
</dd>
<dt><code>vmxnet</code>, <code>vmxnet3</code></dt>
<dt><code>vmxnet</code>, <code>vmxnet2</code>, <code>vmxnet3</code></dt>
<dd>
Special VMware VMXnet network card, requires VMware tools inside
the guest.
the guest. See <a href="http://kb.vmware.com/kb/1001805">VMware KB1001805</a>
for details.
</dd>
<dt><code>e1000</code></dt>
<dd>
@ -363,7 +450,7 @@ ide0:0.startConnected = "false"
ethernet0.present = "true"
ethernet0.networkName = "VM Network"
ethernet0.addressType = "vpx"
ethernet0.address = "00:50:56:91:48:c7"
ethernet0.generatedAddress = "00:50:56:91:48:c7"
chipset.onlineStandby = "false"
guestOSAltName = "Red Hat Enterprise Linux 5 (32-Bit)"
guestOS = "rhel5"
@ -404,10 +491,11 @@ Enter root password for example.com:
&lt;on_crash&gt;destroy&lt;/on_crash&gt;
&lt;devices&gt;
&lt;disk type='file' device='disk'&gt;
&lt;driver name='lsilogic'/&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0' model='lsilogic'/&gt;
&lt;interface type='bridge'&gt;
&lt;mac address='00:50:56:91:48:c7'/&gt;
&lt;source bridge='VM Network'/&gt;
@ -435,10 +523,11 @@ $ cat &gt; demo.xml &lt;&lt; EOF
&lt;/os&gt;
&lt;devices&gt;
&lt;disk type='file' device='disk'&gt;
&lt;driver name='lsilogic'/&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0' model='lsilogic'/&gt;
&lt;interface type='bridge'&gt;
&lt;mac address='00:50:56:25:48:c7'/&gt;
&lt;source bridge='VM Network'/&gt;
@ -487,7 +576,9 @@ ethernet0.address = "00:50:56:25:48:C7"
&lt;disk type='file' device='disk'&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0'/&gt;
&lt;interface type='bridge'&gt;
&lt;mac address='00:50:56:25:48:c7'/&gt;
&lt;source bridge='VM Network'/&gt;
@ -511,7 +602,7 @@ ethernet0.address = "00:50:56:25:48:C7"
esx://example.com/?vcenter=example-vcenter.com
</pre>
<p>
Here an example how to migrate the domain <code>Fedora11</code> from
Here's an example how to migrate the domain <code>Fedora11</code> from
ESX server <code>example-src.com</code> to ESX server
<code>example-dst.com</code> implicitly involving vCenter
<code>example-vcenter.com</code> using <code>virsh</code>.
@ -526,6 +617,19 @@ Enter username for example-dst.com [root]:
Enter root password for example-dst.com:
Enter username for example-vcenter.com [administrator]:
Enter administrator password for example-vcenter.com:
</pre>
<p>
<span class="since">Since 0.8.3</span> you can directly connect to a vCenter.
This simplifies migration a bit. Here's the same migration as above but
using <code>vpx://</code> connections and assuming both ESX server are in
datacenter <code>dc1</code> and aren't part of a cluster.
</p>
<pre>
$ virsh -c vpx://example-vcenter.com/dc1/example-src.com migrate Fedora11 vpx://example-vcenter.com/dc1/example-dst.com
Enter username for example-vcenter.com [administrator]:
Enter administrator password for example-vcenter.com:
Enter username for example-vcenter.com [administrator]:
Enter administrator password for example-vcenter.com:
</pre>
@ -593,5 +697,10 @@ Enter administrator password for example-vcenter.com:
VMware VMX config parameters
</a>
</li>
<li>
<a href="http://www.vmware.com/pdf/vsp_4_pvscsi_perf.pdf">
VMware ESX 4.0 PVSCSI Storage Performance
</a>
</li>
</ul>
</body></html>

477
docs/firewall.html.in Normal file
View File

@ -0,0 +1,477 @@
<?xml version="1.0"?>
<html>
<body>
<h1 >Firewall and network filtering in libvirt</h1>
<p>There are three pieces of libvirt functionality which do network
filtering of some type.
<br /><br />
At a high level they are:
</p>
<ul>
<li>The virtual network driver
<br /><br />
This provides a isolated bridge device (ie no physical NICs
enslaved). Guest TAP devices are attached to this bridge.
Guests can talk to each other and the host, and optionally the
wider world.
<br /><br />
</li>
<li>The QEMU driver MAC filtering
<br /><br />
This provides a generic filtering of MAC addresses to prevent
the guest spoofing its MAC address. This is mostly obsoleted by
the next item, so won't be discussed further.
<br /><br />
</li>
<li>The network filter driver
<br /><br />
This provides fully configurable, arbitrary network filtering
of traffic on guest NICs. Generic rulesets are defined at the
host level to control traffic in some manner. Rules sets are
then associated with individual NICs of a guest. While not as
expressive as directly using iptables/ebtables, this can still
do nearly everything you would want to on a guest NIC filter.
</li>
</ul>
<h3><a name="name-fw-virtual-network-driver"
id="id-fw-virtual-network-driver">The virtual network driver</a>
</h3>
<p>The typical configuration for guests is to use bridging of the
physical NIC on the host to connect the guest directly to the LAN.
In RHEL6 there is also the possibility of using macvtap/sr-iov
and VEPA connectivity. None of this stuff plays nicely with wireless
NICs, since they will typically silently drop any traffic with a
MAC address that doesn't match that of the physical NIC.
</p>
<p>Thus the virtual network driver in libvirt was invented. This takes
the form of an isolated bridge device (ie one with no physical NICs
enslaved). The TAP devices associated with the guest NICs are attached
to the bridge device. This immediately allows guests on a single host
to talk to each other and to the host OS (modulo host IPtables rules).
</p>
<p>libvirt then uses iptables to control what further connectivity is
available. There are three configurations possible for a virtual
network at time of writing:
</p>
<ul>
<li>isolated: all off-node traffic is completely blocked</li>
<li>nat: outbound traffic to the LAN is allowed, but MASQUERADED</li>
<li>forward: outbound traffic to the LAN is allowed</li>
</ul>
<p>The latter 'forward' case requires the virtual network be on a
separate sub-net from the main LAN, and that the LAN admin has
configured routing for this subnet. In the future we intend to
add support for IP subnetting and/or proxy-arp. This allows for
the virtual network to use the same subnet as the main LAN and
should avoid need for the LAN admin to configure special routing.
</p>
<p>Libvirt will optionally also provide DHCP services to the virtual
network using DNSMASQ. In all cases, we need to allow DNS/DHCP
queries to the host OS. Since we can't predict whether the host
firewall setup is already allowing this, we insert 4 rules into
the head of the INPUT chain
</p>
<pre>
target prot opt in out source destination
ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67
ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67</pre>
<p>Note we have restricted our rules to just the bridge associated
with the virtual network, to avoid opening undesirable holes in
the host firewall wrt the LAN/WAN.
</p>
<p>The next rules depend on the type of connectivity allowed, and go
in the main FORWARD chain:
</p>
<ul>
<li>type=isolated
<br /><br />
Allow traffic between guests. Deny inbound. Deny outbound.
<pre>
target prot opt in out source destination
ACCEPT all -- virbr1 virbr1 0.0.0.0/0 0.0.0.0/0
REJECT all -- * virbr1 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- virbr1 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable</pre>
</li>
<li>type=nat
<br /><br />
Allow inbound related to an established connection. Allow
outbound, but only from our expected subnet. Allow traffic
between guests. Deny all other inbound. Deny all other outbound.
<pre>
target prot opt in out source destination
ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 state RELATED,ESTABLISHED
ACCEPT all -- virbr0 * 192.168.122.0/24 0.0.0.0/0
ACCEPT all -- virbr0 virbr0 0.0.0.0/0 0.0.0.0/0
REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- virbr0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable</pre>
</li>
<li>type=routed
<br /><br />
Allow inbound, but only to our expected subnet. Allow
outbound, but only from our expected subnet. Allow traffic
between guests. Deny all other inbound. Deny all other outbound.
<pre>
target prot opt in out source destination
ACCEPT all -- * virbr2 0.0.0.0/0 192.168.124.0/24
ACCEPT all -- virbr2 * 192.168.124.0/24 0.0.0.0/0
ACCEPT all -- virbr2 virbr2 0.0.0.0/0 0.0.0.0/0
REJECT all -- * virbr2 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- virbr2 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable</pre>
</li>
<li>Finally, with type=nat, there is also an entry in the POSTROUTING
chain to apply masquerading:
<pre>
target prot opt in out source destination
MASQUERADE all -- * * 192.168.122.0/24 !192.168.122.0/24</pre>
</li>
</ul>
<h3><a name="name-fw-network-filter-driver"
id="id-fw-network-filter-driver">The network filter driver</a>
</h3>
<p>This driver provides a fully configurable network filtering capability
that leverages ebtables, iptables and ip6tables. This was written by
the libvirt guys at IBM and although its XML schema is defined by libvirt,
the conceptual model is closely aligned with the DMTF CIM schema for
network filtering:
</p>
<p><a href="http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf">http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf</a></p>
<p>The filters are managed in libvirt as a top level, standalone object.
This allows the filters to then be referenced by any libvirt object
that requires their functionality, instead tieing them only to use
by guest NICs. In the current implementation, filters can be associated
with individual guest NICs via the libvirt domain XML format. In the
future we might allow filters to be associated with the virtual network
objects. Further we're expecting to define a new 'virtual switch' object
to remove the complexity of configuring bridge/sriov/vepa networking
modes. This make also end up making use of network filters.
</p>
<p>There are a new set of virsh commands for managing network filters:</p>
<ul>
<li>virsh nwfilter-define
<br /><br />
define or update a network filter from an XML file
<br /><br />
</li>
<li>virsh nwfilter-undefine
<br /><br />
undefine a network filter
<br /><br />
</li>
<li>virsh nwfilter-dumpxml
<br /><br />
network filter information in XML
<br /><br />
</li>
<li>virsh nwfilter-list
<br /><br />
list network filters
<br /><br />
</li>
<li>virsh nwfilter-edit
<br /><br />
edit XML configuration for a network filter
</li>
</ul>
<p>There are equivalently named C APIs for each of these commands.</p>
<p>As with all objects libvirt manages, network filters are configured
using an XML format. At a high level the format looks like this:
</p>
<pre>
&lt;filter name='no-spamming' chain='XXXX'&gt;
&lt;uuid&gt;d217f2d7-5a04-0e01-8b98-ec2743436b74&lt;/uuid&gt;
&lt;rule ...&gt;
....
&lt;/rule&gt;
&lt;filterref filter='XXXX'/&gt;
&lt;/filter&gt;</pre>
<p>Every filter has a name and UUID which serve as unique identifiers.
A filter can have zero-or-more <code>&lt;rule&gt;</code> elements which
are used to actually define network controls. Filters can be arranged
into a DAG, so zero-or-more <code>&lt;filterref/&gt;</code> elements are
also allowed. Cycles in the graph are not allowed.
</p>
<p>The <code>&lt;rule&gt;</code> element is where all the interesting stuff
happens. It has three attributes, an action, a traffic direction and an
optional priority. eg:
</p>
<pre>&lt;rule action='drop' direction='out' priority='500'&gt;</pre>
<p>Within the rule there are a wide variety of elements allowed, which
do protocol specific matching. Supported protocols currently include
<code>mac</code>, <code>arp</code>, <code>rarp</code>, <code>ip</code>,
<code>ipv6</code>, <code>tcp/ip</code>, <code>icmp/ip</code>,
<code>igmp/ip</code>, <code>udp/ip</code>, <code>udplite/ip</code>,
<code>esp/ip</code>, <code>ah/ip</code>, <code>sctp/ip</code>,
<code>tcp/ipv6</code>, <code>icmp/ipv6</code>, <code>igmp/ipv6</code>,
<code>udp/ipv6</code>, <code>udplite/ipv6</code>, <code>esp/ipv6</code>,
<code>ah/ipv6</code>, <code>sctp/ipv6</code>. Each protocol defines what
is valid inside the &lt;rule&gt; element. The general pattern though is:
</p>
<pre>
&lt;protocol match='yes|no' attribute1='value1' attribute2='value2'/&gt;</pre>
<p>So, eg a TCP protocol, matching ports 0-1023 would be expressed as:</p>
<pre>&lt;tcp match='yes' srcportstart='0' srcportend='1023'/&gt;</pre>
<p>Attributes can included references to variables defined by the
object using the rule. So the guest XML format allows each NIC
to have a MAC address and IP address defined. These are made
available to filters via the variables <code><b>$IP</b></code> and
<code><b>$MAC</b></code>.
</p>
<p>So to define a filter that prevents IP address spoofing we can
simply match on source IP address <code>!= $IP</code> like this:
</p>
<pre>
&lt;filter name='no-ip-spoofing' chain='ipv4'&gt;
&lt;rule action='drop' direction='out'&gt;
&lt;ip match='no' srcipaddr='<b>$IP</b>' /&gt;
&lt;/rule&gt;
&lt;/filter&gt;</pre>
<p>I'm not going to go into details on all the other protocol
matches you can do, because it'll take far too much space.
You can read about the options
<a href="formatnwfilter.html#nwfelemsRulesProto">here</a>.
</p>
<p>Out of the box in RHEL6/Fedora rawhide, libvirt ships with a
set of default useful rules:
</p>
<pre>
# virsh nwfilter-list
UUID Name
----------------------------------------------------------------
15b1ab2b-b1ac-1be2-ed49-2042caba4abb allow-arp
6c51a466-8d14-6d11-46b0-68b1a883d00f allow-dhcp
7517ad6c-bd90-37c8-26c9-4eabcb69848d allow-dhcp-server
3d38b406-7cf0-8335-f5ff-4b9add35f288 allow-incoming-ipv4
5ff06320-9228-2899-3db0-e32554933415 allow-ipv4
db0b1767-d62b-269b-ea96-0cc8b451144e clean-traffic
f88f1932-debf-4aa1-9fbe-f10d3aa4bc95 no-arp-spoofing
772f112d-52e4-700c-0250-e178a3d91a7a no-ip-multicast
7ee20370-8106-765d-f7ff-8a60d5aaf30b no-ip-spoofing
d5d3c490-c2eb-68b1-24fc-3ee362fc8af3 no-mac-broadcast
fb57c546-76dc-a372-513f-e8179011b48a no-mac-spoofing
dba10ea7-446d-76de-346f-335bd99c1d05 no-other-l2-traffic
f5c78134-9da4-0c60-a9f0-fb37bc21ac1f no-other-rarp-traffic
7637e405-4ccf-42ac-5b41-14f8d03d8cf3 qemu-announce-self
9aed52e7-f0f3-343e-fe5c-7dcb27b594e5 qemu-announce-self-rarp</pre>
<p>Most of these are just building blocks. The interesting one here
is 'clean-traffic'. This pulls together all the building blocks
into one filter that you can then associate with a guest NIC.
This stops the most common bad things a guest might try, IP
spoofing, arp spoofing and MAC spoofing. To look at the rules for
any of these just do:
</p>
<pre>virsh nwfilter-dumpxml FILTERNAME|UUID</pre>
<p>They are all stored in <code>/etc/libvirt/nwfilter</code>, but don't
edit the files there directly. Use <code>virsh nwfilter-define</code>
to update them. This ensures the guests have their iptables/ebtables
rules recreated.
</p>
<p>To associate the clean-trafffic filter with a guest, edit the
guest XML config and change the <code>&lt;interface&gt;</code> element
to include a <code>&lt;filterref&gt;</code> and also specify the
whitelisted <code>&lt;ip address/&gt;</code> the guest is allowed to
use:
</p>
<pre>
&lt;interface type='bridge'&gt;
&lt;mac address='52:54:00:56:44:32'/&gt;
&lt;source bridge='br1'/&gt;
&lt;ip address='10.33.8.131'/&gt;
&lt;target dev='vnet0'/&gt;
&lt;model type='virtio'/&gt;
&lt;filterref filter='clean-traffic'/&gt;
&lt;/interface&gt;</pre>
<p>If no <code>&lt;ip address&gt;</code> is included, the network filter
driver will activate its 'learning mode'. This uses libpcap to snoop on
network traffic the guest sends and attempts to identify the
first IP address it uses. It then locks traffic to this address.
Obviously this isn't entirely secure, but it does offer some
protection against the guest being trojaned once up and running.
In the future we intend to enhance the learning mode so that it
looks for DHCPOFFERS from a trusted DHCP server and only allows
the offered IP address to be used.
</p>
<p>Now, how is all this implemented...?</p>
<p>The network filter driver uses a combination of ebtables, iptables and
ip6tables, depending on which protocols are referenced in a filter. The
out of the box 'clean-traffic' filter rules only require use of
ebtables. If you want to do matching at tcp/udp/etc protocols (eg to add
a new filter 'no-email-spamming' to block port 25), then iptables will
also be used.
</p>
<p>The driver attempts to keep its rules separate from those that
the host admin might already have configured. So the first thing
it does with ebtables, is to add two hooks in POSTROUTING and
PREROUTING chains, to redirect traffic to custom chains. These
hooks match on the TAP device name of the guest NIC, so they
should not interact badly with any administrator defined rules:
</p>
<pre>
Bridge chain: PREROUTING, entries: 1, policy: ACCEPT
-i vnet0 -j libvirt-I-vnet0
Bridge chain: POSTROUTING, entries: 1, policy: ACCEPT
-o vnet0 -j libvirt-O-vnet0</pre>
<p>To keep things managable and easy to follow, the driver will then
create further sub-chains for each protocol then it needs to match
against:
</p>
<pre>
Bridge chain: libvirt-I-vnet0, entries: 5, policy: ACCEPT
-p IPv4 -j I-vnet0-ipv4
-p ARP -j I-vnet0-arp
-p 0x8035 -j I-vnet0-rarp
-p 0x835 -j ACCEPT
-j DROP
Bridge chain: libvirt-O-vnet0, entries: 4, policy: ACCEPT
-p IPv4 -j O-vnet0-ipv4
-p ARP -j O-vnet0-arp
-p 0x8035 -j O-vnet0-rarp
-j DROP</pre>
<p>Finally, here comes the actual implementation of the filters. This
example shows the 'clean-traffic' filter implementation.
I'm not going to explain what this is doing now. :-)
</p>
<pre>
Bridge chain: I-vnet0-ipv4, entries: 2, policy: ACCEPT
-s ! 52:54:0:56:44:32 -j DROP
-p IPv4 --ip-src ! 10.33.8.131 -j DROP
Bridge chain: O-vnet0-ipv4, entries: 1, policy: ACCEPT
-j ACCEPT
Bridge chain: I-vnet0-arp, entries: 6, policy: ACCEPT
-s ! 52:54:0:56:44:32 -j DROP
-p ARP --arp-mac-src ! 52:54:0:56:44:32 -j DROP
-p ARP --arp-ip-src ! 10.33.8.131 -j DROP
-p ARP --arp-op Request -j ACCEPT
-p ARP --arp-op Reply -j ACCEPT
-j DROP
Bridge chain: O-vnet0-arp, entries: 5, policy: ACCEPT
-p ARP --arp-op Reply --arp-mac-dst ! 52:54:0:56:44:32 -j DROP
-p ARP --arp-ip-dst ! 10.33.8.131 -j DROP
-p ARP --arp-op Request -j ACCEPT
-p ARP --arp-op Reply -j ACCEPT
-j DROP
Bridge chain: I-vnet0-rarp, entries: 2, policy: ACCEPT
-p 0x8035 -s 52:54:0:56:44:32 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 52:54:0:56:44:32 --arp-mac-dst 52:54:0:56:44:32 -j ACCEPT
-j DROP
Bridge chain: O-vnet0-rarp, entries: 2, policy: ACCEPT
-p 0x8035 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 52:54:0:56:44:32 --arp-mac-dst 52:54:0:56:44:32 -j ACCEPT
-j DROP</pre>
<p>NB, we would have liked to include the prefix 'libvirt-' in all
of our chain names, but unfortunately the kernel limits names
to a very short maximum length. So only the first two custom
chains can include that prefix. The others just include the
TAP device name + protocol name.
</p>
<p>If I define a new filter 'no-spamming' and then add this to the
'clean-traffic' filter, I can illustrate how iptables usage works:
</p>
<pre>
# cat &gt; /root/spamming.xml &lt;&lt;EOF
&lt;filter name='no-spamming' chain='root'&gt;
&lt;uuid&gt;d217f2d7-5a04-0e01-8b98-ec2743436b74&lt;/uuid&gt;
&lt;rule action='drop' direction='out' priority='500'&gt;
&lt;tcp dstportstart='25' dstportend='25'/&gt;
&lt;/rule&gt;
&lt;/filter&gt;
EOF
# virsh nwfilter-define /root/spamming.xml
# virsh nwfilter-edit clean-traffic</pre>
<p>...add <code>&lt;filterref filter='no-spamming'/&gt;</code></p>
<p>All active guests immediately have their iptables/ebtables rules
rebuilt.
</p>
<p>The network filter driver deals with iptables in a very similar
way. First it separates out its rules from those the admin may
have defined, by adding a couple of hooks into the INPUT/FORWARD
chains:
</p>
<pre>
Chain INPUT (policy ACCEPT 13M packets, 21G bytes)
target prot opt in out source destination
libvirt-host-in all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT 5532K packets, 3010M bytes)
target prot opt in out source destination
libvirt-in all -- * * 0.0.0.0/0 0.0.0.0/0
libvirt-out all -- * * 0.0.0.0/0 0.0.0.0/0
libvirt-in-post all -- * * 0.0.0.0/0 0.0.0.0/0</pre>
<p>These custom chains then do matching based on the TAP device
name, so they won't open holes in the admin defined matches for
the LAN/WAN (if any).
</p>
<pre>
Chain libvirt-host-in (1 references)
target prot opt in out source destination
HI-vnet0 all -- * * 0.0.0.0/0 0.0.0.0/0 [goto] PHYSDEV match --physdev-in vnet0
Chain libvirt-in (1 references)
target prot opt in out source destination
FI-vnet0 all -- * * 0.0.0.0/0 0.0.0.0/0 [goto] PHYSDEV match --physdev-in vnet0
Chain libvirt-in-post (1 references)
target prot opt in out source destination
ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 PHYSDEV match --physdev-in vnet0
Chain libvirt-out (1 references)
target prot opt in out source destination
FO-vnet0 all -- * * 0.0.0.0/0 0.0.0.0/0 [goto] PHYSDEV match --physdev-out vnet0</pre>
<p>Finally, we can see the interesting bit which is the actual
implementation of my filter to block port 25 access:
</p>
<pre>
Chain FI-vnet0 (1 references)
target prot opt in out source destination
DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25
Chain FO-vnet0 (1 references)
target prot opt in out source destination
DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp spt:25
Chain HI-vnet0 (1 references)
target prot opt in out source destination
DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25</pre>
<p>One thing in looking at this you may notice is that if there
are many guests all using the same filters, we will be duplicating
the iptables rules over and over for each guest. This is merely a
limitation of the current rules engine implementation. At the libvirt
object modelling level you can clearly see we've designed the model
so filter rules are defined in one place, and indirectly referenced
by guests. Thus it should be possible to change the implementation in
the future so we can share the actual iptables/ebtables rules for
each guest to create a more scalable system. The stuff in current libvirt
is more or less the very first working implementation we've had of this,
so there's not been much optimization work done yet.
</p>
<p>Also notice that at the XML level we don't expose the fact we
are using iptables or ebtables at all. The rule definition is done in
terms of network protocols. Thus if we ever find a need, we could
plug in an alternative implementation that calls out to a different
firewall implementation instead of ebtables/iptables (providing that
implementation was suitably expressive of course)
</p>
<p>Finally, in terms of problems we have in deployment. The biggest
problem is that if the admin does <code>service iptables restart</code>
all our work gets blown away. We've experimented with using lokkit
to record our custom rules in a persistent config file, but that
caused different problem. Admins who were not using lokkit for
their config found that all their own rules got blown away. So
we threw away our lokkit code. Instead we document that if you
run <code>service iptables restart</code>, you need to send SIGHUP to
libvirt to make it recreate its rules.
</p>
<p>More in depth documentation on this is <a href="formatnwfilter.html">here</a>.</p>
</body>
</html>

View File

@ -22,6 +22,7 @@ BIOS you will see</p>
&lt;vmx/&gt;
&lt;/features&gt;
&lt;model&gt;core2duo&lt;/model&gt;
&lt;vendor&gt;Intel&lt;/vendor&gt;
&lt;topology sockets="1" cores="2" threads="1"/&gt;
&lt;feature name="lahf_lm"/&gt;
&lt;feature name='xtpr'/&gt;

View File

@ -79,6 +79,8 @@
&lt;type&gt;hvm&lt;/type&gt;
&lt;loader&gt;/usr/lib/xen/boot/hvmloader&lt;/loader&gt;
&lt;boot dev='hd'/&gt;
&lt;boot dev='cdrom'/&gt;
&lt;bootmenu enable='yes'/&gt;
&lt;/os&gt;
...</pre>
@ -104,6 +106,12 @@
times to setup a priority list of boot devices to try in turn.
<span class="since">Since 0.1.3</span>
</dd>
<dt><code>bootmenu</code></dt>
<dd> Whether or not to enable an interactive boot menu prompt on guest
startup. The <code>enable</code> attribute can be either "yes" or "no".
If not specified, the hypervisor default is used. <span class="since">
Since 0.8.3</span>
</dd>
</dl>
<h4><a name="elementsOSBootloader">Host bootloader</a></h4>
@ -220,6 +228,7 @@
...
&lt;cpu match='exact'&gt;
&lt;model&gt;core2duo&lt;/model&gt;
&lt;vendor&gt;Intel&lt;/vendor&gt;
&lt;topology sockets='1' cores='2' threads='1'/&gt;
&lt;feature policy='disable' name='lahf_lm'/&gt;
&lt;/cpu&gt;
@ -267,6 +276,13 @@
definition can be found in <code>cpu_map.xml</code> file installed
in libvirt's data directory.</dd>
<dt><code>vendor</code></dt>
<dd><span class="since">Since 0.8.3</span> the content of the
<code>vendor</code> element specifies CPU vendor requested by the
guest. If this element is missing, the guest can be run on a CPU
matching given features regardless on its vendor. The list of
supported vendors can be found in <code>cpu_map.xml</code>.</dd>
<dt><code>topology</code></dt>
<dd>The <code>topology</code> element specifies requested topology of
virtual CPU provided to the guest. Three non-zero values have to be
@ -477,13 +493,16 @@
...
&lt;devices&gt;
&lt;disk type='file'&gt;
&lt;driver name="tap" type="aio" cache="default"&gt;
&lt;driver name="tap" type="aio" cache="default"/&gt;
&lt;source file='/var/lib/xen/images/fv0'/&gt;
&lt;target dev='hda' bus='ide'/&gt;
&lt;encryption type='...'&gt;
...
&lt;/encryption&gt;
&lt;shareable/&gt;
&lt;serial&gt;
...
&lt;/serial&gt;
&lt;/disk&gt;
&lt;/devices&gt;
...</pre>
@ -532,6 +551,11 @@
between domains (assuming the hypervisor and OS support this),
which means that caching should be deactivated for that device.
</dd>
<dt><code>serial</code></dt>
<dd>If present, this specify serial number of virtual hard drive.
For example, it may look as <code>&lt;serial&gt;WD-WMAP9A966149&lt;/serial&gt;</code>.
<span class="since">Since 0.7.1</span>
</dd>
</dl>
<h4><a name="elementsUSB">USB and PCI devices</a></h4>
@ -649,7 +673,7 @@
&lt;interface type='network'&gt;
&lt;source network='default'/&gt;
&lt;target dev='vnet7'/&gt;
&lt;mac address="11:22:33:44:55:66"/&gt;
&lt;mac address="00:11:22:33:44:55"/&gt;
&lt;/interface&gt;
&lt;/devices&gt;
...</pre>
@ -685,7 +709,7 @@
&lt;interface type='bridge'&gt;
&lt;source bridge='br0'/&gt;
&lt;target dev='vnet7'/&gt;
&lt;mac address="11:22:33:44:55:66"/&gt;
&lt;mac address="00:11:22:33:44:55"/&gt;
&lt;/interface&gt;
&lt;/devices&gt;
...</pre>
@ -707,7 +731,7 @@
&lt;interface type='user'/&gt;
...
&lt;interface type='user'&gt;
&lt;mac address="11:22:33:44:55:66"/&gt;
&lt;mac address="00:11:22:33:44:55"/&gt;
&lt;/interface&gt;
&lt;/devices&gt;
...</pre>
@ -741,8 +765,11 @@
<p>
Provides direct attachment of the virtual machine's NIC to the given
physial interface of the host. This setup requires the Linux macvtap
driver to be available. One of the modes 'vepa'
physial interface of the host.
<span class="since">Since 0.7.7 (QEMU and KVM only)</span><br>
This setup requires the Linux macvtap
driver to be available. <span class="since">(Since Linux 2.6.34.)</span>
One of the modes 'vepa'
( <a href="http://www.ieee802.org/1/files/public/docs2009/new-evb-congdon-vepa-modular-0709-v01.pdf">
'Virtual Ethernet Port Aggregator'</a>), 'bridge' or 'private'
can be chosen for the operation mode of the macvtap device, 'vepa'
@ -1105,8 +1132,16 @@ qemu-kvm -net nic,model=? /dev/null
<p>
This represents the primary console. This can be the paravirtualized
console with Xen guests, or duplicates the primary serial port for fully
virtualized guests without a paravirtualized console.
console with Xen guests, virtio console for QEMU/KVM, or duplicates
the primary serial port for fully virtualized guests without a
paravirtualized console.
</p>
<p>
A virtio console device is exposed in the
guest as /dev/hvc[0-7] (for more information, see
<a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>)
<span class="since">Since 0.8.3</span>
</p>
<pre>
@ -1116,6 +1151,12 @@ qemu-kvm -net nic,model=? /dev/null
&lt;source path='/dev/pts/4'/&gt;
&lt;target port='0'/&gt;
&lt;/console&gt;
&lt;!-- KVM virtio console --&gt;
&lt;console type='pty'&gt;
&lt;source path='/dev/pts/5'/&gt;
&lt;target type='virtio' port='0'/&gt;
&lt;/console&gt;
&lt;/devices&gt;
...</pre>
@ -1139,6 +1180,11 @@ qemu-kvm -net nic,model=? /dev/null
&lt;source mode='bind' path='/tmp/guestfwd'/&gt;
&lt;target type='guestfwd' address='10.0.2.1' port='4600'/&gt;
&lt;/channel&gt;
&lt;!-- KVM virtio channel --&gt;
&lt;channel type='pty'&gt;
&lt;target type='virtio' name='arbitrary.virtio.serial.port.name'/&gt;
&lt;/channel&gt;
&lt;/devices&gt;
...</pre>
@ -1155,6 +1201,13 @@ qemu-kvm -net nic,model=? /dev/null
forwarded to the channel device on the host. The <code>target</code>
element must have <code>address</code> and <code>port</code> attributes.
<span class="since">Since 0.7.3</span></dd>
<dt><code>virtio</code></dt>
<dd>Paravirtualized virtio channel. Channel is exposed in the guest under
/dev/vport*, and if the optional element<code>name</code> is specified,
/dev/virtio-ports/$name (for more info, please see
<a href="http://fedoraproject.org/wiki/Features/VirtioSerial">http://fedoraproject.org/wiki/Features/VirtioSerial</a>)
<span class="since">Since 0.7.7</span></dd>
</dl>
<h5><a name="elementsCharHostInterface">Host interface</a></h5>
@ -1487,6 +1540,53 @@ qemu-kvm -net nic,model=? /dev/null
</dd>
</dl>
<h4><a name="elementsMemBalloon">Memory balloon device</a></h4>
<p>
A virtual memory balloon device is added to all Xen and KVM/QEMU
guests. It will be seen as <code>memballoon</code> element.
It will be automatically added when appropriate, so there is no
need to explicitly add this element in the guest XML unless a
specific PCI slot needs to be assigned.
<span class="since">Since 0.8.3, Xen, QEMU and KVM only</span>
</p>
<p>
Example automatically added device with KVM
</p>
<pre>
...
&lt;devices&gt;
&lt;memballoon model='virtio'/&gt;
&lt;/devices&gt;
...</pre>
<p>
Example manually added device with static PCI slot 2 requested
</p>
<pre>
...
&lt;devices&gt;
&lt;watchdog model='virtio'/&gt;
&lt;address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/&gt;
&lt;/devices&gt;
&lt;/domain&gt;</pre>
<dl>
<dt><code>model</code></dt>
<dd>
<p>
The required <code>model</code> attribute specifies what type
of balloon device is provided. Valid values are specific to
the virtualization platform
</p>
<ul>
<li>'virtio' &mdash; default with QEMU/KVM</li>
<li>'xen' &mdash; default with Xen</li>
</ul>
</dd>
</dl>
<h2><a name="examples">Example configs</a></h2>
<p>

1527
docs/formatnwfilter.html.in Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
<html>
<body>
<h1>Snapshot XML format</h1>
<ul id="toc"></ul>
<h2><a name="SnapshotAttributes">Snapshot XML</a></h2>
<p>
Attributes of libvirt snapshots are stored as child elements of
the <code>domainsnapshot</code> element. At snapshot creation
time, only the <code>name</code> and <code>description</code>
elements are settable; the rest of the fields are informational
(and readonly) and will be filled in by libvirt when the
snapshot is created.
</p>
<p>
The top-level <code>domainsnapshot</code> element may contain
the following elements:
</p>
<dl>
<dt><code>name</code></dt>
<dd>The name for this snapshot. If the name is specified when
initially creating the snapshot, then the snapshot will have
that particular name. If the name is omitted when initially
creating the snapshot, then libvirt will make up a name for the snapshot.
</dd>
<dt><code>description</code></dt>
<dd>A human-readable description of the snapshot. If the
description is omitted when initially creating the snapshot,
then this field will be empty.
</dd>
<dt><code>creationTime</code></dt>
<dd>The time this snapshot was created. The time is specified
in seconds since the Epoch, UTC (i.e. Unix time). Readonly.
</dd>
<dt><code>state</code></dt>
<dd>The state of the domain at the time this snapshot was
taken. When the domain is reverted to this snapshot, the domain's state
will be set to whatever is in this field. Readonly.
</dd>
<dt><code>parent</code></dt>
<dd>The parent of this snapshot. This element contains exactly
one child element, name. This specifies the name of the parent
snapshot of this snapshot, and is used to represent trees of
snapshots. Readonly.
</dd>
<dt><code>domain</code></dt>
<dd>The domain that this snapshot was taken against. This
element contains exactly one child element, uuid. This
specifies the uuid of the domain that this snapshot was taken
against. Readonly.
</dd>
</dl>
<h2><a name="example">Example</a></h2>
<pre>
&lt;domainsnapshot&gt;
&lt;name&gt;os-updates&lt;/name&gt;
&lt;description&gt;Snapshot of OS install and updates&lt;/description&gt;
&lt;state&gt;running&lt;/state&gt;
&lt;creationTime&gt;1270477159&lt;/creationTime&gt;
&lt;parent&gt;
&lt;name&gt;bare-os-install&lt;/name&gt;
&lt;/parent&gt;
&lt;domain&gt;
&lt;uuid&gt;93a5c045-6457-2c09-e56c-927cdf34e178&lt;/uuid&gt;
&lt;/domain&gt;
&lt;/domainsnapshot&gt;</pre>
</body>
</html>

View File

@ -20,7 +20,7 @@
and stable layer to securely manage domains on a node. The node may be
distant and libvirt should provide all APIs needed to provision, create,
modify, monitor, control, migrate and stop the domains, within the limits
of the support of the hypervisor for those operations. Multiple mode may
of the support of the hypervisor for those operations. Multiple nodes may
be accessed with libvirt simultaneously but the APIs are limited to
single node operations.</p>
<p>This implies the following sub-goals:</p>

View File

@ -11,16 +11,15 @@
early and listen to feedback.</li>
<li><p>Post patches in unified diff format. A command similar to this
should work:</p>
should work:</p>
<pre>
diff -urp libvirt.orig/ libvirt.modified/ &gt; libvirt-myfeature.patch
</pre>
diff -urp libvirt.orig/ libvirt.modified/ &gt; libvirt-myfeature.patch</pre>
<p>
or:
</p>
<pre>
git diff > libvirt-myfeature.patch
</pre></li>
git diff > libvirt-myfeature.patch</pre>
</li>
<li>Split large changes into a series of smaller patches, self-contained
if possible, with an explanation of each patch and an explanation of how
the sequence of patches fits together.</li>
@ -29,20 +28,36 @@
<li><p>Run the automated tests on your code before submitting any changes.
In particular, configure with compile warnings set to -Werror:</p>
<pre>
./configure --enable-compile-warnings=error
</pre>
./configure --enable-compile-warnings=error</pre>
<p>
and run the tests:
</p>
<pre>
make check
make syntax-check
make -C tests valgrind
</pre>
make -C tests valgrind</pre>
<p>
The latter test checks for memory leaks.
</p>
<p>
If you encounter any failing tests, the VIR_TEST_DEBUG
environment variable may provide extra information to debug
the failures. Larger values of VIR_TEST_DEBUG may provide
larger amounts of information:
</p>
<pre>
VIR_TEST_DEBUG=1 make check (or)
VIR_TEST_DEBUG=2 make check</pre>
<p>
Also, individual tests can be run from inside the 'tests/'
directory, like:
</p>
<pre>
./qemuxml2xmltest</pre>
</li>
<li>Update tests and/or documentation, particularly if you are adding
a new feature or changing the output of a program.</li>
</ol>
@ -100,13 +115,148 @@
</pre>
<p>
Note that sometimes you'll have to postprocess that output further, by
Note that sometimes you'll have to post-process that output further, by
piping it through "expand -i", since some leading TABs can get through.
Usually they're in macro definitions or strings, and should be converted
anyhow.
</p>
<h2><a name="curly_braces">Curly braces</a></h2>
<p>
Omit the curly braces around an "if", "while", "for" etc. body only
when that body occupies a single line. In every other case we require
the braces. This ensures that it is trivially easy to identify a
single-*statement* loop: each has only one *line* in its body.
</p>
<p>
Omitting braces with a single-line body is fine:
</p>
<pre>
while (expr) // one-line body -> omitting curly braces is ok
single_line_stmt ();</pre>
<p>
However, the moment your loop/if/else body extends onto a second
line, for whatever reason (even if it's just an added comment), then
you should add braces. Otherwise, it would be too easy to insert a
statement just before that comment (without adding braces), thinking
it is already a multi-statement loop:
</p>
<pre>
while (true) // BAD! multi-line body with no braces
/* comment... */
single_line_stmt ();</pre>
<p>
Do this instead:
</p>
<pre>
while (true) { // Always put braces around a multi-line body.
/* comment... */
single_line_stmt ();
}</pre>
<p>
There is one exception: when the second body line is not at the same
indentation level as the first body line:
</p>
<pre>
if (expr)
die ("a diagnostic that would make this line"
" extend past the 80-column limit"));</pre>
<p>
It is safe to omit the braces in the code above, since the
further-indented second body line makes it obvious that this is still
a single-statement body.
</p>
<p>
To reiterate, don't do this:
</p>
<pre>
if (expr) // BAD: no braces around...
while (expr_2) { // ... a multi-line body
...
}</pre>
<p>
Do this, instead:
</p>
<pre>
if (expr) {
while (expr_2) {
...
}
}</pre>
<p>
However, there is one exception in the other direction, when even a
one-line block should have braces. That occurs when that one-line,
brace-less block is an "else" block, and the corresponding "then" block
*does* use braces. In that case, either put braces around the "else"
block, or negate the "if"-condition and swap the bodies, putting the
one-line block first and making the longer, multi-line block be the
"else" block.
</p>
<pre>
if (expr) {
...
...
}
else
x = y; // BAD: braceless "else" with braced "then"</pre>
<p>
This is preferred, especially when the multi-line body is more than a
few lines long, because it is easier to read and grasp the semantics of
an if-then-else block when the simpler block occurs first, rather than
after the more involved block:
</p>
<pre>
if (!expr)
x = y; // putting the smaller block first is more readable
else {
...
...
}</pre>
<p>
If you'd rather not negate the condition, then at least add braces:
</p>
<pre>
if (expr) {
...
...
} else {
x = y;
}</pre>
<h2><a href="types">Preprocessor</a></h2>
<p>
For variadic macros, stick with C99 syntax:
</p>
<pre>
#define vshPrint(_ctl, ...) fprintf(stdout, __VA_ARGS__)
</pre>
<p>Use parenthesis when checking if a macro is defined, and use
indentation to track nesting:
</p>
<pre>
#if defined(HAVE_POSIX_FALLOCATE) &amp;&amp; !defined(HAVE_FALLOCATE)
# define fallocate(a,ignored,b,c) posix_fallocate(a,b,c)
#endif
</pre>
<h2><a href="types">C types</a></h2>
<p>
@ -241,7 +391,7 @@
<h2><a name="string">String comparisons</a></h2>
<h2><a name="string_comparision">String comparisons</a></h2>
<p>
Do not use the strcmp, strncmp, etc functions directly. Instead use
@ -288,6 +438,46 @@
</ul>
<h2><a name="string_copying">String copying</a></h2>
<p>
Do not use the strncpy function. According to the man page, it
does <b>not</b> guarantee a NULL-terminated buffer, which makes
it extremely dangerous to use. Instead, use one of the
functionally equivalent functions:
</p>
<pre>virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)</pre>
<p>
The first three arguments have the same meaning as for strncpy;
namely the destination, source, and number of bytes to copy,
respectively. The last argument is the number of bytes
available in the destination string; if a copy of the source
string (including a \0) will not fit into the destination, no
bytes are copied and the routine returns NULL. Otherwise, n
bytes from the source are copied into the destination and a
trailing \0 is appended.
</p>
<pre>virStrcpy(char *dest, const char *src, size_t destbytes)</pre>
<p>
Use this variant if you know you want to copy the entire src
string into dest. Note that this is a macro, so arguments could
be evaluated more than once. This is equivalent to
virStrncpy(dest, src, strlen(src), destbytes)
</p>
<pre>virStrcpyStatic(char *dest, const char *src)</pre>
<p>
Use this variant if you know you want to copy the entire src
string into dest *and* you know that your destination string is
a static string (i.e. that sizeof(dest) returns something
meaningful). Note that this is a macro, so arguments could be
evaluated more than once. This is equivalent to
virStrncpy(dest, src, strlen(src), sizeof(dest)).
</p>
<h2><a name="strbuf">Variable length string buffer</a></h2>
<p>
@ -348,7 +538,7 @@
#include &lt;limits.h&gt;
#if HAVE_NUMACTL Some system includes aren't supported
#include &lt;numa.h&gt; everywhere so need these #if defences.
# include &lt;numa.h&gt; everywhere so need these #if guards.
#endif
#include "internal.h" Include this first, after system includes.
@ -389,40 +579,113 @@
of arguments.
</p>
<h2><a name="committers">Libvirt commiters guidelines</a></h2>
<h2><a name="goto">Use of goto</a></h2>
<p>
The AUTHORS files indicates the list of people with commit acces right
The use of goto is not forbidden, and goto is widely used
throughout libvirt. While the uncontrolled use of goto will
quickly lead to unmaintainable code, there is a place for it in
well structured code where its use increases readability and
maintainability. In general, if goto is used for error
recovery, it's likely to be ok, otherwise, be cautious or avoid
it all together.
</p>
<p>
The typical use of goto is to jump to cleanup code in the case
of a long list of actions, any of which may fail and cause the
entire operation to fail. In this case, a function will have a
single label at the end of the function. It's almost always ok
to use this style. In particular, if the cleanup code only
involves free'ing memory, then having multiple labels is
overkill. VIR_FREE() and every function named XXXFree() in
libvirt is required to handle NULL as its arg. Thus you can
safely call free on all the variables even if they were not yet
allocated (yes they have to have been initialized to NULL).
This is much simpler and clearer than having multiple labels.
</p>
<p>
There are a couple of signs that a particular use of goto is not
ok:
</p>
<ul>
<li>You're using multiple labels. If you find yourself using
multiple labels, you're strongly encouraged to rework your code
to eliminate all but one of them.</li>
<li>The goto jumps back up to a point above the current line of
code being executed. Please use some combination of looping
constructs to re-execute code instead; it's almost certainly
going to be more understandable by others. One well-known
exception to this rule is restarting an i/o operation following
EINTR.</li>
<li>The goto jumps down to an arbitrary place in the middle of a
function followed by further potentially failing calls. You
should almost certainly be using a conditional and a block
instead of a goto. Perhaps some of your function's logic would
be better pulled out into a helper function.</li>
</ul>
<p>
Although libvirt does not encourage the Linux kernel wind/unwind
style of multiple labels, there's a good general discussion of
the issue archived at
<a href=http://kerneltrap.org/node/553/2131>KernelTrap</a>
</p>
<p>
When using goto, please use one of these standard labels if it
makes sense:
</p>
<pre>
error: A path only taken upon return with an error code
cleanup: A path taken upon return with success code + optional error
no_memory: A path only taken upon return with an OOM error code
retry: If needing to jump upwards (eg retry on EINTR)</pre>
<h2><a name="committers">Libvirt committer guidelines</a></h2>
<p>
The AUTHORS files indicates the list of people with commit access right
who can actually merge the patches.
</p>
<p>
The general rule for commiting patches is to make sure it has been reviewed
properly in the mailing-list first, usually if a couple of persons gave an
The general rule for committing a patch is to make sure
it has been reviewed
properly in the mailing-list first, usually if a couple of people gave an
ACK or +1 to a patch and nobody raised an objection on the list it should
be good to go. If the patch touches a part of the code where you're not the
main maintainer or not have a very clear idea of how things work, it's better
to wait for a more authoritative feedback though. Before commiting please
also rebuild locally and run 'make check syntax-check' and make sure they
don't raise error. Try to look for warnings too for example configure with
be good to go. If the patch touches a part of the code where you're not
the main maintainer, or where you do not have a very clear idea of
how things work, it's better
to wait for a more authoritative feedback though. Before committing, please
also rebuild locally, run 'make check syntax-check', and make sure you
don't raise errors. Try to look for warnings too; for example,
configure with
</p>
<pre>
--enable-compile-warnings=error
</pre>
<p>
which adds -Werror to compile flags, so no warnings get missed
</p>
<p>
Exceptions to that 'review and approval on the list first' is fixing failures
An exception to 'review and approval on the list first' is fixing failures
to build:
</p>
<ul>
<li>if a recently commited patch breaks compilation on a platform
or for a given driver then it's fine to commit a minimal fix
<li>if a recently committed patch breaks compilation on a platform
or for a given driver, then it's fine to commit a minimal fix
directly without getting the review feedback first</li>
<li>if make check or make syntax-check breaks, if there is
an obvious fix, it's fine to commit immediately.
The patch should still be sent to the list (or tell what the fix was if
trivial) and 'make check syntax-check' should pass too before commiting
trivial), and 'make check syntax-check' should pass too, before committing
anything</li>
<li>
fixes for documentation and code comments can be managed

70
docs/hooks.html.in Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0"?>
<html>
<body>
<h1>Hooks for specific system management</h1>
<p>Libvirt includes synchronous hooks, starting from version 0.8.0, as a
way to tie in specific tailored system actions at a specific time.
If these scripts are present on the host where the hypervisor
is running, then they are called when the libvirt daemon is doingi
some significant action.</p>
<p>The scripts are expected to execute quickly, return a zero exit
status if all conditions are set for the daemon to continue the
action (non zero will be considered a failure which may
be ignored but in general will stop the ongoing operation).
The script also should not call back into libvirt as the daemon
is waiting for the script exit and deadlock is likely to occur.</p>
<p>The scripts are stored in the directory <code>/etc/libvirt/hooks/</code>
when using a standard installation path
(<code>$SYSCONF_DIR/libvirt/hooks/</code> in general).</p>
<p>Each script is given the following command line arguments:</p>
<ul>
<li> the first argument is the name of the object involved in the
operation, or '-' if there is none.
<li> the second argument is the name of the operation.
<li> the third argument is a suboperation indication like 'start' or
'end', or '-' if there is none.
<li> the last argument is an extra argument string or '-' if there
is none.
</ul>
<p>There are currently scripts for 3 domains of operation:
<ul>
<li><p><code>/etc/libvirt/hooks/daemon</code> script if
present is called at 3 points in time:</p>
<p>at daemon startup, typically started with the following
arguments:</p>
<pre>/etc/libvirt/hooks/daemon - start - start</pre>
<p>at daemon shutdown when it is about to exit, with the following
arguments:</p>
<pre>/etc/libvirt/hooks/daemon - shutdown - shutdown</pre>
<p>When the daemon is asked to reload its driver state when
receiving the SIGHUP signal, arguments are:</p>
<pre>/etc/libvirt/hooks/daemon - reload begin SIGHUP</pre>
</li>
<li><p><code>/etc/libvirt/hooks/qemu</code> script and <br/>
<code>/etc/libvirt/hooks/lxc</code> associate hooks for domain
operation on the respective QEmu/KVM and LXC drivers.</p>
<p> The domain related hooks also receive the full XML description
for the concerned domain on their stdin, which allows them to get
all the information from the domain, including UUID or storage
if that is needed for the script operation.</p>
<p> Currently only domain startup and domain end operations
involve the hook, the first one just before the domain gets
created.
For example if starting a QEmu domain named <code>test</code>
the following script will get called:</p>
<pre>/etc/libvirt/hooks/qemu test start begin -</pre>
<p> note that a non-zero return value from the script will abort the
domain startup operation, and if an error string is passed on
stderr by the hook script, it will be provided back to the user
at the libvirt API level.</p>
<p> For domain shutdown, the script will be called just after the
domain has finished execution, and the script will get:</p>
<pre>/etc/libvirt/hooks/qemu test stopped end -</pre>
<p> It is expected that other operations will be associated to hooks
but at the time of 0.8.0 only those 2 are associated to the
domains life cycle</p>
</li>
</ul>
<p></p>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@ -3,6 +3,7 @@
schemadir = $(pkgdatadir)/schemas
schema_DATA = \
domain.rng \
domainsnapshot.rng \
interface.rng \
network.rng \
secret.rng \
@ -10,6 +11,7 @@ schema_DATA = \
storagepool.rng \
storagevol.rng \
nodedev.rng \
capability.rng
capability.rng \
nwfilter.rng
EXTRA_DIST = $(schema_DATA)

View File

@ -18,6 +18,11 @@
<define name='hostcaps'>
<element name='host'>
<optional>
<element name='uuid'>
<ref name='UUID'/>
</element>
</optional>
<element name='cpu'>
<element name='arch'>
<ref name='archnames'/>
@ -74,6 +79,11 @@
<element name='model'>
<text/>
</element>
<optional>
<element name='vendor'>
<text/>
</element>
</optional>
<element name='topology'>
<attribute name='sockets'>
<ref name='positiveInteger'/>
@ -349,4 +359,15 @@
<param name='pattern'>[a-zA-Z0-9\-_]+</param>
</data>
</define>
<define name="UUID">
<choice>
<data type="string">
<param name="pattern">[a-fA-F0-9]{32}</param>
</data>
<data type="string">
<param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
</data>
</choice>
</define>
</grammar>

View File

@ -41,6 +41,9 @@
<optional>
<ref name="seclabel"/>
</optional>
<optional>
<ref name='qemucmdline'/>
</optional>
</interleave>
</element>
</define>
@ -115,8 +118,20 @@
</optional>
<choice>
<ref name="osbootkernel"/>
<ref name="osbootdev"/>
<oneOrMore>
<ref name="osbootdev"/>
</oneOrMore>
</choice>
<optional>
<element name="bootmenu">
<attribute name="enable">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</element>
</optional>
</interleave>
</element>
</define>
@ -295,6 +310,9 @@
</interleave>
</define>
<define name="clock">
<zeroOrMore>
<ref name="timer"/>
</zeroOrMore>
<optional>
<element name="clock">
<choice>
@ -329,7 +347,82 @@
</element>
</optional>
</define>
<!--
<define name="timer">
<element name="timer">
<attribute name="name">
<choice>
<value>platform</value>
<value>pit</value>
<value>rtc</value>
<value>hpet</value>
<value>tsc</value>
</choice>
</attribute>
<optional>
<attribute name="track">
<choice>
<value>boot</value>
<value>guest</value>
<value>wall</value>
</choice>
</attribute>
</optional>
<optional>
<attribute name="tickpolicy">
<choice>
<value>delay</value>
<value>catchup</value>
<value>merge</value>
<value>discard</value>
</choice>
</attribute>
</optional>
<optional>
<ref name="catchup"/>
</optional>
<optional>
<attribute name="frequency">
<ref name="unsignedInt"/>
</attribute>
</optional>
<optional>
<attribute name="mode">
<choice>
<value>auto</value>
<value>native</value>
<value>emulate</value>
<value>paravirt</value>
<value>smpsafe</value>
</choice>
</attribute>
</optional>
<optional>
<attribute name="present">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
<empty/>
</element>
</define>
<define name="catchup">
<element name="catchup">
<optional>
<attribute name="threshold">
<ref name="unsignedInt"/>
</attribute>
<attribute name="slew">
<ref name="unsignedInt"/>
</attribute>
<attribute name="limit">
<ref name="unsignedInt"/>
</attribute>
</optional>
</element>
</define>
<!--
A bootloader may be used to extract the OS information instead of
defining the OS parameter in the instance. It points just to the
binary or script used to extract the data from the first disk device.
@ -521,6 +614,9 @@
<ref name="driverCache"/>
</group>
</choice>
<optional>
<ref name="driverErrorPolicy"/>
</optional>
<empty/>
</element>
</define>
@ -543,6 +639,15 @@
</choice>
</attribute>
</define>
<define name="driverErrorPolicy">
<attribute name="error_policy">
<choice>
<value>stop</value>
<value>ignore</value>
<value>enospace</value>
</choice>
</attribute>
</define>
<define name="controller">
<element name="controller">
<choice>
@ -578,6 +683,17 @@
<attribute name="index">
<ref name="unsignedInt"/>
</attribute>
<optional>
<attribute name="model">
<choice>
<value>auto</value>
<value>buslogic</value>
<value>lsilogic</value>
<value>lsisas1068</value>
<value>vmpvscsi</value>
</choice>
</attribute>
</optional>
<optional>
<ref name="address"/>
</optional>
@ -727,6 +843,9 @@
</optional>
<empty/>
</element>
<optional>
<ref name="virtualPortProfile"/>
</optional>
<ref name="interface-options"/>
</interleave>
</group>
@ -805,8 +924,52 @@
<optional>
<ref name="address"/>
</optional>
<optional>
<element name="filterref">
<ref name="filterref-node-attributes"/>
</element>
</optional>
</interleave>
</define>
<define name="virtualPortProfile">
<choice>
<group>
<element name="virtualport">
<attribute name="type">
<value>802.1Qbg</value>
</attribute>
<element name="parameters">
<attribute name="managerid">
<ref name="uint8range"/>
</attribute>
<attribute name="typeid">
<ref name="uint24range"/>
</attribute>
<attribute name="typeidversion">
<ref name="uint8range"/>
</attribute>
<optional>
<attribute name="instanceid">
<ref name="UUID"/>
</attribute>
</optional>
</element>
</element>
</group>
<group>
<element name="virtualport">
<attribute name="type">
<value>802.1Qbh</value>
</attribute>
<element name="parameters">
<attribute name="profileid">
<ref name="virtualPortProfileID"/>
</attribute>
</element>
</element>
</group>
</choice>
</define>
<!--
An emulator description is just a path to the binary used for the task
-->
@ -1049,17 +1212,38 @@
<interleave>
<ref name="qemucdevSrcDef"/>
<optional>
<element name="target">
<optional>
<attribute name="port"/>
</optional>
</element>
<ref name="qemucdevTgtDef"/>
</optional>
<optional>
<ref name="address"/>
</optional>
</interleave>
</define>
<define name="qemucdevConsoleTgtType">
<attribute name="type">
<choice>
<value>xen</value>
<value>serial</value>
<value>uml</value>
<value>virtio</value>
</choice>
</attribute>
</define>
<define name="qemucdevTgtDef">
<element name="target">
<interleave>
<optional>
<ref name="qemucdevConsoleTgtType"/>
</optional>
<optional>
<attribute name="port"/>
</optional>
</interleave>
</element>
</define>
<define name="qemucdevSrcType">
<attribute name="type">
<choice>
@ -1119,7 +1303,9 @@
</optional>
<empty/>
</group>
<ref name="qemucdev"/>
<choice>
<ref name="qemucdev"/>
</choice>
</choice>
</element>
</define>
@ -1162,6 +1348,19 @@
</optional>
</element>
</define>
<define name="memballoon">
<element name="memballoon">
<attribute name="model">
<choice>
<value>virtio</value>
<value>xen</value>
</choice>
</attribute>
<optional>
<ref name="address"/>
</optional>
</element>
</define>
<define name="parallel">
<element name="parallel">
<ref name="qemucdev"/>
@ -1333,6 +1532,11 @@
<ref name="driveBus"/>
</attribute>
</optional>
<optional>
<attribute name="port">
<ref name="driveUnit"/>
</attribute>
</optional>
</define>
<!--
Devices attached to a domain.
@ -1363,6 +1567,9 @@
<optional>
<ref name="watchdog"/>
</optional>
<optional>
<ref name="memballoon"/>
</optional>
</interleave>
</element>
</define>
@ -1404,6 +1611,7 @@
<interleave>
<ref name="cpuModel"/>
<optional>
<ref name="cpuVendor"/>
<ref name="cpuTopology"/>
</optional>
<zeroOrMore>
@ -1431,6 +1639,12 @@
</element>
</define>
<define name="cpuVendor">
<element name="vendor">
<text/>
</element>
</define>
<define name="cpuFeature">
<element name="feature">
<attribute name="policy">
@ -1488,6 +1702,47 @@
</element>
</define>
<define name="filterref-node-attributes">
<attribute name="filter">
<data type="NCName"/>
</attribute>
<optional>
<element name="parameter">
<attribute name="name">
<ref name="filter-param-name"/>
</attribute>
<attribute name="value">
<ref name="filter-param-value"/>
</attribute>
</element>
</optional>
</define>
<!--
Optional hypervisor extensions in their own namespace:
QEmu
-->
<define name="qemucmdline">
<element name="commandline" ns="http://libvirt.org/schemas/domain/qemu/1.0">
<zeroOrMore>
<element name="arg">
<attribute name='value'/>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="env">
<attribute name='name'>
<ref name="filter-param-name"/>
</attribute>
<optional>
<attribute name='value'/>
</optional>
<empty/>
</element>
</zeroOrMore>
</element>
</define>
<!--
Type library
@ -1648,4 +1903,41 @@
<param name="pattern">[a-zA-Z0-9_\.\+\-/]+</param>
</data>
</define>
<define name="filter-param-name">
<data type="string">
<param name="pattern">[a-zA-Z0-9_]+</param>
</data>
</define>
<define name="filter-param-value">
<data type="string">
<param name="pattern">[a-zA-Z0-9_\.:]+</param>
</data>
</define>
<define name="uint8range">
<choice>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,2}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">255</param>
</data>
</choice>
</define>
<define name="uint24range">
<choice>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,6}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">16777215</param>
</data>
</choice>
</define>
<define name="virtualPortProfileID">
<data type="string">
<param name="maxLength">39</param>
</data>
</define>
</grammar>

View File

@ -0,0 +1,53 @@
<!-- A Relax NG schema for the libvirt domain snapshot properties XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<ref name='domainsnapshot'/>
</start>
<define name='domainsnapshot'>
<element name='domainsnapshot'>
<interleave>
<optional>
<element name='name'>
<text/>
</element>
</optional>
<optional>
<element name='description'>
<text/>
</element>
</optional>
<optional>
<element name='state'>
<text/>
</element>
</optional>
<optional>
<element name='creationTime'>
<text/>
</element>
</optional>
<optional>
<element name='active'>
<text/>
</element>
</optional>
<optional>
<element name='domain'>
<element name='uuid'>
<text/>
</element>
</element>
</optional>
<optional>
<element name='parent'>
<element name='name'>
<text/>
</element>
</element>
</optional>
</interleave>
</element>
</define>
</grammar>

829
docs/schemas/nwfilter.rng Normal file
View File

@ -0,0 +1,829 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="filter"/>
</start>
<define name="filter">
<element name="filter">
<ref name="filter-node-attributes"/>
<optional>
<element name="uuid">
<ref name="UUID"/>
</element>
</optional>
<zeroOrMore>
<choice>
<element name="filterref">
<ref name="filterref-node-attributes"/>
</element>
<element name="rule">
<ref name="rule-node-attributes"/>
<optional>
<zeroOrMore>
<element name="mac">
<ref name="match-attribute"/>
<ref name="common-l2-attributes"/>
<ref name="mac-attributes"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="arp">
<ref name="match-attribute"/>
<ref name="common-l2-attributes"/>
<ref name="arp-attributes"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="rarp">
<ref name="match-attribute"/>
<ref name="common-l2-attributes"/>
<ref name="arp-attributes"/> <!-- same as arp -->
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="ip">
<ref name="match-attribute"/>
<ref name="common-l2-attributes"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-port-attributes"/>
<ref name="ip-attributes"/>
<ref name="dscp-attribute"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="ipv6">
<ref name="match-attribute"/>
<ref name="common-l2-attributes"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-port-attributes"/>
<ref name="ip-attributes"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="tcp">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-port-attributes"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="udp">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-port-attributes"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="sctp">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-port-attributes"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="icmp">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
<ref name="icmp-attributes"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="igmp">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="all">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="esp">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="ah">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="udplite">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ip-attributes-p1"/>
<ref name="common-ip-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="tcp-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-port-attributes"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="udp-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-port-attributes"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="sctp-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-port-attributes"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="icmpv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
<ref name="icmp-attributes"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="all-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="esp-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="ah-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
<optional>
<zeroOrMore>
<element name="udplite-ipv6">
<ref name="match-attribute"/>
<ref name="srcmac-attribute"/>
<ref name="common-ipv6-attributes-p1"/>
<ref name="common-ipv6-attributes-p2"/>
</element>
</zeroOrMore>
</optional>
</element>
</choice>
</zeroOrMore>
</element>
</define>
<!-- ########### attributes of XML nodes ############ -->
<define name="filter-node-attributes">
<attribute name="name">
<data type="NCName"/>
</attribute>
<optional>
<attribute name="chain">
<choice>
<value>root</value>
<value>arp</value>
<value>rarp</value>
<value>ipv4</value>
<value>ipv6</value>
</choice>
</attribute>
</optional>
</define>
<define name="filterref-node-attributes">
<attribute name="filter">
<data type="NCName"/>
</attribute>
<optional>
<element name="parameter">
<attribute name="name">
<ref name="filter-param-name"/>
</attribute>
<attribute name="value">
<ref name="filter-param-value"/>
</attribute>
</element>
</optional>
</define>
<define name="rule-node-attributes">
<attribute name="action">
<ref name='action-type'/>
</attribute>
<attribute name="direction">
<ref name='direction-type'/>
</attribute>
<optional>
<attribute name="priority">
<ref name='priority-type'/>
</attribute>
</optional>
<optional>
<attribute name="statematch">
<ref name='statematch-type'/>
</attribute>
</optional>
</define>
<define name="match-attribute">
<interleave>
<optional>
<attribute name="match">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
</interleave>
</define>
<define name="srcmac-attribute">
<interleave>
<optional>
<attribute name="srcmacaddr">
<ref name="addrMAC"/>
</attribute>
</optional>
</interleave>
</define>
<define name="common-l2-attributes">
<interleave>
<ref name="srcmac-attribute"/>
<optional>
<attribute name="srcmacmask">
<ref name="addrMAC"/>
</attribute>
</optional>
<optional>
<attribute name="dstmacaddr">
<ref name="addrMAC"/>
</attribute>
</optional>
<optional>
<attribute name="dstmacmask">
<ref name="addrMAC"/>
</attribute>
</optional>
</interleave>
</define>
<define name="common-ip-attributes-p1">
<interleave>
<optional>
<attribute name="srcipaddr">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="srcipmask">
<ref name="addrMask"/>
</attribute>
</optional>
<optional>
<attribute name="dstipaddr">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="dstipmask">
<ref name="addrMask"/>
</attribute>
</optional>
</interleave>
</define>
<define name="common-ip-attributes-p2">
<interleave>
<optional>
<attribute name="srcipfrom">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="srcipto">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="dstipfrom">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="dstipto">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="dscp">
<ref name="sixbitrange"/>
</attribute>
</optional>
<optional>
<attribute name="connlimit-above">
<ref name="uint16range"/>
</attribute>
</optional>
</interleave>
</define>
<define name="common-ipv6-attributes-p1">
<interleave>
<optional>
<attribute name="srcipaddr">
<ref name="addrIPv6"/>
</attribute>
</optional>
<optional>
<attribute name="srcipmask">
<ref name="addrMaskv6"/>
</attribute>
</optional>
<optional>
<attribute name="dstipaddr">
<ref name="addrIPv6"/>
</attribute>
</optional>
<optional>
<attribute name="dstipmask">
<ref name="addrMaskv6"/>
</attribute>
</optional>
</interleave>
</define>
<define name="common-ipv6-attributes-p2">
<interleave>
<optional>
<attribute name="srcipfrom">
<ref name="addrIPv6"/>
</attribute>
</optional>
<optional>
<attribute name="srcipto">
<ref name="addrIPv6"/>
</attribute>
</optional>
<optional>
<attribute name="dstipfrom">
<ref name="addrIPv6"/>
</attribute>
</optional>
<optional>
<attribute name="dstipto">
<ref name="addrIPv6"/>
</attribute>
</optional>
<optional>
<attribute name="dscp">
<ref name="sixbitrange"/>
</attribute>
</optional>
</interleave>
</define>
<define name="common-port-attributes">
<interleave>
<optional>
<attribute name="srcportstart">
<ref name="uint16range"/>
</attribute>
</optional>
<optional>
<attribute name="srcportend">
<ref name="uint16range"/>
</attribute>
</optional>
<optional>
<attribute name="dstportstart">
<ref name="uint16range"/>
</attribute>
</optional>
<optional>
<attribute name="dstportend">
<ref name="uint16range"/>
</attribute>
</optional>
</interleave>
</define>
<define name="icmp-attributes">
<interleave>
<optional>
<attribute name="type">
<ref name="uint8range"/>
</attribute>
</optional>
<optional>
<attribute name="code">
<ref name="uint8range"/>
</attribute>
</optional>
</interleave>
</define>
<define name="mac-attributes">
<interleave>
<optional>
<attribute name="protocolid">
<ref name="mac-protocolid"/>
</attribute>
</optional>
</interleave>
</define>
<define name="arp-attributes">
<interleave>
<optional>
<attribute name="arpsrcmacaddr">
<ref name="addrMAC"/>
</attribute>
</optional>
<optional>
<attribute name="arpsrcipaddr">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="arpdstmacaddr">
<ref name="addrMAC"/>
</attribute>
</optional>
<optional>
<attribute name="arpdstipaddr">
<ref name="addrIP"/>
</attribute>
</optional>
<optional>
<attribute name="hwtype">
<ref name="uint16range"/>
</attribute>
</optional>
<optional>
<attribute name="opcode">
<ref name="arpOpcodeType"/>
</attribute>
</optional>
<optional>
<attribute name="protocoltype">
<ref name="uint16range"/>
</attribute>
</optional>
</interleave>
</define>
<define name="ip-attributes">
<optional>
<attribute name="protocol">
<ref name="ipProtocolType"/>
</attribute>
</optional>
</define>
<define name="dscp-attribute">
<optional>
<attribute name="dscp">
<ref name="sixbitrange"/>
</attribute>
</optional>
</define>
<!-- ################ type library ################ -->
<define name="UUID">
<choice>
<data type="string">
<param name="pattern">[a-fA-F0-9]{32}</param>
</data>
<data type="string">
<param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
</data>
</choice>
</define>
<define name="addrMAC">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">([a-fA-F0-9]{1,2}:){5}[a-fA-F0-9]{1,2}</param>
</data>
</choice>
</define>
<define name="addrIP">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]</param>
</data>
</choice>
</define>
<define name="addrIPv6">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">([a-fA-F0-9]{0,4}:){2,7}([a-fA-F0-9]*)(([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9])?</param>
</data>
</choice>
</define>
<define name="addrMask">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">32</param>
</data>
<data type="string">
<param name="pattern">([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]</param>
</data>
</choice>
</define>
<define name="addrMaskv6">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">128</param>
</data>
<data type="string">
<param name="pattern">([a-fA-F0-9]{0,4}:){2,7}([a-fA-F0-9]*)</param>
</data>
</choice>
</define>
<define name="sixbitrange">
<choice>
<data type="string">
<param name="pattern">0x([0-3][0-9a-fA-F]|[0-9a-fA-F])</param>
</data>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">63</param>
</data>
</choice>
</define>
<define name="mac-protocolid">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">0x([6-9a-fA-F][0-9a-fA-F]{2}|[0-9a-fA-F]{4})</param>
</data>
<data type="int">
<param name="minInclusive">1536</param>
<param name="maxInclusive">65535</param>
</data>
<choice>
<value>arp</value>
<value>rarp</value>
<value>ipv4</value>
<value>ipv6</value>
</choice>
</choice>
</define>
<define name="uint8range">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,2}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">255</param>
</data>
</choice>
</define>
<define name="uint16range">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,4}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">65535</param>
</data>
</choice>
</define>
<define name="arpOpcodeType">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">65535</param>
</data>
<data type="string">
<param name="pattern">([Rr]eply|[Rr]equest|[Rr]equest_[Rr]everse|[Rr]eply_[Rr]everse|DRARP_[Rr]equest|DRARP_[Rr]eply|DRARP_[Ee]rror|InARP_[Rr]equest|ARP_NAK)</param>
</data>
</choice>
</define>
<define name="ipProtocolType">
<choice>
<!-- variable -->
<data type="string">
<param name="pattern">$[a-zA-Z0-9_]+</param>
</data>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{1,2}</param>
</data>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">255</param>
</data>
<choice>
<value>tcp</value>
<value>udp</value>
<value>udplite</value>
<value>esp</value>
<value>ah</value>
<value>icmp</value>
<value>igmp</value>
<value>sctp</value>
<value>icmpv6</value>
</choice>
</choice>
</define>
<define name="filter-param-name">
<data type="string">
<param name="pattern">[a-zA-Z0-9_]+</param>
</data>
</define>
<define name="filter-param-value">
<data type="string">
<param name="pattern">[a-zA-Z0-9_\.:]+</param>
</data>
</define>
<define name='action-type'>
<choice>
<value>drop</value>
<value>accept</value>
</choice>
</define>
<define name='direction-type'>
<choice>
<value>in</value>
<value>out</value>
<value>inout</value>
</choice>
</define>
<define name='priority-type'>
<data type="int">
<param name="minInclusive">0</param>
<param name="maxInclusive">1000</param>
</data>
</define>
<define name='statematch-type'>
<data type="string">
<param name="pattern">([Ff][Aa][Ll][Ss][Ee]|0)</param>
</data>
</define>
</grammar>

View File

@ -188,12 +188,14 @@
</element>
</define>
<define name='initiatorinfoiqn'>
<element name='iqn'>
<attribute name='name'>
<text/>
</attribute>
<empty/>
<define name='initiatorinfo'>
<element name='initiator'>
<element name='iqn'>
<attribute name='name'>
<text/>
</attribute>
<empty/>
</element>
</element>
</define>
@ -372,7 +374,7 @@
<ref name='sourceinfohost'/>
<ref name='sourceinfodev'/>
<optional>
<ref name='initiatorinfoiqn'/>
<ref name='initiatorinfo'/>
</optional>
<optional>
<ref name='sourceinfoauth'/>

View File

@ -258,7 +258,7 @@
</li><li>
<a title="User contributed content" class="inactive" href="http://wiki.libvirt.org">Wiki</a>
</li><li>
<a title="Frequently asked questions" class="inactive" href="FAQ.html">FAQ</a>
<a title="Frequently asked questions" class="inactive" href="http://wiki.libvirt.org/page/FAQ">FAQ</a>
</li><li>
<a title="How and where to report bugs and request features" class="inactive" href="bugs.html">Bug reports</a>
</li><li>

View File

@ -50,6 +50,14 @@
<a href="logging.html">Logging</a>
<span>The library and the daemon logging support</span>
</li>
<li>
<a href="firewall.html">Firewall</a>
<span>Firewall and network filter configuration</span>
</li>
<li>
<a href="hooks.html">Hooks</a>
<span>Hooks for system specific management</span>
</li>
</ul>
</li>
<li>
@ -93,6 +101,12 @@
<li>
<a href="formatnetwork.html">Networks</a>
<span>The virtual network XML format</span>
<ul>
<li>
<a href="formatnwfilter.html">Network Filtering</a>
<span>Network filter XML format</span>
</li>
</ul>
</li>
<li>
<a href="formatstorage.html">Storage</a>
@ -114,6 +128,10 @@
<a href="formatsecret.html">Secrets</a>
<span>The secret XML format</span>
</li>
<li>
<a href="formatsnapshot.html">Snapshots</a>
<span>The snapshot XML format</span>
</li>
</ul>
</li>
<li>
@ -247,7 +265,7 @@
<span>User contributed content</span>
</li>
<li>
<a href="FAQ.html">FAQ</a>
<a href="http://wiki.libvirt.org/page/FAQ">FAQ</a>
<span>Frequently asked questions</span>
</li>
<li>

View File

@ -1,4 +1,4 @@
# Last Modified: Fri Nov 6 16:41:59 2009
# Last Modified: Mon Apr 5 15:11:27 2010
#include <abstractions/base>
#include <abstractions/consoles>
@ -16,13 +16,11 @@
/dev/kvm rw,
/dev/ptmx rw,
/dev/kqemu rw,
@{PROC}/*/status r,
# WARNING: uncommenting these gives the guest direct access to host hardware.
# This is required for USB pass through but is a security risk. You have been
# warned.
#/sys/bus/usb/devices/ r,
#/sys/devices/*/*/usb[0-9]*/** r,
#/dev/bus/usb/*/[0-9]* rw,
# For hostdev access. The actual devices will be added dynamically
/sys/bus/usb/devices/ r,
/sys/devices/*/*/usb[0-9]*/** r,
# WARNING: this gives the guest direct access to host hardware and specific
# portions of shared memory. This is required for sound using ALSA with kvm,
@ -38,6 +36,9 @@
# unless you absolutely need it.
deny capability kill,
# Uncomment the following if you need access to /dev/fb*
#/dev/fb* rw,
/etc/pulse/client.conf r,
@{HOME}/.pulse-cookie rwk,
owner /root/.pulse-cookie rwk,
@ -56,6 +57,10 @@
/usr/share/openhackware/** r,
/usr/share/proll/** r,
/usr/share/vgabios/** r,
/usr/share/seabios/** r,
# access PKI infrastructure
/etc/pki/libvirt-vnc/** r,
# the various binaries
/usr/bin/kvm rmix,
@ -99,11 +104,3 @@
/bin/dash rmix,
/bin/dd rmix,
/bin/cat rmix,
# The svirt driver does not relabel the state file
# (https://bugzilla.redhat.com/show_bug.cgi?id=529363) resulting in denied
# messages. Uncommenting these lines can work around this somewhat by
# allowing users to save state files in the specified directory. We use
# 'owner' to make sure we don't overwrite the user's files.
#owner @{HOME}/libvirt-state-files/ r,
#owner @{HOME}/libvirt-state-files/** rw,

View File

@ -1,4 +1,4 @@
# Last Modified: Mon Jul 06 17:22:37 2009
# Last Modified: Mon Apr 5 15:10:27 2010
#include <tunables/global>
/usr/lib/libvirt/virt-aa-helper {
@ -14,9 +14,25 @@
deny @{PROC}/[0-9]*/mounts r,
@{PROC}/filesystems r,
# for hostdev
/sys/devices/ r,
/sys/devices/** r,
/usr/lib/libvirt/virt-aa-helper mr,
/sbin/apparmor_parser Ux,
/etc/apparmor.d/libvirt/* r,
/etc/apparmor.d/libvirt/libvirt-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]* rw,
# for backingstore -- allow access to non-hidden files in @{HOME} as well
# as storage pools
audit deny @{HOME}/.* mrwkl,
audit deny @{HOME}/.*/ rw,
audit deny @{HOME}/.*/** mrwkl,
audit deny @{HOME}/bin/ rw,
audit deny @{HOME}/bin/** mrwkl,
@{HOME}/ r,
@{HOME}/** r,
/var/lib/libvirt/images/ r,
/var/lib/libvirt/images/** r,
}

View File

@ -1,4 +1,4 @@
# Last Modified: Wed Sep 23 23:23:58 2009
# Last Modified: Mon Apr 5 15:03:58 2010
#include <tunables/global>
@{LIBVIRT}="libvirt"
@ -21,6 +21,7 @@
capability chown,
capability setpcap,
capability mknod,
capability fsetid,
network inet stream,
network inet dgram,
@ -35,7 +36,6 @@
/sbin/* Ux,
/usr/bin/* Ux,
/usr/sbin/* Ux,
/usr/lib/libvirt/* Ux,
# force the use of virt-aa-helper
audit deny /sbin/apparmor_parser rwxl,
@ -44,7 +44,7 @@
audit deny /sys/kernel/security/apparmor/matching rwxl,
audit deny /sys/kernel/security/apparmor/.* rwxl,
/sys/kernel/security/apparmor/profiles r,
/usr/lib/libvirt/virt-aa-helper Pxr,
/usr/lib/libvirt/* PUxr,
# allow changing to our UUID-based named profiles
change_profile -> @{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*,

View File

@ -6,19 +6,19 @@
#include <signal.h>
#if HAVE_SYS_POLL_H
#include <sys/types.h>
#include <sys/poll.h>
#include <libvirt/libvirt.h>
# include <sys/types.h>
# include <sys/poll.h>
# include <libvirt/libvirt.h>
#define DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
# define DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
__func__, __LINE__)
#define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
# define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
__func__, __LINE__, __VA_ARGS__)
#define STREQ(a,b) (strcmp(a,b) == 0)
# define STREQ(a,b) (strcmp(a,b) == 0)
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__((__unused__))
#endif
# ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
# endif
/* handle globals */
int h_fd = 0;
@ -28,7 +28,7 @@ virFreeCallback h_ff = NULL;
void *h_opaque = NULL;
/* timeout globals */
#define TIMEOUT_MS 1000
# define TIMEOUT_MS 1000
int t_active = 0;
int t_timeout = -1;
virEventTimeoutCallback t_cb = NULL;
@ -38,10 +38,6 @@ void *t_opaque = NULL;
/* Prototypes */
const char *eventToString(int event);
int myDomainEventCallback1 (virConnectPtr conn, virDomainPtr dom,
int event, int detail, void *opaque);
int myDomainEventCallback2 (virConnectPtr conn, virDomainPtr dom,
int event, int detail, void *opaque);
int myEventAddHandleFunc (int fd, int event,
virEventHandleCallback cb,
void *opaque,
@ -152,11 +148,11 @@ static const char *eventDetailToString(int event, int detail) {
return ret;
}
int myDomainEventCallback1 (virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int event,
int detail,
void *opaque ATTRIBUTE_UNUSED)
static int myDomainEventCallback1(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int event,
int detail,
void *opaque ATTRIBUTE_UNUSED)
{
printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), eventToString(event),
@ -164,11 +160,11 @@ int myDomainEventCallback1 (virConnectPtr conn ATTRIBUTE_UNUSED,
return 0;
}
int myDomainEventCallback2 (virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int event,
int detail,
void *opaque ATTRIBUTE_UNUSED)
static int myDomainEventCallback2(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int event,
int detail,
void *opaque ATTRIBUTE_UNUSED)
{
printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), eventToString(event),
@ -176,6 +172,92 @@ int myDomainEventCallback2 (virConnectPtr conn ATTRIBUTE_UNUSED,
return 0;
}
static int myDomainEventRebootCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
void *opaque ATTRIBUTE_UNUSED)
{
printf("%s EVENT: Domain %s(%d) rebooted\n", __func__, virDomainGetName(dom),
virDomainGetID(dom));
return 0;
}
static int myDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
long long offset,
void *opaque ATTRIBUTE_UNUSED)
{
printf("%s EVENT: Domain %s(%d) rtc change %lld\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), offset);
return 0;
}
static int myDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int action,
void *opaque ATTRIBUTE_UNUSED)
{
printf("%s EVENT: Domain %s(%d) watchdog action=%d\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), action);
return 0;
}
static int myDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque ATTRIBUTE_UNUSED)
{
printf("%s EVENT: Domain %s(%d) io error path=%s alias=%s action=%d\n", __func__, virDomainGetName(dom),
virDomainGetID(dom), srcPath, devAlias, action);
return 0;
}
static int myDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
int phase,
virDomainEventGraphicsAddressPtr local,
virDomainEventGraphicsAddressPtr remote,
const char *authScheme,
virDomainEventGraphicsSubjectPtr subject,
void *opaque ATTRIBUTE_UNUSED)
{
int i;
printf("%s EVENT: Domain %s(%d) graphics ", __func__, virDomainGetName(dom),
virDomainGetID(dom));
switch (phase) {
case VIR_DOMAIN_EVENT_GRAPHICS_CONNECT:
printf("connected ");
break;
case VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE:
printf("initialized ");
break;
case VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT:
printf("disconnected ");
break;
}
printf("local: family=%d node=%s service=%s ",
local->family, local->node, local->service);
printf("remote: family=%d node=%s service=%s ",
remote->family, remote->node, remote->service);
printf("auth: %s ", authScheme);
for (i = 0 ; i < subject->nidentity ; i++) {
printf(" identity: %s=%s",
subject->identities[i].type,
subject->identities[i].name);
}
printf("\n");
return 0;
}
static void myFreeFunc(void *opaque)
{
char *str = opaque;
@ -293,9 +375,16 @@ int main(int argc, char **argv)
int sts;
int callback1ret = -1;
int callback2ret = -1;
struct sigaction action_stop = {
.sa_handler = stop
};
int callback3ret = -1;
int callback4ret = -1;
int callback5ret = -1;
int callback6ret = -1;
int callback7ret = -1;
struct sigaction action_stop;
memset(&action_stop, 0, sizeof action_stop);
action_stop.sa_handler = stop;
if(argc > 1 && STREQ(argv[1],"--help")) {
usage(argv[0]);
@ -310,7 +399,7 @@ int main(int argc, char **argv)
myEventRemoveTimeoutFunc);
virConnectPtr dconn = NULL;
dconn = virConnectOpen (argv[1] ? argv[1] : NULL);
dconn = virConnectOpenReadOnly (argv[1] ? argv[1] : NULL);
if (!dconn) {
printf("error opening\n");
return -1;
@ -324,10 +413,44 @@ int main(int argc, char **argv)
/* Add 2 callbacks to prove this works with more than just one */
callback1ret = virConnectDomainEventRegister(dconn, myDomainEventCallback1,
strdup("callback 1"), myFreeFunc);
callback2ret = virConnectDomainEventRegister(dconn, myDomainEventCallback2,
strdup("callback 2"), myFreeFunc);
callback2ret = virConnectDomainEventRegisterAny(dconn,
NULL,
VIR_DOMAIN_EVENT_ID_LIFECYCLE,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventCallback2),
strdup("callback 2"), myFreeFunc);
callback3ret = virConnectDomainEventRegisterAny(dconn,
NULL,
VIR_DOMAIN_EVENT_ID_REBOOT,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventRebootCallback),
strdup("callback reboot"), myFreeFunc);
callback4ret = virConnectDomainEventRegisterAny(dconn,
NULL,
VIR_DOMAIN_EVENT_ID_RTC_CHANGE,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventRTCChangeCallback),
strdup("callback rtcchange"), myFreeFunc);
callback5ret = virConnectDomainEventRegisterAny(dconn,
NULL,
VIR_DOMAIN_EVENT_ID_WATCHDOG,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventWatchdogCallback),
strdup("callback watchdog"), myFreeFunc);
callback6ret = virConnectDomainEventRegisterAny(dconn,
NULL,
VIR_DOMAIN_EVENT_ID_IO_ERROR,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventIOErrorCallback),
strdup("callback io error"), myFreeFunc);
callback7ret = virConnectDomainEventRegisterAny(dconn,
NULL,
VIR_DOMAIN_EVENT_ID_GRAPHICS,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventGraphicsCallback),
strdup("callback graphics"), myFreeFunc);
if ((callback1ret == 0) && (callback2ret == 0) ) {
if ((callback1ret != -1) &&
(callback2ret != -1) &&
(callback3ret != -1) &&
(callback4ret != -1) &&
(callback5ret != -1) &&
(callback6ret != -1) &&
(callback7ret != -1)) {
while(run) {
struct pollfd pfd = { .fd = h_fd,
.events = h_event,
@ -364,8 +487,12 @@ int main(int argc, char **argv)
DEBUG0("Deregistering event handlers");
virConnectDomainEventDeregister(dconn, myDomainEventCallback1);
virConnectDomainEventDeregister(dconn, myDomainEventCallback2);
virConnectDomainEventDeregisterAny(dconn, callback2ret);
virConnectDomainEventDeregisterAny(dconn, callback3ret);
virConnectDomainEventDeregisterAny(dconn, callback4ret);
virConnectDomainEventDeregisterAny(dconn, callback5ret);
virConnectDomainEventDeregisterAny(dconn, callback6ret);
virConnectDomainEventDeregisterAny(dconn, callback7ret);
}
DEBUG0("Closing connection");

View File

@ -172,10 +172,10 @@ class virEventLoopPure:
if now >= next:
sleep = 0
else:
sleep = next - now
sleep = (next - now) / 1000.0
self.debug("Poll with a sleep of %d" % sleep)
events = self.poll.poll(sleep / 1000.0)
events = self.poll.poll(sleep)
# Dispatch any file handle events that occurred
for (fd, revents) in events:
@ -396,21 +396,49 @@ def virEventLoopPureStart():
# Everything that now follows is a simple demo of domain lifecycle events
##########################################################################
def eventToString(event):
eventStrings = ( "Added",
"Removed",
eventStrings = ( "Defined",
"Undefined",
"Started",
"Suspended",
"Resumed",
"Stopped",
"Saved",
"Restored" );
"Stopped" );
return eventStrings[event];
def detailToString(event, detail):
eventStrings = (
( "Added", "Updated" ),
( "Removed" ),
( "Booted", "Migrated", "Restored", "Snapshot" ),
( "Paused", "Migrated", "IOError", "Watchdog" ),
( "Unpaused", "Migrated"),
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot")
)
return eventStrings[event][detail]
def myDomainEventCallback1 (conn, dom, event, detail, opaque):
print "myDomainEventCallback1 EVENT: Domain %s(%s) %s %d" % (dom.name(), dom.ID(), eventToString(event), detail)
print "myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
eventToString(event),
detailToString(event, detail))
def myDomainEventCallback2 (conn, dom, event, detail, opaque):
print "myDomainEventCallback2 EVENT: Domain %s(%s) %s %d" % (dom.name(), dom.ID(), eventToString(event), detail)
print "myDomainEventCallback2 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
eventToString(event),
detailToString(event, detail))
def myDomainEventRebootCallback(conn, dom, opaque):
print "myDomainEventRebootCallback: Domain %s(%s)" % (dom.name(), dom.ID())
def myDomainEventRTCChangeCallback(conn, dom, utcoffset, opaque):
print "myDomainEventRTCChangeCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), utcoffset)
def myDomainEventWatchdogCallback(conn, dom, action, opaque):
print "myDomainEventWatchdogCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), action)
def myDomainEventIOErrorCallback(conn, dom, srcpath, devalias, action, opaque):
print "myDomainEventIOErrorCallback: Domain %s(%s) %s %s %d" % (dom.name(), dom.ID(), srcpath, devalias, action)
def myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme, subject, opaque):
print "myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(), dom.ID(), phase, authScheme)
def usage():
print "usage: "+os.path.basename(sys.argv[0])+" [uri]"
@ -451,7 +479,12 @@ def main():
#Add 2 callbacks to prove this works with more than just one
vc.domainEventRegister(myDomainEventCallback1,None)
vc.domainEventRegister(myDomainEventCallback2,None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, myDomainEventCallback2, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_REBOOT, myDomainEventRebootCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_RTC_CHANGE, myDomainEventRTCChangeCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR, myDomainEventIOErrorCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_WATCHDOG, myDomainEventWatchdogCallback, None)
vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_GRAPHICS, myDomainEventGraphicsCallback, None)
# The rest of your app would go here normally, but for sake
# of demo we'll just go to sleep. The other option is to

View File

@ -1,2 +1,5 @@
Makefile
Makefile.in
openauth
.deps
.libs

View File

@ -0,0 +1,5 @@
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
noinst_PROGRAMS = openauth
openauth_CFLAGS = $(WARN_CFLAGS)
openauth_SOURCES = openauth.c
openauth_LDADD = @top_builddir@/src/libvirt.la

View File

@ -0,0 +1,287 @@
/* This is a copy of the hellolibvirt example demonstaring how to use
* virConnectOpenAuth with a custom auth callback */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
static void
showError(virConnectPtr conn)
{
int ret;
virErrorPtr err;
err = malloc(sizeof(*err));
if (err == NULL) {
printf("Could not allocate memory for error data\n");
goto out;
}
ret = virConnCopyLastError(conn, err);
switch (ret) {
case 0:
printf("No error found\n");
break;
case -1:
printf("Parameter error when attempting to get last error\n");
break;
default:
printf("libvirt reported: \"%s\"\n", err->message);
break;
}
virResetError(err);
free(err);
out:
return;
}
static int
showHypervisorInfo(virConnectPtr conn)
{
int ret = 0;
unsigned long hvVer, major, minor, release;
const char *hvType;
/* virConnectGetType returns a pointer to a static string, so no
* allocation or freeing is necessary; it is possible for the call
* to fail if, for example, there is no connection to a
* hypervisor, so check what it returns. */
hvType = virConnectGetType(conn);
if (hvType == NULL) {
ret = 1;
printf("Failed to get hypervisor type\n");
showError(conn);
goto out;
}
if (virConnectGetVersion(conn, &hvVer) != 0) {
ret = 1;
printf("Failed to get hypervisor version\n");
showError(conn);
goto out;
}
major = hvVer / 1000000;
hvVer %= 1000000;
minor = hvVer / 1000;
release = hvVer % 1000;
printf("Hypervisor: \"%s\" version: %lu.%lu.%lu\n",
hvType,
major,
minor,
release);
out:
return ret;
}
static int
showDomains(virConnectPtr conn)
{
int ret = 0, i, numNames, numInactiveDomains, numActiveDomains;
char **nameList = NULL;
numActiveDomains = virConnectNumOfDomains(conn);
if (numActiveDomains == -1) {
ret = 1;
printf("Failed to get number of active domains\n");
showError(conn);
goto out;
}
numInactiveDomains = virConnectNumOfDefinedDomains(conn);
if (numInactiveDomains == -1) {
ret = 1;
printf("Failed to get number of inactive domains\n");
showError(conn);
goto out;
}
printf("There are %d active and %d inactive domains\n",
numActiveDomains, numInactiveDomains);
nameList = malloc(sizeof(*nameList) * numInactiveDomains);
if (nameList == NULL) {
ret = 1;
printf("Could not allocate memory for list of inactive domains\n");
goto out;
}
numNames = virConnectListDefinedDomains(conn,
nameList,
numInactiveDomains);
if (numNames == -1) {
ret = 1;
printf("Could not get list of defined domains from hypervisor\n");
showError(conn);
goto out;
}
if (numNames > 0) {
printf("Inactive domains:\n");
}
for (i = 0 ; i < numNames ; i++) {
printf(" %s\n", *(nameList + i));
/* The API documentation doesn't say so, but the names
* returned by virConnectListDefinedDomains are strdup'd and
* must be freed here. */
free(*(nameList + i));
}
out:
free(nameList);
return ret;
}
/* Struct to pass the credentials to the auth callback via the cbdata pointer */
struct _AuthData {
char *username;
char *password;
};
typedef struct _AuthData AuthData;
/* This function will be called by libvirt to obtain credentials in order to
* authenticate to the hypervisor */
static int
authCallback(virConnectCredentialPtr cred, unsigned int ncred, void *cbdata)
{
int i;
AuthData *authData = cbdata;
/* libvirt might request multiple credentials in a single call.
* This example supports VIR_CRED_AUTHNAME and VIR_CRED_PASSPHRASE
* credentials only, but there are several other types.
*
* A request may also contain a prompt message that can be displayed
* to the user and a challenge. The challenge is specific to the
* credential type and hypervisor type.
*
* For example the ESX driver passes the hostname of the ESX or vCenter
* server as challenge. This allows a auth callback to return the
* proper credentials. */
for (i = 0; i < ncred ; ++i) {
switch (cred[i].type) {
case VIR_CRED_AUTHNAME:
cred[i].result = strdup(authData->username);
if (cred[i].result == NULL) {
return -1;
}
cred[i].resultlen = strlen(cred[i].result);
break;
case VIR_CRED_PASSPHRASE:
cred[i].result = strdup(authData->password);
if (cred[i].result == NULL) {
return -1;
}
cred[i].resultlen = strlen(cred[i].result);
break;
default:
return -1;
}
}
return 0;
}
/* The list of credential types supported by our auth callback */
static int credTypes[] = {
VIR_CRED_AUTHNAME,
VIR_CRED_PASSPHRASE
};
/* The auth struct that will be passed to virConnectOpenAuth */
static virConnectAuth auth = {
credTypes,
sizeof(credTypes) / sizeof(int),
authCallback,
NULL, // cbdata will be initialized in main
};
int
main(int argc, char *argv[])
{
int ret = 0;
virConnectPtr conn;
char *uri;
AuthData authData;
if (argc != 4) {
ret = 1;
printf("Usage: %s <uri> <username> <password>\n", argv[0]);
goto out;
}
uri = argv[1];
authData.username = argv[2];
authData.password = argv[3];
auth.cbdata = &authData;
printf("Attempting to connect to hypervisor\n");
conn = virConnectOpenAuth(uri, &auth, 0);
if (NULL == conn) {
ret = 1;
printf("No connection to hypervisor\n");
showError(conn);
goto out;
}
uri = virConnectGetURI(conn);
if (uri == NULL) {
ret = 1;
printf("Failed to get URI for hypervisor connection\n");
showError(conn);
goto disconnect;
}
printf("Connected to hypervisor at \"%s\"\n", uri);
free(uri);
if (showHypervisorInfo(conn) != 0) {
ret = 1;
goto disconnect;
}
if (showDomains(conn) != 0) {
ret = 1;
goto disconnect;
}
disconnect:
if (virConnectClose(conn) != 0) {
printf("Failed to disconnect from hypervisor\n");
showError(conn);
ret = 1;
} else {
printf("Disconnected from hypervisor\n");
}
out:
return ret;
}

View File

@ -0,0 +1,35 @@
FILTERS = \
allow-arp.xml \
allow-dhcp-server.xml \
allow-dhcp.xml \
allow-incoming-ipv4.xml \
allow-ipv4.xml \
clean-traffic.xml \
no-arp-spoofing.xml \
no-ip-multicast.xml \
no-ip-spoofing.xml \
no-mac-broadcast.xml \
no-mac-spoofing.xml \
no-other-l2-traffic.xml \
no-other-rarp-traffic.xml \
qemu-announce-self.xml \
qemu-announce-self-rarp.xml
EXTRA_DIST=$(FILTERS)
confdir = $(sysconfdir)/libvirt
NWFILTER_DIR = "$(DESTDIR)$(sysconfdir)/libvirt/nwfilter"
install-data-local:
$(MKDIR_P) "$(NWFILTER_DIR)"
for f in $(FILTERS); do \
$(INSTALL_DATA) $(srcdir)/$$f "$(NWFILTER_DIR)"; \
done
uninstall-local::
for f in $(FILTERS); do \
rm -f "$(NWFILTER_DIR)/$$f"; \
done
-test -z $(shell ls $(NWFILTER_DIR)) || rmdir $(NWFILTER_DIR)

View File

@ -0,0 +1,3 @@
<filter name='allow-arp' chain='arp'>
<rule direction='inout' action='accept'/>
</filter>

View File

@ -0,0 +1,24 @@
<filter name='allow-dhcp-server' chain='ipv4'>
<!-- accept outgoing DHCP requests -->
<!-- note, this rule must be evaluated before general MAC broadcast
traffic is discarded since DHCP requests use MAC broadcast -->
<rule action='accept' direction='out' priority='100'>
<ip srcipaddr='0.0.0.0'
dstipaddr='255.255.255.255'
protocol='udp'
srcportstart='68'
dstportstart='67' />
</rule>
<!-- accept incoming DHCP responses from a specific DHCP server
parameter DHPCSERVER needs to be passed from where this filter is
referenced -->
<rule action='accept' direction='in' priority='100' >
<ip srcipaddr='$DHCPSERVER'
protocol='udp'
srcportstart='67'
dstportstart='68'/>
</rule>
</filter>

View File

@ -0,0 +1,21 @@
<filter name='allow-dhcp' chain='ipv4'>
<!-- accept outgoing DHCP requests -->
<!-- not, this rule must be evaluated before general MAC broadcast
traffic is discarded since DHCP requests use MAC broadcast -->
<rule action='accept' direction='out' priority='100'>
<ip srcipaddr='0.0.0.0'
dstipaddr='255.255.255.255'
protocol='udp'
srcportstart='68'
dstportstart='67' />
</rule>
<!-- accept incoming DHCP responses from any DHCP server -->
<rule action='accept' direction='in' priority='100' >
<ip protocol='udp'
srcportstart='67'
dstportstart='68'/>
</rule>
</filter>

View File

@ -0,0 +1,3 @@
<filter name='allow-incoming-ipv4' chain='ipv4'>
<rule direction='in' action='accept'/>
</filter>

View File

@ -0,0 +1,3 @@
<filter name='allow-ipv4' chain='ipv4'>
<rule direction='inout' action='accept'/>
</filter>

View File

@ -0,0 +1,20 @@
<filter name='clean-traffic'>
<!-- An example of a traffic filter enforcing clean traffic
from a VM by
- preventing MAC spoofing -->
<filterref filter='no-mac-spoofing'/>
<!-- preventing IP spoofing on outgoing, allow all IPv4 in incoming -->
<filterref filter='no-ip-spoofing'/>
<filterref filter='allow-incoming-ipv4'/>
<!-- preventing ARP spoofing/poisoning -->
<filterref filter='no-arp-spoofing'/>
<!-- preventing any other traffic than IPv4 and ARP -->
<filterref filter='no-other-l2-traffic'/>
<!-- allow qemu to send a self-announce upon migration end -->
<filterref filter='qemu-announce-self'/>
</filter>

View File

@ -0,0 +1,32 @@
<filter name='no-arp-spoofing' chain='arp'>
<uuid>f88f1932-debf-4aa1-9fbe-f10d3aa4bc95</uuid>
<rule action='drop' direction='out' priority='300' >
<mac match='no' srcmacaddr='$MAC'/>
</rule>
<!-- no arp spoofing -->
<!-- drop if ipaddr or macaddr does not belong to guest -->
<rule action='drop' direction='out' priority='350' >
<arp match='no' arpsrcmacaddr='$MAC'/>
</rule>
<rule action='drop' direction='out' priority='400' >
<arp match='no' arpsrcipaddr='$IP' />
</rule>
<!-- drop if ipaddr or macaddr odes not belong to guest -->
<rule action='drop' direction='in' priority='450' >
<arp match='no' arpdstmacaddr='$MAC'/>
<arp opcode='reply'/>
</rule>
<rule action='drop' direction='in' priority='500' >
<arp match='no' arpdstipaddr='$IP' />
</rule>
<!-- accept only request or reply packets -->
<rule action='accept' direction='inout' priority='600' >
<arp opcode='request'/>
</rule>
<rule action='accept' direction='inout' priority='650' >
<arp opcode='reply'/>
</rule>
<!-- drop everything else -->
<rule action='drop' direction='inout' priority='1000' />
</filter>

View File

@ -0,0 +1,9 @@
<filter name='no-ip-multicast' chain='ipv4'>
<!-- drop if destination IP address is in the 224.0.0.0/4 subnet -->
<rule action='drop' direction='out'>
<ip dstipaddr='224.0.0.0' dstipmask='4' />
</rule>
<!-- not doing anything with receiving side ... -->
</filter>

View File

@ -0,0 +1,7 @@
<filter name='no-ip-spoofing' chain='ipv4'>
<!-- drop if srcipaddr is not the IP address of the guest -->
<rule action='drop' direction='out'>
<ip match='no' srcipaddr='$IP' />
</rule>
</filter>

View File

@ -0,0 +1,8 @@
<filter name='no-mac-broadcast' chain='ipv4'>
<!-- drop if destination mac is bcast mac addr. -->
<rule action='drop' direction='out'>
<mac dstmacaddr='ff:ff:ff:ff:ff:ff' />
</rule>
<!-- not doing anything with receiving side ... -->
</filter>

View File

@ -0,0 +1,5 @@
<filter name='no-mac-spoofing' chain='ipv4'>
<rule action='drop' direction='out' priority='10'>
<mac match='no' srcmacaddr='$MAC' />
</rule>
</filter>

View File

@ -0,0 +1,7 @@
<filter name='no-other-l2-traffic'>
<!-- drop all other l2 traffic than for which rules have been
written for; i.e., drop all other than arp and ipv4 traffic -->
<rule action='drop' direction='inout' priority='1000'/>
</filter>

View File

@ -0,0 +1,3 @@
<filter name='no-other-rarp-traffic' chain='rarp'>
<rule action='drop' direction='inout' priority='1000'/>
</filter>

View File

@ -0,0 +1,14 @@
<filter name='qemu-announce-self-rarp' chain='rarp'>
<rule action='accept' direction='out' priority='500'>
<rarp opcode='Request_Reverse'
srcmacaddr='$MAC' dstmacaddr='ff:ff:ff:ff:ff:ff'
arpsrcmacaddr='$MAC' arpdstmacaddr='$MAC'
arpsrcipaddr='0.0.0.0' arpdstipaddr='0.0.0.0'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<rarp opcode='Request_Reverse'
dstmacaddr='ff:ff:ff:ff:ff:ff'
arpsrcmacaddr='$MAC' arpdstmacaddr='$MAC'
arpsrcipaddr='0.0.0.0' arpdstipaddr='0.0.0.0'/>
</rule>
</filter>

View File

@ -0,0 +1,13 @@
<filter name='qemu-announce-self' chain='root'>
<!-- as of 4/26/2010 qemu sends out a bogus packet with
wrong rarp protocol ID -->
<!-- accept what is being sent now -->
<rule action='accept' direction='out'>
<mac protocolid='0x835'/>
</rule>
<!-- accept if it was changed to rarp -->
<filterref filter='qemu-announce-self-rarp'/>
<filterref filter='no-other-rarp-traffic'/>
</filter>

Some files were not shown because too many files have changed in this diff Show More