]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
11 years agoIntroduce lxcDomObjFromDomain
Michal Privoznik [Wed, 17 Jul 2013 07:37:09 +0000 (09:37 +0200)]
Introduce lxcDomObjFromDomain

Similarly to qemu driver, we can use a helper function to
lookup a domain instead of copying multiple lines around.

11 years agoRemove lxcDriverLock from almost everywhere
Michal Privoznik [Wed, 17 Jul 2013 07:20:26 +0000 (09:20 +0200)]
Remove lxcDriverLock from almost everywhere

With the majority of fields in the virLXCDriverPtr struct
now immutable or self-locking, there is no need for practically
any methods to be using the LXC driver lock. Only a handful
of helper APIs now need it.

11 years agolxc: Make activeUsbHostdevs use locks
Michal Privoznik [Wed, 17 Jul 2013 07:14:42 +0000 (09:14 +0200)]
lxc: Make activeUsbHostdevs use locks

The activeUsbHostdevs item in LXCDriver are lockable, but the lock has
to be called explicitly. Call the virObject(Un)Lock() in order to
achieve mutual exclusion once lxcDriverLock is removed.

11 years agoStop accessing driver->caps directly in LXC driver
Michal Privoznik [Mon, 15 Jul 2013 09:43:10 +0000 (11:43 +0200)]
Stop accessing driver->caps directly in LXC driver

The 'driver->caps' pointer can be changed on the fly. Accessing
it currently requires the global driver lock. Isolate this
access in a single helper, so a future patch can relax the
locking constraints.

11 years agolxc: switch to virCloseCallbacks API
Michal Privoznik [Mon, 15 Jul 2013 17:08:11 +0000 (19:08 +0200)]
lxc: switch to virCloseCallbacks API

11 years agoIntroduce annotations for virLXCDriverPtr fields
Michal Privoznik [Tue, 16 Jul 2013 17:20:24 +0000 (19:20 +0200)]
Introduce annotations for virLXCDriverPtr fields

Annotate the fields in virLXCDriverPtr to indicate the locking
rules for their use.

11 years agolxc: Use atomic ops for driver->nactive
Michal Privoznik [Tue, 16 Jul 2013 17:05:06 +0000 (19:05 +0200)]
lxc: Use atomic ops for driver->nactive

11 years agoIntroduce a virLXCDriverConfigPtr object
Michal Privoznik [Tue, 16 Jul 2013 15:45:05 +0000 (17:45 +0200)]
Introduce a virLXCDriverConfigPtr object

Currently the virLXCDriverPtr struct contains an wide variety
of data with varying access needs. Move all the static config
data into a dedicated virLXCDriverConfigPtr object. The only
locking requirement is to hold the driver lock, while obtaining
an instance of virLXCDriverConfigPtr. Once a reference is held
on the config object, it can be used completely lockless since
it is immutable.

NB, not all APIs correctly hold the driver lock while getting
a reference to the config object in this patch. This is safe
for now since the config is never updated on the fly. Later
patches will address this fully.

11 years agovirLXCDriver: Drop unused @cgroup
Michal Privoznik [Thu, 18 Jul 2013 11:34:55 +0000 (13:34 +0200)]
virLXCDriver: Drop unused @cgroup

It is not used anywhere, so it makes no sense to have it there.

11 years agoqemu: Move close callbacks handling into util/virclosecallbacks.c
Michal Privoznik [Mon, 15 Jul 2013 14:53:13 +0000 (16:53 +0200)]
qemu: Move close callbacks handling into util/virclosecallbacks.c

11 years agoqemuhotplugtest: Resolve some memleaks
Michal Privoznik [Thu, 18 Jul 2013 10:38:02 +0000 (12:38 +0200)]
qemuhotplugtest: Resolve some memleaks

If testQemuHotplugAttach succeeds, the vm->def steals the dev pointer.
However, not the envelope, which needs to be freed. In addition,
driver.config is allocated, but never freed.

11 years agoqemuDomainDetachChrDevice: Don't leak @charAlias
Michal Privoznik [Thu, 18 Jul 2013 10:35:51 +0000 (12:35 +0200)]
qemuDomainDetachChrDevice: Don't leak @charAlias

Moreover, since virAsprintf now does report OOM error, there's no need
to call virReportOOMError in error path.

11 years agovirAsprintf: correctly check return value
Ján Tomko [Thu, 18 Jul 2013 10:13:46 +0000 (12:13 +0200)]
virAsprintf: correctly check return value

When virAsprintf was changed from a function to a macro
reporting OOM error in dc6f2da, it was documented as returning
0 on success. This is incorrect, it returns the number of bytes
written as asprintf does.

Some of the functions were converted to use virAsprintf's return
value directly, changing the return value on success from 0 to >= 0.

For most of these, this is not a problem, but the change in
virPCIDriverDir breaks PCI passthrough.

The return value check in virhashtest pre-dates virAsprintf OOM
conversion.

vmwareMakePath seems to be unused.

11 years agoMerge virCommandPreserveFD / virCommandTransferFD
Daniel P. Berrange [Thu, 11 Jul 2013 10:31:56 +0000 (11:31 +0100)]
Merge virCommandPreserveFD / virCommandTransferFD

Merge the virCommandPreserveFD / virCommandTransferFD methods
into a single virCommandPasFD method, and use a new
VIR_COMMAND_PASS_FD_CLOSE_PARENT to indicate their difference
in behaviour

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnable FD passing when starting guests with virsh
Daniel P. Berrange [Thu, 11 Jul 2013 15:32:14 +0000 (16:32 +0100)]
Enable FD passing when starting guests with virsh

Add a "--pass-fds N,M,..." arg to the virsh start/create
methods. This allows pre-opened file descriptors from the
shell to be passed on into the guest

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoLXC: Wire up the virDomainCreate{XML}WithFiles methods
Daniel P. Berrange [Tue, 9 Jul 2013 17:15:45 +0000 (18:15 +0100)]
LXC: Wire up the virDomainCreate{XML}WithFiles methods

Wire up the new virDomainCreate{XML}WithFiles methods in the
LXC driver, so that FDs get passed down to the init process.

The lxc_container code needs to do a little dance in order
to renumber the file descriptors it receives into linear
order, starting from STDERR_FILENO + 1.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix impl of virDomainCreateWithFlags remote client helper
Daniel P. Berrange [Fri, 12 Jul 2013 10:56:00 +0000 (11:56 +0100)]
Fix impl of virDomainCreateWithFlags remote client helper

In the following commit:

  commit 03d813bbcd7b4a18360105500672b84d985dd889
  Author: Marek Marczykowski <marmarek@invisiblethingslab.com>
  Date:   Thu May 23 02:01:30 2013 +0200

    remote: fix dom->id after virDomainCreateWithFlags

The virDomainCreateWithFlags remote client helper was made to
invoke REMOTE_PROC_DOMAIN_LOOKUP_BY_UUID to refresh the 'id'
of the domain, following the pattern used in the previous
virDomainCreate method impl.

The remote protocol for virDomainCreateWithFlags though did
actually fix the design flaw in virDomainCreate, by directly
returning the new domain info. For some reason, this data was
never used. So we can just use that data now instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce remote protocol support for virDomainCreate{XML}WithFiles
Daniel P. Berrange [Tue, 9 Jul 2013 17:03:18 +0000 (18:03 +0100)]
Introduce remote protocol support for virDomainCreate{XML}WithFiles

Since they make use of file descriptor passing, the remote protocol
methods for virDomainCreate{XML}WithFiles must be written by hand.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce new domain create APIs to pass pre-opened FDs to LXC
Daniel P. Berrange [Tue, 9 Jul 2013 16:12:38 +0000 (17:12 +0100)]
Introduce new domain create APIs to pass pre-opened FDs to LXC

With container based virt, it is useful to be able to pass
pre-opened file descriptors to the container init process.
This allows for containers to be auto-activated from incoming
socket connections, passing the active socket into the container.

To do this, introduce a pair of new APIs, virDomainCreateXMLWithFiles
and virDomainCreateWithFiles, which accept an array of file
descriptors. For the LXC driver, UNIX file descriptor passing
will be used to send them to libvirtd, which will them pass
them down to libvirt_lxc, which will then pass them to the container
init process.

This will only be implemented for LXC right now, but the design
is generic enough it could work with other hypervisors, hence
I suggest adding this to libvirt.so, rather than libvirt-lxc.so

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agomaint: Make ctags work out of the box
Jiri Denemark [Wed, 17 Jul 2013 10:43:53 +0000 (12:43 +0200)]
maint: Make ctags work out of the box

The .ctags file specifies default options for ctags so that it does not
ignore libvirt.h.in and ignores uninteresting files. As a result, you
can just run "ctags" and navigating to a public API won't get you to a
useless entry in api.html.

11 years agoesx: Support for disk-only and quiescing snapshots.
Geoff Hickey [Wed, 17 Jul 2013 18:28:33 +0000 (14:28 -0400)]
esx: Support for disk-only and quiescing snapshots.

Add support for creating disk-only (no memory) snapshots in esx, and
for quiescing the VM before taking the snapshot. The VMware API
supports these operations directly, so adding support to libvirt is
just a matter of setting the flags correctly when calling
VMware. VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY and
VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE are now valid flags for esx.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: implement virDomainGetNumaParameters
Dario Faggioli [Sat, 13 Jul 2013 00:27:18 +0000 (02:27 +0200)]
libxl: implement virDomainGetNumaParameters

Although, having it depending on Xen >= 4.3 (by using the proper
libxl feature flag).

Xen currently implements a NUMA placement policy which is basically
the same as the 'interleaved' policy of `numactl', although it can
be applied on a subset of the available nodes. We therefore hardcode
"interleave" as 'numa_mode', and we use the newly introduced libxl
interface to figure out what nodes a domain spans ('numa_nodeset').

With this change, it is now possible to query the NUMA node
affinity of a running domain:

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// list
 Id    Name                           State
----------------------------------------------------
 23    F18_x64                        running

[raistlin@Zhaman ~]$ sudo virsh --connect xen:/// numatune 23
numa_mode      : interleave
numa_nodeset   : 1

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agolibxl: advertise the support for VIR_TYPED_PARAM_STRING
Dario Faggioli [Sat, 13 Jul 2013 00:27:10 +0000 (02:27 +0200)]
libxl: advertise the support for VIR_TYPED_PARAM_STRING

domainGetNumaParameters has a string typed parameter, hence it
is necessary for the libxl driver to support this.

This change implements the connectSupportsFeature hook for the
libxl driver, advertising that VIR_DRV_FEATURE_TYPED_PARAM_STRING
is supported.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Eric Blake <eblake@redhat.com>
11 years agoxen: Add interface versions for Xen 4.3
Stefan Bader [Tue, 16 Jul 2013 16:11:16 +0000 (18:11 +0200)]
xen: Add interface versions for Xen 4.3

Xen 4.3 changes sysctl version to 10 and domctl version to 9. Update
the hypervisor driver to work with those.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agolxc_container: Don't call virGetGroupList during exec
Michal Privoznik [Wed, 17 Jul 2013 09:21:09 +0000 (11:21 +0200)]
lxc_container: Don't call virGetGroupList during exec

Commit 75c1256 states that virGetGroupList must not be called
between fork and exec, then commit ee777e99 promptly violated
that for lxc.

Patch originally posted by Eric Blake <eblake@redhat.com>.

11 years agocgroup: reuse buffer for getline
Ján Tomko [Wed, 17 Jul 2013 08:56:05 +0000 (10:56 +0200)]
cgroup: reuse buffer for getline

Reuse the buffer for getline and track buffer allocation
separately from the string length to prevent unlikely
out-of-bounds memory access.

This fixes the following leak that happened when zero bytes were read:

==404== 120 bytes in 1 blocks are definitely lost in loss record 1,344 of 1,671
==404==    at 0x4C2C71B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==404==    by 0x906F862: getdelim (iogetdelim.c:68)
==404==    by 0x52A48FB: virCgroupPartitionNeedsEscaping (vircgroup.c:1136)
==404==    by 0x52A0FB4: virCgroupPartitionEscape (vircgroup.c:1171)
==404==    by 0x52A0EA4: virCgroupNewDomainPartition (vircgroup.c:1450)

11 years agoqemuDomainGetSchedulerType: Prefer qemuDomObjFromDomain
Michal Privoznik [Wed, 17 Jul 2013 06:07:20 +0000 (08:07 +0200)]
qemuDomainGetSchedulerType: Prefer qemuDomObjFromDomain

In all qemu APIs we tend to prefer qemuDomObjFromDomain over
virDomainObjListFindByUUID. But somehow the
qemuDomainGetSchedulerType left unattended.

11 years agovirSecurityManagerGenLabel: Skip seclabels without model
Michal Privoznik [Mon, 15 Jul 2013 13:50:29 +0000 (15:50 +0200)]
virSecurityManagerGenLabel: Skip seclabels without model

While generating seclabels, we check the seclabel stack if required
driver is in the stack. If not, an error is returned. However, it is
possible for a seclabel to not have any model set (happens with LXC
domains that have just <seclabel type='none'>). If that's the case,
we should just skip the iteration instead of calling STREQ(NULL, ...)
and SIGSEGV-ing subsequently.

11 years agolxcCapsInit: Allocate primary security driver unconditionally
Michal Privoznik [Mon, 15 Jul 2013 13:36:04 +0000 (15:36 +0200)]
lxcCapsInit: Allocate primary security driver unconditionally

Currently, if the primary security driver is 'none', we skip
initializing caps->host.secModels. This means, later, when LXC domain
XML is parsed and <seclabel type='none'/> is found (see
virSecurityLabelDefsParseXML), the model name is not copied to the
seclabel. This leads to subsequent crash in virSecurityManagerGenLabel
where we call STREQ() over the model (note, that we are expecting model
to be !NULL).

11 years agoqemu: Separate host device removal into a standalone function
Jiri Denemark [Thu, 11 Jul 2013 09:14:16 +0000 (11:14 +0200)]
qemu: Separate host device removal into a standalone function

11 years agoqemu: Separate net device removal into a standalone function
Jiri Denemark [Tue, 9 Jul 2013 22:37:12 +0000 (00:37 +0200)]
qemu: Separate net device removal into a standalone function

11 years agoqemu: Separate controller removal into a standalone function
Jiri Denemark [Tue, 9 Jul 2013 22:10:32 +0000 (00:10 +0200)]
qemu: Separate controller removal into a standalone function

11 years agoqemu: Separate disk device removal into a standalone function
Jiri Denemark [Tue, 9 Jul 2013 21:43:22 +0000 (23:43 +0200)]
qemu: Separate disk device removal into a standalone function

11 years agoqemu: Add qemuDomainReleaseDeviceAddress to remove any address
Jiri Denemark [Tue, 9 Jul 2013 20:30:57 +0000 (22:30 +0200)]
qemu: Add qemuDomainReleaseDeviceAddress to remove any address

11 years agoCreate directory for lease files if it's missing
Guido Günther [Sun, 7 Jul 2013 12:59:48 +0000 (14:59 +0200)]
Create directory for lease files if it's missing

If we don't autostart a network it's not being created.

Debian Bug http://bugs.debian.org/715200

11 years agobuild: avoid compiler warning on shadowed name
Eric Blake [Tue, 16 Jul 2013 16:11:32 +0000 (10:11 -0600)]
build: avoid compiler warning on shadowed name

Introduced in commit 24b08219; compilation on RHEL 6.4 complained:
qemu/qemu_hotplug.c: In function 'qemuDomainAttachChrDevice':
qemu/qemu_hotplug.c:1257: error: declaration of 'remove' shadows a global declaration [-Wshadow]
/usr/include/stdio.h:177: error: shadowed declaration is here [-Wshadow]

* src/qemu/qemu_hotplug.c (qemuDomainAttachChrDevice): Avoid the
name 'remove'.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC: Change the owner of live attached host devices
Gao feng [Tue, 16 Jul 2013 02:00:06 +0000 (10:00 +0800)]
LXC: Change the owner of live attached host devices

The owner of this host devices should be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Change the owner of host devices to the root of container
Gao feng [Tue, 16 Jul 2013 02:00:05 +0000 (10:00 +0800)]
LXC: Change the owner of host devices to the root of container

These host devices are created for container,
the owner should be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Create host devices for container on host side
Gao feng [Tue, 16 Jul 2013 02:00:04 +0000 (10:00 +0800)]
LXC: Create host devices for container on host side

Otherwise the container will fail to start if we
enable user namespace, since there is no rights to
do mknod in uninit user namespace.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Change the owner of live attached disk device
Gao feng [Tue, 16 Jul 2013 02:00:03 +0000 (10:00 +0800)]
LXC: Change the owner of live attached disk device

The owner of this disk device should be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Move virLXCControllerChown to lxc_container.c
Gao feng [Tue, 16 Jul 2013 02:00:02 +0000 (10:00 +0800)]
LXC: Move virLXCControllerChown to lxc_container.c

lxc driver will use this function to change the owner
of hot added devices.

Move virLXCControllerChown to lxc_container.c and Rename
it to lxcContainerChown.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: controller: change the owner of disk to the root of container
Gao feng [Tue, 16 Jul 2013 02:00:01 +0000 (10:00 +0800)]
LXC: controller: change the owner of disk to the root of container

These disk devices are created for container,
the owner should be the root user of container.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: Setup disks for container on host side
Gao feng [Tue, 16 Jul 2013 02:00:00 +0000 (10:00 +0800)]
LXC: Setup disks for container on host side

Since mknod in container is forbidden, we should setup disks
on host side.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoqemu: Fix double free of returned JSON array in qemuAgentGetVCPUs()
Peter Krempa [Tue, 16 Jul 2013 13:39:06 +0000 (15:39 +0200)]
qemu: Fix double free of returned JSON array in qemuAgentGetVCPUs()

A part of the returned monitor response was freed twice and caused
crashes of the daemon when using guest agent cpu count retrieval.

 # virsh vcpucount dom --guest

Introduced in v1.0.6-48-gc6afcb0

11 years agorbd: Do not free the secret if it is not set
Wido den Hollander [Tue, 16 Jul 2013 12:26:07 +0000 (14:26 +0200)]
rbd: Do not free the secret if it is not set

Not all RBD (Ceph) storage pools have cephx authentication turned on,
so "secret" might not be initialized.

It could also be that the secret couldn't be located.

Only call virSecretFree() if "secret" is initialized earlier.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
11 years agoAllow balloon driver collection to be adjusted dynamically
John Ferlan [Mon, 8 Jul 2013 17:19:43 +0000 (13:19 -0400)]
Allow balloon driver collection to be adjusted dynamically

Use the virDomainSetMemoryStatsPeriodFlags() to pass a period defined by
usage of a new --period option in order to set the collection period for the
balloon driver. This may enable or disable the collection based on the value.

Add the --current, --live, & --config options to dommemstat.

11 years agoImplement the virDomainSetMemoryStatsPeriod for QEMU driver
John Ferlan [Mon, 8 Jul 2013 16:47:23 +0000 (12:47 -0400)]
Implement the virDomainSetMemoryStatsPeriod for QEMU driver

Implement the new API that will handle setting the balloon driver statistics
collection period in order to enable or disable the collection dynamically.

11 years agoSpecify remote protocol for virDomainSetMemoryStatsPeriod
John Ferlan [Mon, 8 Jul 2013 16:42:57 +0000 (12:42 -0400)]
Specify remote protocol for virDomainSetMemoryStatsPeriod

Wire up the remote protocol

11 years agoAdd new public API virDomainSetMemoryStatsPeriod
John Ferlan [Mon, 8 Jul 2013 14:22:38 +0000 (10:22 -0400)]
Add new public API virDomainSetMemoryStatsPeriod

Add new API in order to set the balloon memory driver statistics collection
period in order to allow dynamic period adjustment for the virsh dommemstats to
display balloon stats data

11 years agoAdd capability to fetch balloon stats
John Ferlan [Thu, 11 Jul 2013 23:18:48 +0000 (19:18 -0400)]
Add capability to fetch balloon stats

This patch will add the qemuMonitorJSONGetMemoryStats() to execute a
"guest-stats" on the balloonpath using "get-qom" replacing the former
mechanism which looked through the "query-ballon" returned data for
the fields.  The "query-balloon" code only returns 'actual' memory.
Rather than duplicating the existing code, have the JSON API use the
GetBalloonInfo API.

A check in the qemuMonitorGetMemoryStats() will be made to ensure the
balloon driver path has been set.  Since the underlying JSON code can
return data not associated with the balloon driver, we don't fail on
a failure to get the balloonpath.  Of course since we've made the check,
we can then set the ballooninit flag.  Getting the path here is primarily
due to the process reconnect path which doesn't attempt to set the
collection period.

11 years agoDetermine whether to start balloon memory stats gathering.
John Ferlan [Thu, 27 Jun 2013 15:00:31 +0000 (11:00 -0400)]
Determine whether to start balloon memory stats gathering.

At vm startup and attach attempt to set the balloon driver statistics
collection period based on the value found in the domain xml file. This
is not done at reconnect since it's possible that a collection period
was set on the live guest and making the set period call would reset to
whatever value is stored in the config file.

Setting the stats collection period has a side effect of searching through
the qom-list output for the virtio balloon driver and making sure that it
has the right properties in order to allow setting of a collection period
and eventually fetching of statistics.

The walk through the qom-list is expensive and thus the balloonpath will
be saved in the monitor private structure as well as a flag indicating
that the initialization has already been attempted (in the event that a
path is not found, no sense to keep checking).

This processing model conforms to the qom object model model which
requires setting object properties after device startup. That is, it's
not possible to pass the period along via the startup code as it won't
be recognized.

11 years agoAdd 'period' for Memballoon statistics gathering capability
John Ferlan [Wed, 26 Jun 2013 11:00:00 +0000 (07:00 -0400)]
Add 'period' for Memballoon statistics gathering capability

Add a period in seconds to allow/enable statistics gathering from the
Balloon driver for 'virsh dommemstat <domain>'.

11 years agoqemu: Prevent crash of libvirtd without guest agent configuration
Alex Jia [Tue, 16 Jul 2013 09:30:20 +0000 (17:30 +0800)]
qemu: Prevent crash of libvirtd without guest agent configuration

If users haven't configured guest agent then qemuAgentCommand() will
dereference a NULL 'mon' pointer, which causes crash of libvirtd when
using agent based cpu (un)plug.

With the patch, when the qemu-ga service isn't running in the guest,
a expected error "error: Guest agent is not responding: Guest agent
not available for now" will be raised, and the error "error: argument
unsupported: QEMU guest agent is not configured" is raised when the
guest hasn't configured guest agent.

GDB backtrace:

 (gdb) bt
 #0  virNetServerFatalSignal (sig=11, siginfo=<value optimized out>, context=<value optimized out>) at rpc/virnetserver.c:326
 #1  <signal handler called>
 #2  qemuAgentCommand (mon=0x0, cmd=0x7f39300017b0, reply=0x7f394b090910, seconds=-2) at qemu/qemu_agent.c:975
 #3  0x00007f39429507f6 in qemuAgentGetVCPUs (mon=0x0, info=0x7f394b0909b8) at qemu/qemu_agent.c:1475
 #4  0x00007f39429d9857 in qemuDomainGetVcpusFlags (dom=<value optimized out>, flags=9) at qemu/qemu_driver.c:4849
 #5  0x00007f3957dffd8d in virDomainGetVcpusFlags (domain=0x7f39300009c0, flags=8) at libvirt.c:9843

How to reproduce?

 # To start a guest without guest agent configuration
 # then run the following cmdline

 # virsh vcpucount foobar --guest
 error: End of file while reading data: Input/output error
 error: One or more references were leaked after disconnect from the hypervisor
 error: Failed to reconnect to the hypervisor

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

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agoMake logical pools independent on target path
Martin Kletzander [Tue, 30 Apr 2013 11:48:46 +0000 (13:48 +0200)]
Make logical pools independent on target path

When using logical pools, we had to trust the target->path provided.
This parameter, however, can be completely ommited and we can use
'/dev/<source.name>' safely and populate it to target.path.

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

11 years agoqemuhotplugtest: Introduce test for chardev hotplug
Michal Privoznik [Tue, 2 Jul 2013 08:16:30 +0000 (10:16 +0200)]
qemuhotplugtest: Introduce test for chardev hotplug

The test is currently testing just device update function. However,
chardev hotplug is implemented just for device attach and detach. This
fact means, the test needs to be rewritten (the majority of the code is
still shared). Moreover, we are now able to pass VM among multiple test
runs. So for instance, while we add a device in the first run, we can
remove it in the second run.

11 years agoqemu: Implement chardev hotplug on live level
Michal Privoznik [Wed, 13 Mar 2013 10:08:55 +0000 (11:08 +0100)]
qemu: Implement chardev hotplug on live level

Since previous patches has prepared everything for us, we may now
implement live hotplug of a character device.

11 years agoqemu: Implement chardev hotplug on config level
Michal Privoznik [Tue, 12 Mar 2013 14:59:25 +0000 (15:59 +0100)]
qemu: Implement chardev hotplug on config level

There are two levels on which a device may be hotplugged: config
and live. The config level requires just an insert or remove from
internal domain definition structure, which is exactly what this
patch does. There is currently no implementation for a chardev
update action, as there's not much to be updated. But more
importantly, the only thing that can be updated is path or socket
address by which chardevs are distinguished. So the update action
is currently not supported.

11 years agodomain_conf: Auto fill chardev port
Michal Privoznik [Fri, 12 Jul 2013 16:52:17 +0000 (18:52 +0200)]
domain_conf: Auto fill chardev port

Now that we have callbacks, we should auto fill in omitted pieces of
information. It's important for chardev hotplug to fill in the correct
/{serial,parallel,console,channel}/target/@port if no value has been
provided by user.

11 years agocpu: Allow fine tuning of "host-model" cpu
Peter Krempa [Mon, 15 Jul 2013 15:38:55 +0000 (17:38 +0200)]
cpu: Allow fine tuning of "host-model" cpu

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

Until now, the "host-model" cpu mode couldn't be influenced. This patch
allows to use the <feature> elements to either enable or disable
specific CPU flags. This can be used to force flags that can be emulated
even if the host CPU doesn't support them.

11 years agocpu: Clean up code style
Peter Krempa [Mon, 15 Jul 2013 13:40:40 +0000 (15:40 +0200)]
cpu: Clean up code style

11 years agocpu: Add virCPUDefUpdateFeature()
Peter Krempa [Mon, 15 Jul 2013 12:36:09 +0000 (14:36 +0200)]
cpu: Add virCPUDefUpdateFeature()

This new function updates or adds a feature to a existing cpu model
definition. This function will be helpful to allow tuning of
"host-model" features in later patches.

11 years agoconf: Clean up error reporting in cpu definition parsing
Peter Krempa [Mon, 15 Jul 2013 09:12:18 +0000 (11:12 +0200)]
conf: Clean up error reporting in cpu definition parsing

Use VIR_ERR_XML_ERROR instead of VIR_ERR_INTERNAL_ERROR in XML parsing
code and move "%s" formating strings right after the error code.

11 years agostorage_conf: Merge AuthChap and AuthCephx into AuthSecret
John Ferlan [Sat, 13 Jul 2013 19:43:46 +0000 (15:43 -0400)]
storage_conf: Merge AuthChap and AuthCephx into AuthSecret

Merge virStoragePoolDefParseAuthChap and virStoragePoolDefParseAuthCephx
into a common virStoragePoolDefParseAuthSecret.  Change the output to be
common for both by putting 'type' first followed by 'username'.

11 years agostorage_conf: Move username processing into common function
John Ferlan [Sat, 13 Jul 2013 19:15:38 +0000 (15:15 -0400)]
storage_conf: Move username processing into common function

Move the auth->username processing into virStoragePoolDefParseAuth
save the resulting username into chap/cephx specific data

11 years agostorage_pool: Rework chap XML to mimic ceph
John Ferlan [Sat, 13 Jul 2013 18:29:55 +0000 (14:29 -0400)]
storage_pool: Rework chap XML to mimic ceph

The existing 'chap' XML logic was never used - just defined.  Rather than
try to insert a square peg into a round hole, blow it up and rewrite the
logic to follow the 'ceph' format.

Remove the former "chap.login" and "chap.passwd" fields and replace
with "chap.username" and "chap.secret" in _virStoragePoolAuthChap.
Adjust the virStoragePoolDefParseAuthChap() to process.

Change the rng file to describe the new layout

Update the formatstorage.html to describe the usage of the secret element
to mention that the secret type "iscsi" and "ceph" can be used
to storage pool too.

Update the formatsecret.html to include a reference to the storage pool

Update tests to handle the changes from 'login' and 'passwd' to 'username'
and '<secret>' format

11 years agostorage_conf: Move auth processing into virStoragePoolDefParseAuth
John Ferlan [Sat, 13 Jul 2013 18:23:38 +0000 (14:23 -0400)]
storage_conf: Move auth processing into virStoragePoolDefParseAuth

Split processing of "<auth" into its own function

11 years agostorage_conf: Introduce virStoragePoolAuthSecretPtr
John Ferlan [Sat, 13 Jul 2013 18:15:15 +0000 (14:15 -0400)]
storage_conf: Introduce virStoragePoolAuthSecretPtr

Split out the _virStoragePoolAuthSecret data from _virStoragePoolAuthCephx
into its own structure

11 years agostorage_conf: Adjust virStoragePoolAuthType enum
John Ferlan [Sat, 13 Jul 2013 18:14:00 +0000 (14:14 -0400)]
storage_conf: Adjust virStoragePoolAuthType enum

Generate and use the virStoragePoolAuthTypeType{To|From}String helpers

11 years agoAdd qemuMonitorJSONSetObjectProperty() method for QMP qom-set command
John Ferlan [Wed, 3 Jul 2013 18:42:40 +0000 (14:42 -0400)]
Add qemuMonitorJSONSetObjectProperty() method for QMP qom-set command

Add a new qemuMonitorJSONSetObjectProperty() method to support invocation
of the 'qom-set' JSON monitor command with a provided path, property, and
expected data type to set.

NOTE: The set API was added only for the purpose of the qemumonitorjsontest

The test code uses the same "/machine/i440fx" property as the get test and
attempts to set the "realized" property to "true" (which it should be set
at anyway).

11 years agoAdd qemuMonitorJSONGetObjectProperty() method for QMP qom-get command
John Ferlan [Wed, 3 Jul 2013 18:15:07 +0000 (14:15 -0400)]
Add qemuMonitorJSONGetObjectProperty() method for QMP qom-get command

Add a new qemuMonitorJSONGetObjectProperty() method to support invocation
of the 'qom-get' JSON monitor command with a provided path, property, and
expected data type return. The qemuMonitorJSONObjectProperty is similar to
virTypedParameter; however, a future patch will extend it a bit to include
a void pointer to balloon driver statistic data.

NOTE: The ObjectProperty structures and API are added only for the
      purpose of the qemumonitorjsontest

The provided test will execute a qom-get on "/machine/i440fx" which will
return a property "realized".

11 years agoAdd qemuMonitorJSONGetObjectListPaths() method for QMP qom-list command
John Ferlan [Mon, 24 Jun 2013 17:51:56 +0000 (13:51 -0400)]
Add qemuMonitorJSONGetObjectListPaths() method for QMP qom-list command

Add a new qemuMonitorJSONGetObjectListPaths() method to support invocation
of the 'qom-list' JSON monitor command with a provided path.

NOTE: The ListPath structures and API's are added only for the
      purpose of the qemumonitorjsontest

The returned list of paired data fields of "name" and "type" that can
be used to peruse QOM configuration data and eventually utilize for the
balloon statistics.

The test does a "{"execute":"qom-list", "arguments": { "path": "/"}}" which
returns "{"return": [{"name": "machine", "type": "child<container>"},
{"name": "type", "type": "string"}]}" resulting in a return of an array
of 2 elements with [0].name="machine", [0].type="child<container>".  The [1]
entry appears to be a header that could be used some day via a command such
as "virsh qemuobject --list" to format output.

11 years agoqemu: add macvlan delete to qemuDomainAttachNetDevice cleanup
Matthew Rosato [Mon, 1 Jul 2013 15:04:57 +0000 (17:04 +0200)]
qemu: add macvlan delete to qemuDomainAttachNetDevice cleanup

If an error occurs during qemuDomainAttachNetDevice after the macvtap
was created in qemuPhysIfaceConnect, the macvtap device gets left behind.
This patch adds code to the cleanup routine to delete the macvtap.

Signed-off-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agopci: make virPCIDeviceReset more autonomous
Laine Stump [Sat, 29 Jun 2013 02:35:21 +0000 (22:35 -0400)]
pci: make virPCIDeviceReset more autonomous

I recently patches the callers to virPCIDeviceReset() to not call it
if the current driver for a device was vfio-pci (since that driver
will always reset the device itself when appropriate. At the time, Dan
Berrange suggested that I could instead modify virPCIDeviceReset
to check the currently bound driver for the device, and decide
for itself whether or not to go ahead with the reset.

This patch removes the previously added checks, and replaces them with
a check down in virPCIDeviceReset(), as suggested.

The functional difference here is that previously we were deciding
based on either the hostdev configuration or the value of
stubDriverName in the virPCIDevice object, but now we are actually
comparing to the "driver" link in the device's sysfs entry
directly. In practice, both should be the same.

11 years agopci: reorder static functions
Laine Stump [Mon, 1 Jul 2013 03:51:00 +0000 (23:51 -0400)]
pci: reorder static functions

virPCIDeviceGetDriverPathAndName is a static function that will need
to be called by another function that occurs above it in the
file. This patch reorders the static functions so that a forward
declaration isn't needed.

11 years agoqemuBuildChrDeviceCommandLine: Don't leak devstr
Michal Privoznik [Fri, 12 Jul 2013 17:18:29 +0000 (19:18 +0200)]
qemuBuildChrDeviceCommandLine: Don't leak devstr

It's caller's responsibility to free return value of
qemuBuildChrDeviceStr().

11 years agopython: return dictionary without value in case of no blockjob
Guannan Ren [Fri, 17 May 2013 06:30:10 +0000 (14:30 +0800)]
python: return dictionary without value in case of no blockjob

Currently, when there is no blockjob, dom.blockJobInfo('vda')
still reports error because it doesn't distinguish return value 0 from -1.
libvirt.libvirtError: virDomainGetBlockJobInfo() failed

virDomainGetBlockJobInfo() API return value:
 -1 in case of failure, 0 when nothing found, 1 found.

And use PyDict_SetItemString instead of PyDict_SetItem when key is
of string type. PyDict_SetItemString increments key/value reference
count, so call Py_DECREF() for value. For key, we don't need to
do this, because PyDict_SetItemString will handle it internally.

11 years agoconf: reject pci-root controllers with non-zero indexes
Ján Tomko [Fri, 12 Jul 2013 13:05:51 +0000 (15:05 +0200)]
conf: reject pci-root controllers with non-zero indexes

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

11 years agoChange domain controller index type to unsigned
Jincheng Miao [Fri, 12 Jul 2013 12:17:23 +0000 (14:17 +0200)]
Change domain controller index type to unsigned

Error out on negative index values.

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

11 years agovirsh: Mention --driver in man page for nodedev-detach
Peter Krempa [Fri, 12 Jul 2013 09:32:51 +0000 (11:32 +0200)]
virsh: Mention --driver in man page for nodedev-detach

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

Commit d923f6c8 introduced the --driver option but didn't document it in
the man page. The docs are borrowed from the public API documentation.

11 years agoAdd a couple of debug statements to LXC driver
Daniel P. Berrange [Fri, 12 Jul 2013 10:04:55 +0000 (11:04 +0100)]
Add a couple of debug statements to LXC driver

When failing to start a container due to inaccessible root
filesystem path, we did not log any meaningful error. Add a
few debug statements to assist diagnosis

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Introduce qemuBuildChrDeviceStr
Michal Privoznik [Wed, 13 Mar 2013 15:20:34 +0000 (16:20 +0100)]
qemu: Introduce qemuBuildChrDeviceStr

The function being introduced is responsible for creating command
line argument for '-device' for given character device. Based on
the chardev type, it calls appropriate qemuBuild.*ChrDeviceStr(),
e.g.  qemuBuildSerialChrDeviceStr() for serial chardev and so on.

11 years agoqemu_command: Honour chardev alias assignment with a function
Michal Privoznik [Wed, 13 Mar 2013 08:41:33 +0000 (09:41 +0100)]
qemu_command: Honour chardev alias assignment with a function

The chardev alias assignment is going to be needed in a separate
places, so it should be moved into a separate function rather
than copying code randomly around.

11 years agoqemu_monitor: Introduce qemuMonitorDetachCharDev
Michal Privoznik [Tue, 12 Mar 2013 18:57:48 +0000 (19:57 +0100)]
qemu_monitor: Introduce qemuMonitorDetachCharDev

This function wraps 'chardev-remove' qemu monitor command around.
It takes chardev alias as its single argument besides qemu monitor
pointer.

11 years agoqemu_monitor: Introduce qemuMonitorAttachCharDev
Michal Privoznik [Tue, 12 Mar 2013 18:48:04 +0000 (19:48 +0100)]
qemu_monitor: Introduce qemuMonitorAttachCharDev

The function being introduced is responsible for preparing and
executing 'chardev-add' qemu monitor command. Moreover, in case
of PTY chardev, the corresponding pty path is updated.

11 years agoqemu_monitor_json: Move InetSocketAddress build to a separate function
Michal Privoznik [Tue, 12 Mar 2013 18:18:22 +0000 (19:18 +0100)]
qemu_monitor_json: Move InetSocketAddress build to a separate function

Currently, we are building InetSocketAddress qemu json type
within the qemuMonitorJSONNBDServerStart function. However, other
future functions may profit from the code as well. So it should
be moved into a static function.

11 years agodomain_conf: Introduce chardev hotplug helpers
Michal Privoznik [Tue, 12 Mar 2013 14:55:07 +0000 (15:55 +0100)]
domain_conf: Introduce chardev hotplug helpers

For now, only these three helpers are needed:
virDomainChrFind - to find a duplicate chardev within VM def
virDomainChrInsert - wrapper for inserting a new chardev into VM def
virDomainChrRemove - wrapper for removing chardev from VM def

There is, however, one internal helper as well:
virDomainChrGetDomainPtrs which sets given pointers to one of
vmdef->{parallels,serials,consoles,channels} based on passed
chardev type.

11 years agoremote: Improve libssh2 password authentication
Peter Krempa [Tue, 9 Jul 2013 14:46:32 +0000 (16:46 +0200)]
remote: Improve libssh2 password authentication

This patch enables the password authentication in the libssh2 connection
driver. There are a few benefits to this step:

1) Hosts with challenge response authentication will now be supported
with the libssh2 connection driver.

2) Credential for hosts can now be stored in the authentication
credential config file

11 years agolibssh2: Improve password based authentication
Peter Krempa [Tue, 9 Jul 2013 14:34:38 +0000 (16:34 +0200)]
libssh2: Improve password based authentication

The password authentication method wasn't used as there wasn't a
pleasant way to pass the password. This patch adds the option to use
virAuth util functions to request the password either from a config file
or uses the conf callback to request it from the user.

11 years agovirAuth: Don't require virConnectPtr to retrieve authentication creds
Peter Krempa [Tue, 9 Jul 2013 14:14:45 +0000 (16:14 +0200)]
virAuth: Don't require virConnectPtr to retrieve authentication creds

Previously a connection object was required to retrieve the auth
credentials. This patch adds the option to call the retrieval functions
only using the connection URI or path to the configuration file. This
will allow to use this toolkit to request passwords for ssh
authentication in the libssh2 connection driver.

Changes:
*virAuthGetConfigFilePathURI(): use URI to retrieve the config file path
*virAuthGetCredential(): Remove the need to propagate conn object

virAuthGetPasswordPath():
*virAuthGetUsernamePath(): New functions, that use config file path
                           instead of conn object

11 years agonodeinfo: Don't fail on non-contiguous NUMA topologies
hejia hejia [Mon, 8 Jul 2013 14:03:05 +0000 (22:03 +0800)]
nodeinfo: Don't fail on non-contiguous NUMA topologies

nodeGetFreeMemory and nodeGetCellsFreeMemory assumed that the NUMA nodes
are contiguous and starting from 0. Unfortunately there are machines
that don't match this assumption:

available: 1 nodes (1)
node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
node 1 size: 16340 MB
node 1 free: 11065 MB

Before this patch:
error: internal error Failed to query NUMA free memory
error: internal error Failed to query NUMA free memory for node: 0

After this patch:
Total: 15772580 KiB
0: 0 KiB

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agoutil: make virSetUIDGID async-signal-safe
Eric Blake [Wed, 22 May 2013 02:59:10 +0000 (20:59 -0600)]
util: make virSetUIDGID async-signal-safe

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

POSIX states that multi-threaded apps should not use functions
that are not async-signal-safe between fork and exec, yet we
were using getpwuid_r and initgroups.  Although rare, it is
possible to hit deadlock in the child, when it tries to grab
a mutex that was already held by another thread in the parent.
I actually hit this deadlock when testing multiple domains
being started in parallel with a command hook, with the following
backtrace in the child:

 Thread 1 (Thread 0x7fd56bbf2700 (LWP 3212)):
 #0  __lll_lock_wait ()
     at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
 #1  0x00007fd5761e7388 in _L_lock_854 () from /lib64/libpthread.so.0
 #2  0x00007fd5761e7257 in __pthread_mutex_lock (mutex=0x7fd56be00360)
     at pthread_mutex_lock.c:61
 #3  0x00007fd56bbf9fc5 in _nss_files_getpwuid_r (uid=0, result=0x7fd56bbf0c70,
     buffer=0x7fd55c2a65f0 "", buflen=1024, errnop=0x7fd56bbf25b8)
     at nss_files/files-pwd.c:40
 #4  0x00007fd575aeff1d in __getpwuid_r (uid=0, resbuf=0x7fd56bbf0c70,
     buffer=0x7fd55c2a65f0 "", buflen=1024, result=0x7fd56bbf0cb0)
     at ../nss/getXXbyYY_r.c:253
 #5  0x00007fd578aebafc in virSetUIDGID (uid=0, gid=0) at util/virutil.c:1031
 #6  0x00007fd578aebf43 in virSetUIDGIDWithCaps (uid=0, gid=0, capBits=0,
     clearExistingCaps=true) at util/virutil.c:1388
 #7  0x00007fd578a9a20b in virExec (cmd=0x7fd55c231f10) at util/vircommand.c:654
 #8  0x00007fd578a9dfa2 in virCommandRunAsync (cmd=0x7fd55c231f10, pid=0x0)
     at util/vircommand.c:2247
 #9  0x00007fd578a9d74e in virCommandRun (cmd=0x7fd55c231f10, exitstatus=0x0)
     at util/vircommand.c:2100
 #10 0x00007fd56326fde5 in qemuProcessStart (conn=0x7fd53c000df0,
     driver=0x7fd55c0dc4f0, vm=0x7fd54800b100, migrateFrom=0x0, stdin_fd=-1,
     stdin_path=0x0, snapshot=0x0, vmop=VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
     flags=1) at qemu/qemu_process.c:3694
 ...

The solution is to split the work of getpwuid_r/initgroups into the
unsafe portions (getgrouplist, called pre-fork) and safe portions
(setgroups, called post-fork).

* src/util/virutil.h (virSetUIDGID, virSetUIDGIDWithCaps): Adjust
signature.
* src/util/virutil.c (virSetUIDGID): Add parameters.
(virSetUIDGIDWithCaps): Adjust clients.
* src/util/vircommand.c (virExec): Likewise.
* src/util/virfile.c (virFileAccessibleAs, virFileOpenForked)
(virDirCreate): Likewise.
* src/security/security_dac.c (virSecurityDACSetProcessLabel):
Likewise.
* src/lxc/lxc_container.c (lxcContainerSetID): Likewise.
* configure.ac (AC_CHECK_FUNCS_ONCE): Check for setgroups, not
initgroups.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: add virGetGroupList
Eric Blake [Tue, 21 May 2013 23:47:48 +0000 (17:47 -0600)]
util: add virGetGroupList

Since neither getpwuid_r() nor initgroups() are safe to call in
between fork and exec (they obtain a mutex, but if some other
thread in the parent also held the mutex at the time of the fork,
the child will deadlock), we have to split out the functionality
that is unsafe.  At least glibc's initgroups() uses getgrouplist
under the hood, so the ideal split is to expose getgrouplist for
use before a fork.  Gnulib already gives us a nice wrapper via
mgetgroups; we wrap it once more to look up by uid instead of name.

* bootstrap.conf (gnulib_modules): Add mgetgroups.
* src/util/virutil.h (virGetGroupList): New declaration.
* src/util/virutil.c (virGetGroupList): New function.
* src/libvirt_private.syms (virutil.h): Export it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: improve user lookup helper
Eric Blake [Tue, 9 Jul 2013 23:57:48 +0000 (17:57 -0600)]
util: improve user lookup helper

A future patch needs to look up pw_gid; but it is wasteful
to crawl through getpwuid_r twice for two separate pieces
of information, and annoying to copy that much boilerplate
code for doing the crawl.  The current internal-only
virGetUserEnt is also a rather awkward interface; it's easier
to just design it to let callers request multiple pieces of
data as needed from one traversal.

And while at it, I noticed that virGetXDGDirectory could deref
NULL if the getpwuid_r lookup fails.

* src/util/virutil.c (virGetUserEnt): Alter signature.
(virGetUserDirectory, virGetXDGDirectory, virGetUserName): Adjust
callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu_hostdev: Resolve Coverity issue
John Ferlan [Thu, 11 Jul 2013 14:42:30 +0000 (10:42 -0400)]
qemu_hostdev: Resolve Coverity issue

Recent changes uncovered a possibility that 'last_processed_hostdev_vf'
was set to -1 in 'qemuPrepareHostdevPCIDevices' and would cause problems
in for loop end condition in the 'resetvfnetconfig' label if the
variable was never set to 'i' due to 'qemuDomainHostdevNetConfigReplace'
failure.

11 years agostorage_backend: Resolve Coverity issue
John Ferlan [Thu, 11 Jul 2013 14:39:23 +0000 (10:39 -0400)]
storage_backend: Resolve Coverity issue

The switch statement in 'virStorageBackendCreateQemuImgOpts' used the
for loop end condition 'VIR_STORAGE_FILE_FEATURE_LAST' as a possible value,
but since that cannot happen Coverity spits out a DEADCODE message. Adding
the Coverity tag just removes the Coverity message

11 years agovirsh-nodedev: Resolve Coverity issues
John Ferlan [Thu, 11 Jul 2013 14:33:29 +0000 (10:33 -0400)]
virsh-nodedev: Resolve Coverity issues

Recent changes uncovered FORWARD_NULL and NEGATIVE_RETURNS problems with
the processing of the 'ndevices' and its associated allocated arrays in
'vshNodeDeviceListCollect' due to the possibility of returning -1 in a
call and using the returned value as a for loop index end condition.

11 years agovirsh-interface: Resolve Coverity issues
John Ferlan [Thu, 11 Jul 2013 14:31:15 +0000 (10:31 -0400)]
virsh-interface: Resolve Coverity issues

Recent changes uncovered FORWARD_NULL and NEGATIVE_RETURNS problems with
the processing of the 'nActiveIfaces' and 'nInactiveIfaces' and their
associated allocated arrays in 'vshInterfaceListCollect' due to the
possibility of returning -1 in a call and using the return value as a
for loop index end condition.

11 years agovirsh-domain-monitor: Resolve Coverity issues
John Ferlan [Thu, 11 Jul 2013 14:28:44 +0000 (10:28 -0400)]
virsh-domain-monitor: Resolve Coverity issues

Recent changes uncovered a pair of NEGATIVE_RETURNS when processing the
'nnames' in 'vshDomainListCollect' in the for loop due to possible -1 value.

11 years agotestutils: Resolve Coverity issues
John Ferlan [Thu, 11 Jul 2013 11:22:20 +0000 (07:22 -0400)]
testutils: Resolve Coverity issues

Recent changes uncovered a NEGATIVE_RETURNS in the return from sysconf()
when processing a for loop in virtTestCaptureProgramExecChild() in
testutils.c

Code review uncovered 3 other code paths with the same condition that
weren't found by Covirity, so fixed those as well.

11 years agohellolibvirt: Resolve Coverity issues
John Ferlan [Thu, 11 Jul 2013 11:19:37 +0000 (07:19 -0400)]
hellolibvirt: Resolve Coverity issues

Recent changes uncovered a NEGATIVE_RETURNS when processing 'numNames'
in 'showDomains' in the for loop after a possible -1 return.