]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
15 years agoAdd support for another explicit IO error event
Daniel P. Berrange [Thu, 18 Mar 2010 19:37:44 +0000 (19:37 +0000)]
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

15 years agoReport all errors in SELinuxRestoreSecurityFileLabel
Jiri Denemark [Fri, 30 Apr 2010 11:35:15 +0000 (13:35 +0200)]
Report all errors in SELinuxRestoreSecurityFileLabel

15 years agoPrevent updates while IP address learn thread is running
Stefan Berger [Fri, 30 Apr 2010 12:12:26 +0000 (08:12 -0400)]
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.

15 years agoSyncronize the teardown of rules with the thread
Stefan Berger [Fri, 30 Apr 2010 12:10:12 +0000 (08:10 -0400)]
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.

15 years agoClean all tables before applying 'basic' rules
Stefan Berger [Fri, 30 Apr 2010 12:06:18 +0000 (08:06 -0400)]
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.

15 years agoMAke virFileHasSuffix case insensitive
Daniel Veillard [Fri, 30 Apr 2010 12:03:41 +0000 (14:03 +0200)]
MAke virFileHasSuffix case insensitive

* src/util/util.c: as it's used for checking things like .iso suffixes

15 years agonwfilter: Also pick IP address from a DHCP ACK message
Stefan Berger [Fri, 30 Apr 2010 11:51:47 +0000 (07:51 -0400)]
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

15 years agoFix virt-pki-validate's determination of CN
Dustin Kirkland [Thu, 29 Apr 2010 21:20:50 +0000 (16:20 -0500)]
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>
15 years agoqemudDomainSaveFlag: remove dead store
Jim Meyering [Thu, 29 Apr 2010 15:56:01 +0000 (17:56 +0200)]
qemudDomainSaveFlag: remove dead store

* src/qemu/qemu_driver.c (qemudDomainSaveFlag): Remove dead store to "rc".

15 years agoFix detection of disk in IO events
Daniel P. Berrange [Wed, 28 Apr 2010 14:14:47 +0000 (15:14 +0100)]
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

15 years agoImplement python binding for virDomainGetBlockInfo
Daniel P. Berrange [Wed, 28 Apr 2010 12:42:13 +0000 (13:42 +0100)]
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

15 years agoAdd new domblkinfo command to virsh
Daniel P. Berrange [Tue, 27 Apr 2010 19:31:58 +0000 (20:31 +0100)]
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

15 years agoImplement virDomainGetBlockInfo in QEMU driver
Daniel P. Berrange [Tue, 27 Apr 2010 19:31:09 +0000 (20:31 +0100)]
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

15 years agoRemote protocol impl for virDomainGetBlockInfo
Daniel P. Berrange [Tue, 27 Apr 2010 19:29:15 +0000 (20:29 +0100)]
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

15 years agoInternal driver API infrastructure for virDomainGetBlockInfo
Daniel P. Berrange [Tue, 27 Apr 2010 19:27:34 +0000 (20:27 +0100)]
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

15 years agoAdd virDomainGetBlockInfo API to query disk sizing
Daniel P. Berrange [Tue, 27 Apr 2010 19:24:30 +0000 (20:24 +0100)]
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

15 years agoFix a virsh edit memory leak
Chris Lalancette [Wed, 28 Apr 2010 19:50:06 +0000 (15:50 -0400)]
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>
15 years agoFix a qemuDomainPCIAddressSetFree memory leak
Chris Lalancette [Wed, 28 Apr 2010 19:49:41 +0000 (15:49 -0400)]
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>
15 years agoFix a memory leak in the node_device_udev code
Chris Lalancette [Wed, 28 Apr 2010 19:49:10 +0000 (15:49 -0400)]
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>
15 years agoFix build on Ubuntu.
Chris Lalancette [Mon, 26 Apr 2010 13:41:07 +0000 (09:41 -0400)]
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>
15 years agoReport better error if qemuSnapshotIsAllowed failed.
Chris Lalancette [Fri, 23 Apr 2010 15:59:23 +0000 (11:59 -0400)]
Report better error if qemuSnapshotIsAllowed failed.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoRemove unused goto label from qemudDomainCreate
Daniel P. Berrange [Thu, 29 Apr 2010 11:13:02 +0000 (12:13 +0100)]
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

15 years agonwfilter: python bindings for nwfilter
Stefan Berger [Thu, 29 Apr 2010 10:46:01 +0000 (06:46 -0400)]
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.

15 years agoqemuDomainSnapshotCreateXML: avoid NULL dereferences
Jim Meyering [Tue, 27 Apr 2010 20:35:32 +0000 (22:35 +0200)]
qemuDomainSnapshotCreateXML: avoid NULL dereferences

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): When setting
"vm" to NULL, jump over vm-dereferencing code to "cleanup".
(qemuDomainRevertToSnapshot): Likewise.

15 years agoqemudDomainCreate: correct a slightly misdirected goto
Jim Meyering [Tue, 27 Apr 2010 20:16:02 +0000 (22:16 +0200)]
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.

15 years agocygwin/mingw: Fix version script handling
Matthias Bolte [Tue, 27 Apr 2010 07:43:55 +0000 (09:43 +0200)]
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.

15 years agobuild: fix autogen rule for VPATH build
Eric Blake [Tue, 27 Apr 2010 20:39:40 +0000 (14:39 -0600)]
build: fix autogen rule for VPATH build

* cfg.mk (gnulib_srcdir): Override maint.mk default.
(_update_required): Run in correct directory.

15 years agoMove dnsmasq host file to a separate directory
Daniel Veillard [Wed, 28 Apr 2010 13:38:47 +0000 (15:38 +0200)]
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

15 years agonwfilter: allow to mix filterrefs and rules in the schema
Stefan Berger [Wed, 28 Apr 2010 13:12:39 +0000 (09:12 -0400)]
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.

15 years agoFix handling of security driver restore failures in QEMU domain save
Daniel P. Berrange [Thu, 22 Apr 2010 16:16:47 +0000 (17:16 +0100)]
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

15 years agoFix QEMU domain save to block devices with cgroups enabled
Daniel P. Berrange [Wed, 21 Apr 2010 15:44:40 +0000 (16:44 +0100)]
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.

15 years agoFix QEMU save/restore with block devices
Daniel P. Berrange [Wed, 21 Apr 2010 13:06:37 +0000 (14:06 +0100)]
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

15 years agoAvoid create/unlink with block devs used for QEMU save
Daniel P. Berrange [Wed, 21 Apr 2010 10:42:50 +0000 (11:42 +0100)]
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

15 years agoFix crash when cleaning up from failed save attempt
Daniel P. Berrange [Mon, 19 Apr 2010 14:41:48 +0000 (15:41 +0100)]
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

15 years agonwfilter: let qemu's after-migration packet pass
Stefan Berger [Tue, 27 Apr 2010 18:50:35 +0000 (14:50 -0400)]
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.

15 years agoFix up the error message if we can't parse the snapshot XML.
Chris Lalancette [Fri, 23 Apr 2010 15:58:14 +0000 (11:58 -0400)]
Fix up the error message if we can't parse the snapshot XML.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoThe base used for conversion of USB values should be 16 not 10.
Klaus Ethgen [Tue, 27 Apr 2010 07:20:47 +0000 (09:20 +0200)]
The base used for conversion of USB values should be 16 not 10.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
15 years agoFix up the locking in the snapshot code.
Chris Lalancette [Thu, 22 Apr 2010 16:01:56 +0000 (12:01 -0400)]
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>
15 years agocleanup the download section of the documentation
Daniel Veillard [Tue, 27 Apr 2010 12:20:51 +0000 (14:20 +0200)]
cleanup the download section of the documentation

Just removing reverences to the deprecated CVS server and the old git
on et.redhat.com

15 years agonwfilter: add support for RAPR protocol
Stefan Berger [Tue, 27 Apr 2010 11:26:12 +0000 (07:26 -0400)]
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

15 years agoIgnore qemu STOP event when stopping CPUs
Jiri Denemark [Tue, 27 Apr 2010 08:10:31 +0000 (10:10 +0200)]
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.

15 years agoFix build with DEBUG_RAW_IO=1
Jiri Denemark [Tue, 27 Apr 2010 08:11:46 +0000 (10:11 +0200)]
Fix build with DEBUG_RAW_IO=1

15 years agoFix indentation for storage conf XML
David Allan [Tue, 27 Apr 2010 10:01:32 +0000 (12:01 +0200)]
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

15 years agoDon't try to build qemu and lxc on non-Linux platforms
Daniel Veillard [Tue, 27 Apr 2010 08:11:21 +0000 (10:11 +0200)]
Don't try to build qemu and lxc on non-Linux platforms

as their drivers requires linux only headers

15 years agocygwin: Handle differences in the XDR implementation
Matthias Bolte [Sun, 25 Apr 2010 11:31:31 +0000 (13:31 +0200)]
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.

15 years agoCygwin's GCC doesn't like this .sa_handler initialization for some reason
Matthias Bolte [Sun, 25 Apr 2010 10:50:23 +0000 (12:50 +0200)]
Cygwin's GCC doesn't like this .sa_handler initialization for some reason

15 years agolinux/if.h header is not available on non-Linux platforms
Matthias Bolte [Sun, 25 Apr 2010 10:32:11 +0000 (12:32 +0200)]
linux/if.h header is not available on non-Linux platforms

15 years agonwfilter: enable hex number inputs in filter XML
Stefan Berger [Mon, 26 Apr 2010 17:50:40 +0000 (13:50 -0400)]
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

15 years agoStarts dnsmasq from libvirtd with --dhcp-hostsfile option
Satoru SATOH [Mon, 26 Apr 2010 14:07:25 +0000 (16:07 +0200)]
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

15 years agoAdd build support for dnsmasq module
Satoru SATOH [Mon, 26 Apr 2010 13:56:03 +0000 (15:56 +0200)]
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

15 years agoAdd dnsmasq module files
Satoru SATOH [Mon, 26 Apr 2010 13:52:02 +0000 (15:52 +0200)]
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

15 years agoFix make dist missing ESX generated files
Daniel Veillard [Mon, 26 Apr 2010 14:59:50 +0000 (16:59 +0200)]
Fix make dist missing ESX generated files

new method generated files are missing from dist tarball.

15 years agoFix memory leak in virsh snapshot-list.
Chris Lalancette [Fri, 23 Apr 2010 15:59:39 +0000 (11:59 -0400)]
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>
15 years agoFix printing of pathnames on error in qemuDomainSnapshotLoad.
Chris Lalancette [Fri, 23 Apr 2010 15:59:02 +0000 (11:59 -0400)]
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>
15 years agoFix virDomainSnapshotObjFree memory leak.
Chris Lalancette [Fri, 23 Apr 2010 15:58:41 +0000 (11:58 -0400)]
Fix virDomainSnapshotObjFree memory leak.

We were freeing the virDomainSnapshotDefPtr, but not
the virDomainSnapshotObjPtr in virDomainSnapshotObjFree.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoMake virDomainSnapshotObjListDeinit static.
Chris Lalancette [Fri, 23 Apr 2010 15:57:50 +0000 (11:57 -0400)]
Make virDomainSnapshotObjListDeinit static.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix a memory leak in the snapshot code in libvirtd.
Chris Lalancette [Fri, 23 Apr 2010 15:57:16 +0000 (11:57 -0400)]
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>
15 years agocygwin: Check explicitly for getmntent_r
Matthias Bolte [Fri, 23 Apr 2010 09:34:17 +0000 (11:34 +0200)]
cygwin: Check explicitly for getmntent_r

Cygwin has mntent.h but lacks getmntent_r. Update preprocessor
checks to catch this combination.

15 years agoSome NWFilter symbols are conditional and have to be exported conditional
Matthias Bolte [Fri, 23 Apr 2010 16:39:08 +0000 (18:39 +0200)]
Some NWFilter symbols are conditional and have to be exported conditional

15 years agoxen: Fix inside_daemon beeing unused when libvirtd is disabled
Matthias Bolte [Fri, 23 Apr 2010 16:12:09 +0000 (18:12 +0200)]
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.

15 years agoDisable stateful OpenNebula driver if libvirtd is disabled
Matthias Bolte [Fri, 23 Apr 2010 16:00:19 +0000 (18:00 +0200)]
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.

15 years agoImprove configure error message about missing Linux headers
Matthias Bolte [Fri, 23 Apr 2010 09:40:13 +0000 (11:40 +0200)]
Improve configure error message about missing Linux headers

15 years agobuild: fix typo in previous commit
Eric Blake [Fri, 23 Apr 2010 17:24:52 +0000 (11:24 -0600)]
build: fix typo in previous commit

* configure.ac: Avoid syntax error.

15 years agobuild: don't include winsock2.h on cygwin
Eric Blake [Fri, 23 Apr 2010 16:29:35 +0000 (10:29 -0600)]
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.

15 years agoQEmu JSON drop timestamp from command object
Luiz Capitulino [Fri, 23 Apr 2010 16:06:18 +0000 (18:06 +0200)]
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()

15 years agonwfilter: extend schema + add testcase w/ connlimit-above
Stefan Berger [Fri, 23 Apr 2010 15:42:39 +0000 (11:42 -0400)]
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.

15 years agomaint: update AUTHORS
Marco Bozzolan [Fri, 23 Apr 2010 13:48:10 +0000 (07:48 -0600)]
maint: update AUTHORS

* AUTHORS: Use preferred name.

Signed-off-by: Eric Blake <eblake@redhat.com>
15 years agoFix crash in nwfilter driver check
Daniel P. Berrange [Mon, 19 Apr 2010 13:16:46 +0000 (14:16 +0100)]
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()

15 years agoaddrToString: give better error message
Eric Blake [Tue, 20 Apr 2010 16:08:56 +0000 (10:08 -0600)]
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.

15 years agomaint: update AUTHORS with recent contributors
Eric Blake [Thu, 22 Apr 2010 20:13:03 +0000 (14:13 -0600)]
maint: update AUTHORS with recent contributors

git shortlog $(git log -1 --format=%H AUTHORS).. | grep -v "^ "

then add missing entries to AUTHORS.

* AUTHORS: Update.

15 years agoqemu: fix security context references in DAC code
Spencer Shimko [Wed, 21 Apr 2010 17:44:43 +0000 (13:44 -0400)]
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>
15 years agoChanges from V1 to V2:
Stefan Berger [Thu, 22 Apr 2010 18:58:57 +0000 (14:58 -0400)]
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.

15 years agoProperly indent encryption tags
David Allan [Thu, 22 Apr 2010 16:55:17 +0000 (12:55 -0400)]
Properly indent encryption tags

* Fix for the bug reported at:

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

15 years agoFix locking in qemudDomainCoreDump
Jiri Denemark [Thu, 22 Apr 2010 14:43:08 +0000 (16:43 +0200)]
Fix locking in qemudDomainCoreDump

The hang fix in d376b7d63ec1ef24ba4c812d58b9a414ddb561f8 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.

15 years agoPoll for migration end every 50ms instead of 50us
Jiri Denemark [Thu, 22 Apr 2010 14:22:31 +0000 (16:22 +0200)]
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.

15 years agoconfigure.ac SELinux fixes
Spencer Shimko [Wed, 21 Apr 2010 17:44:29 +0000 (13:44 -0400)]
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>
15 years agoFix QEMU text monitor command error checking
Daniel P. Berrange [Thu, 22 Apr 2010 15:47:33 +0000 (16:47 +0100)]
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

15 years agoFix CPU hotplug command names
Daniel P. Berrange [Thu, 22 Apr 2010 15:39:10 +0000 (16:39 +0100)]
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

15 years agoFix printing of event detail in python events demo program
Daniel P. Berrange [Thu, 22 Apr 2010 15:31:05 +0000 (16:31 +0100)]
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

15 years agoportability fixes to tools/virt-pki-validate.in
Dustin Kirkland [Wed, 21 Apr 2010 21:52:10 +0000 (16:52 -0500)]
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>
15 years agomaint: enforce whitespace on shell scripts
Eric Blake [Wed, 21 Apr 2010 23:21:06 +0000 (17:21 -0600)]
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.

15 years agotestutilsqemu: avoid uninitialized variable
Eric Blake [Thu, 22 Apr 2010 15:00:30 +0000 (09:00 -0600)]
testutilsqemu: avoid uninitialized variable

* tests/testutilsqemu.c (testQemuCapsInit): Initialize variables.

15 years agoFake host CPU for qemu tests
Jiri Denemark [Fri, 16 Apr 2010 06:01:59 +0000 (08:01 +0200)]
Fake host CPU for qemu tests

15 years agoUse configured CPU model if possible
Jiri Denemark [Thu, 15 Apr 2010 10:06:13 +0000 (12:06 +0200)]
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.

15 years agoSupport removing features when converting data to CPU
Jiri Denemark [Wed, 14 Apr 2010 15:41:32 +0000 (17:41 +0200)]
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.

15 years agoMove MIN macro to util.h so that others can use it
Jiri Denemark [Wed, 14 Apr 2010 15:40:14 +0000 (17:40 +0200)]
Move MIN macro to util.h so that others can use it

15 years agoDeal with CPU models in []
Jiri Denemark [Tue, 13 Apr 2010 16:59:14 +0000 (18:59 +0200)]
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.

15 years agoFix initial VCPU pinning in qemu driver
Jiri Denemark [Wed, 21 Apr 2010 07:39:49 +0000 (09:39 +0200)]
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.

15 years agomaint: ignore 'make syntax-check' failure files
Eric Blake [Wed, 21 Apr 2010 15:55:03 +0000 (09:55 -0600)]
maint: ignore 'make syntax-check' failure files

* .gitignore: Add exemption.
* cfg.mk (local-checks-to-skip): Ignore a test to silence a skip
warning.

15 years agoMake avahi startup more robust.
Chris Lalancette [Tue, 23 Mar 2010 13:01:37 +0000 (09:01 -0400)]
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>
15 years agoIgnore empty type attribute in driver element of virtual disks
Guido Günther [Mon, 19 Apr 2010 16:08:19 +0000 (18:08 +0200)]
Ignore empty type attribute in driver element of virtual disks

Fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578347

15 years agobuild: fix preprocessor indentation
Eric Blake [Wed, 21 Apr 2010 15:54:10 +0000 (09:54 -0600)]
build: fix preprocessor indentation

* src/esx/esx_vi.h: Placate cppi.

15 years agoesx: Don't treat an empty root snapshot list as error
Chris Wong [Wed, 21 Apr 2010 09:47:15 +0000 (11:47 +0200)]
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.

15 years agoesx: Gather some XML generation macros in esx_vi.h
Matthias Bolte [Sun, 18 Apr 2010 17:58:58 +0000 (19:58 +0200)]
esx: Gather some XML generation macros in esx_vi.h

15 years agoesx: Fix FindByIp response handling
Matthias Bolte [Sun, 18 Apr 2010 16:07:13 +0000 (18:07 +0200)]
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.

15 years agoesx: Fix virtualHW.version generation
Matthias Bolte [Sun, 18 Apr 2010 16:04:24 +0000 (18:04 +0200)]
esx: Fix virtualHW.version generation

The supported virtualHW.version doesn't depend on the API version,
but on the product version.

15 years agonwfilter: add support for connlimit match
Stefan Berger [Tue, 20 Apr 2010 21:14:38 +0000 (17:14 -0400)]
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.

15 years agoExtend fwall-drv interface and call functions via interface
Stefan Berger [Tue, 20 Apr 2010 21:07:15 +0000 (17:07 -0400)]
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.

15 years agobuild: avoid compiler warning
Eric Blake [Tue, 20 Apr 2010 19:44:31 +0000 (13:44 -0600)]
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.

15 years agoExplicitly set virStoragePoolTypeInfo FS and NETFS defaults
Matthias Bolte [Sun, 18 Apr 2010 12:00:38 +0000 (14:00 +0200)]
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.