]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
9 years agoqemu: Separate raw IO code from qemuProcessStart
Jiri Denemark [Mon, 2 Nov 2015 09:35:58 +0000 (10:35 +0100)]
qemu: Separate raw IO code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate graphics handling code from qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 17:16:53 +0000 (18:16 +0100)]
qemu: Separate graphics handling code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate hook handling code from qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 16:59:43 +0000 (17:59 +0100)]
qemu: Separate hook handling code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Rename stdin_{fd,path} in qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 10:43:30 +0000 (11:43 +0100)]
qemu: Rename stdin_{fd,path} in qemuProcessStart

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use -incoming defer for migrations
Jiri Denemark [Wed, 11 Nov 2015 17:02:23 +0000 (18:02 +0100)]
qemu: Use -incoming defer for migrations

Traditionally, we pass incoming migration URI on QEMU command line,
which has some drawbacks. Depending on the URI QEMU may initialize its
migration state immediately without giving us a chance to set any
additional migration parameters (this applies mainly for fd: URIs). For
some URIs the monitor may be completely blocked from the beginning until
migration is finished, which means we may be stuck in qmp_capabilities
command without being able to send any QMP commands.

QEMU solved this by introducing "defer" parameter for -incoming command
line option. This will tell QEMU to prepare for an incoming migration
while the actual incoming URI is sent using migrate-incoming QMP
command. Before calling this command we can normally talk to the
monitor and even set any migration parameters which will be honored by
the incoming migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Add APIs for migrate-incoming QMP command
Jiri Denemark [Tue, 20 Oct 2015 20:51:48 +0000 (22:51 +0200)]
qemu: Add APIs for migrate-incoming QMP command

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Always set async job when starting a domain
Jiri Denemark [Wed, 21 Oct 2015 08:55:43 +0000 (10:55 +0200)]
qemu: Always set async job when starting a domain

We only started an async job for incoming migration from another host.
When we were starting a domain from scratch or restoring from a saved
state (migration from file) we didn't set any async job. Let's introduce
a new QEMU_ASYNC_JOB_START for these cases.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessIncomingDef
Jiri Denemark [Fri, 6 Nov 2015 17:41:37 +0000 (18:41 +0100)]
qemu: Introduce qemuProcessIncomingDef

Incoming migration may require quite a few parameters (URI, fd, path) to
be considered while starting QEMU and we will soon add another one.
Let's group all of them in a single struct.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Move incoming URI code to qemu_migration
Jiri Denemark [Tue, 20 Oct 2015 13:48:33 +0000 (15:48 +0200)]
qemu: Move incoming URI code to qemu_migration

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't generate migration URI in qemuBuildCommandLine
Jiri Denemark [Tue, 20 Oct 2015 11:51:01 +0000 (13:51 +0200)]
qemu: Don't generate migration URI in qemuBuildCommandLine

Make callers of qemuBuildCommandLine responsible for providing the URI
which should be passed as a parameter for -incoming.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor the code to build -incoming command line
Jiri Denemark [Fri, 16 Oct 2015 15:01:39 +0000 (17:01 +0200)]
qemu: Refactor the code to build -incoming command line

Move the code from qemuBuildCommandLine into dedicated functions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor waiting for completed migration on destination
Jiri Denemark [Thu, 15 Oct 2015 17:49:22 +0000 (19:49 +0200)]
qemu: Refactor waiting for completed migration on destination

Move the code from qemuMigrationFinish into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agolibvirt-domain: Fix typo in debug message
Cole Robinson [Thu, 19 Nov 2015 00:28:45 +0000 (19:28 -0500)]
libvirt-domain: Fix typo in debug message

9 years agoutil: add virDiskNameParse to handle disk and partition idx
Joao Martins [Fri, 13 Nov 2015 13:14:44 +0000 (13:14 +0000)]
util: add virDiskNameParse to handle disk and partition idx

Introduce a new helper function "virDiskNameParse" which extends
virDiskNameToIndex but handling both disk index and partition index.
Also rework virDiskNameToIndex to be based on virDiskNameParse.
A test is also added for this function testing both valid and
invalid disk names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agolibxl: implement virDomainMemorystats
Joao Martins [Fri, 13 Nov 2015 13:14:42 +0000 (13:14 +0000)]
libxl: implement virDomainMemorystats

Introduce support for domainMemoryStats API call, which
consequently enables the use of `virsh dommemstat` command to
query for memory statistics of a domain. We support
the following statistics: balloon info, available and currently
in use. swap-in, swap-out, major-faults, minor-faults require
cooperation of the guest and thus currently not supported.

We build on the data returned from libxl_domain_info and deliver
it in the virDomainMemoryStat format.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agovirSetUIDGID: Don't leak supplementary groups
Richard Weinberger [Tue, 23 Jun 2015 11:48:42 +0000 (13:48 +0200)]
virSetUIDGID: Don't leak supplementary groups

The LXC driver uses virSetUIDGID() to become UID/GID 0.
It passes an empty groups list to virSetUIDGID()
to get rid of all supplementary groups from the host side.
But virSetUIDGID() calls setgroups() only if the supplied list
is larger than 0.
This leads to a container root with unrelated supplementary groups.
In most cases this issue is unoticed as libvirtd runs as UID/GID 0
without any supplementary groups.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agolxc: Bind mount container TTYs
Richard Weinberger [Tue, 23 Jun 2015 14:38:57 +0000 (16:38 +0200)]
lxc: Bind mount container TTYs

Instead of creating symlinks, bind mount the devices to
/dev/pts/XY.
Using bind mounts it is no longer needed to add pts devices
to files like /etc/securetty.

Signed-off-by: Richard Weinberger <richard@nod.at>
9 years agolxc: Don't make container's TTY a controlling TTY
Richard Weinberger [Tue, 23 Jun 2015 13:18:53 +0000 (15:18 +0200)]
lxc: Don't make container's TTY a controlling TTY

Userspace does not expect that the initial console
is a controlling TTY. systemd can deal with that, others not.
On sysv init distros getty will fail to spawn a controlling on
/dev/console or /dev/tty1. Which will cause to whole container
to reboot upon ctrl-c.

This patch changes the behavior of libvirt to match the kernel
behavior where the initial TTY is also not controlling.

The only user visible change should be that a container with
bash as PID 1 would complain. But this matches exactly the kernel
be behavior with init=/bin/bash.
To get a controlling TTY for bash just run "setsid /bin/bash".

Signed-off-by: Richard Weinberger <richard@nod.at>
9 years agolocking: Add io_timeout to sanlock
Michal Privoznik [Fri, 23 Oct 2015 11:21:22 +0000 (13:21 +0200)]
locking: Add io_timeout to sanlock

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

So, if domain loses access to storage, sanlock tries to kill it
after some timeout. So far, the default is 80 seconds. But for
some scenarios this might not be enough. We should allow users to
adjust the timeout according to their needs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: ppc64: Support memory hotplug without NUMA enabled
Peter Krempa [Tue, 13 Oct 2015 17:12:23 +0000 (19:12 +0200)]
qemu: ppc64: Support memory hotplug without NUMA enabled

ppc64 guests don't require adding a NUMA node for hotplug memory to
work. Lift the requirement and add test cases.

9 years agoqemu: command: Prepare memory device def formatter for missing target node
Peter Krempa [Tue, 13 Oct 2015 00:02:22 +0000 (02:02 +0200)]
qemu: command: Prepare memory device def formatter for missing target node

Prepare the command line generator for the possibility that in some
configurations the target NUMA node info will be missing.

9 years agoconf: Prepare making memory device target node optional
Peter Krempa [Wed, 7 Oct 2015 11:52:45 +0000 (13:52 +0200)]
conf: Prepare making memory device target node optional

Adjust the config code so that it does not enforce that target memory
node is specified. To avoid breakage, adjust the qemu memory hotplug
config checker to disallow such config for now.

9 years agoqemu: command: Move dimm device checks from formatter to checker
Peter Krempa [Thu, 8 Oct 2015 05:25:32 +0000 (07:25 +0200)]
qemu: command: Move dimm device checks from formatter to checker

Aggregate the checks of the dimm device into the verification function
rather than having them in the formatter.

9 years agoqemu: domain: Add common function to perform memory hotplug checks
Peter Krempa [Thu, 8 Oct 2015 04:06:15 +0000 (06:06 +0200)]
qemu: domain: Add common function to perform memory hotplug checks

Add a function that will aggregate various checks related to memory
hotplug so that they aren't scattered accross various parts of the
code.

9 years agoqemu: command: Always execute memory device formatter
Peter Krempa [Wed, 7 Oct 2015 13:40:58 +0000 (15:40 +0200)]
qemu: command: Always execute memory device formatter

Since we already make sure before that the domain configuration is
valid we may execute it always at the cost of doing 0 iterations of the
for loop.

This patch will simplify later refactor as it will avoid whitespace
changes.

9 years agoqemu: command: Make qemuBuildMemoryBackendStr usable without NUMA
Peter Krempa [Wed, 7 Oct 2015 12:17:43 +0000 (14:17 +0200)]
qemu: command: Make qemuBuildMemoryBackendStr usable without NUMA

Make the function usable so that -1 can be passed to it as cell ID so
that we can later enable memory hotplug on non-NUMA guests for certain
architectures.

9 years agolibvirt-guests: Disable shutdown timeout
Guido Günther [Tue, 17 Nov 2015 07:39:46 +0000 (08:39 +0100)]
libvirt-guests: Disable shutdown timeout

Since we can't know at service start how many VMs will be running we
can't calculate an apropriate shutdown timeout. So instead of killing
off the service just let it use it's own internal timeout mechanism.

References:
    http://bugs.debian.org/803714
    https://bugzilla.redhat.com/show_bug.cgi?id=1195544

9 years agotpm: adapt sysfs cancel path for new TPM driver
Stefan Berger [Wed, 18 Nov 2015 00:44:13 +0000 (19:44 -0500)]
tpm: adapt sysfs cancel path for new TPM driver

This patch addresses BZ 1244895.

Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths and check their availability.

Add a mockup for the test cases to avoid the testing for
availability of the cancel path.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agolibxl: implement virDomainGetCPUStats
Joao Martins [Fri, 13 Nov 2015 13:14:41 +0000 (13:14 +0000)]
libxl: implement virDomainGetCPUStats

Introduce support for domainGetCPUStats API call and consequently
allow us to use `virsh cpu-stats`. The latter returns a more brief
output than the one provided by`virsh vcpuinfo`.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agobhyve: monitor: do not override domain's privateData
Roman Bogorodskiy [Wed, 4 Nov 2015 15:08:00 +0000 (18:08 +0300)]
bhyve: monitor: do not override domain's privateData

Current monitor code overrides domain object's privateData, e.g.
in virBhyveProcessStart():

  vm->privateData = bhyveMonitorOpen(vm, driver);

where bhyveMonitorPtr() returns bhyveMonitorPtr.

This is not right thing to do, so make bhyveMonitorPtr
a part of the bhyveDomainObjPrivate struct and change related code
accordingly.

9 years agosyntax-check: Add prohibit_space_in_label rule
Andrea Bolognani [Mon, 2 Nov 2015 11:12:22 +0000 (12:12 +0100)]
syntax-check: Add prohibit_space_in_label rule

This guards against code such as

 cleanup :

which is happily accepted by the compiler but does not conform
to our style guidelines.

9 years agoutil: remove unnecessary needSize
Chen Hanxiao [Sat, 14 Nov 2015 06:56:06 +0000 (14:56 +0800)]
util: remove unnecessary needSize

Use toadd->use directly.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
9 years agostorage: Don't assume storage pool exists for FC/SCSI refresh thread
John Ferlan [Mon, 2 Nov 2015 22:21:11 +0000 (17:21 -0500)]
storage: Don't assume storage pool exists for FC/SCSI refresh thread

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

The virStoragePoolFCRefreshThread had passed a pointer to the pool obj
in the virStoragePoolFCRefreshInfoPtr; however, we cannot assume that
the pool exists still since we don't keep the pool lock throughout
the duration of the thread.

Therefore, instead of passing the pool obj pointer, pass the UUID of
the pool and perform a lookup.  If found, then we can perform the
refresh using the locked pool obj pointer; otherwise, we just exit
the thread since the pool is now gone.

9 years agostorage: Introduce virStoragePoolObjFindPoolByUUID
John Ferlan [Mon, 2 Nov 2015 22:15:41 +0000 (17:15 -0500)]
storage: Introduce virStoragePoolObjFindPoolByUUID

Add a new API to search the currently defined pool list for a pool with
a matching UUID and return the locked pool object pointer.

9 years agostorage: Change cbdata scsi refresh thread field name
John Ferlan [Mon, 2 Nov 2015 19:46:32 +0000 (14:46 -0500)]
storage: Change cbdata scsi refresh thread field name

Change the field name from 'name' to 'fchost_name' to better id it.

9 years agostorage: Make active boolean
John Ferlan [Mon, 2 Nov 2015 21:07:34 +0000 (16:07 -0500)]
storage: Make active boolean

Since we treat it like a boolean, let's store it that way. At least one
path had already treated as true/false anyway.

9 years agoqemu: Explain mlock limit size more in detail
Peter Krempa [Wed, 11 Nov 2015 05:44:56 +0000 (06:44 +0100)]
qemu: Explain mlock limit size more in detail

Based on Alex's explanation [1] in the recent discussion let's update
the comment explaining the memory lock limit calculation.

[1]
http://www.redhat.com/archives/libvir-list/2015-November/msg00329.html

9 years agoqemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes
Peter Krempa [Wed, 11 Nov 2015 05:49:06 +0000 (06:49 +0100)]
qemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes

Break early when hard limit is set so that it's not intermixed by other
logic for determining the limit.

9 years agoqemu: Fix job entry debug message
Jiri Denemark [Fri, 30 Oct 2015 08:37:14 +0000 (09:37 +0100)]
qemu: Fix job entry debug message

Logging current async job while in BeginJob is useful, but the async job
we want to start is even more interesting.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Add QEMU 2.4.0 capabilities
Jiri Denemark [Thu, 15 Oct 2015 19:56:22 +0000 (21:56 +0200)]
tests: Add QEMU 2.4.0 capabilities

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Remove qemuxmlnstest
Jiri Denemark [Tue, 20 Oct 2015 14:01:01 +0000 (16:01 +0200)]
tests: Remove qemuxmlnstest

It's just a copy&paste of qemuxml2argv test anyway. We can test most of
them (except for qemuxmlns-qemu-ns-domain.xml which fails to validate
against our schema) by qemuxml2argv test.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Fix style in qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 17:18:10 +0000 (18:18 +0100)]
qemu: Fix style in qemuProcessStart

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agosecurity: Cleanup DAC driver
Jiri Denemark [Fri, 30 Oct 2015 09:20:37 +0000 (10:20 +0100)]
security: Cleanup DAC driver

Fixes several style issues and removes "DEF" (what is it supposed to
mean anyway?) from debug messages.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agodomain-conf: reorder usb controllers so the master is first
Pavel Hrdina [Wed, 11 Nov 2015 14:20:15 +0000 (15:20 +0100)]
domain-conf: reorder usb controllers so the master is first

USB controllers can share the same 'index' which indicates, that there
is some sort of master-companion relationship.  Reorder the controllers
in XML in to place the master controller before its companions.  This is
required by QEMU to not fail with error message:

error: internal error: process exited while connecting to monitor:
2015-10-26T16:25:17.630265Z qemu-system-x86_64:
-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6:
USB bus 'usb.0' not found

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain-conf: cleanup controller insert function
Pavel Hrdina [Wed, 11 Nov 2015 14:18:07 +0000 (15:18 +0100)]
domain-conf: cleanup controller insert function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirsh-domain: update attach-interface to support type=hostdev
Pavel Hrdina [Wed, 21 Oct 2015 10:59:41 +0000 (12:59 +0200)]
virsh-domain: update attach-interface to support type=hostdev

Adding this feature will allow users to easily attach a hostdev network
interface using PCI passthrough.

The interface can be attached using --type=hostdev and PCI address or
as --source.  This command also allows you to tell, whether the interface
should be managed.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirsh.pod: improve attach-interface section
Pavel Hrdina [Wed, 11 Nov 2015 14:01:37 +0000 (15:01 +0100)]
virsh.pod: improve attach-interface section

Rewrite the attach-interface section in man page to be more readable and
extendable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovz: support cpu time in driver's domainGetInfo
Nikolay Shirokovskiy [Wed, 28 Oct 2015 14:29:00 +0000 (17:29 +0300)]
vz: support cpu time in driver's domainGetInfo

Just straight-forward patch.
Use reference counting for privdom as stats internally could drop domain lock.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoqemu: fix parsing of -sdl arg
Daniel P. Berrange [Tue, 10 Nov 2015 12:18:47 +0000 (12:18 +0000)]
qemu: fix parsing of -sdl arg

The previous commit

  commit 4e8993a25006bc5d7c95311d430cc01d8de63564
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Nov 9 16:20:08 2015 +0000

    qemu: assume various QEMU 0.10 features are always available

Added broken handling of -sdl. Instead of duplicating existing
SDL handling code, just ensure it is invoked in the right
scenarios.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume various QEMU 0.10 features are always available
Daniel P. Berrange [Mon, 9 Nov 2015 16:20:08 +0000 (16:20 +0000)]
qemu: assume various QEMU 0.10 features are always available

The -sdl and -net ...name=XXX arguments were both introduced
in QEMU 0.10, so the QEMU driver can assume they are always
available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -vga is always available
Daniel P. Berrange [Mon, 9 Nov 2015 15:39:54 +0000 (15:39 +0000)]
qemu: assume -vga is always available

As of QEMU 0.10.0 the -vga argument was introduced, so the
QEMU driver can assume it is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -drive format is always available
Daniel P. Berrange [Fri, 6 Nov 2015 18:20:20 +0000 (18:20 +0000)]
qemu: assume -drive format is always available

As of QEMU 0.10.0 the -drive format= parameter was added,
so the QEMU driver can assume it is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -drive cache always uses v2 option names
Daniel P. Berrange [Fri, 6 Nov 2015 17:26:08 +0000 (17:26 +0000)]
qemu: assume -drive cache always uses v2 option names

As of QEMU 0.10.0, the -drive cache option stopped using
the on/off value names, so the QEMU driver can assume
use of the new value names.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume support for all migration protocols except rdma
Daniel P. Berrange [Fri, 6 Nov 2015 16:50:26 +0000 (16:50 +0000)]
qemu: assume support for all migration protocols except rdma

Since we require QEMU 0.12.0, we can assume that QEMU supports
all of the fd, tcp, unix and exec migration protocols.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume vnet-hdr feature is always available
Daniel P. Berrange [Fri, 6 Nov 2015 15:48:44 +0000 (15:48 +0000)]
qemu: assume vnet-hdr feature is always available

9 years agoqemu: really remove last traces of Xenner support
Daniel P. Berrange [Fri, 6 Nov 2015 14:44:35 +0000 (14:44 +0000)]
qemu: really remove last traces of Xenner support

We have twice previously attempted to remove Xenner
support

  commit de9be0ab4d7abe4c3ae5beaaff7ddb208921f1f1
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Aug 22 17:29:01 2012 +0100

    Remove xenner support

  commit 92572c3d71bd08e6dd1897c7b14be9d27df608e9
  Author: Ján Tomko <jtomko@redhat.com>
  Date:   Wed Feb 18 16:33:50 2015 +0100

    Remove code handling the QEMU_CAPS_DOMID capability

This change really does remove the last traces of it
in the capabilities handling code

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -uuid is always available
Daniel P. Berrange [Fri, 6 Nov 2015 14:29:52 +0000 (14:29 +0000)]
qemu: assume -uuid is always available

The -uuid arg was added in QEMU 0.10.0, so the QEMU driver can
assume it is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -name is always available
Daniel P. Berrange [Fri, 6 Nov 2015 14:29:41 +0000 (14:29 +0000)]
qemu: assume -name is always available

The -name arg was added in QEMU 0.9.1, so the QEMU driver can
assume it is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -drive argument is always available
Daniel P. Berrange [Fri, 6 Nov 2015 14:28:57 +0000 (14:28 +0000)]
qemu: assume -drive argument is always available

As of QEMU 0.9.1 the -drive argument can be used to configure
all disks, so the QEMU driver can assume it is always available
and drop support for -hda/-cdrom/etc.

Many of the tests need updating because a great many were
running without CAPS_DRIVE set, so using the -hda legacy
syntax.

Fixing the tests uncovered a bug in the argv -> xml
convertor which failed to handle disk with if=floppy.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: handle floppy disk bus when parsing command line argv
Daniel P. Berrange [Mon, 9 Nov 2015 13:26:09 +0000 (13:26 +0000)]
qemu: handle floppy disk bus when parsing command line argv

The QEMU argv -> virDomainDef conversion code was not handling
-drive arguments using the floppy bus. This caused them to be
added as hard disks instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: handle USB bus in qemuAssignDeviceDiskAliasFixed()
Daniel P. Berrange [Mon, 9 Nov 2015 13:25:21 +0000 (13:25 +0000)]
qemu: handle USB bus in qemuAssignDeviceDiskAliasFixed()

The qemuAssignDeviceDiskAliasFixed() method was missing handling
for the USB disk bus type.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -no-reboot is always available
Daniel P. Berrange [Thu, 5 Nov 2015 12:17:50 +0000 (12:17 +0000)]
qemu: assume -no-reboot is always available

The -no-reboot arg was added in QEMU 0.9.0, so the QEMU driver
can now assume it is always present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume 'info chardev' is always available
Daniel P. Berrange [Thu, 5 Nov 2015 11:00:17 +0000 (11:00 +0000)]
qemu: assume 'info chardev' is always available

As of QEMU 0.11.0 the 'info chardev' monitor command can be
used to report on allocated chardev paths, so we can drop
support for parsing QEMU stderr to locate the PTY paths.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: assume -vnc arg always takes a ':'
Daniel P. Berrange [Thu, 5 Nov 2015 11:56:47 +0000 (11:56 +0000)]
qemu: assume -vnc arg always takes a ':'

As of QEMU 0.9.0 the -vnc option accepts a ':' to separate port
from listen address, so the QEMU driver can assume that support
for listen addresses is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: remove all support for kQEMU
Daniel P. Berrange [Thu, 5 Nov 2015 11:49:40 +0000 (11:49 +0000)]
qemu: remove all support for kQEMU

The kQEMU accelerator was deleted in QEMU 0.12, so we no
longer need to support it in the QEMU driver.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: mandate QEMU version 0.12.0 or newer
Daniel P. Berrange [Thu, 5 Nov 2015 10:51:48 +0000 (10:51 +0000)]
qemu: mandate QEMU version 0.12.0 or newer

Check the QEMU version and refuse to work with QEMU versions
older than 0.12.0. This is approximately the vintage of QEMU
that is available in RHEL-6 era distros.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: hotplug: Reject VFIO hotplug if setting RLIMIT_MEMLOCK fails
Peter Krempa [Mon, 9 Nov 2015 12:44:29 +0000 (13:44 +0100)]
qemu: hotplug: Reject VFIO hotplug if setting RLIMIT_MEMLOCK fails

Check the return value of virCommandSetMaxMemLock when hotplugging VFIO
PCI hostdevs and reject the hotplug if the memory limit can't be set.

9 years agoqemu: hotplug: Fix mlock limit handling on memory hotplug
Peter Krempa [Fri, 6 Nov 2015 15:39:31 +0000 (16:39 +0100)]
qemu: hotplug: Fix mlock limit handling on memory hotplug

If mlock is required either due to use of VFIO hostdevs or due to the
fact that it's enabled it needs to be tweaked prior to adding new memory
or after removing a module. Add a helper to determine when it's
necessary and reuse it both on hotplug and hotunplug.

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

9 years agoqemu: Extract logic to determine the mlock limit size for VFIO
Peter Krempa [Fri, 6 Nov 2015 14:51:33 +0000 (15:51 +0100)]
qemu: Extract logic to determine the mlock limit size for VFIO

New function qemuDomainGetMlockLimitBytes will now handle the
calculation so that it unifies the logic to one place and allows later
reuse.

9 years agoconf: Make @def const in virDomainDefGetMemoryInitial
Peter Krempa [Thu, 8 Oct 2015 04:44:30 +0000 (06:44 +0200)]
conf: Make @def const in virDomainDefGetMemoryInitial

Keep const correctness and allow to use this function in cases where
@def is const in the caller.

9 years agotests: redo test argv file line wrapping
Daniel P. Berrange [Fri, 6 Nov 2015 13:20:06 +0000 (13:20 +0000)]
tests: redo test argv file line wrapping

Back in

  commit bd6c46fa0cfe275c24debc1152cfc5206c04b59b
  Author: Juerg Haefliger <juerg.haefliger@hp.com>
  Date:   Mon Jan 31 06:42:57 2011 -0500

    tests: handle backspace-newline pairs in test input files

all the test argv files were line wrapped so that the args
were less than 80 characters.

The way the line wrapping was done turns out to be quite
undesirable, because it often leaves multiple parameters
on the same line. If we later need to add or remove
individual parameters, then it leaves us having to redo
line wrapping.

This commit changes the line wrapping so that every
single "-param value" is one its own new line. If the
"value" is still too long, then we break on ',' or ':'
or ' ' as needed.

This means that when we come to add / remove parameters
from the test files line, the patch diffs will only
ever show a single line added/removed which will greatly
simplify review work.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agovirnetdev: Use virNetDevSetupControl in virNetDevSendEthtoolIoctl
John Ferlan [Wed, 4 Nov 2015 15:48:24 +0000 (10:48 -0500)]
virnetdev: Use virNetDevSetupControl in virNetDevSendEthtoolIoctl

Use virNetDevSetupControl instead of open coding using socket(AF_LOCAL...)
and clearing virIfreq.

By using virNetDevSetupControl, the socket is then opened using
AF_PACKET which requires being privileged (effectively root) in
order to complete successfully.  Since that's now a requirement,
then the ioctl(SIOCETHTOOL) should not fail with EPERM, thus it
is removed from the filtered listed of failure codes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirnetdev: Check for root in virNetDevGetFeatures
John Ferlan [Wed, 4 Nov 2015 15:26:16 +0000 (10:26 -0500)]
virnetdev: Check for root in virNetDevGetFeatures

Since the SIOCETHTOOL ioctl only works for privileged daemons, if called
when not root, then virNetDevGetFeatures will VIR_DEBUG a message and
return 0 as if the functions were not available for the architecture.
This effectively returns an empty bitmap indicating no features available.

Introduced by commit id 'c9027d8f4'

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirnetdev: Fix function comments for virNetDevGetFeatures
John Ferlan [Fri, 6 Nov 2015 14:44:37 +0000 (09:44 -0500)]
virnetdev: Fix function comments for virNetDevGetFeatures

In commit id 'c9027d8f4' when updating the posted patch to generate
a bitmap instead of an array of named feature bits, adjustment of
the args was missed

9 years agovirnetdev: Document reasons for ignoring some SIOCETHTOOL errno values
John Ferlan [Fri, 6 Nov 2015 15:06:11 +0000 (10:06 -0500)]
virnetdev: Document reasons for ignoring some SIOCETHTOOL errno values

Recently reverted commit id '6f2a0198' showed a need to add extra
comments when dealing with filtering of potential "non-issues".

Scanning through upstream patch postings indicates early on the
reasons for the filtering of specific ioctl failures were provided;
however, when converted from causing an error to VIR_DEBUG's the
reasons were missing. A future read/change of the code incorrectly
assumed they could or should be removed.

9 years agoRevert "utils: Remove the logging of errors from virNetDevSendEthtoolIoctl"
Daniel P. Berrange [Tue, 3 Nov 2015 14:17:42 +0000 (14:17 +0000)]
Revert "utils: Remove the logging of errors from virNetDevSendEthtoolIoctl"

This reverts commit 6f2a0198e913c91a2ef8b99db79b7d3cc5396957.

This commit removed error reporting from virNetDevSendEthtoolIoctl
pushing responsibility onto the callers. This is wrong, however,
since virNetDevSendEthtoolIoctl calls virNetDevSetupControl
which can still report errors. So as a result virNetDevSendEthtoolIoctl
may or may not report errors depending on which bit of it fails, and as
a result callers now overwrite some errors.

It also introduced a regression causing unprivileged libvirtd to
spew error messages to the console due to inability to query the
NIC features, an error which was previously ignored.

virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted

Looking back at the original posting I see no explanation of why
thsi refactoring was needed, so reverting the clearly broken
error reporting logic looks like the best option.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: migration: Actually error out on unsupported migration flag
Peter Krempa [Thu, 5 Nov 2015 14:23:37 +0000 (15:23 +0100)]
qemu: migration: Actually error out on unsupported migration flag

The code reported that a migration flag is unsupported but didn't jump
to the error label. Probably an oversight in commit f88af9dc that
introduced the flag checking.

9 years agoqemu: migration: Properly parse memory hotplug migration flag
Peter Krempa [Thu, 5 Nov 2015 14:20:21 +0000 (15:20 +0100)]
qemu: migration: Properly parse memory hotplug migration flag

Since the flag was not enabled when 'eating' the migration cookie,
libvirt reported a bogus error when memory hotplug was enabled:

 unsupported migration cookie feature memory-hotplug

The error was ignored though due to a bug in the code so it slipped
through testing.

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

9 years agonetwork: Remove extraneous ATTRIBUTE_NONNULL for virNetDevWaitDadFinish
John Ferlan [Wed, 4 Nov 2015 22:47:42 +0000 (17:47 -0500)]
network: Remove extraneous ATTRIBUTE_NONNULL for virNetDevWaitDadFinish

Commit id '0f7436ca' added virNetDevWaitDadFinish using ATTRIBUTE_NONNULL
for both arguments, although one is a non-null argument. A Coverity build
balks at that.

9 years agovirnetdev: Check correct return value for virNetDevFeatureAvailable
John Ferlan [Tue, 3 Nov 2015 22:01:25 +0000 (17:01 -0500)]
virnetdev: Check correct return value for virNetDevFeatureAvailable

Rather than "if (virNetDevFeatureAvailable(ifname, &cmd))" change the
success criteria to "if (virNetDevFeatureAvailable(ifname, &cmd) == 1)".

The called helper returns -1 on failure, 0 on not found, and 1 on found.
Thus a failure was setting bits.

Introduced by commit ac3ed20 which changed the helper's return
values without adjusting its callers

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: add /usr/lib to AC_PATH_PROG for qemu-bridge-helper
Michel Normand [Wed, 4 Nov 2015 09:01:24 +0000 (10:01 +0100)]
qemu: add /usr/lib to AC_PATH_PROG for qemu-bridge-helper

For openSUSE the qemu-bridge-helper is installed in /usr/lib
So libvirt has to search it in this directory.

Signed-off-by: Michel Normand <normand@linux.vnet.ibm.com>
9 years agostorage: On 'buildVol' failure don't delete the volume
John Ferlan [Thu, 8 Oct 2015 20:44:02 +0000 (16:44 -0400)]
storage: On 'buildVol' failure don't delete the volume

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

Commit id 'fdda3760' only managed a symptom where it was possible to
create a file in a pool without libvirt's knowledge, so it was reverted.

The real fix is to have all the createVol API's which actually create
a volume (disk, logical, zfs) and the buildVol API's which handle the
real creation of some volume file (fs, rbd, sheepdog) manage deleting
any volume which they create when there is some sort of error in
processing the volume.

This way the onus isn't left up to the storage_driver to determine whether
the buildVol failure was due to some failure as a result of adjustments
made to the volume after creation such as getting sizes, changing ownership,
changing volume protections, etc. or simple a failure in creation.

Without needing to consider that the volume has to be removed, the
buildVol failure path only needs to remove the volume from the pool.
This way if a creation failed due to duplicate name, libvirt wouldn't
remove a volume that it didn't create in the pool target.

9 years agoRevert "storage: Prior to creating a volume, refresh the pool"
John Ferlan [Thu, 8 Oct 2015 20:47:30 +0000 (16:47 -0400)]
Revert "storage: Prior to creating a volume, refresh the pool"

This reverts commit fdda37608a6e22406fbdfe4ac0c573a96a8d0417.

This commit only manages a symptom of finding a buildRet failure
where a volume was not listed in the pool, but someone created the
volume outside of libvirt in the pool being managed by libvirt.

9 years agostorage: Pull volume removal from pool in storageVolDeleteInternal
John Ferlan [Thu, 8 Oct 2015 20:33:16 +0000 (16:33 -0400)]
storage: Pull volume removal from pool in storageVolDeleteInternal

Create a helper function to remove volume from the pool.

9 years agostorage: Cleanup failures in virStorageBackendCreateRaw
John Ferlan [Thu, 8 Oct 2015 20:00:41 +0000 (16:00 -0400)]
storage: Cleanup failures in virStorageBackendCreateRaw

After successfully returning from virFileOpenAs, if subsequent calls fail,
then we need to remove the file since our caller expects that failures after
creation will remove the created file.

9 years agostorage: Cleanup failures virStorageBackendCreateExecCommand
John Ferlan [Tue, 3 Nov 2015 16:30:23 +0000 (11:30 -0500)]
storage: Cleanup failures virStorageBackendCreateExecCommand

After a successful qemu-img/qcow-create of the backing file, if we
fail to stat the file, change it owner/group, or mode, then the
cleanup path should remove the file.

9 years agostorage: Fix setting mode in virStorageBackendCreateExecCommand
John Ferlan [Wed, 14 Oct 2015 13:56:14 +0000 (09:56 -0400)]
storage: Fix setting mode in virStorageBackendCreateExecCommand

Currently the code does not handle the NFS root squash environment
properly since if the file gets created, then the subsequent chmod
will fail in a root squash environment where we're creating a file
in the pool with qemu tools, such as seen via:

   $ virsh vol-create-from $pool $file.xml file.img --inputpool $pool

assuming $file.xml is creating a file of "<format type='qcow2'"> from
an existing file.img in the pool of "<format type='raw'>".

This patch will utilize the virCommandSetUmask when creating the file
in the NETFS pool. The virCommandSetUmask API was added in commit id
'0e1a1a8c4', which was after the original code was developed in commit
id 'e1f27784' to attempt to handle the root squash environment.

Also, rather than blindly attempting to chmod, check to see if the
st_mode bits from the stat match what we're trying to set and only
make the chmod if they don't.

Also, a slight adjustment to the fallback algorithm to move the
virCommandSetUID/virCommandSetGID inside the if (!filecreated) since
they're only useful if we need to attempt to create the file again.

9 years agoRemove new lines from log messages
Jiri Denemark [Tue, 27 Oct 2015 18:14:01 +0000 (19:14 +0100)]
Remove new lines from log messages

VIR_DEBUG and VIR_WARN will automatically add a new line to the message,
having "\n" at the end or at the beginning of the message results in
empty lines.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Fix memory leak in qemuProcessStart
Jiri Denemark [Tue, 20 Oct 2015 12:40:42 +0000 (14:40 +0200)]
qemu: Fix memory leak in qemuProcessStart

nodeset should be freed in both success and failure paths.

While tmppath is freed immediately after it's consumed, moving it from
error to cleanup label is a bit more consistent and robust.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce cleanup label in qemuProcessStart
Jiri Denemark [Tue, 20 Oct 2015 12:30:52 +0000 (14:30 +0200)]
qemu: Introduce cleanup label in qemuProcessStart

Remove code duplication by moving common cleanup code in a dedicated
label.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Rename ret variable in qemuProcessStart
Jiri Denemark [Tue, 20 Oct 2015 12:26:46 +0000 (14:26 +0200)]
qemu: Rename ret variable in qemuProcessStart

Generally, we use "ret" variable for storing the value we are going to
return at the and of a function, but this is not the case in
qemuProcessStart. Let's rename "ret" as "rv".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Rename cleanup label in qemuProcessStart
Jiri Denemark [Tue, 20 Oct 2015 12:24:51 +0000 (14:24 +0200)]
qemu: Rename cleanup label in qemuProcessStart

Current "cleanup" label is only used in error path, thus it should
rather be called "error".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use correct type when calling qemuPrepareNVRAM
Jiri Denemark [Tue, 20 Oct 2015 08:11:26 +0000 (10:11 +0200)]
qemu: Use correct type when calling qemuPrepareNVRAM

qemuProcessStart was passing char * migrateFrom as the third argument to
qemuPrepareNVRAM. We should explicitly convert the pointer to bool which
is what the function expects.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoPost-release version bump to 1.2.22
Jiri Denemark [Wed, 4 Nov 2015 12:09:03 +0000 (13:09 +0100)]
Post-release version bump to 1.2.22

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoRelease of libvirt-1.2.21
Daniel Veillard [Wed, 4 Nov 2015 02:59:12 +0000 (10:59 +0800)]
Release of libvirt-1.2.21

* docs/news.html.in libvirt.spec.in: Updated for the release
* po/*.po*: regenerated

9 years agoutil: set max wait for IPv6 DAD to 20 seconds
Laine Stump [Thu, 29 Oct 2015 18:09:59 +0000 (14:09 -0400)]
util: set max wait for IPv6 DAD to 20 seconds

This was originally set to 5 seconds, but times of 5.5 to 7 seconds
were experienced. Since it's an arbitrary number intended to prevent
an infinite hang, having it a bit too high won't hurt anything, and 20
seconds looks to be adequate (i.e. I think/hope we don't need to make
it tunable in libvirtd.conf)

9 years agoutil: set error if DAD is not finished
Luyao Huang [Thu, 29 Oct 2015 09:47:33 +0000 (17:47 +0800)]
util: set error if DAD is not finished

If DAD not finished in 5 seconds, user will get an
unknown error like this:

 # virsh net-start ipv6
 error: Failed to start network ipv6
 error: An error occurred, but the cause is unknown

Call virReportError to set an error.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agowireshark: Install to generic plugin directory
Michal Privoznik [Tue, 27 Oct 2015 13:02:19 +0000 (14:02 +0100)]
wireshark: Install to generic plugin directory

There has been a report on the list [1] that we are not
installing the wireshark dissector into the correct plugin
directory. And in fact we are not. The problem is, the plugin
directory path is constructed at compile time. However, it's
dependent on the wireshark version, e.g.

  /usr/lib/wireshark/plugins/1.12.6

This is rather unfortunate, because if libvirt RPMs were built
with one version, but installed on a system with newer one, the
plugins are not really loaded. This problem lead fedora packagers
to unify plugin path to:

  /usr/lib/wireshark/plugins/

Cool! But this was enabled just in wireshark-1.12.6-4. Therefore,
we must require at least that version.

And while at it, on some distributions, the wireshark.pc file
already has a variable that defines where plugin dir is. Use that
if possible.

1: https://www.redhat.com/archives/libvirt-users/2015-October/msg00063.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoFix virNetDevWaitDadFinish stub
Roman Bogorodskiy [Thu, 29 Oct 2015 04:20:16 +0000 (07:20 +0300)]
Fix virNetDevWaitDadFinish stub

Build on non-Linux fails because the virNetDevWaitDadFinish() stub
has unused parameters. Fix by adding appropriate ATTRIBUTE_UNUSED
for these parameters.

Pushing under build-breaker rule.

9 years agonetwork: wait for DAD to finish for bridge IPv6 addresses
Maxim Perevedentsev [Tue, 20 Oct 2015 15:44:18 +0000 (18:44 +0300)]
network: wait for DAD to finish for bridge IPv6 addresses

commit db488c79 assumed that dnsmasq would complete IPv6 DAD before
daemonizing, but in reality it doesn't wait, which creates problems
when libvirt's bridge driver sets the matching "dummy tap device" to
IFF_DOWN prior to DAD completing.

This patch waits for DAD completion by periodically polling the kernel
using netlink to check whether there are any IPv6 addresses assigned
to bridge which have a 'tentative' state (if there are any in this
state, then DAD hasn't yet finished). After DAD is finished, execution
continues. To avoid an endless hang in case something was wrong with
the kernel's DAD, we wait a maximum of 5 seconds.