]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agolxc_cgroup: Add check for NULL cgroup before AddTask call
John Ferlan [Fri, 18 Dec 2015 13:25:47 +0000 (08:25 -0500)]
lxc_cgroup: Add check for NULL cgroup before AddTask call

Commit id '71ce4759' altered the cgroup processing with respect to the
call to virCgroupAddTask being moved out from lower layers into the calling
layers especially for qemu processing of emulator and vcpu threads. The
movement affected lxc insomuch as it is possible for a code path to
return a NULL cgroup *and* a 0 return status via virCgroupNewPartition
failure when virCgroupNewIgnoreError succeeded when virCgroupNewMachineManual
returns. Coverity pointed out that would cause virCgroupAddTask to core.

This patch will check for a NULL cgroup as well as the negative return
and just return the NULL cgroup to the caller (as it would have previously)

9 years agoXen: remove xendConfigVersion from driver private struct
Jim Fehlig [Tue, 15 Dec 2015 02:53:16 +0000 (19:53 -0700)]
Xen: remove xendConfigVersion from driver private struct

xendConfigVersion is no longer used, so remove it from the
xenUnifiedPrivate struct.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xenconfig: remove xendConfigVersion from public sexpr functions
Jim Fehlig [Tue, 15 Dec 2015 02:31:39 +0000 (19:31 -0700)]
Xen: xenconfig: remove xendConfigVersion from public sexpr functions

Remove use of xendConfigVersion in the s-expresion config formatter/parser
in src/xenconfig/. Adjust callers in the xen and libxl drivers accordingly.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xend: remove use of XEND_CONFIG_VERSION
Jim Fehlig [Fri, 4 Dec 2015 22:27:34 +0000 (15:27 -0700)]
Xen: xend: remove use of XEND_CONFIG_VERSION

Remove use of XEND_CONFIG_VERSION_* in xend_internal.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xen_driver: remove use of XEND_CONFIG_VERSION
Jim Fehlig [Fri, 4 Dec 2015 21:06:10 +0000 (14:06 -0700)]
Xen: xen_driver: remove use of XEND_CONFIG_VERSION

Remove use of XEND_CONFIG_VERSION_* in the Xen unified driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_sxpr
Jim Fehlig [Tue, 15 Dec 2015 01:18:55 +0000 (18:18 -0700)]
Xen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_sxpr

Remove use of XEND_CONFIG_VERSION_* in s-expression parser/formatter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: use latest XEND_CONFIG_VERSION in xml2sexpr tests
Jim Fehlig [Mon, 14 Dec 2015 06:41:48 +0000 (23:41 -0700)]
Xen: tests: use latest XEND_CONFIG_VERSION in xml2sexpr tests

Change all xml2sexpr tests to use the latest XEND_CONFIG_VERSION
(XEND_CONFIG_VERSION_3_1_0 = 4). Fix tests that do not conform to
the latest version.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xenconfig: remove disks from '(image)' sexpr
Jim Fehlig [Tue, 15 Dec 2015 00:44:30 +0000 (17:44 -0700)]
Xen: xenconfig: remove disks from '(image)' sexpr

It has been quite some time since xend required specifying cdroms
and fds in '(image (hvm ...))'. Remove the code from the parsing
and formatting functions and fixup the associated tests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: use latest XEND_CONFIG_VERSION in sexpr2xml tests
Jim Fehlig [Thu, 10 Dec 2015 04:15:07 +0000 (21:15 -0700)]
Xen: tests: use latest XEND_CONFIG_VERSION in sexpr2xml tests

Change all sexpr2xml tests to use the latest XEND_CONFIG_VERSION
(XEND_CONFIG_VERSION_3_1_0 = 4). Fix tests that do not conform to
the latest version.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xenconfig: remove xendConfigVersion from public functions
Jim Fehlig [Sat, 5 Dec 2015 02:11:39 +0000 (19:11 -0700)]
Xen: xenconfig: remove xendConfigVersion from public functions

Remove use of xendConfigVersion in the xm and xl config formatter/parsers
in src/xenconfig/. Adjust callers in the xen and libxl drivers accordingly.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_xm
Jim Fehlig [Sat, 5 Dec 2015 06:55:00 +0000 (23:55 -0700)]
Xen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_xm

Remove use of XEND_CONFIG_VERSION_* in xm parser/formatter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: xenconfig: remove XEND_CONFIG_VERSION in common code
Jim Fehlig [Fri, 4 Dec 2015 23:08:59 +0000 (16:08 -0700)]
Xen: xenconfig: remove XEND_CONFIG_VERSION in common code

Remove use of XEND_CONFIG_VERSION_* from xenconfig/xen_common.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: use latest XEND_CONFIG_VERSION in xm/xl tests
Jim Fehlig [Sat, 5 Dec 2015 01:09:28 +0000 (18:09 -0700)]
Xen: tests: use latest XEND_CONFIG_VERSION in xm/xl tests

Change all tests to use the latest XEND_CONFIG_VERSION
(XEND_CONFIG_VERSION_3_1_0 = 4). Fix tests that do not conform to
the latest version.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: remove old xml2sexpr tests
Jim Fehlig [Mon, 14 Dec 2015 21:59:40 +0000 (14:59 -0700)]
Xen: tests: remove old xml2sexpr tests

Remove XML to s-expression converstion tests for old xend 3.0.2
config format.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: remove old sexpr2xml tests
Jim Fehlig [Mon, 14 Dec 2015 21:48:58 +0000 (14:48 -0700)]
Xen: tests: remove old sexpr2xml tests

Remove s-expression to XML conversion tests for old xend 3.0.2
config format.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: remove net-ioemu xm config test
Jim Fehlig [Mon, 14 Dec 2015 21:24:56 +0000 (14:24 -0700)]
Xen: tests: remove net-ioemu xm config test

Remove the fullvirt-net-ioemu test since explicitly specifying
'type=ioemu' has not been needed in xm/xend for a long time. It is
not used at all in xl/libxl.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoXen: tests: remove old xm config tests
Jim Fehlig [Mon, 14 Dec 2015 21:22:14 +0000 (14:22 -0700)]
Xen: tests: remove old xm config tests

Remove xm config tests for old xend 3.0.2 config format.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agovirsh: Add build flags to pool-create[-as] and pool-start
John Ferlan [Wed, 25 Nov 2015 14:51:51 +0000 (09:51 -0500)]
virsh: Add build flags to pool-create[-as] and pool-start

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

Utilize recently added VIR_STORAGE_POOL_CREATE_WITH_BUILD* flags in
order to pass the flags along to the virStoragePoolCreateXML and
virStoragePoolCreate API's.

This affects the 'virsh pool-create', 'virsh pool-create-as', and
'virsh pool-start' commands.  While it could be argued that pool-start
doesn't need the flags, they could prove useful for someone trying to
do one command build --overwrite and start command processing or
essentially starting with a clean slate.

NB:
This patch is loosely based upon code originally authored by Osier
Yang that were not reviewed and pushed, see:

https://www.redhat.com/archives/libvir-list/2012-July/msg00497.html

9 years agovirsh: Create a macro for pool-define-as and pool-create-as options
John Ferlan [Wed, 25 Nov 2015 13:57:30 +0000 (08:57 -0500)]
virsh: Create a macro for pool-define-as and pool-create-as options

Although they both are the same now, a future patch will add new options
to pool-create-as. So create a common macro to capture commonality, then
use that in the command specific structure.

9 years agovirsh: Create macro for "overwrite" and no-overwrite" options
John Ferlan [Wed, 25 Nov 2015 14:35:41 +0000 (09:35 -0500)]
virsh: Create macro for "overwrite" and no-overwrite" options

Although not currently used in more than one command, it soon will be
so create a common macro to be used in the new command location.

Additionally, add the ".flags = 0," for both to match the expections
of the structure being predefined.

9 years agovirsh: Create macro for "file" option
John Ferlan [Wed, 25 Nov 2015 14:08:54 +0000 (09:08 -0500)]
virsh: Create macro for "file" option

Rather than continually cut/paste the "file" option for pool command
option structures, generate a macro which will commonly define it for
any command.  Then of course use that macro.

9 years agovirsh: Create macro for "pool" option
John Ferlan [Wed, 25 Nov 2015 14:06:33 +0000 (09:06 -0500)]
virsh: Create macro for "pool" option

Rather than continually cut/paste the "pool" option for pool command
option structures, generate a macro which will commonly define it for
any command.  Then of course use that macro.

9 years agostorage: Add flags to allow building pool during create processing
John Ferlan [Wed, 25 Nov 2015 15:01:45 +0000 (10:01 -0500)]
storage: Add flags to allow building pool during create processing

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

Add flags handling to the virStoragePoolCreate and virStoragePoolCreateXML
API's which will allow the caller to provide the capability for the storage
pool create API's to also perform a pool build during creation rather than
requiring the additional buildPool step. This will allow transient pools
to be defined, built, and started.

The new flags are:

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD
      Perform buildPool without any flags passed.

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE
      Perform buildPool using VIR_STORAGE_POOL_BUILD_OVERWRITE flag.

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE
      Perform buildPool using VIR_STORAGE_POOL_BUILD_NO_OVERWRITE flag.

It is up to the backend to handle the processing of build flags. The
overwrite and no-overwrite flags are mutually exclusive.

NB:
This patch is loosely based upon code originally authored by Osier
Yang that were not reviewed and pushed, see:

https://www.redhat.com/archives/libvir-list/2012-July/msg01328.html

9 years agomark virDomainVirtioSerialAddrSetAddController as static.
Ján Tomko [Wed, 12 Aug 2015 14:52:12 +0000 (16:52 +0200)]
mark virDomainVirtioSerialAddrSetAddController as static.

This function is no longer used outside domain_addr.c

9 years agoRemove dead code from qemuDomainAttachControllerDevice
Ján Tomko [Wed, 12 Aug 2015 14:52:11 +0000 (16:52 +0200)]
Remove dead code from qemuDomainAttachControllerDevice

We only support hotplugging SCSI controllers.
The USB and virtio-serial related code was never reachable because
this function was only called for VIR_DOMAIN_CONTROLLER_TYPE_SCSI
controllers.

This reverts commit ee0d97a and parts of commits 16db8d2
and d6d54cd1.

9 years agoqemu_hotplug: remove qemuDomainAttachDeviceControllerLive
Ján Tomko [Wed, 9 Dec 2015 16:27:12 +0000 (17:27 +0100)]
qemu_hotplug: remove qemuDomainAttachDeviceControllerLive

This function calls qemuDomainAttachControllerDevice for SCSI
controllers and reports an error for all other controllers.

Move the error inside qemuDomainAttachControllerDevice and delete this
wrapper.

9 years agoAllow building lxc without virt-login-shell
Cédric Bosdonnat [Mon, 9 Nov 2015 22:36:40 +0000 (15:36 -0700)]
Allow building lxc without virt-login-shell

Add a configure option to disable virt-login-shell build even if lxc is
enabled.

9 years agostorage: Fix startup issue for logical pool
John Ferlan [Wed, 16 Dec 2015 16:54:04 +0000 (11:54 -0500)]
storage: Fix startup issue for logical pool

Commit id '71b803ac' assumed that the storage pool source device path
was required for a 'logical' pool. This resulted in a failure to start
a pool without any device path defined.

So, adjust the virStorageBackendLogicalMatchPoolSource logic to
return success if at least the pool name matches the vgs output
when no pool source device path is/are provided.

9 years agoqemu: Fix event generated for qemuDomainRevertToSnapshot (pause->run)
John Ferlan [Tue, 15 Dec 2015 18:39:44 +0000 (13:39 -0500)]
qemu: Fix event generated for qemuDomainRevertToSnapshot (pause->run)

A closer review of the code shows that for the transition from paused to
running which was supposed to emit the VIR_DOMAIN_EVENT_RESUMED - no event
would be generated. Rather the event is generated when going from running
to running.

Following the 'was_running' boolean shows it is set when the domain obj
is active and the domain obj state is VIR_DOMAIN_RUNNING. So rather than
using was_running to generate the RESUMED event, use !was_running

9 years agostorage: Attempt to refresh volume after successful wipe volume
John Ferlan [Thu, 17 Dec 2015 12:30:03 +0000 (07:30 -0500)]
storage: Attempt to refresh volume after successful wipe volume

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

When a volume wipe is successful, perform a volume refresh afterwards to
update any volume data that may be used in future volume commands, such as
volume resize.  For a raw file volume, a wipe could truncate the file and
a followup volume resize the capacity may fail because the volume target
allocation isn't updated to reflect the wipe activity.

9 years agovirStorageBackendWipeLocal: remove bytes_wiped argument
Ján Tomko [Fri, 11 Dec 2015 16:33:47 +0000 (17:33 +0100)]
virStorageBackendWipeLocal: remove bytes_wiped argument

It is not used by the caller.

9 years agostorage: drop 'Extent' from virStorageBackendWipeExtentLocal
Ján Tomko [Fri, 11 Dec 2015 16:14:01 +0000 (17:14 +0100)]
storage: drop 'Extent' from virStorageBackendWipeExtentLocal

The only caller always passes 0 for the extent start.
Drop the 'extent_start' parameter, as well as the mention of extents
from the function name.

Change off_t extent_length to unsigned long long wipe_len, as well as the
'remain' variable.

9 years agostorage: move buffer allocation inside virStorageBackendWipeExtentLocal
Ján Tomko [Fri, 11 Dec 2015 15:49:01 +0000 (16:49 +0100)]
storage: move buffer allocation inside virStorageBackendWipeExtentLocal

We do not need to pass a zero-filled buffer as an argument,
the function can allocate its own.

9 years agostorage: fix return values of virStorageBackendWipeExtentLocal
Ján Tomko [Fri, 11 Dec 2015 15:37:34 +0000 (16:37 +0100)]
storage: fix return values of virStorageBackendWipeExtentLocal

Return -1:
* on all failures of fdatasync. Instead of propagating -errno
  all the way up to the virStorageVolWipe API, which is documented
  to return 0 or -1.
* after a partial wipe. If safewrite failed, we would re-use the
  non-negative return value of lseek (which should be 0 in this case,
  because that's the only offset we seek to).

9 years agoqemu: Replace Mlock with MemLock in function names
Andrea Bolognani [Tue, 24 Nov 2015 12:51:11 +0000 (13:51 +0100)]
qemu: Replace Mlock with MemLock in function names

MemLock is already used in other modules and, while still an
abbreviation, is not ambiguous.

9 years agoqemu: Allow qemuDomainAdjustMaxMemLock() to restore previous value
Andrea Bolognani [Thu, 10 Dec 2015 18:13:58 +0000 (19:13 +0100)]
qemu: Allow qemuDomainAdjustMaxMemLock() to restore previous value

When the function changes the memory lock limit for the first time,
it will retrieve the current value and store it inside the
virDomainObj for the domain.

When the function is called again, if memory locking is no longer
needed, it will be able to restore the memory locking limit to its
original value.

9 years agoqemu: Reduce memlock limit after detaching PCI hostdev
Andrea Bolognani [Wed, 18 Nov 2015 12:56:09 +0000 (13:56 +0100)]
qemu: Reduce memlock limit after detaching PCI hostdev

We increase the limit before plugging in a PCI hostdev or a memory
module because some memory might need to be locked due to eg. VFIO.

Of course we should do the opposite after unplugging a device: this
was already the case for memory modules, but not for PCI hostdevs.

9 years agoqemu: Use qemuDomainAdjustMaxMemLock()
Andrea Bolognani [Mon, 23 Nov 2015 16:57:40 +0000 (17:57 +0100)]
qemu: Use qemuDomainAdjustMaxMemLock()

Replace all uses of the qemuDomainRequiresMlock/virProcessSetMaxMemLock
combination with the equivalent qemuDomainAdjustMaxMemLock() call.

9 years agoqemu: Add qemuDomainAdjustMaxMemLock()
Andrea Bolognani [Thu, 10 Dec 2015 17:39:14 +0000 (18:39 +0100)]
qemu: Add qemuDomainAdjustMaxMemLock()

This function detects whether a domain needs RLIMIT_MEMLOCK
to be set, and if so, uses an appropriate value.

9 years agoprocess: Add virProcessGetMaxMemLock()
Andrea Bolognani [Fri, 20 Nov 2015 16:06:41 +0000 (17:06 +0100)]
process: Add virProcessGetMaxMemLock()

This function can be used to retrieve the current locked memory
limit for a process, so that the setting can be later restored.

Add a configure check for getrlimit(), which we now use.

9 years agoprocess: Allow virProcessPrLimit() to get current limit
Andrea Bolognani [Fri, 20 Nov 2015 16:21:11 +0000 (17:21 +0100)]
process: Allow virProcessPrLimit() to get current limit

The prlimit() function allows both getting and setting limits for
a process; expose the same functionality in our wrapper.

Add the const modifier for new_limit, in accordance with the
prototype for prlimit().

9 years agobuild: disable vbox on cygwin
Eric Blake [Tue, 13 Oct 2015 20:47:42 +0000 (14:47 -0600)]
build: disable vbox on cygwin

Cygwin cannot build the vbox driver yet:

  CC       vbox/libvirt_driver_vbox_impl_la-vbox_glue.lo
In file included from vbox/vbox_glue.c:27:0:
vblox/vbox_XPCOMCGlue.c:63:3: error: #error "Port me"
 # error "Port me"
   ^
In file included from vbox/vbox_XPCOMCGlue.c:45:0,
                 from vbox/vbox_glue.c:27:
vbox/vbox_XPCOMCGlue.c: In function 'tryLoadOne':
vbox/vbox_XPCOMCGlue.c:98:46: error: 'DYNLIB_NAME' undeclared (first use in this function)
         if (virAsprintf(&name, "%s/%s", dir, DYNLIB_NAME) < 0)
                                      ^
./util/virstring.h:245:31: note: in definition of macro 'virAsprintf'
                         strp, __VA_ARGS__)
       ^

Rather than trying to figure out how to get dynamic loading of
vbox to work under cygwin (since I don't even have a working vbox
setup to test whether it works), I'm going to be lazy and just
default to not even trying vbox on cygwin.

9 years agoqemu: Search all nodes for shared memory access
Martin Kletzander [Wed, 16 Dec 2015 12:00:33 +0000 (13:00 +0100)]
qemu: Search all nodes for shared memory access

In commit 686eb7a24f7d, the break was not considered part of the
condition, hence breaking after first node when searching.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agopci: Use virPCIDeviceAddress in virPCIDevice
Andrea Bolognani [Tue, 15 Dec 2015 08:44:35 +0000 (09:44 +0100)]
pci: Use virPCIDeviceAddress in virPCIDevice

Instead of replicating the information (domain, bus, slot, function)
inside the virPCIDevice structure, use the already-existing
virPCIDeviceAddress structure.

For users of the module, this means that the object returned by
virPCIDeviceGetAddress() can no longer be NULL and must no longer
be freed by the caller.

9 years agolibxl: Use libxentoollog in preference to libxenctrl if available.
Ian Campbell [Thu, 10 Dec 2015 11:38:36 +0000 (11:38 +0000)]
libxl: Use libxentoollog in preference to libxenctrl if available.

Upstream Xen is in the process of splitting the (stable API) xtl_*
interfaces out from the (unstable API) libxenctrl library and into a
new (stable API) libxentoollog.

In order to be compatible with Xen both before and after this
transition check for xtl_createlogger_stdiostream in a libxentoollog
library and use it if present. If it is not present assume it is in
libxenctrl.

Compile tested on Xen 4.6 and a development tree with the split in
place.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
9 years agolibxl: implement virDomainGetJobStats
Joao Martins [Fri, 13 Nov 2015 13:14:48 +0000 (13:14 +0000)]
libxl: implement virDomainGetJobStats

Introduces support for domainGetJobStats which has the same
info as domainGetJobInfo but in a slightly different format.
Another difference is that virDomainGetJobStats can also
retrieve info on the most recently completed job. Though so
far this is only used in the source node to know if the
migration has been completed. But because we don't support
completed jobs we will deliver an error.

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

Introduce support for domainGetJobInfo to get info about the
ongoing job. If the job is active it will update the
timeElapsed which is computed with the "started" field added to
struct libxlDomainJobObj.  For now we support just the very basic
info and all jobs have VIR_DOMAIN_JOB_UNBOUNDED (i.e. no completion
time estimation) plus timeElapsed computed.

Openstack Kilo uses the Job API to monitor live-migration
progress which is currently nonexistent in libxl driver and
therefore leads to a crash in the nova compute node. Right
now, migration doesn't use jobs in the source node and will
return VIR_DOMAIN_JOB_NONE. Though nova handles this case and
will migrate it properly instead of crashing.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agostorage: Add helper to compare logical pool def against pvs output
John Ferlan [Mon, 7 Dec 2015 20:06:17 +0000 (15:06 -0500)]
storage: Add helper to compare logical pool def against pvs output

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

Add a new helper virStorageBackendLogicalMatchPoolSource to compare the
pool's source name against the output from a 'pvs' command to list all
volume group physical volume data on the host.  In addition, compare the
pool's source device list against the particular volume group's device
list to ensure the source device(s) listed for the pool match what the
was listed for the volume group.

Then for pool startup or check API's we need to call this new API in
order to ensure that the pool we're about to start or declare active
during checkPool has a valid definition vs. the running host.

9 years agostorage: Create helper for virStorageBackendLogicalFindPoolSources
John Ferlan [Mon, 7 Dec 2015 16:27:03 +0000 (11:27 -0500)]
storage: Create helper for virStorageBackendLogicalFindPoolSources

Rework virStorageBackendLogicalFindPoolSources a bit to create a
helper virStorageBackendLogicalGetPoolSources that will make the
pvs call in order to generate a list of associated pv_name and vg_name's.

A future patch will make use of this for start/check processing to
ensure the storage pool source definition matches expectations.

9 years agostorage: Check FS pool source during virStorageBackendFileSystemIsMounted
John Ferlan [Mon, 7 Dec 2015 13:35:57 +0000 (08:35 -0500)]
storage: Check FS pool source during virStorageBackendFileSystemIsMounted

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

When determining whether a FS pool is mounted, rather than assuming that
the FS pool is mounted just because the target.path is in the mount list,
let's make sure that the FS pool source matches what is mounted

9 years agostorage: Refactor virStorageBackendFileSystemGetPoolSource
John Ferlan [Mon, 7 Dec 2015 13:26:42 +0000 (08:26 -0500)]
storage: Refactor virStorageBackendFileSystemGetPoolSource

Refactor code to use standard return functioning with respect to setting
a ret value and going to cleanup.

9 years agostorage: Create helper to generate FS pool source value
John Ferlan [Mon, 7 Dec 2015 13:19:34 +0000 (08:19 -0500)]
storage: Create helper to generate FS pool source value

Refactor the code that builds the pool source string during the FS
storage pool mount to be a separate helper.

A future patch will use the helper in order to validate the mounted
FS matches the pool's expectation during poolCheck processing

9 years agoqemu: add bootindex option to hostdev network interface commandline
Laine Stump [Mon, 30 Nov 2015 22:40:44 +0000 (17:40 -0500)]
qemu: add bootindex option to hostdev network interface commandline

when appropriate, of course. If the config for a domain specifies boot
order with <boot dev='blah'/> elements, e.g.:

     <os>
       ...
       <boot dev='hd'/>
       <boot dev='network'/>
     </os>

Then the first disk device in the config will have ",bootindex=1"
appended to its qemu commandline -device options, and the first (and
*only* the first) network interface device will get ",bootindex=2".

However, if the first network interface device is a "hostdev" device
(an SRIOV Virtual Function (VF) being assigned to the domain with
vfio), then the bootindex option will *not* be appended. This happens
because the bootindex=n option corresponding to the order of "<boot
dev='network'/>" is added to the -device for the first network device
when network device commandline args are constructed, but if it's a
hostdev network device, its commandline arg is instead constructed in
the loop for hostdevs.

This patch fixes that omission by noticing (in bootHostdevNet) if the
first network device was a hostdev, and if so passing on the proper
bootindex to the commandline generator for hostdev devices - the
result is that ",bootindex=2" will be properly appended to the first
"network" device in the config even if it is really a hostdev
(including if it is assigned from a libvirt network pool). (note that
this is only the case if there is no <bootmenu enabled='yes'/> element
in the config ("-boot menu-on" in qemu) , since the two are mutually
exclusive - when the bootmenu is enabled, the individual per-device
bootindex options can't be used by qemu, and we revert to using "-boot
order=xyz" instead).

If a greater level of control over boot order is desired (e.g., more
than one network device should be tried, or a network device other
than the first one encountered in the config), then <boot
dev='network'/> in the <os> element should not be used; instead, the
individual device elements in the config should be given a "<boot
order='n'/>

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

9 years agosecurity_stack: remove extra Security from function names
Ján Tomko [Wed, 9 Dec 2015 13:35:11 +0000 (14:35 +0100)]
security_stack: remove extra Security from function names

Many of the functions follow the pattern:
virSecurity.*Security.*Label

Remove the second 'Security' from the names, it should be
obvious that the virSecurity* functions deal with security
labels even without it.

9 years agosecurity_selinux: remove extra Security from function names
Ján Tomko [Wed, 9 Dec 2015 13:34:34 +0000 (14:34 +0100)]
security_selinux: remove extra Security from function names

Many of the functions follow the pattern:
virSecurity.*Security.*Label

Remove the second 'Security' from the names, it should be obvious
that the virSecurity* functions deal with security labels even
without it.

9 years agosecurity_dac: remove extra Security from function names
Ján Tomko [Wed, 9 Dec 2015 13:33:55 +0000 (14:33 +0100)]
security_dac: remove extra Security from function names

Many of the functions follow the pattern:
virSecurity.*Security.*Label

Remove the second 'Security' from the names, it should be obvious
that the virSecurity* functions deal with security labels even
without it.

9 years agoqemuMonitorJSONEjectMedia: don't stringify the replay at all
Pavel Hrdina [Tue, 15 Dec 2015 10:04:49 +0000 (11:04 +0100)]
qemuMonitorJSONEjectMedia: don't stringify the replay at all

Commit 256496e1 introduced a detection if "is locked" in error replay
from qemu monitor. Commit c4073657 fixed a memory leak, but it was
pointed out by Peter, that this could be done cleaner without
stringifing the replay.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agopci: Use 'addr' instead of 'dev' for virPCIDeviceAddressPtr
Andrea Bolognani [Tue, 15 Dec 2015 08:53:31 +0000 (09:53 +0100)]
pci: Use 'addr' instead of 'dev' for virPCIDeviceAddressPtr

The name 'dev' is more appropriate for virPCIDevicePtr.

9 years agoqemuMonitorJSONEjectMedia: Don't leak stringified reply
Michal Privoznik [Tue, 15 Dec 2015 08:58:30 +0000 (09:58 +0100)]
qemuMonitorJSONEjectMedia: Don't leak stringified reply

The return value of virJSONValueToString() should be freed when
no longer needed. This is not the case after 256496e1.

==26902== 138 bytes in 2 blocks are definitely lost in loss record 1,051 of 1,239
==26902==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26902==    by 0xAA5F599: strdup (in /lib64/libc-2.21.so)
==26902==    by 0x552BAD9: virStrdup (virstring.c:726)
==26902==    by 0x54F60A7: virJSONValueToString (virjson.c:1790)
==26902==    by 0x1DF6EBB9: qemuMonitorJSONEjectMedia (qemu_monitor_json.c:2225)
==26902==    by 0x1DF57A4C: qemuMonitorEjectMedia (qemu_monitor.c:1985)
==26902==    by 0x1DF1EF2D: qemuDomainChangeEjectableMedia (qemu_hotplug.c:199)
==26902==    by 0x1DF90314: qemuDomainChangeDiskLive (qemu_driver.c:7985)
==26902==    by 0x1DF90476: qemuDomainUpdateDeviceLive (qemu_driver.c:8030)
==26902==    by 0x1DF91ED7: qemuDomainUpdateDeviceFlags (qemu_driver.c:8677)
==26902==    by 0x561785F: virDomainUpdateDeviceFlags (libvirt-domain.c:8559)
==26902==    by 0x134210: remoteDispatchDomainUpdateDeviceFlags (remote_dispatch.h:10966)

==26902== 106 bytes in 1 blocks are definitely lost in loss record 1,033 of 1,239
==26902==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26902==    by 0xAA5F599: strdup (in /lib64/libc-2.21.so)
==26902==    by 0x552BAD9: virStrdup (virstring.c:726)
==26902==    by 0x54F60A7: virJSONValueToString (virjson.c:1790)
==26902==    by 0x1DF6EC0C: qemuMonitorJSONEjectMedia (qemu_monitor_json.c:2227)
==26902==    by 0x1DF57A4C: qemuMonitorEjectMedia (qemu_monitor.c:1985)
==26902==    by 0x1DF1EF2D: qemuDomainChangeEjectableMedia (qemu_hotplug.c:199)
==26902==    by 0x1DF90314: qemuDomainChangeDiskLive (qemu_driver.c:7985)
==26902==    by 0x1DF90476: qemuDomainUpdateDeviceLive (qemu_driver.c:8030)
==26902==    by 0x1DF91ED7: qemuDomainUpdateDeviceFlags (qemu_driver.c:8677)
==26902==    by 0x561785F: virDomainUpdateDeviceFlags (libvirt-domain.c:8559)
==26902==    by 0x134210: remoteDispatchDomainUpdateDeviceFlags (remote_dispatch.h:10966)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu cgroups: move new threads to new cgroup after cpuset is set up
Henning Schild [Mon, 14 Dec 2015 20:58:05 +0000 (15:58 -0500)]
qemu cgroups: move new threads to new cgroup after cpuset is set up

Moving tasks to cgroups implied sched_setaffinity. Changing the cpus in
a set implies the same for all tasks in the group.
The old code put the the thread into the cpuset inherited from the
machine cgroup, which allowed it to run outside of vcpupin for a short
while.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
9 years agoqemu: do not put a task into machine cgroup
Henning Schild [Mon, 14 Dec 2015 20:48:05 +0000 (15:48 -0500)]
qemu: do not put a task into machine cgroup

The machine cgroup is a superset, a parent to the emulator and vcpuX
cgroups. The parent cgroup should never have any tasks directly in it.
In fact the parent cpuset might contain way more cpus than the sum of
emulatorpin and vcpupins. So putting tasks in the superset will allow
them to run outside of <cputune>.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
9 years agoutil: cgroups do not implicitly add task to new machine cgroup
Henning Schild [Wed, 9 Dec 2015 16:58:10 +0000 (17:58 +0100)]
util: cgroups do not implicitly add task to new machine cgroup

virCgroupNewMachine used to add the pidleader to the newly created
machine cgroup. Do not do this implicit anymore.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
9 years agovirNetDevMacVLanTapSetup: Drop @multiqueue argument
Michal Privoznik [Sun, 13 Dec 2015 06:54:46 +0000 (07:54 +0100)]
virNetDevMacVLanTapSetup: Drop @multiqueue argument

Firstly, there's a bug (or typo) in the only place where we call
this function: @multiqueue is set whenever @tapfdSize is greater
than zero, while in fact the condition should have been 'greater
than one'.
Then, secondly, since the condition depends on just one
variable, that we are even passing down to the function, we can
move the condition into the function and drop useless argument.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Warn when using vhost-user without shared memory
Martin Kletzander [Tue, 8 Dec 2015 13:15:47 +0000 (14:15 +0100)]
qemu: Warn when using vhost-user without shared memory

When user configures vhost-user interface and forgets to also configure
any shared memory, the search for the root cause of non-operational
interface might take unpleasantly long time.  Let's enhance user
experience by emitting a warning in the logs.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirNetDevMacVLanTapSetup: Work around older systems
Michal Privoznik [Sat, 12 Dec 2015 07:05:17 +0000 (08:05 +0100)]
virNetDevMacVLanTapSetup: Work around older systems

Some older systems, e.g. RHEL-6 do not have IFF_MULTI_QUEUE flag
which we use to enable multiqueue feature. Therefore one gets the
following compile error there:

  CC     util/libvirt_util_la-virnetdevmacvlan.lo
util/virnetdevmacvlan.c: In function 'virNetDevMacVLanTapSetup':
util/virnetdevmacvlan.c:338: error: 'IFF_MULTI_QUEUE' undeclared (first use in this function)
util/virnetdevmacvlan.c:338: error: (Each undeclared identifier is reported only once
util/virnetdevmacvlan.c:338: error: for each function it appears in.)
make[3]: *** [util/libvirt_util_la-virnetdevmacvlan.lo] Error 1

So, whenever user wants us to enable the feature on such systems,
we will just throw a runtime error instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoCVE-2015-5313: storage: don't allow '/' in filesystem volume names
Eric Blake [Wed, 9 Dec 2015 00:46:31 +0000 (17:46 -0700)]
CVE-2015-5313: storage: don't allow '/' in filesystem volume names

The libvirt file system storage driver determines what file to
act on by concatenating the pool location with the volume name.
If a user is able to pick names like "../../../etc/passwd", then
they can escape the bounds of the pool.  For that matter,
virStoragePoolListVolumes() doesn't descend into subdirectories,
so a user really shouldn't use a name with a slash.

Normally, only privileged users can coerce libvirt into creating
or opening existing files using the virStorageVol APIs; and such
users already have full privilege to create any domain XML (so it
is not an escalation of privilege).  But in the case of
fine-grained ACLs, it is feasible that a user can be granted
storage_vol:create but not domain:write, and it violates
assumptions if such a user can abuse libvirt to access files
outside of the storage pool.

Therefore, prevent all use of volume names that contain "/",
whether or not such a name is actually attempting to escape the
pool.

This changes things from:

$ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
Vol ../../../../../../etc/haha created
$ rm /etc/haha

to:

$ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
error: Failed to create vol ../../../../../../etc/haha
error: Requested operation is not valid: volume name '../../../../../../etc/haha' cannot contain '/'

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agoutil: Fixup virnetdevmacvlan.h ATTRIBUTE_NONNULL's
John Ferlan [Fri, 11 Dec 2015 11:37:48 +0000 (06:37 -0500)]
util: Fixup virnetdevmacvlan.h ATTRIBUTE_NONNULL's

Commit id '56e2171c6' removed a variable from the argument list, but
neglected to update the ATTRIBUTE_NONNULL values, so when commit id
'08da97bfb' added a couple of arguments, the values were off.

9 years agotest: qemuxml2argv: Mock virMemoryMaxValue to remove 32/64 bit difference
Peter Krempa [Thu, 10 Dec 2015 13:36:51 +0000 (14:36 +0100)]
test: qemuxml2argv: Mock virMemoryMaxValue to remove 32/64 bit difference

Always return LLONG_MAX even on 32 bit systems. The limitation
originates from our use of "unsigned long" in several APIs. The internal
data type is unsigned long long. Make the test suite deterministic by
removing the architecture difference.

Flaw was introduced in 645881139b3d2c86acf9d644c3a1471520bc9e57 where
I've added a test that uses too large numbers.

9 years agoqemu: Enable multiqueue for macvtaps
Michal Privoznik [Fri, 4 Dec 2015 10:47:22 +0000 (11:47 +0100)]
qemu: Enable multiqueue for macvtaps

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

Ta-da! Now that we know how to open a macvtap device multiple
times, we can finally enable the multiqueue feature. Everything
else is already prepared (e.g. command line generation) from the
previous iteration where the feature was implemented for
TUN/TAP devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevMacVLanCreateWithVPortProfile: Rework to support multiple FDs
Michal Privoznik [Fri, 4 Dec 2015 10:31:17 +0000 (11:31 +0100)]
virNetDevMacVLanCreateWithVPortProfile: Rework to support multiple FDs

For the multiqueue on macvtaps we are going to need to open
the device multiple times. Currently, this is not supported.
Rework the function, so that upper layers can be reworked too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevMacVLanTapSetup: Allow enabling of IFF_MULTI_QUEUE
Michal Privoznik [Tue, 8 Dec 2015 12:17:26 +0000 (13:17 +0100)]
virNetDevMacVLanTapSetup: Allow enabling of IFF_MULTI_QUEUE

Like we are doing for TUN/TAP devices, we should do the same for
macvtaps. Although, it's not as critical as in that case, we
should do it for the consistency.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevMacVLanTapSetup: Rework to support multiple FDs
Michal Privoznik [Fri, 4 Dec 2015 10:19:32 +0000 (11:19 +0100)]
virNetDevMacVLanTapSetup: Rework to support multiple FDs

For the multiqueue on macvtaps we are going to need to open
the device multiple times. Currently, this is not supported.
Rework the function, so that upper layers can be reworked too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevMacVLanTapOpen: Rework to support multiple FDs
Michal Privoznik [Fri, 4 Dec 2015 08:39:02 +0000 (09:39 +0100)]
virNetDevMacVLanTapOpen: Rework to support multiple FDs

For the multiqueue on macvtaps we are going to need to open
the device multiple times. Currently, this is not supported.
Rework the function, so that upper layers can be reworked too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevMacVLanTapOpen: Slightly rework
Michal Privoznik [Fri, 4 Dec 2015 09:55:49 +0000 (10:55 +0100)]
virNetDevMacVLanTapOpen: Slightly rework

There are few outdated things. Firstly, we don't need to undergo
the torture of fopen, fscanf and fclose just to get the interface
index when we have nice wrapper over that: virNetDevGetIndex.
Secondly, we don't need to have statically allocated buffer for
the path we are opening.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetDevMacVLanCreateWithVPortProfile: Turn vnet_hdr into flag
Michal Privoznik [Thu, 3 Dec 2015 10:33:55 +0000 (11:33 +0100)]
virNetDevMacVLanCreateWithVPortProfile: Turn vnet_hdr into flag

So yet again one of integer arguments that we use as a boolean.
Since the argument count of the function is unbearably long
enough, lets turn those booleans into flags.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolog: include hostname in initial log message
Daniel P. Berrange [Fri, 4 Dec 2015 17:35:54 +0000 (17:35 +0000)]
log: include hostname in initial log message

On the very first log message we send to any output, we include
the libvirt version number and package string. In some bug reports
we have been given libvirtd.log files that came from a different
host than the corresponding /var/log/libvirt/qemu log files. So
extend the initial log message to include the hostname too.

eg on first log message we would now see:

 $ libvirtd
 2015-12-04 17:35:36.610+0000: 20917: info : libvirt version: 1.3.0
 2015-12-04 17:35:36.610+0000: 20917: info : hostname: dhcp-1-180.lcy.redhat.com
 2015-12-04 17:35:36.610+0000: 20917: error : qemuMonitorIO:687 : internal error: End of file from monitor

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agostorage: Ignore block devices that fail format detection
John Ferlan [Fri, 30 Oct 2015 14:29:46 +0000 (10:29 -0400)]
storage: Ignore block devices that fail format detection

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

Prior to commit id '98322052' failure to saferead the block device would
cause an error to be logged and the device to be skipped while attempting
to discover/create a stable target path for a new LUN (NPIV).

This was because virStorageBackendSCSIFindLUs ignored errors from
processLU and virStorageBackendSCSINewLun.

Ignoring the failure allowed a multipath device with an "active" and
"ghost" to be present on the host with the "ghost" block device being
ignored. This patch will return a -2 to the caller indicating the desire
to ignore the block device since it cannot be used directly rather than
fail the pool startup.

9 years agostorage: Add debug message
John Ferlan [Tue, 24 Nov 2015 14:23:46 +0000 (09:23 -0500)]
storage: Add debug message

I found this useful while processing a volume that wouldn't end up
showing up in the resulting list of block volumes. In this case, the
partition type wasn't found in the disk_types table.

9 years agostorage: Handle readflags errors
John Ferlan [Tue, 24 Nov 2015 16:15:53 +0000 (11:15 -0500)]
storage: Handle readflags errors

Similar to the openflags VIR_STORAGE_VOL_OPEN_NOERROR processing, if some
read processing operation fails, check the readflags for the corresponding
error flag being set. If so, rather then causing an error - use VIR_WARN
to flag the error, but return -2 which some callers can use to perform
specific actions. Use a new VIR_STORAGE_VOL_READ_NOERROR flag in a new
VolReadErrorMode enum.

9 years agostorage: Set ret = -1 on failures in virStorageBackendUpdateVolTargetInfo
John Ferlan [Fri, 4 Dec 2015 15:40:06 +0000 (10:40 -0500)]
storage: Set ret = -1 on failures in virStorageBackendUpdateVolTargetInfo

While processing the volume for lseek, virFileReadHeaderFD, and
virStorageFileGetMetadataFromBuf - failure would cause an error,
but ret would not be set. That would result in an error message being
sent, but successful status being returned.

9 years agostorage: Add comments for backend APIs
John Ferlan [Tue, 24 Nov 2015 15:41:07 +0000 (10:41 -0500)]
storage: Add comments for backend APIs

Just so it's clearer what to expect upon input and what types of return
values could be generated.  These were loosely copied from existing
virStorageBackendUpdateVolTargetInfoFD.

9 years agostorage: Add readflags for backend error processing
John Ferlan [Tue, 24 Nov 2015 15:08:29 +0000 (10:08 -0500)]
storage: Add readflags for backend error processing

Similar to the openflags which allow VIR_STORAGE_VOL_OPEN_NOERROR to be
passed to avoid open errors, add a 'readflags' variable so that in the
future read failures could also be ignored.

9 years agotests: scsihost: Use fakerootdir instead of fakesysfsdir
Andrea Bolognani [Fri, 4 Dec 2015 13:12:33 +0000 (14:12 +0100)]
tests: scsihost: Use fakerootdir instead of fakesysfsdir

This updates the test program to make it consistent with recent changes
to the mock libraries, and also opens up the possibility of mocking more
than just /sys in the future.

9 years agotests: Use more specific names for variables
Andrea Bolognani [Fri, 4 Dec 2015 13:51:08 +0000 (14:51 +0100)]
tests: Use more specific names for variables

Instead of fakesysfsdir, which is very generic, use fakesysfspcidir and
fakesysfscgroupdir. This makes it explicit what part of the fake sysfs
filesystem they're referring to, and also leaves open the possibility of
handling files in two unrelated parts of the fake sysfs filesystem.

No functional changes.

9 years agotests: Rename LIBVIRT_FAKE_SYSFS_DIR to LIBVIRT_FAKE_ROOT_DIR
Andrea Bolognani [Fri, 4 Dec 2015 12:38:16 +0000 (13:38 +0100)]
tests: Rename LIBVIRT_FAKE_SYSFS_DIR to LIBVIRT_FAKE_ROOT_DIR

The old name is no longer accurate, since now we're using its value as
the root of the fake filesystem.

No functional changes.

9 years agotests: cgroupmock: Use the temporary directory as fake root
Andrea Bolognani [Fri, 4 Dec 2015 09:54:29 +0000 (10:54 +0100)]
tests: cgroupmock: Use the temporary directory as fake root

We might need to mock files living outside SYSFS_PREFIX later on,
so it's better to treat the temporary directory we are passed via
the environment as the root of the fake filesystem and create
SYSFS_PREFIX inside it.

The environment variable name will be changed to reflect the new use
we're making of it in a later commit.

9 years agotests: pcimock: Use the temporary directory as fake root
Andrea Bolognani [Fri, 4 Dec 2015 09:05:56 +0000 (10:05 +0100)]
tests: pcimock: Use the temporary directory as fake root

We might need to mock files living outside PCI_SYSFS_PREFIX later on,
so it's better to treat the temporary directory we are passed via
the environment as the root of the fake filesystem and create
PCI_SYSFS_PREFIX inside it.

The environment variable name will be changed to reflect the new use
we're making of it in a later commit.

9 years agotests: pcimock: Remove check for fakesysfsdir
Andrea Bolognani [Thu, 3 Dec 2015 14:27:28 +0000 (15:27 +0100)]
tests: pcimock: Remove check for fakesysfsdir

init_env() will return right away if fakesysfsdir is already
initialized, so this check is redundant.

9 years agotests: scsihost: Don't set LIBVIRT_FAKE_SYSFS_DIR
Andrea Bolognani [Fri, 4 Dec 2015 12:45:17 +0000 (13:45 +0100)]
tests: scsihost: Don't set LIBVIRT_FAKE_SYSFS_DIR

The test program is not preloading any of the mock libraries that read
that environment variable, so setting it is pointless.

9 years agoqemu: cgroup: Don't use priv->ncpupids to iterate domain vCPUs
Peter Krempa [Fri, 20 Nov 2015 15:10:04 +0000 (16:10 +0100)]
qemu: cgroup: Don't use priv->ncpupids to iterate domain vCPUs

Use the proper data structures for the iteration since ncpupids will be
made private later.

9 years agoqemu: driver: Refactor qemuDomainHelperGetVcpus
Peter Krempa [Fri, 20 Nov 2015 15:02:54 +0000 (16:02 +0100)]
qemu: driver: Refactor qemuDomainHelperGetVcpus

Change some of the control structures and switch to using the new vcpu
structure.

9 years agoqemu: Add helper to retrieve vCPU pid
Peter Krempa [Thu, 12 Nov 2015 15:45:12 +0000 (16:45 +0100)]
qemu: Add helper to retrieve vCPU pid

Instead of directly accessing the array add a helper to do this.

9 years agoqemu: Replace checking for vcpu<->pid mapping availability with a helper
Peter Krempa [Wed, 11 Nov 2015 13:20:04 +0000 (14:20 +0100)]
qemu: Replace checking for vcpu<->pid mapping availability with a helper

Add qemuDomainHasVCpuPids to do the checking and replace in place checks
with it.

We no longer need checking whether the thread contains fake data
(vcpupids[0] == vm->pid) as in b07f3d821dfb11a118ee75ea275fd6ab737d9500
and 65686e5a81d654d834d338fceeaf0229b2ca4f0d this was removed.

9 years agoqemu: Drop checking vcpu threads in emulator bandwidth getter/setter
Peter Krempa [Thu, 12 Nov 2015 14:14:38 +0000 (15:14 +0100)]
qemu: Drop checking vcpu threads in emulator bandwidth getter/setter

The vCPU threads make sense in the counterparts that set the vCPU
bandwidth/quota, not in the emulator one. The emulator tunables are set
all the time anyways.

Drop the extra check and remove the now unneeded vm argument.

9 years agoqemu: cgroup: Remove now unreachable check
Peter Krempa [Wed, 11 Nov 2015 09:28:47 +0000 (10:28 +0100)]
qemu: cgroup: Remove now unreachable check

Since commit 0c04906fa the check for priv->cgroup doesn't make sense as
the calls to virCgroupHasController return the same information. Remove
it and move it's comment partially to the new check.

The already spurious check was also later copied to the iothreads code.

9 years agoconf: Add helper to get pointer to a certain vCPU definition
Peter Krempa [Tue, 3 Nov 2015 07:47:23 +0000 (08:47 +0100)]
conf: Add helper to get pointer to a certain vCPU definition

Once more stuff will be moved into the vCPU data structure it will be
necessary to get a specific one in some ocasions. Add a helper that will
simplify this task.

9 years agoconf: ABI: Split up and improve vcpu info ABI checking
Peter Krempa [Wed, 5 Aug 2015 13:06:04 +0000 (15:06 +0200)]
conf: ABI: Split up and improve vcpu info ABI checking

Extract the checking code into a separate function and prepare the
infrastructure for checking the new structure type.

9 years agoconf: turn def->vcpus into a structure
Peter Krempa [Fri, 23 Oct 2015 07:38:01 +0000 (09:38 +0200)]
conf: turn def->vcpus into a structure

To allow collecting all relevant data at one place let's make def->vcpus
a structure and then we can start moving stuff into it.

9 years agoqemu: refactor qemuDomainHotunplugVcpus
Peter Krempa [Fri, 30 Oct 2015 15:29:45 +0000 (16:29 +0100)]
qemu: refactor qemuDomainHotunplugVcpus

Refactor the code flow so that 'exit_monitor:' can be removed.

This patch moves the auditing functions into places where it's certain
that hotunplug was or was not successful and reports errors from
qemuMonitorGetCPUInfo properly.

9 years agoqemu: Refactor qemuDomainHotplugVcpus
Peter Krempa [Fri, 30 Oct 2015 11:46:33 +0000 (12:46 +0100)]
qemu: Refactor qemuDomainHotplugVcpus

Refactor the code flow so that 'exit_monitor:' can be removed.

This patch also moves the auditing and setting of the new vCPU count
right to the place where the hotplug happens, since it's possible that
the hotplug succeeds and adds a cpu while other stuff fails.

Lastly, failures of qemuMonitorGetCPUInfo are now reported rather than
ignored. The function retuns 0 if it "successfully" detected 0 threads.