]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
10 years agoqemu: Update fsfreeze status on domain state transitions
Michal Privoznik [Mon, 3 Nov 2014 11:57:44 +0000 (12:57 +0100)] 
qemu: Update fsfreeze status on domain state transitions

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

As of b6d4dad1 (1.2.5) libvirt keeps track if domain disks have been
frozen. However, this falls into that set of information which don't
survive domain restart. Therefore, we need to clear the flag upon some
state transitions. Moreover, once we clear the flag we must update the
status file too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 6ea54769ba1816b382698c4311588d7d1a9cd095)

10 years agonetwork: fix call virNetworkEventLifecycleNew when networkStartNetwork fail
Luyao Huang [Sat, 1 Nov 2014 10:03:23 +0000 (18:03 +0800)] 
network: fix call virNetworkEventLifecycleNew when networkStartNetwork fail

When start a network fail, libvirt still call virNetworkEventLifecycleNew
to send a event.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit 45d9ea5cddad5ed151db15362a881b730b8c88f1)

10 years agoRequire at least one console for LXC domain
Ján Tomko [Fri, 31 Oct 2014 08:51:23 +0000 (09:51 +0100)] 
Require at least one console for LXC domain

A domain without a console quietly dies soon after start,
because we try to set /dev/null as a controlling TTY
2014-10-30 15:10:59.705+0000: 1: error : lxcContainerSetupFDs:283 :
ioctl(TIOCSCTTY) failed: Inappropriate ioctl for device

Report an error early instead of trying to start it.

https://bugzilla.redhat.com/show_bug.cgi?id=1155410
(cherry picked from commit 44686f6523cb30a174c052a242fa15f6a2b364e5)

10 years agoDo not probe for power mgmt capabilities in lxc emulator
Ján Tomko [Fri, 31 Oct 2014 09:02:22 +0000 (10:02 +0100)] 
Do not probe for power mgmt capabilities in lxc emulator

It fails after 30 seconds with this error:
error : virDBusCall:1429 : error from service: CanSuspend:
Did not receive a reply. Possible causes include: the remote
application did not send a reply, the message bus security
policy blocked the reply, the reply timeout expired, or the
network connection was broken.

Only probe for the power mgmt capabilities when driver is non-NULL.
This speeds up domain startup by 30 seconds.

https://bugzilla.redhat.com/show_bug.cgi?id=1159227
(cherry picked from commit 7ead1a5d91a93b5614deeef7b0227bffcea9740d)

10 years agoutil: fix releasing pidfile in cleanup
Martin Kletzander [Tue, 4 Nov 2014 09:46:41 +0000 (10:46 +0100)] 
util: fix releasing pidfile in cleanup

Coverity found out the very obvious problem in the code.  That is that
virPidFileReleasePath() was called only if
virPidFileAcquirePath() returned 0.  But virPidFileAcquirePath() doesn't
return only 0 on success, but the FD that needs to be closed.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 3f43bb832646588f57303f09fe5c7ac8ba7602d8)

10 years agoqemu: stop NBD server after successful migration
Weiwei Li [Tue, 4 Nov 2014 09:52:10 +0000 (10:52 +0100)] 
qemu: stop NBD server after successful migration

In qemuMigrationFinish mig->nbd can not be initialized by
qemuMigrationEatCookie without the QEMU_MIGRATION_COOKIE_NBD flag.
That causes qemuMigrationStopNBDServer to return early without
stopping the NBD server properly.

Signed-off-by: Weiwei Li <nuonuoli@tencent.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit c3012a023f2ae5763027cafc1cf2881a3c7c4b45)

10 years agoqemu: make sure capability probing process can start
Martin Kletzander [Thu, 9 Oct 2014 06:18:33 +0000 (08:18 +0200)] 
qemu: make sure capability probing process can start

When daemon is killed right in the middle of probing a qemu binary for
its capabilities, the qemu process is left running.  Next time the
daemon is starting, it cannot start the probing qemu process because the
one that's already running does have the pidfile flock()'d.

Reported-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 0ed1b55b20300e0ea53925349d918935c2114bf2)

10 years agoutil: Introduce virPidFileForceCleanupPath
Martin Kletzander [Sun, 12 Oct 2014 11:40:36 +0000 (13:40 +0200)] 
util: Introduce virPidFileForceCleanupPath

This function is used to cleanup a pidfile doing whatever it takes, even
killing the owning process.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit d1fd086eb41d5505b7dc595abbf6027b9428071b)

10 years agoqemu: make advice from numad available when building commandline
Martin Kletzander [Thu, 30 Oct 2014 06:34:30 +0000 (07:34 +0100)] 
qemu: make advice from numad available when building commandline

Particularly in qemuBuildNumaArgStr(), there was a need for the advice
due to memory backing, which needs to know the nodeset it will be pinned
to.  With newer qemu this caused the following error when starting
domain:

  error: internal error: Advice from numad is needed in case of
  automatic numa placement

even when starting perfectly valid domain, e.g.:

  ...
  <vcpu placement='auto'>4</vcpu>
  <numatune>
    <memory mode='strict' placement='auto'/>
  </numatune>
  <cpu>
    <numa>
      <cell id='0' cpus='0' memory='524288'/>
      <cell id='1' cpus='1' memory='524288'/>
    </numa>
  </cpu>
  ...

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 11a48758a7d6c946062c130b6186ae3eadd58e39)

10 years agoqemu: Release nbd port from migrationPorts instead of remotePorts
weiwei li [Fri, 31 Oct 2014 08:16:22 +0000 (16:16 +0800)] 
qemu: Release nbd port from migrationPorts instead of remotePorts

commit 3e1e16aa8d4238241a1806cb9bdb3b9ad60db777 (Use a port from the
migration range for NBD as well) changed ndb port allocation from
remotePorts to migrationPorts, but did not change the port releasing
process, which makes an error when migrating several times (above 64):
error: internal error: Unable to find an unused port in range
'migration' (49152-49215)

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

Signed-off-by: Weiwei Li <nuonuoli@tencent.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit be598c5ff84656d3498b950d473fafe5b86f87b4)

10 years agoqemu: better error message when block job can't succeed
Eric Blake [Fri, 24 Oct 2014 20:49:13 +0000 (14:49 -0600)] 
qemu: better error message when block job can't succeed

https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
the qemu-kvm shipped as part of RHEL 7.0 intentionally[1] cripples
block jobs by removing the 'block-stream' QMP command, while still
leaving 'block-job-cancel' as an unusable no-op.  Meanwhile, we
already had existing code that checked whether block jobs were
completely missing (such as qemu 0.15), old style (cancel is
synchronous, and all commands spelled with '_'), or new style
(cancel is asynchronous, and all commands spelled with '-'), and
used that three-way probe to give decent error messages.  At the
time that code was added, all existing qemu versions fell in one
of three buckets, and the code was using the presence of
'block-job-cancel' as the witness of which of the three buckets.
But now that RHEL qemu has shipped with intentionally crippled
'block-stream', we have a fourth bucket, which results in ugly
error messages when trying 'virsh blockpull':

 error: Requested operation is not valid: Command 'block-stream' is not found

In reality, the fourth bucket should be treated the same as the
first bucket (no block job support); we can do that by realizing
that no existing build of qemu has working block-stream while
lacking block-job-cancel, so it is easiest to change our witness
to the command that starts a job rather than ends one.  We still
act correctly regarding command spelling and whether cancel is
asynchronous.  And on crippled RHEL builds, we now get the desired:

 error: unsupported configuration: block jobs not supported with this qemu binary

[1] The intentional cripple is limited to qemu-kvm of RHEL; when using
qemu-kvm-rhev of RHEV, block job functionality is supported.  Don't ask
me to explain the "why" behind it all - I'm just dealing with fallout
from someone else's decision.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC): Tweak comment.
* src/qemu/qemu_capabilities.c (virQEMUCapsCommands): Look for stream
rather than cancel when determining the flavor of block jobs supported.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 00331bfbc9626ee9e94352453087b521943236ca)

10 years agotest: Add test to verify helpers used for backing file name parsing
Peter Krempa [Wed, 29 Oct 2014 10:01:48 +0000 (11:01 +0100)] 
test: Add test to verify helpers used for backing file name parsing

Add two test cases to verify that the helpers split and parse the
backing store components properly.

(cherry picked from commit 95a56835926e138c9da5584478f947f7816b54fe)

10 years agostorage: Fix crash when parsing backing store URI with schema
Peter Krempa [Wed, 29 Oct 2014 09:55:23 +0000 (10:55 +0100)] 
storage: Fix crash when parsing backing store URI with schema

The code that parses the schema from the URI touches the "hosts[0]"
member of the storage file source structure in case the URI contains a
schema. The hosts array was not yet allocated at the point in the code
where the transport protocol was parsed and set. This lead to a crash of
libvirtd.

Fix the code by allocating the "hosts" array upfront and add a test case
to verify this scenario. (Unfortunately this requires shuffling the test
case numbers too).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1156288
(cherry picked from commit 98784369fd52ed6aa9bab2a9a9d213c52019e6ee)

10 years agoremote: fix jump depends on uninitialised value
Jincheng Miao [Fri, 24 Oct 2014 04:03:13 +0000 (12:03 +0800)] 
remote: fix jump depends on uninitialised value

Currently remote driver only initializes partial fields of
remote_connect_get_all_domain_stats_args. But xdr_array()
will check the uninitialised field 'doms_val'.
For safty reason, memset all fields of args is better.

Fix the following error from valgrind, like:
==30515== 1 errors in context 1 of 3:
==30515== Conditional jump or move depends on uninitialised value(s)
==30515==    at 0x85E9402: xdr_array (xdr_array.c:88)
==30515==    by 0x4FD8FC9: xdr_remote_connect_get_all_domain_stats_args (remote_protocol.c:6473)
==30515==    by 0x4FE72F2: virNetMessageEncodePayload (virnetmessage.c:350)
==30515==    by 0x4FDD21C: virNetClientProgramCall (virnetclientprogram.c:326)
==30515==    by 0x4FB4D01: callFull.isra.2 (remote_driver.c:6667)
==30515==    by 0x4FCBD45: call (remote_driver.c:6689)
==30515==    by 0x4FCBD45: remoteConnectGetAllDomainStats (remote_driver.c:7793)
==30515==    by 0x4FA0E75: virConnectGetAllDomainStats (libvirt.c:21678)
==30515==    by 0x147FD1: cmdDomstats (virsh-domain-monitor.c:2148)
==30515==    by 0x13006B: vshCommandRun (virsh.c:1915)
==30515==    by 0x12A9E1: main (virsh.c:3699)

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
(cherry picked from commit 28b7601dc7acf99d06277267afb63fff4167b755)

10 years agoqemu_agent: Produce more readable error messages
Michal Privoznik [Tue, 28 Oct 2014 02:41:27 +0000 (03:41 +0100)] 
qemu_agent: Produce more readable error messages

Not every error message from qemu-ga has to have the 'class' field
filled out. For instance, I've seen this error message lately:

  qemuAgentCheckError:1047 : unable to execute QEMU agent command \
  {"execute":"guest-set-time"}: \
  {"error":{"desc":"Invalid parameter type, expected: integer"}}

However, this got translated into rather generic error message:

  internal error: unable to execute QEMU agent command
  'guest-set-time': unknown QEMU command error

So we've dropped better error message in favor of a generic one.
This is due to our code which expects 'class' which is not
present here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit b7fe5a6555a3c23205794b59a6736c6eb7c9464b)

10 years agoqemu: forbid snapshot-delete --children-only on external snapshot
Eric Blake [Mon, 27 Oct 2014 11:37:34 +0000 (05:37 -0600)] 
qemu: forbid snapshot-delete --children-only on external snapshot

https://bugzilla.redhat.com/show_bug.cgi?id=956506 documents that
given a domain where an internal snapshot parent has an external
snapshot child, we lacked a safety check when trying to use the
--children-only option to snapshot-delete:

$ virsh start dom
$ virsh snapshot-create-as dom internal
$ virsh snapshot-create-as dom external --disk-only
$ virsh snapshot-delete dom external
error: Failed to delete snapshot external
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children-only
Domain snapshot internal children deleted

While I'd still like to see patches that actually do proper external
snapshot deletion, we should at least fix the inconsistency in the
meantime.  With this patch:

$ virsh snapshot-delete dom internal --children-only
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet

* src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Fix condition.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 2086a9905aac877d1618f96c7eea8e3d6a01fd9a)

10 years agotests: Add SELINUX_LIBS to fix viridentitytest linker bug
Julio Faracco [Fri, 24 Oct 2014 12:33:52 +0000 (10:33 -0200)] 
tests: Add SELINUX_LIBS to fix viridentitytest linker bug

In a clean build system (Ubuntu 14.04), the viridentitytest failed to compile.
Even if all the SELINUX libraries and depedencies are installed. See the error
message below:

[...]
  CC       viridentitytest.o
  CCLD     viridentitytest
/usr/bin/ld: viridentitytest.o: undefined reference to symbol
                                                       'security_disable'
//lib/x86_64-linux-gnu/libselinux.so.1: error adding symbols: DSO missing
                                                           from command line
collect2: error: ld returned 1 exit status
make: *** [viridentitytest] Error 1

Simply adding the variable SELINUX_LIBS in viridentitytest rules of
Makefile.am to include SELINUX libraries into viridentitytest solved that
compilation issue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit f2a2d0e9ab89a50d9552d2c70de0301ad2b83224)

10 years agoqemu: migration: Make check for empty hook XML robust
Peter Krempa [Wed, 22 Oct 2014 09:27:36 +0000 (11:27 +0200)] 
qemu: migration: Make check for empty hook XML robust

Also consider whitespace only strings returned from the hook as empty
result.

(cherry picked from commit 19b1ee42b49b2764f7df23787f4b6022886a612c)

10 years agoqemu: restore: Fix restoring of VM when the restore hook returns empty XML
Peter Krempa [Wed, 22 Oct 2014 09:22:08 +0000 (11:22 +0200)] 
qemu: restore: Fix restoring of VM when the restore hook returns empty XML

The documentation for the restore hook states that returning an empty
XML is equivalent with copying the input. There was a bug in the code
checking the returned string by checking the string instead of the
contents. Use the new helper to check if the string is empty.

(cherry picked from commit e38677993734e9af3dbd0589e1cecd0b75f7e757)

10 years agoutil: string: Add helper to check whether string is empty
Peter Krempa [Wed, 22 Oct 2014 08:26:42 +0000 (10:26 +0200)] 
util: string: Add helper to check whether string is empty

The helper checks whether a string contains only whitespace or is NULL.
This will be helpful to skip cases where a user string is optional, but
may be provided empty with the same meaning.

(cherry picked from commit 0eeafeedebe4469fce33d7942551957853856619)

10 years agovirsh: domain: Use global constant for XML file size limit
Peter Krempa [Tue, 14 Oct 2014 08:04:31 +0000 (10:04 +0200)] 
virsh: domain: Use global constant for XML file size limit

Few places still used hardcoded limit for maximum XML size for commands
that accept XML files. The hardcoded limits ranged from 8k to 1M. Use
VSH_MAX_XML_FILE to express this limit in a unified way. This will bump
the limit for the commands that used hardcoded string lengths to 10M.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1152427
(cherry picked from commit 4d1852c48541a29e3c47caf0f2b801dfcb6579db)

10 years agoqemu: Fix hot unplug of SCSI_HOST device
John Ferlan [Tue, 23 Sep 2014 22:53:25 +0000 (18:53 -0400)] 
qemu: Fix hot unplug of SCSI_HOST device

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

Introduced by commit id '8f76ad99' the logic to detach a scsi_host
device (SCSI or iSCSI) fails when attempting to remove the 'drive'
because as I found in my investigation - the DelDevice takes care of
that for us.

The investigation turned up commits to adjust the logic for the
qemuMonitorDelDevice and qemuMonitorDriveDel processing for interfaces
(commit id '81f76598'), disk bus=VIRTIO,SCSI,USB (commit id '0635785b'),
and chr devices (commit id '55b21f9b'), but nothing with the host devices.

This commit uses the model for the previous set of changes and applies
it to the hostdev path. The call to qemuDomainDetachHostSCSIDevice will
return to qemuDomainDetachThisHostDevice handling either the audit of
the failure or the wait for the removal and then call into
qemuDomainRemoveHostDevice for the event, removal from the domain hostdev
list, and audit of the removal similar to other paths.

NOTE: For now the 'conn' param to +qemuDomainDetachHostSCSIDevice is left
as ATTRIBUTE_UNUSED.  Removing requires a cascade of other changes to be
left for a future patch.

(cherry picked from commit d2774e54cde2377c78a7572eb3fec0a663e5017f)

10 years agoqemu: unref cfg after TerminateMachine has been called
Martin Kletzander [Tue, 21 Oct 2014 09:44:13 +0000 (11:44 +0200)] 
qemu: unref cfg after TerminateMachine has been called

Commit 4882618ed13b469d92fa8b2b4a158fdb17dbe9f1 added the code that
requests driver cfg, but forgot to unref it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 9661ac2f46eeb4690a25dfc48bdf9dc9a4dfe822)

10 years agoAdd virCgroupTerminateMachine stub
Ján Tomko [Thu, 2 Oct 2014 09:05:50 +0000 (11:05 +0200)] 
Add virCgroupTerminateMachine stub

Fix the build on FreeBSD, broken by commit 4882618.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 99b2b4571d385eeffdc0ccbac426c66562e78933)

10 years agoqemu: use systemd's TerminateMachine to kill all processes
Guido Günther [Thu, 25 Sep 2014 11:32:58 +0000 (13:32 +0200)] 
qemu: use systemd's TerminateMachine to kill all processes

If we don't properly clean up all processes in the
machine-<vmname>.scope systemd won't remove the cgroup and subsequent vm
starts fail with

  'CreateMachine: File exists'

Additional processes can e.g. be added via

  echo $PID > /sys/fs/cgroup/systemd/machine.slice/machine-${VMNAME}.scope/tasks

but there are other cases like

  http://bugs.debian.org/761521

Invoke TerminateMachine to be on the safe side since systemd tracks the
cgroup anyway. This is a noop if all processes have terminated already.

(cherry picked from commit 4882618ed13b469d92fa8b2b4a158fdb17dbe9f1)

10 years agoutil: Prepare URI formatting for libxml2 >= 2.9.2
Martin Kletzander [Fri, 3 Oct 2014 16:27:01 +0000 (18:27 +0200)] 
util: Prepare URI formatting for libxml2 >= 2.9.2

Since commit 8eb55d782a2b9afacc7938694891cc6fad7b42a5 libxml2 removes
two slashes from the URI when there is no server part.  This is fixed
with beb7281055dbf0ed4d041022a67c6c5cfd126f25, but only if the calling
application calls xmlSaveUri() on URI that xmlURIParse() parsed.  And
that is not the case in virURIFormat().  virURIFormat() accepts
virURIPtr that can be created without parsing it and we do that when we
format network storage paths for gluster for example.  Even though
virStorageSourceParseBackingURI() uses virURIParse(), it throws that data
structure right away.

Since we want to format URIs as URIs and not absolute URIs or opaque
URIs (see RFC 3986), we can specify that with a special hack thanks to
commit beb7281055dbf0ed4d041022a67c6c5cfd126f25, by setting port to -1.

This fixes qemuxml2argvtest test where the disk-drive-network-gluster
case was failing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 8f17d0eaae7ee2fa3e214b79b188fc14ed5aa1eb)

10 years agosecurity_selinux: Don't relabel /dev/net/tun
Michal Privoznik [Tue, 7 Oct 2014 14:22:17 +0000 (16:22 +0200)] 
security_selinux: Don't relabel /dev/net/tun

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

The code for relabelling the TAP FD is there due to a race. When
libvirt creates a /dev/tapN device it's labeled as
'system_u:object_r:device_t:s0' by default. Later, when
udev/systemd reacts to this device, it's relabelled to the
expected label 'system_u:object_r:tun_tap_device_t:s0'. Hence, we
have a code that relabels the device, to cut the race down. For
more info see ae368ebfcc4.

But the problem is, the relabel function is called on all TUN/TAP
devices. Yes, on /dev/net/tun too. This is however a special kind
of device - other processes uses it too. We shouldn't touch it's
label then.

Ideally, there would an API in SELinux that would label just the
passed FD and not the underlying path. That way, we wouldn't need
to care as we would be not labeling /dev/net/tun but the FD
passed to the domain. Unfortunately, there's no such API so we
have to workaround until then.

Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ebc05263960f41065fa7d882959ea754b9281ab1)

10 years agoutil: eliminate "use after free" in callers of virNetDevLinkDump
Laine Stump [Wed, 15 Oct 2014 22:49:01 +0000 (00:49 +0200)] 
util: eliminate "use after free" in callers of virNetDevLinkDump

virNetDevLinkDump() gets a message from netlink into "resp", then
calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
then returns tb to its caller, but not before freeing the buffer at
resp. That means that all the callers of virNetDevLinkDump() are
examining memory that has already been freed. This can be verified by
filling the buffer at resp with garbage prior to freeing it (or, I
suppose, just running libvirtd under valgrind) then performing some
operation that calls virNetDevLinkDump().

The upstream commit log incorrectly states that the code has been like
this ever since virNetDevLinkDump() was written. In reality, the
problem was introduced with commit e95de74d, first in libvirt-1.0.5,
which was attempting to eliminate a typecast that caused compiler
warnings. It has only been pure luck (or maybe a lack of heavy load,
and/or maybe an allocation algorithm in malloc() that delays re-use of
just-freed memory) that has kept this from causing errors, for example
when configuring a PCI passthrough or macvtap passthrough network
interface.

The solution taken in this patch is the simplest - just return resp to
the caller along with tb, then have the caller free it after they are
finished using the data (pointers) in tb. I alternately could have
made a cleaner interface by creating a new struct that put tb and resp
together along with a vir*Free() function for it, but this function is
only used in a couple places, and I'm not sure there will be
additional new uses of virNetDevLinkDump(), so the value of adding a
new type, extra APIs, etc. is dubious.

(cherry picked from commit f9f9699f40729556238b905f67a7d6f68c084f6a)

10 years agoCVE-2014-7823: dumpxml: security hole with migratable flag
Eric Blake [Thu, 6 Nov 2014 08:42:24 +0000 (09:42 +0100)] 
CVE-2014-7823: dumpxml: security hole with migratable flag

Commit 28f8dfd (v1.0.0) introduced a security hole: in at least
the qemu implementation of virDomainGetXMLDesc, the use of the
flag VIR_DOMAIN_XML_MIGRATABLE (which is usable from a read-only
connection) triggers the implicit use of VIR_DOMAIN_XML_SECURE
prior to calling qemuDomainFormatXML.  However, the use of
VIR_DOMAIN_XML_SECURE is supposed to be restricted to read-write
clients only.  This patch treats the migratable flag as requiring
the same permissions, rather than analyzing what might break if
migratable xml no longer includes secret information.

Fortunately, the information leak is low-risk: all that is gated
by the VIR_DOMAIN_XML_SECURE flag is the VNC connection password;
but VNC passwords are already weak (FIPS forbids their use, and
on a non-FIPS machine, anyone stupid enough to trust a max-8-byte
password sent in plaintext over the network deserves what they
get).  SPICE offers better security than VNC, and all other
secrets are properly protected by use of virSecret associations
rather than direct output in domain XML.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_GET_XML_DESC):
Tighten rules on use of migratable flag.
* src/libvirt-domain.c (virDomainGetXMLDesc): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit b1674ad5a97441b7e1bd5f5ebaff498ef2fbb11b)

Conflicts:
src/libvirt-domain.c - file split from older src/libvirt.c
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: x86_64 is good enough for i686
Lubomir Rintel [Thu, 16 Oct 2014 19:28:00 +0000 (21:28 +0200)] 
qemu: x86_64 is good enough for i686

virt-manager on Fedora sets up i686 hosts with "/usr/bin/qemu-kvm" emulator,
which in turn unconditionally execs qemu-system-x86_64 querying capabilities
then fails:

Error launching details: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/engine.py", line 748, in _show_vm_helper
    details = self._get_details_dialog(uri, vm.get_connkey())
  File "/usr/share/virt-manager/virtManager/engine.py", line 726, in _get_details_dialog
    obj = vmmDetails(conn.get_vm(connkey))
  File "/usr/share/virt-manager/virtManager/details.py", line 399, in __init__
    self.init_details()
  File "/usr/share/virt-manager/virtManager/details.py", line 784, in init_details
    domcaps = self.vm.get_domain_capabilities()
  File "/usr/share/virt-manager/virtManager/domain.py", line 518, in get_domain_capabilities
    self.get_xmlobj().os.machine, self.get_xmlobj().type)
  File "/usr/lib/python2.7/site-packages/libvirt.py", line 3492, in getDomainCapabilities
    if ret is None: raise libvirtError ('virConnectGetDomainCapabilities() failed', conn=self)
libvirtError: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'

Journal:

Oct 16 21:08:26 goatlord.localdomain libvirtd[1530]: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'

(cherry picked from commit afe8f4200f6e80d2510731165dd2cdae741bd9fb)

10 years agoqemu: Don't compare CPU against host for TCG
Cole Robinson [Tue, 23 Sep 2014 17:07:09 +0000 (13:07 -0400)] 
qemu: Don't compare CPU against host for TCG

Right now when building the qemu command line, we try to do various
unconditional validations of the guest CPU against the host CPU. However
this checks are overly applied. The only time we should use the checks
are:

- The user requests host-model/host-passthrough, or

- When KVM is requsted. CPU features requested in TCG mode are always
  emulated by qemu and are independent of the host CPU, so no host CPU
  checks should be performed.

Right now if trying to specify a CPU for arm on an x86 host, it attempts
to do non-sensical validation and falls over.

Switch all the test cases that were intending to test CPU validation to
use KVM, so they continue to test the intended code.

Amend some aarch64 XML tests with a CPU model, to ensure things work
correctly.

(cherry picked from commit cf7fce8f2fd1c930f357fd4ff93ac35f38eb30c6)

10 years agoqemu_command: Split qemuBuildCpuArgStr
Cole Robinson [Tue, 23 Sep 2014 15:35:57 +0000 (11:35 -0400)] 
qemu_command: Split qemuBuildCpuArgStr

Move the CPU mode/model handling to its own function. This is just
code movement and re-indentation.

(cherry picked from commit e1d872dc77c80d43036f928f83f560f2e9286148)

11 years agoRelease of libvirt-1.2.9 v1.2.9
Daniel Veillard [Wed, 1 Oct 2014 08:45:32 +0000 (16:45 +0800)] 
Release of libvirt-1.2.9

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

11 years agodomain_conf: fix domain deadlock CVE-2014-3657
Pavel Hrdina [Mon, 22 Sep 2014 16:19:07 +0000 (18:19 +0200)] 
domain_conf: fix domain deadlock

If you use public api virConnectListAllDomains() with second parameter
set to NULL to get only the number of domains you will lock out all
other operations with domains.

Introduced by commit 2c680804.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoAllow setting migration max downtime any time
Chris St. Pierre [Mon, 29 Sep 2014 13:45:28 +0000 (13:45 +0000)] 
Allow setting migration max downtime any time

This removes the artificial and unnecessary restriction that
virDomainSetMaxDowntime() only be called while a migration is in
progress.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemu: monitor: Avoid shadowing variable "devname" on FreeBSD
Peter Krempa [Tue, 30 Sep 2014 09:41:43 +0000 (11:41 +0200)] 
qemu: monitor: Avoid shadowing variable "devname" on FreeBSD

FreeBSD's compiler complains that we shadow the symbol. Sigh.

s/devname/dev_name/

11 years agoqemu: monitor: return block stats data as a hash to avoid disk mixup
Peter Krempa [Thu, 25 Sep 2014 08:12:15 +0000 (10:12 +0200)] 
qemu: monitor: return block stats data as a hash to avoid disk mixup

The current block stats code matched up the disk name with the actual
stats by the order in the data returned from qemu. This unfortunately
isn't right as qemu may return the disks in any order. Fix this by
returning a hash of stats and index them by the disk alias.

11 years agoAlso filter out non-migratable features out of host-passthrough
Ján Tomko [Mon, 29 Sep 2014 10:44:43 +0000 (12:44 +0200)] 
Also filter out non-migratable features out of host-passthrough

Commit de0aeaf filtered them out from the host-model features,
to allow host-model to be migratable by default.

Even though they are not passed to QEMU for host-passthrough,
(and not enabled by default) filter them out too
so the user does not think the domain has them.

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

11 years agoDon't verify CPU features with host-passthrough
Ján Tomko [Mon, 29 Sep 2014 13:58:38 +0000 (15:58 +0200)] 
Don't verify CPU features with host-passthrough

Commit fba6bc4 introduced the non-migratable invtsc feature,
breaking save/migration with host-model and host-passthrough.

On hosts with this feature present it was automatically included
in the CPU definition, regardless of QEMU support.

Commit de0aeaf stopped including it by default for host-model,
but failed to fix host-passthrough.

This commit ignores checking of CPU features with host-passthrough,
since we don't pass them to QEMU (only -cpu host is passed),
allowing domains using host-passthrough that were saved with
the broken version of libvirtd to be restored.

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

11 years agoFix crash cpu_shares change event crash on domain startup v1.2.9-rc2
Ján Tomko [Mon, 29 Sep 2014 11:47:44 +0000 (13:47 +0200)] 
Fix crash cpu_shares change event crash on domain startup

Introduced by commit 0dce260.

qemuDomainEventQueue was called with qemuDomainObjPrivatePtr instead
of virQEMUDriverPtr.

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

11 years agostorage: Fix logical pool fmt type
Erik Skultety [Thu, 25 Sep 2014 14:26:18 +0000 (16:26 +0200)] 
storage: Fix logical pool fmt type

According to our documentation logical pool supports formats 'auto' and
'lvm2'. However, in storage_conf.c we previously defined storage pool
formats: unknown, lvm2. Due to backward compatibility reasons
we must continue refer to pool format type 'unknown' instead of 'auto'.

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

11 years agovirsh: Fix help message of allocpages
Tomoki Sekiyama [Fri, 26 Sep 2014 22:57:22 +0000 (18:57 -0400)] 
virsh: Fix help message of allocpages

Fix info in the command definition of allocpages, which is currently
pointing info for 'capabilities'.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
11 years agoqemu: remove capabilities.monitor.sock when done
Guido Günther [Thu, 25 Sep 2014 08:30:58 +0000 (10:30 +0200)] 
qemu: remove capabilities.monitor.sock when done

Prompted by

   http://bugs.debian.org/761131

11 years agoconf: report error in virCPUDefParseXML
Jincheng Miao [Thu, 25 Sep 2014 11:28:33 +0000 (19:28 +0800)] 
conf: report error in virCPUDefParseXML

When detected invalid 'memAccess', virCPUDefParseXML should report error.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
11 years agoCheck for NULL in qemu monitor event filter
Ján Tomko [Mon, 22 Sep 2014 11:54:52 +0000 (13:54 +0200)] 
Check for NULL in qemu monitor event filter

When virConnectDomainQemuMonitorEventRegister is called with the
VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX flag,
ignore the flag instead of crashing.

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

11 years agoFix typo s/EMULATORIN/EMULATORPIN/
Daniel P. Berrange [Fri, 26 Sep 2014 10:20:56 +0000 (11:20 +0100)] 
Fix typo s/EMULATORIN/EMULATORPIN/

Fix the typo in VIR_DOMAIN_TUNABLE_CPU_EMULATORIN

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRename tunable event constants
Daniel P. Berrange [Thu, 25 Sep 2014 16:48:01 +0000 (17:48 +0100)] 
Rename tunable event constants

For the new VIR_DOMAIN_EVENT_ID_TUNABLE event we have a bunch of
constants added

   VIR_DOMAIN_EVENT_CPUTUNE_<blah>
   VIR_DOMAIN_EVENT_BLKDEVIOTUNE_<blah>

This naming convention is bad for two reasons

  - There is no common prefix unique for the events to both
    relate them, and distinguish them from other event
    constants

  - The values associated with the constants were chosen
    to match the names used with virConnectGetAllDomainStats
    so having EVENT in the constant name is not applicable in
    that respect

This patch proposes renaming the constants to

    VIR_DOMAIN_TUNABLE_CPU_<blah>
    VIR_DOMAIN_TUNABLE_BLKDEV_<blah>

ie, given them a common VIR_DOMAIN_TUNABLE prefix.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agolxc_monitor_protocol: Redefine xdr_uint64_t if needed
Michal Privoznik [Tue, 23 Sep 2014 08:44:42 +0000 (10:44 +0200)] 
lxc_monitor_protocol: Redefine xdr_uint64_t if needed

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

On some systems (using libtirpc instead of glibc's
implementation), xdr_uint64_t exists rather under different name:
xdr_u_int64_t. This makes compilation fail then:

libvirt_lxc-lxc_monitor_protocol.o: In function `xdr_virLXCMonitorInitEventMsg':
/usr/local/src/libvirt/libvirt-1.1.1/src/./lxc/lxc_monitor_protocol.c:31: undefined reference to `xdr_uint64_t'

Therefore we rather mirror the d707c866 commit and redefine
xdr_uint64_t if needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemuPrepareNVRAM: Save domain after NVRAM path generation
Michal Privoznik [Thu, 25 Sep 2014 12:39:19 +0000 (14:39 +0200)] 
qemuPrepareNVRAM: Save domain after NVRAM path generation

On a domain startup, the variable store path is generated if needed.
The path is intended to be generated only once. However, the updated
domain definition is not saved into config dir rather than state XML
only. So later, whenever the domain is destroyed and the daemon is
restarted, the generated path is forgotten and the file may be left
behind on virDomainUndefine() call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoremoteNodeGetFreePages: Don't alloc args.pages.pages_val
Michal Privoznik [Thu, 25 Sep 2014 09:18:50 +0000 (11:18 +0200)] 
remoteNodeGetFreePages: Don't alloc args.pages.pages_val

There's no one to free() it anyway. Instead, we can just pass the
provided array pointer directly.

==20039== 48 bytes in 4 blocks are definitely lost in loss record 658 of 787
==20039==    at 0x4C2A700: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20039==    by 0x4EA661F: virAllocN (viralloc.c:191)
==20039==    by 0x50386EF: remoteNodeGetFreePages (remote_driver.c:7625)
==20039==    by 0x5003504: virNodeGetFreePages (libvirt.c:21379)
==20039==    by 0x154625: cmdFreepages (virsh-host.c:374)
==20039==    by 0x12F718: vshCommandRun (virsh.c:1935)
==20039==    by 0x1339FB: main (virsh.c:3747)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonodeinfo: fix version of nodeAllocPages
Tomoki Sekiyama [Thu, 25 Sep 2014 20:02:21 +0000 (16:02 -0400)] 
nodeinfo: fix version of nodeAllocPages

Fix comments about the version in which '.nodeAllocPages' are added.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
11 years agoqemu: Always re-detect backing chain
Peter Krempa [Thu, 25 Sep 2014 15:30:28 +0000 (17:30 +0200)] 
qemu: Always re-detect backing chain

Since 363e9a68 we track backing chain metadata when creating snapshots
the right way even for the inactive configuration. As we did not yet
update other code paths that modify the backing chain (blockpull) the
newDef backing chain gets out of sync.

After stopping of a VM the new definition gets copied to the next start
one. The new VM then has incorrect backing chain info. This patch
switches the backing chain detector to always purge the existing backing
chain and forces re-detection to avoid this issue until we'll have full
backing chain tracking support.

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

11 years agoevent_example: cleanup example code for tunable event
Pavel Hrdina [Thu, 25 Sep 2014 13:03:46 +0000 (15:03 +0200)] 
event_example: cleanup example code for tunable event

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agovirNodeAllocPages: Disallow RO connection
Michal Privoznik [Thu, 25 Sep 2014 15:12:46 +0000 (17:12 +0200)] 
virNodeAllocPages: Disallow RO connection

Due to a missing check the API can be successfully called even if
the connection is ReadOnly. Fortunately, the API hasn't been
released yet, so there's no need for a CVE.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoparallels: login to parallels SDK
Dmitry Guryanov [Thu, 11 Sep 2014 16:24:03 +0000 (20:24 +0400)] 
parallels: login to parallels SDK

Add files parallels_sdk.c and parallels_sdk.h for code
which works with SDK, so libvirt's code will not mix with
dealing with parallels SDK.

To use Parallels SDK you must first call PrlApi_InitEx function,
and then you will be able to connect to a server with
PrlSrv_LoginLocalEx function. When you've done you must call
PrlApi_Deinit. So let's call PrlApi_InitEx on first .connectOpen,
count number of connections and deinitialize, when this counter
becomes zero.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
11 years agoparallels: build with parallels SDK
Dmitry Guryanov [Thu, 11 Sep 2014 16:24:02 +0000 (20:24 +0400)] 
parallels: build with parallels SDK

Executing prlctl command is not an optimal way to interact with
Parallels Cloud Server (PCS), it's better to use parallels SDK,
which is a remote API to paralles dispatcher service.

We prepared opensource version of this SDK and published it on
github, it's distributed under LGPL license. Here is a git repo:
https://github.com/Parallels/parallels-sdk.

To build with parallels SDK user should get compiler and linker
options from pkg-config 'parallels-sdk' file. So fix checks in
configure script and build with parallels SDK, if that pkg-config
file exists and add gcc options to makefile.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
11 years agovirnetserver: Raise log level of max_clients related messages
Michal Privoznik [Thu, 25 Sep 2014 09:50:04 +0000 (11:50 +0200)] 
virnetserver: Raise log level of max_clients related messages

We have these configuration knobs, like max_clients and
max_anonymous_clients. They limit the number of clients
connected.  Whenever the limit is reached, the daemon stops
accepting new ones and resumes if one of the connected clients
disconnects. If that's the case, a debug message is printed into
the logs. And when the daemon starts over to accept new clients
too. However, the problem is the messages have debug priority.
This may be unfortunate, because if the daemon stops accepting
new clients all of a sudden, and users don't have debug logs
enabled they have no idea what's going on. Raise the messages
level to INFO at least.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agopolkit_driver: fix possible segfault
Pavel Hrdina [Thu, 25 Sep 2014 09:13:29 +0000 (11:13 +0200)] 
polkit_driver: fix possible segfault

The changes in commit c7542573 introduced possible segfault. Looking
deeper into the code and the original code before the patch series were
applied I think that we should report error for each function failure
and also we shouldn't call some of the function twice.

Found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoblkdeviotune: trigger tunable event for blkdeviotune updates
Pavel Hrdina [Thu, 25 Sep 2014 09:30:57 +0000 (11:30 +0200)] 
blkdeviotune: trigger tunable event for blkdeviotune updates

Use the universal tunable event to report changes to user. All
blkdeviotune values are prefixed with "blkdeviotune".

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoblkdeviotune: fix bug with saving values into live XML
Pavel Hrdina [Thu, 25 Sep 2014 09:28:25 +0000 (11:28 +0200)] 
blkdeviotune: fix bug with saving values into live XML

When you updated some blkdeviotune values for running domain the values
were stored only internally, but not saved into the live XML so they
won't survive restarting the libvirtd.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoFix build without polkit v1.2.9-rc1
Pavel Hrdina [Thu, 25 Sep 2014 08:57:24 +0000 (10:57 +0200)] 
Fix build without polkit

The commit 1b854c76 introduced a new function 'virPolkitCheckAuth' and
in the #else section when you don't have polkit all attributes should be
follwed by ATTRIBUTE_UNUSED.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agotunable_event: extend debug message and tweak limit for remote message
Pavel Hrdina [Wed, 24 Sep 2014 07:43:31 +0000 (09:43 +0200)] 
tunable_event: extend debug message and tweak limit for remote message

It would be nice to also print a params pointer and number of params in
the debug message and the previous limit for number of params in the rpc
message was too large. The 2048 params will be enough for future events.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agovirsh: Expose virNodeAllocPages
Michal Privoznik [Wed, 17 Sep 2014 13:53:42 +0000 (15:53 +0200)] 
virsh: Expose virNodeAllocPages

The new virsh command is named 'allocpages'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonodeinfo: Implement nodeAllocPages
Michal Privoznik [Thu, 18 Sep 2014 07:47:07 +0000 (09:47 +0200)] 
nodeinfo: Implement nodeAllocPages

And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirnuma: Introduce virNumaSetPagePoolSize
Michal Privoznik [Thu, 18 Sep 2014 07:24:16 +0000 (09:24 +0200)] 
virnuma: Introduce virNumaSetPagePoolSize

This internal API can be used to allocate or free some pages in
the huge pages pool.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoIntroduce virNodeAllocPages
Michal Privoznik [Tue, 16 Sep 2014 16:17:22 +0000 (18:17 +0200)] 
Introduce virNodeAllocPages

A long time ago in a galaxy far, far away it has been decided
that libvirt will manage not only domains but host as well. And
with my latest work on qemu driver supporting huge pages, we miss
the cherry on top: an API to allocate huge pages on the run.
Currently users are forced to log into the host and adjust the
huge pages pool themselves.  However, with this API the problem
is gone - they can both size up and size down the pool.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonodeGetFreePages: Push forgotten change
Michal Privoznik [Wed, 24 Sep 2014 13:10:18 +0000 (15:10 +0200)] 
nodeGetFreePages: Push forgotten change

In the previous patch I've changed the for loop bounds but forgot
to 'git add' changes that adapt the rest of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agosecurity: Fix labelling host devices (bz 1145968)
Cole Robinson [Wed, 24 Sep 2014 15:47:46 +0000 (11:47 -0400)] 
security: Fix labelling host devices (bz 1145968)

The check for ISCSI devices was missing a check of subsys type, which
meant we could skip labelling of other host devices as well. This fixes
USB hotplug on F21

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

11 years agoFix MinGW build
Pavel Hrdina [Wed, 24 Sep 2014 09:07:08 +0000 (11:07 +0200)] 
Fix MinGW build

When building on mingw the format string for long long/unsigned long
long have to be I64d/I64u instead of lld/llu.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoConvert polkit code to use DBus API instead of CLI helper
Daniel P. Berrange [Wed, 10 Sep 2014 13:52:48 +0000 (14:52 +0100)] 
Convert polkit code to use DBus API instead of CLI helper

Spawning the pkcheck program every time a permission check is
required is hugely expensive on CPU. The pkcheck program is just
a dumb wrapper for the DBus API, so rewrite the code to use the
DBus API directly. This also simplifies error handling a bit.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSupport passing dict by reference for dbus messages
Daniel P. Berrange [Tue, 9 Sep 2014 14:19:58 +0000 (15:19 +0100)] 
Support passing dict by reference for dbus messages

Currently DBus dict values must be passed inline

   virDBusMessageEncode("a{ss}",
                        3,
                        "key1", "val1",
                        "key2", "val2",
                        "key3", "val3");
   virDBusMessageDecode("a{ss}",
                        3,
                        &key1, &val1,
                        &key2, &val2,
                        &key3, &val3);

This allows them to be passed by reference

   const char **dictin = {
      "key1", "val1",
      "key2", "val2",
      "key3", "val3"
   };
   char **dictout;
   size_t ndictout;

   virDBusMessageEncode("a&{ss}",
                        ARRAY_CARDINALITY(dict) / 2,
                        dictin);
   virDBusMessageDecode("a&{ss}",
                        &ndictout,
                        &dictout);

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert remote daemon & acl code to use polkit API
Daniel P. Berrange [Thu, 22 Aug 2013 16:09:03 +0000 (17:09 +0100)] 
Convert remote daemon & acl code to use polkit API

Convert the remote daemon auth check and the access control
code to use the common polkit API for checking auth.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert callers to use typesafe APIs for getting identity attrs
Daniel P. Berrange [Thu, 22 Aug 2013 16:02:40 +0000 (17:02 +0100)] 
Convert callers to use typesafe APIs for getting identity attrs

Convert virAccessDriverPolkitFormatProcess to use typesafe API
for getting process ID attribute.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoConvert callers to use typesafe APIs for setting identity attrs
Daniel P. Berrange [Thu, 22 Aug 2013 15:58:58 +0000 (16:58 +0100)] 
Convert callers to use typesafe APIs for setting identity attrs

Update virNetServerClientCreateIdentity and virIdentityGetSystem
to use the new typesafe APIs for setting identity attributes

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd typesafe APIs for virIdentity attributes
Daniel P. Berrange [Thu, 22 Aug 2013 15:43:35 +0000 (16:43 +0100)] 
Add typesafe APIs for virIdentity attributes

Instead of requiring the caller to format to/from strings,
add typesafe APIs todo this work.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd common API for doing polkit authentication
Daniel P. Berrange [Thu, 22 Aug 2013 13:27:19 +0000 (14:27 +0100)] 
Add common API for doing polkit authentication

There are now two places in libvirt which use polkit. Currently
they use pkexec, which is set to be replaced by direct DBus API
calls. Add a common API which they will both be able to use for
this purpose.

No tests are added at this time, since the impl will be gutted
in favour of a DBus API call shortly.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: wire up virtio-net segment offloading options
Ján Tomko [Thu, 11 Sep 2014 10:58:04 +0000 (12:58 +0200)] 
qemu: wire up virtio-net segment offloading options

Format the segment offloading options specified by
<driver>
  <host .../>
  <guest .../>
</driver>
on virtio-net command line.

11 years agoconf: add options for disabling segment offloading
Ján Tomko [Thu, 11 Sep 2014 10:56:31 +0000 (12:56 +0200)] 
conf: add options for disabling segment offloading

Add options for tuning segment offloading:
<driver>
  <host csum='off' gso='off' tso4='off' tso6='off'
        ecn='off' ufo='off'/>
  <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/>
</driver>
which control the respective host_ and guest_ properties
of the virtio-net device.

11 years agonodeinfo: fix nodeGetFreePages when max node is zero
Jincheng Miao [Wed, 24 Sep 2014 05:45:30 +0000 (13:45 +0800)] 
nodeinfo: fix nodeGetFreePages when max node is zero

In nodeGetFreePages, if startCell is given by '0',
and the max node number is '0' too. The for-loop
wouldn't be executed.
So convert it to while-loop.

Before:
> virsh freepages --cellno 0 --pagesize 4
error: internal error: no suitable info found

After:
> virsh freepages --cellno 0 --pagesize 4
4KiB: 472637

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoLXC: emphasis uid start of idmap only accept '0' in docs
Chen Hanxiao [Tue, 23 Sep 2014 03:40:03 +0000 (11:40 +0800)] 
LXC: emphasis uid start of idmap only accept '0' in docs

We don't accept any other values except '0'.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoFix bug with loading bridge name for active domain during libvirtd start
Pavel Hrdina [Thu, 18 Sep 2014 13:06:44 +0000 (15:06 +0200)] 
Fix bug with loading bridge name for active domain during libvirtd start

If you have a bridge network in running domain and libvirtd is restarted
the information about host bridge interface is lost from live xml.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agostorage: Improve error message when traversing backing chains
Peter Krempa [Thu, 11 Sep 2014 17:09:48 +0000 (19:09 +0200)] 
storage: Improve error message when traversing backing chains

Report also the name of the parent file and uid/gid used to access it to
help debugging broken storage configurations.

11 years agoqemu: Report better errors from broken backing chains
Peter Krempa [Thu, 11 Sep 2014 16:59:32 +0000 (18:59 +0200)] 
qemu: Report better errors from broken backing chains

Request erroring out from the backing chain traveller and drop qemu's
internal backing chain integrity tester.

The backing chain traveller reports errors by itself with possibly more
detail than qemuDiskChainCheckBroken ever could.

We also need to make sure that we reconnect to existing qemu instances
even at the cost of losing the backing chain info (this really should be
stored in the XML rather than reloaded from disk, but that needs some
work).

11 years agoqemu: Sanitize argument names and empty disk check in qemuDomainDetermineDiskChain
Peter Krempa [Thu, 18 Sep 2014 09:21:10 +0000 (11:21 +0200)] 
qemu: Sanitize argument names and empty disk check in qemuDomainDetermineDiskChain

Reuse virStorageSourceIsEmpty and rename "force" argument to
"force_probe".

11 years agoutil: storage: Allow metadata crawler to report useful errors
Peter Krempa [Thu, 11 Sep 2014 16:28:47 +0000 (18:28 +0200)] 
util: storage: Allow metadata crawler to report useful errors

Add a new parameter to virStorageFileGetMetadata that will break the
backing chain detection process and report useful error message rather
than having to use virStorageFileChainGetBroken.

This patch just introduces the option, usage will be provided
separately.

11 years agolibvirt-guests: run after time-sync.target
Jim Fehlig [Mon, 8 Sep 2014 16:22:14 +0000 (10:22 -0600)] 
libvirt-guests: run after time-sync.target

When libvirt-guests is configured to start guests on host
boot, it is possible for guests start and read the host
clock before it is synchronized.  Services such as
libvirt-guests that require correct time should use the
Special Passive System Unit time-sync.target

http://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target

11 years agocputune_event: queue the event for cputune updates
Pavel Hrdina [Tue, 9 Sep 2014 14:34:12 +0000 (16:34 +0200)] 
cputune_event: queue the event for cputune updates

Now we have universal tunable event so we can use it for reporting
changes to user. The cputune values will be prefixed with "cputune" to
distinguish it from other tunable events.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoadd an example how to use tunable event
Pavel Hrdina [Tue, 26 Aug 2014 21:47:44 +0000 (23:47 +0200)] 
add an example how to use tunable event

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoevent: introduce new event for tunable values
Pavel Hrdina [Wed, 10 Sep 2014 11:28:24 +0000 (13:28 +0200)] 
event: introduce new event for tunable values

This new event will use typedParameters to expose what has been actually
updated and the reason is that we can in the future extend any tunable
values or add new tunable values. With typedParameters we don't have to
worry about creating some other events, we will just use this universal
event to inform user about updates.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoqemu: Fix memory leak in RDMA migration code
Jiri Denemark [Tue, 23 Sep 2014 13:22:24 +0000 (15:22 +0200)] 
qemu: Fix memory leak in RDMA migration code

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoconf: sanitize tap and vhost paths
Martin Kletzander [Mon, 22 Sep 2014 14:26:53 +0000 (16:26 +0200)] 
conf: sanitize tap and vhost paths

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoqemuBuildNumaArgStr: Discard def->cpu check
Michal Privoznik [Tue, 23 Sep 2014 11:08:39 +0000 (13:08 +0200)] 
qemuBuildNumaArgStr: Discard def->cpu check

In the function at one place we check if def->cpu is NULL prior
to accessing def->cpu->ncells. Then, later in the code,
def->cpu->ncells is accessed directly, without the check. This
makes coverity unhappy, because the first check makes it think
def->cpu can be NULL. However, the function is not called if
def->cpu is NULL. Therefore, remove the first check and hopefully
make coverity cheer again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonodeinfo: Prefer MIN in nodeGetFreePages
Michal Privoznik [Tue, 23 Sep 2014 09:34:06 +0000 (11:34 +0200)] 
nodeinfo: Prefer MIN in nodeGetFreePages

It's better to use a macro instead of if-else construct.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agodomain_conf: separate structures from virDomainDef
Pavel Hrdina [Tue, 16 Sep 2014 16:41:12 +0000 (18:41 +0200)] 
domain_conf: separate structures from virDomainDef

Cleanup virDomanDef structure from other nested structure and create
separate type definition for them.

Fix a typo in virDomainHugePage.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agoFix typo of virNodeGetFreePages comment
Jincheng Miao [Mon, 22 Sep 2014 10:14:28 +0000 (18:14 +0800)] 
Fix typo of virNodeGetFreePages comment

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
11 years agonodeinfo: report error when given node is out of range
Jincheng Miao [Mon, 22 Sep 2014 10:14:27 +0000 (18:14 +0800)] 
nodeinfo: report error when given node is out of range

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirsh-host: fix pagesize unit of freepages
Jincheng Miao [Mon, 22 Sep 2014 10:14:26 +0000 (18:14 +0800)] 
virsh-host: fix pagesize unit of freepages

The unit of '--pagesize' of freepages is kibibytes.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemu: Memory pre-pinning support for RDMA migration
Michael R. Hines [Mon, 13 Jan 2014 06:28:12 +0000 (14:28 +0800)] 
qemu: Memory pre-pinning support for RDMA migration

RDMA Live migration requires registering memory with the hardware, and
thus QEMU offers a new 'capability' to pre-register / mlock() the guest
memory in advance for higher RDMA performance before the migration
begins. This capability is disabled by default, which means QEMU will
register the memory with the hardware in an on-demand basis.

This patch exposes this capability with the following example usage:

virsh migrate --live --rdma-pin-all --migrateuri rdma://hostname domain qemu+ssh://hostname/system

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemu: RDMA migration support
Michael R. Hines [Mon, 13 Jan 2014 06:28:11 +0000 (14:28 +0800)] 
qemu: RDMA migration support

This patch adds support for RDMA protocol in migration URIs.

USAGE: $ virsh migrate --live --migrateuri rdma://hostname domain qemu+ssh://hostname/system

Since libvirt runs QEMU in a pretty restricted environment, several
files needs to be added to cgroup_device_acl (in qemu.conf) for QEMU to
be able to access the host's infiniband hardware. Full documenation of
the feature can be found on QEMU wiki:
http://wiki.qemu.org/Features/RDMALiveMigration

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemu: Add RDMA migration capabilities
Jiri Denemark [Thu, 11 Sep 2014 12:11:54 +0000 (14:11 +0200)] 
qemu: Add RDMA migration capabilities