]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
9 years agovirNumaSetPagePoolSize: Produce friendlier error message
Michal Privoznik [Mon, 8 Jun 2015 12:05:25 +0000 (14:05 +0200)]
virNumaSetPagePoolSize: Produce friendlier error message

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

The function takes two important arguments (among many others): @node
and @page_size. From these two a path under /sys is constructed. The
path is then used to read and write the desired size of huge pages
pool. However, if the path does not exists due to either @node or
@page_size having nonexistent value (e.g. there's no such NUMA node or
no page size like -2), an cryptic error message is produced:

  virsh # allocpages --pagesize 2049 --pagecount 8 --cellno -2
  error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory

Add two more checks to catch this and therefore produce much more
friendlier error messages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agological: Fix typo in error message
John Ferlan [Tue, 9 Jun 2015 22:21:57 +0000 (18:21 -0400)]
logical: Fix typo in error message

9 years agonetwork: escape quotes for dsmasq conf contents
Shivaprasad G Bhat [Mon, 1 Jun 2015 08:10:04 +0000 (13:40 +0530)]
network: escape quotes for dsmasq conf contents

dnsmasq conf file contents needs to have quotes escaped for it to
work.  Because of this, the network-create/start for a network with
quotes in the name fails. The patch escapes strings for the entries
that go into the conf file.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
9 years agoconf: fix domaincommon.rng to accept network name with quotes
Shivaprasad G Bhat [Mon, 1 Jun 2015 08:07:23 +0000 (13:37 +0530)]
conf: fix domaincommon.rng to accept network name with quotes

The network name is currently of type "deviceName" but it should be
"text" as name is defined in the network.rng.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
9 years agoparallels: fix formatting errors in parallels driver
Dmitry Guryanov [Tue, 9 Jun 2015 14:04:24 +0000 (17:04 +0300)]
parallels: fix formatting errors in parallels driver

This patch fixes several formatting errors, which I
missed before pushing previous patches. Mostly because
of missing cppi package.

9 years agoparallels: treat block devices as disks for containers
Maxim Nestratov [Wed, 3 Jun 2015 21:10:00 +0000 (00:10 +0300)]
parallels: treat block devices as disks for containers

We are going to add block devices as disks for containers
not as filesystems.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: report SATA bus type for container block devices disks
Maxim Nestratov [Wed, 3 Jun 2015 21:10:00 +0000 (00:10 +0300)]
parallels: report SATA bus type for container block devices disks

As we can add disks based on block devices to containers and bus type
doesn't have any meaning here, let us report always SATA for them.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: process '/' mount point correctly for containers
Maxim Nestratov [Wed, 3 Jun 2015 21:10:00 +0000 (00:10 +0300)]
parallels: process '/' mount point correctly for containers

Since we are going to add block devices as root disks we have
to specify root mount point for boot block devices. But we
shouldn't do this if a filesystem disk with such
target mount point already exists.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: add isCt parameter to prlsdkGetDiskInfo and prlsdkAddDisk
Maxim Nestratov [Wed, 3 Jun 2015 21:10:00 +0000 (00:10 +0300)]
parallels: add isCt parameter to prlsdkGetDiskInfo and prlsdkAddDisk

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: add block device statistics to driver
Nikolay Shirokovskiy [Tue, 9 Jun 2015 07:35:53 +0000 (10:35 +0300)]
parallels: add block device statistics to driver

Statistics provided through PCS SDK. As we have only async interface in SDK we
need to be subscribed to statistics in order to get it. Trivial solution on
every stat request to subscribe, wait event and then unsubscribe will lead to
significant delays in case of a number of successive requests, as the event
will be delivered on next PCS server notify cycle. On the other hand we don't
want to keep unnesessary subscribtion. So we take an hibrid solution to
subcsribe on first request and then keep a subscription while requests are
active. We populate cache of statistics on subscribtion events and use this
cache to serve libvirts requests.

 * Cache details.
Cache is just handle to last arrived event, we call this cache
as if this handle is valid it is used to serve synchronous
statistics requests. We use number of successive events count
to detect that user lost interest to statistics. We reset this
count to 0 on every request. If more than PARALLELS_STATISTICS_DROP_COUNT
successive events arrive we unsubscribe. Special value of -1
of this counter is used to differentiate between subscribed/unsubscribed state
to protect from delayed events.

Values of PARALLELS_STATISTICS_DROP_COUNT and PARALLELS_STATISTICS_TIMEOUT are
just drop-ins, choosen without special consideration.

 * Thread safety issues
Use parallelsDomObjFromDomainRef in parallelsDomainBlockStats as
we could wait on domain lock down on stack in prlsdkGetStatsParam
and if we won't keep reference we could get dangling pointer
on return from wait.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@parallels.com>
9 years agovirsh: change-media: Fix behavior with --update without a source
Peter Krempa [Tue, 9 Jun 2015 11:27:42 +0000 (13:27 +0200)]
virsh: change-media: Fix behavior with --update without a source

Docs state that it should behave like eject. Currently the code does not
do that. This is a regression since f4b5f53027da4fed2250628e11bac4019.

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

9 years agoqemu: Capitalize "storage" in qemuDomainAttachUSBMassStorageDevice()
Andrea Bolognani [Tue, 9 Jun 2015 08:40:59 +0000 (10:40 +0200)]
qemu: Capitalize "storage" in qemuDomainAttachUSBMassStorageDevice()

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: caps: Advertise arm 32-on-64 KVM option
Cole Robinson [Thu, 21 May 2015 22:18:30 +0000 (18:18 -0400)]
qemu: caps: Advertise arm 32-on-64 KVM option

We need to use qemu-system-aarch64 to run armv7l KVM VMs on an aarch64
host.

9 years agoqemu: caps: qemu-system-aarch64 supports armv7l
Cole Robinson [Thu, 21 May 2015 22:06:09 +0000 (18:06 -0400)]
qemu: caps: qemu-system-aarch64 supports armv7l

And it always has, so advertise it similarly to i686

9 years agoqemu: command: Support arm 32-on-64 KVM with -cpu aarch64=off
Cole Robinson [Thu, 21 May 2015 22:18:20 +0000 (18:18 -0400)]
qemu: command: Support arm 32-on-64 KVM with -cpu aarch64=off

qemu 2.3.0 added the -cpu host,aarch64=off option, which allows using
qemu-system-aarch64 KVM to run armv7l VMs.

Add a capabilities check for it, wire it up in qemu_command, and test
the command line generation.

9 years agoparallels: return only success from PCS event handler
Nikolay Shirokovskiy [Fri, 5 Jun 2015 13:47:58 +0000 (16:47 +0300)]
parallels: return only success from PCS event handler

2 reasons to to this.
1. PCS SDK really don't care of handler return value.
2. It hard to imagine how notifier can handle
subscriber failures. Even if there are some situations
we probably will use some special error codes and
not just throw error codes we get from SDK itself.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@parallels.com>
9 years agoparallels: simplify event types discrimination
Nikolay Shirokovskiy [Thu, 4 Jun 2015 11:45:02 +0000 (14:45 +0300)]
parallels: simplify event types discrimination

Use issuer type instead of event type to group
vm related events. This saves us from
explicit enumeration of all vm event types in
prlsdkHandleVmEvent.

9 years agoutiltest: Use int8_t instead of char.
Michal Privoznik [Mon, 8 Jun 2015 08:24:08 +0000 (10:24 +0200)]
utiltest: Use int8_t instead of char.

Not every architecture out there has 'char' signed by default.
For instance, my arm box has it unsigned by default:

  $ gcc -dM -E - < /dev/null | grep __CHAR_UNSIGNED__
  #define __CHAR_UNSIGNED__ 1

Therefore, after 65c61e50 the test if failing for me. Problem is,
we are trying to assign couple of negative values into char
assuming some will overflow and some don't. That can't be the
case if 'char' is unsigned by default. Lets use more explicit types
instead: int8_t and uint8_t where is no ambiguity.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: process: fix build on FreeBSD
Roman Bogorodskiy [Mon, 8 Jun 2015 07:13:41 +0000 (11:13 +0400)]
util: process: fix build on FreeBSD

Commit 825df8c3 refactored virProcess{Set,Get}Affinity routines,
however broke BSD implementation because of the incorrect variable
name. Fix build by using a proper variable name.

Pushing as trivial and build break fix.

9 years agoutil: Properly return error from virGetUserID and virGetGroupID stubs
Peter Krempa [Mon, 8 Jun 2015 07:32:24 +0000 (09:32 +0200)]
util: Properly return error from virGetUserID and virGetGroupID stubs

The stubs for the two functions that are compiled on platforms that
don't have HAVE_GETPWUID_R and friends defined do not return error but
report an error message. The calling code then assumes that the @uid or
@gid arguments were filled, which is not the case in the stubs.

9 years agoTurn qemuMonitorFindBalloonObjectPath into a void function
Ján Tomko [Thu, 4 Jun 2015 13:44:29 +0000 (15:44 +0200)]
Turn qemuMonitorFindBalloonObjectPath into a void function

We were effectively ignoring its errors anyway.

9 years agoDo not access the domain definition in qemuMonitorFindBalloonObjectPath
Ján Tomko [Wed, 3 Jun 2015 15:19:06 +0000 (17:19 +0200)]
Do not access the domain definition in qemuMonitorFindBalloonObjectPath

The monitor code does not hold the virDomainObjPtr lock and should
not access the defitinion.

9 years agoOnly call SetMemoryStatsPeriod for virtio memballoon
Ján Tomko [Wed, 3 Jun 2015 15:13:47 +0000 (17:13 +0200)]
Only call SetMemoryStatsPeriod for virtio memballoon

9 years agoCheck for balloon model in qemuDomainSetMemoryStatsPeriod
Ján Tomko [Wed, 3 Jun 2015 14:52:57 +0000 (16:52 +0200)]
Check for balloon model in qemuDomainSetMemoryStatsPeriod

There's no point in calling the monitor if there is no balloon.

9 years agoOnly call qemuMonitorGetMemoryStats for virtio memballoon
Ján Tomko [Wed, 3 Jun 2015 15:02:42 +0000 (17:02 +0200)]
Only call qemuMonitorGetMemoryStats for virtio memballoon

There is nothing to get from the monitor for model='none'.

9 years agoInvert the condition in qemuDomainMemoryStats
Ján Tomko [Wed, 3 Jun 2015 14:58:31 +0000 (16:58 +0200)]
Invert the condition in qemuDomainMemoryStats

It only makes sense if qemuMonitorGetMemoryStats is called,
but the following patch will make that call conditional.

9 years agoAdd endjob label to qemuDomainMemoryStats
Ján Tomko [Wed, 3 Jun 2015 14:55:25 +0000 (16:55 +0200)]
Add endjob label to qemuDomainMemoryStats

Reduce the indentation level.

9 years agoRemove path argument from qemuMonitorJSONFindLinkPath
Ján Tomko [Wed, 3 Jun 2015 10:58:17 +0000 (12:58 +0200)]
Remove path argument from qemuMonitorJSONFindLinkPath

All the callers use "/" anyway.

9 years agoIntroduce qemuMonitorJSONFindLinkPath
Ján Tomko [Wed, 3 Jun 2015 10:40:08 +0000 (12:40 +0200)]
Introduce qemuMonitorJSONFindLinkPath

When traversing through the QOM tree, we're looking for
a link to a device, e.g.:
link<virtio-balloon-pci>

Introduce a helper that will format the link name at the start,
instead of doing it every time while recursing through the tree.

9 years agoMove qemuMonitorFindObjectPath to qemu_monitor_json
Ján Tomko [Wed, 3 Jun 2015 10:22:53 +0000 (12:22 +0200)]
Move qemuMonitorFindObjectPath to qemu_monitor_json

This function is specific to the JSON monitor.

9 years agorpc: Fix reference counting around virNetSocketAddIOCallback
Daniel P. Berrange [Thu, 4 Jun 2015 17:18:56 +0000 (19:18 +0200)]
rpc: Fix reference counting around virNetSocketAddIOCallback

Ref service passed as a parameter to the callback.  And don't unref the
socket that is part of the service being passed at another point in code.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agorpc: Don't use unrelated value as privateData of client
Daniel P. Berrange [Thu, 4 Jun 2015 17:16:32 +0000 (19:16 +0200)]
rpc: Don't use unrelated value as privateData of client

Append privateData of the client only if there are any, otherwise the
previous value (socket data) will get there again.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agorpc: Make virNetServerAddClient function dynamic
Daniel P. Berrange [Thu, 4 Jun 2015 17:16:32 +0000 (19:16 +0200)]
rpc: Make virNetServerAddClient function dynamic

As opposed to 'static'; by exporting it (privately).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agomdns: Set error when failing due to missing avahi
Martin Kletzander [Thu, 4 Jun 2015 15:34:42 +0000 (17:34 +0200)]
mdns: Set error when failing due to missing avahi

When building without avahi support, we used VIR_DEBUG() to note that to
the user.  However, functions that fail because of that (return NULL/-1)
did not set the error message.  This was the only file that forgot to do
such thing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agostorage: Add check for valid FS types in checkPool callback
John Ferlan [Tue, 2 Jun 2015 23:48:56 +0000 (19:48 -0400)]
storage: Add check for valid FS types in checkPool callback

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

The virStorageBackendFileSystemIsMounted is called from three source paths
checkPool, startPool, and stopPool. Both start and stop validate the FS
fields before calling *IsMounted; however the check path there is no call.
This could lead the code into returning a true in "isActive" if for some
reason the target path for the pool was mounted. The assumption being
that if it was mounted, then we believe we started/mounted it.

It's also of note that commit id '81165294' added an error message for
the start/mount path regarding that the target is already mounted so
fail the start. That check was adjusted by commit id '13fde7ce' to
only message if actually mounted.

At one time this led to the libvirtd restart autostart code to declare
that the pool was active even though the startPool would inhibit startup
and the stopPool would inhibit shutdown. The autostart path changed as
of commit id '2a31c5f0' as part of the keep storage pools started between
libvirtd restarts.

This patch adds the same check made prior to start/mount and stop/unmount
to ensure we have a valid configuration before attempting to see if the
target is already mounted to declare "isActive" or not. Finding an improper
configuration will now cause an error at checkPool, which should make it
so we can no longer be left in a situation where the pool was started and
we have no way to stop it.

9 years agostorage: FS backend adjust error message on error path
John Ferlan [Tue, 2 Jun 2015 20:25:58 +0000 (16:25 -0400)]
storage: FS backend adjust error message on error path

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

Currently the assumption on the error message is that there are
no source device paths defined when the number of devices check
fails, but in reality the XML could have had none or it could have
had more than the value supported. Adjust the error message accordingly
to make it clearer what the error really is.

9 years agostorage: Refactor storage pool type checks
John Ferlan [Tue, 2 Jun 2015 23:35:35 +0000 (19:35 -0400)]
storage: Refactor storage pool type checks

Refactor the code for both startPool (*Mount) and stopPool (*Unmount) code
paths by introducing virStorageBackendFileSystemIsValid.

9 years agostorage: Remove extraneous @conn from function comments
John Ferlan [Tue, 2 Jun 2015 23:58:33 +0000 (19:58 -0400)]
storage: Remove extraneous @conn from function comments

Over time the parameters changed, but the comment wasn't updated

9 years agoremote: fix odd comma operator
Eric Blake [Fri, 5 Jun 2015 03:44:48 +0000 (21:44 -0600)]
remote: fix odd comma operator

Commit 1882c0bd accidentally used ',' instead of ';'; oddly
enough, the result was still syntactically valid (yes, C is
a fun language).  But it made me do a double take; it's better
to use idiomatic syntax.

* daemon/remote.c (remoteRelayDomainEventDeviceAdded): Fix
harmless typo.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agoqemu: Update balloon info only if job is allowed
Peter Krempa [Thu, 4 Jun 2015 11:47:02 +0000 (13:47 +0200)]
qemu: Update balloon info only if job is allowed

In qemuDomainUpdateCurrentMemorySize I misplaced the actual update of
the balloon size to a place where it may not be initialized. Move it a
few lines above.

9 years agoconf: Fix mistakes in pointer usage in virDomainObjGetDefs
Peter Krempa [Thu, 4 Jun 2015 11:20:12 +0000 (13:20 +0200)]
conf: Fix mistakes in pointer usage in virDomainObjGetDefs

Coverity rightfully determined that in commit 3d021381c71221e563182f03
I made a mistake in the first check if @persDef is not NULL is
dereferencing it rather than checking.

Additionally if the vm is online the code would set @liveDef twice
rather than modifying @persDef. Fix both mistakes.

9 years agoqemu: Check for qemu capability when calling virDomainGetBlockIoTune()
Martin Kletzander [Thu, 28 May 2015 09:38:43 +0000 (11:38 +0200)]
qemu: Check for qemu capability when calling virDomainGetBlockIoTune()

When getting block device I/O tuning data there is no check for whether
QEMU supports such options and the call fails on
qemuMonitorGetBlockIoThrottle() when getting the particular throttle
data.  So try reporting a better error when blkdeviotune is not
supported.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Refactor qemuDomainSetVcpusFlags by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:29:06 +0000 (14:29 +0200)]
qemu: Refactor qemuDomainSetVcpusFlags by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainGetEmulatorPinInfo by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:29:06 +0000 (14:29 +0200)]
qemu: Refactor qemuDomainGetEmulatorPinInfo by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainPinEmulator by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:29:06 +0000 (14:29 +0200)]
qemu: Refactor qemuDomainPinEmulator by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainGetVcpuPinInfo by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainGetVcpuPinInfo by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainPinVcpuFlags by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:17:35 +0000 (14:17 +0200)]
qemu: Refactor qemuDomainPinVcpuFlags by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainSetBlkioParameters by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainSetBlkioParameters by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainChgIOThread by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainChgIOThread by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainPinIOThread by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainPinIOThread by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainGetIOThreadInfo by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainGetIOThreadInfo by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainGetVcpusFlags by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainGetVcpusFlags by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainSetMemoryStatsPeriod by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainSetMemoryStatsPeriod by reusing virDomainObjGetDefs

9 years agoqemu: Refactor qemuDomainSetMemoryFlags by reusing virDomainObjGetDefs
Peter Krempa [Fri, 29 May 2015 12:22:23 +0000 (14:22 +0200)]
qemu: Refactor qemuDomainSetMemoryFlags by reusing virDomainObjGetDefs

9 years agoconf: Add new helpers to resolve virDomainModificationImpact to domain defs
Peter Krempa [Fri, 29 May 2015 12:37:20 +0000 (14:37 +0200)]
conf: Add new helpers to resolve virDomainModificationImpact to domain defs

virDomainLiveConfigHelperMethod that is used for this job now does
modify the flags but still requires the callers to extract the correct
definition objects.

In addition coverity and other static analyzers are usually unhappy as
they don't grasp the fact that @flags are upadted according to the
correct def to be present.

To work this issue around and simplify the calling chain let's add a new
helper that will work only on drivers that always copy the persistent
def to a transient at start of a vm. This will allow to drop a few
arguments. The new function syntax will also fill two definition
pointers rather than modifying the @flags parameter.

9 years agolibxl: Don't remove vcpu pin definition in libxlDomainCleanup
Peter Krempa [Thu, 28 May 2015 13:31:09 +0000 (15:31 +0200)]
libxl: Don't remove vcpu pin definition in libxlDomainCleanup

The vCPU pinning definition gets removed when the domain definition is
being freed later. If there is no next configuration it would remove the
configured pinning.

9 years agoRevert "cputune: Support cputune for xend driver"
Peter Krempa [Thu, 28 May 2015 12:40:30 +0000 (14:40 +0200)]
Revert "cputune: Support cputune for xend driver"

This reverts commit 01692bb167f7ab81213921ba1116d46a4651ef0e.

Quoting the original commit message:

"Not sure if it's the correct way to add cputune xml for xend driver..."

It is not. The defition created that is converted from the internal xend
structures would also be leaked since it isn't used any more.

Revert the commit since it does not make sense to keep the info
internally.

9 years agoqemu: libxl: vcpupin: Don't reset pinning when pinning to all pcpus
Peter Krempa [Mon, 25 May 2015 12:19:50 +0000 (14:19 +0200)]
qemu: libxl: vcpupin: Don't reset pinning when pinning to all pcpus

In the pre-NUMA ages pinning a vCPU to all pCPUs was eaqual to deleting
the pinning info. Now it does not entirely work that way. Pinning a vCPU
to all pCPUs might be a desired operation. Additionally removal of the
pinning will result into using the default pinning information at the
next boot which might be different from all vcpus.

This patch removes the false assumption that we should remove the
pinning after pinning to all vCPUs and tweaks the documentation for
virsh.

A later patch will implement a new flag for the virDomainPinVcpuFlags
API that will allow to remove the pinning in a sane way.

9 years agolib: virDomainPinIOThread: Remove spurious overflow check
Peter Krempa [Thu, 28 May 2015 09:44:42 +0000 (11:44 +0200)]
lib: virDomainPinIOThread: Remove spurious overflow check

Internal structures use unsigned int, so there's no need for this legacy
check that was copied from the vCPU pinning api.

9 years agoconf: Store cpu count as unsigned int
Peter Krempa [Mon, 25 May 2015 13:43:29 +0000 (15:43 +0200)]
conf: Store cpu count as unsigned int

While we probably won't see machines with more than 65536 cpus for a
while lets store the cpu count as an integer so that we can avoid quite
a lot of overflow checks in our code.

9 years agoqemu: Refactor qemuDomainGetInfo
Peter Krempa [Wed, 27 May 2015 15:33:23 +0000 (17:33 +0200)]
qemu: Refactor qemuDomainGetInfo

Since the returned structure uses "unsigned long" for memory sizes add a
few overflow checks to notify the user in case we are not able to
represent given values.

9 years agoqemu: Add helper to update domain balloon size and refactor usage places
Peter Krempa [Wed, 27 May 2015 13:51:52 +0000 (15:51 +0200)]
qemu: Add helper to update domain balloon size and refactor usage places

When qemu does not support the balloon event the current memory size
needs to be queried. Since there are two places that implement the same
logic, split it out into a function and reuse.

9 years agoqemu: process: Update current balloon state to maximum on vm startup
Peter Krempa [Wed, 27 May 2015 13:04:14 +0000 (15:04 +0200)]
qemu: process: Update current balloon state to maximum on vm startup

After libvirt issues the balloon resize command, the current balloon
size needs to be changed to the maximum memory size since the vCPUs were
not started and thus the balloon driver could not return the memory.

Since GetXMLDesc and other APIs return the balloon size without updating
it in case they are not able to obtain the job and the memory balloon
does not support the asynchronous event the sizing might be incorrect.

9 years agoAlways add 'console' matching the 'serial' device
Ján Tomko [Wed, 13 Aug 2014 11:06:04 +0000 (13:06 +0200)]
Always add 'console' matching the 'serial' device

We have been formatting the first serial device also
as a console device, but only if there were no other consoles.

If there is a <serial> device present in the XML, but no serial
<console>, or if there isn't any <console> at all but the domain
definition hasn't gone through a parse->format->parse round-trip,
the <console> device would not be formatted.

Change the code to always add the stub device for the first
serial device.

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

9 years agomaint: remove incorrect apostrophes from 'its'
Ján Tomko [Wed, 3 Jun 2015 10:10:36 +0000 (12:10 +0200)]
maint: remove incorrect apostrophes from 'its'

9 years agodocs: php: remove reference to Red Hat
Ján Tomko [Wed, 3 Jun 2015 10:08:35 +0000 (12:08 +0200)]
docs: php: remove reference to Red Hat

Also remove the redudant apostrophe from "it's".

9 years agocheck if console/channel PTY is null before attempting to open
Shivaprasad G Bhat [Sun, 31 May 2015 15:55:59 +0000 (21:25 +0530)]
check if console/channel PTY is null before attempting to open

Console/channel devices have their pty devices assigned when the emulator is
actually started. If time is spent in guest preparation, someone attempts
to open the console/channel, the libvirt crashes in virChrdevLockFilePath().
The patch attempts to fix the crash by adding a check before attempting to
open.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
9 years agovirnetdev: fix moving of 802.11 phys
Lubomir Rintel [Mon, 1 Jun 2015 18:40:23 +0000 (20:40 +0200)]
virnetdev: fix moving of 802.11 phys

There was a couple of problems with the style fixes applied to the original
patch:

1.) virFileReadAllQuiet comparison was incorrectly parenthesized when moved
into a condition, causing the len to be set to the result of comparison. This,
together with the removed underflow check would underflow the phy buffer.

2.) The logic was broken. Failure to call "ip" would abort the function, thus
the "iw" branch would never be reached.

This aims to fix the issues and work around possible style complains :)

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
9 years agoutil: process: Refactor and fix virProcessSetAffinity
Peter Krempa [Tue, 2 Jun 2015 06:34:50 +0000 (08:34 +0200)]
util: process: Refactor and fix virProcessSetAffinity

Refactor the function to return the bitmap instead of an integer and the
inner workings so that they make more sense.

This patch also fixes possible segfault on old systems that was
introduced by commit:

commit f1a43a8e4139b028257ef4ed05a81cfb5f8a8741
Author: Hu Tao <hutao@cn.fujitsu.com>
Date:   Fri Sep 14 15:46:59 2012 +0800

    use virBitmap to store cpu affinity info

9 years agoutil: Clear output broadcast address before filling it in
Martin Kletzander [Wed, 3 Jun 2015 10:46:36 +0000 (12:46 +0200)]
util: Clear output broadcast address before filling it in

Since commit 55ace7c4789c8a7408139460f4b639cee00e5125, the sockettest
fails without VIR_TEST_DEBUG set.  The problem is found by test number
42 (co-incidence?), which tests range '192.168.122.1' -
'192.168.122.255' in network '192.168.122.0/24'.  That is supposed to
fail because the end address is equal to the broadcast address.

When comparing these two in 'virSocketAddrEqual(end, &broadcast)',
there is a check for sin_addr as well as for sin_port.  That port,
however, is different when we do not enable test debugging.  With the
testing enabled, the port is 0 (correctly initialized), but without that
it has a random number there.  And that's because the structure is not
initialized anywhere.

By zeroing the structure before filling in the info, we make sure we
return only the address and not any information that was not requested.
And the test work once again.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirsh: Fix Ctrl-C behavior when watching a job
Jiri Denemark [Mon, 1 Jun 2015 13:06:16 +0000 (15:06 +0200)]
virsh: Fix Ctrl-C behavior when watching a job

When watching a job (save, managedsave, dump, migrate) virsh spawns a
thread to call the appropriate API and waits for the result while
watching for interruption signals (SIGINT, Ctrl-C on the terminal).
Whenever such signal is caught, virsh calls virDomainAbortJob, stops
waiting for the job, and returns the result of virDomainAbortJob.

This is wrong because the job might have finished in the meantime or it
might have been cancelled by someone else and virsh would just report
the failure to abort the job. However, we are not interested in the
virDomainAbortJob's result at all, we need to keep waiting for the main
job to finish and report its result instead.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: process: Refactor setup of memory ballooning
Peter Krempa [Wed, 27 May 2015 12:26:05 +0000 (14:26 +0200)]
qemu: process: Refactor setup of memory ballooning

Since the monitor code now supports ullongs when setting balloon size,
drop the legacy code with overflow checking.

Additionally the comment mentioning that the job is treated as a sync
job does not make sense any more since the monitor is entered
asynchronously.

9 years agoqemu: monitor: Make qemuMonitorSetBalloon operate on unsinged long long
Peter Krempa [Wed, 27 May 2015 12:03:17 +0000 (14:03 +0200)]
qemu: monitor: Make qemuMonitorSetBalloon operate on unsinged long long

9 years agomonitor: Move documentation for qemuMonitorGetBalloonInfo
Peter Krempa [Wed, 27 May 2015 11:42:32 +0000 (13:42 +0200)]
monitor: Move documentation for qemuMonitorGetBalloonInfo

Document the top level function rather than both bottom level ones. It
makes looking the docs up quicker.

9 years agoutil: Add macro to overflow check integer assignments
Peter Krempa [Wed, 27 May 2015 08:54:38 +0000 (10:54 +0200)]
util: Add macro to overflow check integer assignments

Add a macro that will allow to simplify overflow checks and make them
more universal in case data types change.

9 years agolibxl: Refactor libxlDomainGetVcpuPinInfo
Peter Krempa [Fri, 22 May 2015 12:51:18 +0000 (14:51 +0200)]
libxl: Refactor libxlDomainGetVcpuPinInfo

Reuse the approach in qemuDomainGetVcpuPinInfo.

9 years agolibxl: Unbreak vcpu pinning
Peter Krempa [Fri, 22 May 2015 08:20:55 +0000 (10:20 +0200)]
libxl: Unbreak vcpu pinning

Libxl's vcpu pinning would work only if the vcpu array was ordered and
was not sparse. Remove the condition and iterate the pinning array
properly.

9 years agolibxl: Reuse virBitmapToData in libxlDomainSetVcpuAffinities
Peter Krempa [Fri, 22 May 2015 07:53:12 +0000 (09:53 +0200)]
libxl: Reuse virBitmapToData in libxlDomainSetVcpuAffinities

9 years agoqemu: Refactor qemuDomainHelperGetVcpus by reusing virBitmapToDataBuf
Peter Krempa [Fri, 29 May 2015 12:01:32 +0000 (14:01 +0200)]
qemu: Refactor qemuDomainHelperGetVcpus by reusing virBitmapToDataBuf

Get rid of the unnecessary allocation and copying of the bitmap and
clean up some unnecesary temporary variables.

9 years agoqemu: Reuse virBitmapToDataBuf in qemuDomainGetEmulatorPinInfo
Peter Krempa [Fri, 29 May 2015 11:52:29 +0000 (13:52 +0200)]
qemu: Reuse virBitmapToDataBuf in qemuDomainGetEmulatorPinInfo

9 years agoqemu: Use virBitmapToDataBuf in qemuDomainGetVcpuPinInfo
Peter Krempa [Fri, 22 May 2015 09:07:21 +0000 (11:07 +0200)]
qemu: Use virBitmapToDataBuf in qemuDomainGetVcpuPinInfo

Reuse the function so that we can get rid of a lot of temporary
allocations.

9 years agoutil: bitmap: Add virBitmapToDataBuf that does not allocate the buffer
Peter Krempa [Thu, 21 May 2015 16:25:36 +0000 (18:25 +0200)]
util: bitmap: Add virBitmapToDataBuf that does not allocate the buffer

Since some functions can be optimized by reusing the buffers that they
already have instead of allocating and copying new ones, lets split
virBitmapToData to two functions where one only converts the data and
the second one is a wrapper that allocates the buffer if necessary.

9 years agoconf: Move pinning information definition closer to the usage place
Peter Krempa [Thu, 21 May 2015 14:16:15 +0000 (16:16 +0200)]
conf: Move pinning information definition closer to the usage place

9 years agoconf: Refactor emulatorpin handling
Peter Krempa [Thu, 21 May 2015 12:55:18 +0000 (14:55 +0200)]
conf: Refactor emulatorpin handling

Store the emulator pinning cpu mask as a pure virBitmap rather than the
virDomainPinDef since it stores only the bitmap and refactor
qemuDomainPinEmulator to do the same operations in a much saner way.

As a side effect virDomainEmulatorPinAdd and virDomainEmulatorPinDel can
be removed since they don't add any value.

9 years agoqemu: Fix possible crash in qemuProcessSetVcpuAffinities
Peter Krempa [Thu, 28 May 2015 14:22:13 +0000 (16:22 +0200)]
qemu: Fix possible crash in qemuProcessSetVcpuAffinities

In case when <vcpu ... cpuset=""> is not specified, the vcpupin array is
not guaranteed to be allocated to def->vcpus. This would cause a crash
for TCG since it does not report thread IDs for vCPUs.

9 years agoparallels: set virtType depending on driver name
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: set virtType depending on driver name

We remember driver name in a new field 'drivername' within
private parallels connection structure. When a new domain
is defined we use this name to set corresponding virtType.
We set VIR_DOMAIN_VIRT_VZ for 'vz' driver and
VIR_DOMAIN_VIRT_PARALLELS for 'Parallels'.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: recommend to connect to vz:///system when connection fails
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: recommend to connect to vz:///system when connection fails

Though parallels:///system is still accepted we will encourage users
to use vz:///system instead.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: increment the number of connection drivers
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: increment the number of connection drivers

We need to do this because we have just added a vz driver.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: add a new vz connection driver and hypervisor structures
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: add a new vz connection driver and hypervisor structures

We add this connection driver just as an exact copy with different
name to keep backward compatibility.
Vz stands for Virtuozzo, which is a new name of Parallels Cloud Server.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: accept vz as a driver uri and name
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: accept vz as a driver uri and name

If 'parallels:///system' uri is specified then connection is made to
'Parallels' driver and domain type will be VIR_DOMAIN_VIRT_PARALLELS.
In case of 'vz:///system' connection is established to 'vz' driver
and domain type will be VIR_DOMAIN_VIRT_VZ.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: add new guest capabilities assigned to vz driver
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: add new guest capabilities assigned to vz driver

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: use newly introduced VIR_DOMAIN_VIRT_VZ
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: use newly introduced VIR_DOMAIN_VIRT_VZ

As soon as we keep backward compatibility we treat this constant
as synonym to VIR_DOMAIN_VIRT_PARALLELS.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: introduce vz driver constant and string
Maxim Nestratov [Tue, 26 May 2015 17:12:00 +0000 (20:12 +0300)]
parallels: introduce vz driver constant and string

This new name and constant will be used as substitutions for parallels driver one.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoqemu: Do not release device address on successful RNG attach
Luyao Huang [Sun, 31 May 2015 11:29:46 +0000 (19:29 +0800)]
qemu: Do not release device address on successful RNG attach

Commit id '980b265d' neglected to check for a successful status when
deciding whether to release the device address for the RNG attach thus
the address would be released even though the device was added.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoqemu: Need to return status of RNG device removal
Luyao Huang [Sun, 31 May 2015 13:27:25 +0000 (21:27 +0800)]
qemu: Need to return status of RNG device removal

Commit id '862473fa' neglected to return the status from the
qemuDomainRemoveRNGDevice call in qemuDomainRemoveDevice causing
the function to always fail when receiving an RNG device unplug
event. Additionally the domain status/state would not be updated
in the processDeviceDeletedEvent path.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoaudit: Audit number of iothreads at domain startup
Luyao Huang [Sun, 31 May 2015 14:07:58 +0000 (22:07 +0800)]
audit: Audit number of iothreads at domain startup

If the domain has IOThreads defined, then audit the number started
at domain startup time.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agobuild: silence ar warnings on rawhide
Eric Blake [Tue, 2 Jun 2015 15:17:43 +0000 (09:17 -0600)]
build: silence ar warnings on rawhide

Newer binutils 'ar' has added an option 'D' for deterministic
builds, and at least on rawhide, this option is enabled by default.
But it conflicts with the 'u' optimization where the linker only
modifies libraries based on file timestamps, but can result in
different library ordering based on which files were touched last.
Thus, it results in some noisy compilation, for every CCLD line:

  CCLD     libvirt_driver_qemu_impl.la
  ar: `u' modifier ignored since `D' is the default (see `U')

Upstream automake has decided that defaulting ARFLAGS to 'cru' is
no longer beneficial, and that switching the default to 'cr' will
both silence the noise and not penalize modern build systems.

https://lists.gnu.org/archive/html/automake-patches/2015-06/msg00000.html

But rather than wait for newer automake to propagate to all systems
that already have newer binutils, we might as well just use the new
default ourselves, even on older platforms.

* configure.ac: Default AR[_]FLAGS to 'cr', not 'cru'.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agoutil: report all address range errors in virSocketAddrGetRange()
Laine Stump [Tue, 26 May 2015 19:44:24 +0000 (15:44 -0400)]
util: report all address range errors in virSocketAddrGetRange()

There are now many more reasons that virSocketAddrGetRange() could
fail, so it is much more informative to report the error there instead
of in the caller. (one of the two callers was previously assuming
success, which is almost surely safe based on the parsing that has
already happened to the config by that time, but it still is nicer to
account for an error "just in case")

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653

9 years agonetwork: cleanup range loop in networkDnsmasqConfContents
Laine Stump [Tue, 26 May 2015 19:32:59 +0000 (15:32 -0400)]
network: cleanup range loop in networkDnsmasqConfContents

This loop had automatic variable definitions mixed with code. This
patch moves the definitions to the top of the function and puts
cleanup for them at the bottom. No functional change.

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653

9 years agonetwork: validate DHCP ranges are completely within defined network
Laine Stump [Fri, 22 May 2015 21:32:02 +0000 (17:32 -0400)]
network: validate DHCP ranges are completely within defined network

virSocketAddrGetRange() has been updated to take the network address
and prefix, and now checks that both the start and end of the range
are within that network, thus validating that the entire range of
addresses is in the network. For IPv4, it also checks that ranges to
not start with the "network address" of the subnet, nor end with the
broadcast address of the subnet (this check doesn't apply to IPv6,
since IPv6 doesn't have a broadcast or network address)

Negative tests have been added to the network update and socket tests
to verify that bad ranges properly generate an error.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=985653