]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoExtend RPC protocol to allow FD passing
Daniel P. Berrange [Fri, 21 Oct 2011 10:30:12 +0000 (11:30 +0100)]
Extend RPC protocol to allow FD passing

Define two new RPC message types VIR_NET_CALL_WITH_FDS and
VIR_NET_REPLY_WITH_FDS. These message types are equivalent
to VIR_NET_CALL and VIR_NET_REPLY, except that between the
message header, and payload there is a 32-bit integer field
specifying how many file descriptors have been passed.

The actual file descriptors are sent/recv'd out of band.

* src/rpc/virnetmessage.c, src/rpc/virnetmessage.h,
  src/libvirt_private.syms: Add support for handling
  passed file descriptors
* src/rpc/virnetprotocol.x: Extend protocol for FD
  passing

13 years agoAdd APIs for virNetSocket for sending/receiving file descriptors
Daniel P. Berrange [Fri, 21 Oct 2011 10:13:21 +0000 (11:13 +0100)]
Add APIs for virNetSocket for sending/receiving file descriptors

Add APIs to the virNetSocket object, to allow file descriptors
to be sent/received over UNIX domain socket connections

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h,
  src/libvirt_private.syms: Add APIs for FD send/recv

13 years agoWire up QEMU implementation for virDomainOpenGraphics
Daniel P. Berrange [Fri, 21 Oct 2011 08:00:13 +0000 (09:00 +0100)]
Wire up QEMU implementation for virDomainOpenGraphics

The QEMU monitor command 'add_client' can be used to connect to
a VNC or SPICE graphics display. This allows for implementation
of the virDomainOpenGraphics API

* src/qemu/qemu_driver.c: Implement virDomainOpenGraphics
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Add binding for 'add_client' command

13 years agoExtend graphics event to include UNIX socket
Daniel P. Berrange [Fri, 21 Oct 2011 08:14:02 +0000 (09:14 +0100)]
Extend graphics event to include UNIX socket

Not all VNC/SPICE servers use a TCP socket for their connections.
It is possible to configure a UNIX socket server. The graphics
event must thus include a UNIX socket address type.

* include/libvirt/libvirt.h.in: Add UNIX socket address type
  for graphics event
* src/qemu/qemu_monitor_json.c: Add 'unix' string to address
  type enum

13 years agoIntroduce the virDomainOpenGraphics API
Daniel P. Berrange [Fri, 21 Oct 2011 08:00:37 +0000 (09:00 +0100)]
Introduce the virDomainOpenGraphics API

The virDomainOpenGraphics API allows a libvirt client to pass in
a file descriptor for an open socket pair, and get it connected
to the graphics display of the guest. This is limited to working
with local libvirt hypervisors connected over a UNIX domain
socket, since it will use UNIX FD passing

* include/libvirt/libvirt.h.in: Define virDomainOpenGraphics
* src/driver.h: Define driver for virDomainOpenGraphics
* src/libvirt_public.syms, src/libvirt.c: Entry point for
  virDomainOpenGraphics
* src/libvirt_internal.h: VIR_DRV_FEATURE_FD_PASSING

13 years agoRemove trailing whitespace from all xfig files
Daniel P. Berrange [Fri, 28 Oct 2011 09:11:16 +0000 (10:11 +0100)]
Remove trailing whitespace from all xfig files

The 5th line of every xfig file has 'Letter   ' which
annoys GITs trailing-whitespace commit hook. Hand edit
the files to remove that trailing whitespace

* docs/*.fig: Remove trailing whitespace

13 years agoAdd documentation about migration.
Daniel P. Berrange [Fri, 2 Oct 2009 16:53:51 +0000 (17:53 +0100)]
Add documentation about migration.

This adds a page documenting many aspects of migration:

 - The types of migration (managed direct, p2p, unmanaged direct)
 - Data transports (native, tunnelled)
 - Migration URIs
 - Config file handling
 - Example scenarios

* libvirt.css: Rules for data tables and diagrams
* Makefile.am: Include extra png/fig files
* migration-managed-direct.fig, migration-managed-direct.png,
  migration-managed-direct.png, migration-managed-p2p.png,
  migration-native.fig, migration-native.png,
  migration-tunnel.fig, migration-tunnel.png,
  migration-unmanaged-direct.fig, migration-unmanaged-direct.png:
  Diagrams of migration
* migration.html.in, sitemap.html.in: New migration doc

13 years agovirsh: Fix error message on vol-create-from failure
Ryota Ozaki [Mon, 24 Oct 2011 11:44:04 +0000 (20:44 +0900)]
virsh: Fix error message on vol-create-from failure

If vol-create-from is failed due to 'input volume not found',
virsh outputs like this:
  $ sudo virsh vol-create-from testpool test-vol.xml test.img
  error: failed to get vol 'test.img', specifying --pool might help
  error: Storage volume not found: no storage vol with matching path
However, '--pool' is incorrect because it is already specified as
second argument ('testpool' in this case). It should be "--inputpool".

The patch fixes this by using pooloptname, which will be "inputpool"
in this case and "pool" in other cases, as error message.

13 years agobridge: modify for use when sVirt is enabled with qemu
Tyler Coumbes [Mon, 24 Oct 2011 23:43:47 +0000 (18:43 -0500)]
bridge: modify for use when sVirt is enabled with qemu

This refactors the TAP creation code out of brAddTap into a new
function brCreateTap to allow it to be used on its own. I have also
changed ifSetInterfaceMac to brSetInterfaceMac and exported it since
it is will be needed by code outside of util/bridge.c in the next
patch.

 AUTHORS                 |    1 +
 src/libvirt_bridge.syms |    2 +
 src/util/bridge.c       |  116 +++++++++++++++++++++++++++++++----------------
 src/util/bridge.h       |    9 ++++
 4 files changed, 89 insertions(+), 39 deletions(-)

13 years agoUse virXMLSaveFile when writing XML config
Jiri Denemark [Thu, 27 Oct 2011 16:55:47 +0000 (18:55 +0200)]
Use virXMLSaveFile when writing XML config

13 years agoIntroduce virXMLSaveFile as a wrapper for virFileRewrite
Jiri Denemark [Thu, 6 Oct 2011 09:57:06 +0000 (11:57 +0200)]
Introduce virXMLSaveFile as a wrapper for virFileRewrite

Every time we write XML into a file we call virEmitXMLWarning to write a
warning that the file is automatically generated. virXMLSaveFile
simplifies this into a single step and makes rewriting existing XML file
safe by using virFileRewrite internally.

13 years agoIntroduce virFileRewrite for safe file rewrite
Jiri Denemark [Thu, 13 Oct 2011 10:17:12 +0000 (12:17 +0200)]
Introduce virFileRewrite for safe file rewrite

When saving config files we just overwrite old content of the file. In
case something fails during that process (e.g. disk gets full) we lose
both old and new content. This patch makes the process more robust by
writing the new content into a separate file and only if that succeeds
the original file is atomically replaced with the new one.

13 years agoAdd a systemtap script for watching QEMU monitor interactions
Daniel P. Berrange [Mon, 24 Oct 2011 14:31:37 +0000 (15:31 +0100)]
Add a systemtap script for watching QEMU monitor interactions

This change adds some systemtap/dtrace probes to the QEMU monitor
client code. In particular it allows watching of all operations
for a VM

* examples/systemtap/qemu-monitor.stp: Watch all monitor commands
* src/Makefile.am: Passing libdir/bindir/sbindir to dtrace2systemtap.pl
* src/dtrace2systemtap.pl: Accept libdir/bindir/sbindir as args
  and look for '# binary:' comment to mark probes against libvirtd
  vs libvirt.so
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor_json.c,
  src/qemu/qemu_monitor_text.c: Add probes for key functions

13 years agolxc: Revert zeroing count of allocated items if VIR_REALLOC_N fails
Peter Krempa [Thu, 27 Oct 2011 08:24:30 +0000 (10:24 +0200)]
lxc: Revert zeroing count of allocated items if VIR_REALLOC_N fails

Previous commit clears number of items alocated in lxcSetupLoopDevices
if VIR_REALLOC_N fails. In that case, the pointer is not NULL, and
causes leaking FDs that have been allocated.

 *  src/lxc/lxc_controller.c: revert zeroing array size

13 years agoFix typo in virFileAccessibleAs
Daniel P. Berrange [Thu, 27 Oct 2011 08:25:02 +0000 (09:25 +0100)]
Fix typo in virFileAccessibleAs

* src/util/util.c: s/git_t/gid_t/ in parameter list of virFileAccessibleAs

13 years agolxc: avoid null deref on lxcSetupLoopDevices failure
Alex Jia [Thu, 27 Oct 2011 07:18:00 +0000 (15:18 +0800)]
lxc: avoid null deref on lxcSetupLoopDevices failure

If the function lxcSetupLoopDevices(def, &nloopDevs, &loopDevs) failed,
the variable loopDevs will keep a initial NULL value, however, the
function VIR_FORCE_CLOSE(loopDevs[i]) will directly deref it.

This patch also fixes returning a bogous number of devices from
lxcSetupLoopDevices on an error path.

* rc/lxc/lxc_controller.c: fixed a null pointer dereference.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agolxc: avoid missing '{' in the function
Alex Jia [Thu, 27 Oct 2011 07:17:59 +0000 (15:17 +0800)]
lxc: avoid missing '{' in the function

Cppcheck detected a syntaxError on lxcDomainInterfaceStats.

* src/lxc/lxc_driver.c: fixed missing '{' in the function lxcDomainInterfaceStats.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: simplify use of HAVE_YAJL
Eric Blake [Thu, 20 Oct 2011 20:36:32 +0000 (14:36 -0600)]
qemu: simplify use of HAVE_YAJL

Rather than making all clients of monitor commands that are JSON-only
check whether yajl support was compiled in, it is simpler to just
avoid setting the capability bit up front if we can't use the capability.

* src/qemu/qemu_capabilities.c (qemuCapsComputeCmdFlags): Only set
capability bit if we also have yajl library to use it.
* src/qemu/qemu_driver.c (qemuDomainReboot): Drop #ifdefs.
* src/qemu/qemu_process.c (qemuProcessStart): Likewise.
* tests/qemuhelptest.c (testHelpStrParsing): Pass test even
without yajl.
* tests/qemuxml2argvtest.c (mymain): Simplify use of json flag.
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-*.args:
Update expected results to match.

13 years agosnapshot: minor cleanups from reviewing indentation
Eric Blake [Wed, 26 Oct 2011 17:30:24 +0000 (11:30 -0600)]
snapshot: minor cleanups from reviewing indentation

Break some long lines, and use more efficient functions when possible,
such as relying on virBufferEscapeString to skip output on a NULL arg.
Ensure that output does not embed newlines, since auto-indent won't
work in those situations.

* src/conf/domain_conf.c (virDomainTimerDefFormat): Break output lines.
(virDomainDefFormatInternal, virDomainDiskDefFormat)
(virDomainActualNetDefFormat, virDomainNetDefFormat)
(virDomainHostdevDefFormat): Minor cleanups.

13 years agosnapshot: simplify indentation of disk encryption xml
Eric Blake [Thu, 22 Sep 2011 18:16:26 +0000 (12:16 -0600)]
snapshot: simplify indentation of disk encryption xml

Use auto-indent in more places.

* src/conf/storage_encryption_conf.h (virStorageEncryptionFormat):
Drop parameter.
* src/conf/storage_encryption_conf.c (virStorageEncryptionFormat)
(virStorageEncryptionSecretFormat): Simplify with auto-indent.
* src/conf/domain_conf.c (virDomainDiskDefFormat): Adjust caller.
* src/conf/storage_conf.c (virStorageVolTargetDefFormat): Likewise.

13 years agosnapshot: simplify indentation of nwfilter
Eric Blake [Thu, 22 Sep 2011 19:05:03 +0000 (13:05 -0600)]
snapshot: simplify indentation of nwfilter

Fixing this involved some refactoring of common code out of
domain_conf and nwfilter_conf into nwfilter_params.

* src/conf/nwfilter_params.h (virNWFilterFormatParamAttributes):
Adjust signature.
* src/conf/nwfilter_params.c (_formatParameterAttrs)
(virNWFilterFormatParamAttributes): Adjust indentation handling,
and handle filterref here.
(formatterParam): Delete unused struct.
* src/conf/domain_conf.c (virDomainNetDefFormat): Adjust caller.
* src/conf/nwfilter_conf.c (virNWFilterIncludeDefFormat): Likewise.

13 years agostorage: avoid null deref on qemu-img failure
Eric Blake [Fri, 21 Oct 2011 21:34:34 +0000 (15:34 -0600)]
storage: avoid null deref on qemu-img failure

Detected by Coverity.  Only possible if qemu-img gives bogus output,
but we might as well be robust.

* src/storage/storage_backend.c
(virStorageBackendQEMUImgBackingFormat): Check for strstr failure.

13 years agobuild: avoid RHEL 5 build failure on LXC
Eric Blake [Wed, 26 Oct 2011 16:11:50 +0000 (10:11 -0600)]
build: avoid RHEL 5 build failure on LXC

Per the discussion here, LXC on RHEL 5 makes no sense.
https://www.redhat.com/archives/libvir-list/2011-September/msg01169.html

* configure.ac (with_lxc): Reject RHEL 5.x LXC as too old.

13 years agobuild: use gnulib fdatasync
Eric Blake [Mon, 24 Oct 2011 22:40:05 +0000 (16:40 -0600)]
build: use gnulib fdatasync

Commit 1726a73 hacked around MacOS' lack of fdatasync, since
gnulib did not have it at the time.  But now that we use newer
gnulib, we can avoid the hack.

* bootstrap.conf (gnulib_modules): Add fdatasync.
* configure.ac (AC_CHECK_FUNCS_ONCE): Drop our own check.

13 years agoAdd REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE to remote_protocol-structs
Daniel P. Berrange [Tue, 25 Oct 2011 12:07:34 +0000 (13:07 +0100)]
Add REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE to remote_protocol-structs

* src/remote_protocol-structs: Add new event

13 years agonwfilter: extend schema to support new targets
Stefan Berger [Tue, 25 Oct 2011 15:21:57 +0000 (11:21 -0400)]
nwfilter: extend schema to support new targets

Extend the nwfilter schema to support the continue and return targets.

13 years agoutil: Add virFileAccessibleAs to private symbols
Michal Privoznik [Tue, 25 Oct 2011 09:38:13 +0000 (11:38 +0200)]
util: Add virFileAccessibleAs to private symbols

Commit 458b7099b2e791b58f1286002974927d3e8bcc80 introduced this
function. However it was not added into libvirt_private.syms so
the compilation may not succeed on some hosts.

13 years agostartupPolicy: Emit event on disk source dropping
Michal Privoznik [Tue, 18 Oct 2011 14:15:42 +0000 (16:15 +0200)]
startupPolicy: Emit event on disk source dropping

If a disk source gets dropped because it is not accessible,
mgmt application might want to be informed about this. Therefore
we need to emit an event. The event presented in this patch
is however a bit superset of what written above. The reason is simple:
an intention to be easily expanded, e.g. on 'user ejected disk
in guest' events. Therefore, callback gets source string and disk alias
(which should be unique among a domain) and reason (an integer);

13 years agoqemu: implement startupPolicy
Michal Privoznik [Tue, 18 Oct 2011 08:51:06 +0000 (10:51 +0200)]
qemu: implement startupPolicy

This patch implements on_missing feature in qemu driver.
Upon qemu startup process an accessibility of CDROMs
and floppy disks is checked. The source might get dropped
if unavailable and on_missing is set accordingly.
No event is emit thought. Look for follow up patch.

13 years agoqemu: Move device alias assigning before command line construction
Michal Privoznik [Thu, 20 Oct 2011 12:45:12 +0000 (14:45 +0200)]
qemu: Move device alias assigning before command line construction

This patch is rather cosmetic as it only moves device alias
assignation from command line construction just before that.
However, it is needed in connotation of previous and next patch.

13 years agoutil: Create virFileAccessibleAs function
Michal Privoznik [Mon, 17 Oct 2011 16:00:28 +0000 (18:00 +0200)]
util: Create virFileAccessibleAs function

This function checks if a given path is accessible under
given uid and gid.

13 years agoconf: Introduce optional startupPolicy attribute for cdrom and floppy
Michal Privoznik [Mon, 17 Oct 2011 14:54:03 +0000 (16:54 +0200)]
conf: Introduce optional startupPolicy attribute for cdrom and floppy

This attribute says what to do with cdrom (or floppy) if
the source is missing. It accepts:
- mandatory - fail if missing for any reason (the default)
- requisite - fail if missing on boot up, drop if missing on
              migrate/restore/revert
- optional  - drop if missing at any start attempt.

However, this patch introduces only XML part of this new
functionality.

13 years agostorage: make previous leak less likely to regress
Eric Blake [Fri, 21 Oct 2011 22:44:52 +0000 (16:44 -0600)]
storage: make previous leak less likely to regress

Splitting into two functions allows the user to call the right
function, rather than having to remember that a *Free function is
an exception to the rule.

* src/conf/storage_conf.h (virStoragePoolSourceClear): New function.
* src/libvirt_private.syms (storage_conf.h): Export it.
* src/conf/storage_conf.c (virStoragePoolSourceFree): Split...
(virStoragePoolSourceClear): ...into new function.
(virStoragePoolDefFree, virStoragePoolDefParseSourceString):
Update callers.
* src/test/test_driver.c (testStorageFindPoolSources): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSourcesFunc)
(virStorageBackendFileSystemNetFindPoolSources): Likewise.
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIFindPoolSources): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalFindPoolSources): Likewise.

13 years agostorage: plug iscsi memory leak
Eric Blake [Fri, 21 Oct 2011 22:30:22 +0000 (16:30 -0600)]
storage: plug iscsi memory leak

Detected by Coverity.  virStoragePoolSourceFree does not free the
actual passed-in pointer.  A bigger patch would be to rename it
virStoragePoolSourceClear to match behavior, or even split it into
two functions depending on needed behavior; but this is the minimal
fix to the one location out of eight that leaked memory.

* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSIFindPoolSources): Free memory.

13 years agowaitpid: improve safety
Eric Blake [Fri, 21 Oct 2011 17:09:23 +0000 (11:09 -0600)]
waitpid: improve safety

Based on a report by Coverity.  waitpid() can leak resources if it
fails with EINTR, so it should never be used without checking return
status.  But we already have a helper function that does that, so
use it in more places.

* src/lxc/lxc_container.c (lxcContainerAvailable): Use safer
virWaitPid.
* daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
* tests/testutils.c (virtTestCaptureProgramOutput, virtTestMain):
Likewise.
* src/libvirt.c (virConnectAuthGainPolkit): Simplify with virCommand.

13 years agoqemu: avoid leaking uninit data from hotplug to dumpxml
Eric Blake [Fri, 21 Oct 2011 23:09:17 +0000 (17:09 -0600)]
qemu: avoid leaking uninit data from hotplug to dumpxml

Detected by Coverity.  Both text and JSON monitors set only the
bus and unit fields, which means driveAddr.controller spends
life as garbage on the stack, and is then memcpy()'d into the
in-memory representation which the user can see via dumpxml.

* src/qemu/qemu_hotplug.c (qemuDomainAttachSCSIDisk): Only copy
defined fields.

13 years agovirsh: Fix vol-info's 'Type' output
Ryota Ozaki [Sat, 22 Oct 2011 04:24:17 +0000 (13:24 +0900)]
virsh: Fix vol-info's 'Type' output

We have a new vol type "dir" in addition to "file" and "block", but
virsh doesn't know it. Fix it.

Additionally, the patch lets virsh output "unknown" if not matched
any of them.

13 years agodocs: Document filesystem type='block' for LXC
Ryota Ozaki [Fri, 21 Oct 2011 14:26:29 +0000 (23:26 +0900)]
docs: Document filesystem type='block' for LXC

Commit 77791dc0e allows LXC to use a host block device as a guest
filesystem, but it isn't documented yet.

13 years agosupport continue/return targets in nwfilter
David L Stevens [Tue, 18 Oct 2011 19:55:25 +0000 (12:55 -0700)]
support continue/return targets in nwfilter

This patch adds support for "continue" and "return" actions
in filter rules.

Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
13 years agosnapshot: simplify indentation of network xml
Eric Blake [Thu, 22 Sep 2011 18:00:45 +0000 (12:00 -0600)]
snapshot: simplify indentation of network xml

More simplifications possible due to auto-indent.  Also,
<bandwidth> within <actual> was only using 6 instead of 8 spaces.

* src/util/network.h (virVirtualPortProfileFormat)
(virBandwidthDefFormat): Alter signature.
* src/util/network.c (virVirtualPortProfileFormat)
(virBandwidthDefFormat): Alter indentation.
(virBandwidthChildDefFormat): Tweak to make use easier.
* src/conf/network_conf.c (virPortGroupDefFormat)
(virNetworkDefFormat): Adjust callers.
* src/conf/domain_conf.c (virDomainNetDefFormat): Likewise.
(virDomainActualNetDefFormat): Likewise, and fix bandwidth
indentation.

13 years agosnapshot: simplify indentation of cpu features
Eric Blake [Wed, 21 Sep 2011 23:42:07 +0000 (17:42 -0600)]
snapshot: simplify indentation of cpu features

Auto-indent makes life a bit easier; this patch also drops unused
arguments and replaces a misspelled flag name with two entry points
instead, so that callers don't have to worry about how much spacing
is present when embedding cpu elements.

* src/conf/cpu_conf.h (virCPUFormatFlags): Delete.
(virCPUDefFormat): Drop unused argument.
(virCPUDefFormatBuf): Alter signature.
(virCPUDefFormatBufFull): New prototype.
* src/conf/cpu_conf.c (virCPUDefFormatBuf): Split...
(virCPUDefFormatBufFull): ...into new function.
(virCPUDefFormat): Adjust caller.
* src/conf/domain_conf.c (virDomainDefFormatInternal): Likewise.
* src/conf/capabilities.c (virCapabilitiesFormatXML): Likewise.
* src/cpu/cpu.c (cpuBaselineXML): Likewise.
* tests/cputest.c (cpuTestCompareXML): Likewise.

13 years agosnapshot: simplify indentation of sysinfo
Eric Blake [Wed, 21 Sep 2011 23:28:01 +0000 (17:28 -0600)]
snapshot: simplify indentation of sysinfo

The improvements to virBuffer, along with a paradigm shift to pass
the original buffer through rather than creating a second buffer,
allow us to shave off quite a few lines of code.

* src/util/sysinfo.h (virSysinfoFormat): Alter signature.
* src/util/sysinfo.c (virSysinfoFormat, virSysinfoBIOSFormat)
(virSysinfoSystemFormat, virSysinfoProcessorFormat)
(virSysinfoMemoryFormat): Change indentation parameter.
* src/conf/domain_conf.c (virDomainSysinfoDefFormat): Adjust
caller.
* src/qemu/qemu_driver.c (qemuGetSysinfo): Likewise.

13 years agosnapshot: test domainsnapshot indentation
Eric Blake [Thu, 22 Sep 2011 20:29:00 +0000 (14:29 -0600)]
snapshot: test domainsnapshot indentation

Add a test for the simple parts of my indentation changes, and
fix the fallout.

* tests/domainsnapshotxml2xmltest.c: New test.
* tests/Makefile.am (domainsnapshotxml2xmltest_SOURCES): Build it.
* src/conf/domain_conf.c (virDomainSnapshotDefFormat): Avoid NULL
deref, match documented order.
* src/conf/domain_conf.h (virDomainSnapshotDefFormat): Add const.
* tests/domainsnapshotxml2xmlout/all_parameters.xml: Tweak output.
* tests/domainsnapshotxml2xmlout/disk_snapshot.xml: Likewise.
* tests/domainsnapshotxml2xmlout/full_domain.xml: Likewise.
* .gitignore: Exempt new binary.

13 years agosnapshot: indent domain xml when nesting
Eric Blake [Sat, 17 Sep 2011 12:57:30 +0000 (06:57 -0600)]
snapshot: indent domain xml when nesting

<domainsnapshot> is the first public instance of <domain> being
used as a sub-element, although we have two other private uses
(runtime state, and migration cookie).  Although indentation has
no effect on XML parsing, using it makes the output more consistent.

This uses virBuffer auto-indentation to obtain the effect, for all
but the portions of <domain> that are not generated a line at a
time into the same virBuffer.  Further patches will clean up the
remaining problems.

* src/conf/domain_conf.h (virDomainDefFormatInternal): New prototype.
* src/conf/domain_conf.c (virDomainDefFormatInternal): Export.
(virDomainObjFormat, virDomainSnapshotDefFormat): Update callers.
* src/libvirt_private.syms (domain_conf.h): Add new export.
* src/qemu/qemu_migration.c (qemuMigrationCookieXMLFormat): Use
new function.
(qemuMigrationCookieXMLFormatStr): Update caller.

13 years agovirbuf: add auto-indentation support
Eric Blake [Thu, 20 Oct 2011 21:48:47 +0000 (15:48 -0600)]
virbuf: add auto-indentation support

Rather than having to adjust all callers in a chain to deal with
indentation, it is nicer to have virBuffer do auto-indentation.

* src/util/buf.h (_virBuffer): Increase size.
(virBufferAdjustIndent, virBufferGetIndent): New prototypes.
* src/libvirt_private.syms (buf.h): Export new functions.
* src/util/buf.c (virBufferAdjustIndent, virBufferGetIndent): New
functions.
(virBufferSetError, virBufferAdd, virBufferAddChar)
(virBufferVasprintf, virBufferStrcat, virBufferURIEncodeString):
Implement auto-indentation.
* tests/virbuftest.c (testBufAutoIndent): Test it.
(testBufInfiniteLoop): Don't rely on internals.
Idea by Daniel P. Berrange.

13 years agovirbuf: more detailed error reporting
Eric Blake [Tue, 27 Sep 2011 19:37:23 +0000 (13:37 -0600)]
virbuf: more detailed error reporting

The next patch wants to add some sanity checking, which would
be a different error than ENOMEM.  Many existing callers blindly
report OOM failure if virBuf reports an error, and this will be
wrong in the (unlikely) case that they actually had a usage error
instead; but since the most common error really is ENOMEM, I'm
not going to fix all callers.  Meanwhile, new discriminating
callers can react differently depending on what failure happened.

* src/util/buf.c (virBufferSetError): Add parameter.
(virBufferGrow, virBufferVasprintf, virBufferEscapeString)
(virBufferEscapeSexpr, virBufferEscapeShell): Adjust callers.

13 years agovirbuf: improve testsuite reporting
Eric Blake [Sat, 17 Sep 2011 13:57:26 +0000 (07:57 -0600)]
virbuf: improve testsuite reporting

I had some temporary test failures while working on virbuf
improvements in later patches, with output that looked like:

Expected [<]
Actual [  <]

which is pretty hard to figure out.  Adding an Offset designation
made it much easier to find which particular '<' was at the
wrong indentation, to fix the right part of the code.

* tests/testutils.c (virtTestDifference): Make it easier to
diagnose test failures.

13 years agovirbuf: fix const-correctness
Eric Blake [Tue, 27 Sep 2011 19:50:03 +0000 (13:50 -0600)]
virbuf: fix const-correctness

Although the compiler wasn't complaining (since it was the pointer,
rather than what was being pointed to, that was actually const), it
looks quite suspicious to call a function with an argument labeled
const when the nature of the pointer (virBufferPtr) is hidden behind
a typedef.  Dropping const makes the function declarations easier
to read.

* src/util/buf.h: Drop const from all functions that modify buffer
argument.
* src/util/buf.c (virBufferSetError, virBufferAdd)
(virBufferContentAndReset, virBufferFreeAndReset)
(virBufferAsprintf, virBufferVasprintf, virBufferEscapeString)
(virBufferEscapeSexpr, virBufferEscape): Fix fallout.

13 years agodocs: fix incorrect info about routed networks
Laine Stump [Thu, 20 Oct 2011 19:26:30 +0000 (15:26 -0400)]
docs: fix incorrect info about routed networks

In a recent expansion of the documentation on network forward modes, I
incorrectly stated that incoming sessions to guests on routed networks
were blocked. This is true for guests on NATed networks, but not
routed. This patch corrects that error, and adds a pointer to the
nwfilter page for those who do want to restrict incoming sessions to
hosts on routed networks.

13 years agoqemu: allow json in domxml-to-native
tangchen [Thu, 20 Oct 2011 10:37:52 +0000 (18:37 +0800)]
qemu: allow json in domxml-to-native

There is a little difference between the output of domxml-to-native and the actual commandline.
No matter qemu is in control or readline mode, domxml-to-native always converts it to readline mode.

That is because the parameter "monitor_json" for qemuBuildCommandLine() is always set to false
in qemuDomainXMLToNative().

Signed-off-by: tangchen <tangchen@cn.fujitsu.com>
13 years agodocs: document managed=yes of hostdev passthrough
Eric Blake [Fri, 14 Oct 2011 22:59:16 +0000 (16:59 -0600)]
docs: document managed=yes of hostdev passthrough

Clarify some of the effects of managed passthrough <hostdev> devices;
with recent changes (commit d093547), a nodedev-reattach is only needed
to pair up to an explicit nodedev-dettach (but beware that older
virt-manager has a bug where it uses explicit nodedev-dettach under the
hood when using the gui to hotplug a hostdev device).

* docs/formatdomain.html.in: Mention reattach.
* tools/virsh.pod (nodedev): Mention managed mode.

13 years agoFix virFileOpenTty definition on Win32
Daniel P. Berrange [Thu, 20 Oct 2011 09:02:27 +0000 (10:02 +0100)]
Fix virFileOpenTty definition on Win32

Stub out a complete impl of virFileOpenTty to avoid unused
parameter warnings

* src/util/util.c: Fix virFileOpenTty on Win32

13 years agosupport setting bandwidth from virsh attach-interface
Hu Tao [Tue, 18 Oct 2011 07:32:30 +0000 (15:32 +0800)]
support setting bandwidth from virsh attach-interface

Adds two options, inbound and outbound, to attach-interface to set
bandwidth when attaching interfaces

13 years agolxc: use hand-rolled code in place of unlockpt and grantpt
Serge E. Hallyn [Wed, 19 Oct 2011 01:39:57 +0000 (20:39 -0500)]
lxc: use hand-rolled code in place of unlockpt and grantpt

The glibc ones (intentionally) cannot handle ptys opened in a
devpts not mounted at /dev/pts.

Drop the (un-exported, unused) virFileOpenTtyAt.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agobuild: ignore test executable
Eric Blake [Wed, 19 Oct 2011 19:49:59 +0000 (13:49 -0600)]
build: ignore test executable

* .gitignore: Add exemption.

13 years agoqemu: Test name-space handling
Philipp Hahn [Tue, 18 Oct 2011 19:16:01 +0000 (21:16 +0200)]
qemu: Test name-space handling

Add test cases for parsing the qemu-name-space.
This is based on qemuxml2argv{test,data/}, but can not reside in
qemuxml2argv{test,data/} because ...

1. qemuxmlns-qemu-ns-domain.xml is not schema-valid and breaks
domainschematest. The test is still important to detect xmlns:qemu
bindings to a name-space other than
http://libvirt.org/schemas/domain/qemu/1.0

2. they break qemuxml2xml, because the xmlns:qemu binding is moved to
the top-level <domain> element when converting from argv to xml.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoqemu: Fix name-space handling
Philipp Hahn [Tue, 18 Oct 2011 16:22:49 +0000 (18:22 +0200)]
qemu: Fix name-space handling

The XML parser for the qemu specific extensions expects the qemu name-space
to be bound to the 'qemu' prefix. This is too strict, since the name of the
name-space-prefix is only meant as an internal lookup key. Only the associated
URI is relevant.
<domain>...
  <qemu:commandline xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
  ...</qemu:commandline>
</domain>

<domain xmlns:ns0="http://libvirt.org/schemas/domain/qemu/1.0">...
  <ns0:commandline>
  ...</ns0:commandline>
</domain>

<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
  <qemu:commandline xmlns:qemu="urn:foo">
  ...</qemu:commandline>
</domain>

Remove the test for checking the name-space binding on the top-level <domain>
element. Registering the name-space with XPath is enough.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agocompile: fix undefined reference to gnutls_x509_crt_get_dn with gcc-4.6.1
Xu He Jie [Tue, 18 Oct 2011 08:06:44 +0000 (08:06 +0000)]
compile: fix undefined reference to gnutls_x509_crt_get_dn with gcc-4.6.1

When I compile libvirt with gcc-4.6.1 in ubuntu 11.10, got error as below:

  CCLD   libvirtd
/usr/bin/ld: ../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_migration.o): undefined reference to symbol 'gnutls_x509_crt_get_dn@@GNUTLS_1_4'
/usr/bin/ld: note: 'gnutls_x509_crt_get_dn@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so so try adding it to the linker command line
/usr/lib/x86_64-linux-gnu/libgnutls.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[3]: *** [libvirtd] Error 1

It can compile with gcc-4.5.2 in ubuntu 11.04, but it can not compile with gcc-4.6.1 in ubuntu 11.10.

I didn't find reason. Does Anyone know the reason or the different between gcc-4.5.2 and gcc-4.6.1?

I still provide a patch for this. Just make it is working now.

Signed-off-by: soulxu <soulxu@soulxu-ThinkPad-T410.(none)>
13 years agoReplace virBufferAdd with virBufferAddLit for const string
Daniel P. Berrange [Wed, 19 Oct 2011 08:44:08 +0000 (09:44 +0100)]
Replace virBufferAdd with virBufferAddLit for const string

The statement

        virBufferAdd(buf, "''", 2);

triggers a syntax-check warning

* src/util/buf.c: Replace virBufferAdd with virBufferAddLit

13 years agodocumentation: trivial spelling fix
Philipp Hahn [Tue, 18 Oct 2011 14:53:55 +0000 (16:53 +0200)]
documentation: trivial spelling fix

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoAllow for URI aliases when connecting to libvirt
Daniel P. Berrange [Thu, 13 Oct 2011 10:49:45 +0000 (11:49 +0100)]
Allow for URI aliases when connecting to libvirt

This adds support for a libvirt client configuration file
either /etc/libvirt/libvirt.conf for privileged clients,
or $HOME/.libvirt/libvirt.conf for unprivileged clients.

It allows one parameter

 uri_aliases = [
   "hail=qemu+ssh://root@hail.cloud.example.com/system",
   "sleet=qemu+ssh://root@sleet.cloud.example.com/system",
 ]

Any call to virConnectOpen with a non-NULL URI will first
attempt to match against the uri_aliases list. An application
can disable this by using VIR_CONNECT_NO_ALIASES

* docs/uri.html.in: Document URI aliases
* include/libvirt/libvirt.h.in: Add VIR_CONNECT_NO_ALIASES
* libvirt.spec.in, mingw32-libvirt.spec.in: Add /etc/libvirt/libvirt.conf
* src/Makefile.am: Install default config file
* src/libvirt.c: Add support for URI aliases
* src/remote/remote_driver.c: Don't try to handle URIs
  with no scheme and which clearly are not paths
* src/util/conf.c: Don't raise error on virConfFree(NULL)
* src/xen/xen_driver.c: Don't raise error on URIs
  with no scheme

13 years agoAdd support for autodestroy of guests to the LXC and UML drivers
Daniel P. Berrange [Wed, 13 Jul 2011 11:21:54 +0000 (12:21 +0100)]
Add support for autodestroy of guests to the LXC and UML drivers

We recently added support for VIR_DOMAIN_START_AUTODESTROY and
an impl to the QEMU driver. It is very desirable to support in
other drivers, so this adds it to LXC and UML

* src/lxc/lxc_conf.h, src/lxc/lxc_driver.c,
  src/uml/uml_conf.h, src/uml/uml_driver.c: Wire up autodestroy
  functions

13 years agoUse virBufferEscapeShell in cmdEcho
Guido Günther [Thu, 13 Oct 2011 20:49:15 +0000 (22:49 +0200)]
Use virBufferEscapeShell in cmdEcho

13 years agoqemu: replace qemuMonitorEscapeShell by virBufferEscapeShell
Guido Günther [Tue, 18 Oct 2011 19:09:13 +0000 (21:09 +0200)]
qemu: replace qemuMonitorEscapeShell by virBufferEscapeShell

13 years agovirBufferEscapeShell: Emit quotes for the empty string
Guido Günther [Thu, 13 Oct 2011 21:48:40 +0000 (23:48 +0200)]
virBufferEscapeShell: Emit quotes for the empty string

Make the empty string return '' to match cmdEcho's behavior.

13 years agosnapshot: detect when qemu lacks disk-snapshot support
Eric Blake [Tue, 18 Oct 2011 21:28:47 +0000 (15:28 -0600)]
snapshot: detect when qemu lacks disk-snapshot support

Noticed when testing new libvirt against old qemu that lacked the
snapshot_blkdev HMP command.  Libvirt was mistakenly treating the
command as successful, and re-writing the domain XML to use the
just-created 0-byte file, rendering the domain broken on restart.

* src/qemu/qemu_monitor_text.c (qemuMonitorTextDiskSnapshot):
Notice another possible error message.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive): Don't keep 0-byte file
on failure.

13 years agovirBufferEscapeShell: Fix escaping of single quotes.
Guido Günther [Tue, 18 Oct 2011 07:07:41 +0000 (09:07 +0200)]
virBufferEscapeShell: Fix escaping of single quotes.

When checking if we need to escape a single quote we were looking at the
character after the quote instead of at the quote itself.

13 years agocompile: Add a missing function 'pciDeviceListFind' to libvirt_private.syms
Xu He Jie [Tue, 18 Oct 2011 02:46:38 +0000 (02:46 +0000)]
compile: Add a missing function 'pciDeviceListFind' to libvirt_private.syms

compile error:
./src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_hostdev.o): In function `qemuPrepareHostdevPCIDevices':
/home/soulxu/data/work-code/libvirt/src/qemu/qemu_hostdev.c:183: undefined reference to `pciDeviceListFind'
/home/soulxu/data/work-code/libvirt/src/qemu/qemu_hostdev.c:230: undefined reference to `pciDeviceListFind'
./src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_hostdev.o): In function `qemuGetActivePciHostDeviceList':
/home/soulxu/data/work-code/libvirt/src/qemu/qemu_hostdev.c:102: undefined reference to `pciDeviceListFind'
./src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_hostdev.o): In function `qemuDomainReAttachHostdevDevices':
/home/soulxu/data/work-code/libvirt/src/qemu/qemu_hostdev.c:370: undefined reference to `pciDeviceListFind'

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
13 years agoqemu: Do not wait if the PCI device is not managed when reattaching
Osier Yang [Mon, 17 Oct 2011 10:19:58 +0000 (18:19 +0800)]
qemu: Do not wait if the PCI device is not managed when reattaching

Waiting for qemu-kvm cleaning up the PCI bar(s) mapping with long time
while the device is not managed is just waste of time.

13 years agoAdd AHCI support to qemu driver
Jim Fehlig [Wed, 28 Sep 2011 03:46:08 +0000 (21:46 -0600)]
Add AHCI support to qemu driver

Tested with multiple AHCI controllers and multiple disks attached
to a controller. E.g.,

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test/disk0.raw'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test/disk1.raw'/>
      <target dev='sdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test/disk2.raw'/>
      <target dev='sdc' bus='sata'/>
      <address type='drive' controller='1' bus='0' unit='0'/>
    </disk>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <controller type='sata' index='1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>

13 years agosnapshot: implement LIST_LEAVES flag in esx
Eric Blake [Sat, 8 Oct 2011 02:30:14 +0000 (20:30 -0600)]
snapshot: implement LIST_LEAVES flag in esx

Relatively straight-forward filtering.

* src/esx/esx_vi.h (esxVI_GetNumberOfSnapshotTrees)
(esxVI_GetSnapshotTreeNames): Add parameter.
* src/esx/esx_vi.c (esxVI_GetNumberOfSnapshotTrees)
(esxVI_GetSnapshotTreeNames): Allow leaf filtering.
* src/esx/esx_driver.c (esxDomainSnapshotNum)
(esxDomainSnapshotListNames, esxDomainSnapshotNumChildren)
(esxDomainSnapshotListChildrenNames): Pass new flag through.

13 years agoFix virt-sanlock-cleanup documentation
Philipp Hahn [Mon, 17 Oct 2011 16:21:54 +0000 (18:21 +0200)]
Fix virt-sanlock-cleanup documentation

The referenced page does not exist, but locking.html has a section about
sanlock.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoFix VPATH build
Jiri Denemark [Mon, 17 Oct 2011 15:42:47 +0000 (17:42 +0200)]
Fix VPATH build

probes.h is generated in build directory; setting a dependency on
probes.h from source directory doesn't work well in VPATH builds. Caused
by commit 1afcfbdda0cac112faa61f74ec943e46aa43f2f5

13 years agoqemu: Relax -no-shutdown check to [0.14.0, 0.15.0]
Jiri Denemark [Mon, 17 Oct 2011 10:15:20 +0000 (12:15 +0200)]
qemu: Relax -no-shutdown check to [0.14.0, 0.15.0]

The patch that fixes SIGTERM handling with -no-shutdown was taken into
0.15.1 stable release of qemu.

13 years agoFix two comments related to error handling
Philipp Hahn [Mon, 17 Oct 2011 15:02:33 +0000 (17:02 +0200)]
Fix two comments related to error handling

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agobuild: fix 'make dist' error
Wen Congyang [Thu, 13 Oct 2011 07:18:31 +0000 (15:18 +0800)]
build: fix 'make dist' error

When I run 'make dist', I receive the following error messages:
make[1]: Entering directory `/home/wency/source/libvirt/src'
  GEN    remote/remote_protocol.h
  GEN    remote/remote_protocol.c
  GEN    remote/qemu_protocol.h
  GEN    remote/qemu_protocol.c
  GEN    remote/qemu_client_bodies.h
  CC     libvirt_driver_remote_la-remote_protocol.lo
In file included from ./remote/remote_protocol.h:16,
                 from ./remote/remote_protocol.c:7:
/internal.h:249:23: error: probes.h: No such file or directory
make[1]: *** [libvirt_driver_remote_la-remote_protocol.lo] Error 1
make[1]: Leaving directory `/home/wency/source/libvirt/src'
make: *** [distdir] Error 1

The reason is that we use probes.h before generating it.

13 years agoAdd missing strdup return value check
Roopa Prabhu [Fri, 14 Oct 2011 22:25:28 +0000 (15:25 -0700)]
Add missing strdup return value check

Check strdup return value and fail if error

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
13 years agoqemu: Honor the orginal PCI dev properties when reattaching
Osier Yang [Thu, 13 Oct 2011 08:30:21 +0000 (16:30 +0800)]
qemu: Honor the orginal PCI dev properties when reattaching

BZ# https://bugzilla.redhat.com/show_bug.cgi?id=736214

The problem is caused by the original info of domain's PCI dev is
maintained by qemu_driver->activePciHostdevs list, (E.g. dev->reprobe,
which stands for whether need to reprobe driver for the dev when do
reattachment). The fields (dev->reprobe, dev->unbind_from_stub, and
dev->remove_slot) are initialized properly when preparing the PCI
device for managed attachment. However, when do reattachment, it
construct a complete new "pciDevice" without honoring the original
dev info, and thus the dev won't get the original driver or can get
other problem.

This patch is to fix the problem by get the devs from list
driver->activePciHostdevs.

Tested with following 3 scenarios:
  * the PCI was bound to some driver not pci-stub before attaching

    result: the device will be bound to the original driver

  * the PCI was bound to pci-stub before attaching

    result: no driver reprobing, and still bound to pci-stub

  * The PCI was not bound to any driver

    result: no driver reprobing, and still not bound to any driver.

13 years agomacvtap: avoid invalid free
Roopa Prabhu [Fri, 14 Oct 2011 20:41:46 +0000 (13:41 -0700)]
macvtap: avoid invalid free

Commit 0472f39 plugged a leak, but introduced another bug:

Actually looks like physfndev is conditionally allocated in getPhysfnDev
Its better to modify getPhysfnDev to allocate physfndev every time.

13 years agodocs: fix network XML documentation
Laine Stump [Fri, 14 Oct 2011 18:35:32 +0000 (14:35 -0400)]
docs: fix network XML documentation

A few people have attempted to use the new forwarding modes with older
versions of libvirt. The docs where the modes are described have
always stated the minimum required libvirt version, but the examples
at the end didn't, which I believe is what has caused the confusion.

Similarly, the section on portgroups now has a version tag added at
the beginning.

I also noticed that there was no example of defining a <dns> hostname,
so I added one, as well as making the domain name example more
recognizable (by adding ".com" to the domain).

13 years agoClarify semantics of virDomainMigrate2
Jiri Denemark [Fri, 14 Oct 2011 19:24:18 +0000 (21:24 +0200)]
Clarify semantics of virDomainMigrate2

Explicitly disallow conflicts between domain name from dxml and dname.

13 years agoqemu: Do not reattach PCI device used by other domain when shutdown
Osier Yang [Thu, 13 Oct 2011 04:05:04 +0000 (12:05 +0800)]
qemu: Do not reattach PCI device used by other domain when shutdown

When failing on starting a domain, it tries to reattach all the PCI
devices defined in the domain conf, regardless of whether the devices
are still used by other domain. This will cause the devices to be deleted
from the list qemu_driver->activePciHostdevs, thus the devices will be
thought as usable even if it's not true. And following commands
nodedev-{reattach,reset} will be successful.

How to reproduce:
  1) Define two domains with same PCI device defined in the confs.
  2) # virsh start domain1
  3) # virsh start domain2
  4) # virsh nodedev-reattach $pci_device

You will see the device will be reattached to host successfully.
As pciDeviceReattach just check if the device is still used by
other domain via checking if the device is in list driver->activePciHostdevs,
however, the device is deleted from the list by step 2).

This patch is to prohibit the bug by:
  1) Prohibit a domain starting or device attachment right at
     preparation period (qemuPrepareHostdevPCIDevices) if the
     device is in list driver->activePciHostdevs, which means
     it's used by other domain.

  2) Introduces a new field for struct _pciDevice, (const char *used_by),
     it will be set as the domain name at preparation period,
     (qemuPrepareHostdevPCIDevices). Thus we can prohibit deleting
     the device from driver->activePciHostdevs if it's still used by
     other domain when stopping the domain process.

* src/pci.h (define two internal functions, pciDeviceSetUsedBy and
    pciDevceGetUsedBy)
* src/pci.c (new field "const char *used_by" for struct _pciDevice,
    implementations for the two new functions)
* src/libvirt_private.syms (Add the two new internal functions)
* src/qemu_hostdev.h (Modify the definition of functions
    qemuPrepareHostdevPCIDevices, and qemuDomainReAttachHostdevDevices)
* src/qemu_hostdev.c (Prohibit preparation and don't delete the
    device from activePciHostdevs list if it's still used by other domain)
* src/qemu_hotplug.c (Update function usage, as the definitions are
    changed)

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoXen: Fake versions in xencapstest
Philipp Hahn [Fri, 14 Oct 2011 12:10:26 +0000 (14:10 +0200)]
Xen: Fake versions in xencapstest

virInitialize() → xenRegister() → xenhypervisorInit() determines the
version of the Hypervisor. This breaks xencapstest when building as root
on a dom0 system, since xenHypervisorBuildCapabilities() adds the "hap"
and "viridian" features based on the detected version.

Add an optional parameter to xenhypervisorInit() to disable automatic
detection of the Hypervisor version. The passed in arguments are used
instead.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoXen: move versions to struct
Philipp Hahn [Fri, 14 Oct 2011 10:58:01 +0000 (12:58 +0200)]
Xen: move versions to struct

Calling virInitialize() → xenRegister() → xenhypervisorInit() directly
opens a connection to the Xen Hypervisor, which breaks some unit tests.

Move all static variables into a struct to make it easier to override
them when testing.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoesx: drop dead code to silence Coverity
Eric Blake [Thu, 13 Oct 2011 22:06:38 +0000 (16:06 -0600)]
esx: drop dead code to silence Coverity

Coverity detected that the only way to get to the cleanup label
is if objectSpec had been successfully allocated, so the null
check was dead code.

* src/esx/esx_vi.c (esxVI_LookupObjectContentByType): Drop
redundant null check.

13 years agoutil: Fix typo in virGetHostname description
Jiri Denemark [Fri, 14 Oct 2011 14:25:50 +0000 (16:25 +0200)]
util: Fix typo in virGetHostname description

13 years agoFix syntax problem in mingw32-libvirt.spec.in
Daniel P. Berrange [Fri, 14 Oct 2011 09:01:56 +0000 (10:01 +0100)]
Fix syntax problem in mingw32-libvirt.spec.in

When defining macros, you can't put comments on the end of the
line because they will get included in the macro definition

* mingw32-libvirt.spec.in: Fix comment about hyperv

13 years agomacvtap: plug memory leak for 802.1Qbh
Eric Blake [Thu, 13 Oct 2011 22:45:58 +0000 (16:45 -0600)]
macvtap: plug memory leak for 802.1Qbh

Detected by Coverity.  Leak present since commit ca3b22b.

* src/util/macvtap.c (doPortProfileOp8021Qbh): Release device name.

13 years agoqemu: plug memory leak on migration
Eric Blake [Thu, 13 Oct 2011 22:19:44 +0000 (16:19 -0600)]
qemu: plug memory leak on migration

Detected by Coverity.  Leak introduced in commit 72de0d2.

* src/qemu/qemu_migration.c (qemuMigrationCookieGraphicsXMLParse):
Clean up on success.

13 years agoconf: plug memory leak on error
Eric Blake [Thu, 13 Oct 2011 22:10:47 +0000 (16:10 -0600)]
conf: plug memory leak on error

Detected by Coverity.  Leak present since commit 874e65a; and
while commit d50bb45 tried to fix the issue, it missed a path.

* src/conf/domain_conf.c (virDomainDefParseBootXML): Always clean
up useserial.

13 years agoUse virBufferEscapeShell in virNetSocketNewConnectSSH
Guido Günther [Thu, 13 Oct 2011 19:49:01 +0000 (21:49 +0200)]
Use virBufferEscapeShell in virNetSocketNewConnectSSH

to escape the netcat command since it's passed to the shell. Adjust
expected test case output accordingly.

13 years agoAdd virBufferEscapeShell
Guido Günther [Thu, 28 Jul 2011 13:25:00 +0000 (15:25 +0200)]
Add virBufferEscapeShell

Escape strings so they're safe to pass to the shell. It's based on
virsh's cmdEcho.

13 years agoAutodetect if the remote nc command supports the -q option
Guido Günther [Fri, 8 Jul 2011 19:07:29 +0000 (21:07 +0200)]
Autodetect if the remote nc command supports the -q option

Based on a patch by Marc Deslauriers <marc.deslauriers@ubuntu.com>

RH: https://bugzilla.redhat.com/show_bug.cgi?id=562176
Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/517478
Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=573172

13 years agostorage: plug memory leak on error
Eric Blake [Thu, 13 Oct 2011 21:06:01 +0000 (15:06 -0600)]
storage: plug memory leak on error

Detected by Coverity.  Present since commit 82c1740.

* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol): Fix leak.

13 years agoutil: Make getaddrinfo failure nonfatal in virGetHostname
Jiri Denemark [Thu, 13 Oct 2011 14:19:37 +0000 (16:19 +0200)]
util: Make getaddrinfo failure nonfatal in virGetHostname

Setting a hostname that cannot be resolved is not the best configuration
but since virGetHostname only calls getaddrinfo to get host's canonical
name and we do not fail if the returned canonical name is NULL or
"localhost", there is no reason why we should fail if getaddrinfo itself
fails.

13 years agoqemu: Make sure BeginJob is always followed by EndJob
Jiri Denemark [Thu, 13 Oct 2011 10:51:02 +0000 (12:51 +0200)]
qemu: Make sure BeginJob is always followed by EndJob

Otherwise we can end up with a dangling job that can only be cleared by
restarting libvirtd.

13 years agoqemu: Log debug messages when changing job
Jiri Denemark [Thu, 13 Oct 2011 10:32:38 +0000 (12:32 +0200)]
qemu: Log debug messages when changing job

Log debug messages anytime we call *BeginJob* or *EndJob* so that it's
easier to spot incorrect usage of domain job APIs.

13 years agoqemu: fix text block info parsing
Eric Blake [Thu, 13 Oct 2011 00:27:20 +0000 (18:27 -0600)]
qemu: fix text block info parsing

Detected by Coverity.  p (the pointer to the string) is always true;
when in reality, we wanted to know whether the integer value of the
just-parsed string is '0' or '1'.  Logic bug since commit b1b5b51.

* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetBlockInfo): Set
results to proper value.

13 years agoqemu: avoid text monitor null deref
Eric Blake [Thu, 13 Oct 2011 00:19:28 +0000 (18:19 -0600)]
qemu: avoid text monitor null deref

Detected by Coverity.  If, for some reason, our text monitor input
does not match our assumptions, we end up incrementing p while it
is NULL, then dereferencing the pointer 0x1, which will fault.

* src/qemu/qemu_monitor_text.c
(qemuMonitorTextGetBlockStatsParamsNumber): Rewrite to avoid
deref of strchr failure.  Fix indentation.

13 years agoqemu: check for json allocation failure
Eric Blake [Thu, 13 Oct 2011 00:10:24 +0000 (18:10 -0600)]
qemu: check for json allocation failure

Detected by Coverity.  Introduced in commit b1b5b51.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockInfo):
Avoid null dereference.