]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agobuild: also check qemu_protocol for on-the-wire stability
Eric Blake [Fri, 8 Jul 2011 16:54:02 +0000 (10:54 -0600)]
build: also check qemu_protocol for on-the-wire stability

Since we are going to add some libvirt-qemu.so entry points in
0.9.4, we might as well start checking for RPC stability, just
as for libvirt.so.

* src/Makefile.am (PROTOCOL_STRUCTS): New variable.
(remote_protocol-structs): Rename...
(%_protocol-structs): ...and make more generic.
* src/qemu_protocol-structs: New file.

13 years agobuild: avoid requiring -lm
Eric Blake [Mon, 11 Jul 2011 23:22:20 +0000 (17:22 -0600)]
build: avoid requiring -lm

log2() is heavy when ffs() can do the same thing.  But ffs()
requires gnulib support for mingw.

This patch solves this linker error on Fedora 14.

/usr/bin/ld: libvirt_lxc-domain_conf.o: undefined reference to symbol 'log2@@GLIBC_2.2.5'
/usr/bin/ld: note: 'log2@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

* .gnulib: Update to latest, for ffs.
* bootstrap.conf (gnulib_modules): Import ffs.
* src/conf/domain_conf.c (virDomainDefParseXML): Use ffs instead
of log2.
Reported by Dave Allan.

13 years agoRemove code no longer used after commit df0b57a9
Jim Fehlig [Mon, 11 Jul 2011 20:38:03 +0000 (14:38 -0600)]
Remove code no longer used after commit df0b57a9

13 years agoAdd domain type checking
Matthias Bolte [Mon, 11 Jul 2011 17:29:09 +0000 (19:29 +0200)]
Add domain type checking

The drivers were accepting domain configs without checking if those
were actually meant for them. For example the LXC driver happily
accepts configs with type QEMU.

Add a check for the expected domain types to the virDomainDefParse*
functions.

13 years agoremote: Fix memory leak
Alex Jia [Mon, 11 Jul 2011 05:14:45 +0000 (13:14 +0800)]
remote: Fix memory leak

Detected in valgrind run:

==9184== 1 bytes in 1 blocks are definitely lost in loss record 1 of 19
==9184==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184==    by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184==    by 0x4CF97C9: xdr_remote_domain_get_security_label_ret (remote_protocol.c:1696)
==9184==    by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184==    by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184==    by 0x4CE3887: call (remote_driver.c:3933)
==9184==    by 0x4CF71C6: remoteDomainGetSecurityLabel (remote_driver.c:1580)
==9184==    by 0x4CCA480: virDomainGetSecurityLabel (libvirt.c:7340)
==9184==    by 0x41993A: cmdDominfo (virsh.c:2414)
==9184==    by 0x411E92: vshCommandRun (virsh.c:12730)
==9184==    by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== 2 bytes in 1 blocks are definitely lost in loss record 2 of 19
==9184==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184==    by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184==    by 0x4CF974F: xdr_remote_node_get_security_model_ret (remote_protocol.c:1713)
==9184==    by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184==    by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184==    by 0x4CE3887: call (remote_driver.c:3933)
==9184==    by 0x4CF6F96: remoteNodeGetSecurityModel (remote_driver.c:1648)
==9184==    by 0x4CBF799: virNodeGetSecurityModel (libvirt.c:7382)
==9184==    by 0x4197D7: cmdDominfo (virsh.c:2394)
==9184==    by 0x411E92: vshCommandRun (virsh.c:12730)
==9184==    by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== 8 bytes in 1 blocks are definitely lost in loss record 3 of 19
==9184==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==9184==    by 0x3073715F78: xdr_array (xdr_array.c:97)
==9184==    by 0x4CF9729: xdr_remote_node_get_security_model_ret (remote_protocol.c:1710)
==9184==    by 0x4D08741: virNetMessageDecodePayload (virnetmessage.c:286)
==9184==    by 0x4D00F78: virNetClientProgramCall (virnetclientprogram.c:318)
==9184==    by 0x4CE3887: call (remote_driver.c:3933)
==9184==    by 0x4CF6F96: remoteNodeGetSecurityModel (remote_driver.c:1648)
==9184==    by 0x4CBF799: virNodeGetSecurityModel (libvirt.c:7382)
==9184==    by 0x4197D7: cmdDominfo (virsh.c:2394)
==9184==    by 0x411E92: vshCommandRun (virsh.c:12730)
==9184==    by 0x4211ED: main (virsh.c:14076)
==9184==
==9184== LEAK SUMMARY:
==9184==    definitely lost: 11 bytes in 3 blocks

* src/remote/remote_driver.c: Avoid leak on remoteDomainGetSecurityLabel
  and remoteNodeGetSecurityModel.

13 years agotests: simplify formatting
Eric Blake [Mon, 11 Jul 2011 15:19:11 +0000 (09:19 -0600)]
tests: simplify formatting

The shell version would output 40 extra spaces for a test with
a multiple of 40 sub-tests, and the C version can use the same
printf optimization for avoiding a loop over single space output
as the shell version.

* tests/testutils.c (virtTestMain): Avoid loop for alignment.
* tests/test-lib.sh: Fix formatting when counter is multiple of 40.

13 years agoDo not drop kernel cmdline for xen pv domains
Jim Fehlig [Thu, 7 Jul 2011 01:17:16 +0000 (19:17 -0600)]
Do not drop kernel cmdline for xen pv domains

Kernel cmdline args can be passed to xen pv domains even when a
bootloader is specified.  The current config-to-sxpr mapping
ignores cmdline when bootloader is present.

Since the xend sub-driver is used with many xen toolstack versions,
this patch takes conservative approach of adding an else block to
existing !def->os.bootloader, and only appends sxpr if def->os.cmdline
is non-NULL.

V2: Fix existing testcase broken by this patch and add new testcases

13 years agokill vm if saving config failed in v3 protocol
Wen Congyang [Fri, 1 Jul 2011 10:05:43 +0000 (18:05 +0800)]
kill vm if saving config failed in v3 protocol

If virDomainSaveConfig() failed, we will return NULL to source,
and the vm is still available to restart during confirm() step in
v3 protocol. So we should kill it off in qemuMigrationFinish().

In v2 protocol, we should not set vm to NULL, because we hold
a reference of vm and should unrefernce it.

13 years agoRPC: fix argument's name
Wen Congyang [Mon, 11 Jul 2011 08:26:34 +0000 (16:26 +0800)]
RPC: fix argument's name

13 years agofix typo error
Wen Congyang [Mon, 11 Jul 2011 08:26:16 +0000 (16:26 +0800)]
fix typo error

13 years agobios: Add support for SGA
Michal Privoznik [Fri, 8 Jul 2011 07:56:17 +0000 (09:56 +0200)]
bios: Add support for SGA

This patch creates new <bios> element which, at this time has only the
attribute useserial='yes|no'. This attribute allow users to use
Serial Graphics Adapter and see BIOS messages from the very first moment
domain boots up. Therefore, users can choose boot medium, set PXE, etc.

13 years agoFix rpm build with sanlock and without QEmu
Daniel Veillard [Mon, 11 Jul 2011 07:57:01 +0000 (15:57 +0800)]
Fix rpm build with sanlock and without QEmu

The qemu-sanlock.conf file is not installed in this case

13 years agovbox: Fix logic in storage driver open function
Matthias Bolte [Thu, 7 Jul 2011 07:21:37 +0000 (09:21 +0200)]
vbox: Fix logic in storage driver open function

If the main driver is the vbox driver, then the open function
has to return an error if the private data is invalid.

13 years agotests: Improve output of tests that decide to skip at runtime
Matthias Bolte [Sat, 9 Jul 2011 09:50:38 +0000 (11:50 +0200)]
tests: Improve output of tests that decide to skip at runtime

Don't print OK/FAIL for tests that decide to be skipped after
calling virtTestMain. Delay printing of the indentation before
the first test until we know that the test didn't decide to be
skipped.

Also make the reconnect test use VIRT_TEST_MAIN.

13 years agotests: Fix compressed test output padding logic
Matthias Bolte [Sat, 9 Jul 2011 08:40:37 +0000 (10:40 +0200)]
tests: Fix compressed test output padding logic

The current logic tries to count from 1 to 40 and ignores paddings
of 0 and 1 to 40. This doesn't work for counter + 1 mod 40 == 0
like here for counter value 159

TEST: virsh-all
      ........................................ 40
      ........................................ 80
      ........................................ 120
      ....................................... 159 OK
PASS: virsh-all

Also seq isn't portable. Therefore, calculate the correct padding
length directly and use printf to output it at once.

13 years agotests: Use EXIT_AM_SKIP instead of 77 directly
Matthias Bolte [Fri, 8 Jul 2011 23:24:44 +0000 (01:24 +0200)]
tests: Use EXIT_AM_SKIP instead of 77 directly

13 years agorpc: Fix whitespace problem in generated code
Matthias Bolte [Fri, 8 Jul 2011 22:10:04 +0000 (00:10 +0200)]
rpc: Fix whitespace problem in generated code

Add missing line break and fix indention level.

Reported by Cole Robinson.

13 years agosanlock: avoid lockspace setup when auto_disk_lease is off
Federico Simoncelli [Fri, 8 Jul 2011 10:18:35 +0000 (10:18 +0000)]
sanlock: avoid lockspace setup when auto_disk_lease is off

When auto_disk_lease is off we should avoid the automatic lockspace
creation.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
13 years agolibvirtd: diagnose explicitly requested but missing conf file
Eric Blake [Fri, 8 Jul 2011 17:44:25 +0000 (11:44 -0600)]
libvirtd: diagnose explicitly requested but missing conf file

Fixes test regression introduced in commit 8e2e4780.

* daemon/libvirtd.c (daemonConfigLoad): Add argument.
(main): Update caller.

13 years agoqemu: clean up OOM checks
Michael Santos [Fri, 8 Jul 2011 15:13:54 +0000 (11:13 -0400)]
qemu: clean up OOM checks

13 years agoDon't exit if the libvirtd config does not exist
Daniel P. Berrange [Fri, 8 Jul 2011 14:27:42 +0000 (15:27 +0100)]
Don't exit if the libvirtd config does not exist

It is common for the $HOME/.libvirt/libvirtd.conf file to not
exist. Treat this situation as non-fatal since we can carry
on with our default settings just fine.

* daemon/libvirtd.c: Treat ENOENT as non-fatal when loading
  config

13 years agoFix sending of reply to final RPC message
Daniel P. Berrange [Fri, 8 Jul 2011 11:54:29 +0000 (12:54 +0100)]
Fix sending of reply to final RPC message

The dispatch for the CLOSE RPC call was invoking the method
virNetServerClientClose(). This caused the client connection
to be immediately terminated. This meant the reply to the
final RPC message was never sent. Prior to the RPC rewrite
we merely flagged the connection for closing, and actually
closed it when the next RPC call dispatch had completed.

* daemon/remote.c: Flag connection for a delayed close
* daemon/stream.c: Update to use new API for closing
  failed connection
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h:
  Add support for a delayed connection close. Rename the
  virNetServerClientMarkClose method to virNetServerClientImmediateClose
  to clarify its semantics

13 years agoFix leak of remote driver if final 'CLOSE' RPC call fails
Daniel P. Berrange [Fri, 8 Jul 2011 11:41:06 +0000 (12:41 +0100)]
Fix leak of remote driver if final 'CLOSE' RPC call fails

When closing a remote connection we issue a (fairly pointless)
'CLOSE' RPC call to the daemon. If this fails we skip all the
cleanup of private data, but the virConnectPtr object still
gets released as normal. This causes a memory leak. Since the
CLOSE RPC call is pretty pointless, just carry on freeing the
remote driver if it fails.

* src/remote/remote_driver.c: Ignore failure to issue CLOSE
  RPC call

13 years agoFix release of outgoing stream confirmation/abort message
Daniel P. Berrange [Fri, 8 Jul 2011 11:37:22 +0000 (12:37 +0100)]
Fix release of outgoing stream confirmation/abort message

When sending back the final OK or ERROR message on completion
of a stream, we were not decrementing the 'nrequests' tracker
on the client. With the default requests limit of '5', this
meant once a client had created 5 streams, they are unable to
process any further RPC calls.  There was also a bug when
handling an error from decoding a message length header, which
meant a client connection would not immediately be closed.

* src/rpc/virnetserverclient.c: Fix release of request after
  stream completion & mark client for close on error

13 years agoFix leak of 'msg' object in client stream code
Daniel P. Berrange [Fri, 8 Jul 2011 11:35:36 +0000 (12:35 +0100)]
Fix leak of 'msg' object in client stream code

In one exit path we forgot to free the virNetMessage object causing
a large memory leak for streams which send a lot of data. Some other
paths were calling VIR_FREE directly instead of virNetMessageFree
although this was (currently) harmless.

* src/rpc/virnetclientstream.c: Fix leak of msg object
* src/rpc/virnetclientprogram.c: Call virNetMessageFree instead
  of VIR_FREE

13 years agoFix potential crash in libvirtd with active streams
Daniel P. Berrange [Fri, 8 Jul 2011 11:33:52 +0000 (12:33 +0100)]
Fix potential crash in libvirtd with active streams

If a client disconnects while it has a stream active, there is
a race condition which could see libvirtd crash. This is because
the client struct may be freed before the last stream event has
triggered. This is trivially solved by holding an extra reference
on the client for the stream callbak

* daemon/stream.c: Acquire reference on client when adding the
  stream callback

13 years agoFix mistaken order of server cert/key parameters in constructor
Daniel P. Berrange [Fri, 8 Jul 2011 10:14:20 +0000 (11:14 +0100)]
Fix mistaken order of server cert/key parameters in constructor

The virNetTLSContextNew was being passed key/cert parameters in
the wrong order. This wasn't immediately visible because if
virNetTLSContextNewPath was used, a second bug reversed the order
of those parameters again.

Only if the paths were manually specified in /etc/libvirt/libvirtd.conf
did the bug appear

* src/rpc/virnettlscontext.c: Fix order of params passed to
  virNetTLSContextNew

13 years agographics: add support for action_if_connected in qemu
Michal Privoznik [Thu, 26 May 2011 14:15:54 +0000 (16:15 +0200)]
graphics: add support for action_if_connected in qemu

This option accepts 3 values:
-keep, to keep current client connected (Spice+VNC)
-disconnect, to disconnect client (Spice)
-fail, to fail setting password if there is a client connected (Spice)

13 years agoutil: Don't try to fchown files opened as non-root
Jiri Denemark [Fri, 8 Jul 2011 12:11:01 +0000 (14:11 +0200)]
util: Don't try to fchown files opened as non-root

When virFileOpenAs is called with VIR_FILE_OPEN_AS_UID flag and uid/gid
different from root/root while libvirtd is running as root, we fork a
new child, change its effective UID/GID to uid/gid and run
virFileOpenAsNoFork. It doesn't make any sense to fchown() the opened
file in this case since we already know that uid/gid can access the file
when open succeeds and one of the following situations may happen:

- the file is already owned by uid/gid and we skip fchown even before
  this patch
- the file is owned by uid but not gid because it was created in a
  directory with SETGID set, in which case it is desirable not to change
  the group
- the file may be owned by a completely different user and/or group
  because it was created on a root-squashed or even all-squashed NFS
  filesystem, in which case fchown would most likely fail anyway

13 years agoqemu: Don't chown files on NFS share if dynamic_ownership is off
Michal Privoznik [Thu, 7 Jul 2011 15:33:15 +0000 (17:33 +0200)]
qemu: Don't chown files on NFS share if dynamic_ownership is off

When dynamic ownership is disabled we don't want to chown any files,
not just local.

13 years agomicroblaze: Add architecture support
John Williams [Thu, 7 Jul 2011 02:45:05 +0000 (12:45 +1000)]
microblaze: Add architecture support

Add libvirt support for MicroBlaze architecture as a QEMU target.  Based on mips/mipsel pattern.

Signed-off-by: John Williams <john.williams@petalogix.com>
13 years agoSkip some xen tests if xend is not running
Jim Fehlig [Thu, 7 Jul 2011 21:53:41 +0000 (15:53 -0600)]
Skip some xen tests if xend is not running

Currently, the xen statstest and reconnect tests are only compiled
if xend is running.  Compile them unconditionally if xen headers
are present, but skip the tests at runtime if xend is not running.

This is in response to Eric's suggestion here

https://www.redhat.com/archives/libvir-list/2011-July/msg00367.html

13 years agoutil: drop unused safezero argument
Eric Blake [Wed, 6 Jul 2011 22:32:10 +0000 (16:32 -0600)]
util: drop unused safezero argument

No caller was using the flags argument, and this function is internal
only, so we might as well skip it.

* src/util/util.h (safezero): Update signature.
* src/util/util.c (safezero): Update function.
* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace)
(virLockManagerSanlockCreateLease): Update all callers.
* src/storage/storage_backend.c (createRawFile): Likewise.

13 years agoconf: prefer unsigned int for flags
Eric Blake [Wed, 6 Jul 2011 22:05:03 +0000 (16:05 -0600)]
conf: prefer unsigned int for flags

* src/conf/domain_conf.c (virDomainGraphicsDefParseXML)
(virDomainDeviceInfoFormat, virDomainDeviceInfoParseXML)
(virDomainDiskDefParseXML, virDomainControllerDefParseXML)
(virDomainFSDefParseXML, virDomainNetDefParseXML)
(virDomainChrDefParseTargetXML, virDomainChrDefParseXML)
(virDomainSmartcardDefParseXML, virDomainInputDefParseXML)
(virDomainTimerDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainMemballoonDefParseXML)
(virDomainVideoDefParseXML)
(virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevDefParseXML, virSecurityLabelDefParseXML)
(virDomainVcpuPinDefParseXML, virDomainDefParseXML)
(virDomainDefParse, virDomainDiskDefFormat)
(virDomainControllerDefFormat, virDomainFSDefFormat)
(virDomainNetDefFormat, virDomainChrSourceDefFormat)
(virDomainChrDefFormat, virDomainSmartcardDefFormat)
(virDomainSoundDefFormat, virDomainMemballoonDefFormat)
(virDomainWatchdogDefFormat, virDomainVideoDefFormat)
(virDomainInputDefFormat, virDomainGraphicsDefFormat)
(virDomainHostdevDefFormat, virDomainObjFormat): Switch signature.
(virDomainObjTaint, virDomainSaveStatus): Use unsigned flags.

13 years agodrivers: prefer unsigned int for flags
Eric Blake [Wed, 6 Jul 2011 20:40:19 +0000 (14:40 -0600)]
drivers: prefer unsigned int for flags

Now that the public APIs always use unsigned flags, the internal
driver callbacks might as well do likewise.

* src/driver.h (vrDrvOpen, virDrvDomainCoreDump)
(virDrvDomainGetXMLDesc, virDrvNetworkGetXMLDesc)
(virDrvNWFilterGetXMLDesc): Update type.
* src/remote/remote_protocol.x (remote_open_args)
(remote_domain_core_dump_args, remote_domain_get_xml_desc_args)
(remote_network_get_xml_desc_args)
(remote_nwfilter_get_xml_desc_args): Likewise.
* src/test/test_driver.c: Update clients.
* src/remote/remote_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* src/xen/xen_hypervisor.h: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xend_internal.c: Likewise.
* src/xen/xend_internal.h: Likewise.
* src/xen/xm_internal.c: Likewise.
* src/xen/xm_internal.h: Likewise.
* src/xen/xs_internal.c: Likewise.
* src/xen/xs_internal.h: Likewise.
* src/xen/xen_inotify.c: Likewise.
* src/xen/xen_inotify.h: Likewise.
* src/phyp/phyp_driver.c: Likewise.
* src/openvz/openvz_driver.c: Likewise.
* src/vmware/vmware_driver.c: Likewise.
* src/vbox/vbox_driver.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xenapi/xenapi_driver.c: Likewise.
* src/esx/esx_driver.c: Likewise.
* src/esx/esx_interface_driver.c: Likewise.
* src/esx/esx_network_driver.c: Likewise.
* src/esx/esx_storage_driver.c: Likewise.
* src/esx/esx_device_monitor.c: Likewise.
* src/esx/esx_secret_driver.c: Likewise.
* src/esx/esx_nwfilter_driver.c: Likewise.
* src/interface/netcf_driver.c: Likewise.
* src/nwfilter/nwfilter_driver.c: Likewise.
* src/libxl/libxl_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/secret/secret_driver.c: Likewise.
* src/storage/storage_driver.c: Likewise.
* src/node_device/node_device_hal.c: Likewise.
* src/node_device/node_device_udev.c: Likewise.
* src/remote_protocol-structs: Likewise.

13 years agopublic API: prefer unsigned int for flags
Eric Blake [Wed, 6 Jul 2011 19:55:47 +0000 (13:55 -0600)]
public API: prefer unsigned int for flags

Most APIs use 'unsigned int flags'; but a few stragglers were using
a signed value.  In particular, the vir*GetXMLDesc APIs were
split-brain, with inconsistent choice of types.  Although it is
an API break to use 'int' instead of 'unsigned int', it is ABI
compatible (pre-compiled apps will have no difference in behavior),
and generally apps can be recompiled without any issue (only rare
apps that compiled with extremely high warning levels, or which
pass libvirt API around as typed function pointers, would have to
make any code changes to deal with the change).

The migrate APIs use 'unsigned long flags', which can't be changed,
due to ABI constraints.

This patch intentionally touches only the public API, to prove the
claim that most existing code (including driver callbacks and virsh)
still compiles just fine in spite of the type change.

* include/libvirt/libvirt.h.in (virConnectOpenAuth)
(virDomainCoreDump, virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc): Use unsigned int for flags.
(virDomainHasCurrentSnapshot): Use consistent spelling.
* src/libvirt.c (virConnectOpenAuth, virDomainCoreDump)
(virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc, do_open): Update accordingly.

13 years agomaint: print flags in hex during debug
Eric Blake [Wed, 6 Jul 2011 18:18:34 +0000 (12:18 -0600)]
maint: print flags in hex during debug

Debugging decimal flags is a pain.

* src/libvirt.c: Always print flags in hex.

13 years agovirsh: make destroy sound less scary
Eric Blake [Wed, 6 Jul 2011 21:42:47 +0000 (15:42 -0600)]
virsh: make destroy sound less scary

Destroy has a rather negative English connotation.  Try to reduce
the impact, so newbies aren't as scared to use it.

* tools/virsh.c: Tweak all destroy documentation.
* tools/virsh.pod: Likewise.

13 years agobuild: use gnulib pthread_sigmask
Eric Blake [Wed, 6 Jul 2011 14:46:15 +0000 (08:46 -0600)]
build: use gnulib pthread_sigmask

Gnulib finally learned how to do pthread_sigmask on mingw.

* .gnulib: Update to latest, for pthread_sigmask.
* bootstrap.conf (gnulib_modules): Add pthread_sigmask.
* configure.ac (AC_CHECK_FUNCS): Drop redundant check.
* src/rpc/virnetclient.c (virNetClientSetTLSSession)
(virNetClientIOEventLoop): Make code unconditional.
* src/util/command.c (virFork): Likewise.
* tools/virsh.c (doMigrate, cmdMigrate): Likewise.

13 years agobuild: fix virBufferVasprintf on mingw
Eric Blake [Thu, 30 Jun 2011 17:57:42 +0000 (11:57 -0600)]
build: fix virBufferVasprintf on mingw

Gnulib documents that mingw vsnprintf is broken (it returns -1
on out-of-space, instead of the count of what would have been
printed); but while we were using the snprintf wrapper, we had
not yet been using the vsnprintf wrapper.

Meanwhile, mingw (but not mingw64) has a replacement snprintf
that fixes return values, but still lacks %1$s support; so in
that case, gnulib didn't replace snprintf, but libintl then
went ahead and installed a version that supported %1$s but not
return values.  Gnulib has since been fixed to guarantee that
the snprintf module will always guarantee the constraints needed
by libintl.

Also, we want to guarantee that strdup sets errno on failure.

* .gnulib: Update to latest, for vsnprintf fix.
* bootstrap.conf (gnulib_modules): Add vsnprintf, strdup-posix.
Reported by Matthias Bolte.

13 years agoFix compilation of statstest.c during make check
Jim Fehlig [Thu, 7 Jul 2011 16:15:05 +0000 (10:15 -0600)]
Fix compilation of statstest.c during make check

13 years agopython: Fix bogus label placement
Matthias Bolte [Wed, 6 Jul 2011 17:25:18 +0000 (19:25 +0200)]
python: Fix bogus label placement

13 years agoutil: close the ioctl socket at the end of if(Get|Set)MacAddress
Laine Stump [Wed, 6 Jul 2011 06:50:06 +0000 (02:50 -0400)]
util: close the ioctl socket at the end of if(Get|Set)MacAddress

Otherwise this will leak an fd each time one of these functions is
called.

13 years agoutil: rename err_exit to cleanup in interface.c
Laine Stump [Wed, 6 Jul 2011 13:33:54 +0000 (09:33 -0400)]
util: rename err_exit to cleanup in interface.c

This brings it in line with the recommendations in HACKING.

13 years agosysinfo: delete unnecessary white space of sysinfo.
Minoru Usui [Wed, 29 Jun 2011 04:43:35 +0000 (13:43 +0900)]
sysinfo: delete unnecessary white space of sysinfo.

  * Trim each element and delete null entry of sysinfo by
  virSkipSpacesBackwards().

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agoutil: add virTrimSpaces
Eric Blake [Wed, 29 Jun 2011 17:47:08 +0000 (11:47 -0600)]
util: add virTrimSpaces

The next patch wants to adjust an end pointer to trim trailing
spaces but without modifying the underlying string, but a more
generally useful ability to trim trailing spaces in place is
also worth providing.

* src/util/util.h (virTrimSpaces, virSkipSpacesBackwards): New
prototypes.
* src/util/util.c (virTrimSpaces, virSkipSpacesBackwards): New
functions.
* src/libvirt_private.syms (util.h): Export new functions.
Inspired by a patch by Minoru Usui.

13 years agoutil: fix virSkipSpaces
Eric Blake [Wed, 29 Jun 2011 17:30:43 +0000 (11:30 -0600)]
util: fix virSkipSpaces

Most clients of virSkipSpaces don't want to omit backslashes.
Also, open-coding the list of spaces is not as nice as using
c_isspace.

* src/util/util.c (virSkipSpaces): Use c_isspace.
(virSkipSpacesAndBackslash): New function.
* src/util/util.h (virSkipSpacesAndBackslash): New prototype.
* src/xen/xend_internal.c (sexpr_to_xend_topology): Update caller.
* src/libvirt_private.syms (util.h): Export new function.

13 years agodocs: minor whitespace cleanups
Eric Blake [Wed, 6 Jul 2011 19:49:28 +0000 (13:49 -0600)]
docs: minor whitespace cleanups

No change in wording.  One spacing change in a <pre>, noticed because
of odd XML formatting online; the rest is in free-flowing text to
make it easier to see nesting levels in the document.

* docs/formatdomain.html.in: Adjust spacing.  Break long lines.

13 years agoReduce code duplication in virFileMakePath(Helper)
Matthias Bolte [Wed, 6 Jul 2011 13:39:21 +0000 (15:39 +0200)]
Reduce code duplication in virFileMakePath(Helper)

Move stat and mkdir to virFileMakePathHelper.

Also use the stat result to detect whether the existing path
is a directory and set errno accordingly if it's not.

13 years agoapparmor: Finish incomplete renaming of relabel to norelabel
Matthias Bolte [Wed, 6 Jul 2011 12:15:05 +0000 (14:15 +0200)]
apparmor: Finish incomplete renaming of relabel to norelabel

Commit 693eac388f1759d was incomplete here.

13 years agoFix default value of security label 'relabel' attribute
Daniel P. Berrange [Tue, 5 Jul 2011 09:49:51 +0000 (10:49 +0100)]
Fix default value of security label 'relabel' attribute

When no <seclabel> is present in the XML, the virDomainSeclabelDef
struct is left as all zeros. Unfortunately, this means it gets setup
as type=dynamic, with relabel=no, which is an illegal combination.

Change the 'bool relabel' attribute in virDomainSeclabelDef to
the inverse 'bool norelabel' so that the default initialization
is sensible

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/security/security_apparmor.c, src/security/security_selinux.c:
  Replace 'relabel' with 'norelabel'

13 years agoFix return value semantic of virFileMakePath
Matthias Bolte [Tue, 5 Jul 2011 21:02:53 +0000 (23:02 +0200)]
Fix return value semantic of virFileMakePath

Some callers expected virFileMakePath to set errno, some expected
it to return an errno value. Unify this to return 0 on success and
-1 on error. Set errno to report detailed error information.

Also optimize virFileMakePath if stat fails with an errno different
from ENOENT.

13 years agonodedev: Let check_fc_host_linux report errors to the caller
Matthias Bolte [Tue, 5 Jul 2011 21:57:14 +0000 (23:57 +0200)]
nodedev: Let check_fc_host_linux report errors to the caller

13 years agoFix compilation error when SASL support is disabled
Jean-Baptiste Rouault [Tue, 5 Jul 2011 15:30:09 +0000 (17:30 +0200)]
Fix compilation error when SASL support is disabled

This patch adds #if HAVE_SASL where needed in libvirtd.h

13 years agopci: initialize state values on reattach
Guannan Ren [Sun, 3 Jul 2011 12:09:44 +0000 (20:09 +0800)]
pci: initialize state values on reattach

add a new API pciDeviceReAttachInit() in pci.c to initialize state values for nodedev reattach

Initialize three state value of device driver to 1. This is just for a new call to
qemudNodeDeviceReAttach()

13 years agoxml: create an RNG file for common types and move some definitions there
Laine Stump [Sun, 26 Jun 2011 09:13:10 +0000 (05:13 -0400)]
xml: create an RNG file for common types and move some definitions there

domain.rng, network.rng, and interface.rng already use a few of the
same types (or in some cases *should* but don't), and an upcoming code
change will have them sharing even more. To prepare for that, this
patch takes those common data type definitions and moves them into
basictypes.rng.

This may break some rule about the need to RNG files to be autonomous
or something, but I saw that storageencryption.rng is used in this
way, so I figured it must not be completely against the law...

13 years agodocs: sort the file list in the schemas Makefile
Laine Stump [Tue, 5 Jul 2011 02:19:09 +0000 (22:19 -0400)]
docs: sort the file list in the schemas Makefile

13 years agoqemu: check flags in qemuDomainGetXMLDesc
Laine Stump [Sat, 2 Jul 2011 04:53:06 +0000 (00:53 -0400)]
qemu: check flags in qemuDomainGetXMLDesc

Although most functions with flags check to verify no application is
passing in flag bits that are currently undefined, for some reason
this function wasn't.

13 years agoconf: fix domain parse flags
Laine Stump [Mon, 4 Jul 2011 19:06:07 +0000 (15:06 -0400)]
conf: fix domain parse flags

* Change all flags args from int to unsigned int

* Allow passing flags in virDomainObjParseFile (and propogate those
  flags all the way down the call chain). Previously the flags were
  hardcoded (to VIR_DOMAIN_XML_INTERNAL_STATUS) several layers down
  the chain. Pass that value in at the one place that is currently
  calling virDomainObjParseFile.

13 years agotests: Disable networkxml2argvtest when configured without network
Matthias Bolte [Tue, 5 Jul 2011 13:26:18 +0000 (15:26 +0200)]
tests: Disable networkxml2argvtest when configured without network

Reported by Ruben Kerkhof.

13 years agoqemu: Fix virFileMakePath error handling in snapshot creation
Matthias Bolte [Mon, 4 Jul 2011 08:49:54 +0000 (10:49 +0200)]
qemu: Fix virFileMakePath error handling in snapshot creation

virFileMakePath returns an errno value on error, that will never
be negative. An virFileMakePath error would have been ignored here,
instead of being reported correctly.

13 years agoconf: Fix declaration of virNetworkDNS(Hosts)Def struct
Matthias Bolte [Mon, 4 Jul 2011 15:20:02 +0000 (17:20 +0200)]
conf: Fix declaration of virNetworkDNS(Hosts)Def struct

The struct A {} A; construct triggers a linker error on OSX about
duplicate symbols. This also differs from the common struct style.

Switch to common style to fix this.

Reported by Justin Clift.

13 years agoAdd documentation for the seclabel XML element
Daniel P. Berrange [Mon, 27 Jun 2011 11:31:36 +0000 (12:31 +0100)]
Add documentation for the seclabel XML element

The domain XML documentation is missing information about the
<seclabel> element used by security drivers

* formatdomain.html.in: Document <seclabel>

13 years agoAllow for resource relabelling with static labels
Daniel P. Berrange [Fri, 24 Jun 2011 09:21:33 +0000 (10:21 +0100)]
Allow for resource relabelling with static labels

Add a new attribute to the <seclabel> XML to allow resource
relabelling to be enabled with static label usage.

  <seclabel model='selinux' type='static' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c392,c662</label>
  </seclabel>

* docs/schemas/domain.rng: Add relabel attribute
* src/conf/domain_conf.c, src/conf/domain_conf.h: Parse
  the 'relabel' attribute
* src/qemu/qemu_process.c: Unconditionally clear out the
  'imagelabel' attribute
* src/security/security_apparmor.c: Skip based on 'relabel'
  attribute instead of label type
* src/security/security_selinux.c: Skip based on 'relabel'
  attribute instead of label type and fill in <imagelabel>
  attribute if relabel is enabled.

13 years agoAllow a base label to be specified in dynamic labelling mode
Daniel P. Berrange [Thu, 23 Jun 2011 14:48:48 +0000 (15:48 +0100)]
Allow a base label to be specified in dynamic labelling mode

Normally the dynamic labelling mode will always use a base
label of 'svirt_t' for VMs. Introduce a <baselabel> field
in the <seclabel> XML to allow this base label to be changed

eg

   <seclabel type='dynamic' model='selinux'>
     <baselabel>system_u:object_r:virt_t:s0</baselabel>
   </seclabel>

* docs/schemas/domain.rng: Add <baselabel>
* src/conf/domain_conf.c, src/conf/domain_conf.h: Parsing
  of base label
* src/qemu/qemu_process.c: Don't reset 'model' attribute if
  a base label is specified
* src/security/security_apparmor.c: Refuse to support base label
* src/security/security_selinux.c: Use 'baselabel' when generating
  label, if available

13 years agostorage: Do not override the exact error of createRawFile
Osier Yang [Mon, 4 Jul 2011 08:13:23 +0000 (16:13 +0800)]
storage: Do not override the exact error of createRawFile

virStorageBackendCreateRaw: createRawFile already reported the
exact error.

Before the fix:

error: Failed to create vol vol-create.img
error: cannot create path '/var/lib/libvirt/images/vol-create.img': Unknown error 18446744073709551597

After the fix:

error: Failed to create vol vol-create.img
error: cannot fill file '/var/lib/libvirt/images/vol-create.img': No space left on device

13 years agoRelease of libvirt-0.9.3
Daniel Veillard [Mon, 4 Jul 2011 07:54:36 +0000 (15:54 +0800)]
Release of libvirt-0.9.3

* configure.ac docs/news.html.in libvirt.spec.in: update for the
  new release
* po/*.po*: updated and regenerated localizations

13 years agoinitialize pointer to NULL
Wen Congyang [Mon, 4 Jul 2011 06:00:28 +0000 (14:00 +0800)]
initialize pointer to NULL

cmd is not initialized to NULL, but we try to freed it if we
meet some error.

13 years agostorage: avoid crash on parse error
Eric Blake [Mon, 4 Jul 2011 02:41:38 +0000 (10:41 +0800)]
storage: avoid crash on parse error

Coverity detected that we could crash on bogus input.  Meanwhile,
strtok_r is rather heavy compared to strchr.

* src/storage/storage_backend_iscsi.c (virStorageBackendIQNFound):
  Check for parse failure, and use lighter-weight functions.

13 years agovmware: avoid null deref on failed lookup
Eric Blake [Mon, 4 Jul 2011 02:32:22 +0000 (10:32 +0800)]
vmware: avoid null deref on failed lookup

* src/vmware/vmware_driver.c (vmwareDomainReboot): Check error
  before dereferencing memory.

13 years agoqemu: avoid null deref on low memory
Eric Blake [Mon, 4 Jul 2011 02:30:43 +0000 (10:30 +0800)]
qemu: avoid null deref on low memory

Detected by Coverity.  qemuDomainEventQueue requires a non-NULL
pointer; most callers silently drop the event if we encountered
and OOM situation trying to create the event.

* src/qemu/qemu_migration.c (qemuMigrationFinish): Check for OOM.

13 years agocgroup: silence coverity warning
Eric Blake [Mon, 4 Jul 2011 02:28:27 +0000 (10:28 +0800)]
cgroup: silence coverity warning

Coverity noted that most clients reacted to failure to hash; but in
a best-effort kill loop, we can ignore failure.

* src/util/cgroup.c (virCgroupKillInternal): Ignore hash failure.

13 years agorpc: silence coverity warning
Eric Blake [Mon, 4 Jul 2011 02:26:05 +0000 (10:26 +0800)]
rpc: silence coverity warning

Coverity noted that 4 out of 5 calls to virNetClientStreamRaiseError
checked the return value.  This case expects a particular value, so
warn if our expectations went wrong due to some bug elsewhere.

* src/rpc/virnetclient.c (virNetClientCallDispatchStream): Warn on
  unexpected scenario.

13 years agoqemu: silence coverity warnings
Eric Blake [Mon, 4 Jul 2011 02:23:46 +0000 (10:23 +0800)]
qemu: silence coverity warnings

Coverity warns if the majority of callers check a function for
errors, but a few don't; but in qemu_audit and qemu_domain, the
choice to not check for failures was safe.  In qemu_command, the
failure to generate a uuid can only occur on a bad pointer.

* src/qemu/qemu_audit.c (qemuAuditCgroup): Ignore failure to get
  cgroup controller.
* src/qemu/qemu_domain.c (qemuDomainObjEnterMonitor)
  (qemuDomainObjEnterMonitorWithDriver): Ignore failure to get
  timestamp.
* src/qemu/qemu_command.c (qemuParseCommandLine): Check for error.

13 years agorpc: avoid memory leak on error
Eric Blake [Mon, 4 Jul 2011 02:22:50 +0000 (10:22 +0800)]
rpc: avoid memory leak on error

Detected by Coverity.  The leak is on an error path, but I'm not
sure whether that path is likely to be triggered in practice.

* src/rpc/virnetserverservice.c (virNetServerServiceAccept): Plug leak.

13 years agorpc: fix logic bug
Eric Blake [Mon, 4 Jul 2011 01:45:21 +0000 (09:45 +0800)]
rpc: fix logic bug

Spotted by Coverity.  If we don't update tmp each time through
the loop, then if the filter being removed was not the head of
the list, we accidentally lose all filters prior to the one we
wanted to remove.

* src/rpc/virnetserverclient.c (virNetServerClientRemoveFilter):
    Don't lose unrelated filters.

13 years agopci: avoid memory leak on error
Eric Blake [Thu, 30 Jun 2011 23:35:46 +0000 (17:35 -0600)]
pci: avoid memory leak on error

Detected by Coverity.  Some, but not all, error paths were clean;
but they were repetitive so I refactored them.

* src/util/pci.c (pciGetDevice): Plug leak.

13 years agointerface: avoid memory leak on parse error
Eric Blake [Thu, 30 Jun 2011 23:13:49 +0000 (17:13 -0600)]
interface: avoid memory leak on parse error

Detected by Coverity.  Unlikely to hit unless the file contents
were corrupted.

* src/util/interface.c (ifaceRestoreMacAddress): Plug leak.

13 years agolibvirtd: avoid memory leak on OOM
Eric Blake [Thu, 30 Jun 2011 23:08:41 +0000 (17:08 -0600)]
libvirtd: avoid memory leak on OOM

Detected by Coverity; only strikes on OOM so not serious.

* daemon/libvirtd.c (daemonPidFilePath): Plug leak.

13 years agobuild: avoid 'make syntax-check' failure
Eric Blake [Fri, 1 Jul 2011 22:27:19 +0000 (16:27 -0600)]
build: avoid 'make syntax-check' failure

* tests/utiltest.c (DO_TEST): Fix indentation for cppi.

13 years agotests: Add a general util test
Matthias Bolte [Fri, 1 Jul 2011 17:58:15 +0000 (19:58 +0200)]
tests: Add a general util test

Move non-esx specific tests from esxutilstest there and add a
test for virParseVersionString.

13 years agoutil: choose whether to require micro in version strings
Eric Blake [Fri, 1 Jul 2011 13:23:02 +0000 (07:23 -0600)]
util: choose whether to require micro in version strings

To avoid regressions, we let callers specify whether to require a
minor and micro version.  Callers that were parsing uname() output
benefit from defaulting to 0, whereas callers that were parsing
version strings from other sources should not change in behavior.

* src/util/util.c (virParseVersionString): Allow caller to choose
whether to fail if minor or micro is missing.
* src/util/util.h (virParseVersionString): Update signature.
* src/esx/esx_driver.c (esxGetVersion): Update callers.
* src/lxc/lxc_driver.c (lxcVersion): Likewise.
* src/openvz/openvz_conf.c (openvzExtractVersionInfo): Likewise.
* src/uml/uml_driver.c (umlGetVersion): Likewise.
* src/vbox/vbox_MSCOMGlue.c (vboxLookupVersionInRegistry):
Likewise.
* src/vbox/vbox_tmpl.c (vboxExtractVersion): Likewise.
* src/vmware/vmware_conf.c (vmwareExtractVersion): Likewise.
* src/xenapi/xenapi_driver.c (xenapiGetVersion): Likewise.
Reported by Matthias Bolte.

13 years agobuild: consistently use CFLAGS
Eric Blake [Tue, 31 May 2011 22:15:28 +0000 (16:15 -0600)]
build: consistently use CFLAGS

According to the automake manual, CPPFLAGS (aka INCLUDES, as spelled
in automake 1.9.6) should only include -I, -D, and -U directives; more
generic directives like -Wall belong in CFLAGS since they affect more
phases of the build process.  Therefore, we should be sticking CFLAGS
additions into a CFLAGS container, not a CPPFLAGS container.

* src/Makefile.am (libvirt_driver_vmware_la_CFLAGS): Use AM_CFLAGS.
(INCLUDES): Move CFLAGS items...
(AM_CFLAGS): ...to their proper location.
* python/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
* tests/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
(commandtest_CFLAGS, commandhelper_CFLAGS)
(virnetmessagetest_CFLAGS, virnetsockettest_CFLAGS): Use AM_CFLAGS.

13 years agoExplicitely invoke python for API doc generator
Daniel Veillard [Fri, 1 Jul 2011 15:46:52 +0000 (17:46 +0200)]
Explicitely invoke python for API doc generator

This fixes the problem of not finding python in /usr/bin
which broke build on FreeBSD

13 years agofix virParseVersionString with linux 3.0
Scott Moser [Fri, 1 Jul 2011 10:40:21 +0000 (06:40 -0400)]
fix virParseVersionString with linux 3.0

linux 3.0 has no micro version number, and that is causing problems
for virParseVersionString.  The patch below should allow for:
  major
  major.minor
  major.minor.micro

If major or minor are not present they just default to zero.
We found this in Ubuntu (https://bugs.launchpad.net/bugs/802977)

13 years agobuild: remove dead variables
Eric Blake [Thu, 30 Jun 2011 23:05:19 +0000 (17:05 -0600)]
build: remove dead variables

Detected by Coverity.  No real harm in leaving these, but fixing
them cuts down on the noise for future analysis.

* src/rpc/virnetserver.c (virNetServerAddService): Delete unused
entry.
* src/util/sysinfo.c (virSysinfoRead): Delete dead assignment to
base.

13 years agoRemove bogus jsondata.h file reference which does not exist
Daniel P. Berrange [Fri, 1 Jul 2011 09:16:33 +0000 (10:16 +0100)]
Remove bogus jsondata.h file reference which does not exist

* tests/Makefile.am: Remove jsondata.h

13 years agobuild: simplify sanlock distribution
Eric Blake [Wed, 29 Jun 2011 15:24:12 +0000 (09:24 -0600)]
build: simplify sanlock distribution

EXTRA_DIST files should unconditionally be part of the tarball,
rather than depending on the presence of sanlock-devel.

Meanwhile, parallel builds could fail if we don't use mkdir -p.

* src/Makefile.am (EXTRA_DIST): Always ship sanlock .aug and
template .conf files.
(%-sanlock.conf): Use MKDIR_P.

13 years agobuild: allow 'make syntax-check' on fresh checkout
Eric Blake [Tue, 28 Jun 2011 15:50:11 +0000 (09:50 -0600)]
build: allow 'make syntax-check' on fresh checkout

For good or for bad, I did a fresh checkout, ./autogen.sh, then
'configure', then 'make syntax-check', and was surprised that it
failed.  Running 'make' before 'make syntax-check' cleaned up the
issue, but this patch makes it work up front.

* cfg.mk (sc_po_check): Add prerequisites.

13 years agobuild: ignore generated file
Eric Blake [Thu, 30 Jun 2011 18:13:51 +0000 (12:13 -0600)]
build: ignore generated file

* .gitignore: Exempt jsontest binary.

13 years agoAdd conditionals to allow build without SASL
Daniel P. Berrange [Thu, 30 Jun 2011 17:18:08 +0000 (18:18 +0100)]
Add conditionals to allow build without SASL

* daemon/libvirtd.c, daemon/remote.c: Add #if HAVE_SASL and
  suitable function stubs to allow build without SASL

13 years agobuild: avoid double-close bug with pipe2
Eric Blake [Wed, 29 Jun 2011 22:11:30 +0000 (16:11 -0600)]
build: avoid double-close bug with pipe2

Based on Coverity's finding on the previous patch, I audited
gnulib's pipe2 code and found that we had the potential for
a subtle double-close bug, unless gnulib guarantees that the
contents of the fd array are unchanged on pipe2() failure.

* .gnulib: Update to latest, for pipe2 fix.

13 years agorpc: avoid freeing uninitialized variable
Eric Blake [Wed, 29 Jun 2011 18:28:57 +0000 (12:28 -0600)]
rpc: avoid freeing uninitialized variable

Detected by Coverity.  Both are instances of bad things happening
if pipe2 fails; the virNetClientNew failure could free garbage,
and virNetSocketNewConnectCommand could close random fds.

Note: POSIX doesn't guarantee the contents of fd[0] and fd[1]
after pipe failure: http://austingroupbugs.net/view.php?id=467
We may need to introduce a virPipe2 wrapper that guarantees
that on pipe failure, the fds are explicitly set to -1, rather
than our current state of assuming the fds are unchanged from
their value prior to the failed pipe call.

* src/rpc/virnetclient.c (virNetClientNew): Initialize variable.
* src/rpc/virnetsocket.c (virNetSocketNewConnectCommand):
Likewise.

13 years agovirsh: avoid uninitialized variable
Eric Blake [Wed, 29 Jun 2011 18:04:08 +0000 (12:04 -0600)]
virsh: avoid uninitialized variable

Detected by Coverity; neither vshCmddefHelp nor vshCmdOptParse
was initializing opts_required.

* tools/virsh.c (vshCmddefOptParse): Always initialize bitmaps.

13 years agovirsh: avoid integer overflow
Eric Blake [Wed, 29 Jun 2011 17:58:36 +0000 (11:58 -0600)]
virsh: avoid integer overflow

Detected by Coverity.  info.nrVirtCpu is unsigned short, but if
cpumaplen is int, then the product of the two in vshMalloc risks
unintended sign extension.  cmdVcpuinfo had already solved this
by using size_t cpumaplen.

* tools/virsh.c (cmdVcpuPin): Use correct type.

13 years agoFix stream procedure number for virDomainMigratePrepareTunnel3
Daniel P. Berrange [Thu, 30 Jun 2011 15:52:13 +0000 (16:52 +0100)]
Fix stream procedure number for virDomainMigratePrepareTunnel3

The virDomainMigratePrepareTunnel3 impl in the remote driver
was using the procedure number for the virDomainMigratePrepareTunnel
method. This doesn't work out so well, because it makes the server
ignore & drop all stream packets

* src/remote/remote_driver.c: Fix procedure for PrepareTunnel3

13 years agoSend back an error if we get unexpected stream control message
Daniel P. Berrange [Thu, 30 Jun 2011 15:49:08 +0000 (16:49 +0100)]
Send back an error if we get unexpected stream control message

We ignore any stream data packets which come in for streams which
are not registered, since these packets are async and do not have
a reply. If we get a stream control packet though we must send back
an actual error, otherwise a (broken) client may hang forever
making it hard to diagnose the client bug.

* src/rpc/virnetserverprogram.c: Send back error for unexpected
  stream control messages

13 years agoFix release of virNetMessagePtr instances in streams processing
Daniel P. Berrange [Thu, 30 Jun 2011 15:40:47 +0000 (16:40 +0100)]
Fix release of virNetMessagePtr instances in streams processing

If a message packet for a invalid stream is received it is just
free'd. This is not good because it doesn't let the client RPC
request counter decrement. If a stream is shutdown with pending
packets the message also isn't released properly because of an
incorrect header type

* daemon/stream.c: Fix message header type
* src/rpc/virnetserverprogram.c: Send dummy reply instead of
  free'ing ignored stream message

13 years agoAdd missing include of signal.h in virnetsocket.c
Daniel P. Berrange [Thu, 30 Jun 2011 15:06:48 +0000 (16:06 +0100)]
Add missing include of signal.h in virnetsocket.c

virNetSocketFree uses kill(SIGTERM) so we must include
signal.h for the definitions

* src/rpc/virnetsocket.c: Include signal.h

13 years agoAdd test case for parsing JSON docs
Daniel P. Berrange [Thu, 30 Jun 2011 14:08:29 +0000 (15:08 +0100)]
Add test case for parsing JSON docs

While investigating some memory leaks it was unclear whether the
JSON code correctly free'd all memory during parsing. Add a test
case which can be run under valgrind to clearly demonstrate that
the parser is leak free.

* tests/Makefile.am: Add 'jsontest'
* tests/jsontest.c: A few simple JSON parsing tests