]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoqemu: reject rather than hang on blockcommit of active layer
Eric Blake [Tue, 27 May 2014 23:07:08 +0000 (17:07 -0600)]
qemu: reject rather than hang on blockcommit of active layer

qemu 2.0 added the ability to commit the active layer, but slightly
differently than what libvirt had been anticipating in its
implementation of the virDomainBlockCommit call.  As a result, if
you attempt to do a 'virsh blockcommit $dom vda', qemu gets into a
state where it is waiting on libvirt to end the job, while libvirt
is waiting on qemu to end the job, and the guest is effectively
hung with regards to further commands for that block device.

I have patches coming down the pipeline that will add full support
for blockcommit of the active layer when coupled with qemu 2.0 or
later; but they depend on Peter's improvements to block job handling
and form enough of a new feature that they are not ready for
inclusion in the 1.2.5 release.  So for now, just reject the
attempt, rather than letting the user get stuck.  This is no worse
than the behavior of qemu 1.7 rejecting the job.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Reject active
commit.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodoc: fix documentation of virDomainSet(Get)Metadata
Dan Kenigsberg [Wed, 28 May 2014 10:15:01 +0000 (11:15 +0100)]
doc: fix documentation of virDomainSet(Get)Metadata

The documentation of the functions should match the argument name in the actual
function signature.

Signed-off-by: Dan Kenigsberg <danken@redhat.com>
10 years agoqemu: Fix specifying char devs for PPC
Olivia Yin [Tue, 27 May 2014 05:44:14 +0000 (13:44 +0800)]
qemu: Fix specifying char devs for PPC

QEMU ppce500 board uses the legacy -serial option.

Other PPC boards don't give any way to explicitly wire in a -chardev
except pseries which uses -device spapr-vty with -chardev.

Add test case for -serial option for ppce500

Signed-off-by: Olivia Yin <Hong-Hua.Yin@freescale.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agochange machine name ppce500v2 to ppce500
Olivia Yin [Tue, 27 May 2014 05:44:13 +0000 (13:44 +0800)]
change machine name ppce500v2 to ppce500

ppce500v2 is not machine supported by official release of QEMU.
It should be replaced by ppce500.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoFix an extra ' in a translated string
Daniel Veillard [Mon, 26 May 2014 13:51:26 +0000 (21:51 +0800)]
Fix an extra ' in a translated string

Raised by ukrainian translator Yuri Chornoivan
https://fedora.transifex.com/projects/p/libvirt/translate/#uk/strings/25483059

10 years agoClean up chardev sockets on QEMU shutdown
Ján Tomko [Tue, 13 May 2014 06:54:20 +0000 (08:54 +0200)]
Clean up chardev sockets on QEMU shutdown

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

Clean up unix socket files for chardevs using mode='bind',
like we clean up the monitor socket.
They are created by QEMU on startup and not really useful
after shutting it down.

10 years agoqemu: fix <clock offset='variable' basis='localtime'/>
Laine Stump [Wed, 21 May 2014 14:20:50 +0000 (17:20 +0300)]
qemu: fix <clock offset='variable' basis='localtime'/>

For a clock element as above, libvirt simply converts current system
time with localtime_r(), then starts qemu with a time string that
doesn't contain any timezone information. So, from qemu's point of
view, the -rtc string it gets for:

   <clock offset='variable' basis='utc' adjustment='10800'/>

is identical to the -rtc string it gets for:

   <clock offset='variable' basis='localtime' adjustment='0'/>

(assuming the host is in a timezone that is 10800 seconds ahead of
UTC, as is the case on the machine where this message is being
written).

Since the commandlines are identical, qemu will behave identically
after this point in either case.

There are two problems in the case of basis='localtime' though:

Problem 1) If the guest modifies its RTC, for example to add 20
seconds, the RTC_CHANGE event from qemu will then contain offset:20 in
both cases. But libvirt will have saved the original adjustment into
adjustment0, and will add that value onto the offset in the
event. This means that in the case of basis=;utc', it will properly
emit an event with offset:10820, but in the case of basis='localtime'
the event will contain offset:20, which is *not* the new offset of the
RTC from UTC (as the event it documented to provide).

Problem 2) If the guest is migrated to another host that is in a
different timezone, or if it is migrated or saved/restored after the
DST status has changed from what it was when the guest was originally
started, the newly restarted guest will have a different RTC (since it
will be based on the new localtime, which could have shifted by
several hours).

The solution to both of these problems is simple - rather than
maintaining the original adjustment value along with
"basis='localtime'" in the domain status, when the domain is started
we convert the adjustment offset to one relative to UTC, and set the
status to "basis='utc'". Thus, whatever the RTC offset was from UTC
when it was initially started, that offset will be maintained when
migrating across timezones and DST settings, and the RTC_CHANGE events
will automatically contain the proper offset (which should by
definition always be relative to UTC).

This fixes a problem that was implied but not openly stated in:

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

10 years agoqemu: fix RTC_CHANGE event for <clock offset='variable' basis='utc'/>
Laine Stump [Wed, 21 May 2014 09:54:34 +0000 (12:54 +0300)]
qemu: fix RTC_CHANGE event for <clock offset='variable' basis='utc'/>

commit e31b5cf393857 attempted to fix libvirt's
VIR_DOMAIN_EVENT_ID_RTC_CHANGE, which is documentated to always
provide the new offset of the domain's real time clock from UTC. The
problem was that, in the case that qemu is provided with an "-rtc
base=x" where x is an absolute time (rather than "utc" or
"localtime"), the offset sent by qemu's RTC_CHANGE event is *not* the
new offset from UTC, but rather is the sum of all changes to the
domain's RTC since it was started with base=x.

So, despite what was said in commit e31b5cf393857, if we assume that
the original value stored in "adjustment" was the offset from UTC at
the time the domain was started, we can always determine the current
offset from UTC by simply adding the most recent (i.e. current) offset
from qemu to that original adjustment.

This patch accomplishes that by storing the initial adjustment in the
domain's status as "adjustment0". Each time a new RTC_CHANGE event is
received from qemu, we simply add adjustment0 to the value sent by
qemu, store that as the new adjustment, and forward that value on to
any event handler.

This patch (*not* e31b5cf393857, which should be reverted prior to
applying this patch) fixes:

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

(for the case where basis='utc'. It does not fix basis='localtime')

10 years agoRevert "qemu: Report the offset from host UTC for RTC_CHANGE event"
Laine Stump [Tue, 20 May 2014 11:43:33 +0000 (14:43 +0300)]
Revert "qemu: Report the offset from host UTC for RTC_CHANGE event"

This reverts commit e31b5cf393857a6ca78d148c19393e28dfb39de1.

This commit attempted to work around a bug in the offset value
reported by qemu's RTC_CHANGE event in the case that a variable base
date was given on the qemu commandline. The patch mixed up the math
involved in arriving at the corrected offset to report, and in the
process added an unnecessary private attribute to the clock
element. Since that element is private/internal and not used by anyone
else, it makes sense to simplify things by removing it.

10 years agoutil: new function virTimeLocalOffsetFromUTC
Laine Stump [Sat, 24 May 2014 14:21:26 +0000 (08:21 -0600)]
util: new function virTimeLocalOffsetFromUTC

Since there isn't a single libc API to get this value, this patch
supplies one which gets the value by grabbing current time, then
converting that into a struct tm with gmtime_r(), then back to a
time_t using mktime.

The returned value is the difference between UTC and localtime in
seconds. If localtime is ahead of UTC (east) the offset will be a
positive number, and if localtime is behind UTC (west) the offset will
be negative.

This function should be POSIX-compliant, and is threadsafe, but not
async signal safe. If it was ever necessary to know this value in a
child process, we could cache it with a one-time init function when
libvirtd starts, then just supply the cached value, but that
complexity isn't needed for current usage; that would also have the
problem that it might not be accurate after a local daylight savings
boundary.

(If it weren't for DST, we could simply replace this entire function
with "-timezone"; timezone contains the offset of the current timezone
(negated from what we want) but doesn't account for DST. And in spite
of being guaranteed by POSIX, it isn't available on older versions of
mingw.)

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: Add storage file API to read file headers
Peter Krempa [Fri, 7 Mar 2014 10:53:18 +0000 (11:53 +0100)]
storage: Add storage file API to read file headers

Add storage driver based functions to access headers of storage files
for metadata extraction. Along with this patch a local filesystem and
gluster via libgfapi implementation is provided. The gluster
implementation is based on code of the saferead_lim function.

10 years agostorage: Add support for access to files using provided uid/gid
Peter Krempa [Fri, 25 Apr 2014 11:45:48 +0000 (13:45 +0200)]
storage: Add support for access to files using provided uid/gid

To allow using the storage driver APIs to access files on various
storage sources in a universal fashion possibly on storage such as nfs
with root squash we'll need to store the desired uid/gid in the
metadata.

Add new initialisation API that will store the desired uid/gid and a
wrapper for the current use. Additionally add docs for the two APIs.

10 years agostorage: Add NONE protocol type for network disks
Peter Krempa [Thu, 24 Apr 2014 14:11:44 +0000 (16:11 +0200)]
storage: Add NONE protocol type for network disks

Currently the protocol type with index 0 was NBD which made it hard to
distinguish whether the protocol type was actually assigned. Add a new
protocol type with index 0 to distinguish it explicitly.

10 years agoconf: Fix domain disk path iterator to work with networked storage
Peter Krempa [Sat, 26 Apr 2014 09:38:29 +0000 (11:38 +0200)]
conf: Fix domain disk path iterator to work with networked storage

Skip networked storage but continue iteration through backing chain to
iterate through all the local paths in the backing chain.

10 years agostorage: Rework debugging of storage file access through storage driver
Peter Krempa [Fri, 2 May 2014 14:51:48 +0000 (16:51 +0200)]
storage: Rework debugging of storage file access through storage driver

Print the debug statements of individual file access functions from the
main API functions instead of the individual backend functions.

Also enhance initialization debug messages on a per-backend basis.

10 years agostorage: Store gluster volume name separately
Peter Krempa [Fri, 2 May 2014 14:17:42 +0000 (16:17 +0200)]
storage: Store gluster volume name separately

The gluster volume name was previously stored as part of the source path
string. This is unfortunate when we want to do operations on the path as
the volume is used separately.

Parse and store the volume name separately for gluster storage volumes
and use the newly stored variable appropriately.

10 years agoqemu: Make qemuDomainPrepareDiskChainElement aware of remote storage
Peter Krempa [Mon, 5 May 2014 08:34:16 +0000 (10:34 +0200)]
qemu: Make qemuDomainPrepareDiskChainElement aware of remote storage

Refactor the function to accept a virStorageSourcePtr instead of just
the path, add a check to run it only on local storage and fix callers
(possibly by using a newly introduced wrapper that wraps a path in the
 virStorageSource struct for legacy code)

10 years agoqemu: process: Refresh backing chain info when reconnecting to qemu
Peter Krempa [Fri, 16 May 2014 13:16:18 +0000 (15:16 +0200)]
qemu: process: Refresh backing chain info when reconnecting to qemu

Refresh the disk backing chains when reconnecting to a qemu process
after daemon restart. There are a few internal fields that don't get
refreshed from the XML. Until we are able to do that, let's reload all
the metadata by the backing chain crawler.

10 years agoqemu: Properly abort migration to a file
Jiri Denemark [Thu, 22 May 2014 10:38:47 +0000 (12:38 +0200)]
qemu: Properly abort migration to a file

This is similar to the previous commit in that we need to explicitly
send migrate_cancel when libvirt detects an error other than those
reported by query-migrate. However, the possibility to hit such error is
pretty small.

10 years agoqemu: Send migrate_cancel when aborting migration
Jiri Denemark [Thu, 22 May 2014 10:29:20 +0000 (12:29 +0200)]
qemu: Send migrate_cancel when aborting migration

When QEMU reports failed or cancelled migration, we don't need to send
it migrate_cancel QMP command. But in all other error paths, such as if
we detect broken connection to a destination daemon or something else
happens inside libvirt, we need to explicitly send migrate_cancel
command instead of relying on the migration to be implicitly cancelled
when destination QEMU is killed.

Because we were not doing so, one could end up with a paused domain
after failed migration.

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

10 years agoFix error message when TUNNELLED flag is used in non-p2p migration
Jiri Denemark [Thu, 22 May 2014 11:18:21 +0000 (13:18 +0200)]
Fix error message when TUNNELLED flag is used in non-p2p migration

The current error message is

    error: use virDomainMigrateToURI3 for peer-to-peer migration

which is correct but a bit misleading because the client did not specify
VIR_MIGRATE_PEER2PEER flag. This patch changes the error message to

    error: cannot perform tunnelled migration without using peer2peer
    flag

which is consistent with the error reported by older migration APIs.

Reported by Rich Jones in
https://bugzilla.redhat.com/show_bug.cgi?id=1095924

10 years agoconf: fix backing store parse off-by-one
Eric Blake [Thu, 22 May 2014 03:45:02 +0000 (21:45 -0600)]
conf: fix backing store parse off-by-one

Commit 546154e parses the type attribute from a <backingStore>
element, but forgot that the earlier commit 9673418 added a
placeholder element in the same 1.2.3 release; as a result,
the C code was mistakenly allowing "none" as a type.

Similarly, the same commit allows "none" as the <format>
sub-element type, even though that has been a placeholder
since the 0.10.2 release with commit f772b3d.

* src/conf/domain_conf.c (virDomainDiskBackingStoreParse): Require
non-zero types.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoDon't log an internal error when the guest hasn't updated balloon stats
Ján Tomko [Wed, 14 May 2014 07:35:18 +0000 (09:35 +0200)]
Don't log an internal error when the guest hasn't updated balloon stats

If virDomainMemoryStats is called too soon after domain startup,
QEMU returns:
"error":{"class":"GenericError","desc":"guest hasn't updated any stats yet"}
when we try to query balloon stats.

Check for this reply and log it as OPERATION_INVALID instead of
INTERNAL_ERROR. This means the daemon only logs it at the debug level,
without polluting system logs.

Reported by Laszlo Pal:
https://www.redhat.com/archives/libvirt-users/2014-May/msg00023.html

10 years agoqemuSetupCgroupForVcpu: s/virProcessInfoSetAffinity/virProcessSetAffinity/
Michal Privoznik [Thu, 22 May 2014 10:30:20 +0000 (12:30 +0200)]
qemuSetupCgroupForVcpu: s/virProcessInfoSetAffinity/virProcessSetAffinity/

In the f56c773bf we've made the substitution but forgot to fix one
comment which is still referring to the old name. This may be
potentially misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agobhyve: fix virObjectUnlock() usage
Roman Bogorodskiy [Sat, 17 May 2014 19:08:14 +0000 (23:08 +0400)]
bhyve: fix virObjectUnlock() usage

In a number of places in the bhyve driver, virObjectUnlock()
is called with an arg without check if the arg is non-NULL, which
could result in passing NULL value and a warning like:

virObjectUnlock:340 : Object 0x0 ((unknown)) is not a virObjectLockable instance

* src/bhyve/bhyve_driver.c (bhyveDomainGetInfo)
(bhyveDomainGetState, bhyveDomainGetAutostart)
(bhyveDomainSetAutostart, bhyveDomainIsActive)
(bhyveDomainIsPersistent, bhyveDomainGetXMLDesc)
(bhyveDomainUndefine, bhyveDomainLookupByUUID)
(bhyveDomainLookupByName, bhyveDomainLookupByID)
(bhyveDomainCreateWithFlags, bhyveDomainOpenConsole):
Check if arg is not NULL before calling virObjectUnlock on it.

10 years agovirdbus: Show method name in error message
Cole Robinson [Sat, 3 May 2014 19:53:03 +0000 (15:53 -0400)]
virdbus: Show method name in error message

If you trigger bug 1033369, we get the error message:

  error from service: Invalid argument

Which is a bit too generic to pinpoint what is actually failing. This
changes it to:

  error from service: CreateMachine: Invalid argument

Acked-by: Eric Blake <eblake@redhat.com>
10 years agovirdbus: Remove redundant error macro
Cole Robinson [Sat, 3 May 2014 19:46:52 +0000 (15:46 -0400)]
virdbus: Remove redundant error macro

This is the only callsite.

We drop use of localerror.name here, because it's not actually useful
to us: rather than the parameter name which received an invalid value
(which was assumed), it's actually the the dbus errno equivalent.
Just use the error string.

Acked-by: Eric Blake <eblake@redhat.com>
10 years agotests: avoid dlsym mocking on mingw
Eric Blake [Tue, 20 May 2014 21:04:44 +0000 (15:04 -0600)]
tests: avoid dlsym mocking on mingw

I got a build failure when cross-compiling to mingw with the
mingw64-dbus package installed:

  CC       virmockdbus_la-virmockdbus.lo
../../tests/virmockdbus.c:29:6: error: 'dbus_connection_set_change_sigpipe' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
 VIR_MOCK_STUB_VOID_ARGS(dbus_connection_set_change_sigpipe,
      ^
../../tests/virmockdbus.c:33:18: error: 'dbus_bus_get' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
 VIR_MOCK_STUB_RET_ARGS(dbus_bus_get,
...

Well duh - mingw lacks dlopen and friends, even if it can support
dbus.  A similar failure occured in virsystemdtest.c; but in that
file, we know that systemd is a Linux-only concept.

* tests/virmockdbus.c: Cripple on mingw.
* tests/virsystemdtest.c: Cripple on non-Linux.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: snapshot: Fix return value of external checkpoint with no disks
Peter Krempa [Tue, 20 May 2014 13:22:14 +0000 (15:22 +0200)]
qemu: snapshot: Fix return value of external checkpoint with no disks

When doing an external checkpoint of a VM with no disk selected we'd
return failure but not set error code. This was a result of ret not
being set to 0 during walking of the disk array.

Rework early failure checking and set the error code to success before
iterating the array of disks so that we return success if no disks are
snapshotted.

Fixes the following symptom (or without --diskspec for diskless VMs)

 $ virsh snapshot-create-as snapshot-test  --memspec /tmp/asdf --diskspec hda,snapshot=no
 error: An error occurred, but the cause is unknown

10 years agoqemu: snapshot: Forbid empty snapshots
Peter Krempa [Tue, 20 May 2014 12:22:25 +0000 (14:22 +0200)]
qemu: snapshot: Forbid empty snapshots

If neither disks nor memory are selected for snapshot we'd record
metadata in case of external snapshot and do a disk snapshot in case of
external disk snapshot. Forbid this as it doesn't make much sense.

10 years agoqemu: snapshot: Forbid partial internal snapshots
Peter Krempa [Tue, 20 May 2014 12:04:23 +0000 (14:04 +0200)]
qemu: snapshot: Forbid partial internal snapshots

qemu's savevm command does a snapshot of all non readonly disks of a VM.
Libvirt though allowed disabling snapshot for certain disk of a VM.

10 years agoqemu: snapshot: Use typecasted switch in qemuDomainSnapshotPrepare()
Peter Krempa [Tue, 20 May 2014 08:38:42 +0000 (10:38 +0200)]
qemu: snapshot: Use typecasted switch in qemuDomainSnapshotPrepare()

Convert the switch to a typecasted value so that the compiler tracks
additions for us.

10 years agobhyve: domain events support
Roman Bogorodskiy [Wed, 23 Apr 2014 11:55:05 +0000 (15:55 +0400)]
bhyve: domain events support

Support events for these functions:

 - domainDefineXML
 - domainUndefine
 - domainCreate{WithFlags,XML}
 - domainDestroy

10 years agomigration: add support for migrateURI configuration
Chen Fan [Tue, 20 May 2014 06:08:05 +0000 (14:08 +0800)]
migration: add support for migrateURI configuration

For now, we set the migration URI via command line '--migrate_uri' or
construct the URI by looking up the dest host's hostname which could be
solved by DNS automatically.

But in cases the dest host have two or more NICs to reach, we may need to
send the migration data over a specific NIC which is different from the
automatically resolved one for some reason like performance, security, etc.
Thus we must explicitly specify the migrateuri in command line everytime,
but it is too troublesome if there are many such hosts (and don't forget
virt-manager).

This patch adds a configuration file option on dest host to save the
default value set which can be specified to a migration hostname or
one of this host's addresses used for transferring data, thus user doesn't
have to specify it in command line everytime.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoutil: refactor virNetlinkCommand to fix several bugs / style problems
Laine Stump [Tue, 13 May 2014 11:34:43 +0000 (14:34 +0300)]
util: refactor virNetlinkCommand to fix several bugs / style problems

Inspired by a simpler patch from "Wangrui (K) <moon.wangrui@huawei.com>".

A submitted patch pointed out that virNetlinkCommand() was doing an
improper typecast of the return value from nl_recv() (int to
unsigned), causing it to miss error returns, and that even after
remedying that problem, virNetlinkCommand() was calling VIR_FREE() on
the pointer returned from nl_recv() (*resp) even if nl_recv() had
returned an error, and that in this case the pointer was verifiably
invalid, as it was pointing to memory that had been allocated by
libnl, but then freed prior to returning the error.

While reviewing this patch, I noticed several other problems with this
seemingly simple function (at least one of them as serious as the
problem being reported/fixed by the aforementioned patch), and decided
they all deserved to be fixed. Here is the list:

1) The return value from nl_recv() must be assigned to an int (rather
   than unsigned int) in order to detect failure.

2) When nl_recv() returns an error or 0, the contents of *resp is
   invalid, and should be simply set to 0, *not* VIR_FREE()'d.

3) When nl_recv() returns 0, errno is not set, so the logged error
   message should not reference errno (it *is* an error though).

4) The first error return from virNetlinkCommand returns -EINVAL,
   incorrectly implying that the caller can expect the return value to
   be of the "-errno" variety, which is not true in any other case.

5) The 2nd error return returns directly with garbage in *resp. While
   the caller should never use *resp in this case, it's still good
   practice to set it to NULL.

6) For the next 5 (!!) error conditions, *resp will contain garbage,
   and virNetlinkCommand() will goto it's cleanup code which will
   VIR_FREE(*resp), almost surely leading to a segfault.

In addition to fixing these 6 problems, this patch also makes the
following two changes to make the function conform more closely to the
style of other libvirt code:

1) Change the handling of return code from "named rc and defaulted to
0, but changed to -1 on error" to the more common "named ret and
defaulted to -1, but changed to 0 on success".

2) Rename the "error" label to "cleanup", since the code that follows
is executed in success cases as well as failure.

10 years agobuild: nuke more uses of 'sync'
Eric Blake [Mon, 19 May 2014 23:02:42 +0000 (17:02 -0600)]
build: nuke more uses of 'sync'

Commit d5c86278 was incomplete; other functions also triggered
compiler warnings about collisions in the use of 'sync'.

* src/qemu/qemu_driver.c (qemuDomainSetTime): Fix another client.
* tools/virsh-domain-monitor.c (cmdDomTime): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoavoid 'sync' as variable name
Pavel Hrdina [Mon, 19 May 2014 14:36:55 +0000 (16:36 +0200)]
avoid 'sync' as variable name

Old gcc complains about shadowing 'sync' variable:

../../src/qemu/qemu_agent.c: In function 'qemuAgentSetTime':
../../src/qemu/qemu_agent.c:1737: warning: declaration of 'sync'
  shadows a global declaration [-Wshadow]
/usr/include/unistd.h:464: warning: shadowed declaration is here
  [-Wshadow]

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoReturn error when updating cdrom device
Pavel Hrdina [Mon, 19 May 2014 13:48:43 +0000 (15:48 +0200)]
Return error when updating cdrom device

The commit 84c59ffa improved the way we change ejectable media.
If for any reason the first "eject" didn't open the tray we
should return with error.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoRevert "maint: prefer enum over int for virstoragefile structs"
Eric Blake [Sat, 17 May 2014 00:50:03 +0000 (18:50 -0600)]
Revert "maint: prefer enum over int for virstoragefile structs"

This partially reverts commits b279e52f7 and ea18f8b2.

It turns out our code base is full of:

if ((struct.member = virBlahFromString(str)) < 0)
    goto error;

Meanwhile, the C standard says it is up to the compiler whether
an enum is signed or unsigned when all of its declared values
happen to be positive.  In my testing (Fedora 20, gcc 4.8.2),
the compiler picked signed, and nothing changed.  But others
testing with gcc 4.7 got compiler warnings, because it picked
the enum to be unsigned, but no unsigned value is less than 0.
Even worse:

if ((struct.member = virBlahFromString(str)) <= 0)
    goto error;

is silently compiled without warning, but incorrectly treats -1
from a bad parse as a large positive number with no warning; and
without the compiler's help to find these instances, it is a
nightmare to maintain correctly.  We could force signed enums
with a dummy negative declaration in each enum, or cast the
result of virBlahFromString back to int after assigning to an
enum value, or use a temporary int for collecting results from
virBlahFromString, but those actions are all uglier than what we
were trying to cure by directly using enum types for struct
values in the first place.  It's better off to just live with int
members, and use 'switch ((virFoo) struct.member)' where we want
the compiler to help, than to track down all the conversions from
string to enum and ensure they don't suffer from type problems.

* src/util/virstorageencryption.h: Revert back to int declarations
with comment about enum usage.
* src/util/virstoragefile.h: Likewise.
* src/conf/domain_conf.c: Restore back to casts in switches.
* src/qemu/qemu_driver.c: Likewise.
* src/qemu/qemu_command.c: Add cast rather than revert.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoFix crash in DAC driver with no seclabels
Ján Tomko [Mon, 19 May 2014 11:50:52 +0000 (13:50 +0200)]
Fix crash in DAC driver with no seclabels

With dynamic_ownership = 1 but no seclabels, RestoreChardevLabel
dereferences the NULL seclabel when checking if norelabel is set.

Remove this check, since it is already done in RestoreSecurityAllLabel
and if norelabel is set, RestoreChardevLabel is never called.

10 years agoparallels: create VMs in the default place
Dmitry Guryanov [Wed, 7 May 2014 18:04:09 +0000 (22:04 +0400)]
parallels: create VMs in the default place

Each VM consists of a set of files in PCS: config, hard
disk images, log file, memory dump. All these files are stored
in a per-vm directory. When we create a new VM, we can ether specify
path to the VM or create the VM in a default path
(<default path>/<vm name>.pvm). This default path can be configured
with command
prlsrvctl user set --def-vm-home <path> command.

Currenty parallels driver creates VM in the same place, where first
hard disk is located. Let's change this logic and create VMs in
the default path. It will be much clearer and allow us to create
VMs without hard disks.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: add disks correctly
Dmitry Guryanov [Wed, 7 May 2014 18:04:08 +0000 (22:04 +0400)]
parallels: add disks correctly

Disks support in this driver was implemented with an assumption,
that disk images can't be created by hand, without VM. So
complex storage driver was implemented with workaround.

This is not true, we can create new disks using ploop tool.
So the first step to reimplement disks support in parallels
driver is to do not use information from the storage driver,
until we will implement VIR_STORAGE_TYPE_VOLUME disks.

So after this patch disks can be added in the same way as
in any other driver: you create a disk image and then add
an entry to the XML definition of the domain with path to that
image file, for example:

<disk type='file' device='disk'>
  <driver type='ploop'/>
  <source file='/storage/harddisk1.hdd'/>
  <target dev='sda' bus='sata'/>
  <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

This patch makes parallels storage driver useless, but I'll fix it
later. Now you can create an image by hand, using ploop tool,
and then add it to some domain.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: set file format in virDomainDef
Dmitry Guryanov [Wed, 7 May 2014 18:04:07 +0000 (22:04 +0400)]
parallels: set file format in virDomainDef

Set file format in virDomainDef structure to produce correct
XML in virDomainGetXMLDesc function.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoparallels: add VIR_STORAGE_FILE_PLOOP format
Dmitry Guryanov [Wed, 7 May 2014 18:04:06 +0000 (22:04 +0400)]
parallels: add VIR_STORAGE_FILE_PLOOP format

Add VIR_STORAGE_FILE_PLOOP format. This format is used
to store disk images for virtual machines in PCS and containers
in PCS, OpenVZ and also in Parallels Desktop for Mac.

This format is described on OpenVZ site -
https://openvz.org/Ploop (together with ploop devices). It
consists of XML descriptor and one or more image files: base
image and deltas. Format of the image files described here:
https://openvz.org/Ploop/format.

This patch only adds VIR_STORAGE_FILE_PLOOP constant, consequent
patches will use it in parallels driver.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agovirSecurityDACRestoreSecurityHostdevLabel: Unmark @def as unused
Michal Privoznik [Mon, 19 May 2014 09:15:52 +0000 (11:15 +0200)]
virSecurityDACRestoreSecurityHostdevLabel: Unmark @def as unused

The domain definition is clearly used a few lines
below so there's no need to mark @def as unused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodocs: add a serial device with a seclabel example
Ján Tomko [Fri, 16 May 2014 14:52:41 +0000 (16:52 +0200)]
docs: add a serial device with a seclabel example

10 years agoconf: fix seclabels for chardevs
Ján Tomko [Fri, 16 May 2014 12:31:28 +0000 (14:31 +0200)]
conf: fix seclabels for chardevs

We allow a seclabel to be specified in the <source> element
of a chardev:

<serial type='file'>
  <source path='/tmp/serial.file'>
    <seclabel model='dac' relabel='no'/>
  </source>
</serial>

But we format it outside the source:

<serial type='file'>
  <source path='/tmp/serial.file'/>
  <target port='0'/>
    <seclabel model='dac' relabel='no'/>
</serial>

Move the formatting inside the source to fix this to make the
seclabel persistent across XML format->parse.

Introduced by commit f8b08d0 'Add <seclabel> to character devices.'

10 years agoRename virDomainDiskSourceDefFormatSeclabel
Ján Tomko [Fri, 16 May 2014 12:55:17 +0000 (14:55 +0200)]
Rename virDomainDiskSourceDefFormatSeclabel

Drop the 'Disk' from the name, as there is nothing disk-specific
about the function.

10 years agosecurity_dac: honor relabel='no' in chardev config
Jim Fehlig [Thu, 15 May 2014 22:24:43 +0000 (16:24 -0600)]
security_dac: honor relabel='no' in chardev config

The DAC driver ignores the relabel='no' attribute in chardev config

  <serial type='file'>
    <source path='/tmp/jim/test.file'>
      <seclabel model='dac' relabel='no'/>
    </source>
    <target port='0'/>
  </serial>

This patch avoids labeling chardevs when relabel='no' is specified.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agosecurity_dac: avoid relabeling hostdevs when relabel='no'
Jim Fehlig [Thu, 15 May 2014 21:58:04 +0000 (15:58 -0600)]
security_dac: avoid relabeling hostdevs when relabel='no'

When relabel='no' at the domain level, there is no need to call
the hostdev relabeling functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agosecurity_dac: honor relabel='no' in disk config
Jim Fehlig [Thu, 15 May 2014 21:30:26 +0000 (15:30 -0600)]
security_dac: honor relabel='no' in disk config

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

The DAC driver ignores the relabel='no' attribute in disk config

  <disk type='file' device='floppy'>
    <driver name='qemu' type='raw'/>
    <source file='/some/path/floppy.img'>
      <seclabel model='dac' relabel='no'/>
    </source>
    <target dev='fda' bus='fdc'/>
    <readonly/>
  </disk>

This patch avoid labeling disks when relabel='no' is specified.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agosecurity_dac: avoid relabeling when relabel='no'
Jim Fehlig [Thu, 15 May 2014 22:38:01 +0000 (16:38 -0600)]
security_dac: avoid relabeling when relabel='no'

If relabel='no' at the domain level, no need to attempt relabeling
in virSecurityDAC{Set,Restore}SecurityAllLabel().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agosecurity_dac: rework callback parameter passing
Jim Fehlig [Thu, 15 May 2014 18:15:01 +0000 (12:15 -0600)]
security_dac: rework callback parameter passing

Currently, the DAC security driver passes callback data as

    void params[2];
    params[0] = mgr;
    params[1] = def;

Clean this up by defining a structure for passing the callback
data.  Moreover, there's no need to pass the whole virDomainDef
in the callback as the only thing needed in the callbacks is
virSecurityLabelDefPtr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agosecurity_dac: cleanup use of enum types
Jim Fehlig [Thu, 15 May 2014 17:35:15 +0000 (11:35 -0600)]
security_dac: cleanup use of enum types

In switch statements, use enum types since it is safer when
adding new items to the enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agosecurity_dac: annotate some functions with ATTRIBUTE_NONNULL
Jim Fehlig [Tue, 13 May 2014 21:38:00 +0000 (15:38 -0600)]
security_dac: annotate some functions with ATTRIBUTE_NONNULL

Annotate some static function parameters with ATTRIBUTE_NONNULL
and remove checks for NULL inputs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agomaint: fix typos related to disk name resolution
Eric Blake [Fri, 16 May 2014 17:12:20 +0000 (11:12 -0600)]
maint: fix typos related to disk name resolution

In a number of APIs, the text implied that a user might have
<target dev='xvda'/> - but common convention is to use "vda",
not "xvda".  For example, virDomainGetDiskErrors was correct,
while virDomainBlockStats was confusing.

* src/libvirt.c: Make examples consistent.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoutil: fix memory leak in failure path of virCgroupKillRecursiveInternal
Chen Hanxiao [Tue, 13 May 2014 08:01:16 +0000 (16:01 +0800)]
util: fix memory leak in failure path of virCgroupKillRecursiveInternal

Don't leak keypath when we fail to kill a process

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agomaint: prefer enum over int for virstoragefile structs
Eric Blake [Wed, 14 May 2014 22:40:33 +0000 (16:40 -0600)]
maint: prefer enum over int for virstoragefile structs

For internal structs, we might as well be type-safe and let the
compiler help us with less typing required on our part (getting
rid of casts is always nice).  In trying to use enums directly,
I noticed two problems in virstoragefile.h that can't be fixed
without more invasive refactoring: virStorageSource.format is
used as more of a union of multiple enums in storage volume
code (so it has to remain an int), and virStorageSourcePoolDef
refers to pooltype whose enum is declared in src/conf, but where
src/util can't pull in headers from src/conf.

* src/util/virstoragefile.h (virStorageNetHostDef)
(virStorageSourcePoolDef, virStorageSource): Use enums instead of
int for fields of internal types.
* src/qemu/qemu_command.c (qemuParseCommandLine): Cover all values.
* src/conf/domain_conf.c (virDomainDiskSourceParse)
(virDomainDiskSourceFormat): Simplify clients.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskInternal): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: shorten 'TypeType' function names
Eric Blake [Wed, 14 May 2014 19:48:15 +0000 (13:48 -0600)]
maint: shorten 'TypeType' function names

The VIR_ENUM_DECL/VIR_ENUM_IMPL helper macros already append 'Type'
to the enum name being converted; it looks silly to have functions
with 'TypeType' in their name.  Even though some of our enums have
to have a 'Type' suffix, the corresponding string conversion
functions do not.

* src/conf/secret_conf.h (VIR_ENUM_DECL): Rename virSecretUsageType.
* src/conf/storage_conf.h (VIR_ENUM_DECL): Rename
virStoragePoolAuthType, virStoragePoolSourceAdapterType,
virStoragePartedFsType.
* src/conf/domain_conf.c (virDomainDiskDefParseXML)
(virDomainFSDefParseXML, virDomainFSDefFormat): Update callers.
* src/conf/secret_conf.c (virSecretDefParseUsage)
(virSecretDefFormatUsage): Likewise.
* src/conf/storage_conf.c (virStoragePoolDefParseAuth)
(virStoragePoolDefParseSource, virStoragePoolSourceFormat):
Likewise.
* src/lxc/lxc_controller.c (virLXCControllerSetupLoopDevices):
Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskPartFormat): Likewise.
* src/util/virstorageencryption.c (virStorageEncryptionSecretParse)
(virStorageEncryptionSecretFormat): Likewise.
* tools/virsh-secret.c (cmdSecretList): Likewise.
* src/libvirt_private.syms (secret_conf.h, storage_conf.h): Export
corrected names.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: use enum typedef for virstorageencryption.h
Eric Blake [Wed, 14 May 2014 19:36:56 +0000 (13:36 -0600)]
maint: use enum typedef for virstorageencryption.h

Continuing the work of consistent enum cleanups; this time in
virstorageencryption.h.

* src/util/virstorageencryption.h (virStorageEncryptionFormat):
Convert to typedef, renaming to avoid collision with function.
(virStorageEncryptionSecret, virStorageEncryption): Directly use
enums.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovbox: fix stale comment about vdi storage type
Eric Blake [Wed, 14 May 2014 19:26:28 +0000 (13:26 -0600)]
vbox: fix stale comment about vdi storage type

The code had some todo's about adding 'vdi' to the list of
virStorageType, but we've already done that.

* src/vbox/vbox_tmpl.c (vboxStorageVolCreateXML)
(vboxStorageVolGetXMLDesc): Use enum value for vdi type.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: Implement virDomain{Get,Set}Time
Michal Privoznik [Wed, 2 Apr 2014 17:05:42 +0000 (19:05 +0200)]
qemu: Implement virDomain{Get,Set}Time

One caveat though, qemu-ga is expecting time and returning time
in nanoseconds. With all the buffering and propagation delay, the
time is already wrong once it gets to the qemu-ga, but there's
nothing we can do about it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: Expose virDomain{Get,Set}Time
Michal Privoznik [Wed, 2 Apr 2014 16:50:12 +0000 (18:50 +0200)]
virsh: Expose virDomain{Get,Set}Time

These APIs are exposed under new virsh command 'domtime' which both gets
and sets (not at the same time of course :)).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virDomain{Get,Set}Time APIs
Michal Privoznik [Wed, 2 Apr 2014 16:25:07 +0000 (18:25 +0200)]
Introduce virDomain{Get,Set}Time APIs

These APIs allow users to get or set time in a domain, which may come
handy if the domain has been resumed just recently and NTP is not
configured or hasn't kicked in yet and the guest is running
something time critical. In addition, NTP may refuse to re-set the clock
if the skew is too big.

In addition, new ACL attribute is introduced 'set_time'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Avoid leak in qemuDomainCheckRemoveOptionalDisk
Jiri Denemark [Thu, 15 May 2014 11:11:12 +0000 (13:11 +0200)]
qemu: Avoid leak in qemuDomainCheckRemoveOptionalDisk

Coverity complains about event being leaked in
qemuDomainCheckRemoveOptionalDisk. The best fix for it is to remove the
disk directly since we already know its index.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agosecurity_dac: Fix indentation
Jim Fehlig [Wed, 14 May 2014 17:38:53 +0000 (11:38 -0600)]
security_dac: Fix indentation

10 years agosecurity_dac: Remove unnecessary curly braces
Jim Fehlig [Wed, 14 May 2014 17:37:27 +0000 (11:37 -0600)]
security_dac: Remove unnecessary curly braces

10 years agosecurity_dac: Remove unnecessary ATTRIBUTE_UNUSED
Jim Fehlig [Wed, 14 May 2014 17:30:53 +0000 (11:30 -0600)]
security_dac: Remove unnecessary ATTRIBUTE_UNUSED

Remove ATTRIBUTE_UNUSED on several function parameters that are
actually used.

10 years agovirsh: reject undefine --wipe-storage without also naming storage
Li Yang [Wed, 14 May 2014 06:15:37 +0000 (02:15 -0400)]
virsh: reject undefine --wipe-storage without also naming storage

For now, if only '--wipe-storage' is assigned, user can undefine a
domain normally. But actually '--wipe-storage' doesn't do anything,
and this may confuse user. Better is to require that '--wipe-storage'
only works if the user specifies volumes to be removed.

Before:
$ virsh undefine virt-tests-vm1 --wipe-storage
Domain virt-tests-vm1 has been undefined

After:
$ virsh undefine virt-tests-vm1 --wipe-storage
error: '--wipe-storage' requires '--storage <string>' or '--remove-all-storage'

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoconf: use typedefs for enums in "src/conf/snapshot_conf.h"
Julio Faracco [Sun, 11 May 2014 15:08:51 +0000 (12:08 -0300)]
conf: use typedefs for enums in "src/conf/snapshot_conf.h"

In "src/conf/" there are many enumeration (enum) declarations.
Similar to the recent cleanup to "src/util" directory, it's
better to use a typedef for variable types, function types and
other usages. Other enumeration and folders will be changed to
typedef's in the future. Most of the files changed in this
commit are related to snapshot (snapshot_conf) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoconf: use typedefs for enums in "src/conf/storage_conf.h"
Julio Faracco [Sun, 11 May 2014 15:08:50 +0000 (12:08 -0300)]
conf: use typedefs for enums in "src/conf/storage_conf.h"

In "src/conf/" there are many enumeration (enum) declarations.
Similar to the recent cleanup to "src/util" directory, it's
better to use a typedef for variable types, function types and
other usages. Other enumeration and folders will be changed to
typedef's in the future. Most of the files changed in this
commit are related to storage (storage_conf) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoconf: use typedefs for enums in "src/conf/nwfilter_conf.h"
Julio Faracco [Sun, 11 May 2014 15:08:49 +0000 (12:08 -0300)]
conf: use typedefs for enums in "src/conf/nwfilter_conf.h"

In "src/conf/" there are many enumeration (enum) declarations.
Similar to the recent cleanup to "src/util" directory, it's better
to use a typedef for variable types, function types and other
usages. Other enumeration and folders will be changed to typedef's
in the future. Most of the files changed in this commit are related
to network filter (nwfilter_conf) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: Ignore temporary job errors when checking migration status
Jiri Denemark [Tue, 13 May 2014 12:45:31 +0000 (14:45 +0200)]
qemu: Ignore temporary job errors when checking migration status

When qemu driver is polling for migration to finish (in
qemuMigrationWaitForCompletion), it may happen that another job allowed
during migration is running and if it does not finish within 30 seconds,
migration would be cancelled because of that. However, we can just
ignore the timeout and let the waiting loop try again later.

If an event fired at the end of migration is ever implemented in QEMU,
we can just wait for the event instead of polling for migration status
and libvirt will behave consistently, i.e., migration won't be cancelled
in case another job started during migration takes long time to finish.

For bug https://bugzilla.redhat.com/show_bug.cgi?id=1083238

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Make qemuProcess{Start,Stop}CPUs easier to follow
Jiri Denemark [Wed, 14 May 2014 11:22:34 +0000 (13:22 +0200)]
qemu: Make qemuProcess{Start,Stop}CPUs easier to follow

As a side effect, the return value of qemuDomainObjEnterMonitorAsync is
not directly used as the return value of qemuProcess{Start,Stop}CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemuDomainObjBeginNestedJob: Return -2 for temporary failures
Jiri Denemark [Tue, 13 May 2014 12:39:35 +0000 (14:39 +0200)]
qemuDomainObjBeginNestedJob: Return -2 for temporary failures

If job queue is full or waiting for a job times out, the function
returns -2 so that it can be handled in a different way by callers.

The change is safe since all existing callers of
qemuDomainObjBeginNestedJob check the return value to be less than zero.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Make qemuDomainObjBeginNestedJob static
Jiri Denemark [Tue, 13 May 2014 12:34:55 +0000 (14:34 +0200)]
qemu: Make qemuDomainObjBeginNestedJob static

It's only used within qemu_domain.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: snapshot: Terminate job when memory compression program isn't found
Peter Krempa [Wed, 14 May 2014 07:43:52 +0000 (09:43 +0200)]
qemu: snapshot: Terminate job when memory compression program isn't found

If the compression program for external snapshot memory image isn't
found we exitted the function without terminating the domain job. This
caused the domain to be unusable.

The problem was introduced in commit 7df5093f.

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

10 years agoqemu: extract common PCI handling functions
Roman Bogorodskiy [Tue, 13 May 2014 16:10:40 +0000 (20:10 +0400)]
qemu: extract common PCI handling functions

Move sharable PCI handling functions to domain_addr.[ch], and
change theirs prefix from 'qemu' to 'vir':

 - virDomainPCIAddressAsString;
 - virDomainPCIAddressBusSetModel;
 - virDomainPCIAddressEnsureAddr;
 - virDomainPCIAddressFlagsCompatible;
 - virDomainPCIAddressGetNextSlot;
 - virDomainPCIAddressReleaseSlot;
 - virDomainPCIAddressReserveAddr;
 - virDomainPCIAddressReserveNextSlot;
 - virDomainPCIAddressReserveSlot;
 - virDomainPCIAddressSetFree;
 - virDomainPCIAddressSetGrow;
 - virDomainPCIAddressSlotInUse;
 - virDomainPCIAddressValidate;

The only change here is function names, the implementation itself
stays untouched.

Extract common allocation code from DomainPCIAddressSetCreate
into virDomainPCIAddressSetAlloc.

10 years agoqemu: extract PCI handling structs
Roman Bogorodskiy [Sat, 10 May 2014 16:35:24 +0000 (20:35 +0400)]
qemu: extract PCI handling structs

Introduce new files (domain_addr.[ch]) to provide
an API for domain device handling that could be
shared across the drivers.

A list of data types were extracted and moved there:

 qemuDomainPCIAddressBus -> virDomainPCIAddressBus
 qemuDomainPCIAddressBusPtr -> virDomainPCIAddressBusPtr
 _qemuDomainPCIAddressSet -> virDomainPCIAddressSet
 qemuDomainPCIAddressSetPtr -> virDomainPCIAddressSetPtr
 qemuDomainPCIConnectFlags -> virDomainPCIConnectFlags

Also, move the related definitions and macros.

10 years agosanlock: avoid leak in acquire()
Martin Kletzander [Tue, 13 May 2014 11:40:38 +0000 (13:40 +0200)]
sanlock: avoid leak in acquire()

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Adjust size for qcow2/qed if not on sector boundary
John Ferlan [Mon, 12 May 2014 14:21:09 +0000 (10:21 -0400)]
qemu: Adjust size for qcow2/qed if not on sector boundary

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

If qemuDomainBlockResize() is passed a size not on a KiB boundary - that
is passed a size based in bytes (VIR_DOMAIN_BLOCK_RESIZE_BYTES), then
depending on the source format (qcow2 or qed), the value passed must
be on a sector (or 512 byte) boundary. Since other libvirt code quietly
adjusts the capacity values, then do so here as well.

10 years agoRevert "qemu: Adjust size for qcow2/qed if not on sector boundary"
John Ferlan [Mon, 12 May 2014 14:10:11 +0000 (10:10 -0400)]
Revert "qemu: Adjust size for qcow2/qed if not on sector boundary"

This reverts commit e3d66229a1026cd33319714c0ededf650cd261c2.

10 years agovirsh: domain: Fix output of the VNC display number for domdisplay
Peter Krempa [Tue, 13 May 2014 09:26:28 +0000 (11:26 +0200)]
virsh: domain: Fix output of the VNC display number for domdisplay

Commit 9976c4b9a665f10ab0d2071954efb7f432d194eb broke the output for VNC
displays as the port number is converted to VNC display number by
subtracting 5900. This yields port 0 for the first display and thus the
output would be skipped.

Before:
 $ virsh domdisplay VM
 vnc://localhost

After:
 $ tools/virsh domdisplay VM
 vnc://localhost:0

10 years agosanlock: don't fail with unregistered domains
Martin Kletzander [Mon, 12 May 2014 09:38:47 +0000 (11:38 +0200)]
sanlock: don't fail with unregistered domains

When a domain was started without registration in sanlock, but libvirt
was restarted after that, most of the operations failed due to
contacting sanlock about that process.  E.g. migration could not be
performed because the locks couldn't be released (or inquired before a
release).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agosanlock: code movement in virLockManagerSanlockAcquire
Martin Kletzander [Mon, 12 May 2014 09:38:08 +0000 (11:38 +0200)]
sanlock: code movement in virLockManagerSanlockAcquire

Just move some code around for future patches to ease the review.
With this patch there is no need for drastic cleanup path later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoapibuild: Disallow 'returns' return description
Michal Privoznik [Mon, 12 May 2014 12:23:18 +0000 (14:23 +0200)]
apibuild: Disallow 'returns' return description

Our documentation generator is a bit messy, to say the least. For
instance, the description to return values of a function is
searched within C comment. Currently, all lines that start with
'returns' or 'Returns' are viewed as return value description.
However, there are some valid uses where the 'returns' word is in
the middle of a sentence describing function behavior not the
return value. And there are no places where 'returns' is used to
describe return values.  For instance:
virDomainDetachDeviceFlags, virConnectNetworkEventRegisterAny and
virDomainGetDiskErrors. This leads to HTML documemtation being
generated incorrectly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Support mountpoints option of guest-fsfreeze-freeze
Tomoki Sekiyama [Fri, 2 May 2014 00:06:19 +0000 (20:06 -0400)]
qemu: Support mountpoints option of guest-fsfreeze-freeze

With this patch, virDomainFSFreeze will pass the mountpoints argument
to qemu guest agent. For example,

  virDomainFSFreeze(dom, {"/mnt/vol1", "/mnt/vol2"}, 2, 0)

will issue qemu guest agent command:

  {"execute":"guest-fsfreeze-freeze",
   "arguments":{"mountpoints":["/mnt/vol1","/mnt/vol2"]}}

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
10 years agovirsh: Expose new virDomainFSFreeze and virDomainFSThaw API
Tomoki Sekiyama [Fri, 2 May 2014 00:06:13 +0000 (20:06 -0400)]
virsh: Expose new virDomainFSFreeze and virDomainFSThaw API

These are exposed under domfsfreeze command and domfsthaw command.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: Implement virDomainFSFreeze and virDomainFSThaw
Tomoki Sekiyama [Fri, 2 May 2014 00:06:07 +0000 (20:06 -0400)]
qemu: Implement virDomainFSFreeze and virDomainFSThaw

Use qemuDomainSnapshotFSFreeze() and qemuDomainSnapshotFSFThaw() which are
already implemented for snapshot quiescing.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agomaint: fix typos related to 'frozen'
Eric Blake [Tue, 13 May 2014 02:15:50 +0000 (20:15 -0600)]
maint: fix typos related to 'frozen'

"Freezed" is not an English word.

* src/lxc/lxc_driver.c (lxcFreezeContainer): Fix typo.
* src/qemu/qemu_driver.c (qemuDomainSnapshotFSFreeze): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoconf: use typedefs for enums in node_device_conf, nwfilter_params
Julio Faracco [Sun, 11 May 2014 15:08:48 +0000 (12:08 -0300)]
conf: use typedefs for enums in node_device_conf, nwfilter_params

In "src/conf/" there are many enumeration (enum) declarations. Similar
to the recent cleanup to "src/util" directory, it's better to use a
typedef for variable types, function types and other usages. Other
enumeration and folders will be changed to typedef's in the future.
Most of the files changed in this commit are reltaed to Node and
Network (node_device_conf.h and nwfilter_params.*) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodocs: mention vagrant-libvirt in apps.html
James Shubin [Sun, 11 May 2014 04:24:10 +0000 (00:24 -0400)]
docs: mention vagrant-libvirt in apps.html

Doc patch for apps.html as per: http://libvirt.org/apps.html#add

Disclaimer: I've contributed patches to the project that this commit
adds.

Vagrant-Libvirt is an excellent way to use vagrant with libvirt. This
way you can benefit from the vagrant features, while not loosing access
to the familiar (and useful) tools such as virsh and virt-manager.

Development currently at:

https://github.com/pradels/vagrant-libvirt/

although recent contributors include:

https://github.com/sciurus/vagrant-libvirt/

and:

https://github.com/purpleidea/vagrant-libvirt/

see git log for more details.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoupdate documentation of <interface type='hostdev'>
Chunyan Liu [Thu, 8 May 2014 06:44:05 +0000 (14:44 +0800)]
update documentation of <interface type='hostdev'>

<interface type='hostdev' managed='yes'> is supported, but
nowhere mentions 'managed' in <interface type='hostdev'> syntax.
Update documentation to cover it.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agolibxl: fix support for <interface type="hostdev"> syntax
Chunyan Liu [Thu, 8 May 2014 06:44:04 +0000 (14:44 +0800)]
libxl: fix support for <interface type="hostdev"> syntax

A VIR_DOMAIN_NET_TYPE_HOSTDEV interface device is really a hostdev
device, which is created by the libxl driver in libxlMakePCIList().
There is no need to create a libxl_device_nic for such hostdev
devices, so skip interfaces of type VIR_DOMAIN_NET_TYPE_HOSTDEV in
libxlMakeNicList().

Signed-off-by: Chunyan Liu <cyliu@suse.com>
10 years agomaint: use $(SED) instead of sed for syntax-check
Roman Bogorodskiy [Sun, 11 May 2014 08:25:44 +0000 (12:25 +0400)]
maint: use $(SED) instead of sed for syntax-check

Some syntax-check rules use GNU sed specific regexps, so make
sure we're using $(SED) instead of sed, which might not be a
GNU sed.

10 years agobhyve: implement connectGetSysinfo
Roman Bogorodskiy [Wed, 23 Apr 2014 09:24:05 +0000 (13:24 +0400)]
bhyve: implement connectGetSysinfo

10 years agoqemu: Implement a stub cpuArchDriver.compare() handler for arm and aarch64
Oleg Strikov [Wed, 7 May 2014 16:38:10 +0000 (20:38 +0400)]
qemu: Implement a stub cpuArchDriver.compare() handler for arm and aarch64

Libvirt calls cpuArchDriver.compare() while doing guest migration.
We don't have any logic to distinguish between different arm and
aarch64 models that's why this patch allows migration to any host.

Signed-off-by: Oleg Strikov <oleg.strikov@canonical.com>
10 years agoESX: add virStorageVolGetInfo in iSCSI backend.
Dawid Zamirski [Fri, 25 Apr 2014 18:20:41 +0000 (14:20 -0400)]
ESX: add virStorageVolGetInfo in iSCSI backend.

Since the ESX storage implements VMFS and iSCSI storage backends and
chooses relevant backend dynamically at runtime, there was a segfault
when issuing vol-info on iSCSI volume due to unimplemented
virStorageGetInfo function. This patch implements that function that was
missing in iSCSI backend and returns expected result without a segfault.

11 years agostorage: Resolve issues in failure path
John Ferlan [Tue, 6 May 2014 18:16:48 +0000 (14:16 -0400)]
storage: Resolve issues in failure path

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

Refactoring in commit id '0c2305b3' resulted in the wrong storage
volume object being passed to the new storageVolDeleteInternal().
It should have passed 'voldef' which is the address found in the
pool->volumes.objs[i] array.  By passing 'voldef', the DeleteInternal
code will find and remove the voldef from the volumes.objs[] list.

11 years agoparallels: add a set of trivial functions
Dmitry Guryanov [Wed, 23 Apr 2014 14:35:03 +0000 (18:35 +0400)]
parallels: add a set of trivial functions

Add functions parallelsIsAlive, parallelsIsEncrypted,
parallelsIsSecure which are very simple to implement, but
may be required by some libvirt users. Almost all other
drivers have these functions.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>