]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
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.

15 years agoesx: Add support for the VMXNET 2 (Enhanced) NIC model
Matthias Bolte [Sat, 17 Apr 2010 09:43:01 +0000 (11:43 +0200)]
esx: Add support for the VMXNET 2 (Enhanced) NIC model

Add a test case and document it.

15 years agoMark in_open parameter of remoteAuthenticate as unused when it's unused
Matthias Bolte [Tue, 20 Apr 2010 18:28:00 +0000 (20:28 +0200)]
Mark in_open parameter of remoteAuthenticate as unused when it's unused

Otherwise compiling with -Werror will fail.

15 years agoInstall nwfilter xml files from source directory.
Philipp Hahn [Thu, 15 Apr 2010 09:21:18 +0000 (11:21 +0200)]
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>
15 years agoDon't ship generated python/libvirt.? files.
Philipp Hahn [Thu, 15 Apr 2010 10:49:33 +0000 (12:49 +0200)]
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>
15 years agoFixup python binding for virDomainSnapshot APIs
Daniel P. Berrange [Tue, 20 Apr 2010 09:49:27 +0000 (11:49 +0200)]
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

15 years agoFix network hotplug to use device_add in QEMU
Daniel P. Berrange [Fri, 16 Apr 2010 10:46:38 +0000 (11:46 +0100)]
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

15 years agoFix error reporting for getfd + host_net_add in QEMU
Daniel P. Berrange [Thu, 15 Apr 2010 15:40:54 +0000 (16:40 +0100)]
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

15 years agoFix device_del in JSON mode for QEMU
Daniel P. Berrange [Thu, 15 Apr 2010 11:17:29 +0000 (12:17 +0100)]
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

15 years agonwfilter: Free nwfilter hash of virConnectPtr
Matthias Bolte [Sat, 17 Apr 2010 16:20:15 +0000 (18:20 +0200)]
nwfilter: Free nwfilter hash of virConnectPtr

And close the driver on connection close.

15 years agoReplace printf with logging macros
Matthias Bolte [Fri, 2 Apr 2010 19:43:17 +0000 (21:43 +0200)]
Replace printf with logging macros

15 years agoMark internal.h for translation
Jiri Denemark [Fri, 16 Apr 2010 17:21:10 +0000 (19:21 +0200)]
Mark internal.h for translation

15 years agoUse virCheckFlags for APIs added in 0.8.0
Jiri Denemark [Fri, 16 Apr 2010 12:04:31 +0000 (14:04 +0200)]
Use virCheckFlags for APIs added in 0.8.0

15 years agoIntroduce virCheckFlags for consistent flags checking
Jiri Denemark [Tue, 13 Apr 2010 13:48:04 +0000 (15:48 +0200)]
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.

15 years agonwfilter: Clear all state tracking from a drop rule
Stefan Berger [Fri, 16 Apr 2010 11:34:36 +0000 (07:34 -0400)]
nwfilter: Clear all state tracking from a drop rule

Don't use state-matching in a drop rule.

15 years agoesx: Replace scanf with STRSKIP and strtok_r
Matthias Bolte [Tue, 13 Apr 2010 22:03:12 +0000 (00:03 +0200)]
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.

15 years agoUpdate to latest gnulib to get strtok_r relaxed to LGPLv2+
Matthias Bolte [Thu, 15 Apr 2010 00:03:05 +0000 (02:03 +0200)]
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.

15 years agoesx: Add nwfilter driver stub
Matthias Bolte [Wed, 14 Apr 2010 23:38:50 +0000 (01:38 +0200)]
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.

15 years agoremote: react to failures on wakeupFD
Eric Blake [Tue, 9 Mar 2010 22:17:21 +0000 (15:17 -0700)]
remote: react to failures on wakeupFD

* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Report
failures on pipe used for wakeup.
Reported by Chris Lalancette.

15 years agoutil: ensure safe{read,write,zero} return is checked
Eric Blake [Tue, 2 Mar 2010 16:35:01 +0000 (09:35 -0700)]
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.

15 years agomaint: another preprocessor fix
Eric Blake [Thu, 15 Apr 2010 17:37:25 +0000 (11:37 -0600)]
maint: another preprocessor fix

Regression introduced in commit 62170b995.

* src/util/memory.h: Placate cppi, and fit 80 columns.

15 years agoFix CDROM media change for QEMU when using -device syntax
Daniel P. Berrange [Thu, 15 Apr 2010 10:35:07 +0000 (11:35 +0100)]
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

15 years agoUpdate QEMU device_add command in JSON mode
Daniel P. Berrange [Wed, 14 Apr 2010 15:02:37 +0000 (16:02 +0100)]
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

15 years agoRename parameter in qemuMonitorDeviceDel
Daniel P. Berrange [Wed, 14 Apr 2010 14:36:42 +0000 (15:36 +0100)]
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()

15 years agoRemove code from JSON monitor for commands that won't be ported
Daniel P. Berrange [Wed, 14 Apr 2010 14:23:38 +0000 (15:23 +0100)]
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

15 years agoRun test suite as part of RPM build process
Daniel P. Berrange [Mon, 12 Apr 2010 18:39:00 +0000 (19:39 +0100)]
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

15 years agoFix QEMU memory stats JSON mode
Daniel P. Berrange [Mon, 12 Apr 2010 11:31:15 +0000 (12:31 +0100)]
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

15 years agoFix QEMU command building errors to reflect unsupported configuration
Daniel P. Berrange [Mon, 12 Apr 2010 17:20:31 +0000 (18:20 +0100)]
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

15 years agonwfilter: fix tear down order and consolidate functions
Stefan Berger [Thu, 15 Apr 2010 14:49:24 +0000 (10:49 -0400)]
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.

15 years agoTrivial fix: Add braces to for statement to avoid crashes
Stefan Berger [Thu, 15 Apr 2010 01:24:21 +0000 (21:24 -0400)]
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.

15 years agoFix close_used_without_including_unistd_h error
Matthias Bolte [Wed, 14 Apr 2010 22:59:11 +0000 (00:59 +0200)]
Fix close_used_without_including_unistd_h error

Triggered by gnulib when compiling with MinGW.

15 years agoFix apibuild.py warnings about missing ':'
Matthias Bolte [Wed, 14 Apr 2010 22:58:01 +0000 (00:58 +0200)]
Fix apibuild.py warnings about missing ':'

15 years agoImplement variable length structure allocator
David Allan [Mon, 5 Apr 2010 17:11:34 +0000 (13:11 -0400)]
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

15 years agoqemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
Jim Meyering [Wed, 7 Apr 2010 18:54:50 +0000 (20:54 +0200)]
qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang

* src/util/conf.c (virConfParseValue): Add an sa_assert.

15 years agoxend_internal.c: assure clang that we do not dereference NULL
Jim Meyering [Tue, 2 Mar 2010 15:07:30 +0000 (16:07 +0100)]
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.

15 years agoqemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
Jim Meyering [Wed, 7 Apr 2010 15:27:50 +0000 (17:27 +0200)]
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.

15 years agovirGetHostnameLocalhost: avoid FP NULL-ptr-deref from clang
Jim Meyering [Wed, 7 Apr 2010 15:23:24 +0000 (17:23 +0200)]
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.

15 years agonwfilter_ebiptables_driver.c: avoid NULL dereference
Jim Meyering [Mon, 29 Mar 2010 16:27:26 +0000 (18:27 +0200)]
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.

15 years agobuild: set STATIC_ANALYSIS when running via clang or coverity
Jim Meyering [Wed, 7 Apr 2010 15:02:25 +0000 (17:02 +0200)]
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.

15 years agosa_assert: assert-like macro, enabled only for use with static analyzers
Jim Meyering [Wed, 7 Apr 2010 14:13:17 +0000 (16:13 +0200)]
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.

15 years agobuild: fix recent 'make syntax-check' failure
Eric Blake [Wed, 14 Apr 2010 17:23:09 +0000 (11:23 -0600)]
build: fix recent 'make syntax-check' failure

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

15 years agovirt-aa-helper-test: avoid non-portable echo -n
Eric Blake [Wed, 14 Apr 2010 15:51:45 +0000 (09:51 -0600)]
virt-aa-helper-test: avoid non-portable echo -n

* tests/virt-aa-helper-test (testme): Use printf instead.

15 years agoschematestutils.sh: improve shell portability: avoid "echo -e"
Jim Meyering [Wed, 14 Apr 2010 11:25:46 +0000 (13:25 +0200)]
schematestutils.sh: improve shell portability: avoid "echo -e"

* tests/schematestutils.sh: Use printf rather than echo -e.

15 years agovirStorageBackendFileSystemMount: prefer strdup over virAsprintf
Jim Meyering [Wed, 14 Apr 2010 08:03:03 +0000 (10:03 +0200)]
virStorageBackendFileSystemMount: prefer strdup over virAsprintf

* src/storage/storage_backend_fs.c (virStorageBackendFileSystemMount):
Use virAsprintf only when needed.  In this case, strdup works fine.

15 years agovirStorageBackendFileSystemMount: placate clang
Jim Meyering [Wed, 14 Apr 2010 08:00:53 +0000 (10:00 +0200)]
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.

15 years agoImplement forgotten backend of virInterfaceIsActive()
Laine Stump [Tue, 13 Apr 2010 17:22:56 +0000 (13:22 -0400)]
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.

15 years agoopenvzGetProcessInfo: address clang-detected low-probability flaw
Jim Meyering [Wed, 14 Apr 2010 07:09:57 +0000 (09:09 +0200)]
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.

15 years agovshCommandRun: avoid used-uninitialized timing-related report from clang
Jim Meyering [Wed, 14 Apr 2010 07:04:28 +0000 (09:04 +0200)]
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.

15 years agonwfilter: use virFindFileInPath for needed CLI tools
Stefan Berger [Wed, 14 Apr 2010 10:29:55 +0000 (06:29 -0400)]
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.

15 years agoesx: Extend esx_vi_generator.py to cover methods too
Matthias Bolte [Tue, 13 Apr 2010 12:25:52 +0000 (14:25 +0200)]
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.

15 years agoesxVMX_GatherSCSIControllers: avoid NULL dereference
Jim Meyering [Wed, 14 Apr 2010 08:18:20 +0000 (10:18 +0200)]
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.

15 years agoFix build of openvz on RHEL-5.
Chris Lalancette [Tue, 6 Apr 2010 19:33:32 +0000 (15:33 -0400)]
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>
15 years agoFix up formatting of remote protocol stuff.
Chris Lalancette [Wed, 7 Apr 2010 15:23:11 +0000 (11:23 -0400)]
Fix up formatting of remote protocol stuff.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix messsage -> message.
Chris Lalancette [Thu, 8 Apr 2010 12:19:35 +0000 (08:19 -0400)]
Fix messsage -> message.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoFix up a debug typo.
Chris Lalancette [Thu, 8 Apr 2010 12:47:02 +0000 (08:47 -0400)]
Fix up a debug typo.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoRemove some debugging leftovers.
Chris Lalancette [Thu, 8 Apr 2010 14:29:46 +0000 (10:29 -0400)]
Remove some debugging leftovers.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoConsolidate interface related functions in interface.c
Stefan Berger [Tue, 13 Apr 2010 14:57:11 +0000 (10:57 -0400)]
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.

15 years agoFix nodeinfotest on NUMA machines
Daniel P. Berrange [Tue, 13 Apr 2010 10:39:16 +0000 (11:39 +0100)]
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

15 years agobuild: include usleep gnulib module
Eric Blake [Mon, 12 Apr 2010 21:56:19 +0000 (15:56 -0600)]
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.

15 years agoFix spec file for builds without lxc
Daniel Berteaud [Tue, 13 Apr 2010 08:40:21 +0000 (10:40 +0200)]
Fix spec file for builds without lxc

* libvirt.spec.in: fix a cut and paste error

15 years agobuild: fix syntax-check problems
Eric Blake [Mon, 12 Apr 2010 22:43:05 +0000 (16:43 -0600)]
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.

15 years agoadd nwfilter functions to virsh man page
Stefan Berger [Mon, 12 Apr 2010 21:50:31 +0000 (17:50 -0400)]
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.

15 years agoRelease of libvirt-0.8.0
Daniel Veillard [Mon, 12 Apr 2010 17:39:20 +0000 (19:39 +0200)]
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

15 years agoAdd documentation for synchronous hooks
Daniel Veillard [Mon, 12 Apr 2010 15:13:32 +0000 (17:13 +0200)]
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

15 years agoRename virsh "revert-to-snapshot" to "snapshot-revert"
Chris Lalancette [Mon, 12 Apr 2010 13:36:13 +0000 (09:36 -0400)]
Rename virsh "revert-to-snapshot" to "snapshot-revert"

Signed-off-by: Chris Lalancette <clalance@redhat.com>
15 years agoSmall fixes to virsh man page
Luiz Capitulino [Mon, 12 Apr 2010 12:22:02 +0000 (14:22 +0200)]
Small fixes to virsh man page

* tools/virsh.pod: add two missing 's' and section about 'dominfo' is
  duplicated

15 years agonwfilter: Fix memory leak on daemon init and shutdown
Stefan Berger [Mon, 12 Apr 2010 12:19:11 +0000 (08:19 -0400)]
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.

15 years agonwfilter: Process DHCP option to determine whether packet is a DHCP_OFFER
Stefan Berger [Fri, 9 Apr 2010 19:54:29 +0000 (15:54 -0400)]
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.

15 years agoAdd enospace option to qemu disk error policy
David Allan [Thu, 8 Apr 2010 20:05:50 +0000 (16:05 -0400)]
Add enospace option to qemu disk error policy

* Dan Kenigsberg requested explicit support for the qemu default disk error policy which is enospace

15 years agoMore event callback fixes
Daniel P. Berrange [Thu, 8 Apr 2010 15:01:00 +0000 (16:01 +0100)]
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

15 years agoUndoing 2nd application of the patch...
Stefan Berger [Fri, 9 Apr 2010 14:05:59 +0000 (10:05 -0400)]
Undoing 2nd application of the patch...

15 years agoFix error in nwfilter test driver
Stefan Berger [Fri, 9 Apr 2010 13:55:22 +0000 (09:55 -0400)]
Fix error in nwfilter test driver

Trivial fix for the c&p error in the nwfilter test driver.

15 years agoFix error in nwfilter test driver
Stefan Berger [Fri, 9 Apr 2010 13:53:47 +0000 (09:53 -0400)]
Fix error in nwfilter test driver

Trivial fix for the c&p error in the nwfilter test driver.

15 years agoFix some cppi prepocessor indentation issues
Daniel Veillard [Fri, 9 Apr 2010 13:10:46 +0000 (15:10 +0200)]
Fix some cppi prepocessor indentation issues

* src/conf/nwfilter_conf.c src/util/hooks.c: added spaces to avoid
  "make syntax-check" failures

15 years agoqemu: catch cdrom change error
Ryan Harper [Fri, 9 Apr 2010 13:07:16 +0000 (15:07 +0200)]
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

15 years agoAvoid using multicast addresses for Ethernet MAC examples
redshift [Fri, 9 Apr 2010 12:38:12 +0000 (14:38 +0200)]
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'

15 years agonwfilter: More XML parser test cases
Stefan Berger [Fri, 9 Apr 2010 11:25:02 +0000 (07:25 -0400)]
nwfilter: More XML parser test cases

This patch adds a couple more nwfilter test cases for the XML parser tests.

15 years agoCleanup the msg_gen_function list in cfg.mk
Matthias Bolte [Fri, 9 Apr 2010 00:29:11 +0000 (02:29 +0200)]
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.

15 years agoremote: Replace some virRaiseError with remoteError
Matthias Bolte [Sat, 3 Apr 2010 17:17:53 +0000 (19:17 +0200)]
remote: Replace some virRaiseError with remoteError

15 years agoremote: Remove virConnectPtr from error/errorf
Matthias Bolte [Sat, 3 Apr 2010 12:55:42 +0000 (14:55 +0200)]
remote: Remove virConnectPtr from error/errorf

Also unify error/errorf to remoteError and update cfg.mk accordingly.

15 years agoRemove undefined symbols from symbols file
Matthias Bolte [Thu, 8 Apr 2010 18:45:38 +0000 (20:45 +0200)]
Remove undefined symbols from symbols file

15 years agoesx: Add domain snapshot support
Matthias Bolte [Wed, 7 Apr 2010 09:23:53 +0000 (11:23 +0200)]
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.

15 years agoGenerate libvirt.def from libvirt.syms
Matthias Bolte [Mon, 22 Mar 2010 01:25:36 +0000 (02:25 +0100)]
Generate libvirt.def from libvirt.syms

The MinGW linker needs the libvirt.def file.

15 years agoFix unterminated B<...> in virsh man page
Jiri Denemark [Thu, 8 Apr 2010 12:44:48 +0000 (14:44 +0200)]
Fix unterminated B<...> in virsh man page

15 years agoFix up python bindings for new event callbacks
Daniel P. Berrange [Fri, 26 Mar 2010 13:22:06 +0000 (13:22 +0000)]
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

15 years agoAdd missing nwfilter_learnipaddr.c to POTFILES.in
Daniel P. Berrange [Thu, 8 Apr 2010 11:01:00 +0000 (12:01 +0100)]
Add missing nwfilter_learnipaddr.c to POTFILES.in

* po/POTFILES.in: Add src/nwfilter/nwfilter_learnipaddr.c

15 years agoFix Win32 portability problems
Daniel P. Berrange [Wed, 7 Apr 2010 15:06:43 +0000 (16:06 +0100)]
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

15 years agonwfilter: fix for directionality of ICMP traffic
Stefan Berger [Thu, 8 Apr 2010 10:25:38 +0000 (06:25 -0400)]
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>

15 years agoesx: Allow 'lsisas1068' as SCSI controller type
Matthias Bolte [Fri, 12 Mar 2010 19:08:47 +0000 (20:08 +0100)]
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.

15 years agoesx: Report an error for invalid arguments in esxList(Defined)Domains
Matthias Bolte [Wed, 7 Apr 2010 08:55:00 +0000 (10:55 +0200)]
esx: Report an error for invalid arguments in esxList(Defined)Domains

15 years agoAvoid searching for windres when not building for Windows
Diego Elio Pettenò [Thu, 8 Apr 2010 09:52:46 +0000 (11:52 +0200)]
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

15 years agoExecutable does not belong into repository.
Stefan Berger [Wed, 7 Apr 2010 23:52:25 +0000 (19:52 -0400)]
Executable does not belong into repository.

Removing the tests/nwfilterxml2xmltest executable that got in with a previous patch.

15 years agonwfilter: Support for learning a VM's IP address
Stefan Berger [Wed, 7 Apr 2010 21:02:18 +0000 (23:02 +0200)]
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

15 years agoxenXMDomainDefineXML: remove dead store and useless/leaky virGetDomain
Jim Meyering [Wed, 7 Apr 2010 18:17:44 +0000 (20:17 +0200)]
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.