]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoUse virGetLastErrorMessage to avoid Coverity message
John Ferlan [Thu, 5 May 2016 22:27:00 +0000 (18:27 -0400)]
Use virGetLastErrorMessage to avoid Coverity message

Both instances use VIR_WARN() to print the error from a failed
virDBusGetSystemBus() call.  Rather than use the virGetLastError
and need to check for valid return err pointer, just use the
virGetLastErrorMessage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: command: unconditionally allow accel3d='no'
Cole Robinson [Sun, 8 May 2016 17:38:56 +0000 (13:38 -0400)]
qemu: command: unconditionally allow accel3d='no'

This matches how we handle spice gl='no' even if spice GL isn't
supported. Not too interesting in practice but I figure we should
be consistent

8 years agodomaincaps: Report video modelType
Cole Robinson [Sun, 8 May 2016 16:11:39 +0000 (12:11 -0400)]
domaincaps: Report video modelType

Requires adding the plumbing for <device><video>
The value is <enum name='modelType'> to match the associated domain
XML of <video><model type='XXX'/>

Wire it up for qemu too

8 years agodomaincaps: Report graphics type enum
Cole Robinson [Sun, 8 May 2016 15:57:20 +0000 (11:57 -0400)]
domaincaps: Report graphics type enum

Requires adding the plumbing for <device><graphics>
Wire it up for qemu too

8 years agoutil: polkit: Fix polkit agent startup
Peter Krempa [Mon, 9 May 2016 09:02:51 +0000 (11:02 +0200)]
util: polkit: Fix polkit agent startup

Commit 0b36b0e9 broke polkit agent startup when attempting to fix a
coverity warning. Refactor it properly so that we don't need the 'cmd'
intermediate variable.

8 years agoqemu: domain: Don't treat unknown storage type as not having backing chain
Peter Krempa [Thu, 5 May 2016 13:25:52 +0000 (15:25 +0200)]
qemu: domain: Don't treat unknown storage type as not having backing chain

qemuDomainCheckDiskPresence has short-circuit code to skip the
determination of the disk backing chain for storage formats that can't
have backing volumes. The code treats VIR_STORAGE_FILE_NONE as not
having backing chain and skips the call to qemuDomainDetermineDiskChain.

This is wrong as qemuDomainDetermineDiskChain is responsible for storage
format detection and has logic to determine the default type if format
detection is disabled.

This allows to storage passed via <disk type="volume"> to circumvent the
enforcement to have correct storage format or that we shall default to
format='raw', since we don't set the default type via the post parse
callback for "volume" backed disks as the translation code could come up
with a better guess.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1328003

8 years agoqemu: Reject invalid block copy targets for <disk device='lun'>
Peter Krempa [Mon, 2 May 2016 13:26:51 +0000 (15:26 +0200)]
qemu: Reject invalid block copy targets for <disk device='lun'>

Extract the relevant parts of the existing checker and reuse them for
blockcopy since copying to a non-block device creates an invalid
configuration.

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

8 years agoqemu: command: Remove unnecessary label in qemuCheckDiskConfig
Peter Krempa [Mon, 2 May 2016 13:16:50 +0000 (15:16 +0200)]
qemu: command: Remove unnecessary label in qemuCheckDiskConfig

8 years agoconf: Kill now unused virDomainDiskSourceIsBlockType
Peter Krempa [Mon, 2 May 2016 13:07:34 +0000 (15:07 +0200)]
conf: Kill now unused virDomainDiskSourceIsBlockType

8 years agoqemu: command: Use more appropriate checking function for block devices
Peter Krempa [Mon, 2 May 2016 12:57:09 +0000 (14:57 +0200)]
qemu: command: Use more appropriate checking function for block devices

In qemuCheckDiskConfig would now use virDomainDiskSourceIsBlockType just
as a glorified version of virStorageSourceIsBlockLocal that reports
error messages. Replace it with the latter including the message for
clarity.

8 years agoqemu: Support <disk device='lun'> for iSCSI direct mapped volumes
Peter Krempa [Mon, 2 May 2016 12:47:18 +0000 (14:47 +0200)]
qemu: Support <disk device='lun'> for iSCSI direct mapped volumes

Commit c820fbff9fbfe1f2549a5b60967496587f8d8bfc added support for iSCSI
disk as backing for <disk device='lun'>. We would not use it for a disk
type="volume" with direct access mode which basically maps to direct
iSCSI usage. Fix it by adding the storage source type accessor that
resolves the volume type.

8 years agolxc: Fix wrong error message on disk hotplug
Peter Krempa [Mon, 2 May 2016 11:08:53 +0000 (13:08 +0200)]
lxc: Fix wrong error message on disk hotplug

Commit 36025c552 tried to improve error reporting for <disk type="lun">
but reused the code in LXC which doesn't care about the actual disk
type. The error messages would then contain a bogous hint that the
config for the 'lun' device is invalid which might not be the case.

Re-do the relevant portion of the commit with the original message.

8 years agoutil: Replace virDomainDiskSourceIsBlockType with a new helper
Peter Krempa [Mon, 2 May 2016 11:42:32 +0000 (13:42 +0200)]
util: Replace virDomainDiskSourceIsBlockType with a new helper

For disks sources described by a libvirt volume we don't need to do a
complicated check since virStorageTranslateDiskSourcePool already
correctly determines the actual disk type.

Replace the checks using a new accessor that does not open-code the
whole logic.

8 years agoqemu_monitor_json: Follow refactor
Michal Privoznik [Wed, 4 May 2016 08:28:43 +0000 (10:28 +0200)]
qemu_monitor_json: Follow refactor

In 7884d089d2f I've started to refactor qemu_monitor_json.c.
Thing is, it's current structure is nothing like the rest of our
code. The @ret variable is rewritten all the time, if()-s are
nested instead of using goto and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: blkdeviotune: accept human readable values for bytes
Nishith Shah [Wed, 4 May 2016 14:25:10 +0000 (14:25 +0000)]
virsh: blkdeviotune: accept human readable values for bytes

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

Use vshCommandOptScaledInt instead of vshCommandOptULongLong so that
values with suffixes can be passed when bytes are being passed along.
Values for the iops parameters still need to be given in the absolute
form as they are not bytes but numbers.

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
9 years agogenericxml2xml: add several graphics tests
Pavel Hrdina [Mon, 25 Apr 2016 15:10:30 +0000 (17:10 +0200)]
genericxml2xml: add several graphics tests

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: fix migration/managedsave with usb keyboard
Pavel Hrdina [Fri, 6 May 2016 11:55:15 +0000 (13:55 +0200)]
domain_conf: fix migration/managedsave with usb keyboard

Commin 36785c7e refactored the code for input devices but introduced a
bug where we removed all keyboard from migratable XML.  We have to
remove only implicit keyboards like PS2 or XEN.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoqemu_hotplug: cleanup error messages in qemuDomainChangeGraphics
Pavel Hrdina [Mon, 25 Apr 2016 13:36:28 +0000 (15:36 +0200)]
qemu_hotplug: cleanup error messages in qemuDomainChangeGraphics

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoqemu_process: handle port allocation for VNC the same way as for Spice
Pavel Hrdina [Mon, 25 Apr 2016 13:24:48 +0000 (15:24 +0200)]
qemu_process: handle port allocation for VNC the same way as for Spice

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoqemu_process: move listen code out of qemuProcessSetupGraphics
Pavel Hrdina [Thu, 28 Apr 2016 07:35:14 +0000 (09:35 +0200)]
qemu_process: move listen code out of qemuProcessSetupGraphics

Move adding the config listen type=address if there is none in
qemuProcessPrepareDomain and move check for multiple listens to
qemuProcessStartValidate.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agographics: use enums instead of int
Pavel Hrdina [Mon, 2 May 2016 15:45:23 +0000 (17:45 +0200)]
graphics: use enums instead of int

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirCgroupValidateMachineGroup: Reflect change in CGroup struct naming
Michal Privoznik [Thu, 5 May 2016 15:35:38 +0000 (17:35 +0200)]
virCgroupValidateMachineGroup: Reflect change in CGroup struct naming

Fron c3bd0019c0e on instead of creating the following path for
cgroups:

  /sys/fs/cgroupX/$name.libvirt-$driver

we generate rather more verbose one:

  /sys/fs/cgroupX/$driver-$id-$name.libvirt-$driver

where $name is optional and included iff contains allowed chars.
See original commit for more reasoning. Now, problem with the
original commit is that we are unable to start any LXC domain
after it. Because when starting LXC container, the CGroup layout
is created by our lxc_controller process and then detected and
validated by libvirtd. The validation is done by trying to match
detected layout against all the possible patterns for cgroup
paths that we've ever had. And the commit in question forgot to
update this part of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodomaincapstest: Add tests for QEMU 2.6
Jiri Denemark [Thu, 28 Apr 2016 12:24:51 +0000 (14:24 +0200)]
domaincapstest: Add tests for QEMU 2.6

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Add tests for aarch64 and ppc64le
Jiri Denemark [Wed, 27 Apr 2016 14:48:56 +0000 (16:48 +0200)]
qemucapabilitiestest: Add tests for aarch64 and ppc64le

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agodomaincapstest: Use default machine type
Jiri Denemark [Thu, 28 Apr 2016 16:01:18 +0000 (18:01 +0200)]
domaincapstest: Use default machine type

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Rename *.caps to *.xml
Jiri Denemark [Thu, 28 Apr 2016 15:45:41 +0000 (17:45 +0200)]
qemucapabilitiestest: Rename *.caps to *.xml

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Test all capabilities
Jiri Denemark [Thu, 28 Apr 2016 15:02:38 +0000 (17:02 +0200)]
qemucapabilitiestest: Test all capabilities

Enhance the test to cover all capabilities we probe for rather than
testing the flags only.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Reorder flags in caps files
Jiri Denemark [Thu, 28 Apr 2016 15:27:40 +0000 (17:27 +0200)]
qemucapabilitiestest: Reorder flags in caps files

The flags should follow the order in which they are defined in
virQEMUCaps enum.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Reindent *.caps files
Jiri Denemark [Thu, 28 Apr 2016 15:10:19 +0000 (17:10 +0200)]
qemucapabilitiestest: Reindent *.caps files

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Uses consistent names
Jiri Denemark [Thu, 28 Apr 2016 13:54:31 +0000 (15:54 +0200)]
qemucapabilitiestest: Uses consistent names

In other tests we use "expected" and "actual" to refer to the expected
outcome of the tested API and the result we got, respectively.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Export caps cache APIs for tests
Jiri Denemark [Thu, 28 Apr 2016 13:01:02 +0000 (15:01 +0200)]
qemu: Export caps cache APIs for tests

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate formatting from saving into caps cache
Jiri Denemark [Thu, 28 Apr 2016 12:59:15 +0000 (14:59 +0200)]
qemu: Separate formatting from saving into caps cache

We will need to use the formatter directly for testing QEMU capabilities
code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemucapabilitiestest: Prepare for testing non-x86_64 archs
Jiri Denemark [Mon, 25 Apr 2016 12:19:49 +0000 (14:19 +0200)]
qemucapabilitiestest: Prepare for testing non-x86_64 archs

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Refactor domaincapstest
Jiri Denemark [Mon, 25 Apr 2016 12:20:58 +0000 (14:20 +0200)]
tests: Refactor domaincapstest

The test was just a big mess passing callbacks and their data through
data for another callback.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuDomainSecretIV
John Ferlan [Mon, 2 May 2016 10:43:32 +0000 (06:43 -0400)]
qemu: Introduce qemuDomainSecretIV

Add the data structure and infrastructure to support an initialization
vector (IV) secrets. The IV secret generation will need to have access
to the domain private master key, so let's make sure the prepare disk
and hostdev functions can accept that now.

Anywhere that needs to make a decision over which secret type to use
in order to fill in or use the IV secret has a switch added.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Separate network URI command building code
John Ferlan [Mon, 2 May 2016 10:39:43 +0000 (06:39 -0400)]
qemu: Separate network URI command building code

Create helper API's in order to build the network URI as shortly we will
be adding a new SecretInfo type

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuDomainSecretDestroy to qemuProcessLaunch
John Ferlan [Mon, 2 May 2016 17:31:47 +0000 (13:31 -0400)]
qemu: Move qemuDomainSecretDestroy to qemuProcessLaunch

Rather than need to call qemuDomainSecretDestroy after any call to
qemuProcessLaunch, let's do the destroy in qemuProcessLaunch since
that's where command line is eventually generated and processed. Once
it's generated, we can clear out the secrets.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuDomainSecretPrepare to qemuProcessPrepareDomain
John Ferlan [Mon, 2 May 2016 17:20:55 +0000 (13:20 -0400)]
qemu: Move qemuDomainSecretPrepare to qemuProcessPrepareDomain

Commit id '40d8e2ba3' added the function to qemuProcessStart because
in order to set up some secrets in the future we will need the master
key. However, since the previous patch split the master key creation
into two parts (create just the key and create the file), we can now
call qemuDomainSecretPrepare from qemuProcessPrepareDomain since the
file is not necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Split out the master key create and write
John Ferlan [Mon, 2 May 2016 17:11:24 +0000 (13:11 -0400)]
qemu: Split out the master key create and write

A recent review of related changes noted that we should split the creation
(or generation) of the master key into the qemuProcessPrepareDomain and leave
the writing of the master key for qemuProcessPrepareHost.

Made the adjustment and modified some comments to functions that have
changed calling parameters, but didn't change the intro doc.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Adjust names of qemuDomainSecretInfoType enums
John Ferlan [Mon, 2 May 2016 11:20:32 +0000 (07:20 -0400)]
qemu: Adjust names of qemuDomainSecretInfoType enums

From a review after push, add the "_TYPE" into the name.

Also use qemuDomainSecretInfoType in the struct rather than int
with the comment field containing the struct name

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agorpc: use virNetMessageClearPayload in client
Cole Robinson [Wed, 27 Apr 2016 22:02:22 +0000 (18:02 -0400)]
rpc: use virNetMessageClearPayload in client

This removes the opencoded payload freeing in the client, to use
the shared virNetMessageClearPayload call. Two changes:

- ClearPayload sets nfds=0, which fixes a potential crash if
  an error path called virNetMessageFree/Clear on the message
  after fds was free'd
- We drop the inner loop VIR_FORCE_CLOSE... this may mean fds are
  kept open a little bit longer if the call is blocking but in
  practice I don't think it will have any effect

9 years agorpc: Clear more in virNetMessageClearPayload
Cole Robinson [Wed, 27 Apr 2016 21:55:54 +0000 (17:55 -0400)]
rpc: Clear more in virNetMessageClearPayload

Set all counters to 0. This doesn't impact current users, but
future users will want this

9 years agorpc: Add virNetMessageClearPayload
Cole Robinson [Wed, 27 Apr 2016 21:47:34 +0000 (17:47 -0400)]
rpc: Add virNetMessageClearPayload

Handles freeing the buffer and fds, but not the message details.
Use it to drop some duplicate code.

9 years agovirNetServerClientNewPostExecRestart: Avoid align problems
Michal Privoznik [Thu, 5 May 2016 07:07:50 +0000 (09:07 +0200)]
virNetServerClientNewPostExecRestart: Avoid align problems

I've noticed this while trying to compile libvirt on my arm box.

  CC       rpc/libvirt_net_rpc_server_la-virnetserverclient.lo
rpc/virnetserverclient.c: In function 'virNetServerClientNewPostExecRestart':
rpc/virnetserverclient.c:516:45: error: cast increases required alignment of target type [-Werror=cast-align]
                                             (long long *) &timestamp) < 0) {
                                             ^
cc1: all warnings being treated as errors

Problem is, @timestap is defined as time_t which is 32 bits long,
and we are typecasting it to long long which is 64bits long.
Solution is to make @timestamp type of long long. At the same
time, we can make @conn_time in _virNetServerClient struct long
long too. There is no need for it to be type of time_t.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirNetServerClientNewPostExecRestart: Drop useless typecasts
Michal Privoznik [Thu, 5 May 2016 06:42:50 +0000 (08:42 +0200)]
virNetServerClientNewPostExecRestart: Drop useless typecasts

In this function, @id is defined as unsigned long long. When
passing this variable to virJSONValueObjectGetNumberUlong(),
well address of this variable, it's typecasted to ull*. There
is no need for that. It's a same story with @nrequests_max.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoAdd qemucapsprobe in .gitignore
Jiri Denemark [Thu, 5 May 2016 08:09:32 +0000 (10:09 +0200)]
Add qemucapsprobe in .gitignore

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Add qemucapsprobe helper
Jiri Denemark [Tue, 26 Apr 2016 13:04:55 +0000 (15:04 +0200)]
tests: Add qemucapsprobe helper

Adding new *.replies files for qemucapabilitiestest or updating the
files when libvirt adds an additional QMP command into the probing
process is quite painful. The goal of the new qemucapsprobe command is
to make this process as easy as

    tests/qemucapsprobe /path/to/qemu/binary >caps.replies

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirjson: Make pretty format more compact
Jiri Denemark [Wed, 27 Apr 2016 14:49:25 +0000 (16:49 +0200)]
virjson: Make pretty format more compact

json_reformat uses two spaces for when indenting nested objects, let's
do the same. The result of virJSONValueToString will be exactly the same
as json_reformat would produce.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Make qemuMonitorJSONIOProcessLine available for tests
Jiri Denemark [Wed, 27 Apr 2016 14:50:43 +0000 (16:50 +0200)]
qemu: Make qemuMonitorJSONIOProcessLine available for tests

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Make virQEMUCapsNewForBinary usable from tests
Jiri Denemark [Tue, 26 Apr 2016 13:03:06 +0000 (15:03 +0200)]
qemu: Make virQEMUCapsNewForBinary usable from tests

virQEMUCapsNewForBinary unconditionally loads data from cache and probes
using both QMP and -help parsing, which is suboptimal when we want to
use it in tests.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Decouple preload code from main()
Jiri Denemark [Tue, 26 Apr 2016 13:00:24 +0000 (15:00 +0200)]
tests: Decouple preload code from main()

The new VIRT_TEST_PRELOAD macro does not force the caller to create a
special main function which would need to be called through
virtTestMain().

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Create a shared library with qemu driver
Jiri Denemark [Tue, 26 Apr 2016 12:58:56 +0000 (14:58 +0200)]
tests: Create a shared library with qemu driver

Currently all qemu driver tests are statically linked to qemu driver
library, which makes it impossible to mock any API from the library.
This patch creates a shared qemu driver library which can be used
instead of the static one.

NB we can't use libvirt_driver_qemu.so directly since it is linked with
-module and it is supposed to be dlopened.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agobhyve: implement domainShutdown
Roman Bogorodskiy [Wed, 4 May 2016 16:41:59 +0000 (19:41 +0300)]
bhyve: implement domainShutdown

Bhyve supports ACPI shutdown by issuing SIGTERM signal to a bhyve
process.

Add the bhyveDomainShutdown() function and virBhyveProcessShutdown()
helper function that just sends SIGTERM to VM's bhyve process. If
a guest supports ACPI shutdown then process will be terminated and
this event will be noticed by the bhyve monitor code that will handle
setting proper status and clean up VM's resources by calling
virBhyveProcessStop().

9 years agobhyve: drop virProcessKillPainfully() from destroy
Roman Bogorodskiy [Wed, 4 May 2016 16:41:58 +0000 (19:41 +0300)]
bhyve: drop virProcessKillPainfully() from destroy

Current implementation of domainDestroy for bhyve calls
virProcessKillPainfully() for the bhyve process and then
executes "bhyvectl --destroy".

This is wrong for two reasons:

 * bhyvectl --destroy alone is sufficient because it terminates
   the process
 * virProcessKillPainfully() first sends SIGTERM and after few
   attempts sends SIGKILL. As SIGTERM triggers ACPI shutdown that
   we're not interested in, it creates an unwanted side effect in
   domainDestroy.

Also, destroy monitor only after "bhyvectl --destroy" command succeeded
to avoid a case when the command fails and domain remains running, but
not being monitored anymore.

9 years agobuild: fix 32-bit build of admin
Eric Blake [Wed, 4 May 2016 19:15:11 +0000 (13:15 -0600)]
build: fix 32-bit build of admin

We can't guarantee which 64-bit type will be used in an RPC struct;
while %lu worked on 64-bit Linux, that won't always be the type
used on all 64-bit platforms; and certainly is not right for 32-bit:

admin.c: In function 'adminDispatchClientGetInfo':
admin.c:265:25: error: format '%lu' expects argument of type 'long unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Werror=format=]

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agovirsh: Pass the correct live/config xml to virshDomainDetachInterface.
Nitesh Konkar [Wed, 4 May 2016 14:26:27 +0000 (10:26 -0400)]
virsh: Pass the correct live/config xml to virshDomainDetachInterface.

cmdDetachInterface function checks for live config
flags and then passes the live/config domain xml
to virshDomainDetachInterface accordingly.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
9 years agovirsh: Introduce virshDomainDetachInterface function
Nitesh Konkar [Wed, 4 May 2016 14:26:26 +0000 (10:26 -0400)]
virsh: Introduce virshDomainDetachInterface function

virshDomainDetachInterface handles virsh interface
detach from the specified live/config domain xml.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
9 years agoadmin: Add a check to reject negative argument for number of typed params
Erik Skultety [Tue, 3 May 2016 15:04:42 +0000 (17:04 +0200)]
admin: Add a check to reject negative argument for number of typed params

Since nparams can be technically negative, it is a good practice throughout
our code to check if nparams actually has a non-negative value. The same effect
would be achieved by converting our internal typed params serializer argument
to 'unsigned' type, but it definitely would not be the path of least resistance.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agotools: virt-host-validate: HW virt support on s390
Bjoern Walk [Tue, 3 May 2016 06:10:54 +0000 (08:10 +0200)]
tools: virt-host-validate: HW virt support on s390

Extend the detection of hardware virtualization to the s390 platform.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
9 years agotools: virt-host-validate: improve error handling
Bjoern Walk [Tue, 3 May 2016 06:10:53 +0000 (08:10 +0200)]
tools: virt-host-validate: improve error handling

When virHostValidateCPUFlag returns NULL, that's more an unexpected
error than the sign of missing CPU flags. Let's react to this
appropriately.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
9 years agotools: virt-host-validate: fix CPU flag detection
Bjoern Walk [Tue, 3 May 2016 06:10:52 +0000 (08:10 +0200)]
tools: virt-host-validate: fix CPU flag detection

Let's fix CPU flag detection on s390, where the flags line begins with
a lower-case 'features'.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
9 years agotools: virt-host-validate: fix missing translation marker
Bjoern Walk [Tue, 3 May 2016 06:10:51 +0000 (08:10 +0200)]
tools: virt-host-validate: fix missing translation marker

Fix a minor typo.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
9 years agoqemu: Add 'iothread' to command line for supported controller
John Ferlan [Thu, 21 Apr 2016 16:07:00 +0000 (12:07 -0400)]
qemu: Add 'iothread' to command line for supported controller

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

Now that we have all the pieces in place, we can add the 'iothread=#' to
the command line for the (two) controllers that support it (virtio-scsi-pci
and virtio-scsi-ccw). Add the tests as well...

9 years agoqemu: Use switch for qemuCheckIOThreads
John Ferlan [Mon, 18 Apr 2016 11:39:59 +0000 (07:39 -0400)]
qemu: Use switch for qemuCheckIOThreads

Rather than an if statement, use a switch.

The switch will also catch the illegal usage of 'iothread' with some other
kind of unsupported bus configuration.

9 years agoconf: Add support for virtio-scsi iothreads
John Ferlan [Wed, 20 Apr 2016 14:49:21 +0000 (10:49 -0400)]
conf: Add support for virtio-scsi iothreads

Add the ability to add an 'iothread' to the controller which will be how
virtio-scsi-pci and virtio-scsi-ccw iothreads have been implemented in qemu.

Describe the new functionality and add tests to parse/validate that the
new attribute can be added.

9 years agoPull latest translations from zanata
Daniel P. Berrange [Wed, 4 May 2016 10:27:16 +0000 (11:27 +0100)]
Pull latest translations from zanata

9 years agolibvirt.spec: remove duplicate files from -docs package
Daniel P. Berrange [Wed, 4 May 2016 09:11:37 +0000 (10:11 +0100)]
libvirt.spec: remove duplicate files from -docs package

Previous commit moved some lists out of the -devel package
and into the -docs package

  commit feffcc03a0d3690dcffd860682dcbaa61d726b39
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Wed Apr 13 10:37:42 2016 -0400

    spec: Only pull in API docs with -devel package

What was not realized is that the rule 'libvirt-docs/*'
and ' docs/*.html docs/html docs/*.gif' actually point
to the exact same content. ie, we had previously included
the website HTML in *both* the -docs and -devel packages.

So this change ended up listing the files twice, which
caused RPM to print a load of warnings:

warning: File listed twice: /usr/share/doc/libvirt-docs/html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/32favicon.png
warning: File listed twice: /usr/share/doc/libvirt-docs/html/404.html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/acl.html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/aclpolkit.html

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agovirsh: volume: Add --bytes to 'vol-info'
Peter Krempa [Tue, 3 May 2016 15:24:55 +0000 (17:24 +0200)]
virsh: volume: Add --bytes to 'vol-info'

9 years agodaemon: Add VIR_ERR_NO_SERVER and VIR_ERR_NO_CLIENT to daemonErrorLogFilter
Erik Skultety [Wed, 4 May 2016 07:30:58 +0000 (09:30 +0200)]
daemon: Add VIR_ERR_NO_SERVER and VIR_ERR_NO_CLIENT to daemonErrorLogFilter

Commits 52a2eef9 and 62be5486 forgot to add these errors to daemon's error
whitelist, i.e. in order to avoid log file pollution with errors like "Domain
not found" or "Server not found" in this case, since these events are valid
and expected to occur.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoconf: Move virDomainControllerModelTypeToString
John Ferlan [Thu, 21 Apr 2016 13:27:01 +0000 (09:27 -0400)]
conf: Move virDomainControllerModelTypeToString

Move virDomainControllerModelTypeToString closer to it's counterpart
virDomainControllerModelTypeFromString.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agodocs: Reformat the Controllers description
John Ferlan [Thu, 21 Apr 2016 12:35:54 +0000 (08:35 -0400)]
docs: Reformat the Controllers description

Reformat to use <dt> elements to make it a bit easier to read.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agodocs: clarify disk iothread support
John Ferlan [Thu, 21 Apr 2016 11:53:08 +0000 (07:53 -0400)]
docs: clarify disk iothread support

Rather than be specific about which devices in the <iothreads> description,
let's leave that for the <disk> description for it's <iothread> value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Add capability for virtio-scsi iothreads
John Ferlan [Wed, 20 Apr 2016 18:43:04 +0000 (14:43 -0400)]
qemu: Add capability for virtio-scsi iothreads

An iothread for virtio-scsi is a property of the controller. Add a lookup
of the 'virtio-scsi-pci' and 'virtio-scsi-ccw' device properties and parse
the output.  For both, support for the iothread was added in qemu 2.4
while support for virtio-scsi in general was added in qemu 1.4.

Modify the various mock capabilities replies (by hand) to reflect the
when virtio-scsi was supported and then specifically when the iothread
property was added. For versions prior to 1.4, use the no device error
return for virtio-scsi. For versions 1.4 to before 2.4, add some data
for virtio-scsi-pci even though it isn't complete we're not looking for
anything specific there anyway. For 2.4 to 2.6, add a more complete reply.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agospec: Rename %{init_scripts} -> %{with_init_script}
Andrea Bolognani [Tue, 3 May 2016 08:43:23 +0000 (10:43 +0200)]
spec: Rename %{init_scripts} -> %{with_init_script}

The convention used throughout the file is to name variables after
the configure option they refer to.

9 years agospec: Type --with-init-script correctly
Andrea Bolognani [Tue, 3 May 2016 08:40:35 +0000 (10:40 +0200)]
spec: Type --with-init-script correctly

Mixing dashes and underscores in configure options apparently
works fine, but it's confusing and just plain ugly.

9 years agoconfigure: Remove nested conditionals in LIBVIRT_CHECK_INIT_SCRIPT
Andrea Bolognani [Tue, 3 May 2016 08:34:52 +0000 (10:34 +0200)]
configure: Remove nested conditionals in LIBVIRT_CHECK_INIT_SCRIPT

We don't need them any longer; moreover, the previous structure
made it very easy for bugs to slip in, by having the result of one
check influence the following one.

By placing the check for "$with_init_script" = check front and
center, hopefully this won't happen (as easily) again.

9 years agoconfigure: Change RHEL default from systemd+redhat to systemd
Andrea Bolognani [Tue, 3 May 2016 08:31:01 +0000 (10:31 +0200)]
configure: Change RHEL default from systemd+redhat to systemd

We don't want to install legacy init scripts on modern,
systemd-native hosts.

9 years agomaint: Ignore all .init, .service and .socket files
Andrea Bolognani [Tue, 3 May 2016 13:36:01 +0000 (15:36 +0200)]
maint: Ignore all .init, .service and .socket files

All files with those extensions are generated, so we can have
three generic rules instead of explicitly ignoring every single
instance.

9 years agovirt-admin: Introduce command client-info
Erik Skultety [Fri, 22 Apr 2016 11:12:01 +0000 (13:12 +0200)]
virt-admin: Introduce command client-info

Wire-up the client identity getter into virt-admin tool. This patch adjusts
man-page accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Introduce virAdmClientGetInfo API
Erik Skultety [Fri, 22 Apr 2016 11:05:42 +0000 (13:05 +0200)]
admin: Introduce virAdmClientGetInfo API

Expose a public API to retrieve some identity and connection information about
a client connected to the specified server on daemon. The identity info
retrieved is mostly connection transport dependent, i.e. there won't be any
socket address returned for a local (UNIX socket) connection, while on the
other hand, when connected through TLS or unencrypted TCP, obviously no UNIX
process identification will be present in the returned data. All supported
values that can be returned in typed params are exposed and documented in
include/libvirt/libvirt-admin.h

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agovirnetserverclient: Add an internal method to retrieve client's identity
Erik Skultety [Fri, 22 Apr 2016 11:08:10 +0000 (13:08 +0200)]
virnetserverclient: Add an internal method to retrieve client's identity

This method just aggregates various client object attributes, like socket
address, connection type (RO/RW), and some TCP/TLS/UNIX identity in an atomic
manner.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agovirneserverclient: Introduce virNetServerClientHasSASLSession
Erik Skultety [Fri, 22 Apr 2016 10:54:26 +0000 (12:54 +0200)]
virneserverclient: Introduce virNetServerClientHasSASLSession

We do have a similar method, serving the same purpose, for TLS, but we lack
one for SASL. So introduce one, in order for other modules to be able to find
out, if a SASL session is active, or better said, that a SASL session exists
at all.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agovirnetsocket: Provide socket address format in a more standard form
Erik Skultety [Tue, 26 Apr 2016 11:39:06 +0000 (13:39 +0200)]
virnetsocket: Provide socket address format in a more standard form

Our socket address format is in a rather non-standard format and that is
because sasl library requires the IP address and service to be delimited by a
semicolon. The string form is a completely internal matter, however once the
admin interfaces to retrieve client identity information are merged, we should
return the socket address string in a common format, e.g. format defined by
URI rfc-3986, i.e. the IP address and service are delimited by a colon and
in case of an IPv6 address, square brackets are added:

Examples:
    127.0.0.1:1234
    [::1]:1234

This patch changes our default format to the one described above, while adding
separate methods to request the non-standard SASL format using semicolon as a
delimiter.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: include: Introduce some client's identity related typed params macros
Erik Skultety [Fri, 22 Apr 2016 09:00:50 +0000 (11:00 +0200)]
admin: include: Introduce some client's identity related typed params macros

This patch could easily be squashed with the virAdmClientGetInfo method
introduced later one, but the idea was to split the logic to as many preferably
independent patches as possible. As the subject hints, this patch defines
some public typed params-related macros used within virAdmClientGetInfo
method. The thing is, there's one identity attribute missing in the set --
SELinux context, which libvirt internally supports in virIdentity, but it
doesn't seem to do much (or anything at all), so there's some room to extend
the set in the future.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Introduce virAdmServerLookupClient
Erik Skultety [Fri, 22 Apr 2016 07:47:09 +0000 (09:47 +0200)]
admin: Introduce virAdmServerLookupClient

Just like with server-related APIs, before any of client-based APIs can be
called, a reference to a client-side client object needs to be obtained. For
this purpose, a lookup method should exist. Apart from the client retrieval
logic, a new error code for non-existent client had to be added as well.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoqemu_monitor_json: Follow our coding style
Michal Privoznik [Tue, 3 May 2016 09:29:11 +0000 (11:29 +0200)]
qemu_monitor_json: Follow our coding style

In majority of our functions we have this variable @ret that is
overwritten a lot. In other areas of the code we use 'goto
cleanup;' just so that this wouldn't happen. But here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agomaint: Don't ignore libvirtd.pod any longer
Andrea Bolognani [Tue, 3 May 2016 13:10:27 +0000 (15:10 +0200)]
maint: Don't ignore libvirtd.pod any longer

Starting from commit 5b479f3b5b82, libvirtd.pod is a source file
rather than a generated file. Update ignore patterns accordingly.

9 years agogitignore: ignore virt(log|lock)d.(service|socket)
Cole Robinson [Tue, 3 May 2016 12:48:33 +0000 (08:48 -0400)]
gitignore: ignore virt(log|lock)d.(service|socket)

9 years agodaemon: add option to read host uuid from /etc/machine-id
Nikolay Shirokovskiy [Tue, 3 May 2016 09:12:41 +0000 (12:12 +0300)]
daemon: add option to read host uuid from /etc/machine-id

Daemon config parameter switch between reading host uuid
either from smbios or machine-id:

host_uuid_source = "smbios|machine-id"

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoutil: factor out reading file into preallocated buffer
Nikolay Shirokovskiy [Tue, 3 May 2016 09:12:40 +0000 (12:12 +0300)]
util: factor out reading file into preallocated buffer

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoqemu: support configuring usb3 controller port count
Cole Robinson [Sat, 23 Apr 2016 23:52:56 +0000 (19:52 -0400)]
qemu: support configuring usb3 controller port count

This adds a ports= attribute to usb controller XML, like

  <controller type='usb' model='nec-xhci' ports='8'/>

This maps to:

  qemu -device nec-usb-xhci,p2=8,p3=8

Meaning, 8 ports that support both usb2 and usb3 devices. Gerd
suggested to just expose them as one knob.

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

9 years agoqemu: caps: introduce QEMU_CAPS_NEC_USB_XHCI_PORTS
Cole Robinson [Sun, 24 Apr 2016 14:52:38 +0000 (10:52 -0400)]
qemu: caps: introduce QEMU_CAPS_NEC_USB_XHCI_PORTS

Reports whether we support -device nec-usb-xhci,p3=XXX value,
which has been available since qemu 1.3.0

9 years agoqemu: parse: Use virControllerDefNew
Cole Robinson [Sun, 24 Apr 2016 15:05:31 +0000 (11:05 -0400)]
qemu: parse: Use virControllerDefNew

Rather than reimplement it. This will be needed in upcoming patches

9 years agoqemu_monitor_json: Drop redundant checks
Michal Privoznik [Tue, 3 May 2016 08:55:41 +0000 (10:55 +0200)]
qemu_monitor_json: Drop redundant checks

In these functions I'm fixing here, we do call
qemuMonitorJSONCheckError() followed by another check if qemu
reply contains 'return' object. If it wouldn't, the former
CheckError() function would error out and the flow would not even
get to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuMonitorJSONQueryRxFilter: Validate qemu reply prior parsing it
Michal Privoznik [Tue, 3 May 2016 08:44:13 +0000 (10:44 +0200)]
qemuMonitorJSONQueryRxFilter: Validate qemu reply prior parsing it

Usually, the flow in this area of the code is as follows:

qemuMonitorJSONMakeCommand()
qemuMonitorJSONCommand()
qemuMonitorJSONCheckError()
parseReply()

But in this function, for some reasons, the last two steps were
swapped. This makes no sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRemove useless os.machine NULL check
Ján Tomko [Tue, 3 May 2016 10:29:26 +0000 (12:29 +0200)]
Remove useless os.machine NULL check

In qemuDomainDefAddDefaultDevices we check for a non-NULL
def->os.machine for x86 archs, but not the others.

Moreover, the only caller - qemuDomainDefPostParse
already checks for it and even then it can happen only
if /etc/libvirt contains an XML without a machine type.

9 years agoIntroduce qemuDomainMachineIsVirt
Ján Tomko [Tue, 3 May 2016 08:49:40 +0000 (10:49 +0200)]
Introduce qemuDomainMachineIsVirt

Use it everywhere except for virQEMUCapsFillDomainFeatureGICCaps.

9 years agoRewrite the condition in qemuDomainAssignARMVirtioMMIOAddresses
Ján Tomko [Tue, 3 May 2016 08:54:55 +0000 (10:54 +0200)]
Rewrite the condition in qemuDomainAssignARMVirtioMMIOAddresses

It was not indented correctly.

9 years agoRemove useless variable in qemuDomainAssignAddresses
Ján Tomko [Thu, 28 Apr 2016 13:35:41 +0000 (15:35 +0200)]
Remove useless variable in qemuDomainAssignAddresses

We do not need to propagate the exact return values
and the only possible ones are 0 and -1 anyway.

Remove the temporary variable and use the usual pattern:

if (f() < 0)
    return -1;

9 years agoReturn void in qemuDomainAssignARMVirtioMMIOAddresses
Ján Tomko [Thu, 28 Apr 2016 13:31:52 +0000 (15:31 +0200)]
Return void in qemuDomainAssignARMVirtioMMIOAddresses

This function does not fail and it does not need to return anything.