]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: Enable secure boot
Michal Privoznik [Wed, 13 Jul 2016 09:33:52 +0000 (11:33 +0200)]
qemu: Enable secure boot

In qemu, enabling this feature boils down to adding the following
onto the command line:

  -global driver=cfi.pflash01,property=secure,value=on

However, there are some constraints resulting from the
implementation. For instance, System Management Mode (SMM) is
required to be enabled, the machine type must be q35-2.4 or
later, and the guest should be x86_64. While technically it is
possible to have 32 bit guests with secure boot, some non-trivial
CPU flags tuning is required (for instance lm and nx flags must
be prohibited). Given complexity of our CPU driver, this is not
trivial. Therefore I've chosen to forbid 32 bit guests for now.
If there's ever need, we can refine the check later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoIntroduce @secure attribute to os loader element
Michal Privoznik [Wed, 13 Jul 2016 07:22:51 +0000 (09:22 +0200)]
Introduce @secure attribute to os loader element

This element will control secure boot implemented by some
firmwares. If the firmware used in <loader/> does support the
feature we must tell it to the underlying hypervisor. However, we
can't know whether loader does support it or not just by looking
at the file. Therefore we have to have an attribute to the
element where users can tell us whether the firmware is secure
boot enabled or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoIntroduce SMM feature
Michal Privoznik [Wed, 13 Jul 2016 12:09:20 +0000 (14:09 +0200)]
Introduce SMM feature

Since its release of 2.4.0 qemu is able to enable System
Management Module in the firmware, or disable it. We should
expose this capability in the XML. Unfortunately, there's no good
way to determine whether the binary we are talking to supports
it. I mean, if qemu's run with real machine type, the smm
attribute can be seen in 'qom-list /machine' output. But it's not
there when qemu's run with -M none. Therefore we're stuck with
version based check.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMachineCommandLine: Follow our pattern
Michal Privoznik [Wed, 13 Jul 2016 11:57:17 +0000 (13:57 +0200)]
qemuBuildMachineCommandLine: Follow our pattern

We use 'goto cleanup' for a reason. If a function can exit at
many places but doesn't follow the pattern, it has to copy the
free code in multiple places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agorpm: set TLS priority to @LIBVIRT,SYSTEM on Fedora >= 25
Daniel P. Berrange [Thu, 4 Aug 2016 07:56:27 +0000 (08:56 +0100)]
rpm: set TLS priority to @LIBVIRT,SYSTEM on Fedora >= 25

With newest gnutls available in Fedora 25/rawhide, it is
possible to have TLS priority fallbacks, so we can finally
use --tls-priority=@LIBVIRT,SYSTEM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agotests: qemuxml2xml: Add some USB test cases
Andrea Bolognani [Fri, 29 Jul 2016 14:09:53 +0000 (16:09 +0200)]
tests: qemuxml2xml: Add some USB test cases

All these configurations are already covered for qemuxml2argv,
but there were no equivalent tests for qemuxml2xml.

8 years agotests: qemuxml2xml: Use DO_TEST() for most tests
Andrea Bolognani [Fri, 29 Jul 2016 13:27:03 +0000 (15:27 +0200)]
tests: qemuxml2xml: Use DO_TEST() for most tests

Now that DO_TEST() can be passed capabilities, there is little
need to use DO_TEST_FULL() instead of DO_TEST().

8 years agotests: qemuxml2xml: Pass capabilities to DO_TEST()
Andrea Bolognani [Fri, 29 Jul 2016 13:13:56 +0000 (15:13 +0200)]
tests: qemuxml2xml: Pass capabilities to DO_TEST()

This will allow us to remove most DO_TEST_FULL() usages. For the
time being, just add the extra argument to all DO_TEST() calls.

8 years agotests: qemuxml2xml: Use WHEN_BOTH for most tests
Andrea Bolognani [Fri, 29 Jul 2016 12:47:40 +0000 (14:47 +0200)]
tests: qemuxml2xml: Use WHEN_BOTH for most tests

A bunch of cases were only being tested for WHEN_ACTIVE or
WHEN_INACTIVE. Use WHEN_BOTH for all except the very few that
actually require the existing setup.

8 years agotests: qemuxml2xml: Clean up disk-mirror
Andrea Bolognani [Fri, 29 Jul 2016 12:20:12 +0000 (14:20 +0200)]
tests: qemuxml2xml: Clean up disk-mirror

Instead of testing it twice using WHEN_ACTIVE and WHEN_INACTIVE
separately, just use WHEN_BOTH.

8 years agotests: qemuxml2argv: Fix usb-too-long-port-path-invalid
Andrea Bolognani [Fri, 29 Jul 2016 11:54:13 +0000 (13:54 +0200)]
tests: qemuxml2argv: Fix usb-too-long-port-path-invalid

The test case uses DO_TEST_PARSE_FLAGS_ERROR(), but doesn't
pass any parse flag. Use DO_TEST_PARSE_ERROR() instead.

8 years agotests: qemuxml2argv: Remove useless GIC flags
Andrea Bolognani [Fri, 29 Jul 2016 16:11:26 +0000 (18:11 +0200)]
tests: qemuxml2argv: Remove useless GIC flags

DO_TEST_FAILURE() doesn't take a GIC version, but the GIC flag
was passed anyway. Get rid of all such occurrences.

8 years agovirObjectEventNew: Use virObjectUnref() to free virObjectEvent
Michal Privoznik [Thu, 4 Aug 2016 06:33:17 +0000 (08:33 +0200)]
virObjectEventNew: Use virObjectUnref() to free virObjectEvent

While no leak was observed yet, there might be one if
virObjectEventClass is ever derived from another class. Because
in that case plain VIR_FREE() will not call dispose() from parent
classes possibly leaking some memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agolibxlDoMigrateReceive: Drop useless check for !vm
Michal Privoznik [Wed, 3 Aug 2016 12:48:01 +0000 (14:48 +0200)]
libxlDoMigrateReceive: Drop useless check for !vm

In the cleanup path, @vm cannot be possibly NULL. If it were so,
we would receive SIGSEGV much earlier. At the beginning of the
function we do libxlDomainObjBeginJob(.., vm, ..); and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirshConnect: Don't leak polkit agent
Michal Privoznik [Wed, 3 Aug 2016 12:41:50 +0000 (14:41 +0200)]
virshConnect: Don't leak polkit agent

In our attempts to reconnect, we may create a polkit daemon.
However, it may happen that we would rewrite the variable that
already holds pointer to the agent.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurityselinuxlabeltest: Prefer virGetLastErrorMessage() over virGetLastError
Michal Privoznik [Thu, 4 Aug 2016 07:20:31 +0000 (09:20 +0200)]
securityselinuxlabeltest: Prefer virGetLastErrorMessage() over virGetLastError

At the beginning of the test, some preparation work is done. For
instance new virSecurityManager is created. If this fails for
whatever reason, we try to fetch the latest error and print the
error message contained in it. However, if there's a bug in our
code and no error is reported, this approach will lead to crash,
while with virGetLastErrorMessage() it won't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirqemu: Reflect return type of virJSONValueArraySize()
Michal Privoznik [Wed, 3 Aug 2016 06:32:44 +0000 (08:32 +0200)]
virqemu: Reflect return type of virJSONValueArraySize()

The virJSONValueArraySize() function return ssize_t (with
possibly returning -1 if the passed json is not an array).
Storing the return value into size_t is possibly dangerous then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: domain: Simplify return values of qemuDomainRefreshVcpuInfo
Peter Krempa [Mon, 1 Aug 2016 05:35:50 +0000 (07:35 +0200)]
qemu: domain: Simplify return values of qemuDomainRefreshVcpuInfo

Call the vcpu thread info validation separately to decrease complexity
of returned values by qemuDomainRefreshVcpuInfo.

This function now returns 0 on success and -1 on error. Certain
failures of qemu to report data are still considered as success. Any
error reported now is fatal.

8 years agoqemu: domain: Improve vCPU data checking in qemuDomainRefreshVcpu
Peter Krempa [Fri, 8 Jul 2016 13:39:32 +0000 (15:39 +0200)]
qemu: domain: Improve vCPU data checking in qemuDomainRefreshVcpu

Validate the presence of the thread id according to state of the vCPU
rather than just checking the vCPU count. Additionally put the new
validation code into a separate function so that the information
retrieval can be split from the validation.

8 years agoqemu: monitor: Rename qemuMonitor(JSON|Text)GetCPUInfo
Peter Krempa [Fri, 8 Jul 2016 13:36:27 +0000 (15:36 +0200)]
qemu: monitor: Rename qemuMonitor(JSON|Text)GetCPUInfo

Use a name that contains the command used to get the information.

8 years agoqemu: domain: Rename qemuDomainDetectVcpuPids to qemuDomainRefreshVcpuInfo
Peter Krempa [Tue, 19 Jul 2016 14:00:29 +0000 (16:00 +0200)]
qemu: domain: Rename qemuDomainDetectVcpuPids to qemuDomainRefreshVcpuInfo

The function will eventually do more useful stuff than just detection of
thread ids.

8 years agoqemu: Improve error message in virDomainGetVcpus
Peter Krempa [Mon, 18 Jul 2016 09:21:06 +0000 (11:21 +0200)]
qemu: Improve error message in virDomainGetVcpus

If the VM is offline we can't retrieve the runtime statistical
information. Pinning could be retrieved but there are separate APIs for
that.

8 years agoqemu: monitor: Add do-while block to QEMU_CHECK_MONITOR_FULL
Peter Krempa [Fri, 29 Jul 2016 07:04:34 +0000 (09:04 +0200)]
qemu: monitor: Add do-while block to QEMU_CHECK_MONITOR_FULL

Assure that it's just one statement to avoid problems when used with
conditions.

8 years agoqemu: monitor: Add monitor API for device_add supporting JSON objects
Peter Krempa [Sun, 31 Jul 2016 13:26:12 +0000 (15:26 +0200)]
qemu: monitor: Add monitor API for device_add supporting JSON objects

Rather than formatting a string and splitting it back to a JSON object
add API that will take a JSON object directly.

8 years agoconf: events: Fix coverity warning
Cole Robinson [Wed, 3 Aug 2016 22:45:50 +0000 (18:45 -0400)]
conf: events: Fix coverity warning

Since 2bfa75134 virObjectEventNew can be passed a NULL 'uuid' value,
so drop the ATTRIBUTE_NONNULL annotation

8 years agolibxl: allow libxl to calculate shadow mem requirements
Jim Fehlig [Tue, 2 Aug 2016 23:36:34 +0000 (17:36 -0600)]
libxl: allow libxl to calculate shadow mem requirements

Long, long ago before libxl_get_required_shadow_memory() was
made publicly available, its code was copied to the libxl driver
for calculating shadow memory requirements of HVM domains.

Long ago, libxl_get_required_shadow_memory() was exported in
libxl_utils.h and included in xen-devel packages everywhere.

Remove the copied code, which has become stale, and let libxl
provode a proper shadow memory value.

8 years agoqemu: Add support to get/set IOThread period and quota cgroup values
John Ferlan [Mon, 25 Jul 2016 11:07:43 +0000 (07:07 -0400)]
qemu: Add support to get/set IOThread period and quota cgroup values

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

Add support for IOThread quota/bandwidth and period parameters for non
session mode. If in session mode, then error out.  Uses all the same
places where {vcpu|emulator|global}_{period|quota} are adjusted and
adds the iothread values.

8 years agoconf: Add IOThread quota and period scheduler/cputune defs
John Ferlan [Mon, 25 Jul 2016 11:04:38 +0000 (07:04 -0400)]
conf: Add IOThread quota and period scheduler/cputune defs

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

Add the definitions to allow for viewing/setting cgroup period and quota
limits for IOThreads.

This is similar to the work done for emulator quota and period by
commit ids 'b65dafa' and 'e051c482'.

Being able to view/set the IOThread specific values is related to more
recent changes adding global period (commmit id '4d92d58f') and global
quota (commit id '55ecdae') definitions and qemu support (commit id
'4e17ff79' and 'fbcbd1b2'). With a global setting though, if somehow
the IOThread value in the cgroup hierarchy was set "outside of libvirt"
to a value that is incompatible with the global value.

Allowing control over IOThread specific values provides the capability
to alter the IOThread values as necessary.

8 years agoDon't error when attaching security label of model "none"
Daniel P. Berrange [Wed, 13 Jul 2016 10:16:45 +0000 (11:16 +0100)]
Don't error when attaching security label of model "none"

If you invoke virDomainLxcEnterSecurityLabel() on security
model of "none" it will report an error. Logically a "none"
security model should be treated as a no-op, so we should
just return success immediately, instead of an error.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: only report errno in trace message on failure
Daniel P. Berrange [Tue, 2 Aug 2016 10:48:01 +0000 (11:48 +0100)]
qemu: only report errno in trace message on failure

Avoid reporting a stale errno value when the syscall succeeds,
instead always pass 0.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirsh: qemu-monitor-command: Don't print extra newline with --pretty
Peter Krempa [Mon, 1 Aug 2016 04:13:39 +0000 (06:13 +0200)]
virsh: qemu-monitor-command: Don't print extra newline with --pretty

The prettified JSON string already contains a newline so don't print
another one. This allows to pipe the json output (in conjunction with
the --quiet option) to files without having to truncate them afterwards.

8 years agotests: Make schema test fail on XML schema errors
Peter Krempa [Tue, 2 Aug 2016 07:11:33 +0000 (09:11 +0200)]
tests: Make schema test fail on XML schema errors

Failure to parse the schema file would not trigger a test suite failure.

In addition to making the test fail it's necessary to split up the
parsing of the schema file into a separate test.

This is necessary as the XML validator uses libvirt errors to report
problems parsing of the actual schema RNG needs to be split out into a
separate function and called via virTestRun which has the
infrastructure to report them.

8 years agoremote: Fix indentation of the remote protocol structs check file
Peter Krempa [Tue, 2 Aug 2016 14:15:57 +0000 (16:15 +0200)]
remote: Fix indentation of the remote protocol structs check file

8 years agoqemu: Use the hostdev alias in qemuDomainAttachHostSCSIDevice error path
John Ferlan [Mon, 18 Jul 2016 17:24:27 +0000 (13:24 -0400)]
qemu: Use the hostdev alias in qemuDomainAttachHostSCSIDevice error path

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

Rather than pass the whole drive string (which contained the alias),
pass only the alias for the qemuMonitorDriveDel call in the error
path when adding a host device in the monitor fails.

8 years agoqemu: Use qemuAliasFromHostdev
John Ferlan [Mon, 18 Jul 2016 17:22:29 +0000 (13:22 -0400)]
qemu: Use qemuAliasFromHostdev

When building the command line alias and for SCSI Host Device deletion,
use the common API to build the alias

8 years agoqemu: Introduce qemuAliasFromHostdev
John Ferlan [Mon, 18 Jul 2016 17:19:02 +0000 (13:19 -0400)]
qemu: Introduce qemuAliasFromHostdev

Introduce a common API to generate the alias for a host device

8 years agoqemu: Add attempt to call qemuMonitorDriveDel for AttachSCSI failure path
John Ferlan [Mon, 18 Jul 2016 16:50:52 +0000 (12:50 -0400)]
qemu: Add attempt to call qemuMonitorDriveDel for AttachSCSI failure path

Completion of fix for:
    https://bugzilla.redhat.com/show_bug.cgi?id=1336225

Similar to the other disk types, add the qemuMonitorDriveDel in the failure
to add/hotplug a SCSI disk.

8 years agoqemu: Add attempt to call qemuMonitorDriveDel for USB failure path
John Ferlan [Wed, 29 Jun 2016 20:32:58 +0000 (16:32 -0400)]
qemu: Add attempt to call qemuMonitorDriveDel for USB failure path

Partial fix for:
    https://bugzilla.redhat.com/show_bug.cgi?id=1336225

Similar to the other disk types, add the qemuMonitorDriveDel in the failure
to add/hotplug a USB.

Added a couple of other formatting changes just to have a less cluttered look

8 years agoqemu: Make QEMU_DRIVE_HOST_PREFIX more private
John Ferlan [Wed, 29 Jun 2016 17:34:00 +0000 (13:34 -0400)]
qemu: Make QEMU_DRIVE_HOST_PREFIX more private

Move QEMU_DRIVE_HOST_PREFIX into the qemu_alias.c to dissuade future
callers from using it. Create qemuAliasDiskDriveSkipPrefix in order
to handle the current consumers that desire to check if an alias has
the drive- prefix and "get beyond it" in order to get the disk alias.

8 years agoqemu: Use qemuAliasFromDisk to generate drive alias
John Ferlan [Wed, 29 Jun 2016 17:11:58 +0000 (13:11 -0400)]
qemu: Use qemuAliasFromDisk to generate drive alias

Rather than open code build the drive alias command in multiple places,
use the helper to ensure consistency.

8 years agoqemu: Use qemuAliasFromDisk instead of qemuDeviceDriveHostAlias
John Ferlan [Wed, 29 Jun 2016 16:37:39 +0000 (12:37 -0400)]
qemu: Use qemuAliasFromDisk instead of qemuDeviceDriveHostAlias

Since we already have a function that will generate the drivestr from
the alias, let's use it and remove the qemuDeviceDriveHostAlias.

Move the QEMU_DRIVE_HOST_PREFIX definition into qemu_alias.h

Also alter qemuAliasFromDisk to use the QEMU_DRIVE_HOST_PREFIX instead
of "drive-%s".

8 years agoqemu: Use qemuAliasFromDisk to generate drive alias
John Ferlan [Mon, 1 Aug 2016 12:26:42 +0000 (08:26 -0400)]
qemu: Use qemuAliasFromDisk to generate drive alias

The qemuDomainSnapshotCreateSingleDiskActive open coded generating the
disk drive alias. Let's use the common function.

8 years agoqemu: Remove generation of drive alias from qcow passphrase backends
John Ferlan [Mon, 1 Aug 2016 12:11:44 +0000 (08:11 -0400)]
qemu: Remove generation of drive alias from qcow passphrase backends

Rather than pass the disks[i]->info.alias to qemuMonitorSetDrivePassphrase
and then generate the "drive-%s" alias from that, let's use qemuAliasFromDisk
prior to the call to generate the drive alias and then pass that along
thus removing the need to generate the alias from the monitor code.

8 years agoqemu: Reorder qemuDomainAttachUSBMassStorageDevice failure path
John Ferlan [Mon, 25 Apr 2016 16:26:48 +0000 (12:26 -0400)]
qemu: Reorder qemuDomainAttachUSBMassStorageDevice failure path

Modify the error/exit path to match what was done for Virtio and SCSI.
If nothing else it'll have a consistent look'n'feel

8 years agoevent-test: support node device lifecycle event APIs
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:56 +0000 (14:02 +0200)]
event-test: support node device lifecycle event APIs

8 years agonode_device: Implement event queue in udev
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:55 +0000 (14:02 +0200)]
node_device: Implement event queue in udev

8 years agonode_device: implement node device lifecycle event APIs
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:54 +0000 (14:02 +0200)]
node_device: implement node device lifecycle event APIs

8 years agoremote: implement node device lifecycle event APIs
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:53 +0000 (14:02 +0200)]
remote: implement node device lifecycle event APIs

8 years agotest: implement node device lifecycle event APIs
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:52 +0000 (14:02 +0200)]
test: implement node device lifecycle event APIs

Also includes unittests for node device lifecycle events API

8 years agoconf: add node_device_event handling
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:51 +0000 (14:02 +0200)]
conf: add node_device_event handling

Add node device event handling infrastructure to node_device_event.[ch]

8 years agoIntroduce node device lifecycle event APIs
Jovanka Gulicoska [Thu, 28 Jul 2016 12:02:50 +0000 (14:02 +0200)]
Introduce node device lifecycle event APIs

Node device lifecycle event API entry points for registering and
deregistering node deivce events, as well as types of events
associated with node device.
These entry points will be used for implementing asynchronous
lifecycle events.

Node device API:
virConnectNodeDeviceEventRegisterAny
virConnectNodeDeviceEventDeregisterAny
virNodeDeviceEventLifecycleType which has events CREATED and DELETED

8 years agoqemu: Set fake reboot flag to false when mode=agent
Nikolay Shirokovskiy [Tue, 2 Aug 2016 11:37:39 +0000 (07:37 -0400)]
qemu: Set fake reboot flag to false when mode=agent

As commit id 'e2b86f580' notes, when mode=agent possibly setting the
fake reboot flag to true wouldn't be necessary; however, it doesn't
"force" the issue by just ensuring the fake reboot is false, so this
patch adds the explicit setting for the reboot path.

More investigation and details can be found in commit id '8be502fd'
as well as in the archives at:

  https://www.redhat.com/archives/libvir-list/2015-April/msg00715.html

8 years agoqemu: Set fake reboot flag only in acpi mode for shutdown
Nikolay Shirokovskiy [Thu, 14 Jul 2016 11:08:22 +0000 (14:08 +0300)]
qemu: Set fake reboot flag only in acpi mode for shutdown

Conditional setting of the fake reboot flag should only happen for
the acpi mode shutdown path; however, for the agent mode shutdown,
the fake reboot should be cleared. This patch will essentially revert
commit id '8be502fd', but adds an explicit setting of the flag to false
when using mode=agent while also only conditionally setting the reboot
flag if the guest went away. This also avoids an issue where a shutdown
with reboot semantics is done from agent mode which sets the reboot
flag followed by a shutdown from within the guest which would result
in a reboot due to the fake reboot flag being set. The change will
also properly handle the cases described in the following archive post:

  https://www.redhat.com/archives/libvir-list/2015-April/msg00715.html

8 years agolibxl: Fix broken build attach/detach controller device
John Ferlan [Tue, 2 Aug 2016 13:20:32 +0000 (09:20 -0400)]
libxl: Fix broken build attach/detach controller device

Commit id '44304c6eb' added the API libxlDomainAttachControllerDevice
inside a conditional LIBXL_HAVE_PVUSB, but called that function outside
the conditional in libxlDomainAttachDeviceLive.

Similarly, the API libxlDomainDetachControllerDevice was added inside a
conditional LIBXL_HAVE_PVUSB, but called outside the conditional in
libxlDomainDetachDeviceLive.

This patch adds the conditional LIBXL_HAVE_PVUSB around those two calls
from within the switch.

8 years agolibxl: Fix broken build from libxlDomainCleanup
John Ferlan [Tue, 2 Aug 2016 13:18:56 +0000 (09:18 -0400)]
libxl: Fix broken build from libxlDomainCleanup

Commit id '7d3b2eb5' missed a closing parenthesis on the ignore_value
macro, causing the failure

8 years agorpc: virnetserver: Remove dead code checking the client limits
Erik Skultety [Wed, 20 Jul 2016 10:39:50 +0000 (12:39 +0200)]
rpc: virnetserver: Remove dead code checking the client limits

Prior to commit 2737aaaf, we allowed every client to connect successfully,
however, if accepting a client would eventually lead to an overcommit of the
limits, we would disconnect it immediately with "Too many active clients,
dropping connection from...". Recent changes refactored the code in a way, that
it is not possible for the client-related callback to be dispatched and the
client to be accepted if the limits wouldn't permit to do so, therefore a check
if a connection should be dropped due to limits violation has become a dead
code that could be removed.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: rpc: virnetserver: Fix updating of the client limits
Erik Skultety [Wed, 20 Jul 2016 10:10:29 +0000 (12:10 +0200)]
admin: rpc: virnetserver: Fix updating of the client limits

Commit 2737aaaf changed our policy for accepting new clients in a way, that
instead of accepting new clients only to disconnect them immediately, since
that would overcommit the limit, we temporarily disable polling for the
dedicated file descriptor, so any new connection will queue on the socket.
Commit 8b1f0469 then added the possibility to change the limits during runtime
but it didn't re-enable polling for the previously disabled file descriptor,
thus any new connection would still continue to queue on the socket. This patch
forces an update of the services each time the limits were changed in some way.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agorpc: virnetserver: Add code to CheckLimits to handle suspending of services
Erik Skultety [Wed, 20 Jul 2016 08:36:06 +0000 (10:36 +0200)]
rpc: virnetserver: Add code to CheckLimits to handle suspending of services

So far, virNetServerCheckLimits was only used to possibly re-enable accepting
new clients that might have previously been disabled due to client limits
violation (max_clients, max_anonymous_clients). This patch refactors
virNetServerAddClient, which is currently the only place where the services get
disabled, in order to use the virNetServerCheckLimits helper instead of
checking the limits by itself.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agorpc: virnetserver: Move virNetServerCheckLimits which is static up in the file
Erik Skultety [Wed, 20 Jul 2016 08:17:19 +0000 (10:17 +0200)]
rpc: virnetserver: Move virNetServerCheckLimits which is static up in the file

Since virNetServerAddClient checks for the limits in order to temporarily
suspend the services, thus not accepting any more clients, there is no reason
why virNetServerCheckLimits, which is only responsible for re-enabling
previously disabled services according to the limits, could not do both. To be
able to do that however, it needs to be moved up in the file since it's static
(and because it's just a helper and there's only one caller it should remain
 static).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agorpc: virnetserver: Rename ClientSetProcessingControls to ClientSetLimits
Erik Skultety [Wed, 20 Jul 2016 07:32:20 +0000 (09:32 +0200)]
rpc: virnetserver: Rename ClientSetProcessingControls to ClientSetLimits

The original naming was just a leftover that should have been fixed in commit
8b1f0469.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agolibxl: add hooks support
Cédric Bosdonnat [Mon, 11 Jul 2016 11:55:53 +0000 (13:55 +0200)]
libxl: add hooks support

Introduce libxl hook and use it for start, prepare, started,
stop, stopped, migrate events.

8 years agolibxl: fix segfault in libxlReconnectDomain
Cédric Bosdonnat [Wed, 27 Jul 2016 12:46:41 +0000 (14:46 +0200)]
libxl: fix segfault in libxlReconnectDomain

In case of error, libxlReconnectDomain may call
virDomainObjListRemoveLocked. However it has no local reference on
the domain object, leading to segfault. Get a reference to the domain
object at the start of the function and release it at the end to avoid
problems.

This commit also factorizes code between the error and normal ends.

8 years agolibxl: add a flag to mark guests as tainted by a hook
Cédric Bosdonnat [Mon, 11 Jul 2016 13:54:31 +0000 (15:54 +0200)]
libxl: add a flag to mark guests as tainted by a hook

The migrate hook will affect the migrated guest definition. Allow
these domains be marked as tainted in the libxl driver.

8 years agoqemuDomainDeviceDefPostParse: add USB controller model check
Chunyan Liu [Wed, 15 Jun 2016 06:00:14 +0000 (14:00 +0800)]
qemuDomainDeviceDefPostParse: add USB controller model check

To sync with virDomainControllerModelUSB, we add two models
in qemuControllerModelUSB 'qusb1' and 'qusb2', but those
models are not supported in qemu driver. So add check in
device post parse to report errors if 'qusb1' and 'qusb2'
are specified.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agoxenconfig: add conversion of usb controller config to and from xml
Chunyan Liu [Wed, 15 Jun 2016 06:00:12 +0000 (14:00 +0800)]
xenconfig: add conversion of usb controller config to and from xml

libxl configuration files conversion can now handle USB controllers.
When parting libxl config file, USB controllers with type PV are
ignored as those aren't handled.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agolibxl: check available controller and port when hotplugging USB device
Chunyan Liu [Wed, 15 Jun 2016 06:00:11 +0000 (14:00 +0800)]
libxl: check available controller and port when hotplugging USB device

When hotplugging a USB device, check if there is an available controller
and port, if not, automatically create a USB controller of version
2.0 and 8 ports.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agolibxl: support usb controller hotplug
Chunyan Liu [Wed, 15 Jun 2016 06:00:10 +0000 (14:00 +0800)]
libxl: support usb controller hotplug

Support USB controller hot-plug and hot-unplug.

 #virsh attach-device dom usbctrl.xml
 #virsh detach-device dom usbctrl.xml
 usbctrl.xml example:
 <controller type='usb' index='0' model='qusb2'>

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agolibxl: support USB controllers in creation time
Chunyan Liu [Wed, 15 Jun 2016 06:00:09 +0000 (14:00 +0800)]
libxl: support USB controllers in creation time

To support USB Controller in xen guest domains, just add
USB controller in domain config xml as following:
<controller type='usb' model='qusb2' ports='4'/>

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agoextend usb controller model to support xen pvusb
Chunyan Liu [Wed, 15 Jun 2016 06:00:08 +0000 (14:00 +0800)]
extend usb controller model to support xen pvusb

According to libxl implementation, it supports pvusb
controller of version 1.1 and version 2.0, and it
supports two types of backend, 'pvusb' (dom0 backend)
and 'qusb' (qemu backend). But currently pvusb backend
is not checked in yet.

To match libxl support, extend usb controller schema
to support two more models: qusb1 (qusb, version 1.1)
and 'qusb2' (qusb version 2.0).

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agovirsh: qemu-monitor-command: Simplify control flow
Peter Krempa [Mon, 1 Aug 2016 04:24:35 +0000 (06:24 +0200)]
virsh: qemu-monitor-command: Simplify control flow

Construct the query string by using virBufferTrim rather than having to
remember to add a space and simplify cleanup path.

8 years agovirsh: qemu-monitor-command: Use macro for exclusive options
Peter Krempa [Mon, 1 Aug 2016 04:12:17 +0000 (06:12 +0200)]
virsh: qemu-monitor-command: Use macro for exclusive options

8 years agoqemu: cap: Refactor access to array in virQEMUCapsProbeQMPMachineTypes
Peter Krempa [Fri, 29 Jul 2016 08:35:48 +0000 (10:35 +0200)]
qemu: cap: Refactor access to array in virQEMUCapsProbeQMPMachineTypes

Use a temporary pointer rather than always recalculating the index in a
very verbose way.

8 years agoqemu: caps: Sanitize storage of machine type related data
Peter Krempa [Fri, 29 Jul 2016 08:13:46 +0000 (10:13 +0200)]
qemu: caps: Sanitize storage of machine type related data

Add a structure to store the data and use a single array of the
structures rather than having 3 separate arrays with shared indexes.

8 years agoqemu: capabilities: Drop unused function virQEMUCapsGetMachineTypes
Peter Krempa [Fri, 29 Jul 2016 08:12:05 +0000 (10:12 +0200)]
qemu: capabilities: Drop unused function virQEMUCapsGetMachineTypes

8 years agostorage: Clean up volume wiping
Martin Kletzander [Thu, 14 Jul 2016 05:27:02 +0000 (07:27 +0200)]
storage: Clean up volume wiping

Let's cleanly differentiate what wiping a volume does for ploop and
other volumes so it's more readable what is done for each one instead of
branching out multiple times in different parts of the same function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agostorage: Use path instead of volume as an argument
Martin Kletzander [Mon, 1 Aug 2016 12:04:29 +0000 (14:04 +0200)]
storage: Use path instead of volume as an argument

Some functions use volume specification merely to use the target path
from it.  Let's change it to pass the path only so that it can be used
for other files than just volumes.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agostorage: Move functions around
Martin Kletzander [Mon, 1 Aug 2016 11:38:10 +0000 (13:38 +0200)]
storage: Move functions around

This is done in order to call them in next patches from each other and
definitions would be missing otherwise.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Fix domain state after reset
Martin Kletzander [Wed, 13 Jul 2016 14:13:58 +0000 (16:13 +0200)]
qemu: Fix domain state after reset

When reset was called from a domain that crashed we didn't change the
crashed state into a paused one which could confuse users.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirsh: Report error when explicit connection fails
Martin Kletzander [Fri, 29 Jul 2016 06:09:22 +0000 (08:09 +0200)]
virsh: Report error when explicit connection fails

Commit 0c56d9431839 forgot to return false in the cmdConnect command
after the clean up made there.

Before (assuming you don't have uri alias for 'asdf'):
  $ virsh connect asdf
  error: failed to connect to the hypervisor

  $ echo $?
  0

After (with the same assumption):
  $ virsh connect asdf
  error: failed to connect to the hypervisor
  error: no connection driver available for asdf

  $ echo $?
  1

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Fix support for startupPolicy with volume/pool disks
Martin Kletzander [Mon, 1 Aug 2016 15:51:28 +0000 (17:51 +0200)]
qemu: Fix support for startupPolicy with volume/pool disks

Until now we simply errored out when the translation from pool+volume
failed.  However, we should instead check whether that disk is needed or
not since there is an option for that.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Remove unnecessary label and its only reference
Martin Kletzander [Mon, 1 Aug 2016 15:56:26 +0000 (17:56 +0200)]
qemu: Remove unnecessary label and its only reference

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Make qemuDomainCheckDiskStartupPolicy self-contained
Martin Kletzander [Mon, 1 Aug 2016 15:52:02 +0000 (17:52 +0200)]
qemu: Make qemuDomainCheckDiskStartupPolicy self-contained

There is an error reset following the function and check for
startupPolicy before that.  Let's reflect those things inside that
function so that future code doesn't have to be that complex.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoPost-release version bump to 2.2.0
Michal Privoznik [Tue, 2 Aug 2016 11:00:38 +0000 (13:00 +0200)]
Post-release version bump to 2.2.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoFix unbalanced quotation marks
Yuri Chornoivan [Tue, 2 Aug 2016 07:04:39 +0000 (09:04 +0200)]
Fix unbalanced quotation marks

8 years agoRelease of libvirt-2.1.0
Daniel Veillard [Tue, 2 Aug 2016 08:33:35 +0000 (10:33 +0200)]
Release of libvirt-2.1.0

* docs/news.html.in: updated for release
* po/*.po*: regenerated

8 years agoRevert "Fix unbalanced quotation marks"
Daniel Veillard [Tue, 2 Aug 2016 10:34:18 +0000 (12:34 +0200)]
Revert "Fix unbalanced quotation marks"

This reverts commit 6a40801186d1fcba38360f58659f898b67f08a01.
release of 2.1.0 need to go first

8 years agoFix unbalanced quotation marks
Yuri Chornoivan [Tue, 2 Aug 2016 07:04:39 +0000 (09:04 +0200)]
Fix unbalanced quotation marks

8 years agodaemon: sasl: Don't forget to save SASL username to client's identity
Erik Skultety [Thu, 28 Jul 2016 14:42:04 +0000 (16:42 +0200)]
daemon: sasl: Don't forget to save SASL username to client's identity

Once the SASL authentication process has successfully passed, we should also
save the SASL username used to client's identity, so that when a client like
virt-admin tries to obtain it, the server will actually format the username to
the response data.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Retrieve the SASL context for both local and remote connection
Erik Skultety [Tue, 19 Jul 2016 06:55:31 +0000 (08:55 +0200)]
admin: Retrieve the SASL context for both local and remote connection

When commit 4a0e9108 added a support for client information retrieval, it made
the API return SASL identity info only for clients connected remotely, yet SASL
can be happily used with UNIX sockets as well.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agostorage: Document wiping formatted volume types
Martin Kletzander [Thu, 14 Jul 2016 09:34:14 +0000 (11:34 +0200)]
storage: Document wiping formatted volume types

When wiping a volume we just rewrite all the data of the volume, not
only the content.  Since format gets overridden, we need to recreate the
volume.  However we can't do that for every possible format out there.
Since it was only coded for the ploop volume type, let's document what
might be the consequences instead of forbidding it for every other
format out there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: remove panic dev models s390 and pseries when migrating
Boris Fiuczynski [Thu, 28 Jul 2016 13:15:49 +0000 (15:15 +0200)]
qemu: remove panic dev models s390 and pseries when migrating

The panic devices with models s390 and pseries are autogenerated.
For backwards compatibility reasons the devices are to be removed
when migrating.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
8 years agowireshark: Drop glib dependency
Michal Privoznik [Mon, 1 Aug 2016 08:21:04 +0000 (10:21 +0200)]
wireshark: Drop glib dependency

The only function that we currently use from glib is g_sprintf().
That's a very big gun for such small target. Not only that, but
we've silently relied on wireshark dragging in the glib. Replace
the g_sprintf() with plain sprinf() so that we can drop the glib
dependency.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoschema: fix resolved interfaces of network type
Nikolay Shirokovskiy [Wed, 20 Jul 2016 12:11:46 +0000 (15:11 +0300)]
schema: fix resolved interfaces of network type

  This patch reflects cases when <interface> element and its <source>
subelement for network type are formated based on actual type resolved
from referenced network instead of original one. networkAllocateActualDevice
and virDomainActualNetDefContentsFormat are taken as reference.

8 years agoschema: add missed alias element to memory device
Nikolay Shirokovskiy [Wed, 20 Jul 2016 12:11:45 +0000 (15:11 +0300)]
schema: add missed alias element to memory device

8 years agoqemu: fix domain id after domainCreateWithFlags()
Sascha Silbe [Wed, 27 Jul 2016 14:05:20 +0000 (16:05 +0200)]
qemu: fix domain id after domainCreateWithFlags()

Ever since virDomainCreateWithFlags() was introduced by de3aadaa
[drivers: add virDomainCreateWithFlags if virDomainCreate exists], the
domain ID retrieved with virDomainGetID() was incorrect for several
drivers after virDomainCreateWithFlags() was called. The API consumer
had to look up the domain anew to retrieve the correct ID.

For the ESX driver, this was fixed in 6139b274 [esx: Update ID after
starting a domain]. For the openvz driver, it was fixed in fd81a097
[openvzDomainCreateWithFlags: set domain id to the correct value]. The
test driver, the OpenNebula driver (removed in the meantime) and the
vbox driver were already updating the domain ID correctly in
domainCreate().

Copy over the ID in qemuDomainCreateWithFlags() to fix this for the qemu
driver, too.

Fixes: de3aadaa ("drivers: add virDomainCreateWithFlags if virDomainCreate exists")
Reported-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Tested-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
8 years agotests: qemu: Don't leak security manager object
Peter Krempa [Fri, 29 Jul 2016 16:06:51 +0000 (18:06 +0200)]
tests: qemu: Don't leak security manager object

==2064442== 200 (88 direct, 112 indirect) bytes in 1 blocks are definitely lost in loss record 54 of 73
==2064442==    at 0x4C2E0F0: calloc (vg_replace_malloc.c:711)
==2064442==    by 0x18E75B80: virAllocVar (viralloc.c:560)
==2064442==    by 0x18EC43B0: virObjectNew (virobject.c:193)
==2064442==    by 0x18EC476E: virObjectLockableNew (virobject.c:219)
==2064442==    by 0x1906BC73: virSecurityManagerNewDriver (security_manager.c:93)
==2064442==    by 0x1906C076: virSecurityManagerNewStack (security_manager.c:115)
==2064442==    by 0x43CC39: qemuTestDriverInit (testutilsqemu.c:548)
==2064442==    by 0x4337ED: mymain (qemumonitorjsontest.c:2440)
==2064442==    by 0x43BABE: virTestMain (testutils.c:982)
==2064442==    by 0x43A490: main (qemumonitorjsontest.c:2558)

8 years agoconf: Catch invalid memory model earlier
Michal Privoznik [Thu, 28 Jul 2016 16:20:31 +0000 (18:20 +0200)]
conf: Catch invalid memory model earlier

Consider the following XML snippet:

    <memory model=''>
      <target>
        <size unit='KiB'>523264</size>
        <node>0</node>
      </target>
    </memory>

Whats wrong you ask? The @model attribute. This should result in
an error thrown into users faces during virDomainDefine phase.
Except it doesn't. The XML validation catches this error, but if
users chose to ignore that, they will end up with invalid XML.
Well, they won't be able to start the machine - that's when error
is produced currently. But it would be nice if we could catch the
error like this earlier.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoadmin: Fix default uri config option name s/admin_uri_default/uri_default
Erik Skultety [Wed, 27 Jul 2016 11:23:03 +0000 (13:23 +0200)]
admin: Fix default uri config option name s/admin_uri_default/uri_default

The original name 'admin_uri_default' was introduced to our code by commit
dbecb87f. However, at that time we already had a separate config file for
admin library but the commit mentioned above didn't properly adjust the
config's option name. The result is that when we're loading the config, we
check a non-existent config option (there's not much to do with the URIs
anyway, since we only allow local connection). Additionally, virt-admin's man
page documents, that the default URI can be altered by setting
admin_uri_default option. So the fix proposed by this patch leaves the
libvirt-admin.conf as is and adjusts the naming in the code as well as in the
virt-admin's man page.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agowireshark: Adapt to dissector function header change
Michal Privoznik [Thu, 28 Jul 2016 08:21:45 +0000 (10:21 +0200)]
wireshark: Adapt to dissector function header change

In wireshark commit bbdd89b9 (contained in 2.1.0 release) they
have changed prototype of dissector function. Now it returns
number of bytes consumed by the dissector, and can get a pointer
to user specified data (which we don't use).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Need to free fileprops in error path
John Ferlan [Thu, 28 Jul 2016 13:25:40 +0000 (09:25 -0400)]
qemu: Need to free fileprops in error path

The virJSONValueObjectCreate only consumes the object on success, so on
failure we must free - from commit id 'f4441017' (found by Coverity).