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

13 years agorpc: silence coverity false positives
Eric Blake [Tue, 2 Aug 2011 22:02:48 +0000 (16:02 -0600)]
rpc: silence coverity false positives

In virNetServerNew, Coverity didn't realize that srv->mdsnGroupName
can only be non-NULL if mdsnGroupName was non-NULL.

In virNetServerRun, Coverity didn't realize that the array is non-NULL
if the array count is non-zero.

* src/rpc/virnetserver.c (virNetServerNew): Use alternate pointer.
(virNetServerRun): Give coverity a hint.

13 years agorpc: avoid null deref
Eric Blake [Tue, 2 Aug 2011 21:57:19 +0000 (15:57 -0600)]
rpc: avoid null deref

Detected by Coverity.

* src/rpc/virnetserverclient.c (virNetServerClientDispatchRead):
Avoid null deref on OOM.

13 years agobuild: silence coverity false positives
Eric Blake [Tue, 2 Aug 2011 20:26:17 +0000 (14:26 -0600)]
build: silence coverity false positives

Coverity complained that 395 out of 409 virAsprintf calls are
checked, and therefore assumed that the remaining cases are bugs
waiting to happen.  But in each of these cases, a failed virAsprintf
will properly set the target string to NULL, and pass on that
failure to the caller, without wasting efforts to check the call.
Adding the ignore_value silences Coverity.

* src/conf/domain_audit.c (virDomainAuditGetRdev): Ignore
virAsprintf return value, when it behaves like we need.
* src/network/bridge_driver.c (networkDnsmasqLeaseFileNameDefault)
(networkRadvdConfigFileName, networkBridgeDummyNicName)
(networkRadvdPidfileBasename): Likewise.
* src/util/storage_file.c (absolutePathFromBaseFile): Likewise.
* src/openvz/openvz_driver.c (openvzGenerateContainerVethName):
Likewise.
* src/util/command.c (virCommandTranslateStatus): Likewise.

13 years agoqemu: avoid memory leaks
Eric Blake [Tue, 2 Aug 2011 20:07:25 +0000 (14:07 -0600)]
qemu: avoid memory leaks

Quite a few leaks detected by coverity.  For chr, the leaks were
close enough to the allocations to plug in place; for disk, the
leaks were separated from the allocation by enough other lines with
intermediate failure cases that I refactored the cleanup instead.

* src/qemu/qemu_command.c (qemuParseCommandLine): Plug leaks.

13 years agoqemu: plug child process leak on domain core dump
Eric Blake [Tue, 2 Aug 2011 20:35:40 +0000 (14:35 -0600)]
qemu: plug child process leak on domain core dump

Detected by Coverity.  Leak introduced by typo in commit 58e668d2.

* src/qemu/qemu_driver.c (doCoreDump): Use correct function.

13 years agoqemu: remove dead code
Eric Blake [Tue, 2 Aug 2011 20:18:01 +0000 (14:18 -0600)]
qemu: remove dead code

Warning detected by Coverity.  No need for the NULL check, and
removing it silences the warning without any semantic change.

* src/qemu/qemu_migration.c (qemuMigrationFinish): All entries to
endjob had non-NULL vm.

13 years agoconf: avoid memory leak on disk operations
Eric Blake [Tue, 2 Aug 2011 19:48:43 +0000 (13:48 -0600)]
conf: avoid memory leak on disk operations

Detected by Coverity.  Leak on meta introduced in commit 85aa40e.

* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Plug leak.

13 years agorpc: avoid crash on error
Eric Blake [Tue, 2 Aug 2011 19:36:14 +0000 (13:36 -0600)]
rpc: avoid crash on error

Detected by Coverity.  Freeing the wrong variable results in both
a memory leak and the likelihood of the caller dereferencing through
a freed pointer.

* src/rpc/virnettlscontext.c (virNetTLSSessionNew): Free correct
variable.

13 years agoqemu: avoid null deref on block pull error
Eric Blake [Tue, 2 Aug 2011 19:17:04 +0000 (13:17 -0600)]
qemu: avoid null deref on block pull error

Coverity detected that 5 of 6 callers of virJSONValueArrayGet checked
for a NULL return; and that by not checking we risk a null deref
during an error.  The error is unlikely since the prior call to
virJSONValueArraySize would probably have already caught any botched
JSON array parse, but better safe than sorry.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockJobInfo):
Check for NULL.
(qemuMonitorJSONExtractPtyPaths): Fix typo.

13 years agorpc: correctly process sasl whitelist globs
Eric Blake [Tue, 2 Aug 2011 19:04:19 +0000 (13:04 -0600)]
rpc: correctly process sasl whitelist globs

Detected by Coverity.  We want to compare the result of fnmatch 'rv',
not our pre-set return value 'ret'.

* src/rpc/virnetsaslcontext.c (virNetSASLContextCheckIdentity):
Check correct variable.

13 years agobuild: allow caching the input to STATIC_ANALYSIS
Eric Blake [Tue, 2 Aug 2011 18:25:58 +0000 (12:25 -0600)]
build: allow caching the input to STATIC_ANALYSIS

Right now, every re-run of configure re-evaluates whether a
static analysis tool is in use.  But if you run configure under
coverity, make a tweak, and then do an incremental rebuild with
gcc but not coverity to test the tweak, then rerun a build under
coverity, then configure does not get rerun, and static analysis
ends up with lots of false positives.

This patch caches the static analysis result, and also makes it
easier to force static analysis even if the existing checks are
insufficient to detect newer versions of the static analyzer tools.

* configure.ac (lv_cv_static_analysis): New cache variable.

13 years agofdstream: drop delete argument
Eric Blake [Tue, 2 Aug 2011 17:19:53 +0000 (11:19 -0600)]
fdstream: drop delete argument

Revert 6a1f5f568f8.  Now that libvirt_iohelper takes fds by
inheritance rather than by open() (commit 1eb66479), there is
no longer a race where the parent can unlink() a file prior to
the iohelper open()ing the same file.  From there, it makes
more sense to have the callers both create and unlink, rather
than the caller create and the stream unlink, since the latter
was only needed when iohelper had to do the unlink.

* src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile):
Callers are responsible for deletion.
* src/fdstream.c (virFDStreamOpenFileInternal): Don't leak created
file on failure.
(virFDStreamOpenFile, virFDStreamCreateFile): Drop parameter.
* src/lxc/lxc_driver.c (lxcDomainOpenConsole): Update callers.
* src/qemu/qemu_driver.c (qemuDomainScreenshot)
(qemuDomainOpenConsole): Likewise.
* src/storage/storage_driver.c (storageVolumeDownload)
(storageVolumeUpload): Likewise.
* src/uml/uml_driver.c (umlDomainOpenConsole): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.

13 years agoscreenshot: don't unlink bogus file
Eric Blake [Tue, 2 Aug 2011 16:58:21 +0000 (10:58 -0600)]
screenshot: don't unlink bogus file

The previous qemu patch could end up calling unlink(tmp) before
tmp was the name of a valid file (unlinking a fileXXXXXX template
instead), or calling unlink(tmp) twice on success (once here,
and once at the end of the stream).  Meanwhile, vbox also suffered
from the same leaked tmp file bug.

* src/qemu/qemu_driver.c (qemuDomainScreenshot): Don't unlink on
success, or on invalid name.
* src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Don't leak temp file.

13 years agopython: avoid unlikely sign extension bug
Eric Blake [Tue, 2 Aug 2011 16:03:41 +0000 (10:03 -0600)]
python: avoid unlikely sign extension bug

Detected by Coverity; same analysis as for commit f73198df.

* python/libvirt-override.c (libvirt_virDomainGetVcpuPinInfo): Use
correct type.

13 years agorpc: avoid uninitialized memory use
Eric Blake [Tue, 2 Aug 2011 15:56:10 +0000 (09:56 -0600)]
rpc: avoid uninitialized memory use

Spotted by Coverity.  Gnutls documents that buffer must be NULL
if gnutls_x509_crt_get_key_purpose_oid is to be used to determine
the correct size needed for allocating a buffer.

* src/rpc/virnettlscontext.c
(virNetTLSContextCheckCertKeyPurpose): Initialize buffer.

13 years agorpc: avoid double close on error
Eric Blake [Tue, 2 Aug 2011 15:50:54 +0000 (09:50 -0600)]
rpc: avoid double close on error

Spotted by coverity.  If pipe2 fails, then we attempt to close
uninitialized fds, which may result in a double-close.

* src/rpc/virnetserver.c (virNetServerSignalSetup): Initialize fds.

13 years agoqemu: Unlink temporary file on failure
Michal Privoznik [Tue, 2 Aug 2011 15:50:18 +0000 (17:50 +0200)]
qemu: Unlink temporary file on failure

Although virFDStreamOpenFile will unlink it once opened, when we hit
error path, we must unlink it by hand.

13 years agodoc: fix confusing statement about required privileges
Eric Blake [Tue, 2 Aug 2011 13:03:38 +0000 (15:03 +0200)]
doc: fix confusing statement about required privileges

src/libvirt.c: "may requires" is confusing; the s was extra.

13 years agorpc: avoid libvirtd crash on unexpected client close
Eric Blake [Mon, 1 Aug 2011 19:41:38 +0000 (13:41 -0600)]
rpc: avoid libvirtd crash on unexpected client close

Steps to reproduce this problem (vm1 is not running):
for i in `seq 50`; do virsh managedsave vm1& done; killall virsh

Pre-patch, virNetServerClientClose could end up setting client->sock
to NULL prior to other cleanup functions trying to use client->sock.
This fixes things by checking for NULL in more places, and by deferring
the cleanup until after all queued messages have been served.

* src/rpc/virnetserverclient.c (virNetServerClientRegisterEvent)
(virNetServerClientGetFD, virNetServerClientIsSecure)
(virNetServerClientLocalAddrString)
(virNetServerClientRemoteAddrString): Check for closed socket.
(virNetServerClientClose): Rearrange close sequence.
Analysis from Wen Congyang.

13 years agovirsh: fix memory leak in cmdNetworkInfo
Alex Jia [Tue, 2 Aug 2011 08:31:36 +0000 (16:31 +0800)]
virsh: fix memory leak in cmdNetworkInfo

* tools/virsh.c: avoid memory leak in cmdNetworkInfo.

* how to reproduce?
  % valgrind -v --leak-check=yes virsh net-info default

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agodoc: fix incorrect option in blockjob
Alex Jia [Tue, 2 Aug 2011 07:05:05 +0000 (15:05 +0800)]
doc: fix incorrect option in blockjob

* tools/virsh.pod: change 'live' to 'abort' based on actual option

13 years agoopenvz: detect when a domain was shut down from the inside
Jean-Baptiste Rouault [Fri, 29 Jul 2011 08:41:32 +0000 (10:41 +0200)]
openvz: detect when a domain was shut down from the inside

This patch adds an internal function openvzGetVEStatus to
get the real state of the domain. This function is used in
various places in the driver, in particular to detect when
the domain has been shut down by the user with the "halt"
command.

13 years agoqemu: fix crash when mixing sync and async monitor jobs
Eric Blake [Thu, 28 Jul 2011 23:18:24 +0000 (17:18 -0600)]
qemu: fix crash when mixing sync and async monitor jobs

Currently, we attempt to run sync job and async job at the same time. It
means that the monitor commands for two jobs can be run in any order.

In the function qemuDomainObjEnterMonitorInternal():
    if (priv->job.active == QEMU_JOB_NONE && priv->job.asyncJob) {
        if (qemuDomainObjBeginNestedJob(driver, obj) < 0)
We check whether the caller is an async job by priv->job.active and
priv->job.asynJob. But when an async job is running, and a sync job is
also running at the time of the check, then priv->job.active is not
QEMU_JOB_NONE. So we cannot check whether the caller is an async job
in the function qemuDomainObjEnterMonitorInternal(), and must instead
put the burden on the caller to tell us when an async command wants
to do a nested job.

Once the burden is on the caller, then only async monitor enters need
to worry about whether the VM is still running; for sync monitor enter,
the internal return is always 0, so lots of ignore_value can be dropped.

* src/qemu/THREADS.txt: Reflect new rules.
* src/qemu/qemu_domain.h (qemuDomainObjEnterMonitorAsync): New
prototype.
* src/qemu/qemu_process.h (qemuProcessStartCPUs)
(qemuProcessStopCPUs): Add parameter.
* src/qemu/qemu_migration.h (qemuMigrationToFile): Likewise.
(qemuMigrationWaitForCompletion): Make static.
* src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal): Add
parameter.
(qemuDomainObjEnterMonitorAsync): New function.
(qemuDomainObjEnterMonitor, qemuDomainObjEnterMonitorWithDriver):
Update callers.
* src/qemu/qemu_driver.c (qemuDomainSaveInternal)
(qemudDomainCoreDump, doCoreDump, processWatchdogEvent)
(qemudDomainSuspend, qemudDomainResume, qemuDomainSaveImageStartVM)
(qemuDomainSnapshotCreateActive, qemuDomainRevertToSnapshot):
Likewise.
* src/qemu/qemu_process.c (qemuProcessStopCPUs)
(qemuProcessFakeReboot, qemuProcessRecoverMigration)
(qemuProcessRecoverJob, qemuProcessStart): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationToFile)
(qemuMigrationWaitForCompletion, qemuMigrationUpdateJobStatus)
(qemuMigrationJobStart, qemuDomainMigrateGraphicsRelocate)
(doNativeMigrate, doTunnelMigrate, qemuMigrationPerformJob)
(qemuMigrationPerformPhase, qemuMigrationFinish)
(qemuMigrationConfirm): Likewise.
* src/qemu/qemu_hotplug.c: Drop unneeded ignore_value.

13 years agoqemu: fix return value issue
Alex Jia [Mon, 1 Aug 2011 15:45:27 +0000 (23:45 +0800)]
qemu: fix return value issue

whether or not previous return value is -1, the following codes will be
executed for a inactive guest in src/qemu/qemu_driver.c:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.

* src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
  in out of blkio weight range for a inactive guest.

* how to reproduce?
  % virsh blkiotune ${guestname} --weight 10
  % echo $?

  Note: guest must be inactive, argument 10 in out of blkio weight range,
  and can get a error information by checking libvirtd.log, however,
  virsh hasn't raised any error information, and return value is 0.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: fix return value issue in qemuDomainSetMemoryParameters
Alex Jia [Mon, 1 Aug 2011 15:06:07 +0000 (23:06 +0800)]
qemu: fix return value issue in qemuDomainSetMemoryParameters

whether or not previous return value is -1, the following codes will be
executed for a inactive guest in qemuDomainSetMemoryParameters:
ret = virDomainSaveConfig(driver->configDir, persistentDef);
and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
will be overwritten, this patch will fix this issue.

* src/qemu/qemu_driver.c: avoid return value is overwritten when set
  min_guarante value to a inactive guest.

* how to reproduce?
  % virsh memtune ${guestname} --min_guarante 1024
  % echo $?

  Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented
  in memory tunable, and I can get the error when check actual libvirtd.log,
  however, virsh hasn't raised any error information, and return value is 0.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agovirsh: Fix vol-name and vol-pool commands
Matthias Bolte [Mon, 1 Aug 2011 12:42:06 +0000 (14:42 +0200)]
virsh: Fix vol-name and vol-pool commands

This commands don't have a --pool option, so don't tell
vshCommandOptVolBy that there could be one. This made
vshCommandOptString for pooloptname fail and an "missing option"
error was reported.

Make pooloptname optional for vshCommandOptVolBy.

13 years agoCorrect the default value of lock_manager in qemu.conf
Guannan Ren [Mon, 1 Aug 2011 13:15:46 +0000 (21:15 +0800)]
Correct the default value of lock_manager in qemu.conf

* src/qemu/qemu.conf: switch back the comment for the default lock
  manager to sanlock

13 years agoqemu: Fix a regression of domjobabort
Osier Yang [Mon, 1 Aug 2011 11:41:07 +0000 (19:41 +0800)]
qemu: Fix a regression of domjobabort

Introduced by f9a837da73a11ef, the condition is not changed after
the else clause is removed. So now it quit with "domain is not
running" when the domain is running. However, when the domain is
not running, it reports "no job is active".

How to reproduce:

1)
% virsh start $domain
% virsh domjobabort $domain
error: Requested operation is not valid: domain is not running

2)
% virsh destroy $domain
% virsh domjobabort $domain
error: Requested operation is not valid: no job is active on the domain

3)
% virsh save $domain /tmp/$domain.save

Before above commands finished, try to abort job in another terminal

% virsh domabortjob $domain
error: Requested operation is not valid: domain is not running

13 years agoconf: Don't leak the virtual port profile in virNetworkDefFree
Matthias Bolte [Mon, 1 Aug 2011 08:06:59 +0000 (10:06 +0200)]
conf: Don't leak the virtual port profile in virNetworkDefFree

Reported by Alex Jia.

13 years agosave: generate idempotent inactive xml for running domain
Eric Blake [Fri, 22 Jul 2011 03:37:33 +0000 (21:37 -0600)]
save: generate idempotent inactive xml for running domain

Originally noticed by comparing the xml generated by virDomainSave
with the xml produced by reparsing and redumping that xml, but I
also did an audit of every last use of VIR_DOMAIN_XML_INACTIVE in
domain_conf.c to ensure that no other discrepancies exist.

* src/conf/domain_conf.c (virDomainDeviceInfoIsSet): Add
parameter, and update all callers.  Make static.
(virDomainNetDefFormat): Skip generated ifname.
(virDomainDefFormatInternal): Skip default <seclabel>.
(virDomainChrSourceDefParseXML): Skip generated pty path, and add
parameter.  Update callers.
* src/conf/domain_conf.h (virDomainDeviceInfoIsSet): Delete.
* src/libvirt_private.syms (domain_conf.h): Update.

13 years agoconf: make 'vnet' prefix a macro
Eric Blake [Fri, 29 Jul 2011 15:36:17 +0000 (09:36 -0600)]
conf: make 'vnet' prefix a macro

Using a macro ensures that all the code is looking for the same
prefix.

* src/conf/domain_conf.h (VIR_NET_GENERATED_PREFIX): New macro.
* src/conf/domain_conf.c (virDomainNetDefParseXML): Use it.
* src/uml/uml_conf.c (umlConnectTapDevice): Likewise.
* src/qemu/qemu_command.c (qemuNetworkIfaceConnect): Likewise.
Suggested by Laine Stump.

13 years agonetwork: don't forward DNS requests from isolated networks
Laine Stump [Fri, 29 Jul 2011 19:42:04 +0000 (15:42 -0400)]
network: don't forward DNS requests from isolated networks

This is in response to:

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

which points out that a guest on an "isolated" network could
potentially exploit the DNS forwarding provided by dnsmasq to create a
communication channel to the outside.

This patch eliminates that possibility by adding the "--no-resolv"
argument to the dnsmasq commandline, which tells dnsmasq to not
forward on any requests that it can't resolve itself (by looking at
its own static hosts files and runtime list of dhcp clients), but to
instead return a failure for those requests.

This shouldn't cause any undesirable change from current
behavior, even in the case where a guest is currently configured with
multiple interfaces, one of them being connected to an isolated
network, and another to a network that does have connectivity to the
outside. If the isolated network's DNS server is queried for a name
it doesn't know, it will return "Refused" rather than "Unknown", which
indicates to the guest that it should query other servers, so it then
queries the connected DNS server, and gets the desired response.

13 years agobuild: fix include path for cygwin
Eric Blake [Fri, 29 Jul 2011 19:16:29 +0000 (13:16 -0600)]
build: fix include path for cygwin

Without this, cygwin failed to compile:

In file included from ../src/rpc/virnetmessage.h:24,
                 from ../src/rpc/virnetclient.h:27,
                 from remote/remote_driver.c:31:
../src/rpc/virnetprotocol.h:9:21: error: rpc/rpc.h: No such file or directory

With that fixed, compilation warned:

rpc/virnetsocket.c: In function 'virNetSocketNewListenUNIX':
rpc/virnetsocket.c:347: warning: format '%d' expects type 'int', but argument 8 has type 'gid_t' [-Wformat]
rpc/virnetsocket.c: In function 'virNetSocketGetLocalIdentity':
rpc/virnetsocket.c:743: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness

* src/Makefile.am (libvirt_driver_remote_la_CFLAGS)
(libvirt_net_rpc_client_la_CFLAGS)
(libvirt_net_rpc_server_la_CFLAGS): Include XDR_CFLAGS, for rpc
headers on cygwin.
* src/rpc/virnetsocket.c (virNetSocketNewListenUNIX)
(virNetSocketGetLocalIdentity): Avoid compiler warnings.

13 years agobuild: avoid non-portable shell in test setup
Eric Blake [Fri, 29 Jul 2011 14:52:27 +0000 (08:52 -0600)]
build: avoid non-portable shell in test setup

POSIX states that 'a=1; a=2 b=$a command' has unspecified results
for the value of $b visible within command.  In particular, on
BSD, this resulted in PATH not picking up the in-test ssh.

* tests/Makefile.am (lv_abs_top_builddir): New macro.
(path_add, TESTS_ENVIRONMENT): Use it to avoid referring to an
environment variable set previously within the same command line.
Reported by Matthias Bolte.

13 years agotests: Don't use bash if we don't have to
Matthias Bolte [Fri, 29 Jul 2011 12:17:48 +0000 (14:17 +0200)]
tests: Don't use bash if we don't have to

This tested failed on FreeBSD because it was using bash, that might
not be installed.

13 years agoutils: More useful error message for hook script failure
Osier Yang [Fri, 29 Jul 2011 14:40:47 +0000 (22:40 +0800)]
utils: More useful error message for hook script failure

Commit 3709a386 ported hooks codes to new command execution API,
together with the useful error message removed. Though we can't
get "errbuf" from the new command execution API anymore, still
we can give a more useful error.

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

13 years agofreebsd: Fix build problem due to picking up the wrong libvirt.h
Matthias Bolte [Thu, 28 Jul 2011 12:55:21 +0000 (14:55 +0200)]
freebsd: Fix build problem due to picking up the wrong libvirt.h

Gettext annoyingly modifies CPPFLAGS in-place, putting
-I/usr/local/include into the search patch if libintl headers
must be used from that location.  But since we must support
automake 1.9.6 which lacks AM_CPPFLAGS, and since CPPFLAGS is used
prior to INCLUDES, this means that the build picks up the _old_
installed libvirt.h in priority to the in-tree version, leading
to all sorts of weird build failures on FreeBSD.

Fix this by teaching configure to undo gettext's actions, but
to keep any changes required by gettext at the end of INCLUDES
after all in-tree locations are used first.  Also requires
adding a wrapper Makefile.am and making gnulib-tool create
just gnulib.mk files during the bootstrap process.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agofreebsd: Avoid /bin/true in commandtest
Matthias Bolte [Thu, 28 Jul 2011 15:51:26 +0000 (17:51 +0200)]
freebsd: Avoid /bin/true in commandtest

Rely on PATH and use just true, because on FreeBSD it's /usr/bin/true.

13 years agotests: Unify style of test skipping code
Matthias Bolte [Thu, 28 Jul 2011 15:48:12 +0000 (17:48 +0200)]
tests: Unify style of test skipping code

Prefer 'return EXIT_AM_SKIP' over 'exit(EXIT_AM_SKIP)'.

Prefer 'int main(void)' over 'int main(int argc, char **argv)'.

Fix mymain signature in commandtest and nodeinfotest.

13 years agosave: let qemu driver manipulate save files
Eric Blake [Fri, 22 Jul 2011 03:31:46 +0000 (21:31 -0600)]
save: let qemu driver manipulate save files

The goal here is that save-image-dumpxml fed back to
save-image-define should not change the save file; anywhere that
this is not the case is probably a bug in domain_conf.c.

* src/qemu/qemu_driver.c (qemuDomainSaveImageGetXMLDesc)
(qemuDomainSaveImageDefineXML): New functions.
(qemuDomainSaveImageOpen): Add parameter.
(qemuDomainRestoreFlags, qemuDomainObjRestore): Adjust clients.

13 years agosave: support qemu modifying xml on domain save/restore
Eric Blake [Mon, 18 Jul 2011 23:27:59 +0000 (17:27 -0600)]
save: support qemu modifying xml on domain save/restore

With this, it is possible to update the path to a disk backing
image on either the save or restore action, without having to
binary edit the XML embedded in the state file.

This also modifies virDomainSave to output a smaller xml (only
the inactive xml, which is all the more virDomainRestore parses),
while still guaranteeing padding for most typical abi-compatible
xml replacements, necessary so that the next patch for
virDomainSaveImageDefineXML will not cause unnecessary
modifications to the save image file.

* src/qemu/qemu_driver.c (qemuDomainSaveInternal): Add parameter,
only use inactive state, and guarantee padding.
(qemuDomainSaveImageOpen): Add parameter.
(qemuDomainSaveFlags, qemuDomainManagedSave)
(qemuDomainRestoreFlags, qemuDomainObjRestore): Update callers.

13 years agomaint: add missing copyright notices
Eric Blake [Thu, 28 Jul 2011 18:56:24 +0000 (12:56 -0600)]
maint: add missing copyright notices

I went with the shorter license notice used by src/libvirt.c,
rather than spelling out the full LGPLv2+ clause into each of
these files.

* configure.ac: Declare copyright.
* all Makefile.am: Likewise.

13 years agoxen: drop unused callbacks
Eric Blake [Thu, 28 Jul 2011 20:57:55 +0000 (14:57 -0600)]
xen: drop unused callbacks

Found by:

for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h)
do
  git grep "\(\.\|->\)$f\b" src/xen
done | cat

and looking through the resulting list to see which callback struct
members are still necessary.

* src/xen/xen_driver.h (xenUnifiedDriver): Drop all callbacks that
are only used directly.
* src/xen/xen_hypervisor.c (xenHypervisorDriver): Shrink list.
* src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
* src/xen/xend_internal.c (xenDaemonDriver): Likewise.
* src/xen/xm_internal.c (xenXMDriver): Likewise.
* src/xen/xs_internal.c (xenStoreDriver): Likewise.

13 years agoxen: make direct call when there is only one subdriver
Eric Blake [Thu, 21 Jul 2011 21:11:32 +0000 (15:11 -0600)]
xen: make direct call when there is only one subdriver

No need to use a for loop if we know there is exactly one client.
Found by:

for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h)
do
  git grep "\(\.\|->\)$f\b" src/xen
done | cat

and looking through the resulting list to see which callback struct
members are used exactly once.  The next patch will ensure that we
don't reintroduce uses of these callbacks.

* src/xen/xen_driver.c (xenUnifiedClose): Call close
unconditionally, to match xenUnifiedOpen.
(xenUnifiedNodeGetInfo, xenUnifiedDomainCreateXML)
(xenUnifiedDomainSave, xenUnifiedDomainRestore)
(xenUnifiedDomainCoreDump, xenUnifiedDomainUpdateDeviceFlags):
Make direct call to lone implementation.
* src/xen/xend_internal.h (xenDaemonDomainCoreDump)
(xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Add prototypes.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump)
(xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Export.

13 years agoxen: reduce callback special cases
Eric Blake [Thu, 21 Jul 2011 20:26:47 +0000 (14:26 -0600)]
xen: reduce callback special cases

The callback struct is great when iterating through several
possibilities, but when calling a known callback, it's just
overhead.  We can make the direct call in those cases.

* src/xen/xen_driver.c (xenUnifiedOpen, xenUnifiedDomainSuspend)
(xenUnifiedDomainResume, xenUnifiedDomainDestroyFlags): Make
direct calls instead of going through callback.

13 years agoxen: cleanup callback struct
Eric Blake [Thu, 21 Jul 2011 20:10:33 +0000 (14:10 -0600)]
xen: cleanup callback struct

Using C99 initializers and xen-specific prefixes will make it
so that future patches are less likely to add callback members
to the xenUnifiedDriver struct, since the goal is to get rid
of the callback struct in the first place.

* src/xen/xen_driver.h (xenUnifiedDriver): Rename all struct
members, to make it obvious which ones are still in use.
* src/xen/xen_driver.c: Update all callers.
* src/xen/xen_hypervisor.c (xenHypervisorDriver): Rewrite with C99
initializers.
* src/xen/xend_internal.c (xenDaemonDriver): Likewise.
* src/xen/xs_internal.c (xenStoreDriver): Likewise.
* src/xen/xm_internal.c (xenXMDriver): Likewise.
* src/xen/xen_inotify.c (xenInotifyDriver): Likewise.

13 years agolibxl: fix build failure due to change in virDomainGraphicsDef
Laine Stump [Thu, 28 Jul 2011 18:38:14 +0000 (14:38 -0400)]
libxl: fix build failure due to change in virDomainGraphicsDef

This failure was introduced by commit dacee3d, which removed
listenAddr from the unions in virDomainGraphicsDef in favor of putting
it in the address attribute of virDomainGraphicsListenDef.

13 years agoqemu: support type=network in domain graphics <listen>
Laine Stump [Thu, 7 Jul 2011 06:12:04 +0000 (02:12 -0400)]
qemu: support type=network in domain graphics <listen>

The domain XML now understands the <listen> subelement of its
<graphics> element (including when listen type='network'), and the
network driver has an internal API that will turn a network name into
an IP address, so the final logical step is to put the glue into the
qemu driver so that when it is starting up a domain, if it finds
<listen type='network' network='xyz'/> in the XML, it will call the
network driver to get an IPv4 address associated with network xyz, and
tell qemu to listen for vnc (or spice) on that address rather than the
default address (localhost).

The motivation for this is that a large installation may want the
guests' VNC servers listening on physical interfaces rather than
localhost, so that users can connect directly from the outside; this
requires sending qemu the appropriate IP address to listen on. But
this address will of course be different for each host, and if a guest
might be migrated around from one host to another, it's important that
the guest's config not have any information embedded in it that is
specific to one particular host. <listen type='network.../> can solve
this problem in the following manner:

  1) on each host, define a libvirt network of the same name,
     associated with the interface on that host that should be used
     for listening (for example, a simple macvtap network: <forward
     mode='bridge' dev='eth0'/>, or host bridge network: <forward
     mode='bridge'/> <bridge name='br0'/>

  2) in the <graphics> element of each guest's domain xml, tell vnc to
     listen on the network name used in step 1:

     <graphics type='vnc' port='5922'>
       <listen type='network'network='example-net'/>
     </graphics>

(all the above also applies for graphics type='spice').

13 years agoconf: add <listen> subelement to domain <graphics> element
Laine Stump [Thu, 7 Jul 2011 04:20:28 +0000 (00:20 -0400)]
conf: add <listen> subelement to domain <graphics> element

Once it's plugged in, the <listen> element will be an optional
replacement for the "listen" attribute that graphics elements already
have. If the <listen> element is type='address', it will have an
attribute called 'address' which will contain an IP address or dns
name that the guest's display server should listen on. If, however,
type='network', the <listen> element should have an attribute called
'network' that will be set to the name of a network configuration to
get the IP address from.

* docs/schemas/domain.rng: updated to allow the <listen> element

* docs/formatdomain.html.in: document the <listen> element and its
  attributes.

* src/conf/domain_conf.[hc]:

  1) The domain parser, formatter, and data structure are modified to
     support 0 or more <listen> subelements to each <graphics>
     element. The old style "legacy" listen attribute is also still
     accepted, and will be stored internally just as if it were a
     separate <listen> element. On output (i.e. format), the address
     attribute of the first <listen> element of type 'address' will be
     duplicated in the legacy "listen" attribute of the <graphic>
     element.

  2) The "listenAddr" attribute has been removed from the unions in
     virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
     This attribute is now in the <listen> subelement (aka
     virDomainGraphicsListenDef)

  3) Helper functions were written to provide simple access
     (both Get and Set) to the listen elements and their attributes.

* src/libvirt_private.syms: export the listen helper functions

* src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
  src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
  src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c

  Modify all these files to use the listen helper functions rather
  than directly referencing the (now missing) listenAddr
  attribute. There can be multiple <listen> elements to a single
  <graphics>, but the drivers all currently only support one, so all
  replacements of direct access with a helper function indicate index
  "0".

* tests/* - only 3 of these are new files added explicitly to test the
  new <listen> element. All the others have been modified to reflect
  the fact that any legacy "listen" attributes passed in to the domain
  parse will be saved in a <listen> element (i.e. one of the
  virDomainGraphicsListenDefs), and during the domain format function,
  both the <listen> element as well as the legacy attributes will be
  output.

13 years agovirsh: avoid missing zero value judgement in cmdBlkiotune
Alex Jia [Thu, 28 Jul 2011 11:13:41 +0000 (19:13 +0800)]
virsh: avoid missing zero value judgement in cmdBlkiotune

* tools/virsh.c: fix missing zero value judgement in cmdBlkiotune and correct
  vshError information.

  when weight is equal to 0, the cmdBlkiotune will not raise any error information
  when judge weight value first time, and execute else branch to judge weight
  value again, strncpy(temp->field, VIR_DOMAIN_BLKIO_WEIGHT, sizeof(temp->field))
  will be not executed for ever. However, if and only if param->field is equal
  to VIR_DOMAIN_BLKIO_WEIGHT, underlying qemuDomainSetBlkioParameters function
  will check whether weight value is in range [100, 1000].

* how to reproduce?

  % virsh blkiotune ${guestname} --weight 0

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agobuild: avoid type-punning compiler warning
Eric Blake [Tue, 26 Jul 2011 22:21:10 +0000 (16:21 -0600)]
build: avoid type-punning compiler warning

On RHEL 5, with gcc 4.1.2:

rpc/virnetsaslcontext.c: In function 'virNetSASLSessionUpdateBufSize':
rpc/virnetsaslcontext.c:396: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

* src/rpc/virnetsaslcontext.c (virNetSASLSessionUpdateBufSize):
Use a union to work around gcc warning.

13 years agoqemu: fix nested job with driver lock held
Eric Blake [Wed, 27 Jul 2011 23:13:22 +0000 (17:13 -0600)]
qemu: fix nested job with driver lock held

qemuMigrationUpdateJobStatus (called in a loop by migration
and save tasks) uses qemuDomainObjEnterMonitorWithDriver;
however, that function ended up starting a nested job without
releasing the driver.

Since no one else is making nested calls, we can inline the
internal functions to properly track driver_locked.

* src/qemu/qemu_domain.h (qemuDomainObjBeginNestedJob)
(qemuDomainObjBeginNestedJobWithDriver)
(qemuDomainObjEndNestedJob): Drop unused prototypes.
* src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal):
Reflect driver lock to nested job.
(qemuDomainObjBeginNestedJob)
(qemuDomainObjBeginNestedJobWithDriver)
(qemuDomainObjEndNestedJob): Drop unused functions.

13 years agoqemu: Fix memory leak on metadata fetching
Michal Privoznik [Thu, 28 Jul 2011 13:42:57 +0000 (15:42 +0200)]
qemu: Fix memory leak on metadata fetching

As written in virStorageFileGetMetadataFromFD decription, caller
must free metadata after use. Qemu driver miss this and therefore
leak metadata which can grow to huge mem leak if somebody query
for blockInfo a lot.

13 years agofreebsd: Add gnulib environ module for the commandtest
Matthias Bolte [Thu, 28 Jul 2011 11:07:56 +0000 (13:07 +0200)]
freebsd: Add gnulib environ module for the commandtest

13 years agolibvirt.c: Update outdated description of flags
Michal Privoznik [Thu, 28 Jul 2011 08:23:45 +0000 (10:23 +0200)]
libvirt.c: Update outdated description of flags

Because we do support flags for virDomainSetBlkioParameters and
virDomainGetBlkioParameters, update appropriate description as well.

13 years agopython: add python binding for virDomainSetMemoryParameters
Hu Tao [Wed, 27 Jul 2011 02:13:11 +0000 (10:13 +0800)]
python: add python binding for virDomainSetMemoryParameters

13 years agopython: add python binding for virDomainGetMemoryParameters
Hu Tao [Wed, 27 Jul 2011 02:13:10 +0000 (10:13 +0800)]
python: add python binding for virDomainGetMemoryParameters

13 years agopython: add python binding for virDomainSetBlkioParameters
Hu Tao [Wed, 27 Jul 2011 02:13:09 +0000 (10:13 +0800)]
python: add python binding for virDomainSetBlkioParameters

13 years agopython: add python binding for virDomainGetBlkioParameters
Hu Tao [Wed, 27 Jul 2011 02:13:08 +0000 (10:13 +0800)]
python: add python binding for virDomainGetBlkioParameters

13 years agovirsh: fix memory leak in cmdVolPath code
Alex Jia [Thu, 28 Jul 2011 02:42:51 +0000 (10:42 +0800)]
virsh: fix memory leak in cmdVolPath code

* tools/virsh.c: avoid memory leak in cmdVolPath.
* src/libvirt.c: Add doc for virStorageVolGetPath to tell one
  must free() the returned path after use.

* how to reproduce?

% dd if=/dev/zero of=/var/lib/libvirt/images/foo.img count=1 bs=10M
% virsh pool-refresh default
% valgrind -v --leak-check=full virsh vol-path --vol \
/var/lib/libvirt/images/foo.img

* actual results:

Detected in valgrind run:

==16436== 32 bytes in 1 blocks are definitely lost in loss record 7 of 22
==16436==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==16436==    by 0x386A314B3D: xdr_string (in /lib64/libc-2.12.so)
==16436==    by 0x3DF8CD770D: xdr_remote_nonnull_string (remote_protocol.c:3
==16436==    by 0x3DF8CD7EC8: xdr_remote_storage_vol_get_path_ret
% virsh pool-refresh default
% valgrind -v --leak-check=full virsh vol-path --vol \
/var/lib/libvirt/images/foo.img

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: Improve docs for virsh dump format
Osier Yang [Thu, 28 Jul 2011 01:37:52 +0000 (09:37 +0800)]
qemu: Improve docs for virsh dump format

The error in getCompressionType will never be reported, change
the errors codes into warning (VIR_WARN("%s", _(foo)); doesn't break
syntax-check rule), and also improve the docs in qemu.conf to tell
user the truth.

13 years agoqemu: improve thread documentation
Eric Blake [Wed, 27 Jul 2011 22:20:00 +0000 (16:20 -0600)]
qemu: improve thread documentation

* src/qemu/THREADS.txt: Fix problems with typos, grammar, and
outdated examples.

13 years agovirsh: expose change-protection during migration
Eric Blake [Wed, 27 Jul 2011 16:13:48 +0000 (10:13 -0600)]
virsh: expose change-protection during migration

* tools/virsh.c (doMigrate): Add --change-protection flag.
* tools/virsh.pod (migrate): Document it.

13 years agorpc: Fix memory leak in remoteDomainSet*Parameters functions
Matthias Bolte [Wed, 27 Jul 2011 18:32:25 +0000 (20:32 +0200)]
rpc: Fix memory leak in remoteDomainSet*Parameters functions

Add a new helper remoteFreeTypedParameters and teach the generator
to add it to the cleanup section.

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

13 years agosend-key: Implement Python API
Lai Jiangshan [Thu, 21 Jul 2011 09:21:10 +0000 (17:21 +0800)]
send-key: Implement Python API

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agoqemu: Remove special case for virDomainAbortJob
Jiri Denemark [Tue, 19 Jul 2011 00:27:39 +0000 (02:27 +0200)]
qemu: Remove special case for virDomainAbortJob

This doesn't abort migration job in any phase, yet.

13 years agoqemu: Remove special case for virDomainSuspend
Jiri Denemark [Tue, 19 Jul 2011 00:27:38 +0000 (02:27 +0200)]
qemu: Remove special case for virDomainSuspend

13 years agoqemu: Remove special case for virDomainMigrateSetMaxDowntime
Jiri Denemark [Tue, 19 Jul 2011 00:27:37 +0000 (02:27 +0200)]
qemu: Remove special case for virDomainMigrateSetMaxDowntime

Call qemu monitor command directly within a special job that is only
allowed during outgoing migration.

13 years agoqemu: Remove special case for virDomainMigrateSetMaxSpeed
Jiri Denemark [Tue, 19 Jul 2011 00:27:36 +0000 (02:27 +0200)]
qemu: Remove special case for virDomainMigrateSetMaxSpeed

Call qemu monitor command directly within a special job that is only
allowed during outgoing migration.

13 years agoqemu: Remove special case for virDomainBlockStats
Jiri Denemark [Tue, 19 Jul 2011 00:27:35 +0000 (02:27 +0200)]
qemu: Remove special case for virDomainBlockStats

Like other query commands, this can now be called directly during
migration.

13 years agoqemu: Remove special case for virDomainGetBlockInfo
Jiri Denemark [Tue, 19 Jul 2011 00:27:34 +0000 (02:27 +0200)]
qemu: Remove special case for virDomainGetBlockInfo

Like other query commands, this can now be called directly during
migration.

13 years agoqemu: Recover from interrupted migration
Jiri Denemark [Tue, 19 Jul 2011 00:27:33 +0000 (02:27 +0200)]
qemu: Recover from interrupted migration

13 years agoqemu: Migration job on source daemon
Jiri Denemark [Tue, 19 Jul 2011 00:27:32 +0000 (02:27 +0200)]
qemu: Migration job on source daemon

Make MIGRATION_OUT use the new helper methods.

This also introduces new protection to migration v3 process: the
migration job is held from Begin to Confirm to avoid changes to a domain
during migration (esp. between Begin and Perform phases). This change is
automatically applied to p2p and tunneled migrations. For normal
migration, this requires support from a client. In other words, if an
old (pre 0.9.4) client starts normal migration of a domain, the domain
will not be protected against changes between Begin and Perform steps.

13 years agoqemu: Migration job on destination daemon
Jiri Denemark [Tue, 19 Jul 2011 00:27:31 +0000 (02:27 +0200)]
qemu: Migration job on destination daemon

Make MIGRATION_IN use the new helper methods.

13 years agoqemu: Implement migration job phases
Jiri Denemark [Tue, 19 Jul 2011 00:27:30 +0000 (02:27 +0200)]
qemu: Implement migration job phases

This patch introduces several helper methods to deal with jobs and
phases during migration in a simpler manner.

13 years agobuild: support warnings on RHEL 5
Eric Blake [Tue, 26 Jul 2011 20:22:55 +0000 (14:22 -0600)]
build: support warnings on RHEL 5

Without this, a configure built by autoconf 2.59 was broken when
trying to detect which compiler warning flags were supported.

* .gnulib: Update to latest, for warnings.m4 fix.
* bootstrap.conf: Add fclose explicitly, to match recent gnulib
implicit dependency changes.
* src/qemu/qemu_conf.c (includes): Drop unused include.
* src/uml/uml_conf.c (include): Likewise.
Reported by Daniel P. Berrange.

13 years agobandwidth: Integrate bandwidth into portgroups
Michal Privoznik [Tue, 26 Jul 2011 12:42:37 +0000 (14:42 +0200)]
bandwidth: Integrate bandwidth into portgroups

Every DomainNetDef has a bandwidth, as does every portgroup.
Whenever a DomainNetDef of type NETWORK is about to be used, a call is
made to networkAllocateActualDevice(). This function chooses the "best"
bandwidth object and places it in the DomainActualNetDef.
From that point on, whenever some code needs to use the bandwidth data
for the interface, it's retrieved with virDomainNetGetActualBandwidth(),
which will always return the "best" info as determined in the
previous step.

13 years agodoc: Add doc for blockpull and blockjob commands
Osier Yang [Wed, 27 Jul 2011 02:48:28 +0000 (10:48 +0800)]
doc: Add doc for blockpull and blockjob commands

Commit b31abc6f0 introduce commands blockpull and blockjob, but
forgot to add the docs meanwhile.

13 years agopython: Properly report errors if virStreamRecv fails
Cole Robinson [Tue, 26 Jul 2011 23:25:43 +0000 (19:25 -0400)]
python: Properly report errors if virStreamRecv fails

We only want to raise the special value -2. -1 should return None
which tells the bindings to throw an exception.

13 years agotools: format percent strings of nodecpustats
Alex Jia [Tue, 26 Jul 2011 07:32:37 +0000 (15:32 +0800)]
tools: format percent strings of nodecpustats

* tools/virsh.c: format strings display for virsh nodecpustats --percent.

* how to reproduce?

% virsh nodecpustats --percent
usage:            2.0%
    user  :       1.0%
    system:       1.0%
idle  :          98.0%
iowait:           0.0%

* after format strings

% virsh nodecpustats --percent
usage:            2.0%
user:             1.0%
system:           1.0%
idle:            98.0%
iowait:           0.0%

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoBuild: fix build if HAVE_AVAHI is not defined
Stefan Berger [Tue, 26 Jul 2011 15:42:00 +0000 (11:42 -0400)]
Build: fix build if HAVE_AVAHI is not defined

Fix the build if HAVE_AVAHI is not defined.

13 years agoFix incorrect implication about list options
Dave Allan [Tue, 26 Jul 2011 03:20:49 +0000 (23:20 -0400)]
Fix incorrect implication about list options

The description of the list command seemed to suggest that it could
take a set of domains as an argument, which is not correct in the
current HEAD.  If virsh list is intended to take a list of domains,
then this patch should be NAK'd and a bug opened against virsh list.

Reported by hachi on #virt

v2:

Change language to include transient domains

Osier pointed out that transient domains are not defined, so what I
had originally proposed wasn't quite correct.

13 years agoFix race in ref counting when handling RPC jobs
Daniel P. Berrange [Tue, 26 Jul 2011 14:49:15 +0000 (15:49 +0100)]
Fix race in ref counting when handling RPC jobs

When an incoming RPC message is ready for processing,

  virNetServerClientDispatchRead()

will invoke the 'dispatchFunc' callback. This is set to

  virNetServerDispatchNewMessage

This function puts the message + client in a queue for processing by the thread
pool. The thread pool worker function is

  virNetServerHandleJob

The first thing this does is acquire an extra reference on the 'client'.

Unfortunately, between the time the message+client are put on the thread pool
queue, and the time the worker runs, the client object may have had its last
reference removed.

We clearly need to add the reference to the client object before putting the
client on the processing queue

* src/rpc/virnetserverclient.c: Add a reference to the client when
  invoking the dispatch function
* src/rpc/virnetserver.c: Don't acquire a reference to the client
  when in the worker thread