]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agovirsh: Notify users about disconnects
Jiri Denemark [Tue, 15 Sep 2015 14:46:07 +0000 (16:46 +0200)]
virsh: Notify users about disconnects

After my "client rpc: Report proper error for keepalive disconnections"
patch, virsh would no long print a warning when it closes a connection
to a daemon after a keepalive timeout. Although the warning

    virsh # 2015-09-15 10:59:26.729+0000: 642080: info :
    libvirt version: 1.2.19
    2015-09-15 10:59:26.729+0000: 642080: warning :
    virKeepAliveTimerInternal:143 : No response from client
    0x7efdc0a46730 after 1 keepalive messages in 2 seconds

was pretty ugly, it was still useful. This patch brings the useful part
back while making it much nicer:

virsh # error: Disconnected from qemu:///system due to keepalive timeout

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoclient rpc: Process pending data on error
Jiri Denemark [Tue, 15 Sep 2015 14:45:41 +0000 (16:45 +0200)]
client rpc: Process pending data on error

Even though we hit an error in client's IO loop, we still want to
process any pending data. So instead of reporting the error right away,
we can finish the current iteration and report the error once we're done
with it. Note that the error is stored in client->error by
virNetClientMarkClose so we don't need to worry about it being reset or
rewritten by any API we call in the meantime.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoclient rpc: Report proper error for keepalive disconnections
Jiri Denemark [Fri, 11 Sep 2015 15:07:56 +0000 (17:07 +0200)]
client rpc: Report proper error for keepalive disconnections

Whenever a connection was closed due to keepalive timeout, we would log
a warning but the interrupted API would return rather useless generic
error:

    internal error: received hangup / error event on socket

Let's report a proper keepalive timeout error and make sure it is
propagated to all pending APIs. The error should be better now:

    internal error: connection closed due to keepalive timeout

Based on an old patch from Martin Kletzander.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoconf: escape string for disk driver name attribute
Luyao Huang [Tue, 22 Sep 2015 08:13:53 +0000 (16:13 +0800)]
conf: escape string for disk driver name attribute

Just like e92e5ba1, this attribute was missed.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoUse VIR_DIV_UP macro where possible
Martin Kletzander [Mon, 24 Aug 2015 13:54:26 +0000 (15:54 +0200)]
Use VIR_DIV_UP macro where possible

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoMakefile: fix build fail when make rpm
Luyao Huang [Wed, 23 Sep 2015 02:09:47 +0000 (10:09 +0800)]
Makefile: fix build fail when make rpm

Build fail and error like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_command.lo
qemu/qemu_capabilities.c:46:27: fatal error: qemu_capspriv.h: No such file or directory
 #include "qemu_capspriv.h"

Add qemu_capspriv.h to source.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agospec: Fix some warnings with latest rpmbuild
Cole Robinson [Tue, 22 Sep 2015 19:56:50 +0000 (15:56 -0400)]
spec: Fix some warnings with latest rpmbuild

$ rpmbuild -ba libvirt.spec
warning: Macro expanded in comment on line 5: # If neither fedora nor rhel was defined, try to guess them from %{dist}

warning: Macro %enable_autotools defined but not used within scope
warning: Macro %client_only defined but not used within scope
...

9 years agotests: Avoid use of virQEMUDriverCreateXMLConf(NULL)
Michal Privoznik [Tue, 22 Sep 2015 14:27:57 +0000 (16:27 +0200)]
tests: Avoid use of virQEMUDriverCreateXMLConf(NULL)

We use the function to create a virDomainXMLOption object that is
required for some functions. However, we don't pass the driver
pointer to the object anywhere - rather than pass NULL. This
causes trouble later when parsing a domain XML and calling post
parse callbacks:

  Program received signal SIGSEGV, Segmentation fault.
  0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
  1043        qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
  (gdb) bt
  #0  0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
  #1  0x00007ffff2928bf9 in virDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, xmlopt=0x7c82c0) at conf/domain_conf.c:4269
  #2  0x00007ffff294de04 in virDomainDefParseXML (xml=0x7da8c0, root=0x7dab80, ctxt=0x7da980, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16400
  #3  0x00007ffff294e5b5 in virDomainDefParseNode (xml=0x7da8c0, root=0x7dab80, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16582
  #4  0x00007ffff294e424 in virDomainDefParse (xmlStr=0x0, filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16529
  #5  0x00007ffff294e4b2 in virDomainDefParseFile (filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16553
  #6  0x00000000004303ca in testSELinuxLoadDef (testname=0x53c929 "disks") at securityselinuxlabeltest.c:192
  #7  0x00000000004309e8 in testSELinuxLabeling (opaque=0x53c929) at securityselinuxlabeltest.c:313
  #8  0x0000000000431207 in virtTestRun (title=0x53c92f "Labelling \"disks\"", body=0x430964 <testSELinuxLabeling>, data=0x53c929) at testutils.c:211
  #9  0x0000000000430c5d in mymain () at securityselinuxlabeltest.c:373
  #10 0x00000000004325c2 in virtTestMain (argc=1, argv=0x7fffffffd7e8, func=0x430b4a <mymain>) at testutils.c:863
  #11 0x0000000000430deb in main (argc=1, argv=0x7fffffffd7e8) at securityselinuxlabeltest.c:381

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuTestDriverInit: init the driver lock too
Michal Privoznik [Tue, 22 Sep 2015 14:12:39 +0000 (16:12 +0200)]
qemuTestDriverInit: init the driver lock too

Even though usage of the lock is limited to a very few cases,
it's still needed. Therefore we should initialize it too.
Otherwise we may get some random test failures:

==1204== Conditional jump or move depends on uninitialised value(s)
==1204==    at 0xEF7F7CF: pthread_mutex_lock (in /lib64/libpthread-2.20.so)
==1204==    by 0x9CA89A5: virMutexLock (virthread.c:89)
==1204==    by 0x450B2A: qemuDriverLock (qemu_conf.c:83)
==1204==    by 0x45549C: virQEMUDriverGetConfig (qemu_conf.c:869)
==1204==    by 0x448E29: qemuDomainDeviceDefPostParse (qemu_domain.c:1240)
==1204==    by 0x9CC9B13: virDomainDeviceDefPostParse (domain_conf.c:4224)
==1204==    by 0x9CC9B91: virDomainDefPostParseDeviceIterator (domain_conf.c:4251)
==1204==    by 0x9CC7843: virDomainDeviceInfoIterateInternal (domain_conf.c:3440)
==1204==    by 0x9CC9C25: virDomainDefPostParse (domain_conf.c:4276)
==1204==    by 0x9CEEE03: virDomainDefParseXML (domain_conf.c:16400)
==1204==    by 0x9CEF5B4: virDomainDefParseNode (domain_conf.c:16582)
==1204==    by 0x9CEF423: virDomainDefParse (domain_conf.c:16529)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRevert "qemu: Fix integer/boolean logic in qemuSetUnprivSGIO"
John Ferlan [Fri, 18 Sep 2015 12:18:38 +0000 (08:18 -0400)]
Revert "qemu: Fix integer/boolean logic in qemuSetUnprivSGIO"

This reverts commit 69b850fe2a19d0c32ae2f209e8d8463df6ead665.

This change broke the ability to "clear" or reset unfiltered back
to filtered.

9 years agotest: Add test to validate that memory sizes don't get updated on migration
Peter Krempa [Mon, 21 Sep 2015 17:10:12 +0000 (19:10 +0200)]
test: Add test to validate that memory sizes don't get updated on migration

9 years agoqemu: ppc64: Align memory sizes to 256MiB blocks
Peter Krempa [Mon, 21 Sep 2015 16:10:55 +0000 (18:10 +0200)]
qemu: ppc64: Align memory sizes to 256MiB blocks

For some machine types ppc64 machines now require that memory sizes are
aligned to 256MiB increments (due to the dynamically reconfigurable
memory). As now we treat existing configs reasonably in regards to
migration, we can round all the sizes unconditionally. The only drawback
will be that the memory size of a VM can potentially increase by
(256MiB - 1byte) * number_of_NUMA_nodes.

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

9 years agoqemu: command: Align memory sizes only on fresh starts
Peter Krempa [Thu, 17 Sep 2015 06:14:05 +0000 (08:14 +0200)]
qemu: command: Align memory sizes only on fresh starts

When we are starting a qemu process for an incomming migration or
snapshot reloading we should not modify the memory sizes in the domain
since we could potentially change the guest ABI that was tediously
checked before. Additionally the function now updates the initial memory
size according to the NUMA node size, which should not happen if we are
restoring state.

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

9 years agoconf: Don't always recalculate initial memory size from NUMA size totals
Peter Krempa [Fri, 18 Sep 2015 15:24:32 +0000 (17:24 +0200)]
conf: Don't always recalculate initial memory size from NUMA size totals

When implementing memory hotplug I've opted to recalculate the initial
memory size (contents of the <memory> element) as a sum of the sizes of
NUMA nodes when NUMA was enabled. This was based on an assumption that
qemu did not allow starting when the NUMA node size total didn't equal
to the initial memory size. Unfortunately the check was introduced to
qemu just lately.

This patch uses the new XML parser flag to decide whether it's safe to
update the memory size total from the NUMA cell sizes or not.

As an additional improvement we now report an error in case when the
size of hotplug memory would exceed the total memory size.

The rest of the changes assures that the function is called with correct
flags.

9 years agoconf: Pre-calculate initial memory size instead of always calculating it
Peter Krempa [Thu, 13 Aug 2015 14:39:28 +0000 (16:39 +0200)]
conf: Pre-calculate initial memory size instead of always calculating it

Add 'initial_memory' member to struct virDomainMemtune so that the
memory size can be pre-calculated once instead of inferring it always
again and again.

Separating of the fields will also allow finer granularity of decisions
in later patches where it will allow to keep the old initial memory
value in cases where we are handling incomming migration from older
versions that did not always update the size from NUMA as the code did
previously.

The change also requires modification of the qemu memory alignment
function since at the point where we are modifying the size of NUMA
nodes the total size needs to be recalculated too.

The refactoring done in this patch also fixes a crash in the hyperv
driver that did not properly initialize def->numa and thus
virDomainNumaGetMemorySize(def->numa) crashed.

In summary this patch should have no functional impact at this point.

9 years agoconf: Rename max_balloon to total_memory
Peter Krempa [Wed, 16 Sep 2015 12:25:42 +0000 (14:25 +0200)]
conf: Rename max_balloon to total_memory

The name of the variable was misleading. Rename it and it's setting
accessor before other fixes.

9 years agoconf: Split memory related post parse stuff into separate function
Peter Krempa [Tue, 15 Sep 2015 14:59:23 +0000 (16:59 +0200)]
conf: Split memory related post parse stuff into separate function

The post parse func is growing rather large. Since later patches will
introduce more logic in the memory post parse code, split it into a
separate handler.

9 years agoconf: Add XML parser flag that will allow us to do incompatible updates
Peter Krempa [Tue, 15 Sep 2015 15:04:55 +0000 (17:04 +0200)]
conf: Add XML parser flag that will allow us to do incompatible updates

Add a new parser flag that will mark code paths that parse XML files
wich will not be used with existing VM state so that post parse
callbacks can possibly do ABI incompatible changes if needed.

9 years agoconf: Document all VIR_DOMAIN_DEF_PARSE_* flags
Peter Krempa [Tue, 15 Sep 2015 13:23:53 +0000 (15:23 +0200)]
conf: Document all VIR_DOMAIN_DEF_PARSE_* flags

9 years agoconf: Drop VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST flag
Peter Krempa [Tue, 15 Sep 2015 12:08:52 +0000 (14:08 +0200)]
conf: Drop VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST flag

The flag was used only for formatting the XML and once the parser and
formatter flags were split in 0ecd6851093945dd5ddc78266c61b577c65394ae
it doesn't make sense any more to have it.

9 years agoqemu: Make memory alignment helper more universal
Peter Krempa [Fri, 31 Jul 2015 14:00:20 +0000 (16:00 +0200)]
qemu: Make memory alignment helper more universal

Extract the size determination into a separate function and reuse it
across the memory device alignment functions. Since later we will need
to decide the alignment size according to architecture let's pass def to
the functions.

9 years agoconf: Add helper to determine whether memory hotplug is enabled for a vm
Peter Krempa [Mon, 14 Sep 2015 14:42:46 +0000 (16:42 +0200)]
conf: Add helper to determine whether memory hotplug is enabled for a vm

Add a simple helper so that the code doesn't have to rewrite the same
condition multiple times.

9 years agolibxl: vz: Use accessor instead of direct access for max_balloon
Peter Krempa [Wed, 16 Sep 2015 12:00:02 +0000 (14:00 +0200)]
libxl: vz: Use accessor instead of direct access for max_balloon

Commits 45697fe5 and f863ac80 used direct access to the variable instead
of the preferred accessor method.

9 years agoRemoved unneeded check
Pavel Fedin [Wed, 9 Sep 2015 14:03:16 +0000 (17:03 +0300)]
Removed unneeded check

Since test suite now correctly creates capabilities cache, the hack is not
needed any more.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agotests: use mockup cache
Pavel Fedin [Wed, 9 Sep 2015 14:03:15 +0000 (17:03 +0300)]
tests: use mockup cache

Use the new API in order to correctly add capability sets to the cache
before parsing XML files

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoImplement infrastracture for mocking up QEMU capabilities cache
Pavel Fedin [Wed, 9 Sep 2015 14:03:14 +0000 (17:03 +0300)]
Implement infrastracture for mocking up QEMU capabilities cache

The main purpose of this patch is to introduce test mode to
virQEMUCapsCacheLookup(). This is done by adding a global variable, which
effectively overrides binary name. This variable is supposed to be set by
test suite.

The second addition is qemuTestCapsCacheInsert() function which allows the
test suite to actually populate the cache.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agotests: split out common qemu driver initialization
Pavel Fedin [Tue, 15 Sep 2015 06:16:02 +0000 (08:16 +0200)]
tests: split out common qemu driver initialization

Two utility functions are introduced for proper initialization and
cleanup of the driver.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agotest driver: don't unlock pool after freeing it
David Mansfield [Thu, 17 Sep 2015 12:59:24 +0000 (08:59 -0400)]
test driver: don't unlock pool after freeing it

 Invalid read of size 4
    at 0x945CA30: __pthread_mutex_unlock_full (in /lib64/libpthread-2.20.so)
    by 0x4F0404B: virMutexUnlock (virthread.c:94)
    by 0x4F7161B: virStoragePoolObjUnlock (storage_conf.c:2603)
    by 0x4FE0476: testStoragePoolUndefine (test_driver.c:4328)
    by 0x4FCF086: virStoragePoolUndefine (libvirt-storage.c:656)
    by 0x15A7F5: cmdPoolUndefine (virsh-pool.c:1721)
    by 0x12F48D: vshCommandRun (vsh.c:1212)
    by 0x132AA7: main (virsh.c:943)
  Address 0xfda56a0 is 16 bytes inside a block of size 104 free'd
    at 0x4C2BA6C: free (vg_replace_malloc.c:473)
    by 0x4EA5C96: virFree (viralloc.c:582)
    by 0x4F70B69: virStoragePoolObjFree (storage_conf.c:412)
    by 0x4F7167B: virStoragePoolObjRemove (storage_conf.c:437)
    by 0x4FE0468: testStoragePoolUndefine (test_driver.c:4323)
    by 0x4FCF086: virStoragePoolUndefine (libvirt-storage.c:656)
    by 0x15A7F5: cmdPoolUndefine (virsh-pool.c:1721)
    by 0x12F48D: vshCommandRun (vsh.c:1212)
    by 0x132AA7: main (virsh.c:943)

9 years agovirfile: Use virProcessWait in virDirCreate
John Ferlan [Tue, 15 Sep 2015 12:27:38 +0000 (08:27 -0400)]
virfile: Use virProcessWait in virDirCreate

Rather than inlining the code, use the common API.

9 years agovirfile: Use virProcessWait in virFileUnlink
John Ferlan [Mon, 14 Sep 2015 20:51:14 +0000 (16:51 -0400)]
virfile: Use virProcessWait in virFileUnlink

Rather than inlining the code, use the common API.

9 years agovirfile: Use virProcessWait in virFileOpenForked
John Ferlan [Tue, 8 Sep 2015 22:09:53 +0000 (18:09 -0400)]
virfile: Use virProcessWait in virFileOpenForked

Rather than inlining the code, use the common API

9 years agovirfile: Rename virFileUnlink to virFileRemove
John Ferlan [Mon, 21 Sep 2015 11:36:55 +0000 (07:36 -0400)]
virfile: Rename virFileUnlink to virFileRemove

Similar to commit id '35847860', it's possible to attempt to create
a 'netfs' directory in an NFS root-squash environment which will cause
the 'vol-delete' command to fail.  It's also possible error paths from
the 'vol-create' would result in an error to remove a created directory
if the permissions were incorrect (and disallowed root access).

Thus rename the virFileUnlink to be virFileRemove to match the C API
functionality, adjust the code to following using rmdir or unlink
depending on the path type, and then use/call it for the VIR_STORAGE_VOL_DIR

9 years agovz: remove error logging from prlsdkUUIDParse
Maxim Nestratov [Mon, 21 Sep 2015 11:08:41 +0000 (14:08 +0300)]
vz: remove error logging from prlsdkUUIDParse

As far as not every call of prlsdkUUIDParse assume correct UUID
supplied, there is no use to complain about wrong format in it.
Otherwise our log is flooded with false error messages.
For instance, calling prlsdkUUIDParse from prlsdkEventsHandler
works as a filter and in case of uuid absence for event issuer,
we simply know that we shouldn't continue further processing.
Instead of error logging for all calls we should explicitly take
into accaunt where it is called from.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainChangeDiskLive: Allow startupPolicy change
Michal Privoznik [Tue, 15 Sep 2015 15:13:01 +0000 (17:13 +0200)]
qemuDomainChangeDiskLive: Allow startupPolicy change

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainDiskChangeSupported: Fill in missing checks
Michal Privoznik [Tue, 15 Sep 2015 13:41:18 +0000 (15:41 +0200)]
qemuDomainDiskChangeSupported: Fill in missing checks

So far this function was not kept in sync with changing
virDomainDiskDef. Fill in all the missing checks and reorganize
their order so it's easier to track which items are not being
checked for.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: s/virDomainDiskDiffersSourceOnly/qemuDomainDiskChangeSupported/
Michal Privoznik [Tue, 15 Sep 2015 13:25:18 +0000 (15:25 +0200)]
qemu: s/virDomainDiskDiffersSourceOnly/qemuDomainDiskChangeSupported/

I always felt like this function is qemu specific rather than
libvirt-wide. Other drivers may act differently on virDomainDef
change and in fact may require talking to underlying hypervisor
even if something else's than disk->src has changed.  I know that
the function is still incomplete, but lets break that into two
commits that are easier to review. This one is pure code
movement.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainChangeDiskLive: rework slightly
Michal Privoznik [Tue, 15 Sep 2015 12:37:21 +0000 (14:37 +0200)]
qemuDomainChangeDiskLive: rework slightly

Firstly, our coding guidelines suggest using 'cleanup' label
instead of 'end'. Then, @ret should be set to value representing
success as the last statement before the 'cleanup' label.
And while I am at this function, lets enumerate all the possible
enum items (virDomainDiskDevice) and avoid using 'default' in
switch(). Pooh. Also, nothing bad happens if we look up the disk
to change in the domain upfront. In fact, it's going to be
helpful later when we want to keep some old values for performing
a rollback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu_domain: Introduce qemuDomainDiskSourceDiffers
Michal Privoznik [Tue, 15 Sep 2015 11:41:42 +0000 (13:41 +0200)]
qemu_domain: Introduce qemuDomainDiskSourceDiffers

This new private API should return true iff sources of two disks
differs in sense that qemu should be instructed to change the
disk backend. For instance, ejecting a CDROM is such case, or
pointing disk into a different ISO location, and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: s/qemuDomainChangeDiskMediaLive/qemuDomainChangeDiskLive/
Michal Privoznik [Tue, 15 Sep 2015 11:16:24 +0000 (13:16 +0200)]
qemu: s/qemuDomainChangeDiskMediaLive/qemuDomainChangeDiskLive/

While we currently only allow changing a media in a disk, this is
going to change in a while, so the function name would be
invalid. Moreover, the old name does not match the pattern laid
out by other update functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again
Michal Privoznik [Mon, 14 Sep 2015 10:59:53 +0000 (12:59 +0200)]
qemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again

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

So, in 11e058ca589808bd I've tried to make UpdateDevice update
startupPolicy too. And it worked well until somebody came around
and pushed d0dc6c036914da which accidentally removed my
contribution. Redo my commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix some corner cases in persistent migration
Jiri Denemark [Thu, 10 Sep 2015 22:14:59 +0000 (00:14 +0200)]
qemu: Fix some corner cases in persistent migration

When persistently migrating a domain to a destination host where the
same domain already exists (i.e., it is persistent and shutdown at the
destination), we would happily throw away the original persistent
definition without properly freeing it. And when updating the definition
fails for some reason we don't properly revert to the original state
leaving the domain broken.

In addition to fixing these issues, the patch also makes sure the domain
definition parsed from a migration cookie is either used or freed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Queue events in migration Finish phase ASAP
Jiri Denemark [Tue, 7 Jul 2015 13:54:39 +0000 (15:54 +0200)]
qemu: Queue events in migration Finish phase ASAP

For quite a long time we don't need to postpone queueing events until
the end of the function since we no longer have the big driver lock.
Let's make the code of qemuMigrationFinish simpler by queuing events at
the time we generate them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemuDomainEventQueue: Check if event is non-NULL
Jiri Denemark [Tue, 7 Jul 2015 13:33:53 +0000 (15:33 +0200)]
qemuDomainEventQueue: Check if event is non-NULL

Every single call to qemuDomainEventQueue() uses the following pattern:

    if (event)
        qemuDomainEventQueue(driver, event);

Let's move the check for valid event to qemuDomainEventQueue and
simplify all callers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't report false errors in migration protocol v2
Jiri Denemark [Tue, 7 Jul 2015 13:29:10 +0000 (15:29 +0200)]
qemu: Don't report false errors in migration protocol v2

Finish is the final state in v2 of our migration protocol. If something
fails, we have no option to abort the migration and resume the original
domain. Non fatal errors (such as failure to start guest CPUs or make
the domain persistent) has to be treated as success. Keeping the domain
running while reporting the failure was just asking for trouble.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Kill domain when migration finish fails
Jiri Denemark [Tue, 7 Jul 2015 12:42:42 +0000 (14:42 +0200)]
qemu: Kill domain when migration finish fails

Whenever something fails during incoming migration in Finish phase
before we started guest CPUs, we need to kill the domain in addition to
reporting the failure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't fail migration on save status failure
Jiri Denemark [Tue, 7 Jul 2015 12:15:31 +0000 (14:15 +0200)]
qemu: Don't fail migration on save status failure

When we save status XML at the point during migration where we have
already started the domain on destination, we can't really go back and
abort migration. Thus the only thing we can do is to log a warning and
report success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Simplify qemuMigrationFinish
Jiri Denemark [Tue, 7 Jul 2015 12:11:58 +0000 (14:11 +0200)]
qemu: Simplify qemuMigrationFinish

Offline migration is quite special because we don't really need to do
anything but make the domain persistent. Let's do it separately from
normal migration to avoid cluttering the code with
!(flags & VIR_MIGRATE_OFFLINE).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Split qemuMigrationFinish
Jiri Denemark [Tue, 7 Jul 2015 10:11:37 +0000 (12:11 +0200)]
qemu: Split qemuMigrationFinish

Separate code which makes incoming domain persistent into
qemuMigrationPersist.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agolibxl: fix AttachDeviceConfig on hostdev type
Chunyan Liu [Thu, 17 Sep 2015 05:15:22 +0000 (01:15 -0400)]
libxl: fix AttachDeviceConfig on hostdev type

After attach-device a <hostdev> with --config, new device doesn't
show up in dumpxml and in guest.

To fix that, set dev->data.hostdev = NULL after work so that the
pointer is not freed, since vmdef has the pointer and still need it.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
9 years agovmx: Expose datacenter path in domain XML
Matthias Bolte [Fri, 11 Sep 2015 10:00:47 +0000 (12:00 +0200)]
vmx: Expose datacenter path in domain XML

Tool such as libguestfs need the datacenter path to get access to disk
images. The ESX driver knows the correct datacenter path, but this
information cannot be accessed using libvirt API yet. Also, it cannot
be deduced from the connection URI in a robust way.

Expose the datacenter path in the domain XML as <vmware:datacenterpath>
node similar to the way the <qemu:commandline> node works. The new node
is ignored while parsing the domain XML. In contrast to <qemu:commandline>
it is output only.

9 years agovirfile: Check for existence of dir in virFileDeleteTree
John Ferlan [Tue, 15 Sep 2015 20:33:36 +0000 (16:33 -0400)]
virfile: Check for existence of dir in virFileDeleteTree

Commit id 'f1f68ca33' added code to remove the directory paths for
auto-generated sockets, but that code could be called before the
paths were created resulting in generating error messages from
virFileDeleteTree indicating that the file doesn't exist.

Rather than "enforce" all callers to make the non-NULL and existence
checks, modify the virFileDeleteTree API to silently ignore NULL on
input and non-existent directory trees.

9 years agovirsh: Teach attach-interface to --print-xml
Michal Privoznik [Mon, 7 Sep 2015 10:13:47 +0000 (12:13 +0200)]
virsh: Teach attach-interface to --print-xml

We have the same argument to many other commands that produce an
XML based on what user typed. But unfortunately attach-interface
was missing it. Maybe nobody had needed it yet. Well, I did
just now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix using guest architecture as lookup key
Andrea Bolognani [Tue, 15 Sep 2015 13:58:09 +0000 (15:58 +0200)]
qemu: Fix using guest architecture as lookup key

When looking for a QEMU binary suitable for running ppc64le guests
we have to take into account the fact that we use the QEMU target
as key for the hash, so direct comparison is not good enough.

Factor out the logic from virQEMUCapsFindBinaryForArch() to a new
virQEMUCapsFindTarget() function and use that both when looking
for QEMU binaries available on the system and when looking up
QEMU capabilities later.

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

9 years agolibxl: fix compiler error introduced by commit ba25c214
Jim Fehlig [Wed, 16 Sep 2015 03:10:59 +0000 (21:10 -0600)]
libxl: fix compiler error introduced by commit ba25c214

libxl/libxl_conf.c: In function 'libxlDriverConfigNew':
libxl/libxl_conf.c:1560:30: error: 'log_level' may be used uninitialized
in this function [-Werror=maybe-uninitialized]

9 years agolibxl: open libxl log stream with libvirtd log_level
Jim Fehlig [Tue, 15 Sep 2015 14:17:44 +0000 (08:17 -0600)]
libxl: open libxl log stream with libvirtd log_level

Instead of a hardcoded DEBUG log level, use the overall
daemon log level specified in libvirtd.conf when opening
a log stream with libxl. libxl is very verbose when DEBUG
log level is set, resulting in huge log files that can
potentially fill a disk. Control of libxl verbosity should
be placed in the administrator's hands.

9 years agoIgnore virtio-mmio disks in qemuAssignDevicePCISlots()
Pavel Fedin [Wed, 9 Sep 2015 12:02:53 +0000 (15:02 +0300)]
Ignore virtio-mmio disks in qemuAssignDevicePCISlots()

Fixes the following error when attempting to add a disk with bus='virtio'
to a machine which actually supports virtio-mmio (caught with ARM virt):

virtio disk cannot have an address of type 'virtio-mmio'

The problem has been likely introduced by
e8d55172544c1fafe31a9e09346bdebca4f0d6f9. Before that
qemuAssignDevicePCISlots() was never called for ARM "virt" machine.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agosecurity_selinux: Take @privileged into account
Michal Privoznik [Thu, 10 Sep 2015 11:27:28 +0000 (13:27 +0200)]
security_selinux: Take @privileged into account

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

If running in session mode it may happen that we fail to set
correct SELinux label, but the image may still be readable to
the qemu process. Take this into account.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirSecurityManager: Track if running as privileged
Michal Privoznik [Thu, 10 Sep 2015 09:43:31 +0000 (11:43 +0200)]
virSecurityManager: Track if running as privileged

We may want to do some decisions in drivers based on fact if we
are running as privileged user or not. Propagate this info there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosecurity_selinux: Replace SELinuxSCSICallbackData with proper struct
Michal Privoznik [Thu, 10 Sep 2015 11:49:18 +0000 (13:49 +0200)]
security_selinux: Replace SELinuxSCSICallbackData with proper struct

We have plenty of callbacks in the driver. Some of these
callbacks require more than one argument to be passed. For that
we currently have a data type (struct) per each callback. Well,
so far for only one - SELinuxSCSICallbackData. But lets turn it
into more general name so it can be reused in other callbacks too
instead of each one introducing a new, duplicate data type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirSecuritySELinuxSetSecurityAllLabel: drop useless virFileIsSharedFSType
Michal Privoznik [Thu, 10 Sep 2015 11:29:36 +0000 (13:29 +0200)]
virSecuritySELinuxSetSecurityAllLabel: drop useless virFileIsSharedFSType

The check is done in virSecuritySELinuxSetFilecon itself. There's
no need to check it again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoMinor typo fixes in documentation
Christian Loehle [Tue, 15 Sep 2015 09:15:06 +0000 (11:15 +0200)]
Minor typo fixes in documentation

Signed-off-by: Christian Loehle <cloehle@linutronix.de>
9 years agoutil: Add space before comment end marker
Andrea Bolognani [Mon, 14 Sep 2015 09:29:03 +0000 (11:29 +0200)]
util: Add space before comment end marker

This allows the Wikipedia link to be recognized correctly by eg.
gnome-terminal's Open Link and Copy Link Address features.

9 years agoqemu: Allow others to browse /var/lib/libvirt/qemu
Martin Kletzander [Tue, 8 Sep 2015 16:34:36 +0000 (18:34 +0200)]
qemu: Allow others to browse /var/lib/libvirt/qemu

Commit f1f68ca33433 tried fixing running multiple domains under various
users, but if the user can't browse the directory, it's hard for the
qemu running under that user to create the monitor socket.

The permissions need to be fixed in two places in the spec file due to
support for both installations with and without driver modules.

Creating a directory with '$(MKDIR_P) -m' shouldn't fail even on systems
where autoconf needs to fallback to 'install-sh -d'.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Do not allow others into per-VM subdirectories
Martin Kletzander [Sat, 12 Sep 2015 13:00:58 +0000 (15:00 +0200)]
qemu: Do not allow others into per-VM subdirectories

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: hotplug: Properly clean up drive backend if frontend hotplug fails
Peter Krempa [Fri, 11 Sep 2015 15:34:18 +0000 (17:34 +0200)]
qemu: hotplug: Properly clean up drive backend if frontend hotplug fails

Commit 8125113c added code that should remove the disk backend if the
fronted hotplug failed for any reason. The code had a bug though as it
used the disk string for unplug rather than the backend alias. Fix the
code by pre-creating an alias string and using it instead of the disk
string. In cases where qemu does not support QEMU_CAPS_DEVICE, we ignore
the unplug of the backend since we can't really create an alias in that
case.

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

9 years agoqemu: command: Report stderr from qemu-bridge-helper
Cole Robinson [Thu, 10 Sep 2015 16:35:00 +0000 (12:35 -0400)]
qemu: command: Report stderr from qemu-bridge-helper

There's a couple reports of things failing in this area (bug 1259070),
but it's tough to tell what's going wrong without stderr from
qemu-bridge-helper. So let's report stderr in the error message

Couple new examples:

virbr0 is inactive:
internal error: /usr/libexec/qemu-bridge-helper --use-vnet --br=virbr0 --fd=21: failed to communicate with bridge helper: Transport endpoint is not connected
stderr=failed to get mtu of bridge `virbr0': No such device

bridge isn't on the ACL:
internal error: /usr/libexec/qemu-bridge-helper --use-vnet --br=br0 --fd=21: failed to communicate with bridge helper: Transport endpoint is not connected
stderr=access denied by acl file

9 years agoxen: fix race in refresh of config cache
Daniel P. Berrange [Fri, 11 Sep 2015 13:15:50 +0000 (14:15 +0100)]
xen: fix race in refresh of config cache

The xenXMConfigCacheRefresh method scans /etc/xen and loads
all config files it finds. It then scans its internal hash
table and purges any (previously) loaded config files whose
refresh timestamp does not match the timestamp recorded at
the start of xenXMConfigCacheRefresh(). There is unfortunately
a subtle flaw in this, because if loading the config files
takes longer than 1 second, some of the config files will
have a refresh timestamp that is 1 or more seconds different
(newer) than is checked for. So we immediately purge a bunch
of valid config files we just loaded.

To avoid this flaw, we must pass the timestamp we record at
the start of xenXMConfigCacheRefresh() into the
xenXMConfigCacheAddFile() method, instead of letting the
latter call time(NULL) again.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agotests: Don't use testutils in mock libraries
Martin Kletzander [Fri, 11 Sep 2015 09:11:45 +0000 (11:11 +0200)]
tests: Don't use testutils in mock libraries

Mock libraries are not built with testutils.c, but there's one which
uses VIR_TEST_DEBUG.  But because that debug should be an error, if we
change it, then it will not only be more semantically correct, but mingw
compiler will be happier as well.

It also follows suit with all other mock libraries.

For few other things, used in this file, need libvirt.la to be added
into LIBADD for mingw as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolibxl: don't end job for ephemeal domain on start failure
Ian Campbell [Thu, 10 Sep 2015 15:45:07 +0000 (16:45 +0100)]
libxl: don't end job for ephemeal domain on start failure

commit 4b53d0d4ac9c "libxl: don't remove persistent domain on start
failure" cleans up the vm object and sets it to NULL if the vm is not
persistent, however at end job vm (now NULL) is dereferenced via the call to
libxlDomainObjEndJob. Avoid this by skipping "endjob" and going
straight to "cleanup" in this case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
9 years agodocs: Update devguide.html to point to the new Python dev guide
Daniel P. Berrange [Thu, 10 Sep 2015 11:15:45 +0000 (12:15 +0100)]
docs: Update devguide.html to point to the new Python dev guide

We have a new libvirt-appdev-guide-python which we need to
promote to users. Rewrite the existing page to mention it
too. Also use the new URL location which is automatically
refreshed once a day.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: Try several network devices when looking for a default
Andrea Bolognani [Mon, 7 Sep 2015 06:51:00 +0000 (08:51 +0200)]
qemu: Try several network devices when looking for a default

Up until now, the default has been rtl8139, but no check was in
place to make sure that device was actually available.

Now we try rtl8139, e1000 and virtio-net in turn, checking for
availability before using any of them: this means we have a much
better chance for the guest to be able to boot.

9 years agoqemu: Introduce QEMU_CAPS_DEVICE_VIRTIO_NET
Andrea Bolognani [Tue, 1 Sep 2015 12:38:19 +0000 (14:38 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_VIRTIO_NET

This capability can be used to detect whether or not the QEMU
binary supports the virtio-net-* network device.

9 years agoqemu: Introduce QEMU_CAPS_DEVICE_E1000
Andrea Bolognani [Fri, 4 Sep 2015 14:40:37 +0000 (16:40 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_E1000

This capability can be used to detect whether or not the QEMU
binary supports the e1000 network device.

9 years agoqemu: Introduce QEMU_CAPS_DEVICE_RTL8139
Andrea Bolognani [Fri, 4 Sep 2015 14:23:46 +0000 (16:23 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_RTL8139

This capability can be used to detect whether or not the QEMU
binary supports the rtl8139 network device.

9 years agoqemu: Report error if per-VM directory cannot be created
Martin Kletzander [Tue, 8 Sep 2015 17:12:58 +0000 (19:12 +0200)]
qemu: Report error if per-VM directory cannot be created

Commit f1f68ca33433 did not report an error if virFileMakePath()
returned -1.  Well, who would've guessed function with name starting
with 'vir' sets an errno instead of reporting an error the libvirt way.
Anyway, let's fix it, so the output changes from:

  $ virsh start arm
  error: Failed to start domain arm
  error: An error occurred, but the cause is unknown

to:

  $ virsh start arm
  error: Failed to start domain arm
  error: Cannot create directory '/var/lib/libvirt/qemu/domain-arm': Not
  a directory

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRevert "docs: Drop unused rule for internals/%.html.tmp target"
Martin Kletzander [Wed, 9 Sep 2015 09:45:57 +0000 (11:45 +0200)]
Revert "docs: Drop unused rule for internals/%.html.tmp target"

This reverts commit e5470dd0e0a5be02cbf18a882cfc676b39d1c1a5.

This has been ACK'd by the original author in the original mail thread:
https://www.redhat.com/archives/libvir-list/2015-September/msg00310.html

The reason to revert this is due to the patch breaking the generation of
internal subsites.  The original issue still needs to be dealt with,
though.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: migration: Relax enforcement of memory hotplug support
Peter Krempa [Tue, 8 Sep 2015 13:06:26 +0000 (15:06 +0200)]
qemu: migration: Relax enforcement of memory hotplug support

If the current live definition does not have memory hotplug enabled, but
the persistent one does libvirt would reject migration if the
destination does not support memory hotplug even if the user didn't want
to persist the VM at the destination and thus the XML containing the
memory hotplug definition would not be used. To fix this corner case the
code will check for memory hotplug in the newDef only if
VIR_MIGRATE_PERSIST_DEST was used.

9 years agodocs: Remove last use of double semicolon in Makefile
Martin Kletzander [Mon, 7 Sep 2015 08:27:53 +0000 (10:27 +0200)]
docs: Remove last use of double semicolon in Makefile

Double semicolons have special meaning in makefiles, but they would have
to be combined with other rules witch such separators in order to be
used as intended.  Since there are no other rules like that, let's
clean it up.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add win32 version of virFileUnlink
Martin Kletzander [Mon, 7 Sep 2015 08:24:47 +0000 (10:24 +0200)]
util: Add win32 version of virFileUnlink

Commit 35847860f65f Added the virFileUnlink function, but failed to add
a version for mingw build, causing the following error:

  Cannot export virFileUnlink: symbol not defined

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: fix crash when parsing a unordered NUMA <cell/>
Luyao Huang [Tue, 8 Sep 2015 04:59:10 +0000 (12:59 +0800)]
conf: fix crash when parsing a unordered NUMA <cell/>

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

Introduced by 8fedbbdb, if we parse an unordered NUMA cell, will
get a segfault. This is because of a check for overlapping @cpus
sets we have there. However, since the array to hold guest NUMA
cells is allocated upfront and therefore it contains all zeros,
an out of order cell will break our assumption that cell IDs have
increasing character. At this point we try to access yet NULL
bitmap and therefore segfault.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoadmin: Resolve leaked reference to private data
Erik Skultety [Mon, 7 Sep 2015 15:28:22 +0000 (17:28 +0200)]
admin: Resolve leaked reference to private data

Running valgrind on a very simplistic program consisting only of
opening and closing admin connection (virAdmConnect{Open,Close}) shows a
leak in remoteAdminPrivNew, because the last reference to privateData is
not decremented, thus the object won't be disposed. This patch unrefs
the privateData object once we closed the active connection to daemon,
making further use of this connection  useless.

==24577==    at 0x4A089C7: calloc (in /usr/lib64/valgrind/vgpreload_***linux.so)
==24577==    by 0x4E8835F: virAllocVar (viralloc.c:560)
==24577==    by 0x4EDFA5C: virObjectNew (virobject.c:193)
==24577==    by 0x4EDFBD4: virObjectLockableNew (virobject.c:219)
==24577==    by 0x4C14DAF: remoteAdminPrivNew (libvirt-admin.c:152)
==24577==    by 0x4C1537E: virAdmConnectOpen (libvirt-admin.c:308)
==24577==    by 0x400BAD: main (listservers.c:39)

==24577== LEAK SUMMARY:
==24577==    definitely lost: 80 bytes in 1 blocks
==24577==    indirectly lost: 840 bytes in 6 blocks
==24577==      possibly lost: 0 bytes in 0 blocks
==24577==    still reachable: 12,179 bytes in 199 blocks
==24577==         suppressed: 0 bytes in 0 blocks

9 years agovmx: Add handling for CDROM devices with SCSI passthru
Matthias Bolte [Tue, 1 Sep 2015 14:52:04 +0000 (16:52 +0200)]
vmx: Add handling for CDROM devices with SCSI passthru

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

9 years agovmx: The virVMXParseDisk deviceType can be NULL, add some missing checks
Matthias Bolte [Tue, 1 Sep 2015 14:52:03 +0000 (16:52 +0200)]
vmx: The virVMXParseDisk deviceType can be NULL, add some missing checks

9 years agocpu: Introduce IvyBridge CPU model
Jiri Denemark [Fri, 4 Sep 2015 13:06:40 +0000 (15:06 +0200)]
cpu: Introduce IvyBridge CPU model

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirsh: Slightly rework cmdDomblklist
Michal Privoznik [Wed, 2 Sep 2015 13:44:41 +0000 (15:44 +0200)]
virsh: Slightly rework cmdDomblklist

Let's move some variables from an inside loop to global function
declaration header block. It's going to be easier for next
patches. At the same time, order the cleanup calls at the
function's end so it's easier to track which variables are freed
and which not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years ago.gitignore: Ignore the correct rename example binary
Michal Privoznik [Mon, 7 Sep 2015 08:40:55 +0000 (10:40 +0200)]
.gitignore: Ignore the correct rename example binary

In e755186c5c305a9 we tried to introduce an example demonstrating
new virDomainRename API. Unfortunately, in the .gitignore we had
a different binary listed. It's 'rename' binary which we want git
to ignore, not 'test'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoexamples: Add missing build data for 'rename'
Martin Kletzander [Mon, 7 Sep 2015 07:00:19 +0000 (09:00 +0200)]
examples: Add missing build data for 'rename'

Commit e755186c5c30 added the rename example, but forgot to build some
essential files in there as well as add it to the spec file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovmx: Some whitespace cleanup
Matthias Bolte [Tue, 1 Sep 2015 14:52:02 +0000 (16:52 +0200)]
vmx: Some whitespace cleanup

9 years agoconf: Remove need for a couple of sa_asserts
John Ferlan [Tue, 1 Sep 2015 11:20:15 +0000 (07:20 -0400)]
conf: Remove need for a couple of sa_asserts

Remove the need for a couple of sa_asserts.

9 years agoutil: Avoid Coverity FORWARD_NULL
John Ferlan [Tue, 1 Sep 2015 11:02:30 +0000 (07:02 -0400)]
util: Avoid Coverity FORWARD_NULL

Coverity claims it could be possible to call virDBusTypeStackFree with
*stack == NULL and although the two API's that call it don't appear to
allow that - I suppose it's better to be safe than sorry

9 years agovirfile: Avoid Coverity IDENTICAL_BRANCHES error
John Ferlan [Tue, 1 Sep 2015 10:56:38 +0000 (06:56 -0400)]
virfile: Avoid Coverity IDENTICAL_BRANCHES error

In virFileNBDDeviceFindUnused if virFileNBDDeviceIsBusy returns 0,
then both branches jumped to cleanup, so just use ignore_value
since the function returns NULL or some memory and the caller
handles the error.

9 years agolxc: Avoid Coverity SIZEOF_MISMATCH
John Ferlan [Tue, 1 Sep 2015 11:08:47 +0000 (07:08 -0400)]
lxc: Avoid Coverity SIZEOF_MISMATCH

Commit id '692e9fac7' used virProcessSetNamespaces instead of inlining
the similar functionality; however, Coverity notes that the function
prototype expects a size_t value and not an enum and complains. So,
just typecast the enum as a size_t to avoid the noise.

9 years agoqemu: Check virGetLastError return value for migration finish failure
John Ferlan [Tue, 1 Sep 2015 10:47:55 +0000 (06:47 -0400)]
qemu: Check virGetLastError return value for migration finish failure

Commit id '2e7cea243' added a check for an error from Finish instead
of 'unexpected error'; however, if for some reason there wasn't an
error, then virGetLastError could return NULL resulting in the
NULL pointer deref to err->domain.

9 years agoChange name of the domain upon successful rename
Martin Kletzander [Thu, 27 Aug 2015 10:43:15 +0000 (12:43 +0200)]
Change name of the domain upon successful rename

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd example that renames domain there and back
Martin Kletzander [Thu, 27 Aug 2015 10:55:52 +0000 (12:55 +0200)]
Add example that renames domain there and back

And in the middle it prints out its name to demonstrate changes in later
patch(es).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoexamples: Add example polkit ACL rules
Jiri Denemark [Tue, 4 Aug 2015 12:05:52 +0000 (14:05 +0200)]
examples: Add example polkit ACL rules

Creating ACL rules is not exactly easy and existing examples are pretty
simple. This patch adds a somewhat complex example which defines several
roles. Admins can do everything, operators can do basic operations
on any domain and several groups of users who act as operators but only
on a limited set of domains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Need to check for machine.os when using ADDRESS_TYPE_CCW
John Ferlan [Mon, 31 Aug 2015 15:06:42 +0000 (11:06 -0400)]
qemu: Need to check for machine.os when using ADDRESS_TYPE_CCW

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

When attaching a disk, controller, or rng using an address type ccw
or s390, we need to ensure the support is provided by both the machine.os
and the emulator capabilities (corollary to unconditional setting when
address was not provided for the correct machine.os and emulator.

For an inactive guest, an addition followed by a start would cause the
startup to fail after qemu_command builds the command line and attempts
to start the guest. For an active guest, libvirtd would crash.

9 years agoqemu: Introduce qemuDomainMachineIsS390CCW
John Ferlan [Wed, 2 Sep 2015 20:02:14 +0000 (16:02 -0400)]
qemu: Introduce qemuDomainMachineIsS390CCW

Rather than have different usages of STR function in order to determine
whether the domain is s390-ccw or s390-ccw-virtio, make a single API
which will check the machine.os prefix. Then use the function.

9 years agovsh: Make vshInitDebug static
Erik Skultety [Fri, 4 Sep 2015 08:42:29 +0000 (10:42 +0200)]
vsh: Make vshInitDebug static

There's no reason why debug initialization could not be made completely
hidden, just like readline initialization is. The point of the global
initializer vshInit is to make initialization of smaller features transparent
to the user/caller.

9 years agovirsh: Do not make interactive mode default
Erik Skultety [Fri, 4 Sep 2015 09:19:55 +0000 (11:19 +0200)]
virsh: Do not make interactive mode default

Currently, we set interactive mode as default possibly reverting the
setting after we parse the command line arguments. There's nothing
particulary wrong with that, but a call to vshReadlineInit is performed
always in the global initializer just because the default mode is interactive.
Rather than moving vshReadlineInit call somewhere else (because another client
might want to implement interactive mode only), we could make the decision
if we're about to run in interactive mode once the command line is parsed.