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

10 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.

10 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>
10 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>
10 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>
10 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.

10 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).

10 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".

10 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.

10 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

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 years agoqemu: Add RDMA migration capabilities
Jiri Denemark [Thu, 11 Sep 2014 12:11:54 +0000 (14:11 +0200)]
qemu: Add RDMA migration capabilities

10 years agoqemu: Prepare support for arbitrary migration protocol
Jiri Denemark [Mon, 15 Sep 2014 16:15:42 +0000 (18:15 +0200)]
qemu: Prepare support for arbitrary migration protocol

Currently we only support TCP protocol for native QEMU migration but
this is going to be changed. Let's make the code more general and remove
hardcoded TCP protocol from several places.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Fix old tcp:host URIs more cleanly
Jiri Denemark [Mon, 15 Sep 2014 16:13:38 +0000 (18:13 +0200)]
qemu: Fix old tcp:host URIs more cleanly

For compatibility with old libvirt we need to support both tcp:host and
tcp://host migration URIs. Let's make the code that parses them a bit
cleaner.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Expose additional migration statistics
Michael R. Hines [Mon, 13 Jan 2014 06:28:10 +0000 (14:28 +0800)]
qemu: Expose additional migration statistics

RDMA migration uses the 'setup' state in QEMU to optionally lock
all memory before the migration starts. The total time spent in
this state is exposed as VIR_DOMAIN_JOB_SETUP_TIME.

Additionally, QEMU also exports migration throughput (mbps) for both
memory and disk, so let's add them too: VIR_DOMAIN_JOB_MEMORY_BPS,
VIR_DOMAIN_JOB_DISK_BPS.

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agocpu: fix wrong single quote mark
Chen Fan [Tue, 23 Sep 2014 01:45:21 +0000 (09:45 +0800)]
cpu: fix wrong single quote mark

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agocpu: remove repeated word in error message
Daniel P. Berrange [Mon, 22 Sep 2014 15:41:42 +0000 (16:41 +0100)]
cpu: remove repeated word in error message

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoqemu: raise an error when trying to use readonly sata disks
Giuseppe Scrivano [Mon, 22 Sep 2014 13:58:21 +0000 (15:58 +0200)]
qemu: raise an error when trying to use readonly sata disks

commit 72f919f558902968bd0cf9f99f25ac62cbfe3ac6 introduced an user
friendly error message when trying to use IDE disks as readonly.

Do the same thing for the SATA bus.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1112939
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
10 years agoqemu: hook: Provide hook when restoring a domain save image
Peter Krempa [Wed, 17 Sep 2014 09:38:39 +0000 (11:38 +0200)]
qemu: hook: Provide hook when restoring a domain save image

10 years agodocs: specify vhost-net instead of net-vhost
Jianwei Hu [Mon, 22 Sep 2014 13:12:18 +0000 (21:12 +0800)]
docs: specify vhost-net instead of net-vhost

For the tap backend the default is specified and the same should be
done for the vhost attribute.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoschema: properly set tap and vhost backend attributes optional
Jianwei Hu [Mon, 22 Sep 2014 13:46:29 +0000 (21:46 +0800)]
schema: properly set tap and vhost backend attributes optional

Each attribute is optional, commit af8b4a2 forgot to mention that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: save image: Split out checks done only when editing the save img
Peter Krempa [Wed, 17 Sep 2014 13:27:33 +0000 (15:27 +0200)]
qemu: save image: Split out checks done only when editing the save img

Move them to the single corresponding function rather than having them
in the common chunk of code.

10 years agoqemu: save image: Split out new definition check/update
Peter Krempa [Wed, 17 Sep 2014 13:06:18 +0000 (15:06 +0200)]
qemu: save image: Split out new definition check/update

Split out the call to the update method only to places where it is
actually used rather than having a mega-method that does all the stuff.

10 years agoqemu: save image: Add possibility to return XML stored in the image
Peter Krempa [Wed, 17 Sep 2014 12:50:04 +0000 (14:50 +0200)]
qemu: save image: Add possibility to return XML stored in the image

Add a new parameter that will allow to return the XML stored in the save
image for further manipulation and adjust the callers. This option will
be used in later patches.

10 years agoqemu: save image: Split out user provided XML checker
Peter Krempa [Wed, 17 Sep 2014 12:23:05 +0000 (14:23 +0200)]
qemu: save image: Split out user provided XML checker

Extract code used to check save image XMLs provided by users to separate
use.

10 years agolibxl: Drop driver lock in libxlDomainDefineXML
Jim Fehlig [Thu, 18 Sep 2014 21:05:34 +0000 (15:05 -0600)]
libxl: Drop driver lock in libxlDomainDefineXML

There is no need to acquire the driver-wide lock in
libxlDomainDefineXML.  When switching to jobs in the libxl
driver, most driver-wide locks were removed.  The locking here
was preserved since I mistakenly thought virDomainObjListAdd
needed protection.  This is not the case, so remove the
unnecessary locking.

10 years agoqemu: Process the hostdev "rawio" setting
John Ferlan [Tue, 9 Sep 2014 22:51:02 +0000 (18:51 -0400)]
qemu: Process the hostdev "rawio" setting

Mimic the "Disk" processing for 'rawio', but for a scsi_host hostdev
lun device.

10 years agohostdev: Add "rawio" attribute to _virDomainHostdevSubsysSCSI
John Ferlan [Tue, 9 Sep 2014 22:48:57 +0000 (18:48 -0400)]
hostdev: Add "rawio" attribute to _virDomainHostdevSubsysSCSI

Add the 'rawio' attribute to match _virDomainDiskDef and process the
hostdev XML similarly to the disk XML for a lun which supports/requires rawio

10 years agodomain_conf: Change virDomainDiskDef 'rawio' to use virTristateBool
John Ferlan [Thu, 18 Sep 2014 17:54:18 +0000 (13:54 -0400)]
domain_conf: Change virDomainDiskDef 'rawio' to use virTristateBool

Adjust disk definition for 'rawio' to use the TristateBool logic

10 years agoqemu: Add missing goto on rawio
John Ferlan [Fri, 19 Sep 2014 09:53:04 +0000 (05:53 -0400)]
qemu: Add missing goto on rawio

Commit id '9a2f36ec' added a build conditional of CAP_SYS_RAWIO
in order to determine whether or not a disk definition using rawio
should be allowed on platforms without CAP_SYS_RAWIO. If one was
found, virReportError was used but the code didn't goto cleanup.

This patch adds the goto.

10 years agoLXC: add HOME environment variable docs
Chen Hanxiao [Fri, 19 Sep 2014 02:01:04 +0000 (10:01 +0800)]
LXC: add HOME environment variable docs

commit
3020594ac57c5e06e79f3db8c765f6bb18c40802
add HOME environment variable.
Add a doc for this.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoMove the FIPS detection from capabilities
Pavel Hrdina [Thu, 18 Sep 2014 15:38:32 +0000 (17:38 +0200)]
Move the FIPS detection from capabilities

We are not detecting the presence of FIPS from QEMU, but from procfs and
that means it's not QEMU capability. It was decided that we will pass
this flag to QEMU even if it's not supported by old QEMU binaries.

This patch also reverts changes done by commit a21cfb0f to
qemucapabilitestest and implements a new test case in qemuxml2argvtest.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovirSecuritySELinuxSetTapFDLabel: Temporarily revert to old behavior
Michal Privoznik [Thu, 18 Sep 2014 13:17:29 +0000 (15:17 +0200)]
virSecuritySELinuxSetTapFDLabel: Temporarily revert to old behavior

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

A long time ago I've implemented support for so called multiqueue
net.  The idea was to let guest network traffic be processed by
multiple host CPUs and thus increasing performance. However, this
behavior is enabled by QEMU via special ioctl() iterated over the
all tap FDs passed in by libvirt. Unfortunately, SELinux comes in
and disallows the ioctl() call because the /dev/net/tun has label
system_u:object_r:tun_tap_device_t:s0 and 'attach_queue' ioctl()
is not allowed on tun_tap_device_t type. So after discussion with
a SELinux developer we've decided that the FDs passed to the QEMU
should be labelled with svirt_t type and SELinux policy will
allow the ioctl(). Therefore I've made a patch
(cf976d9dcf4e592261b14f03572) that does exactly this. The patch
was fixed then by a4431931393aeb1ac5893f121151fa3df4fde612 and
b635b7a1af0e64754016d758376f382470bc11e7. However, things are not
that easy - even though the API to label FD is called
(fsetfilecon_raw) the underlying file is labelled too! So
effectively we are mangling /dev/net/tun label. Yes, that broke
dozen of other application from openvpn, or boxes, to qemu
running other domains.

The best solution would be if SELinux provides a way to label an
FD only, which could be then labeled when passed to the qemu.
However that's a long path to go and we should fix this
regression AQAP. So I went to talk to the SELinux developer again
and we agreed on temporary solution that:

1) All the three patches are reverted
2) SELinux temporarily allows 'attach_queue' on the
tun_tap_device_t

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodocs: update zfs documentation
Roman Bogorodskiy [Sun, 14 Sep 2014 05:17:54 +0000 (09:17 +0400)]
docs: update zfs documentation

 - docs/formatstorage.html.in: document 'zfs' pool type, add it
   to a list of pool types that could use source physical devices
 - docs/storage.html.in: update a ZFS pool example XML with
   source physical devices, mention that starting from 1.2.9 a
   pool could be created from this devices by libvirt and in earlier
   versions user still has to create a pool manually
 - docs/drvbhyve.html.in: add an example with ZFS pools

10 years agostorage: zfs: implement pool build and delete
Roman Bogorodskiy [Sun, 7 Sep 2014 14:01:34 +0000 (18:01 +0400)]
storage: zfs: implement pool build and delete

 - Provide an implementation for buildPool and deletePool operations
   for the ZFS storage backend.
 - Add VIR_STORAGE_POOL_SOURCE_DEVICE flag to ZFS pool poolOptions
   as now we can specify devices to build pool from
 - storagepool.rng: add an optional 'sourceinfodev' to 'sourcezfs' and
   add an optional 'target' to 'poolzfs' entity
 - Add a couple of tests to storagepoolxml2xmltest

10 years agoaudit: fix memory leak without WITH_AUDIT
Ján Tomko [Thu, 18 Sep 2014 10:08:37 +0000 (12:08 +0200)]
audit: fix memory leak without WITH_AUDIT

Free str unconditionally since we allocate it without WITH_AUDIT
too.

10 years agoaudit: remove redundant NULL assignment
Ján Tomko [Thu, 18 Sep 2014 09:59:38 +0000 (11:59 +0200)]
audit: remove redundant NULL assignment

virVasprintf sets the output to NULL on failure.

10 years agoFixes for domains with no iothreads
Ján Tomko [Thu, 18 Sep 2014 09:57:00 +0000 (11:57 +0200)]
Fixes for domains with no iothreads

Plug a memory leak and silence a warning.

10 years agoFix leak in x86UpdateHostModel
Ján Tomko [Thu, 18 Sep 2014 09:55:52 +0000 (11:55 +0200)]
Fix leak in x86UpdateHostModel

Commit de0aeaf introduced a memory leak.

10 years agoFix libvirtd crash when removing metadata
Erik Skultety [Thu, 18 Sep 2014 12:25:05 +0000 (14:25 +0200)]
Fix libvirtd crash when removing metadata

When trying to remove nonexistent metadata from XML, libvirt daemon
crashes due to dereferencing NULL pointer.

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

10 years agoqemu: Don't fail startup/attach for IOThreads if no JSON
John Ferlan [Wed, 17 Sep 2014 18:43:12 +0000 (14:43 -0400)]
qemu: Don't fail startup/attach for IOThreads if no JSON

If the qemu being used doesn't support JSON, then querying for IOThread
data would fail. In that case, ensure the *iothreads is NULL and return 0
as the count of iothreads available.

10 years agoFix build in qemu_command
Roman Bogorodskiy [Thu, 18 Sep 2014 06:36:27 +0000 (10:36 +0400)]
Fix build in qemu_command

Currently, build with clang fails with:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_command.lo
qemu/qemu_command.c:6580:58: error: implicit conversion from enumeration type
'virMemAccess' to different enumeration type 'virTristateSwitch'
[-Werror,-Wenum-conversion]
        virTristateSwitch memAccess = def->cpu->cells[i].memAccess;
                          ~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
1 error generated.

Fix that by using virMemAccess instead of virTristateSwitch.

10 years agoFix build in qemu_capabilities
Roman Bogorodskiy [Thu, 18 Sep 2014 06:30:40 +0000 (10:30 +0400)]
Fix build in qemu_capabilities

Commit f05b6a91 added virQEMUDriverConfigPtr argument to the
virQEMUCapsFillDomainCaps function and it uses forward declaration
of virQEMUDriverConfig and virQEMUDriverConfigPtr that casues clang
build to fail:

gmake[3]: Entering directory `/usr/home/novel/code/libvirt/src'
  CC       qemu/libvirt_driver_qemu_impl_la-qemu_capabilities.lo
In file included from qemu/qemu_capabilities.c:43:
In file included from qemu/qemu_hostdev.h:27:
qemu/qemu_conf.h:63:37: error: redefinition of typedef 'virQEMUDriverConfig'
is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
                                    ^
qemu/qemu_capabilities.h:328:37: note: previous definition is here
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
                                    ^

Fix that by passing loader and nloader config attributes directly
instead of passing complete config.

10 years agobhyve: tests: fix build
Roman Bogorodskiy [Thu, 18 Sep 2014 06:25:12 +0000 (10:25 +0400)]
bhyve: tests: fix build

Commit b20d39a introduced a new argument for the
virNetDevTapCreateInBridgePort function, however, its mock
in bhyve tests wasn't updated, so the build failed.

Fix build by adding this new argument to the mock version.

10 years agoqemu: fix crash with shared disks
Ján Tomko [Wed, 17 Sep 2014 10:36:21 +0000 (12:36 +0200)]
qemu: fix crash with shared disks

Commit f36a94f introduced a double free on all success paths
in qemuSharedDeviceEntryInsert.

Only call qemuSharedDeviceEntryFree on the error path and
set entry to NULL before jumping there if the entry already
is in the hash table.

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

10 years agoqemu: Improve check for local storage
Peter Krempa [Thu, 11 Sep 2014 17:28:10 +0000 (19:28 +0200)]
qemu: Improve check for local storage

Now that we have a simple function to check locality of storage, reuse
it in qemuDomainCheckDiskPresence().

Also reuse check for empty storage source.

10 years agoqemu: Drop unused formatting of uuid
Peter Krempa [Thu, 11 Sep 2014 16:49:02 +0000 (18:49 +0200)]
qemu: Drop unused formatting of uuid

The formatted UUID isn't used anywhere else in
qemuDomainCheckDiskStartupPolicy. Drop it.

10 years agomaint: clean up _virDomainMemoryStat
Wang Yufei [Tue, 16 Sep 2014 13:19:47 +0000 (21:19 +0800)]
maint: clean up _virDomainMemoryStat

Clean up all _virDomainMemoryStat.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: clean up _virDomainBlockStats
Wang Yufei [Tue, 16 Sep 2014 13:19:46 +0000 (21:19 +0800)]
maint: clean up _virDomainBlockStats

Clean up all _virDomainBlockStats.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: clean up _virDomainInterfaceStats
Wang Yufei [Tue, 16 Sep 2014 13:19:45 +0000 (21:19 +0800)]
maint: clean up _virDomainInterfaceStats

Clean up all _virDomainInterfaceStats.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoCVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk
Peter Krempa [Thu, 11 Sep 2014 14:35:53 +0000 (16:35 +0200)]
CVE-2014-3633: qemu: blkiotune: Use correct definition when looking up disk

Live definition was used to look up the disk index while persistent one
was indexed leading to a crash in qemuDomainGetBlockIoTune. Use the
correct def and report a nice error.

Unfortunately it's accessible via read-only connection, though it can
only crash libvirtd in the cases where the guest is hot-plugging disks
without reflecting those changes to the persistent definition.  So
avoiding hotplug, or doing hotplug where persistent is always modified
alongside live definition, will avoid the out-of-bounds access.

Introduced in: eca96694a7f992be633d48d5ca03cedc9bbc3c9aa (v0.9.8)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140724
Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: Honor hugepages for UMA domains
Michal Privoznik [Tue, 2 Sep 2014 14:53:10 +0000 (16:53 +0200)]
qemu: Honor hugepages for UMA domains

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

There are two ways how to tell qemu to use huge pages. The first one
is suitable for domains with NUMA nodes: the path to hugetlbfs mount
is appended to NUMA node definition on the command line. The second
one is suitable for UMA domains: here there's this global '-mem-path'
argument that accepts path to the hugetlbfs mount point. However, the
latter case was not used for all the cases that it should be. For
instance:

  <memoryBacking>
    <hugepages>
      <page size='2048' unit='KiB' nodeset='0'/>
    </hugepages>
  </memoryBacking>

didn't trigger the '-mem-path' so the huge pages - despite being
configured - were not used at all.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Disallow nonexistent NUMA nodes for hugepages
Michal Privoznik [Mon, 15 Sep 2014 09:59:09 +0000 (11:59 +0200)]
conf: Disallow nonexistent NUMA nodes for hugepages

As of 136ad4974 it is possible to specify different huge pages per
guest NUMA node. However, there's no check if nodeset specified in
./hugepages/page contains only those guest NUMA nodes that exist.
In other words with current code it is possible to define meaningless
combination:

  <memoryBacking>
    <hugepages>
      <page size='1048576' unit='KiB' nodeset='0,2-3'/>
      <page size='2048' unit='KiB' nodeset='1,4'/>
    </hugepages>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
  <cpu>
    <numa>
      <cell id='0' cpus='0' memory='1048576'/>
      <cell id='1' cpus='1' memory='1048576'/>
      <cell id='2' cpus='2' memory='1048576'/>
      <cell id='3' cpus='3' memory='1048576'/>
    </numa>
  </cpu>

Notice the node 4 in <hugepages/>?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoman: virsh: Add docs for supported stats groups
Peter Krempa [Mon, 15 Sep 2014 15:32:42 +0000 (17:32 +0200)]
man: virsh: Add docs for supported stats groups

Document the fields returned.

10 years agolib: Document that virConnectGetAllDomainStats may omit some stats fields
Peter Krempa [Mon, 15 Sep 2014 15:17:17 +0000 (17:17 +0200)]
lib: Document that virConnectGetAllDomainStats may omit some stats fields

Add a note to make the users aware that some stats groups or fields may
be missing in certain cases.

10 years agolib: De-duplicate stats group documentation for all stats functions
Peter Krempa [Mon, 15 Sep 2014 15:13:24 +0000 (17:13 +0200)]
lib: De-duplicate stats group documentation for all stats functions

State that full stats for the stats groups are available in the
virConnectGetAllDomainStats documentation section rather than
duplicating the docs.

10 years agovirsh: add options to query bulk stats group
Francesco Romani [Mon, 15 Sep 2014 08:48:10 +0000 (10:48 +0200)]
virsh: add options to query bulk stats group

Add new bulk stats groups to the domstats command.

Signed-off-by: Francesco Romani <fromani@redhat.com>
10 years agoqemu: bulk stats: implement block group
Francesco Romani [Mon, 15 Sep 2014 08:48:09 +0000 (10:48 +0200)]
qemu: bulk stats: implement block group

This patch implements the VIR_DOMAIN_STATS_BLOCK group of statistics.

To do so, a helper function to get the block stats of all the disks of
a domain is added.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: bulk stats: implement interface group
Francesco Romani [Mon, 15 Sep 2014 08:48:08 +0000 (10:48 +0200)]
qemu: bulk stats: implement interface group

This patch implements the VIR_DOMAIN_STATS_INTERFACE group of
statistics.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: bulk stats: implement VCPU group
Francesco Romani [Mon, 15 Sep 2014 08:48:07 +0000 (10:48 +0200)]
qemu: bulk stats: implement VCPU group

This patch implements the VIR_DOMAIN_STATS_VCPU group of statistics. To
do so, this patch also extracts a helper to gather the vCPU information.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: bulk stats: implement balloon group
Francesco Romani [Mon, 15 Sep 2014 08:48:06 +0000 (10:48 +0200)]
qemu: bulk stats: implement balloon group

This patch implements the VIR_DOMAIN_STATS_BALLOON group of statistics.

Signed-off-by: Francesco Romani <fromani@redhat.com>
10 years agoqemu: bulk stats: implement CPU stats group
Francesco Romani [Mon, 15 Sep 2014 08:48:05 +0000 (10:48 +0200)]
qemu: bulk stats: implement CPU stats group

This patch implements the VIR_DOMAIN_STATS_CPU_TOTAL group of
statistics.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: bulk stats: extend internal collection API
Francesco Romani [Mon, 15 Sep 2014 08:48:04 +0000 (10:48 +0200)]
qemu: bulk stats: extend internal collection API

Future patches which will implement more bulk stats groups for QEMU will
need to access the connection object.

To accommodate that, a few changes are needed:

* enrich internal prototype to pass qemu driver object

* add per-group flag to mark if one collector needs monitor access or not

* If at least one collector of the requested stats needs monitor access
  we must start a query job for each domain.  The specific collectors
  will run nested monitor jobs inside that.

* If the job can't be acquired we pass flags to the collector so
  specific collectors that need monitor access can be skipped in order
  to gather as much data as is possible.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agodomaincapstest: Run cleanly on systems missing OVMF firmware
Michal Privoznik [Wed, 17 Sep 2014 15:17:03 +0000 (17:17 +0200)]
domaincapstest: Run cleanly on systems missing OVMF firmware

As of f05b6a918e28 the test produces the list of paths that can
be passed to <loader/> and libvirt knows about them. However,
during the process of generating the list the paths are checked
for their presence. This may produce different results on
different systems.  Therefore, the path - if missing - is
added to pretend it's there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agorpc: make daemon spawning a bit more intelligent
Martin Kletzander [Sun, 7 Sep 2014 18:41:11 +0000 (20:41 +0200)]
rpc: make daemon spawning a bit more intelligent

This way it behaves more like the daemon itself does (acquiring a
pidfile, deleting the socket before binding, etc.).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodomaincaps: Expose UEFI binary path, if it exists
Michal Privoznik [Tue, 16 Sep 2014 23:52:54 +0000 (19:52 -0400)]
domaincaps: Expose UEFI binary path, if it exists

Check to see if the UEFI binary mentioned in qemu.conf actually
exists, and if so expose it in domcapabilities like

<loader ...>
  <value>/path/to/ovmf</value>
</loader>

We introduce some generic domcaps infrastructure for handling
a dynamic list of string values, it may be of use for future bits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_capabilities: Change virQEMUCapsFillDomainCaps signature
Michal Privoznik [Wed, 17 Sep 2014 09:33:35 +0000 (11:33 +0200)]
qemu_capabilities: Change virQEMUCapsFillDomainCaps signature

Up till now the virQEMUCapsFillDomainCaps() was type of void as
there was no way for it to fail. This is, however, going to
change in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: add support for shared memory mapping
Martin Kletzander [Mon, 8 Sep 2014 09:36:09 +0000 (11:36 +0200)]
qemu: add support for shared memory mapping

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodocs, conf, schema: add support for shared memory mapping
Martin Kletzander [Mon, 8 Sep 2014 09:34:22 +0000 (11:34 +0200)]
docs, conf, schema: add support for shared memory mapping

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoschemas: finish virTristate{Bool,Switch} transition
Martin Kletzander [Mon, 8 Sep 2014 06:06:35 +0000 (08:06 +0200)]
schemas: finish virTristate{Bool,Switch} transition

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Add support for multiple versions of 'pseries' machine type
Pradipta Kr. Banerjee [Sat, 13 Sep 2014 15:28:58 +0000 (20:58 +0530)]
qemu: Add support for multiple versions of 'pseries' machine type

qemu for IBM Power processor architecture is adding functionality for
supporting multiple 'pseries' machine type versions, each with different
capabilities. This patch is for supporting the same

Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
10 years agodomaincaps: Expose UEFI capability
Michal Privoznik [Tue, 16 Sep 2014 12:47:47 +0000 (14:47 +0200)]
domaincaps: Expose UEFI capability

As of 542899168c38 we learned libvirt to use UEFI for domains.
However, management applications may firstly query if libvirt
supports it. And this is where virConnectGetDomainCapabilities()
API comes handy.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoutil: storage: Copy driver type when initializing chain element
Peter Krempa [Tue, 16 Sep 2014 10:55:32 +0000 (12:55 +0200)]
util: storage: Copy driver type when initializing chain element

virStorageSourceInitChainElement initializes a new storage chain element
for use as a new disk source. If the new element doesn't contain the
driver name, copy it from the old source.

This fixes issue where a disk would forget the driver after a snapshot.

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

10 years agoqemu: time: Report errors if agent command fails
Peter Krempa [Tue, 16 Sep 2014 13:37:08 +0000 (15:37 +0200)]
qemu: time: Report errors if agent command fails

Commit b606bbb4 broke reporting of errors when setting of guest time
fails via the guest agent as the return value is not checked and later
overwritten by the return value qemuMonitorRTCResetReinjection();

Fix this by checking the return value before resetting the RTC
reinjection.

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

10 years agoWire up the interface backend options
Ján Tomko [Thu, 11 Sep 2014 15:15:24 +0000 (17:15 +0200)]
Wire up the interface backend options

Pass the user-specified tun path down when creating tap device
when called from the qemu driver.

Also honor the vhost device path specified by user.

10 years agoconf: add backend element to interfaces
Ján Tomko [Thu, 11 Sep 2014 15:11:28 +0000 (17:11 +0200)]
conf: add backend element to interfaces

For tuning the network, alternative devices
for creating tap and vhost devices can be specified via:
<backend tap='/dev/net/tun' vhost='/dev/net-vhost'/>

10 years agoconf: remove redundant local variable
Ján Tomko [Thu, 11 Sep 2014 10:54:20 +0000 (12:54 +0200)]
conf: remove redundant local variable

Use just one int variable for all the FromString calls.

10 years agoconf: split out virtio net driver formatting
Ján Tomko [Wed, 10 Sep 2014 17:12:54 +0000 (19:12 +0200)]
conf: split out virtio net driver formatting

Instead of checking upfront if the <driver> element will be needed
in a big condition, just format all the attributes into a string
and output the <driver> element if the string is not empty.

10 years agoqemu: Need to check for capability before query
John Ferlan [Tue, 16 Sep 2014 09:57:28 +0000 (05:57 -0400)]
qemu: Need to check for capability before query

Prior to trying the query-iothreads call - check if the qemu has
the capability

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agonetwork: check negative values in bridge queues
Erik Skultety [Tue, 16 Sep 2014 08:06:50 +0000 (10:06 +0200)]
network: check negative values in bridge queues

We already are checking for negative value, reporting an error, but
using wrong function and the check only succeeds when a value that
cannot be converted to number successfully is encountered. This patch
provides just a minor change in call of the right version
of function virStrToLong.

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

10 years agoopenvz: fixed two memory leaks on migration code
Hongbin Lu [Tue, 16 Sep 2014 02:22:48 +0000 (22:22 -0400)]
openvz: fixed two memory leaks on migration code

The first one occurs in openvzDomainMigratePrepare3Params() where in
case no remote uri is given, the distant hostname is used. The name is
obtained via virGetHostname() which require callers to free the
returned value.
The second leak lies in openvzDomainMigratePerform3Params(). There's a
virCommand used later. However, at the beginning of the function
virCheckFlags() is called which returns. So the command created was
leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirprocess: Extend list of platforms for setns wrapper
Michal Privoznik [Mon, 15 Sep 2014 13:31:40 +0000 (15:31 +0200)]
virprocess: Extend list of platforms for setns wrapper

Currently, the setns() wrapper is supported only for x86_64 and i686
which leaves us failing to build on other platforms like arm, aarch64
and so on. This means, that the wrapper needs to be extended to those
platforms and make to fail on runtime not compile time.

The syscall numbers for other platforms was fetched using this
command:

kernel.git $ git grep "define.*__NR_setns" | grep -e arm -e powerpc -e s390
arch/arm/include/uapi/asm/unistd.h:#define __NR_setns                   (__NR_SYSCALL_BASE+375)
arch/arm64/include/asm/unistd32.h:#define __NR_setns 375
arch/powerpc/include/uapi/asm/unistd.h:#define __NR_setns               350
arch/s390/include/uapi/asm/unistd.h:#define __NR_setns          339

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoutil: storage: Fix qcow(2) header parser according to docs
Peter Krempa [Mon, 15 Sep 2014 14:16:25 +0000 (16:16 +0200)]
util: storage: Fix qcow(2) header parser according to docs

The backing store string location offset 0 determines that the file
isn't present. The string size shouldn't be then checked:

from qemu.git/docs/specs/qcow2.txt

== Header ==

The first cluster of a qcow2 image contains the file header:

Byte  0 -  3:   magic
                QCOW magic string ("QFI\xfb")

      4 -  7:   version
                Version number (valid values are 2 and 3)

      8 - 15:   backing_file_offset
                Offset into the image file at which the backing file name
                is stored (NB: The string is not null terminated). 0 if the
                image doesn't have a backing file.

     16 - 19:   backing_file_size
                Length of the backing file name in bytes. Must not be
                longer than 1023 bytes. Undefined if the image doesn't have
                a backing file.         ^^^^^^^^^

This patch intentionally leaves the backing file string size check in
place in case a malformatted file would be presented to libvirt. Also
according to the docs the string size is maximum 1023 bytes, thus this
patch adds a check to verify that.

I was also able to verify that the check was done the same way in the
legacy qcow fromat (in qemu's code).