Commit Graph

7935 Commits

Author SHA1 Message Date
Osier Yang
aaa93ab6fa qemu: Allow to undefine a running domain 2011-08-19 21:49:37 +08:00
Osier Yang
ea92a34d1d openvz: Allow to undefine a running domain 2011-08-19 21:48:47 +08:00
Osier Yang
b375fc01e2 lxc: Allow to undefine a running domain 2011-08-19 21:47:33 +08:00
Osier Yang
0f407570b4 libxl: Allow to undefine a running domain.
Undefining a running domain will convert it to trasient, but keep
the domain still running.
2011-08-19 21:46:22 +08:00
Osier Yang
4ffa7530a4 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".
2011-08-19 21:34:59 +08:00
Eric Blake
b14df8bec0 build: fix compilation on mingw64
* .gnulib: Update to latest, for getcwd fixes.
* bootstrap: Resync to gnulib.
2011-08-19 07:20:10 -06:00
Michal Privoznik
b32f8b1989 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.
2011-08-19 11:10:31 +02:00
Michal Privoznik
74c7567133 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.
2011-08-19 10:58:51 +02:00
Taku Izumi
4dec4d414f schedinfo: add missing documentation
This patch adds the missing documentation about the scheduler parameter
"vcpu_period" and "vcpu_quota".
2011-08-19 16:53:22 +08:00
Eric Blake
322d1cfc78 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.
2011-08-18 17:34:56 -06:00
Eric Blake
310b09ec27 build: fix virnetsocket on mingw
Regression introduced in commit 5d30db0.

* src/rpc/virnetsocket.c (virNetSocketNewListenUNIX) [WIN32]: Use
correct signature.
2011-08-17 11:52:38 -06:00
Eric Blake
c811de8fb7 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.
2011-08-17 11:51:24 -06:00
Daniel P. Berrange
984840a2c2 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
2011-08-17 09:44:12 -07:00
Daniel P. Berrange
dbf04dac3e 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
2011-08-17 09:44:12 -07:00
Tom Vijlbrief
108ca33357 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.
2011-08-17 08:01:12 -06:00
Eric Blake
531c858131 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.
2011-08-17 07:45:32 -06:00
Osier Yang
2ce90ea296 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.
2011-08-17 20:58:33 +08:00
Eric Blake
cfbccb3821 virsh: tweak misleading wording
Fixes confusing docs introduced in commit 98369d3.

* tools/virsh.c (cmdSnapshotParent): Operates on named snapshot,
not current.
2011-08-16 17:22:41 -06:00
Daniel P. Berrange
d48a0597e3 Tweak debugging message in RPC client code
Make it clearer that a log message is for an outgoing message
2011-08-16 14:38:11 -07:00
Daniel P. Berrange
b4633113fc 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
2011-08-16 14:38:11 -07:00
Daniel P. Berrange
f682c25308 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
2011-08-16 14:38:11 -07:00
Daniel P. Berrange
3cf37700cd 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
2011-08-16 14:38:11 -07:00
Stefan Berger
57c7b40b76 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.
2011-08-16 15:36:22 -04:00
Stefan Berger
f4765b691d maint: fix some compilation issues on non-linux platforms
This patch fixes *some* compilation issues on non-Linux platforms (cygwin).
2011-08-16 13:54:15 -04:00
Peter Krempa
6452b1eb5c 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
2011-08-16 11:03:36 -06:00
Stefan Berger
34a01fc431 maint: add missing symbols
Add missing symbols to libvirt_private.syms.
2011-08-16 12:38:02 -04:00
Roopa Prabhu
5abbf7b958 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>
2011-08-16 11:59:00 -04:00
Roopa Prabhu
cd5544d412 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>
2011-08-16 11:59:00 -04:00
Roopa Prabhu
17d64cab16 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>
2011-08-16 11:59:00 -04:00
Roopa Prabhu
03172265d3 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>
2011-08-16 11:59:00 -04:00
Eric Blake
8231539830 maint: ignore generated file
* .gitignore: Ignore qemu-sanlock.conf.
2011-08-15 14:42:43 -06:00
Laine Stump
73c0a148af 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.
2011-08-15 09:35:42 -04:00
Peter Krempa
d17101e011 qemu: error message should show uri instead of (null)
Fix pointer for error message uri if domain migration fails.

BZ# 730244
2011-08-15 15:30:03 +02:00
Jiri Denemark
3261761794 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.
2011-08-15 15:21:31 +02:00
Jiri Denemark
e8989ae4e2 qemu: Use virNetSocket for tunneled migration 2011-08-15 15:21:31 +02:00
Jiri Denemark
52e2918ae1 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.
2011-08-15 15:21:31 +02:00
Jiri Denemark
5d30db09a6 Support changing UNIX socket owner in virNetSocketNewListenUNIX
This patch allows owner's UID to be changed as well.
2011-08-15 15:21:31 +02:00
Jiri Denemark
70e4295bc4 Add backlog parameter to virNetSocketListen
So that callers can change the default value.
2011-08-15 15:21:31 +02:00
Daniel P. Berrange
f4287c7676 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()
2011-08-15 15:21:26 +02:00
Douglas Schilling Landgraf
841a403f94 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.
2011-08-15 15:44:39 +08:00
Osier Yang
9e093f0b4c 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)
2011-08-15 15:40:46 +08:00
Eric Blake
2a48b59dec maint: let emacs avoid tabs in rng files
* .dir-locals.el: Add nxml-mode preferences.
2011-08-13 08:56:26 -06:00
Philipp Hahn
24d3738f2d 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>
2011-08-12 16:17:28 -06:00
Eric Blake
be427e8b0b 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.
2011-08-12 16:16:29 -06:00
Daniel P. Berrange
c8a3a26513 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
2011-08-12 20:37:00 +01:00
Daniel P. Berrange
e1da464d88 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
2011-08-12 20:37:00 +01:00
Daniel P. Berrange
b7e5ca48f8 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
2011-08-12 20:37:00 +01:00
Daniel P. Berrange
f80a4ed77a 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
2011-08-12 20:37:00 +01:00
Daniel P. Berrange
e48427051d 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
2011-08-12 20:37:00 +01:00
Eric Blake
e08adab31d virsh: fix dead store
Two copy-and-paste bugs in a row.  :(

* tools/virsh.c (cmdUndefine): Also avoid dead store.
2011-08-12 12:27:06 -06:00