]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agovirsh: properly interleave shared stdout and stderr
Eric Blake [Fri, 19 Aug 2011 15:20:35 +0000 (09:20 -0600)]
virsh: properly interleave shared stdout and stderr

Without this patch, invoking 'virsh >file 2>&1' results in
error messages appearing before normal output, even if they
occurred later in time than the normal output (since stderr
is unbuffered, but stdout waits until a full buffer).

* tools/virsh.c (print_job_progress, vshError): Flush between
stream transitions.
* tests/undefine: Test it.

13 years agomaint: simplify lots of libxml2 clients
Eric Blake [Thu, 18 Aug 2011 21:37:14 +0000 (15:37 -0600)]
maint: simplify lots of libxml2 clients

Repetitive patterns should be factored.  The sign of a good
factorization is a change that kills 5x more lines than it adds :)

* src/conf/domain_conf.c (virDomainDeviceDefParse)
(virDomainSnapshotDefParseString): Use new convenience macros.
* src/conf/storage_conf.c (virStoragePoolDefParseSourceString):
Likewise.
* src/cpu/cpu.c (cpuCompareXML, cpuBaselineXML): Likewise.
* src/esx/esx_vi.c (esxVI_Context_Execute): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationCookieXMLParseStr):
Likewise.
* src/security/virt-aa-helper.c (caps_mockup): Likewise.
* src/test/test_driver.c (testOpenFromFile): Likewise.
* tests/cputest.c (cpuTestLoadXML, cpuTestLoadMultiXML):
Likewise.
* tools/virsh.c (cmdFreecell, makeCloneXML, cmdVNCDisplay)
(cmdTTYConsole, cmdDetachInterface, cmdDetachDisk)
(cmdSnapshotCreate, cmdSnapshotCreateAs, cmdSnapshotCurrent)
(cmdSnapshotList, cmdSnapshotParent): Likewise.

13 years agoxml: add another convenience function
Eric Blake [Thu, 18 Aug 2011 21:01:36 +0000 (15:01 -0600)]
xml: add another convenience function

Often, we want to use XPath functions on the just-parsed document;
fold this into the parser function for convenience.

* src/util/xml.h (virXMLParseHelper): Add argument.
(virXMLParseStrHelper, virXMLParseFileHelper): Delete.
(virXMLParseCtxt, virXMLParseStringCtxt, virXMLParseFileCtxt): New
macros.
* src/libvirt_private.syms (xml.h): Remove deleted functions.
* src/util/xml.c (virXMLParseHelper): Add argument.
(virXMLParseStrHelper, virXMLParseFileHelper): Delete.

13 years agomaint: treat more libxml2 functions as free-like
Eric Blake [Thu, 18 Aug 2011 20:54:43 +0000 (14:54 -0600)]
maint: treat more libxml2 functions as free-like

* cfg.mk (useless_free_options): Add xmlFreeDoc, xmlBufferFree.
* src/esx/esx_vi.c (ESX_VI__TEMPLATE__FREE): Fix offenders.
* tools/virsh.c (cmdFreecell, cmdVNCDisplay, cmdTTYConsole)
(cmdDetachInterface, cmdDetachDisk, cmdSnapshotCreate)
(cmdSnapshotCreateAs, cmdSnapshotList, cmdSnapshotParent):
Likewise.

13 years agotest: rewrite test to match change in behavior
Eric Blake [Fri, 19 Aug 2011 14:57:22 +0000 (08:57 -0600)]
test: rewrite test to match change in behavior

Test failure exposed in commit 7d3390f.

* tests/undefine: Fix to match updated test driver semantics.

13 years agobuild: fix typo in recent test patch
Eric Blake [Fri, 19 Aug 2011 14:14:58 +0000 (08:14 -0600)]
build: fix typo in recent test patch

* src/test/test_driver.c (testDomainUndefineFlags): Use right
variable name.

13 years agoRevert "xen: Allow to undefine a running domain (xm_internal)"
Eric Blake [Fri, 19 Aug 2011 14:19:34 +0000 (08:19 -0600)]
Revert "xen: Allow to undefine a running domain (xm_internal)"

ACK was given too soon.  According to the code, the xm driver is
only used for inactive domains, and has no notion of an active
domain, thus, it cannot support undefine of a running domain.
The real fix for xen needs to be in the unified driver and/or
the xend level.

This reverts commit 49186deda62161599877b0de6f7f4345c50d842a.

13 years agoxen: Allow to undefine a running domain (xm_internal)
Osier Yang [Fri, 19 Aug 2011 13:53:39 +0000 (21:53 +0800)]
xen: Allow to undefine a running domain (xm_internal)

13 years agovmware: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:52:12 +0000 (21:52 +0800)]
vmware: Allow to undefine a running domain

13 years agouml: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:51:42 +0000 (21:51 +0800)]
uml: Allow to undefine a running domain

13 years agotest: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:50:49 +0000 (21:50 +0800)]
test: Allow to undefine a running domain

13 years agoqemu: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:49:37 +0000 (21:49 +0800)]
qemu: Allow to undefine a running domain

13 years agoopenvz: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:48:47 +0000 (21:48 +0800)]
openvz: Allow to undefine a running domain

13 years agolxc: Allow to undefine a running domain
Osier Yang [Fri, 19 Aug 2011 13:47:33 +0000 (21:47 +0800)]
lxc: Allow to undefine a running domain

13 years agolibxl: Allow to undefine a running domain.
Osier Yang [Fri, 19 Aug 2011 13:46:22 +0000 (21:46 +0800)]
libxl: Allow to undefine a running domain.

Undefining a running domain will convert it to trasient, but keep
the domain still running.

13 years agoqemu: Get memory balloon info correctly for text monitor
Osier Yang [Fri, 19 Aug 2011 13:34:59 +0000 (21:34 +0800)]
qemu: Get memory balloon info correctly for text monitor

* src/qemu/qemu_monitor_text.c: BALLOON_PREFIX was defined as
"balloon: actual=", which cause "actual=" is stripped early before
the real parsing. This patch changes BALLOON_PREFIX into "balloon: ",
and modifies related functions, also renames
"qemuMonitorParseExtraBalloonInfo" to "qemuMonitorParseBalloonInfo",
as after the changing, it parses all the info returned by "info balloon".

13 years agobuild: fix compilation on mingw64
Eric Blake [Thu, 18 Aug 2011 00:12:53 +0000 (18:12 -0600)]
build: fix compilation on mingw64

* .gnulib: Update to latest, for getcwd fixes.
* bootstrap: Resync to gnulib.

13 years agostorage: Flush host cache after write
Michal Privoznik [Thu, 18 Aug 2011 12:40:03 +0000 (14:40 +0200)]
storage: Flush host cache after write

Although we are flushing cache after some critical writes (e.g.
volume creation), after some others we do not (e.g. volume cloning).
This patch fix this issue. That is for volume cloning, writing
header of logical volume, and storage wipe.

13 years agodaemon: initialize GnuTLS
Michal Privoznik [Thu, 18 Aug 2011 08:44:08 +0000 (10:44 +0200)]
daemon: initialize GnuTLS

When spice_tls is set but listen_tls is not, we don't initialize
GnuTLS library. So any later gnutls call (e.g. during migration,
where we initialize a certificate) will access uninitialized GnuTLS
internal structs and throws an error.

Although, we might now initialize GnuTLS twice, it is safe according
to the documentation:

    This function can be called many times,
    but will only do something the first time.

This patch creates 2 functions: virNetTLSInit and virNetTLSDeinit
with respect to written above.

13 years agoschedinfo: add missing documentation
Taku Izumi [Fri, 19 Aug 2011 08:53:22 +0000 (16:53 +0800)]
schedinfo: add missing documentation

This patch adds the missing documentation about the scheduler parameter
"vcpu_period" and "vcpu_quota".

13 years agomaint: ignore generated file
Eric Blake [Thu, 18 Aug 2011 23:03:26 +0000 (17:03 -0600)]
maint: ignore generated file

I did 'git add .' while in the middle of 'make syntax-check', and
it picked up a temporary file that should not be committed.

* .gitignore: Ignore sc_* from syntax check.

13 years agobuild: fix virnetsocket on mingw
Eric Blake [Wed, 17 Aug 2011 17:52:38 +0000 (11:52 -0600)]
build: fix virnetsocket on mingw

Regression introduced in commit 5d30db0.

* src/rpc/virnetsocket.c (virNetSocketNewListenUNIX) [WIN32]: Use
correct signature.

13 years agobuild: fix virpidfile on mingw
Eric Blake [Wed, 17 Aug 2011 17:46:35 +0000 (11:46 -0600)]
build: fix virpidfile on mingw

Regression introduced in commit b7e5ca4.

Mingw lacks kill(), but we were only using it for a sanity check;
so we can go with one less check.

Also, on OOM error, this function should outright fail rather than
claim that the pid file was successfully read.

* src/util/virpidfile.c (virPidFileReadPathIfAlive): Skip kill
call where unsupported, and report error on OOM.

13 years agoEnsure async packets never get marked for sync replies
Daniel P. Berrange [Tue, 16 Aug 2011 23:22:44 +0000 (16:22 -0700)]
Ensure async packets never get marked for sync replies

If a client had initiated a stream abort, it will have a call
waiting for a reply in the queue. If more data continues to
arrive on the stream, the abort command could mistakenly get
signalled as complete. Remove the code from async data processing
that looked for waiting calls. Add a sanity check to ensure no
async call can ever be marked as needing a reply

* src/rpc/virnetclient.c: Ensure async data packets can't
  trigger a reply

13 years agoDon't attempt to read from a stream if it is closed
Daniel P. Berrange [Tue, 16 Aug 2011 23:20:58 +0000 (16:20 -0700)]
Don't attempt to read from a stream if it is closed

The I/O event callback processes incoming packets first, and then
does outgoing packets. If the incoming packet caused the stream to
close, then the attempt to process outgoing data resulted in an
error. This caused libvirt to then send an error back to the client,
but the stream had already been stopped. This confused the client
since it sees 2 error events.

* daemon/stream.c: Don't attempt read if stream is closed

13 years agoqemu: disk migration verbose progress
Tom Vijlbrief [Wed, 17 Aug 2011 06:30:02 +0000 (08:30 +0200)]
qemu: disk migration verbose progress

A virsh command like:

migrate --live --copy-storage-all Guest qemu+ssh://user@host/system
--persistent --verbose

shows

Migration: [  0 %]

during the storage copy and does not start counting
until the ram transfer starts

Fix this by scraping optional disk transfer status, and adding it
into the progress meter.

13 years agovirsh: concatenate qemu-monitor-command arguments
Eric Blake [Fri, 5 Aug 2011 23:48:13 +0000 (17:48 -0600)]
virsh: concatenate qemu-monitor-command arguments

Call me lazy, but:

virsh qemu-monitor-command dom --hmp info status

is nicer than:

virsh qemu-monitor-command dom --hmp 'info status'

* tools/virsh.c (cmdQemuMonitorCommand): Allow multiple arguments,
for convenience.

13 years agoqemu: Init reattaching related members of pciDevice before reattach
Osier Yang [Wed, 17 Aug 2011 12:58:33 +0000 (20:58 +0800)]
qemu: Init reattaching related members of pciDevice before reattach

Otherwise the device will still be bound to pci-stub driver even
it's set as "managed=yes" when do detaching. Of course, it won't
triger any driver reprobing too.

13 years agovirsh: tweak misleading wording
Eric Blake [Tue, 16 Aug 2011 22:54:14 +0000 (16:54 -0600)]
virsh: tweak misleading wording

Fixes confusing docs introduced in commit 98369d3.

* tools/virsh.c (cmdSnapshotParent): Operates on named snapshot,
not current.

13 years agoTweak debugging message in RPC client code
Daniel P. Berrange [Tue, 16 Aug 2011 16:48:03 +0000 (09:48 -0700)]
Tweak debugging message in RPC client code

Make it clearer that a log message is for an outgoing message

13 years agoFix race condition in abort of stream
Daniel P. Berrange [Tue, 16 Aug 2011 16:44:28 +0000 (09:44 -0700)]
Fix race condition in abort of stream

If a stream gets a server initiated abort, the client may still
send an abort request before it receives the server side abort.
This causes the server to send back another abort for the
stream. Since the protocol defines that abort is the last thing
to be sent, the client gets confused by this second abort from
the server. If the stream is already shutdown, just drop any
client requested abort, rather than sending back another message.
This fixes the regression from previous versions.

Tested as follows

In one virsh session

  virsh # start foo
  virsh # console foo

In other virsh session

  virsh # destroy foo

The first virsh session should be able to continue issuing
commands without error. Prior to this patch it saw

  virsh # list
  error: Failed to list active domains
  error: An error occurred, but the cause is unknown

  virsh # list
  error: Failed to list active domains
  error: no call waiting for reply with prog 536903814 vers 1 serial 9

* src/rpc/virnetserverprogram.c: Drop abort requests
  for streams which no longer exist

13 years agoEnsure client streams are closed when marking a client for close
Daniel P. Berrange [Sun, 14 Aug 2011 22:44:45 +0000 (15:44 -0700)]
Ensure client streams are closed when marking a client for close

Every active stream results in a reference being held on the
virNetServerClientPtr object. This meant that if a client quit
with any streams active, although all I/O was stopped the
virNetServerClientPtr object would leak. This causes libvirtd
to leak any file handles associated with open streams when a
client quit

To fix this, when we call virNetServerClientClose there is a
callback invoked which lets the daemon release the streams
and thus the extra references

* daemon/remote.c: Add a hook to close all streams
* daemon/stream.c, daemon/stream.h: Add API for releasing
  all streams
* src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h:
  Allow registration of a hook to trigger when closing client

13 years agoEnsure stream is aborted when exiting console
Daniel P. Berrange [Tue, 1 Mar 2011 14:59:45 +0000 (14:59 +0000)]
Ensure stream is aborted when exiting console

After running 'virsh console' in interactive mode, there was a
missing call to virStreamAbort, which meant the server kept the
stream resources open

* tools/console.c: Abort stream when exiting

13 years agomaint: fix some compilation issues on non-linux platforms (part 2)
Stefan Berger [Tue, 16 Aug 2011 19:36:22 +0000 (15:36 -0400)]
maint: fix some compilation issues on non-linux platforms (part 2)

Get rid of the #if __linux__ check in virPidFileReadPathIfAlive that
was preventing a check of a symbolic link in /proc/<pid>/exe on
non-linux platforms against an expected executable. Replace
this with a run-time check testing whether the /proc/<pid>/exe is a
symbolic link and if so call the function doing the comparison
against the expected file the link is supposed to point to.

13 years agomaint: fix some compilation issues on non-linux platforms
Stefan Berger [Tue, 16 Aug 2011 17:54:15 +0000 (13:54 -0400)]
maint: fix some compilation issues on non-linux platforms

This patch fixes *some* compilation issues on non-Linux platforms (cygwin).

13 years agodaemon: Add early libvirtd start verbose errors.
Peter Krempa [Fri, 12 Aug 2011 11:41:29 +0000 (13:41 +0200)]
daemon: Add early libvirtd start verbose errors.

Early errors during start of libvirtd didn't have
an error reporting mechanism and caused libvirtd
to exit silently (only the return value indicated
an error).

Libvirt logging is initialized very early using
enviroment variables and the internal error reporting
API is used to report early errors.

 v2 changes:
 - print errors unconditionaly before logging starts
 - fix message to US spelling
 v2.5 changes:
 - initialize logging from enviroment
 - log all early errors using VIR_ERROR
 v3 changes:
 - move virSetLogFromEnv() after virInitialize()

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

13 years agomaint: add missing symbols
Stefan Berger [Tue, 16 Aug 2011 16:38:02 +0000 (12:38 -0400)]
maint: add missing symbols

Add missing symbols to libvirt_private.syms.

13 years agomacvtap: Fix getPhysfn to get the PF of a direct attach network interface
Roopa Prabhu [Tue, 16 Aug 2011 04:28:58 +0000 (21:28 -0700)]
macvtap: Fix getPhysfn to get the PF of a direct attach network interface

This patch renames getPhysfn to getPhysfnDev and adds code to get the
Physical function and Virtual Function index of the direct attach linkdev (if
the direct attach interface is a SRIOV VF). The idea is to send the port
profile message to a PF if the direct attach interface is a SRIOV VF.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
13 years agointerface: Add functions to get sriov PF/VF relationship of a net interface
Roopa Prabhu [Tue, 16 Aug 2011 04:28:53 +0000 (21:28 -0700)]
interface: Add functions to get sriov PF/VF relationship of a net interface

This patch adds the following functions to get PF/VF relationship of an SRIOV
network interface:
ifaceIsVirtualFunction: Function to check if a network interface is a SRIOV VF
ifaceGetVirtualFunctionIndex: Function to get VF index if a network interface is a SRIOV VF
ifaceGetPhysicalFunction: Function to get the PF net interface name of a SRIOV VF net interface

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
13 years agopci: Add helper functions for sriov devices
Roopa Prabhu [Tue, 16 Aug 2011 04:28:48 +0000 (21:28 -0700)]
pci: Add helper functions for sriov devices

This patch adds the following helper functions:
pciDeviceIsVirtualFunction: Function to check if a pci device is a sriov VF
pciGetVirtualFunctionIndex: Function to get the VF index of a sriov VF
pciDeviceNetName: Function to get the network device name of a pci device
pciConfigAddressCompare: Function to compare pci config addresses

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agopci: Move some pci sriov helper code out of node device driver to util/pci
Roopa Prabhu [Tue, 16 Aug 2011 04:28:43 +0000 (21:28 -0700)]
pci: Move some pci sriov helper code out of node device driver to util/pci

This patch moves some of the sriov related pci code from node_device driver
to src/util/pci.[ch]. Some functions had to go thru name and argument list
change to accommodate the move.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
13 years agomaint: ignore generated file
Eric Blake [Mon, 15 Aug 2011 20:42:43 +0000 (14:42 -0600)]
maint: ignore generated file

* .gitignore: Ignore qemu-sanlock.conf.

13 years agoqemu: support event_idx parameter for virtio disk and net devices
Laine Stump [Sat, 13 Aug 2011 06:32:45 +0000 (02:32 -0400)]
qemu: support event_idx parameter for virtio disk and net devices

In some versions of qemu, both virtio-blk-pci and virtio-net-pci
devices can have an event_idx setting that determines some details of
event processing. When it is enabled, it "reduces the number of
interrupts and exits for the guest". qemu will automatically enable
this feature when it is available, but there may be cases where this
new feature could actually make performance worse (NB: no such case
has been found so far).

As a safety switch in case such a situation is encountered in the
field, this patch adds a new attribute "event_idx" to the <driver>
element of both disk and interface devices. event_idx can be set to
"on" (to force event_idx on in case qemu has it disabled by default)
or "off" (for force event_idx off). In the case that event_idx support
isn't present in qemu, the attribute is ignored (this on the advice of
the qemu developer).

docs/formatdomain.html.in: document the new flag (marking it as
   "don't mess with this!"
docs/schemas/domain.rng: add event_idx in appropriate places
src/conf/domain_conf.[ch]: add event_idx to parser and formatter
src/libvirt_private.syms: export
   virDomainVirtioEventIdx(From|To)String
src/qemu/qemu_capabilities.[ch]: detect and report event_idx in
   disk/net
src/qemu/qemu_command.c: add event_idx parameter to qemu commandline
    when appropriate.
tests/qemuxml2argvdata/qemuxml2argv-event_idx.args,
tests/qemuxml2argvdata/qemuxml2argv-event_idx.xml,
tests/qemuxml2argvtest.c,
tests/qemuxml2xmltest.c: test cases for event_idx.

13 years agoqemu: error message should show uri instead of (null)
Peter Krempa [Mon, 15 Aug 2011 12:58:47 +0000 (14:58 +0200)]
qemu: error message should show uri instead of (null)

Fix pointer for error message uri if domain migration fails.

BZ# 730244

13 years agoqemu: Use fd: protocol for migration
Jiri Denemark [Thu, 11 Aug 2011 13:47:02 +0000 (15:47 +0200)]
qemu: Use fd: protocol for migration

By opening a connection to remote qemu process ourselves and passing the
socket to qemu we get much better errors than just "migration failed"
when the connection is opened by qemu.

13 years agoqemu: Use virNetSocket for tunneled migration
Jiri Denemark [Fri, 12 Aug 2011 08:54:05 +0000 (10:54 +0200)]
qemu: Use virNetSocket for tunneled migration

13 years agoqemu: Refactor do{Tunnel,Native}Migrate functions
Jiri Denemark [Thu, 11 Aug 2011 12:36:04 +0000 (14:36 +0200)]
qemu: Refactor do{Tunnel,Native}Migrate functions

The core of these two functions is very similar and most of it is even
exactly the same. Factor out the core functionality into a separate
function to remove code duplication and make further changes easier.

13 years agoSupport changing UNIX socket owner in virNetSocketNewListenUNIX
Jiri Denemark [Fri, 12 Aug 2011 09:10:19 +0000 (11:10 +0200)]
Support changing UNIX socket owner in virNetSocketNewListenUNIX

This patch allows owner's UID to be changed as well.

13 years agoAdd backlog parameter to virNetSocketListen
Jiri Denemark [Fri, 12 Aug 2011 09:07:51 +0000 (11:07 +0200)]
Add backlog parameter to virNetSocketListen

So that callers can change the default value.

13 years agoAdd API for duplicating a socket/client file descriptor
Daniel P. Berrange [Thu, 7 Jul 2011 14:17:21 +0000 (15:17 +0100)]
Add API for duplicating a socket/client file descriptor

* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add
  virNetSocketDupFD()
* src/rpc/virnetclient.c, src/rpc/virnetclient.h: Add
  virNetClientDupFD() and virNetClientGetFD()

13 years agolibvirtd.init.in: stop/restart() - wrong return value in case of failure
Douglas Schilling Landgraf [Mon, 15 Aug 2011 07:44:39 +0000 (15:44 +0800)]
libvirtd.init.in: stop/restart() - wrong return value in case of failure

The function stop() was always returning 0 (OK) from killproc() even
in case of error.

13 years agodaemon: Fix regression of libvirtd reloading support
Osier Yang [Mon, 15 Aug 2011 07:40:46 +0000 (15:40 +0800)]
daemon: Fix regression of libvirtd reloading support

This is introduced by commit df0b57a95a, which forgot to
add signal handler for SIGHUP.

A simple reproduce method:

1) Create a domain XML under /etc/libvirt/qemu
2) % kill -SIGHUP $(pidof libvirtd)
3) % virsh list --all (the new created domain XML is not listed)

13 years agomaint: let emacs avoid tabs in rng files
Eric Blake [Sat, 13 Aug 2011 13:27:23 +0000 (07:27 -0600)]
maint: let emacs avoid tabs in rng files

* .dir-locals.el: Add nxml-mode preferences.

13 years agoSwap virDomain / virFomainSnapshot declaration
Philipp Hahn [Tue, 12 Apr 2011 06:06:18 +0000 (08:06 +0200)]
Swap virDomain / virFomainSnapshot declaration

In preparation for storing the domain description with the snapshot,
swap the order of declaration.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agobuild: fix recent build failures
Eric Blake [Fri, 12 Aug 2011 21:54:49 +0000 (15:54 -0600)]
build: fix recent build failures

With gcc 4.5.1:

util/virpidfile.c: In function 'virPidFileAcquirePath':
util/virpidfile.c:308:66: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]

Then in tests/commandtest.c, the new virPidFile APIs need to be used.

* src/util/virpidfile.c (virPidFileAcquirePath): Move verify to
top level.
* tests/commandtest.c: Use new pid APIs.

13 years agoConvert libvirtd to use crash-safe pidfile APIs
Daniel P. Berrange [Fri, 5 Aug 2011 14:11:11 +0000 (15:11 +0100)]
Convert libvirtd to use crash-safe pidfile APIs

Remove the current libvirtd pidfile handling code, in favour of
calling out to the new APIs. This ensures libvirtd's pidfile
handling is crashsafe

This also means that the non-root libvirtd instances (for handling
qemu:///session URIs) can now safely use pidfiles without racing

* daemon/libvirtd.c: Switch to use virPidFileAcquire and
  virPidFileRelease

13 years agoAdd some APIs which use locking for crashsafe pidfile handling
Daniel P. Berrange [Wed, 6 Jul 2011 16:12:26 +0000 (17:12 +0100)]
Add some APIs which use locking for crashsafe pidfile handling

In daemons using pidfiles to protect against concurrent
execution there is a possibility that a crash may leave a stale
pidfile on disk, which then prevents later restart of the daemon.

To avoid this problem, introduce a pair of APIs which make
use of virFileLock to ensure crash-safe & race condition-safe
pidfile acquisition & releae

* src/libvirt_private.syms, src/util/virpidfile.c,
  src/util/virpidfile.h: Add virPidFileAcquire and virPidFileRelease

13 years agoIntroduce functions for checking whether a pidfile is valid
Daniel P. Berrange [Fri, 5 Aug 2011 13:41:25 +0000 (14:41 +0100)]
Introduce functions for checking whether a pidfile is valid

In some cases the caller of virPidFileRead might like extra checks
to determine whether the pid just read is really the one they are
expecting. This adds virPidFileReadIfAlive which will check whether
the pid is still alive with kill(0, -1), and (on linux only) will
look at /proc/$PID/path

* libvirt_private.syms, util/virpidfile.c, util/virpidfile.h: Add
  virPidFileReadIfValid and virPidFileReadPathIfValid
* network/bridge_driver.c: Use new APIs to check PID validity

13 years agoMove pidfile functions into util/virpidfile.{c,h}
Daniel P. Berrange [Fri, 5 Aug 2011 13:13:12 +0000 (14:13 +0100)]
Move pidfile functions into util/virpidfile.{c,h}

The functions for manipulating pidfiles are in util/util.{c,h}.
We will shortly be adding some further pidfile related functions.
To avoid further growing util.c, this moves the pidfile related
functions into a dedicated virpidfile.{c,h}. The functions are
also all renamed to have 'virPidFile' as their name prefix

* util/util.h, util/util.c: Remove all pidfile code
* util/virpidfile.c, util/virpidfile.h: Add new APIs for pidfile
  handling.
* lxc/lxc_controller.c, lxc/lxc_driver.c, network/bridge_driver.c,
  qemu/qemu_process.c: Add virpidfile.h include and adapt for API
  renames

13 years agoAdd virFileLock and virFileUnlock APIs
Daniel P. Berrange [Wed, 6 Jul 2011 16:06:58 +0000 (17:06 +0100)]
Add virFileLock and virFileUnlock APIs

Add some simple wrappers around the fcntl() discretionary file
locking capability.

* src/util/util.c, src/util/util.h, src/libvirt_private.syms: Add
  virFileLock and virFileUnlock APIs

13 years agovirsh: fix dead store
Eric Blake [Fri, 12 Aug 2011 18:07:39 +0000 (12:07 -0600)]
virsh: fix dead store

Two copy-and-paste bugs in a row.  :(

* tools/virsh.c (cmdUndefine): Also avoid dead store.

13 years agovirsh: fix logic bug
Eric Blake [Fri, 12 Aug 2011 17:39:35 +0000 (11:39 -0600)]
virsh: fix logic bug

Bug introduced in commit 9a0ec36.

* tools/virsh.c (cmdUndefine): Add missing line.

13 years agovbox, xenapi: add virDomainUndefineFlags
Eric Blake [Thu, 11 Aug 2011 21:44:05 +0000 (15:44 -0600)]
vbox, xenapi: add virDomainUndefineFlags

We forgot to add virDomainUndefineFlags for a couple of hypervisors.
This wires up trivial versions (since neither hypervisor supports
managed save yet, they do not need to support any flags).

* src/vbox/vbox_tmpl.c (vboxDomainCreateXML): Update caller.
(vboxDomainUndefine): Move guts...
(vboxDomainUndefineFlags): ...to new function.
* src/xenapi/xenapi_driver.c (xenapiDomainUndefine)
(xenapiDomainUndefineFlags): Likewise.

13 years agovirsh: don't reject undefine on active domain
Eric Blake [Thu, 11 Aug 2011 22:48:00 +0000 (16:48 -0600)]
virsh: don't reject undefine on active domain

The public API documents that undefine may be used to transition a
running persistent domain into a transient one.  Many drivers still
do not support this usage, but virsh shouldn't be getting in the
way of those that do support it.

This also drops a redundant conditional; vshCommandOptString
guaranteed that name was non-NULL.

* tools/virsh.c (cmdUndefine): Allow undefine on active domains;
the drivers may still reject it, but it is a valid API usage.
* tests/undefine (error): Fix the test to match.

13 years agoImprove tokenizing of linkable terms
Philipp Hahn [Thu, 11 Aug 2011 12:44:00 +0000 (14:44 +0200)]
Improve tokenizing of linkable terms

Currently only tabs and blanks are used for tokenizing the description,
which breaks when a term is at the end of a line or has () appended to
it.
1. Use also other white space characters such as new-lines and carriage
   return for splitting.
2. Remove some common non-word characters from the token before lookup.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agoAdd some docs about the RPC protocol and APIs
Daniel P. Berrange [Thu, 11 Aug 2011 15:11:31 +0000 (16:11 +0100)]
Add some docs about the RPC protocol and APIs

* remote.html.in: Remove obsolete notes about internals of the
  RPC protocol
* internals/rpc.html.in: Extensive docs on RPC protocol/API
* sitemap.html.in: Add new page

13 years agoAlign table cells on top
Philipp Hahn [Thu, 11 Aug 2011 12:40:38 +0000 (14:40 +0200)]
Align table cells on top

When the description of an entry is too long and needs multiple lines,
all other table cells of the same row are currently vertically aligned
on center. Without row borders or different background colors for
alternating rows this is hard to read.

Change the style-sheet to align the table cells of a row on top.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agovirsh: Add dir type for listing volumes with vol-list
Peter Krempa [Thu, 11 Aug 2011 09:37:18 +0000 (11:37 +0200)]
virsh: Add dir type for listing volumes with vol-list

Fix of output of detailed volume list. BZ #727088

13 years agostorage: Directory shouldn't be listed as type 'file'
Peter Krempa [Thu, 11 Aug 2011 09:37:17 +0000 (11:37 +0200)]
storage: Directory shouldn't be listed as type 'file'

Fix internals of libvirt for new storage volume type.
Libvirt reported an invalid type of the volume.

BZ #727088

13 years agovirsh: add snapshot-parent
Eric Blake [Wed, 10 Aug 2011 23:18:55 +0000 (17:18 -0600)]
virsh: add snapshot-parent

Down the road, I want to add virDomainSnapshotGetParent, and use
the new API rather than xml scraping; but this virsh command can
be implemented even without the new API.

* tools/virsh.c (cmdSnapshotParent): New command.
* tools/virsh.pod (snapshot-parent): Document it.

13 years agoqemu: silence clang false positive
Eric Blake [Fri, 5 Aug 2011 15:10:18 +0000 (09:10 -0600)]
qemu: silence clang false positive

Our logic throws off analyzer tools:

ptr var = NULL;
if (flags == 0) flags = live ? _LIVE : _CONFIG;
if (flags & _LIVE) do stuff
if (flags & _CONFIG) var = non-null;
if (flags & _LIVE) do more stuff
else if (flags & _CONFIG) use var

the tools keep thinking that var can still be NULL in the last
if clause, adding the hint shuts them up.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Add a
static analysis hint.

13 years agonetwork: eliminate potential memory leak on parse failure
Laine Stump [Thu, 11 Aug 2011 03:28:05 +0000 (23:28 -0400)]
network: eliminate potential memory leak on parse failure

While the first encountered dns host record is being parsed, it's
possible for virNetworkDef::hosts to point to memory that has been
allocated, but virNetworkDef::nhosts to still be 0. If there is a
failure during that time, virNetworkDef::hosts will be leaked.

Although this isn't currently the case for virNetworkDef::txtrecords,
it could become that way through future re-factoring, and it hurts
nothing to restructure the freeing of txtrecord data to match that of
hosts data.

13 years agonwfilter: tolerate disappearing interfaces while instantiating filter
Stefan Berger [Thu, 11 Aug 2011 10:56:50 +0000 (06:56 -0400)]
nwfilter: tolerate disappearing interfaces while instantiating filter

When instantiating a filter, a VM may disappear and remove its tap interfaces. Tolerate this case and don't report an error.

13 years agoqemu: Fix -chardev udp if parameters are omitted
Cole Robinson [Thu, 11 Aug 2011 07:19:51 +0000 (15:19 +0800)]
qemu: Fix -chardev udp if parameters are omitted

The following XML:

    <serial type='udp'>
      <source mode='connect' service='9999'/>
    </serial>

is accepted by domain_conf.c but maps to the qemu command line:

-chardev udp,host=127.0.0.1,port=2222,localaddr=(null),localport=(null)

qemu can cope with everything omitting except the connection port, which
seems to also be the intent of domain_conf validation, so let's not
generate bogus command lines for that case.
The defaults are empty strings for addresses and 0 for the localport

Additionally, tweak the qemu cli parsing to handle omitted host
parameters
for -serial udp

13 years agodocs: use IPv6 addresses in range reserved for documentation
Laine Stump [Thu, 11 Aug 2011 04:19:11 +0000 (00:19 -0400)]
docs: use IPv6 addresses in range reserved for documentation

Someone in an IRC channel or an email pointed out a few days ago that
the examples of IPv6 addresses in the libvirt documentation were not
in the officially reserved "documentation" range. This addresses their
concern.

13 years agovirsh: add virsh snapshot-current --name
Eric Blake [Wed, 10 Aug 2011 03:10:25 +0000 (21:10 -0600)]
virsh: add virsh snapshot-current --name

Sometimes, full XML is too much; since most snapshot commands
operate on a snapshot name, there should be an easy way to get
at the current snapshot's name.  For example:

virsh snapshot-revert dom `virsh snapshot-current dom --name`

* tools/virsh.c (cmdSnapshotCurrent): Add an option.
* tools/virsh.pod (snapshot-current): Document it.

13 years agovirsh: fix snapshot-create-as to handle arbitrary names
Eric Blake [Wed, 10 Aug 2011 23:00:26 +0000 (17:00 -0600)]
virsh: fix snapshot-create-as to handle arbitrary names

Found this working on the next patch to use xpath to parse
arbitrary names back out.

* tools/virsh.c (cmdSnapshotCreateAs): Escape user input.

13 years agomanagedsave: prohibit use on transient domains
Eric Blake [Wed, 10 Aug 2011 14:51:36 +0000 (08:51 -0600)]
managedsave: prohibit use on transient domains

Transient domains reject attempts to set autostart, and using
virDomainCreate to restart a domain only works on persistent
domains.  Therefore, managed save makes no sense on transient
domains, and should be rejected up front rather than creating
an otherwise unrecoverable managed save file.

Besides, transient domains imply that a lot more management is
being done by the upper layer; this includes the assumption
that the upper layer is okay managing the saved state file
created by virDomainSave, and does not need to use managed save.

* src/libvirt.c: Document that transient domains are incompatible
with managed save.
* src/qemu/qemu_driver.c (qemuDomainManagedSave): Enforce it.
* src/libxl/libxl_driver.c (libxlDomainManagedSave): Likewise.

13 years agodocs: describe new virtual switch configuration in network XML docs
Laine Stump [Wed, 10 Aug 2011 05:41:19 +0000 (01:41 -0400)]
docs: describe new virtual switch configuration in network XML docs

This should have been done with the rest of the patch for virtual
switch / network device abstraction. If documents the new elements
(and new usage of existing elements) in the <network> XML to support
libvirt networks that use existing host bridges and macvtap direct
connections, as well as the new <portgroup> element.

13 years agoBugfix: Check stdoutWatch before removing the handler.
Juerg Haefliger [Wed, 10 Aug 2011 15:03:23 +0000 (17:03 +0200)]
Bugfix: Check stdoutWatch before removing the handler.

13 years agoqemu: minor formatting cleanup
Eric Blake [Fri, 5 Aug 2011 18:03:44 +0000 (12:03 -0600)]
qemu: minor formatting cleanup

I noticed some inconsistent use of 'else'.

* src/qemu/qemu_driver.c (qemuCPUCompare)
(qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot)
(qemuDomainSnapshotDiscard): Match coding conventions.

13 years agoFix memory leak while scanning snapshots
Philipp Hahn [Tue, 9 Aug 2011 13:47:57 +0000 (15:47 +0200)]
Fix memory leak while scanning snapshots

If a snapshot with the name already exists, virDomainSnapshotAssignDef()
just returns NULL, in which case the snapshot definition is leaked.
Currently this leak is not a big problem, since qemuDomainSnapshotLoad()
is only called once during initial startup of libvirtd.

Signed-off-by: Philipp Hahn <hahn@univention.de>
13 years agobuild: fix regression in large file support
Eric Blake [Mon, 8 Aug 2011 15:52:03 +0000 (09:52 -0600)]
build: fix regression in large file support

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

13 years agoAllow use of file images for LXC container filesystems
Daniel P. Berrange [Thu, 4 Aug 2011 09:13:02 +0000 (10:13 +0100)]
Allow use of file images for LXC container filesystems

A previous commit gave the LXC driver the ability to mount
block devices for the container filesystem. Through use of
the loopback device functionality, we can build on this to
support use of plain file images for LXC filesytems.

By setting the LO_FLAGS_AUTOCLEAR flag we can ensure that
the loop device automatically disappears when the container
dies / shuts down

* src/lxc/lxc_container.c: Raise error if we see a file
  based filesystem, since it should have been turned into
  a loopback device already
* src/lxc/lxc_controller.c: Rewrite any filesystems of
  type=file, into type=block, by binding the file image
  to a free loop device

13 years agoFix typo in LXC cgroups setup error message
Daniel P. Berrange [Thu, 4 Aug 2011 14:34:07 +0000 (15:34 +0100)]
Fix typo in LXC cgroups setup error message

* src/lxc/lxc_controller.c: s/PYT/PTY/

13 years agoAllow use of block devices for guest filesystem
Daniel P. Berrange [Fri, 22 Jul 2011 12:02:51 +0000 (13:02 +0100)]
Allow use of block devices for guest filesystem

Currently the LXC driver can only populate filesystems from
host filesystems, using bind mounts. This patch allows host
block devices to be mounted. It autodetects the filesystem
format at mount time, and adds the block device to the cgroups
ACL. Example usage is

    <filesystem type='block' accessmode='passthrough'>
      <source dev='/dev/sda1'/>
      <target dir='/home'/>
    </filesystem>

* src/lxc/lxc_container.c: Mount block device filesystems
* src/lxc/lxc_controller.c: Add block device filesystems
  to cgroups ACL

13 years agoDon't mount /dev for application containers
Daniel P. Berrange [Thu, 4 Aug 2011 16:16:56 +0000 (17:16 +0100)]
Don't mount /dev for application containers

An application container shouldn't get a private /dev. Fix
the regression from 6d37888e6a35a37e6faf7c0a1b1b4d9a5dee1285

* src/lxc/lxc_container.c: Don't mount /dev for app containers

13 years agoqemu: Avoid overwriting errors from virGetHostname
Jiri Denemark [Wed, 3 Aug 2011 10:00:17 +0000 (12:00 +0200)]
qemu: Avoid overwriting errors from virGetHostname

13 years agoqemu: avoid crash on process attach
Eric Blake [Thu, 4 Aug 2011 20:07:58 +0000 (14:07 -0600)]
qemu: avoid crash on process attach

Detected by ccc-analyzer, reported by Alex Jia.

qemuProcessStart always calls qemuProcessWaitForMonitor with a
non-negative position, but qemuProcessAttach always calls with -1.
In the latter case, there is no log file we can scrape, so we
also should not be trying to scrape the logs if the qemu process
died at the very end.

* src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Don't try
to read from log in qemuProcessAttach case.

13 years agonetwork: eliminate lag in updating dnsmasq hosts files
Laine Stump [Wed, 3 Aug 2011 19:33:24 +0000 (15:33 -0400)]
network: eliminate lag in updating dnsmasq hosts files

This addresses https://bugzilla.redhat.com/show_bug.cgi?id=713728

When "defining" a new network (or one that exists but isn't currently
active) the new definition is stored in network->def, but for a
network that already exists and is active, the new definition is
stored in network->newDef, and then moved over to network->def as soon
as the network is destroyed.

However, the code that writes the dhcp and dns hosts files used by
dnsmasq was always using network->def for its information, even when
the new data was actually in network->newDef, so the hosts files
always lagged one edit behind the definition.

This patch changes the code to keep the pointer to the new definition
after it's been assigned into the network, and use it directly
(regardless of whether it's stored in network->newDef or network->def)
to construct the hosts files.

13 years agoqemu: avoid dead store in qemuMonitorTextBlockJob
Alex Jia [Thu, 4 Aug 2011 05:30:19 +0000 (13:30 +0800)]
qemu: avoid dead store in qemuMonitorTextBlockJob

Value stored to 'ret' is never read, so remove this dead assignment.

* src/qemu/qemu_monitor_text.c: kill dead assignment.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: avoid dead store in qemuProcessStart
Alex Jia [Thu, 4 Aug 2011 05:30:18 +0000 (13:30 +0800)]
qemu: avoid dead store in qemuProcessStart

Value stored to 'ret' is never read, in fact, 'cleanup' section will
directly return -1 when function is fail, so remove this dead assignment.

* src/qemu/qemu_process.c: kill dead assignment.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agorpc:fix sasl session relocking intead of unlocking it
Guannan Ren [Thu, 4 Aug 2011 13:27:52 +0000 (21:27 +0800)]
rpc:fix sasl session relocking intead of unlocking it

When trying to use any SASL authentication for TCP sockets by
setting auth_tls = "sasl" in libvirtd.conf on server side, the
client will hang because of the sasl session relocking other than
dropping the lock when exiting virNetSASLSessionExtKeySize()
* src/rpc/virnetsaslcontext.c: virNetSASLSessionExtKeySize drop the
  lock on exit

13 years agodaemon: Unlink unix socket paths on shutdown
Osier Yang [Thu, 4 Aug 2011 08:54:58 +0000 (16:54 +0800)]
daemon: Unlink unix socket paths on shutdown

This patch introduces a internal RPC API "virNetServerClose", which
is standalone with "virNetServerFree".  it closes all the socket fds,
and unlinks the unix socket paths, regardless of whether the socket
is still referenced or not.

This is to address regression bug:
https://bugzilla.redhat.com/show_bug.cgi?id=725702

13 years agobuild: update to latest gnulib
Eric Blake [Wed, 3 Aug 2011 17:07:00 +0000 (11:07 -0600)]
build: update to latest gnulib

I noticed that with 0.9.4, gnulib ended up replacing pthread_sigmask
on glibc, even though glibc's works perfectly fine.  It turns out
to have been an upstream gnulib bug.

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

13 years agoFix detection of GnuTLS 1.x.y
Matthias Bolte [Wed, 3 Aug 2011 16:23:21 +0000 (18:23 +0200)]
Fix detection of GnuTLS 1.x.y

Detection based on gnutls_session doesn't work because GnuTLS 2.x.y
comes with a compat.h that defines gnutls_session to gnutls_session_t.

Instead detect this based on LIBGNUTLS_VERSION_MAJOR. Move this from
configure/config.h to gnutls_1_0_compat.h and make sure that all users
include gnutls_1_0_compat.h properly.

Also fix header guard in gnutls_1_0_compat.h.

13 years agoRelease of libvirt-0.9.4
Daniel Veillard [Wed, 3 Aug 2011 03:02:42 +0000 (11:02 +0800)]
Release of libvirt-0.9.4

* configure.ac docs/news.html.in libvirt.spec.in: updates for new
  release
* po/*.po*: pulled translations from the transifex teams and regenerated
  localizations

13 years agoqemu: silence coverity false positives
Eric Blake [Tue, 2 Aug 2011 22:45:23 +0000 (16:45 -0600)]
qemu: silence coverity false positives

Coverity gets confused by our logic.  Add some hints to silence
false positives.

* src/qemu/qemu_driver.c (qemudDomainGetVcpuPinInfo): Add hint.
(qemuDomainGetMemoryParameters): Likewise.

13 years agoutil: plug memory leak
Eric Blake [Tue, 2 Aug 2011 22:21:37 +0000 (16:21 -0600)]
util: plug memory leak

Leak detected by Coverity; only possible on unlikely ptsname_r
failure.  Additionally, the man page for ptsname_r states that
failure is merely non-zero, not necessarily -1.

* src/util/util.c (virFileOpenTtyAt): Avoid leak on ptsname_r
failure.

13 years agointerface: drop dead code
Eric Blake [Tue, 2 Aug 2011 22:08:05 +0000 (16:08 -0600)]
interface: drop dead code

Coverity detected that ifaceGetNthParent had already dereferenced
'nth' prior to the conditional; all callers already complied with
passing a non-NULL pointer so make this part of the contract.

* src/util/interface.h (ifaceGetNthParent): Add annotations.
* src/util/interface.c (ifaceGetNthParent): Drop useless null check.