]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agostorage: No need to check ret after VIR_APPEND_ELEMENT
John Ferlan [Fri, 19 Feb 2016 19:03:16 +0000 (14:03 -0500)]
storage: No need to check ret after VIR_APPEND_ELEMENT

Generates a false positive for Coverity, but it turns out there's no need
to check ret == -1 since if VIR_APPEND_ELEMENT is successful, the local
vol pointer is cleared anyway.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agozfs: Resolve RESOURCE_LEAK
John Ferlan [Fri, 19 Feb 2016 18:54:45 +0000 (13:54 -0500)]
zfs: Resolve RESOURCE_LEAK

Found by my Coverity checker - virCheckFlags call could return -1, but
not virCommandFree(destroy_cmd).

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoopenvz: Use virStringSplitCount instead of strtok_r
John Ferlan [Fri, 19 Feb 2016 18:35:24 +0000 (13:35 -0500)]
openvz: Use virStringSplitCount instead of strtok_r

When parsing the barrier:limit values, use virStringSplitCount in order
to split the pair and make the approriate checks to get the data.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agohostdev: Remove temporary variable when checking for VF
Andrea Bolognani [Wed, 24 Feb 2016 17:06:52 +0000 (18:06 +0100)]
hostdev: Remove temporary variable when checking for VF

The virHostdevIsVirtualFunction() was called exactly twice, and in
both cases the return value was saved to a temporary variable before
being checked. This would be okay if it improved readability, but in
this case is pretty pointless.

Get rid of the temporary variable and check the return value
directly; while at it, change the check from '<= 0' to '!= 1' to
align it with the way other similar *IsVirtualFunction() functions
are used thorough the code.

9 years agonetdev: Use virNetDevIsVirtualFunction() properly
Andrea Bolognani [Thu, 25 Feb 2016 11:03:35 +0000 (12:03 +0100)]
netdev: Use virNetDevIsVirtualFunction() properly

virNetDevIsVirtualFunction() returns 1 if the interface is a
virtual function, 0 if it isn't and -1 on error. This means that,
despite the name suggesting otherwise, using it as a predicate is
not correct.

Fix two callers that were doing so adding an explicit check on
the return value.

9 years agoutil: Avoid calling closedir(NULL)
Jiri Denemark [Thu, 25 Feb 2016 11:50:12 +0000 (12:50 +0100)]
util: Avoid calling closedir(NULL)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovircgroupmock: Mock access("/sys/devices/system/cpu/present")
Michal Privoznik [Thu, 25 Feb 2016 07:44:46 +0000 (08:44 +0100)]
vircgroupmock: Mock access("/sys/devices/system/cpu/present")

There's been a report on the upstream list [1] describing we
access /sys/devices/system/cpu/present directly on the host from
within our test suite. This may end up in unpredictable results
as no all linux systems are required to have that file. Mock
access to the file.

libvirt.git/tests $ ../run strace vircgrouptest
...
access("/sys/devices/system/cpu/present", F_OK) = 0
...

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoFix bug of attaching redirdev device
Osier Yang [Mon, 22 Feb 2016 16:44:09 +0000 (00:44 +0800)]
Fix bug of attaching redirdev device

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

The corresponding chardev must be attached first, otherwise the
the qemu command line won't be complete (missing the host part),

9 years agobuild: accomodate selinux 2.5 header API change
Eric Blake [Wed, 24 Feb 2016 22:02:44 +0000 (15:02 -0700)]
build: accomodate selinux 2.5 header API change

Yet again, selinux has been adding const-correctness; this change
is ABI-compatible, but breaks API, which affects us when we try to
override things in our testsuite:

../../tests/securityselinuxhelper.c:307:24: error: conflicting types for 'selabel_open'
 struct selabel_handle *selabel_open(unsigned int backend,
                        ^~~~~~~~~~~~
In file included from ../../tests/securityselinuxhelper.c:32:0:
/usr/include/selinux/label.h:73:24: note: previous declaration of 'selabel_open' was here

The problem is a new 'const' prior to the second parameter.

Fix it the same way we did in commit 292d3f2d: check for the new
const at configure time.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agolibxl: implement virDomainInterfaceStats
Joao Martins [Wed, 24 Feb 2016 13:25:46 +0000 (13:25 +0000)]
libxl: implement virDomainInterfaceStats

Introduce support for domainInterfaceStats API call for querying
network interface statistics. Consequently it also enables the use of
`virsh domifstat <dom> <interface name>` command plus seeing the
interfaces names instead of "-" when doing `virsh domiflist <dom>`.

After successful guest creation we fill the network interfaces names
based on domain, device id and append suffix if it's emulated in the
following form: vif<domid>.<devid>[-emu].  We extract the network
interfaces info from the libxl_domain_config object in
libxlDomainCreateIfaceNames() to generate ifname. On domain cleanup we
also clear ifname, in case it was set by libvirt (i.e. being prefixed
with "vif"). We also skip these two steps in case the name of the
interface was manually inserted by the administrator. Since the
introduction of netprefix (commit a040ba9), ifnames with a registered
prefix will be freed on virDomain{Obj,Def}Format*, thus eliminating
the migration issues observed with the reverted commit d2e5538 whereas
source and destination would have the same ifname.

For getting the interface statistics we resort to virNetInterfaceStats
and let libvirt handle the platform specific nits. Note that the
latter is not yet supported in FreeBSD.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agolibxl: small fix in parsing network
Chunyan Liu [Tue, 23 Feb 2016 08:07:58 +0000 (16:07 +0800)]
libxl: small fix in parsing network

Signed-off-by: Chunyan Liu <cyliu@suse.com>
9 years agorbd: fix 32-bit build
Eric Blake [Tue, 23 Feb 2016 23:35:19 +0000 (16:35 -0700)]
rbd: fix 32-bit build

%zu is not always synonymous with uint64_t; on 32-bit machines,
size_t is only 32 bits.  Prefer "%lld"/'unsigned long long' when
the variable is under our control, and "%"PRIu64 when we are
stuck with 'uint64_t' from RBD.

Fixes errors such as:

../../src/storage/storage_backend_rbd.c: In function 'virStorageBackendRBDVolWipe':
../../src/storage/storage_backend_rbd.c:1281:15: error: format '%zu' expects argument of type 'size_t', but argument 8 has type 'uint64_t {aka long long unsigned int}' [-Werror=format=]
     VIR_DEBUG("Need to wipe %zu bytes from RBD image %s/%s",
               ^
../../src/util/virlog.h:90:73: note: in definition of macro 'VIR_DEBUG_INT'
     virLogMessage(src, VIR_LOG_DEBUG, filename, linenr, funcname, NULL, __VA_ARGS__)
                                                                         ^
../../src/storage/storage_backend_rbd.c:1281:5: note: in expansion of macro 'VIR_DEBUG'
     VIR_DEBUG("Need to wipe %zu bytes from RBD image %s/%s",
     ^

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agolibxl: fix bogus indentation from commit fb2bd208
Jim Fehlig [Tue, 23 Feb 2016 22:28:04 +0000 (15:28 -0700)]
libxl: fix bogus indentation from commit fb2bd208

9 years agoqemuBuildCommandLine: Change the condition for -nographics
Michal Privoznik [Tue, 23 Feb 2016 08:38:26 +0000 (09:38 +0100)]
qemuBuildCommandLine: Change the condition for -nographics

There's this check when building command line that whenever
domain has no graphics card configured we put -nographics onto
qemu command line. The check is 'if (!def->graphics)'. This
makes coverity think that def->graphics can be NULL, which is
true. But later in the code every access to def->graphics is
guarded by check for def->ngraphics, so no crash occurs. But this
is something that coverity fails to deduct.
In order to shut coverity up lets change the condition to
'if (!def->ngraphics)'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoxen: Check return value of virStringReplace
Michal Privoznik [Tue, 23 Feb 2016 08:34:49 +0000 (09:34 +0100)]
xen: Check return value of virStringReplace

After 6604a3dd9f8 in which new helper function has been
introduced, the code calls virStringReplace and dereference the
result immediately. The string function can, however, return NULL
so this would SIGSEGV right away. Check for the return value of
the string function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovbox: Avoid signed and unsigned comparison
Michal Privoznik [Tue, 23 Feb 2016 08:27:34 +0000 (09:27 +0100)]
vbox: Avoid signed and unsigned comparison

After 457ff97fa there are two defects in our code. In both of
them we use a signed variable to hold up a number of snapshots
that domain has. We use a helper function to count the number.
However, the helper function may fail in which case it returns
a negative one and control jumps to cleanup label where an
unsigned variable is used to iterate over array of snapshots. The
loop condition thus compare signed and unsigned variables which
in this specific case ends up badly for us.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodocs: Try harder to uninstall
Michal Privoznik [Sat, 13 Feb 2016 10:19:44 +0000 (11:19 +0100)]
docs: Try harder to uninstall

Imagine you have partially installed libvirt, or maybe you're
just running 'make uninstall' from a different version than 'make
install' has been ran. One way or another, we are doing plain
'rm' instead of 'rm -f' and thus not trying hard enough when
uninstalling. In the rest of our code we stick with -f switch. Do
that for docs too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotests: Fix typo oaque -> opaque
Andrea Bolognani [Tue, 23 Feb 2016 09:34:43 +0000 (10:34 +0100)]
tests: Fix typo oaque -> opaque

No functional changes.

9 years agolibxl: add support for rbd qdisk
Jim Fehlig [Thu, 11 Feb 2016 03:53:36 +0000 (20:53 -0700)]
libxl: add support for rbd qdisk

xl/libxl already supports qemu's network-based block backends
such as nbd and rbd. libvirt has supported configuring such
<disk>s for long time too. This patch adds support for rbd
disks in the libxl driver by generating a rbd device URL from
the virDomainDiskDef object. The URL is passed to libxl via the
pdev_path field of libxl_device_disk struct. libxl then passes
the URL to qemu for cosumption by the rbd backend.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoxenconfig: support xl<->xml conversion of rbd disk devices
Jim Fehlig [Thu, 11 Feb 2016 00:39:18 +0000 (17:39 -0700)]
xenconfig: support xl<->xml conversion of rbd disk devices

The target= setting in xl disk configuration can be used to encode
meta info that is meaningful to a backend. Leverage this fact to
support qdisk network disk types such as rbd. E.g. <disk> config
such as

   <disk type='network' device='disk'>
     <driver name='qemu' type='raw'/>
     <source protocol='rbd' name='pool/image'>
       <host name='mon1.example.org' port='6321'/>
       <host name='mon2.example.org' port='6322'/>
       <host name='mon3.example.org' port='6322'/>
     </source>
     <target dev='hdb' bus='ide'/>
     <address type='drive' controller='0' bus='0' target='0' unit='1'/>
   </disk>

can be converted to the following xl config (and vice versa)

  disk = [ "format=raw,vdev=hdb,access=rw,backendtype=qdisk,
            target=rbd:pool/image:auth_supported=none:mon_host=mon1.example.org\\:6321\\;mon2.example.org\\:6322\\;mon3.example.org\\:6322"
         ]

Note that in xl disk config, a literal backslash in target= must
be escaped with a backslash. Conversion of <auth> config is not
handled in this patch, but can be done in a follow-up patch.

Also add a test for the conversions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoxenconfig: produce key=value disk config syntax in xl formatter
Jim Fehlig [Tue, 9 Feb 2016 23:19:01 +0000 (16:19 -0700)]
xenconfig: produce key=value disk config syntax in xl formatter

The most formal form of xl disk configuration uses key=value
syntax to define each configuration item, e.g.

format=raw, vdev=xvda, access=rw, backendtype=phy, target=disksrc

Change the xl disk formatter to produce this syntax, which allows
target= to contain meta info needed to setup a network-based
disksrc (e.g. rbd, nbd, iscsi). For details on xl disk config
format, see  $xen-src/docs/misc/xl-disk-configuration.txt

Update the disk config in the tests to use the formal syntax.
But add tests to ensure disks specified with the positional
parameter syntax are correctly converted to <disk> XML.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoxenconfig: replace text 'xm' with 'xl' in xlconfigtest
Jim Fehlig [Tue, 16 Feb 2016 02:42:27 +0000 (19:42 -0700)]
xenconfig: replace text 'xm' with 'xl' in xlconfigtest

While at it, improve a few comments. No functional change.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agohostdev: Minor style adjustments
Andrea Bolognani [Mon, 25 Jan 2016 13:24:50 +0000 (14:24 +0100)]
hostdev: Minor style adjustments

Mostly labels names and whitespace.

No functional changes.

9 years agocmdSaveImageEdit: Prefer VSH_EXCLUSIVE_OPTIONS over by hand check
Michal Privoznik [Mon, 22 Feb 2016 12:45:53 +0000 (13:45 +0100)]
cmdSaveImageEdit: Prefer VSH_EXCLUSIVE_OPTIONS over by hand check

Since we have the macro there's no need for us to unwind it by
hand and check for mutually exclusive flags ourselves.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agocmdNetworkUpdate: Prefer VSH_EXCLUSIVE_OPTIONS over if-else tree
Michal Privoznik [Mon, 22 Feb 2016 12:33:20 +0000 (13:33 +0100)]
cmdNetworkUpdate: Prefer VSH_EXCLUSIVE_OPTIONS over if-else tree

We have macros that check and reject mutually exclusive
parameters to our commands. Use those instead of if-else tree.
At the same time, the variable @current becomes useless therefore
it is dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: TristateBool and TristateSwitch are interchangeable
Marc-André Lureau [Fri, 19 Feb 2016 14:30:14 +0000 (15:30 +0100)]
util: TristateBool and TristateSwitch are interchangeable

It may be useful in some cases to call TristateSwitch helper with TristateBool.
Document that enum values equivalency in the code.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9 years agoqemu_process: mark auto-generated spice ports as reserved
Pavel Hrdina [Thu, 18 Feb 2016 17:27:13 +0000 (18:27 +0100)]
qemu_process: mark auto-generated spice ports as reserved

In case you will specify graphics like this:

<graphics type='spice' port='-1'/>

or

<graphics type='spice' port='-1' tlsPort='6000'/>

libvirt will automatically add autoport='no'.  This leads to an issue
that in qemuProcessStop() we don't release that port because we are
releasing both port if autoport=yes or only port marked as reserved.

If autoport=no but we request to generate port via '-1' we need to mark
that port as reserved in order to release it.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoMiscellaneous for-loop syntax clean-ups
Martin Kletzander [Mon, 22 Feb 2016 10:04:38 +0000 (11:04 +0100)]
Miscellaneous for-loop syntax clean-ups

Checking whether x > 0 before looping over [0..x] items doesn't make
sense and multi-line body must have curly brackets around it.

Best viewed with '-w'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: add support for LSI SAS1068 (aka MPT Fusion) SCSI controller
Paolo Bonzini [Thu, 11 Feb 2016 10:48:20 +0000 (11:48 +0100)]
qemu: add support for LSI SAS1068 (aka MPT Fusion) SCSI controller

This does nothing more than adding the new device and capability.
The device is present since QEMU 2.6.0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agovirDomainDefFormatInternal: Drop useless check
Michal Privoznik [Mon, 22 Feb 2016 06:59:25 +0000 (07:59 +0100)]
virDomainDefFormatInternal: Drop useless check

There's a check if a domain definition has any graphics card and
if so, we iterate over each one of them. This makes no sense,
because even if it has none we can still iterate over.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoadminDaemonListServers: Don't leak @srv_names array
Michal Privoznik [Mon, 22 Feb 2016 06:25:18 +0000 (07:25 +0100)]
adminDaemonListServers: Don't leak @srv_names array

When getting a list of servers registered for a daemon, it's
returned as a dynamically allocated array filled in with pointers
to constant strings. Because the array is dynamic, it should be
freed when no longer needed (but not the strings!). Even the
function that creates the array suggests that.

==19446== 48 bytes in 3 blocks are definitely lost in loss record 821 of 1,034
==19446==    at 0x4C2C28E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19446==    by 0x54BAFC8: virReallocN (viralloc.c:245)
==19446==    by 0x54BB0BE: virExpandN (viralloc.c:294)
==19446==    by 0x54BB391: virInsertElementsN (viralloc.c:436)
==19446==    by 0x164E3D: virNetDaemonGetServerNames (virnetdaemon.c:217)
==19446==    by 0x15616F: adminDaemonListServers (admin_server.c:52)
==19446==    by 0x155B8C: adminDispatchConnectListServers (admin.c:151)
==19446==    by 0x155FD8: adminDispatchConnectListServersHelper (admin_dispatch.h:101)
==19446==    by 0x568E862: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==19446==    by 0x568E3C3: virNetServerProgramDispatch (virnetserverprogram.c:307)
==19446==    by 0x5687B5B: virNetServerProcessMsg (virnetserver.c:135)
==19446==    by 0x5687C1B: virNetServerHandleJob (virnetserver.c:156)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agogic: Introduce VIR_GIC_VERSION_DEFAULT alias
Andrea Bolognani [Thu, 18 Feb 2016 15:13:42 +0000 (16:13 +0100)]
gic: Introduce VIR_GIC_VERSION_DEFAULT alias

GIC v2 is the default, but checking against that specific version when
we want to know whether the default has been selected is potentially
error prone; using an alias instead makes it safer.

9 years agodocs: List possible GIC versions
Andrea Bolognani [Thu, 18 Feb 2016 14:44:20 +0000 (15:44 +0100)]
docs: List possible GIC versions

Recent changes to the handling of GIC version, specifically commit
2a7b11eafb67, have clearly defined what values are acceptable for the
version attribute of the <gic> element. Update the documentation
accordingly.

9 years agosecurity_selinux: Fix typo in error message
Laurent Bigonville [Sun, 14 Feb 2016 14:06:19 +0000 (15:06 +0100)]
security_selinux: Fix typo in error message

9 years agoqemu: iothreadpin: Always set affinity when pinning iothread
Peter Krempa [Fri, 19 Feb 2016 15:04:15 +0000 (16:04 +0100)]
qemu: iothreadpin: Always set affinity when pinning iothread

Similarly to VM startup always set the legacy affinity. Additionally we
don't need to report an explicit error since virProcessSetAffinity
reports them themselves.

9 years agoqemu: emulatorpin: Always set affinity when pinning emulator thread
Peter Krempa [Fri, 19 Feb 2016 15:04:15 +0000 (16:04 +0100)]
qemu: emulatorpin: Always set affinity when pinning emulator thread

Similarly to VM startup always set the legacy affinity. Additionally we
don't need to report an explicit error since virProcessSetAffinity
reports them themselves.

9 years agoqemu: parse: drop redundant AddImplicitControllers
Cole Robinson [Wed, 17 Feb 2016 16:53:07 +0000 (11:53 -0500)]
qemu: parse: drop redundant AddImplicitControllers

PostParse handles it for us now.

This causes some test suite churn; qemu's custom PostParse could is
now invoked before the generic AddImplicitControllers, so PCI
controllers end up sequentially in the XML before the generically
added IDE controllers. So it's just some XML reordering

9 years agoqemu: parse: rename qemuCaps->caps
Cole Robinson [Wed, 17 Feb 2016 16:37:03 +0000 (11:37 -0500)]
qemu: parse: rename qemuCaps->caps

Everywhere else in qemu driver code 'qemuCaps' is a virQEMUCapsPtr,
and virCapsPtr is generally named just 'caps'. Rename the offenders

9 years agodomain: add implicit controllers from post parse
Cole Robinson [Fri, 8 Jan 2016 03:49:57 +0000 (22:49 -0500)]
domain: add implicit controllers from post parse

Seems like the natural fit, since we are already adding other XML bits
in the PostParse routine.

Previously AddImplicitControllers was only called at the end of XML
parsing, meaning code that builds a DomainDef by hand had to manually
call it. Now those PostParse callers get it for free.

There's some test churn here; xen xm and sexpr test suite bits weren't
calling this before, but now they are, so you'll see new IDE controllers.
I don't think this will cause problems in practice, since the code already
needs to handle these implicit controllers like in the case when a user
defines their own XML.

9 years agoCheck for active domain in virDomainObjWait
Jiri Denemark [Tue, 16 Feb 2016 09:49:26 +0000 (10:49 +0100)]
Check for active domain in virDomainObjWait

virDomainObjWait is designed to be called in a loop. Make sure we break
the loop in case the domain dies to avoid waiting for an event which
will never happen.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Avoid calling qemuProcessStop without a job
Jiri Denemark [Thu, 11 Feb 2016 10:20:28 +0000 (11:20 +0100)]
qemu: Avoid calling qemuProcessStop without a job

Calling qemuProcessStop without a job opens a way to race conditions
with qemuDomainObjExitMonitor called in another thread. A real world
example of such a race condition:

  - migration thread (A) calls qemuMigrationWaitForSpice
  - another thread (B) starts processing qemuDomainAbortJob API
  - thread B signals thread A via qemuDomainObjAbortAsyncJob
  - thread B enters monitor (qemuDomainObjEnterMonitor)
  - thread B calls qemuMonitorSend
  - thread A awakens and calls qemuProcessStop
  - thread A calls qemuMonitorClose and sets priv->mon to NULL
  - thread B calls qemuDomainObjExitMonitor with priv->mon == NULL
  => monitor stays ref'ed and locked

Depending on how lucky we are, the race may result in a memory leak or
it can even deadlock libvirtd's event loop if it tries to lock the
monitor to process an event received before qemuMonitorClose was called.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Simplify error handling in qemuProcessReconnect
Jiri Denemark [Fri, 12 Feb 2016 08:58:22 +0000 (09:58 +0100)]
qemu: Simplify error handling in qemuProcessReconnect

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Process monitor EOF in a job
Jiri Denemark [Thu, 11 Feb 2016 14:32:48 +0000 (15:32 +0100)]
qemu: Process monitor EOF in a job

Stopping a domain without a job risks a race condition with another
thread which started a job a which does not expect anyone else to be
messing around with the same domain object.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Start an async job for processGuestPanicEvent
Jiri Denemark [Thu, 28 Jan 2016 17:32:02 +0000 (18:32 +0100)]
qemu: Start an async job for processGuestPanicEvent

Only a small portion of processGuestPanicEvent was enclosed within a
job, let's make sure we use the job for all operations to avoid race
conditions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Start job in qemuDomainDestroyFlags early
Jiri Denemark [Fri, 19 Feb 2016 14:24:11 +0000 (15:24 +0100)]
qemu: Start job in qemuDomainDestroyFlags early

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessBeginStopJob
Jiri Denemark [Thu, 11 Feb 2016 14:13:09 +0000 (15:13 +0100)]
qemu: Introduce qemuProcessBeginStopJob

When destroying a domain we need to make sure we will be able to start a
job no matter what other operations are running or even stuck in a job.
This is done by killing the domain before starting the destroy job.

Let's introduce qemuProcessBeginStopJob which combines killing a domain
and starting a job in a single API which can be called everywhere we
need a job to stop a domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Pass async job to qemuProcessInit
Jiri Denemark [Thu, 28 Jan 2016 14:56:07 +0000 (15:56 +0100)]
qemu: Pass async job to qemuProcessInit

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: End nested jobs properly
Jiri Denemark [Thu, 28 Jan 2016 12:48:17 +0000 (13:48 +0100)]
qemu: End nested jobs properly

Ending a nested job is no different from ending any other (non-async)
job, after all the code in qemuDomainBeginJobInternal does not handle
them differently either. Thus we should call qemuDomainObjEndJob to stop
nested jobs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Export qemuDomainObjBeginNestedJob
Jiri Denemark [Thu, 28 Jan 2016 12:57:12 +0000 (13:57 +0100)]
qemu: Export qemuDomainObjBeginNestedJob

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirsh: cpupin: Extract getter code into a separate function
Peter Krempa [Fri, 12 Feb 2016 09:56:08 +0000 (10:56 +0100)]
virsh: cpupin: Extract getter code into a separate function

9 years agoqemu: qemuDomainGetStatsVcpu: Fix output for possible sparse vCPU settings
Peter Krempa [Fri, 12 Feb 2016 07:24:07 +0000 (08:24 +0100)]
qemu: qemuDomainGetStatsVcpu: Fix output for possible sparse vCPU settings

qemuDomainHelperGetVcpus would correctly return an array of
virVcpuInfoPtr structs for online vcpus even for sparse topologies, but
the loop that fills the returned typed parameters would number the vcpus
incorrectly. Fortunately sparse topologies aren't supported yet.

9 years agoqemu: vcpupin: Always set affinity even when cgroups are supported
Peter Krempa [Fri, 12 Feb 2016 06:05:24 +0000 (07:05 +0100)]
qemu: vcpupin: Always set affinity even when cgroups are supported

VM startup and CPU hotplug always set the affinity regardless of cgroups
support. Use the same approach for the pinning API.

9 years agoqemu: vcpupin: Don't overwrite errors from functions setting pinning
Peter Krempa [Fri, 12 Feb 2016 05:54:41 +0000 (06:54 +0100)]
qemu: vcpupin: Don't overwrite errors from functions setting pinning

Both errors from the cgroups code and from the affinity code would be
overwritten by the API. Report the more specific error.

9 years agoutil: Use virBitmapIsBitSet in freebsd impl of virProcessSetAffinity
Peter Krempa [Fri, 12 Feb 2016 05:49:50 +0000 (06:49 +0100)]
util: Use virBitmapIsBitSet in freebsd impl of virProcessSetAffinity

Use the helper that does not return errors to fix spuriously looking
dead return of -1.

9 years agovirsh: cmdVcpuPin: Simplify handling of API flags
Peter Krempa [Fri, 12 Feb 2016 05:15:47 +0000 (06:15 +0100)]
virsh: cmdVcpuPin: Simplify handling of API flags

Rather than setting flags to -1 if none were specified, move the logic
to use the old API to the place where we need to decide. It simplifies
the logic a bit.

9 years agotest: qemuxml2argv: Drop QEMU_CAPS_DEVICE uses
Andrea Bolognani [Fri, 19 Feb 2016 12:25:38 +0000 (13:25 +0100)]
test: qemuxml2argv: Drop QEMU_CAPS_DEVICE uses

Since commit 51045df01b3c, the QEMU_CAPS_DEVICE capability is enabled
automatically and shouldn't be passed as an argument to DO_TEST();
however, commit 998a936c4c1a accidentally introduced few such uses.

9 years agoadmin: Fix memory leak in remoteAdminConnectClose
Erik Skultety [Thu, 18 Feb 2016 13:39:18 +0000 (14:39 +0100)]
admin: Fix memory leak in remoteAdminConnectClose

When virt-admin is run with valgrind, this kind of output can be obtained:

HEAP SUMMARY:
  in use at exit: 134,589 bytes in 1,031 blocks
  total heap usage: 2,667 allocs, 1,636 frees, 496,755 bytes allocated

88 bytes in 1 blocks are definitely lost in loss record 82 of 128
 at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 by 0x52F6D1F: virAllocVar (viralloc.c:560)
 by 0x5350268: virObjectNew (virobject.c:193)
 by 0x53503E0: virObjectLockableNew (virobject.c:219)
 by 0x4E3BBCB: virAdmConnectNew (datatypes.c:832)
 by 0x4E38495: virAdmConnectOpen (libvirt-admin.c:209)
 by 0x10C541: vshAdmConnect (virt-admin.c:107)
 by 0x10C7B2: vshAdmReconnect (virt-admin.c:163)
 by 0x10CC7C: cmdConnect (virt-admin.c:298)
 by 0x110838: vshCommandRun (vsh.c:1224)
 by 0x10DFD8: main (virt-admin.c:862)

 LEAK SUMMARY:
    definitely lost: 88 bytes in 1 blocks
    indirectly lost: 0 bytes in 0 blocks
    possibly lost: 0 bytes in 0 blocks
    still reachable: 134,501 bytes in 1,030 blocks
    suppressed: 0 bytes in 0 blocks

This is because virNetClientSetCloseCallback was being reinitialized
incorrectly. By resetting the callbacks in a proper way, the leak is fixed.

9 years agoesx: Avoid using vSphere SessionIsActive function
Matthias Bolte [Mon, 15 Feb 2016 20:17:49 +0000 (21:17 +0100)]
esx: Avoid using vSphere SessionIsActive function

A login session with the vSphere API might expire after some idle time.
The esxVI_EnsureSession function uses the SessionIsActive function to
check if the current session has expired and a relogin needs to be done.

But the SessionIsActive function needs the Sessions.ValidateSession
privilege that is considered as an admin level privilege.

Only vCenter actually provides the SessionIsActive function. This results
in requiring an admin level privilege even for read-only operations on
a vCenter server.

ESX and VMware Server don't provide the SessionIsActive function and
the code already works around that. Use the same workaround for vCenter
again.

This basically reverts commit 5699034b65afd49d91dff13c46481bea545cbaac.

9 years agoError out on missing machine type in machine configs
Ján Tomko [Thu, 11 Feb 2016 09:55:07 +0000 (10:55 +0100)]
Error out on missing machine type in machine configs

Commit f1a89a8 allowed parsing configs from /etc/libvirt
without validating the emulator capabilities.

Check for the presence of os->type.machine even if the
VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS flag is set,
otherwise the daemon can crash on carelessly crafted input
in the config directory.

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

9 years agovsh: use virBufferTrim in vshOutputLogFile
Ján Tomko [Fri, 12 Feb 2016 12:49:18 +0000 (13:49 +0100)]
vsh: use virBufferTrim in vshOutputLogFile

Use virBufferTrim to strip the extra newline at the end
of the message instead of open-coding it after the buffer's
string is formatted.

9 years agoqemu: Introduce qemuBuildMonitorCommandLine
John Ferlan [Wed, 17 Feb 2016 22:27:21 +0000 (17:27 -0500)]
qemu: Introduce qemuBuildMonitorCommandLine

Add new function to manage adding the '-mon' or '-monitor' options to
the command line removing that task from the mainline qemuBuildCommandLine.

Also adjusted qemuBuildChrChardevStr and qemuBuildChrArgStr to use
const virDomainChrSourceDef *def rather than virDomainChrSourceDefPtr def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildSgaCommandLine
John Ferlan [Wed, 17 Feb 2016 22:19:00 +0000 (17:19 -0500)]
qemu: Introduce qemuBuildSgaCommandLine

Add new function to manage adding the '-device sga' to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildSmbiosCommandLine
John Ferlan [Wed, 17 Feb 2016 22:10:37 +0000 (17:10 -0500)]
qemu: Introduce qemuBuildSmbiosCommandLine

Add new function to manage adding the '-smbios' options to the command
line removing that task from the mainline qemuBuildCommandLine

Also while I was looking at it, move the uuid processing closer to usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildNumaCommandLine
John Ferlan [Wed, 17 Feb 2016 21:56:37 +0000 (16:56 -0500)]
qemu: Introduce qemuBuildNumaCommandLine

Add new function to manage adding the '-numa' options to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildIOThreadCommandLine
John Ferlan [Wed, 17 Feb 2016 21:27:30 +0000 (16:27 -0500)]
qemu: Introduce qemuBuildIOThreadCommandLine

Add new function to manage adding the IOThread '-object' to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Rename qemuBuildSmpArgStr to qemuBuildSmpCommandLine
John Ferlan [Wed, 17 Feb 2016 21:23:46 +0000 (16:23 -0500)]
qemu: Rename qemuBuildSmpArgStr to qemuBuildSmpCommandLine

Rename function and move code in from qemuBuildCommandLine to
keep smp related code together. Also make a few style changes
for long lines, return value change, and 2 spaces between functions.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildMemCommandLine
John Ferlan [Wed, 17 Feb 2016 21:19:26 +0000 (16:19 -0500)]
qemu: Introduce qemuBuildMemCommandLine

Add new function to manage adding the '-m' memory options to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Rename qemuBuildCpuArgStr to qemuBuildCpuCommandLine
John Ferlan [Wed, 17 Feb 2016 21:12:49 +0000 (16:12 -0500)]
qemu: Rename qemuBuildCpuArgStr to qemuBuildCpuCommandLine

Rename function and move code from mainline qemuBuildCommandLine to
keep alike code together.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Rename qemuBuildMachineArgStr
John Ferlan [Wed, 17 Feb 2016 21:04:17 +0000 (16:04 -0500)]
qemu: Rename qemuBuildMachineArgStr

Rename to qemuBuildMachineCommandLine to fit current (and future)
helper naming conventions.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Make basic upfront checks before create command
John Ferlan [Mon, 15 Feb 2016 21:55:08 +0000 (16:55 -0500)]
qemu: Make basic upfront checks before create command

Create qemuBuildCommandLineValidate to make some checks before trying
to build the command. This will move some logic from much later to much
earlier - we shouldn't be adjusting any data so that shouldn't matter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: cgroup: fix cgroup permission logic
Bjoern Walk [Thu, 18 Feb 2016 09:19:51 +0000 (10:19 +0100)]
qemu: cgroup: fix cgroup permission logic

Fix logic error introduced in commit d6c91b3c which essentially broke
starting any domain.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
9 years agovirsh: Remove <backingStore> when changing cdrom media source
Peter Krempa [Tue, 28 Jul 2015 13:34:58 +0000 (15:34 +0200)]
virsh: Remove <backingStore> when changing cdrom media source

Since the code is changing the source image path by modifying the
existing XML snippet the <backingStore> stays in place.

As <backingStore> is relevant to the <source> part of the image, the
update of that part makes the element invalid.

CD/floppy images usually don't have a backing chain and the element is
currently ignored though but it might start being used in the future so
let's start behaving correctly.

Drop the <backingStore> subtree once we want to update the XML.

Before this patch, you'd get:
$ virsh change-media --eject --print-xml 10 hdc
<disk type="file" device="cdrom">
      <driver name="qemu" type="qcow2"/>

      <backingStore type="file" index="1">
        <format type="qcow2"/>
        <source file="/var/lib/libvirt/images/vm.1436949097"/>
        <backingStore/>
      </backingStore>
      <target dev="hdc" bus="ide"/>
      ...
    </disk>

After:

 $ virsh change-media --eject --print-xml 10 hdc
<disk type="file" device="cdrom">
      <driver name="qemu" type="qcow2"/>

      <target dev="hdc" bus="ide"/>
      ...
    </disk>

9 years agoqemu: Remove local emulator
John Ferlan [Mon, 15 Feb 2016 21:23:28 +0000 (16:23 -0500)]
qemu: Remove local emulator

Remove the local variable 'emulator' and just use def->emulator

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Kill VIR_WRAPPER_SHELL_PREFIX
Peter Krempa [Wed, 17 Feb 2016 15:44:18 +0000 (16:44 +0100)]
qemu: Kill VIR_WRAPPER_SHELL_PREFIX

The migration code now doesn't need it, so remove the macros and the
configure code that is detecting it.

9 years agoqemu: Move PORT definitions to qemu_conf.c
Cole Robinson [Wed, 10 Feb 2016 14:43:57 +0000 (09:43 -0500)]
qemu: Move PORT definitions to qemu_conf.c

Which is the only user. That was the only reason for including
qemu_command.h, though we need to explicitly include qemu_domain.h
afterwards.

9 years agotests: Remove unused virtTestClearLineRegex
Cole Robinson [Wed, 17 Feb 2016 14:10:28 +0000 (09:10 -0500)]
tests: Remove unused virtTestClearLineRegex

This was only used for test 'xml blanking', which has now all
been removed, and isn't an ideal paradigm anyways since it
inhibits easy XML regeneration.

9 years agotests: lxcconf2xml: Drop XML blanking
Cole Robinson [Tue, 16 Feb 2016 17:07:32 +0000 (12:07 -0500)]
tests: lxcconf2xml: Drop XML blanking

Hardcode a UUID like we did for qemuargv2xml, so we can use standard
comparison helpers, which gives us VIR_TEST_REGENERATE_OUTPUT support

9 years agotests: qemuargv2xml: Drop memory XML blanking
Cole Robinson [Tue, 16 Feb 2016 16:59:08 +0000 (11:59 -0500)]
tests: qemuargv2xml: Drop memory XML blanking

The memory XML blanking is only there to avoid the unit= churn that
was added by default a long time ago.

Drop the blanking, switch over to using the standard comparison
helpers, and regenerate the output with VIR_TEST_REGENERATE_OUTPUT.

9 years agotests: qemuargv2xml: hardcode disk auth usage
Cole Robinson [Tue, 16 Feb 2016 16:49:07 +0000 (11:49 -0500)]
tests: qemuargv2xml: hardcode disk auth usage

If a qemuargv has iscsi or ceph secrets on the command line, we will
convert that to XML like:

  <auth username='myname'>
    <secret type='iscsi'/>
  </auth>

This is not valid XML, as either a UUID or usage must be specified in
the secret block. It's not clear though how the argv2xml code can do
anything correct here, since XML like this requires a libvirt secret
object to have already been defined.

The current test suite handles this by blanking out any <secret> block
in the XML. This avoids domainschematest failures.

Instead of blanking, let's hardcode a usage= name. This lets us test
the other bits of generated <secret> XML, and is a step towards wiring
up VIR_TEST_REGENERATE_OUTPUT

9 years agotests: qemuargv2xml: Remove UUID randomness
Cole Robinson [Tue, 16 Feb 2016 16:13:21 +0000 (11:13 -0500)]
tests: qemuargv2xml: Remove UUID randomness

Overwrite any randomly generated UUID to use a hardcoded value, so
we don't need to blank it when comparing XML.

9 years agotests: qemuargv2xml: Remove unneeded XML blanking
Cole Robinson [Tue, 16 Feb 2016 15:55:24 +0000 (10:55 -0500)]
tests: qemuargv2xml: Remove unneeded XML blanking

None of the test cases depend on dropping these XML bits

9 years agoqemu: Remove unnecessary calculations in qemuDomainSaveMemory
Peter Krempa [Wed, 17 Feb 2016 12:10:11 +0000 (13:10 +0100)]
qemu: Remove unnecessary calculations in qemuDomainSaveMemory

Now that the file migration doesn't require us to use 'dd' and other
legacy stuff for too old qemus we don't even have to calcuate the
offsets and other stuff.

9 years agoqemu: monitor: Remove unused qemuMonitorMigrateToFile
Peter Krempa [Wed, 17 Feb 2016 11:56:07 +0000 (12:56 +0100)]
qemu: monitor: Remove unused qemuMonitorMigrateToFile

With the currently supported qemus we always migrate to file
descriptors so the old function is not required any more.

Additionally QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE macro is now
unused.

9 years agovircgroup: Update virCgroupDenyDevicePath stub
Michal Privoznik [Wed, 17 Feb 2016 13:25:35 +0000 (14:25 +0100)]
vircgroup: Update virCgroupDenyDevicePath stub

In cf113e8d we changed the declaration of
virCgroupAllowDevicePath() and virCgroupDenyDevicePath().
However, while updating the stub for non-cgroup platforms for the
former we forgot to update the latter too causing a build
failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRevert "storageVolCreateXMLFrom: Check if backend knows how to createVol"
Ján Tomko [Mon, 15 Feb 2016 08:04:58 +0000 (09:04 +0100)]
Revert "storageVolCreateXMLFrom: Check if backend knows how to createVol"

This reverts commit 611a278fa46d3136b7fe5c6ab05e660ca3c8fdf4.

According to the original commit message, this is dead code:

  It is highly unlikely that a backend will know how to create a
  volume from a different volume (buildVolFrom) and not know how to
  create an empty volume (createVol).

9 years agosyms: add forgotten virAdmConnectClass symbol
Erik Skultety [Wed, 17 Feb 2016 11:59:31 +0000 (12:59 +0100)]
syms: add forgotten virAdmConnectClass symbol

Although it currently doesn't cause any linking issues, the symbol should be
exported correctly according to our conventions.

9 years agovirt-admin: Introduce cmdSrvList
Erik Skultety [Thu, 19 Nov 2015 15:12:50 +0000 (16:12 +0100)]
virt-admin: Introduce cmdSrvList

Since we introduced listing API earlier in these series, it's time
to wire up the API to the virt-admin client.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Introduce adminDaemonConnectListServers API
Erik Skultety [Fri, 14 Aug 2015 07:17:01 +0000 (09:17 +0200)]
admin: Introduce adminDaemonConnectListServers API

This API is merely a convenience API, i.e. when managing clients connected to
daemon's servers, we should know (convenience) which server the specific client
is connected to. This implies a client-side representation of a server along
with a basic API to let the administrating client know what servers are actually
available on the daemon.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Introduce virAdmServer structure
Erik Skultety [Thu, 13 Aug 2015 14:20:27 +0000 (16:20 +0200)]
admin: Introduce virAdmServer structure

This is the key structure of all management operations performed on the
daemon/clients. An admin client needs to be able to identify
another client (either admin or non-privileged client) to perform an
action on it. This identification includes a server the client is
connected to, thus a client-side representation of a server is needed.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Move admin_server.{h,c} to admin.{h,c}
Erik Skultety [Mon, 10 Aug 2015 10:39:33 +0000 (12:39 +0200)]
admin: Move admin_server.{h,c} to admin.{h,c}

This change is merely because admin_server would contain all the code
from dispatchers and helpers to the actual APIs. Admin should have
similar structure to the daemon-side remote driver - dispatchers and
helpers in a separate module, APIs in a separate module.

Best viewed with -M.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirnetdaemon: Store servers in a hash table
Erik Skultety [Mon, 10 Aug 2015 11:01:44 +0000 (13:01 +0200)]
virnetdaemon: Store servers in a hash table

Since the daemon can manage and add (at fresh start) multiple servers,
we also should be able to add them from a JSON state file in case of a
daemon restart, so post exec restart support for multiple servers is also
provided. Patch also updates virnetdaemontest accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Refactor virHashForEach so it returns as soon as an iterator fails
Erik Skultety [Fri, 12 Feb 2016 09:15:57 +0000 (10:15 +0100)]
util: Refactor virHashForEach so it returns as soon as an iterator fails

The method will now return 0 on success and -1 on error, rather than number of
items which it iterated over before it returned back to the caller. Since the
only place where we actually check the number of elements iterated is in
virhashtest, return value of 0 and -1 can be a pretty accurate hint that it
iterated over all the items. However, if we really want to know the number of
items iterated over (like virhashtest does), a counter has to be provided
through opaque data to each iterator call. This patch adjusts return value of
virHashForEach, refactors the body, so it returns as soon as one of the
iterators fail and adjusts virhashtest to reflect these changes.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoutil: Add a return value to void hash iterators
Erik Skultety [Fri, 12 Feb 2016 09:03:50 +0000 (10:03 +0100)]
util: Add a return value to void hash iterators

Our existing virHashForEach method iterates through all items disregarding the
fact, that some of the iterators might have actually failed. Errors are usually
dispatched through an error element in opaque data which then causes the
original caller of virHashForEach to return -1. In that case, virHashForEach
could return as soon as one of the iterators fail. This patch changes the
iterator return type and adjusts all of its instances accordingly, so the
actual refactor of virHashForEach method can be dealt with later.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoqemu: cgroup: Setup cgroups for bios/firmware images
Peter Krempa [Tue, 16 Feb 2016 15:26:01 +0000 (16:26 +0100)]
qemu: cgroup: Setup cgroups for bios/firmware images

oVirt wants to use OVMF images on top of lvm for their 'logical'
storage thus we should set up device ACLs for them so it will actually
work.

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

9 years agoqemu: cgroup: Extract guts of qemuSetupImageCgroupInternal
Peter Krempa [Tue, 16 Feb 2016 14:46:40 +0000 (15:46 +0100)]
qemu: cgroup: Extract guts of qemuSetupImageCgroupInternal

They will later be reused for setting cgroup for other image backed
devices.

9 years agoqemu: cgroup: Split up qemuSetImageCgroupInternal
Peter Krempa [Tue, 16 Feb 2016 14:37:01 +0000 (15:37 +0100)]
qemu: cgroup: Split up qemuSetImageCgroupInternal

Separate the Teardown and Setup code paths into separate helpers.

9 years agoqemu: cgroup: Switch to qemu(Setup|Teardown)ImageCgroup
Peter Krempa [Mon, 15 Feb 2016 15:15:58 +0000 (16:15 +0100)]
qemu: cgroup: Switch to qemu(Setup|Teardown)ImageCgroup

For other objects we use the two functions rather than one with a bool.
Convert qemuSetImageCgroup to the same approach.

9 years agoqemu: cgroup: Avoid reporting errors from inaccessible NFS volumes
Peter Krempa [Tue, 16 Feb 2016 14:11:32 +0000 (15:11 +0100)]
qemu: cgroup: Avoid reporting errors from inaccessible NFS volumes

Rather than reporting it and then reseting the error, don't report it in
the first place.

9 years agoutil: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath
Peter Krempa [Tue, 16 Feb 2016 13:43:41 +0000 (14:43 +0100)]
util: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath

When adding disk images to ACL we may call those functions on NFS
shares. In that case we might get an EACCES, which isn't really relevant
since NFS would not hold a block device. This patch adds a flag that
allows to stop reporting an error on EACCES to avoid spaming logs.

Currently there's no functional change.

9 years agoutil: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor
Peter Krempa [Tue, 16 Feb 2016 12:57:10 +0000 (13:57 +0100)]
util: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor

Since commit 47e5b5ae virCgroupAllowDevice allows to pass -1 as either
the minor or major device number and it automatically uses '*' in place
of that. Reuse the new approach through the code and drop the duplicated
functions.