]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoqemu: Don't bother user with libvirt-internal paths
Martin Kletzander [Wed, 6 Jan 2016 16:35:04 +0000 (17:35 +0100)]
qemu: Don't bother user with libvirt-internal paths

If user defines a virtio channel with UNIX socket backend and doesn't
care about the path for the socket (e.g. qemu-agent channel), we still
generate it into the persistent XML.  Moreover when then user renames
the domain, due to its persistent socket path saved into the per-domain
directory, it will not start.  So let's forget about old generated paths
and also stop putting them into the persistent definition.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: snapshot: Skip 'transaction' command when no disks are selected
Peter Krempa [Wed, 6 Jan 2016 12:56:47 +0000 (13:56 +0100)]
qemu: snapshot: Skip 'transaction' command when no disks are selected

When doing a memory-only snapshot libvirt would still issue the
'transaction' command without any disk. Skip it if it isn't necessary.

9 years agorbd: Do not append Ceph monitor port number 6789 if not provided
Wido den Hollander [Wed, 6 Jan 2016 10:36:39 +0000 (11:36 +0100)]
rbd: Do not append Ceph monitor port number 6789 if not provided

If no port number was provided for a storage pool libvirt defaults to
port 6789; however, librbd/librados already default to 6789 when no port
number is provided.

In the future Ceph will switch to a new port for the Ceph monitors since
port 6789 is already assigned to a different application by IANA.

Port 6789 is assigned to SMC-HTTPS and Ceph now has port 3300 assigned as
the 'Ceph monitor' port.

In this case it is the best solution to not hardcode any port number into
libvirt and let librados handle the connection.

Only if a user specifies a different port number we pass it down to librados,
otherwise we leave it blank.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
merge

9 years agorbd: Do not error out on a single image during pool refresh
Wido den Hollander [Wed, 6 Jan 2016 09:25:49 +0000 (10:25 +0100)]
rbd: Do not error out on a single image during pool refresh

It could happen that rbd_list() returns X names, but that while
refreshing the pool one of those RBD images is removed from Ceph
through a different route then libvirt.

We do not need to error out in such case, we can simply ignore the
volume and continue.

  error : volStorageBackendRBDRefreshVolInfo:289 :
    failed to open the RBD image 'vol-998': No such file or directory

It could also be that one or more Placement Groups (PGs) inside Ceph
are inactive due to a system failure.

If that happens it could be that some RBD images can not be refreshed
and a timeout will be raised by librados.

  error : volStorageBackendRBDRefreshVolInfo:289 :
    failed to open the RBD image 'vol-893': Connection timed out

Ignore the error and continue to refresh the rest of the pool's
contents.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Only close RBD image if it has been opened
Wido den Hollander [Wed, 6 Jan 2016 09:25:48 +0000 (10:25 +0100)]
rbd: Only close RBD image if it has been opened

It could be that we error out while the RBD image has not been
opened yet. This would cause us to call rbd_close() on pointer
which has not been initialized.

Set it to NULL by default and only close if it is not NULL.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agofix LSB part of virtlogd runlevel script
Olaf Hering [Wed, 2 Dec 2015 07:54:28 +0000 (07:54 +0000)]
fix LSB part of virtlogd runlevel script

Currently pkg build of master branch fails:

[  300s] + /usr/lib/rpm/brp-boot-scripts
[  300s] E: File `virtlogd' is missing `Required-Start', please add even if empty!
[  300s] W: File `virtlogd' is missing `Required-Stop', please add even if empty!
[  300s] E: File `virtlogd' has empty `Default-Start', please specify default runlevel(s)!
[  300s] ERROR: found one or more broken init or boot scripts, please fix them.
[  300s]        For more information about LSB headers please read the manual
[  300s]        page of of insserv by executing the command `man 8 insserv'.
[  300s]        If you don't understand this, mailto=werner@suse.de
[  300s] error: Bad exit status from /var/tmp/rpm-tmp.44965 (%install)

Add the required tags, fix the existing tags.
Use soft dependency "Should-Start" because virtlogd may work without network.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
9 years agovirtlogd: fix lock file path in initscript
Michael Chapman [Thu, 31 Dec 2015 05:09:12 +0000 (16:09 +1100)]
virtlogd: fix lock file path in initscript

The virtlogd initscript's lock file should go in /var/lock/subsys/, not
(the nonexistent) /var/log/subsys/.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agospec: chkconfig(8) and service(8) are in /sbin/, not /bin/
Michael Chapman [Thu, 31 Dec 2015 05:09:11 +0000 (16:09 +1100)]
spec: chkconfig(8) and service(8) are in /sbin/, not /bin/

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agospec: dbus-devel is needed as build dependency if polkit support is enabled
Michael Chapman [Thu, 31 Dec 2015 05:09:11 +0000 (16:09 +1100)]
spec: dbus-devel is needed as build dependency if polkit support is enabled

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agoqemu: Specify format= iff disk source is not empty
Michal Privoznik [Mon, 28 Dec 2015 14:13:52 +0000 (15:13 +0100)]
qemu: Specify format= iff disk source is not empty

Just recently, qemu forbade specifying format for sourceless
disks (qemu commit 39c4ae941ed992a3bb5). It kind of makes sense.
If there's no file to open, why specify its format. Anyway, I
have a domain like this:

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

and obviously I am unable to start it. Therefore, a fix on our
side is needed too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorage: Clean up error path for create buildPool failure
John Ferlan [Fri, 18 Dec 2015 12:45:01 +0000 (07:45 -0500)]
storage: Clean up error path for create buildPool failure

Commit id 'aeb1078ab' added a buildPool option and failure path which
calls virStoragePoolObjRemove, which unlocks the pool, clears the 'pool'
variable, and goto cleanup.  However, at cleanup virStoragePoolObjUnlock
is called without check if pool is non NULL.

9 years agolibvirt-domain: fix dxml passing in virDomainMigrateToURI2
Ján Tomko [Tue, 5 Jan 2016 12:35:48 +0000 (13:35 +0100)]
libvirt-domain: fix dxml passing in virDomainMigrateToURI2

The refactoring in commit a26669d silently ignored the dxml
parameter of virDomainMigrateToURI2.

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

9 years agoconf: Rework code around 'append' attribute
Dmitry Mishin [Tue, 29 Dec 2015 16:55:26 +0000 (19:55 +0300)]
conf: Rework code around 'append' attribute

Commit id '70ffa02fc' added the data.file.append option to some
VIR_DOMAIN_CHR_TYPE_FILE cases in switch statements allowing the
code to "fall through" for the remainder of the cases. This causes
angst in code profiling tools, like Coverity since there is no break;
followed by more case conditions. Adjust the logic to be more specific
within each case.

Signed-off-by: Dmitry Mishin <dim@virtuozzo.com>
9 years agoUse tristate constants for new 'append' field
Dmitry Mishin [Tue, 5 Jan 2016 12:25:38 +0000 (07:25 -0500)]
Use tristate constants for new 'append' field

For completeness, use the VIR_TRISTATE_SWITCH_ABSENT for data.file.append
comparisons. Commit ids '70ffa02f' and '53a15aed' just went with the non
zero comparison.

9 years agodocs: Describe new 'append' attribute for chardevs source
Dmitry Mishin [Thu, 24 Dec 2015 16:40:26 +0000 (19:40 +0300)]
docs: Describe new 'append' attribute for chardevs source

Signed-off-by: Dmitry Mishin <dim@virtuozzo.com>
9 years agoschema: interleave domain name and uuid with other elements
Ján Tomko [Thu, 17 Dec 2015 12:43:58 +0000 (13:43 +0100)]
schema: interleave domain name and uuid with other elements

Allow <name> and <uuid> anywhere under <domain>, not just at the top:

error:XML document failed to validate against schema: Unable to validate
doc against /usr/share/libvirt/schemas/domain.rng
Expecting an element name, got nothing
Invalid sequence in interleave
Element domain failed to validate content

Introduced with the first RelaxNG schema in commit c642103.

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

9 years agoFix formatting for virDomainGetCPUStats docstring
Martin Kletzander [Tue, 5 Jan 2016 07:56:31 +0000 (08:56 +0100)]
Fix formatting for virDomainGetCPUStats docstring

We have few code samples there that are almost unreadable when formatted
because they are not indented properly.  By indenting them they are
formatted as code and hence quite readable.  Also adjust descriptions to
be comments and add semicolons so that the code sample looks like sample
of a working code.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Fix return value of qemuDomainGetBlockJobInfo
Michal Privoznik [Mon, 4 Jan 2016 14:49:56 +0000 (15:49 +0100)]
qemu: Fix return value of qemuDomainGetBlockJobInfo

While reviewing 1b43885d1784640 I've noticed a virReportError()
followed by a goto endjob; without setting the correct return
value. Problem is, if block job is so fast that it's bandwidth
does not fit into ulong, an error is reported. However, by that
time @ret is already set to 1 which means success. Since the
scenario can be hardly considered successful, we should return a
value meaning error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agomaint: update to latest gnulib
Eric Blake [Mon, 4 Jan 2016 20:45:51 +0000 (13:45 -0700)]
maint: update to latest gnulib

Required for the copyright year bump to keep 'make syntax-check'
happy, and also pulls in several portability fixes.

* .gnulib: Update to latest.
* bootstrap: Resync from upstream.
* gnulib/local/m4/ssize_t.m4.diff: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agodocs: update to properly reflect meaning of fields in log filter
Laine Stump [Mon, 21 Dec 2015 15:53:57 +0000 (10:53 -0500)]
docs: update to properly reflect meaning of fields in log filter

The documentation (and comment in libvirtd.conf) says that the text in
a log filter is compared to the "source file name", and gives the
example of "util/json", but this is not correct (at least not since
commit 2835c1e, possibly earlier). It is instead compared to the
string given in the VIR_LOG_INIT() macro invocation at the top of each
source file, which is always "similar to but not the same as" the
source file name (in the example above, the proper name is
"util.json", while the file name is "util/virjson.c"). This patch
corrects the misstatement in both the documentation and in
libvirtd.conf.

9 years agoutil: reduce debug log in virPCIGetVirtualFunctions()
Laine Stump [Sun, 20 Dec 2015 22:58:58 +0000 (17:58 -0500)]
util: reduce debug log in virPCIGetVirtualFunctions()

Due to debug logs like this:

  virPCIGetDeviceAddressFromSysfsLink:2432 : Attempting to resolve device path from device link '/sys/class/net/eth1/device/virtfn6'
  logStrToLong_ui:2369 : Converted '0000:07:00.7' to unsigned int 0
  logStrToLong_ui:2369 : Converted '07:00.7' to unsigned int 7
  logStrToLong_ui:2369 : Converted '00.7' to unsigned int 0
  logStrToLong_ui:2369 : Converted '7' to unsigned int 7
  virPCIGetDeviceAddressFromSysfs:1947 : virPCIDeviceAddress 0000:07:00.7
  virPCIGetVirtualFunctions:2554 : Found virtual function 7

printed *once for each SR-IOV Virtual Function* of a Physical Function
each time libvirt retrieved the list of VFs (so if the system has 128
VFs, there would be 900 lines of log for each call), the debug logs on
any system with a large number of VFs was dominated by "information"
that was possibly useful for debugging when the code was being
written, but is now useless for debugging of any problem on a running
system, and only serves to obscure the real useful information. This
overkill has no place in production code, so this patch removes it.

9 years agoutil: improve error reporting in virNetDevVPortProfileGetStatus
Laine Stump [Fri, 18 Dec 2015 21:40:29 +0000 (16:40 -0500)]
util: improve error reporting in virNetDevVPortProfileGetStatus

The previous error message just indicated that the desired response
couldn't be found, this patch tells what was desired, as well as
listing out the entire table that had been in the netlink response, to
give some kind of idea why it failed.

9 years agoutil: report the MAC address that couldn't be set
Laine Stump [Fri, 18 Dec 2015 17:08:54 +0000 (12:08 -0500)]
util: report the MAC address that couldn't be set

I noticed in a log file that we had failed to set a MAC address. The
log said which interface we were trying to set, but didn't give the
offending MAC address, which could have been useful in determining the
source of the problem. This patch modifies all three places in the
code that set MAC addresses to report the failed MAC as well as
interface.

9 years agorbd: Return VIR_STORAGE_FILE_RAW as format for RBD volumes
Wido den Hollander [Thu, 24 Dec 2015 12:34:58 +0000 (13:34 +0100)]
rbd: Return VIR_STORAGE_FILE_RAW as format for RBD volumes

This used to return 'unkown' and that was not correct.

A vol-dumpxml now returns:

<volume type='network'>
  <name>image3</name>
  <key>libvirt/image3</key>
  <source>
  </source>
  <capacity unit='bytes'>10737418240</capacity>
  <allocation unit='bytes'>10737418240</allocation>
  <target>
    <path>libvirt/image3</path>
    <format type='raw'/>
  </target>
</volume>

The RBD driver will now error out if a different format than RAW
is provided when creating a volume.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agostorage: do not leak storage pool XML filename
Michael Chapman [Thu, 31 Dec 2015 06:04:40 +0000 (17:04 +1100)]
storage: do not leak storage pool XML filename

Valgrind complained:

==28277== 38 bytes in 1 blocks are definitely lost in loss record 298 of 957
==28277==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==28277==    by 0x82D7F57: __vasprintf_chk (in /lib64/libc-2.12.so)
==28277==    by 0x52EF16A: virVasprintfInternal (stdio2.h:199)
==28277==    by 0x52EF25C: virAsprintfInternal (virstring.c:514)
==28277==    by 0x52B1FA9: virFileBuildPath (virfile.c:2831)
==28277==    by 0x19B1947C: storageDriverAutostart (storage_driver.c:191)
==28277==    by 0x19B196A7: storageStateAutoStart (storage_driver.c:307)
==28277==    by 0x538527E: virStateInitialize (libvirt.c:793)
==28277==    by 0x11D7CF: daemonRunStateInit (libvirtd.c:947)
==28277==    by 0x52F4694: virThreadHelper (virthread.c:206)
==28277==    by 0x6E08A50: start_thread (in /lib64/libpthread-2.12.so)
==28277==    by 0x82BE93C: clone (in /lib64/libc-2.12.so)

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agoqemu: do not leak NBD disk data in migration cookie
Michael Chapman [Thu, 31 Dec 2015 06:04:39 +0000 (17:04 +1100)]
qemu: do not leak NBD disk data in migration cookie

Valgrind complained:

==18990== 20 (16 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 188 of 996
==18990==    at 0x4A057BB: calloc (vg_replace_malloc.c:593)
==18990==    by 0x5292E9B: virAllocN (viralloc.c:191)
==18990==    by 0x2221E731: qemuMigrationCookieXMLParseStr (qemu_migration.c:1012)
==18990==    by 0x2221F390: qemuMigrationEatCookie (qemu_migration.c:1413)
==18990==    by 0x222228CE: qemuMigrationPrepareAny (qemu_migration.c:3463)
==18990==    by 0x22224121: qemuMigrationPrepareDirect (qemu_migration.c:3865)
==18990==    by 0x22251C25: qemuDomainMigratePrepare3Params (qemu_driver.c:12414)
==18990==    by 0x5389EE0: virDomainMigratePrepare3Params (libvirt-domain.c:5107)
==18990==    by 0x1278DB: remoteDispatchDomainMigratePrepare3ParamsHelper (remote.c:5425)
==18990==    by 0x53FF287: virNetServerProgramDispatch (virnetserverprogram.c:437)
==18990==    by 0x540523D: virNetServerProcessMsg (virnetserver.c:135)
==18990==    by 0x54052C7: virNetServerHandleJob (virnetserver.c:156)
==18990==
==18990== 20 (16 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 189 of 996
==18990==    at 0x4A057BB: calloc (vg_replace_malloc.c:593)
==18990==    by 0x5292E9B: virAllocN (viralloc.c:191)
==18990==    by 0x2221E731: qemuMigrationCookieXMLParseStr (qemu_migration.c:1012)
==18990==    by 0x2221F390: qemuMigrationEatCookie (qemu_migration.c:1413)
==18990==    by 0x222249D2: qemuMigrationRun (qemu_migration.c:4395)
==18990==    by 0x22226365: doNativeMigrate (qemu_migration.c:4693)
==18990==    by 0x22228E45: qemuMigrationPerform (qemu_migration.c:5553)
==18990==    by 0x2225144B: qemuDomainMigratePerform3Params (qemu_driver.c:12621)
==18990==    by 0x539F5D8: virDomainMigratePerform3Params (libvirt-domain.c:5206)
==18990==    by 0x127305: remoteDispatchDomainMigratePerform3ParamsHelper (remote.c:5557)
==18990==    by 0x53FF287: virNetServerProgramDispatch (virnetserverprogram.c:437)
==18990==    by 0x540523D: virNetServerProcessMsg (virnetserver.c:135)

If we're replacing the NBD data, it's simplest to free the old object
(including the disk list) and allocate a new one.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agoqemu: do not copy out non-existent block job info
Michael Chapman [Thu, 31 Dec 2015 06:04:38 +0000 (17:04 +1100)]
qemu: do not copy out non-existent block job info

Valgrind complained:

==23975== Conditional jump or move depends on uninitialised value(s)
==23975==    at 0x22255FA6: qemuDomainGetBlockJobInfo (qemu_driver.c:16538)
==23975==    by 0x538E97C: virDomainGetBlockJobInfo (libvirt-domain.c:9685)
==23975==    by 0x12F740: remoteDispatchDomainGetBlockJobInfoHelper (remote.c:2834)
==23975==    by 0x53FF287: virNetServerProgramDispatch (virnetserverprogram.c:437)
==23975==    by 0x540523D: virNetServerProcessMsg (virnetserver.c:135)
==23975==    by 0x54052C7: virNetServerHandleJob (virnetserver.c:156)
==23975==    by 0x52F515B: virThreadPoolWorker (virthreadpool.c:145)
==23975==    by 0x52F4668: virThreadHelper (virthread.c:206)
==23975==    by 0x6E08A50: start_thread (in /lib64/libpthread-2.12.so)
==23975==    by 0x82BE93C: clone (in /lib64/libc-2.12.so)
==23975==
==23975== Conditional jump or move depends on uninitialised value(s)
==23975==    at 0x22255FB4: qemuDomainGetBlockJobInfo (qemu_driver.c:16542)
==23975==    by 0x538E97C: virDomainGetBlockJobInfo (libvirt-domain.c:9685)
==23975==    by 0x12F740: remoteDispatchDomainGetBlockJobInfoHelper (remote.c:2834)
==23975==    by 0x53FF287: virNetServerProgramDispatch (virnetserverprogram.c:437)
==23975==    by 0x540523D: virNetServerProcessMsg (virnetserver.c:135)
==23975==    by 0x54052C7: virNetServerHandleJob (virnetserver.c:156)
==23975==    by 0x52F515B: virThreadPoolWorker (virthreadpool.c:145)
==23975==    by 0x52F4668: virThreadHelper (virthread.c:206)
==23975==    by 0x6E08A50: start_thread (in /lib64/libpthread-2.12.so)
==23975==    by 0x82BE93C: clone (in /lib64/libc-2.12.so)

If no matching block job is found, qemuMonitorGetBlockJobInfo returns 0
and we should not write anything to the caller-supplied
virDomainBlockJobInfo pointer.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
9 years agotests: Make test-wrap-argv.pl executable
Michal Privoznik [Tue, 29 Dec 2015 08:37:35 +0000 (09:37 +0100)]
tests: Make test-wrap-argv.pl executable

While 'perl test-wrap-argv.pl' is not too long,
'./test-wrap-argv.pl' is shorter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotools: Disable virt-login-shell on mingw
Michal Privoznik [Sun, 20 Dec 2015 08:16:33 +0000 (09:16 +0100)]
tools: Disable virt-login-shell on mingw

So, after bec787ee9da we are building virt-login-shell
independent of LXC driver. This is nice, but the binary is
enabled by default which makes no sense on mingw. In fact, it
triggers some compilation errors there:

  CC       virt_login_shell-virt-login-shell.o
../../tools/virt-login-shell.c: In function 'main':
../../tools/virt-login-shell.c:289:15: error: implicit declaration of function 'sysconf' [-Werror=implicit-function-declaration]
     openmax = sysconf(_SC_OPEN_MAX);
               ^
../../tools/virt-login-shell.c:289:5: error: nested extern declaration of 'sysconf' [-Werror=nested-externs]
     openmax = sysconf(_SC_OPEN_MAX);
     ^
../../tools/virt-login-shell.c:289:23: error: '_SC_OPEN_MAX' undeclared (first use in this function)
     openmax = sysconf(_SC_OPEN_MAX);
                       ^
../../tools/virt-login-shell.c:289:23: note: each undeclared identifier is reported only once for each function it appears in
cc1: all warnings being treated as errors

While we could workaround sysconf(_SC_OPEN_MAX) issue, the binary
itself makes no sense on systems where no LXC can be spawned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotools: Include PIE_LDFLAGS at the correct place
Michal Privoznik [Sun, 20 Dec 2015 08:01:02 +0000 (09:01 +0100)]
tools: Include PIE_LDFLAGS at the correct place

This is no functional change, but I find it disturbing that
something_LDADD contains PIE_LDFLAGS while something_LDFLAGS
doesn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosysconf: Include unistd.h
Michal Privoznik [Sun, 20 Dec 2015 07:27:21 +0000 (08:27 +0100)]
sysconf: Include unistd.h

The manpage for sysconf() suggest including unistd.h as the
function is declared there. Even though we are not hitting any
compile issues currently, let's include the correct header file
instead of relying on some hidden include chain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirStorageVolWipe: Document that wiping journaled FS is useless
Michal Privoznik [Thu, 17 Dec 2015 10:06:51 +0000 (11:06 +0100)]
virStorageVolWipe: Document that wiping journaled FS is useless

So you have a libvirt volume that you want to wipe out. But lets
say that the volume is actually a file stored on a journaled
filesystem. Overwriting it with zeroes or a pattern does not mean
that corresponding physical location on the disk is overwritten
too, due to journaling. It's the same story with network based
volumes, copy-on-write filesystems, and so on. Since there is no
way that an userland application can write onto specific areas on
disk, all that we can do is document the fact.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz: BUG: fix connecting hang in case of init failure
Maxim Nestratov [Thu, 24 Dec 2015 12:58:59 +0000 (15:58 +0300)]
vz: BUG: fix connecting hang in case of init failure

In case of prlsdkLoadDomains fails, vzOpenDefault should
clear connection privateData pointer every time its
memory is actually freed.
Also it is not necessary to call vzConnectClose if a call
to vzOpenDefault fails, because they both make cleanup of
connection privateData.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agoqemu: Process new 'append' attribute for char dev with output to a file
Dmitry Mishin [Thu, 24 Dec 2015 14:27:55 +0000 (17:27 +0300)]
qemu: Process new 'append' attribute for char dev with output to a file

By default, QEMU truncates serial file on open. Sometimes, it could be weird -
for example, when we are trying to investigate some event, which occured several
restarts ago. This patch adds an ability to preserve previous content.

Signed-off-by: Dmitry Mishin <dim@virtuozzo.com>
9 years agoconf: Add new 'append' attribute for chardevs with file source
Dmitry Mishin [Thu, 24 Dec 2015 14:27:54 +0000 (17:27 +0300)]
conf: Add new 'append' attribute for chardevs with file source

Currently, there is no possibility for user to specify desired behaviour of
output to file - truncate or append. This patch adds an ability to explicitly
specify that user wants to preserve file's content on reopen.

Signed-off-by: Dmitry Mishin <dim@virtuozzo.com>
9 years agotests: add qemu 2.6 caps test
Dmitry Mishin [Thu, 24 Dec 2015 14:27:53 +0000 (17:27 +0300)]
tests: add qemu 2.6 caps test

Signed-off-by: Dmitry Mishin <dim@virtuozzo.com>
9 years agovz: support additional flags in domain undefine
Maxim Nestratov [Tue, 22 Dec 2015 15:29:40 +0000 (18:29 +0300)]
vz: support additional flags in domain undefine

Implement VIR_DOMAIN_UNDEFINE_MANAGED_SAVE and
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA flags support.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: move prlsdkCleanupBridgedNet after domain deletion
Maxim Nestratov [Tue, 22 Dec 2015 15:29:39 +0000 (18:29 +0300)]
vz: move prlsdkCleanupBridgedNet after domain deletion

prlsdkCleanupBridgedNet call should be made strongly after
any actual domain deletion accurs. By doing this we avoid
any potential problems connected with second undefine call
when it is made after first one fails by some reason, and
we detect that network is already deleted.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: delete domains when undefine is called
Maxim Nestratov [Tue, 22 Dec 2015 15:29:38 +0000 (18:29 +0300)]
vz: delete domains when undefine is called

Currently vz driver unregisters domains when undefine is called,
which is wrong because it contradicts with expected behavior.
All vz domains are persistent, which means that when one is
defined a new bundle directory containing meta data is created.
Undefining domains in a way we do now leaves those directories
undeleted, which prevents subsequent define call for the same
domain xml. I.e. the following sequence define->undefine->define
doesn't work now.
The patch fixes the problem by calling PrlVm_Delete instead of
PrlVm_Unreg detaching all disks prior actually doing this to
prevent images deletion.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agohostdev: Emit debug messages while handling PCI hostdevs
Andrea Bolognani [Wed, 16 Dec 2015 15:32:37 +0000 (16:32 +0100)]
hostdev: Emit debug messages while handling PCI hostdevs

Both detach and reattach are complex operations involving several steps,
and it can be useful to be able to follow along by reading the log.

9 years agohostdev: Only rollback detach of managed devices on error
Andrea Bolognani [Thu, 17 Dec 2015 14:11:27 +0000 (15:11 +0100)]
hostdev: Only rollback detach of managed devices on error

Since we don't detach unmanaged devices before attaching them to a
domain, we shouldn't reattach them to rollback an error either.

9 years agohostdev: Mark PCI devices as inactive as they're detached
Andrea Bolognani [Thu, 17 Dec 2015 10:54:14 +0000 (11:54 +0100)]
hostdev: Mark PCI devices as inactive as they're detached

We want to eventually factor out the code dealing with device detaching
and reattaching, so that we can share it and make sure it's called eg.
when 'virsh nodedev-detach' is used.

For that to happen, it's important that the lists of active and inactive
PCI devices are updated every time a device changes its state.

Instead of passing NULL as the last argument of virPCIDeviceDetach() and
virPCIDeviceReattach(), pass the proper list so that it can be updated.

9 years agopci: Introduce virPCIStubDriver enumeration
Andrea Bolognani [Fri, 23 Oct 2015 09:54:07 +0000 (11:54 +0200)]
pci: Introduce virPCIStubDriver enumeration

This replaces the virPCIKnownStubs string array that was used
internally for stub driver validation.

Advantages:

  * possible values are well-defined
  * typos in driver names will be detected at compile time
  * avoids having several copies of the same string around
  * no error checking required when setting / getting value

The names used mirror those in the
virDomainHostdevSubsysPCIBackendType enumeration.

9 years agopci: Remove 'reprobe' parameter from virPCIDeviceUnbind()
Andrea Bolognani [Thu, 29 Oct 2015 15:09:54 +0000 (16:09 +0100)]
pci: Remove 'reprobe' parameter from virPCIDeviceUnbind()

The value is not inspected inside the function, so it makes more
sense for the caller to change the device's setting explicitly.

9 years agopci: Remove redundant parameter from virPCIDeviceBindToStub()
Andrea Bolognani [Thu, 22 Oct 2015 16:15:11 +0000 (18:15 +0200)]
pci: Remove redundant parameter from virPCIDeviceBindToStub()

This internal function supports, in theory, binding to a different
stub driver than the one the PCI device has been configured to use.

In practice, it is only ever called like

  virPCIDeviceBindToStub(dev, dev->stubDriver);

which makes its second parameter redundant. Get rid of it, along
with the extra string copy required to support it.

9 years agoRevert "admin: Rename virAdmConnect to virAdmDaemon"
Erik Skultety [Thu, 10 Dec 2015 12:46:45 +0000 (13:46 +0100)]
Revert "admin: Rename virAdmConnect to virAdmDaemon"

Commmit df8192aa introduced admin related rename and some minor
(caused by automated approach, aka sed) and some more severe isues along with
it. First reason to revert is the inconsistency with libvirt library.
Although we deal with the daemon directly rather than with a specific
hypervisor, we still do have a connection. That being said, contributors might
get under the impression that AdmDaemonNew would spawn/start a new daemon
(since it's admin API, why not...), or AdmDaemonClose would do the exact
opposite or they might expect DaemonIsAlive report overall status of the daemon
which definitely isn't the case.
The second reason to revert this patch is renaming virt-admin client. The
client tool does not necessarily have to reflect the names of the API's it's
using in his internals. An example would be 's/vshAdmConnect/vshAdmDaemon'
where noone can be certain of what the latter function really does. The former
is quite expressive about some connection magic it performs, but the latter does
not say anything, especially when vshAdmReconnect and vshAdmDisconnect were
left untouched.

9 years agoXen: support maxvcpus in xm and xl config
Jim Fehlig [Tue, 15 Dec 2015 21:47:40 +0000 (14:47 -0700)]
Xen: support maxvcpus in xm and xl config

From: Ian Campbell <ian.campbell@citrix.com>

xend prior to 4.0 understands vcpus as maxvcpus and vcpu_avail
as a bit map of which cpus are online (default is all).

xend from 4.0 onwards understands maxvcpus as maxvcpus and
vcpus as the number which are online (from 0..N-1). The
upstream commit (68a94cf528e6 "xm: Add maxvcpus support")
claims that if maxvcpus is omitted then the old behaviour
(i.e. obeying vcpu_avail) is retained, but AFAICT it was not,
in this case vcpu==maxcpus==online cpus. This is good for us
because handling anything else would be fiddly.

This patch changes parsing of the virDomainDef maxvcpus and vcpus
entries to use the corresponding 'maxvcpus' and 'vcpus' settings
from xm and xl config. It also drops use of the old Xen 3.x
'vcpu_avail' setting.

The change also removes the maxvcpus limit of MAX_VIRT_VCPUS (since
maxvcpus is simply a count, not a bit mask), which is particularly
crucial on ARM where MAX_VIRT_CPUS == 1 (since all guests are
expected to support vcpu placement, and therefore only the boot
vcpu's info lives in the shared info page).

Existing tests adjusted accordingly, and new tests added for the
'maxvcpus' setting.

9 years agovirsh: Add --delete-snapshots flag for undefine and vol-delete
John Ferlan [Wed, 2 Dec 2015 23:04:04 +0000 (18:04 -0500)]
virsh: Add --delete-snapshots flag for undefine and vol-delete

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

Commit id '3c7590e0a' added the flag to the rbd backend, but provided
no means via virsh to use the flag.  This patch adds a '--delete-snapshots'
option to both the "undefine" and "vol-delete" commands.

For "undefine", the flag is combined with the "--remove-all-storage" flag
in order to add the appropriate flag for the virStorageVolDelete call;
whereas, for the "vol-delete" command, just the flag is sufficient since
it's only operating on one volume.

Currently only supported for rbd backends.

9 years agolibvirt: Add virStorageVolDeleteFlags to virStorageVolDelete
John Ferlan [Wed, 2 Dec 2015 22:00:46 +0000 (17:00 -0500)]
libvirt: Add virStorageVolDeleteFlags to virStorageVolDelete

Although they've been present for quite a while, they weren't added
to the API definition, so add them there to make it clearer.

Currently only the RBD backend even checks for any flags.

9 years agostorage: Add virCheckFlags to virStorageBackendRBDDeleteVol
John Ferlan [Wed, 2 Dec 2015 21:38:50 +0000 (16:38 -0500)]
storage: Add virCheckFlags to virStorageBackendRBDDeleteVol

The initial commit '74951eade' did not include the proper check for whether
any flags are supported by the driver.

Even though the driver doesn't support VIR_STORAGE_VOL_DELETE_ZEROED,
it still checks and allows the processing to continue

Also add the new VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS since it is handled
as of commit id '3c7590e0a'.

9 years agolxc_cgroup: Add check for NULL cgroup before AddTask call
John Ferlan [Fri, 18 Dec 2015 13:25:47 +0000 (08:25 -0500)]
lxc_cgroup: Add check for NULL cgroup before AddTask call

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

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

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

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

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

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

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

Remove use of XEND_CONFIG_VERSION_* in xend_internal.c

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

Remove use of XEND_CONFIG_VERSION_* in the Xen unified driver.

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

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

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

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

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

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

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

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

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

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

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

Remove use of XEND_CONFIG_VERSION_* in xm parser/formatter.

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

Remove use of XEND_CONFIG_VERSION_* from xenconfig/xen_common.c

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

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

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

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

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

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

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

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

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

Remove xm config tests for old xend 3.0.2 config format.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The new flags are:

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD
      Perform buildPool without any flags passed.

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE
      Perform buildPool using VIR_STORAGE_POOL_BUILD_OVERWRITE flag.

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE
      Perform buildPool using VIR_STORAGE_POOL_BUILD_NO_OVERWRITE flag.

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

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

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

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

This function is no longer used outside domain_addr.c

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

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

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

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

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

Move the error inside qemuDomainAttachControllerDevice and delete this
wrapper.

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

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

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

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

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

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

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

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

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

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

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

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

It is not used by the caller.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Cygwin cannot build the vbox driver yet:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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