]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoqemu: monitor: Open-code retrieval of wr_highest_offset
Peter Krempa [Tue, 23 Jun 2015 14:58:07 +0000 (16:58 +0200)]
qemu: monitor: Open-code retrieval of wr_highest_offset

Instead of using qemuMonitorJSONDevGetBlockExtent (which I plan to
remove later) extract the data in place.

Additionally add a flag that will be set when the wr_highest_offset was
extracted correctly so that callers can act according to that.

The test case addition should help make sure that everything works.

9 years agoqemu: monitor: Fix indentation in qemuMonitorJSONGetOneBlockStatsInfo
Peter Krempa [Tue, 23 Jun 2015 13:11:17 +0000 (15:11 +0200)]
qemu: monitor: Fix indentation in qemuMonitorJSONGetOneBlockStatsInfo

9 years agointernal: Introduce virCheckNonEmptyStringArgGoto and reuse it
Peter Krempa [Tue, 23 Jun 2015 15:35:16 +0000 (17:35 +0200)]
internal: Introduce virCheckNonEmptyStringArgGoto and reuse it

The helper makes sure that strings passed to APIs are non-NULL and
non-empty. This allows to drop some inlined checks where it does not
make sense.

9 years agovz: Fix build after recent commit
Peter Krempa [Fri, 26 Jun 2015 14:00:15 +0000 (16:00 +0200)]
vz: Fix build after recent commit

Function prlsdkGetStatsParam was missing a prototype or the static
keyword. I went with static since it built successfully.

Pushed as a build breaker fix.

9 years agovz: add memory statistics
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: add memory statistics

Implemented counters:
 VIR_DOMAIN_MEMORY_STAT_SWAP_IN
 VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
 VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
 VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
 VIR_DOMAIN_MEMORY_STAT_AVAILABLE
 VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
 VIR_DOMAIN_MEMORY_STAT_UNUSED

Comments.

1. Use vzDomObjFromDomainRef/virDomainObjEndAPI pair to get domain
object as we use prlsdkGetStatsParam. See previous statistics
comments.

2. Balloon statistics is not applicable to containers. Fault
statistics for containers not provided in PCS6 yet.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: add vcpu statistics
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: add vcpu statistics

Comments.

Replace vzDomObjFromDomain/virObjectUnlock pair
to vzDomObjFromDomainRef/virDomainObjEndAPI as we
use prlsdkGetStatsParam. See previous statistics
comments.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: cleanup, make in par net device lookup functions
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: cleanup, make in par net device lookup functions

Make net device lookup by mac return sdk handle
instead of quite ephemeral enumeration index. After
this change there is no need anymore in special
function of removing device by enumeration index.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: add net dev statistiscs
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: add net dev statistiscs

Populate counters SDK currenly supports:
 rx_bytes
 rx_packets
 tx_bytes
 tx_packets

Comments.

Use vzDomObjFromDomainRef/virDomainObjEndAPI pair to get domain
object as we use prlsdkGetStatsParam that can release domain
object lock and thus we need a reference in case domain
is deleated meanwhile.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agodocs: Don't keep temporary files around
Michal Privoznik [Fri, 26 Jun 2015 08:49:19 +0000 (10:49 +0200)]
docs: Don't keep temporary files around

In my previous fix (1310b1358) I've tried to solve an ordering
issue.  Well, while it worked it has a side effect of keeping a
temporary file around. My patch was buggy in that sense. Solve
this by properly marking the dependency without any side effect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_utils: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_utils: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_storage: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_storage: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_sdk: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_sdk: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_network: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_network: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_driver: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_driver: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuBuildMemoryBackendStr: Honour passed @pagesize
Michal Privoznik [Thu, 25 Jun 2015 15:27:29 +0000 (17:27 +0200)]
qemuBuildMemoryBackendStr: Honour passed @pagesize

So far the argument has not much meaning and was practically ignored.
This is not good since when doing memory hotplug, the size of desired
hugepage backing is passed in that argument. Taking closer look at the
tests I'm fixing reveals the bug. For instance, while the following is
in the test:

    <memory model='dimm'>
      <source>
        <nodemask>1-3</nodemask>
        <pagesize unit='KiB'>4096</pagesize>
      </source>
      <target>
        <size unit='KiB'>524287</size>
        <node>0</node>
      </target>
      <address type='dimm' slot='0' base='0x100000000'/>
    </memory>

the generated commandline corresponding to this XML was:

    -object memory-backend-ram,id=memdimm0,size=536870912,\
    host-nodes=1-3,policy=bind

Have you noticed? Yes, memory-backend-ram! Nothing can be further away
from the right answer. The hugepage backing is requested in the XML
and we happily ignore it. This is just not right. It's
memory-backend-file which should have been used:

    -object memory-backend-file,id=memdimm0,prealloc=yes,\
    mem-path=/dev/hugepages4M/libvirt/qemu,size=536870912,\
    host-nodes=1-3,policy=bind

The problem is, that @pagesize passed to qemuBuildMemoryBackendStr
(where this part of commandline is built) was ignored. The hugepage to
back memory was searched only and only by NUMA nodes pinning. This
works only for regular guest NUMA nodes.

Then, I'm changing the hugepages size in the test XMLs too. This is
simply because in the test suite we create dummy mount points just for
2M and 1G hugepages. And in the test 4M was requested. I'm sticking to
2M, but 1G should just work too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuBuildMemoryBackendStr: Fix hugepages lookup process
Michal Privoznik [Wed, 24 Jun 2015 16:09:57 +0000 (18:09 +0200)]
qemuBuildMemoryBackendStr: Fix hugepages lookup process

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

This function constructs the backend (host facing) part of the
memory device.  At the beginning, the configured hugepages are
searched to find the best match for given guest NUMA node.
Configured hugepages can have a @nodeset attribute to specify on
which guest NUMA nodes should be the hugepages backing used.
There is, however, one 'corner case'. Users may just tell 'use
hugepages to back all the nodes'. In other words:

  <memoryBacking>
    <hugepages/>
  </memoryBacking>

  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='1024000' unit='KiB'/>
    </numa>
  </cpu>

Our code fails in this case. Well, since there's no @nodeset (nor
any <page/> child element to <hugepages/>) we fail to lookup the
default hugepage size to use.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Format scheduler priority when it is zero
Luyao Huang [Wed, 24 Jun 2015 04:00:36 +0000 (12:00 +0800)]
conf: Format scheduler priority when it is zero

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

According to our XML definition, zero is as valid as any other value.
Mainly because it should be kernel-agnostic.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agotest: Refactor testNodeGetCPUMap
Peter Krempa [Mon, 22 Jun 2015 14:10:49 +0000 (16:10 +0200)]
test: Refactor testNodeGetCPUMap

Drop locking of the driver since it is not accessed and simplify the
code flow.

9 years agotest: Refactor vcpu pinning and vcpu info retrieval
Peter Krempa [Wed, 17 Jun 2015 09:05:21 +0000 (11:05 +0200)]
test: Refactor vcpu pinning and vcpu info retrieval

Drop internal data structures and use the proper fields in virDomainDef.

This allows to greatly simplify the code and allows to remove the
private data structure that was holding just redundant data.

This patch also fixes the bogous output where we'd report that a fresh
VM without vCPU pinning would not run on all vcpus.

9 years agotest: Refactor testDomainSetVcpusFlags
Peter Krempa [Tue, 16 Jun 2015 17:15:27 +0000 (19:15 +0200)]
test: Refactor testDomainSetVcpusFlags

Remove the bogus flag check and refactor the code by using
virDomainObjGetDefs instead of virDomainObjGetPersistentDef.

9 years agotest: Refactor test driver domain object retrieval
Peter Krempa [Tue, 16 Jun 2015 16:18:03 +0000 (18:18 +0200)]
test: Refactor test driver domain object retrieval

Reuse testDomObjFromDomain to retrieve domain objects in the rest of
the test driver instead of open-coding it in every API.

9 years agotest: Drop locked access to testDriver->domains
Peter Krempa [Mon, 22 Jun 2015 12:33:23 +0000 (14:33 +0200)]
test: Drop locked access to testDriver->domains

Only self-locking APIs are used and the pointer is immutable so there's
no need to lock the driver to access the domain list.

This patch removes locking partially for everything that will not be
converted to testDomObjFromDomain in the next patch.

9 years agotest: Finalize removal of locking from driver->eventState
Peter Krempa [Wed, 24 Jun 2015 10:56:21 +0000 (12:56 +0200)]
test: Finalize removal of locking from driver->eventState

Don't lock the driver when registering event callbacks.

9 years agotest: Refactor test driver event sending
Peter Krempa [Tue, 16 Jun 2015 16:35:57 +0000 (18:35 +0200)]
test: Refactor test driver event sending

Make testObjectEventQueue tolerant to NULL @event and move it so that it
does not require a prototype. Additionally we are now able to remove
locking when accessing driver->eventState, since it's using self-locking
APIs and the pointer is immutable.

9 years agotest: Use atomic access to @nextDomID in struct virTestDriver
Peter Krempa [Wed, 24 Jun 2015 13:08:47 +0000 (15:08 +0200)]
test: Use atomic access to @nextDomID in struct virTestDriver

9 years agotest: Annotate few fields of testDriver structure
Peter Krempa [Wed, 24 Jun 2015 10:46:19 +0000 (12:46 +0200)]
test: Annotate few fields of testDriver structure

Some of the fields are either immutable or self locking, so make a note
of that for future reference.

9 years agotest: Drop unused attribute @path from testDriver struct
Peter Krempa [Wed, 24 Jun 2015 09:25:44 +0000 (11:25 +0200)]
test: Drop unused attribute @path from testDriver struct

It's filled and then freed, but not used anywhere else.

9 years agotest: Extract common parts of test driver data allocation
Peter Krempa [Wed, 24 Jun 2015 09:06:24 +0000 (11:06 +0200)]
test: Extract common parts of test driver data allocation

9 years agotest: Extract code to free testDriver into testDriverFree
Peter Krempa [Mon, 22 Jun 2015 18:13:12 +0000 (20:13 +0200)]
test: Extract code to free testDriver into testDriverFree

Avoid reimplementing it 3 times.

9 years agotest: turn 'defaultConn' into a pointer
Peter Krempa [Mon, 22 Jun 2015 14:49:28 +0000 (16:49 +0200)]
test: turn 'defaultConn' into a pointer

9 years agotest: Drop useless forward declaration
Peter Krempa [Mon, 22 Jun 2015 14:34:22 +0000 (16:34 +0200)]
test: Drop useless forward declaration

9 years agotest: Rename testConn to testDriver
Peter Krempa [Mon, 22 Jun 2015 14:25:16 +0000 (16:25 +0200)]
test: Rename testConn to testDriver

9 years agoqemu: Avoid removing persistent config if migration fails
Luyao Huang [Thu, 25 Jun 2015 01:38:57 +0000 (09:38 +0800)]
qemu: Avoid removing persistent config if migration fails

When migration fails in qemuMigrationPrepareAny, we unconditionally call
qemuDomainRemoveInactive, which should only be called for transient
domains. The check for !vm->persistent was accidentally removed by
commit 540c339.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovz: Adapt to driver rename
Michal Privoznik [Thu, 25 Jun 2015 07:36:41 +0000 (09:36 +0200)]
vz: Adapt to driver rename

In the e6d180f07fb06 commit the parallels driver was renamed to vz.
However, there was a commit merged later, which was sent to the list
before the rename. The other commit is 6de12b026b73. Fix all the
missing renames.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agojson: enhance parser test
Eric Blake [Mon, 22 Jun 2015 21:14:04 +0000 (15:14 -0600)]
json: enhance parser test

We already enable the parser option to detect invalid UTF-8, but
didn't test it.  Also, JSON states that behavior of an object
with a duplicated key is undefined; we chose to reject it, but
were not testing it.

With the enhanced tests in place, we can simplify yajl2
initialization by relying on parser defaults being sane.

* src/util/virjson.c (virJSONValueFromString): Simplify.
* tests/jsontest.c (mymain): Test more bad usage.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: even stricter trailing garbage detection
Eric Blake [Mon, 22 Jun 2015 21:01:15 +0000 (15:01 -0600)]
json: even stricter trailing garbage detection

Since older yajl ignores trailing garbage, a client can cause
problems by intentionally ending the wrapper array early. Since
we already track nesting, it's not too much harder to reject
invalid nesting pops.

* src/util/virjson. (_virJSONParser): Add field.
(virJSONValueFromString): Set witness.
(virJSONParserHandleEndArray): Use it to catch abuse.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: reject trailing garbage
Eric Blake [Mon, 22 Jun 2015 20:18:34 +0000 (14:18 -0600)]
json: reject trailing garbage

Yajl 2 has a nice feature that it can be configured whether to
allow multiple JSON objects parsed from a single stream, defaulting
to off.  And yajl 1.0.12 at least provided a way to tell if all
input bytes were parsed, or if trailing bytes remained after a
valid JSON object was parsed.  But we target RHEL 6 yajl 1.0.7,
which has neither of these.  So fake it by always parsing '[...]'
instead, so that trailing garbage either trips up the array parse,
or is easily detected when unwrapping the result.

* src/util/virjson.c (virJSONValueFromString): With older json,
wrap text to avoid trailing garbage.
* tests/jsontest.c (mymain): Add tests for this.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: reject javascript comments
Eric Blake [Mon, 22 Jun 2015 20:18:33 +0000 (14:18 -0600)]
json: reject javascript comments

We have been allowing javascript style comments in JSON ever
since commit 9428f2c (v0.7.5), but qemu doesn't send them, and
they are not strict JSON.  Reject them for now; if we can later
prove that it is worthwhile, we can reinstate it at that point
(or even make it conditional, by adding a bool parameter to
the libvirt entry point).

* src/util/virjson.c (virJSONValueFromString): Don't enable
comment parsing.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: cope with older yajl semantics
Eric Blake [Mon, 22 Jun 2015 20:18:32 +0000 (14:18 -0600)]
json: cope with older yajl semantics

Commit ceb496e5 fails on RHEL 6, with yajl 1.0.7, because that
version of yajl returns yajl_status_insufficient_data when the
parser is waiting for the rest of a token (this enum value was
dropped in yajl 2, so we have to wrap it).  It also exposes a
problem where older yajl silently ignores trailing garbage after
a successful parse, so this patch works around that by changing
the testsuite.  Another more invasive patch can add tighter
semantics to json parsing, but this is sufficient for a minimal
clean backport.

While touching this, fix up our error message cleanup. Yajl
documents that error messages produced by yajl_get_error()
MUST be cleaned with yajl_free_error(); this is certainly
true if we were to pass non-NULL allocator callbacks during
yajl_alloc(), but probably harmless in our usage of passing
NULL.  But better safe than sorry.

* src/util/virjson.c (virJSONValueFromString): Allow different
error code.  Use canonical cleanup of error message.
(VIR_YAJL_STATUS_OK): New helper macro.
* tests/jsontest.c (mymain): Wrap text to avoid difference in
trailing garbage handling

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agovz: fix syntax-check errors
Dmitry Guryanov [Wed, 24 Jun 2015 19:36:19 +0000 (22:36 +0300)]
vz: fix syntax-check errors

Remove braces around single-statement blocks in vz_sdk.c

9 years agovz: implementation of attach/detach network devices
Mikhail Feoktistov [Mon, 22 Jun 2015 16:57:00 +0000 (19:57 +0300)]
vz: implementation of attach/detach network devices

In this patch we add VIR_DOMAIN_DEVICE_NET handlers implementation
for domainAttachDevice and domainDetachDevice callbacks.

As soon as we don't support this operation for hypervisor type domains,
we implement this functionality for containers only.

In detach procedure we find network device by MAC address.
Because PrlVmDevNet_GetMacAddress() returns MAC as a UTF-8 encoded
null-terminated string, we use memcmp() to compare it.
Also we remove corresponding virtual network by prlsdkDelNetAdapter call.

9 years agoTest for the new watchdog model diag288
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:44 +0000 (11:28 +0200)]
Test for the new watchdog model diag288

Adding a test for the new watchdog model diag288.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoSupport for the new watchdog model diag288
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:43 +0000 (11:28 +0200)]
Support for the new watchdog model diag288

This patch provides support for the new watchdog model "diag288".

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
9 years agoTest for the new watchdog action inject-nmi
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:42 +0000 (11:28 +0200)]
Test for the new watchdog action inject-nmi

Adding a test for the new watchdog action "inject-nmi".

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoSupport for a new watchdog action inject-nmi
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:41 +0000 (11:28 +0200)]
Support for a new watchdog action inject-nmi

This patch provides support for a new watchdog action "inject-nmi" which
allows to define an inject of a non-maskable interrupt into a guest.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
9 years agoscsi: Force error for SCSI pools on virStorageBackendSCSIFindLUs failure
John Ferlan [Tue, 23 Jun 2015 18:40:31 +0000 (14:40 -0400)]
scsi: Force error for SCSI pools on virStorageBackendSCSIFindLUs failure

Related to :

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

Rather than ignore the return status from virStorageBackendSCSIFindLUs,
cause a failure to start the pool if a -1 is returned. Issue was noted
during testing of the bz for iscsi that 'scsi' and 'fc' pools don't fail.

9 years agovircapstest: Properly report error for failed tests
Michal Privoznik [Tue, 23 Jun 2015 11:05:01 +0000 (13:05 +0200)]
vircapstest: Properly report error for failed tests

There are two macros used in the test: CAPSCOMP and CAPS_EXPECT_ERR.
Both run a test case and if a failure occurred, they set the @ret
variable to a value of -1 to indicate an error. Well, that's what they
should do. Due to a typo, they set the variable to a positive one
effectively masking any failed test.

Then, we have couple of tests failing. Fix them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Adjust invalid secrettype setting during parse
John Ferlan [Mon, 15 Jun 2015 14:40:27 +0000 (10:40 -0400)]
conf: Adjust invalid secrettype setting during parse

Commit id '1feaccf0' attempted to handle an empty secrettype value; however,
it made a mistake by processing the secretType as if it was the original
secrettype string.  The 'secretType' is actually whether 'usage' or 'uuid'
was used.

Thus adjust part of the change to make the same check for def->src->type !=
VIR_STORAGE_TYPE_VOLUME before setting auth_secret_usage from the
secrettype field.

Luckily the aforementioned commits misdeed would be overwritten by the
call to virStorageTranslateDiskSourcePool

9 years agoconf: improve the way we format blkiotune and cputune
Luyao Huang [Tue, 23 Jun 2015 13:24:25 +0000 (21:24 +0800)]
conf: improve the way we format blkiotune and cputune

Just refactor existing code to use a child buf instead of
check all element before format <blkiotune> and <cputune>.
This will avoid the more and more bigger element check during
we introduce new elements in <blkiotune> and <cputune> in the
future.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agodocs: Fix trivial copy-paste error
Martin Kletzander [Wed, 24 Jun 2015 08:16:56 +0000 (10:16 +0200)]
docs: Fix trivial copy-paste error

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoImprove some errors for openconsole/channel
Luyao Huang [Mon, 15 Jun 2015 13:58:36 +0000 (21:58 +0800)]
Improve some errors for openconsole/channel

Functions like virDomainOpenConsole() and virDomainOpenChannel() accept
NULL as a dev_name parameter.  Try using alias for the error message if
dev_name is not specified.

Before:
  error: internal error: character device <null> is not using a PTY

After:
  error: internal error: character device serial0 is not using a PTY

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoconf: Enforce scheduler name when parsing XML
Peter Krempa [Tue, 23 Jun 2015 12:25:20 +0000 (14:25 +0200)]
conf: Enforce scheduler name when parsing XML

We require the scheduler name attribute in the schemas but the code
would actually be fine when it was omitted. Make it mandatory.

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

9 years agodocs: Properly mark acl.html dependencies
Michal Privoznik [Mon, 22 Jun 2015 15:17:38 +0000 (17:17 +0200)]
docs: Properly mark acl.html dependencies

The acl.html file includes aclperms.htmlinc which is generated.
However, acl.html is generated too from acl.html.tmp. And in fact,
this is the place where the aclperms file is needed. Fix the
dependency in Makefile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorage: Force setting of disk format type
John Ferlan [Mon, 8 Jun 2015 12:16:58 +0000 (08:16 -0400)]
storage: Force setting of disk format type

Commit id '832a9256' adjusted the code to recognize when the default
type of "unknown" was provided as the format type and to use "dos" if
found. Since the pool is built with "dos" and it could cause some
confusion when formatting the XML after building by seeing "unknown"
in the output, let's just adjust the pool's setting to "dos" so that
subsequent formats will see the value.

9 years agodocs: Adjust Disk storage rng
John Ferlan [Mon, 8 Jun 2015 12:15:17 +0000 (08:15 -0400)]
docs: Adjust Disk storage rng

Currently the grammar uses "none" for a "valid" Disk Storage Pool
format type; however, virStoragePoolFormatDisk uses "unknown" so
virt-xml-validate will fail to validate when "unknown" is found

9 years agoadmin: Fix mingw build by reordering includes
Martin Kletzander [Tue, 23 Jun 2015 11:22:15 +0000 (13:22 +0200)]
admin: Fix mingw build by reordering includes

By trying to lead the way of clean includes, I sorted the lines
alphabetically and that is a problem for mingw builds with gnulib.
As 'configmake.h' defines DATADIR and 'datatypes.h' transitively
includes 'winsock.h' that uses 'DATADIR' as a name for a struct,
it's enough to reorder those.

Even though this might be worked around in gnulib later on, this
fixes the build for now.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agodocs: Correct typos in scsi hostdev and address elements
Eric Farman [Wed, 17 Jun 2015 03:29:55 +0000 (23:29 -0400)]
docs: Correct typos in scsi hostdev and address elements

The type='scsi' parameter of an address element is ignored
if placed within a hostdev section, and rejected by the XML
schema used by virt-xml-validate. Remove it from the doc,
and correct a typo in the remaining address arguments.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agodocs: Fix XML schema handling of LUN address in hostdev tag
Eric Farman [Wed, 17 Jun 2015 03:29:54 +0000 (23:29 -0400)]
docs: Fix XML schema handling of LUN address in hostdev tag

Defining a domain with a SCSI disk attached via a hostdev
tag and a source address unit value longer than two digits
causes an error when editing the domain with virsh edit,
even if no changes are made to the domain definition.
The error suggests invalid XML, somewhere:

  # virsh edit lmb_guest
  error: XML document failed to validate against schema:
  Unable to validate doc against /usr/local/share/libvirt/schemas/domain.rng
  Extra element devices in interleave
  Element domain failed to validate content

The virt-xml-validate tool fails with a similar error:

  # virt-xml-validate lmb_guest.xml
  Relax-NG validity error : Extra element devices in interleave
  lmb_guest.xml:17: element devices: Relax-NG validity error :
  Element domain failed to validate content
  lmb_guest.xml fails to validate

The hostdev tag requires a source address to be specified,
which includes bus, target, and unit address attributes.
According to the SCSI Architecture Model spec (section
4.9 of SAM-2), a LUN address is 64 bits and thus could be
up to 20 decimal digits long.  Unfortunately, the XML
schema limits this string to just two digits.  Similarly,
the target field can be up to 32 bits in length, which
would be 10 decimal digits.

  # lsscsi -xx
  [0:0:19:0x4022401100000000]  disk    IBM      2107900          3.44 /dev/sda
  # lsscsi
  [0:0:19:1074872354]disk    IBM      2107900          3.44  /dev/sda
  # cat lmb_guest.xml
  <domain type='kvm'>
    <name>lmb_guest</name>
    <memory unit='MiB'>1024</memory>
  ...trimmed...
    <devices>
      <controller type='scsi' model='virtio-scsi' index='0'/>
      <hostdev mode='subsystem' type='scsi'>
        <source>
          <adapter name='scsi_host0'/>
          <address bus='0' target='19' unit='1074872354'/>
        </source>
      </hostdev>
  ...trimmed...

Since the reference unit and target fields are used in
several places in the XML schema, create a separate one
specific for SCSI Logical Units that will permit the
greater length.  This permits both the validation utility
and the virsh edit command to succeed when a hostdev
tag is included.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoConvert SCSI logical unit from unsigned int to unsigned long long
Eric Farman [Wed, 17 Jun 2015 03:29:53 +0000 (23:29 -0400)]
Convert SCSI logical unit from unsigned int to unsigned long long

The SCSI Architecture Model defines a logical unit address
as 64-bits in length, so change the field accordingly so
that the entire value could be stored.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
9 years agoPrint SCSI address attributes bus, target, unit as unsigned integer
Eric Farman [Wed, 17 Jun 2015 03:29:52 +0000 (23:29 -0400)]
Print SCSI address attributes bus, target, unit as unsigned integer

The address elements are all unsigned integers, so we should
use the appropriate print directive when printing it.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
9 years agoRead SCSI address attributes bus, target, unit as positive integer
Eric Farman [Wed, 17 Jun 2015 03:29:51 +0000 (23:29 -0400)]
Read SCSI address attributes bus, target, unit as positive integer

The SCSI address element attributes bus, target, and unit are expected
to be positive values, so make sure no one provides a negative value since
the value is stored as an unsigned.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
9 years agoqemu: simplify json parsing
Eric Blake [Sat, 20 Jun 2015 19:40:21 +0000 (13:40 -0600)]
qemu: simplify json parsing

Rather than grabbing an arbitrary JSON value and then checking
if it has the right type, we might as well request the correct
type to begin with.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONIOProcessEvent)
(qemuMonitorJSONCommandWithFd, qemuMonitorJSONHandleGraphics)
(qemuMonitorJSONGetStatus, qemuMonitorJSONExtractCPUInfo)
(qemuMonitorJSONGetVirtType, qemuMonitorJSONGetBalloonInfo)
(qemuMonitorJSONGetMemoryStats)
(qemuMonitorJSONDevGetBlockExtent)
(qemuMonitorJSONGetOneBlockStatsInfo)
(qemuMonitorJSONGetAllBlockStatsInfo)
(qemuMonitorJSONBlockStatsUpdateCapacityOne)
(qemuMonitorJSONBlockStatsUpdateCapacity)
(qemuMonitorJSONGetBlockExtent)
(qemuMonitorJSONGetMigrationStatusReply)
(qemuMonitorJSONGetDumpGuestMemoryCapability)
(qemuMonitorJSONAddFd, qemuMonitorJSONQueryRxFilterParse)
(qemuMonitorJSONExtractChardevInfo)
(qemuMonitorJSONDiskNameLookupOne)
(qemuMonitorJSONDiskNameLookup)
(qemuMonitorJSONGetAllBlockJobInfo)
(qemuMonitorJSONBlockIoThrottleInfo, qemuMonitorJSONGetVersion)
(qemuMonitorJSONGetMachines, qemuMonitorJSONGetCPUDefinitions)
(qemuMonitorJSONGetCommands, qemuMonitorJSONGetEvents)
(qemuMonitorJSONGetKVMState, qemuMonitorJSONGetObjectTypes)
(qemuMonitorJSONGetObjectListPaths)
(qemuMonitorJSONGetObjectProps, qemuMonitorJSONGetTargetArch)
(qemuMonitorJSONGetMigrationCapabilities)
(qemuMonitorJSONGetStringArray, qemuMonitorJSONAttachCharDev)
(qemuMonitorJSONGetCPUx86Data, qemuMonitorJSONGetIOThreads)
(qemuMonitorJSONGetMemoryDeviceInfo): Use shorter idioms.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: make it easier to type-check when getting from object
Eric Blake [Fri, 19 Jun 2015 23:13:03 +0000 (17:13 -0600)]
json: make it easier to type-check when getting from object

While working in qemu_monitor_json, I repeatedly found myself
getting a value then checking if it was an object.  Add some
wrappers to make this task easier.

* src/util/virjson.c (virJSONValueObjectGetByType)
(virJSONValueObjectGetObject, virJSONValueObjectGetArray): New
functions.
(virJSONValueObjectGetString, virJSONValueObjectGetNumberInt)
(virJSONValueObjectGetNumberUint)
(virJSONValueObjectGetNumberLong)
(virJSONValueObjectGetNumberUlong)
(virJSONValueObjectGetNumberDouble)
(virJSONValueObjectGetBoolean): Simplify.
(virJSONValueIsNull): Change return type.
* src/util/virjson.h: Reflect changes.
* src/libvirt_private.syms (virjson.h): Export them.
* tests/jsontest.c (testJSONLookup): New test.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: fully parse input string
Eric Blake [Fri, 19 Jun 2015 23:28:22 +0000 (17:28 -0600)]
json: fully parse input string

I was adding a JSON test, and was shocked to find out our parser
treated the input string of "1" as invalid JSON.  It turns out
that YAJL specifically documents that it buffers input, and that
if the last input read could be a prefix to a longer token, then
you have to explicitly tell the parser that the buffer has ended
before that token will be processed.

It doesn't help that yajl 2 renamed the function from what it was
in yajl 1.

* src/util/virjson.c (virJSONValueFromString): Complete parse, in
case buffer ends in possible token prefix.
* tests/jsontest.c (mymain): Expose the problem.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agotest: Switch to reference counting with testDomObjFromDomain
Peter Krempa [Tue, 16 Jun 2015 12:05:18 +0000 (14:05 +0200)]
test: Switch to reference counting with testDomObjFromDomain

Retrieve domain objects with reference and release them with
virDomainObjEndAPI.

9 years agotest: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags
Peter Krempa [Tue, 16 Jun 2015 08:10:59 +0000 (10:10 +0200)]
test: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags

The test driver copies the domain definition correctly so we can reuse
the helper.

9 years agovirsh: blockcopy: Report error if the copy job fails
Peter Krempa [Fri, 19 Jun 2015 13:43:02 +0000 (15:43 +0200)]
virsh: blockcopy: Report error if the copy job fails

When the block job would fail while watching it using the "--wait"
option for blockcopy, virsh would rather unhelpfully report:

$ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait

Now in mirroring phase

Add a special case when the block job vanishes while waiting for it to
finish to improve the message:

$ virsh blockcopy vm hdc /tmp/raw.img --granularity 8192 --verbose --wait
error: Block Copy unexpectedly failed

9 years agovirQEMUCapsComputeCmdFlags: Indent correctly
Michal Privoznik [Mon, 22 Jun 2015 08:54:56 +0000 (10:54 +0200)]
virQEMUCapsComputeCmdFlags: Indent correctly

There's a small formatting problem in the function. One line is
not correctly indented. Fix this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: caps: Fix syntax-check failure in version based capabilities
Peter Krempa [Mon, 22 Jun 2015 08:48:30 +0000 (10:48 +0200)]
qemu: caps: Fix syntax-check failure in version based capabilities

A single-line 'if' body should not be encased in curly braces. Our
syntax-check enforces it. Introduced in 7f3515b4bb677d0ead1887547efc844

9 years agoIntroduce QEMU_CAPS_ARM_VIRT_PCI
Pavel Fedin [Thu, 11 Jun 2015 06:40:53 +0000 (09:40 +0300)]
Introduce QEMU_CAPS_ARM_VIRT_PCI

This capability specifies that "virt" machine on ARM has PCI controller. Enabled when version is at least 2.3.0.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agolibxl: avoid freeing an uninitialised bitmap
Ian Campbell [Fri, 19 Jun 2015 16:33:30 +0000 (17:33 +0100)]
libxl: avoid freeing an uninitialised bitmap

If vm->def->cputune.nvcpupin is 0 in libxlDomainSetVcpuAffinities (as
seems to be the case on arm) then the VIR_FREE after cleanup: would be
operating on an uninitialised pointer in map.map.

Fix this by using libxl_bitmap_init and libxl_bitmap_dispose in the
appropriate places (like VIR_FREE, libxl_bitmap_dispose is also
idempotent, so there is no double free on exit from the loop).

libxl_bitmap_dispose is slightly preferable since it also sets
map.size back to 0, avoiding a potential source of confusion.

This fixes the crashes we've been seeing in the Xen automated tests on
ARM.

I had a glance at the handful of other users of libxl_bitmap and none
of them looked to have a similar issue.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
9 years agoupdate sheepdog client] update sheepdog client path
Vasiliy Tolstov [Thu, 18 Jun 2015 13:20:42 +0000 (16:20 +0300)]
update sheepdog client] update sheepdog client path

Nnever sheepdog versions have dog client binary
while old have collie. Check them both.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
9 years agoqemu: cancel drive mirrors when p2p connection breaks
Jiri Denemark [Mon, 1 Jun 2015 12:41:50 +0000 (14:41 +0200)]
qemu: cancel drive mirrors when p2p connection breaks

When a connection to the destination host during a p2p migration drops,
we know we will have to cancel the migration; it doesn't make sense to
waste resources by trying to finish the migration. We already do so
after sending "migrate" command to QEMU and we should do it while
waiting for drive mirrors to become ready too.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor qemuMigrationWaitForCompletion
Jiri Denemark [Thu, 28 May 2015 09:58:11 +0000 (11:58 +0200)]
qemu: Refactor qemuMigrationWaitForCompletion

Checking status of all part of migration and aborting it when something
failed is a complex thing which makes the waiting loop hard to read.
This patch moves all the checks into a separate function similarly to
what was done for drive mirror loops.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't pass redundant job name around
Jiri Denemark [Thu, 28 May 2015 09:17:17 +0000 (11:17 +0200)]
qemu: Don't pass redundant job name around

Instead of passing current job name to several functions which already
know what the current job is we can generate the name where we actually
need to use it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor qemuMigrationUpdateJobStatus
Jiri Denemark [Tue, 26 May 2015 12:37:30 +0000 (14:37 +0200)]
qemu: Refactor qemuMigrationUpdateJobStatus

Once we start waiting for migration events instead of polling
query-migrate, priv->job.current will not be regularly updated anymore
because we will get the current status directly from the events. Thus
virDomainGetJob{Info,Stats} will have to query QEMU, but they can't just
blindly update priv->job.current structure. This patch introduces
qemuMigrationFetchJobStatus which just fills in a caller supplied
structure and makes qemuMigrationUpdateJobStatus a tiny wrapper around
it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor qemuDomainGetJob{Info,Stats}
Jiri Denemark [Tue, 26 May 2015 11:24:44 +0000 (13:24 +0200)]
qemu: Refactor qemuDomainGetJob{Info,Stats}

Move common parts of qemuDomainGetJobInfo and qemuDomainGetJobStats into
a separate API (qemuDomainGetJobStatsInternal).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Do not poll for spice migration status
Jiri Denemark [Mon, 25 May 2015 14:57:49 +0000 (16:57 +0200)]
qemu: Do not poll for spice migration status

QEMU_CAPS_SEAMLESS_MIGRATION capability says QEMU supports
SPICE_MIGRATE_COMPLETED event. Thus we can just drop all code which
polls query-spice and replace it with waiting for the event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu_monitor: Wire up SPICE_MIGRATE_COMPLETED event
Jiri Denemark [Thu, 28 May 2015 11:35:06 +0000 (13:35 +0200)]
qemu_monitor: Wire up SPICE_MIGRATE_COMPLETED event

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use domain condition for asyncAbort
Jiri Denemark [Fri, 15 May 2015 13:59:49 +0000 (15:59 +0200)]
qemu: Use domain condition for asyncAbort

To avoid polling for asyncAbort flag changes.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Cancel disk mirrors after libvirtd restart
Jiri Denemark [Tue, 19 May 2015 15:28:25 +0000 (17:28 +0200)]
qemu: Cancel disk mirrors after libvirtd restart

When libvirtd is restarted during migration, we properly cancel the
ongoing migration (unless it managed to almost finished before the
restart). But if we were also migrating storage using NBD, we would
completely forget about the running disk mirrors.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor qemuMonitorBlockJobInfo
Jiri Denemark [Fri, 22 May 2015 11:33:49 +0000 (13:33 +0200)]
qemu: Refactor qemuMonitorBlockJobInfo

"query-block-jobs" QMP command returns all running block jobs at once,
while qemuMonitorBlockJobInfo would only report one. This is not very
nice in case we need to check several block jobs. This patch refactors
the monitor code to always parse all block jobs and store them in a
hash.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Make qemuMigrationCancelDriveMirror usable without async job
Jiri Denemark [Wed, 20 May 2015 08:28:37 +0000 (10:28 +0200)]
qemu: Make qemuMigrationCancelDriveMirror usable without async job

We don't have an async job when reconnecting to existing domains after
libvirtd restart.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoPass domain object to private data formatter/parser
Jiri Denemark [Tue, 19 May 2015 08:14:19 +0000 (10:14 +0200)]
Pass domain object to private data formatter/parser

So that they can format private data (e.g., disk private data) stored
elsewhere in the domain object.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't mess with disk->mirrorState
Jiri Denemark [Tue, 19 May 2015 06:44:16 +0000 (08:44 +0200)]
qemu: Don't mess with disk->mirrorState

This patch reverts commit 76c61cdca20c106960af033e5d0f5da70177af0f.

VIR_DOMAIN_DISK_MIRROR_STATE_ABORT says we asked for a block job to be
aborted rather than saying it was aborted. Let's just use
VIR_DOMAIN_DISK_MIRROR_STATE_NONE consistently whenever a block job
finishes since no caller depends on VIR_DOMAIN_DISK_MIRROR_STATE_ABORT
(anymore) to check whether a block job failed or it was cancelled.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Abort migration early if disk mirror failed
Jiri Denemark [Wed, 10 Jun 2015 09:00:00 +0000 (11:00 +0200)]
qemu: Abort migration early if disk mirror failed

Abort migration as soon as we detect that some of the disk mirrors
failed. There's no sense in trying to finish memory migration first.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Cancel storage migration in parallel
Jiri Denemark [Tue, 9 Jun 2015 21:50:36 +0000 (23:50 +0200)]
qemu: Cancel storage migration in parallel

Instead of cancelling disk mirrors sequentially, let's just call
block-job-cancel for all migrating disks and then wait until all
disappear.

In case we cancel disk mirrors at the end of successful migration we
also need to check all block jobs completed successfully. Otherwise we
have to abort the migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use domain condition for synchronous block jobs
Jiri Denemark [Thu, 14 May 2015 12:28:12 +0000 (14:28 +0200)]
qemu: Use domain condition for synchronous block jobs

By switching block jobs to use domain conditions, we can drop some
pretty complicated code in NBD storage migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Properly report failed migration
Jiri Denemark [Wed, 13 May 2015 16:08:50 +0000 (18:08 +0200)]
qemu: Properly report failed migration

Because we are polling we may detect some errors after we asked QEMU for
migration status even though they occurred before. If this happens and
QEMU reports migration completed successfully, we would happily report
the migration succeeded even though we should have cancelled it because
of the other error.

In practise it is not a big issue now but it will become a much bigger
issue once the check for storage migration status is moved inside the
loop in qemuMigrationWaitForCompletion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuBlockJobUpdate
Jiri Denemark [Mon, 11 May 2015 12:50:48 +0000 (14:50 +0200)]
qemu: Introduce qemuBlockJobUpdate

The wrapper is useful for calling qemuBlockJobEventProcess with the
event details stored in disk's privateData, which is the most likely
usage of qemuBlockJobEventProcess.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoconf: Introduce per-domain condition variable
Jiri Denemark [Tue, 26 May 2015 14:43:58 +0000 (16:43 +0200)]
conf: Introduce per-domain condition variable

Complex jobs, such as migration, need to monitor several events at once,
which is impossible when each of the event uses its own condition
variable. This patch adds a single condition variable to each domain
object. This variable can be used instead of the other event specific
conditions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirNetServerServiceClose: Don't leak sockets
Michal Privoznik [Thu, 18 Jun 2015 12:37:43 +0000 (14:37 +0200)]
virNetServerServiceClose: Don't leak sockets

Well, if a server is being destructed, all underlying services and
their sockets should disappear with it. But due to bug in our
implementation this is not the case. Yes, we are closing the sockets,
but that's not enough. We must also:

1) Unregister them from the event loop
2) Unref the service for each socket

The last step is needed, because each socket callback holds a
reference to the service object. Since in the first step we are
unregistering the callbacks, they no longer need the reference.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetSocket: Fix @watch corner case
Michal Privoznik [Thu, 18 Jun 2015 12:22:10 +0000 (14:22 +0200)]
virNetSocket: Fix @watch corner case

Although highly unlikely, nobody says that virEventAddHandle()
can't return 0 as a handle to socket callback. It can't happen
with our default implementation since all watches will have value
1 or greater, but users can register their own callback functions
(which can re-use unused watch IDs for instance). If this is the
case, weird things may happen.

Also, there's a little bug I'm fixing too, upon
virNetSocketRemoveIOCallback(), the variable holding callback ID
was not reset. Therefore calling AddIOCallback() once again would
fail. Not that we are doing it right now, but we might.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetSocketRemoveIOCallback: Be explicit about unref
Michal Privoznik [Thu, 18 Jun 2015 12:15:08 +0000 (14:15 +0200)]
virNetSocketRemoveIOCallback: Be explicit about unref

When going through the code I've notice that
virNetSocketAddIOCallback() increases the reference counter of
@socket. However, its counter part RemoveIOCallback does not. It took
me a while to realize this disproportion. The AddIOCallback registers
our own callback which eventually calls the desired callback and then
unref the @sock. Yeah, a bit complicated but it works. So, lets note
this hard learned fact in a comment in RemoveIOCallback().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodaemonSetupNetworking: Don't leak services
Michal Privoznik [Thu, 18 Jun 2015 12:11:21 +0000 (14:11 +0200)]
daemonSetupNetworking: Don't leak services

When setting up the daemon networking, new services are created. These
services then have sockets to listen on. Once created, the service
objects are added to corresponding server object. However, during that
process, server increases reference counter of the service object. So,
at the end of the function, we should decrease it again. This way the
service objects will have only 1 reference, but that's okay since
servers are the only objects having a reference.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolib: setvcpus: Remove bogus flag check
Peter Krempa [Tue, 16 Jun 2015 16:55:24 +0000 (18:55 +0200)]
lib: setvcpus: Remove bogus flag check

Since VIR_DOMAIN_AFFECT_CURRENT is 0 the flag check does not make sense
as masking @flags with 0 will always equal to false.

9 years agoscsi: Adjust return status from getBlockDevice
John Ferlan [Fri, 12 Jun 2015 11:22:34 +0000 (07:22 -0400)]
scsi: Adjust return status from getBlockDevice

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

Currently it's not possible to determine the difference between a
fatal memory allocation or failure to open/read the directory error
with a perhaps less fatal, I didn't find the "block" device in the
directory (which may be a disk entry without a block device).

In the case of the latter, we shouldn't cause failure to continue
searching in the caller (virStorageBackendSCSIFindLUs), rather we
should allow trying reading the next directory entry.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: selective block device migration
Pavel Boldin [Mon, 15 Jun 2015 22:42:11 +0000 (01:42 +0300)]
virsh: selective block device migration

Add `virsh migrate' option `--migrate-disks' that allows CLI user to
explicitly specify block devices to migrate.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: migration: selective block device migration
Pavel Boldin [Mon, 15 Jun 2015 22:42:10 +0000 (01:42 +0300)]
qemu: migration: selective block device migration

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

Implement a `migrate_disks' parameters for the QEMU driver. This multi-
value parameter can be used to explicitly specify what block devices
are to be migrated using the NBD server. Tunnelled migration using NBD
is to be done.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: add virTypedParamsAddStringList
Pavel Boldin [Mon, 15 Jun 2015 22:42:09 +0000 (01:42 +0300)]
util: add virTypedParamsAddStringList

The `virTypedParamsAddStringList' function provides interface to add a
NULL-terminated array of string values as a multi-value to the params.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>