]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

9 years agoInvert condition in qemuDomainDefAddDefaultDevices
Ján Tomko [Tue, 3 May 2016 10:05:27 +0000 (12:05 +0200)]
Invert condition in qemuDomainDefAddDefaultDevices

For all the other machine types, we use a positive condition.

Be more positive and use it for i440fx too.

9 years agoUse qemuDomainMachineIs helpers when adding default devices
Ján Tomko [Tue, 3 May 2016 08:33:56 +0000 (10:33 +0200)]
Use qemuDomainMachineIs helpers when adding default devices

Do not duplicate the string comparisons by writing them twice.

9 years agoqemu: Refresh RTC adjustment on qemuProcessReconnect
Michal Privoznik [Fri, 29 Apr 2016 16:01:39 +0000 (18:01 +0200)]
qemu: Refresh RTC adjustment on qemuProcessReconnect

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

Thing is, for some reasons you can have your domain's RTC to be
in something different than UTC. More weirdly, it's not only time
zone what you can shift it of, but an arbitrary value. So, if
domain is configured that way, libvirt will correctly put it onto
qemu cmd line and moreover track it as this offset changes during
domain's life time (e.g. because guest OS decides the best thing
to do is set new time to RTC). Anyway, they way in which this
tracking is implemented is events. But we've got a problem if
change in guest's RTC occurs and the daemon is not running. The
event is lost and we end up reporting invalid value in domain
XML. Therefore, when the daemon is starting up again and it is
reconnecting to all running domains, re-fetch their RTC so the
correct offset value can be computed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Introduce qemuMonitorGetRTCTime
Michal Privoznik [Fri, 29 Apr 2016 14:01:47 +0000 (16:01 +0200)]
qemu: Introduce qemuMonitorGetRTCTime

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirt-admin: Introduce srv-clients-list command
Erik Skultety [Sat, 16 Apr 2016 07:13:21 +0000 (09:13 +0200)]
virt-admin: Introduce srv-clients-list command

Wire-up the public client listing API. Along with this change, a private time
simple conversion method to interpret client's timestamp obtained from server
has been added as well. Format used to for time output is as follows:
YYYY-mm-DD HH:MM:SS+ZZZZ.

Although libvirt exposes methods time-related methods through virtime.h
internally, it utilizes millisecond precision which we don't need in this case,
especially when connection timestamps use precision to seconds only.
This is just a convenience int to string conversion method.

To reflect the new API, man page has been adjusted accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Introduce listing clients
Erik Skultety [Thu, 14 Apr 2016 22:20:11 +0000 (00:20 +0200)]
admin: Introduce listing clients

Finally add public method to retrieve the list of currently connected clients
to a given server.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agorpc: virnetserverclient: Implement client connection transport retrieval
Erik Skultety [Thu, 14 Apr 2016 22:25:04 +0000 (00:25 +0200)]
rpc: virnetserverclient: Implement client connection transport retrieval

Although we document 6 types of transport that we support, internally we can
only differentiate between TCP, TLS, and UNIX transports only, since both SSH
and libssh2 transports, due to using netcat, behave in the exactly the same
way as a UNIX socket.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoinclude: admin: export connection transport constants
Erik Skultety [Thu, 14 Apr 2016 22:24:35 +0000 (00:24 +0200)]
include: admin: export connection transport constants

We have to expose some constants, in order for the client object transport
field to make sense.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agorpc: virnetserver: Support retrieval of a list of clients
Erik Skultety [Thu, 14 Apr 2016 22:21:05 +0000 (00:21 +0200)]
rpc: virnetserver: Support retrieval of a list of clients

For now, the list copy is done simply by locking the whole server, walking the
original and increasing the refcount on each object. We may want to change
the list to a lockable object (like list of domains) later in the future if
we discover some performance issues related to locking the whole server in
order to walk the whole list of clients, possibly issuing some 'ForEach'
callback.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agorpc: gendispatch: Tune it to support client structure
Erik Skultety [Thu, 14 Apr 2016 22:22:59 +0000 (00:22 +0200)]
rpc: gendispatch: Tune it to support client structure

Now that libvirt-admin supports another client-side object and provided that
we want to generate as many both client-side and server-side RPC dispatchers,
support for this needs to be added to gendispatch.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Introduce virAdmClient client-side object
Erik Skultety [Wed, 13 Apr 2016 08:35:26 +0000 (10:35 +0200)]
admin: Introduce virAdmClient client-side object

Besides ID, the object also stores static data like connection transport and
connection timestamp, since once obtained a list of all clients connected to a
server, from user's perspective, it would be nice to know whether a given
client is remote or local only and when did it connect to the daemon.
Along with the object introduction, all necessary client-side methods necessary
to work with the object are added as well.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agorpc: virnetserverclient: Introduce new attribute conn_time to client
Erik Skultety [Tue, 12 Apr 2016 17:21:43 +0000 (19:21 +0200)]
rpc: virnetserverclient: Introduce new attribute conn_time to client

Besides ID, libvirt should provide several parameters to help the user
distinguish two clients from each other. One of them is the connection
timestamp. This patch also adds a testcase for proper JSON formatting of the
new attribute too (proper formatting of older clients that did not support
this attribute yet is included in the existing tests) - in order to
testGenerateJSON to work, a mock of time_t time(time_t *timer) needed to be
created.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agorpc: virnetserverclient: Identify clients by an integer ID
Erik Skultety [Wed, 13 Apr 2016 18:54:40 +0000 (20:54 +0200)]
rpc: virnetserverclient: Identify clients by an integer ID

Admin API needs a way of addressing specific clients. Unlike servers, which we
are happy to address by names both because its name reflects its purpose (to
some extent) and we only have two of them (so far), naming clients doesn't make
any sense, since a) each client is an anonymous, i.e. not recognized after a
disconnect followed by a reconnect, b) we can't predict what kind of requests
it's going to send to daemon, and c) the are loads of them comming and going,
so the only viable option is to use an ID which is of a reasonably wide data
type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoconfigure: Introduce LIBVIRT_{CHECK,RESULT}_INIT_SCRIPT
Andrea Bolognani [Mon, 2 May 2016 11:27:47 +0000 (13:27 +0200)]
configure: Introduce LIBVIRT_{CHECK,RESULT}_INIT_SCRIPT

Move the code dealing with init scripts to a separate file
so configure.ac itself can be a little bit smaller.

9 years agoconfigure: Add systemd detection to --with-init-script=check
Andrea Bolognani [Thu, 28 Apr 2016 15:19:29 +0000 (17:19 +0200)]
configure: Add systemd detection to --with-init-script=check

Most distributions, including RHEL, have switched to systemd,
so we should detect it and act accordingly. This also means
that 'systemd+redhat' should be preferred to legacy 'redhat'.

Our witness for the check is the availability of the systemctl
command on the host.

9 years agoconfigure: Improve --with-init-script=check
Andrea Bolognani [Thu, 28 Apr 2016 14:57:35 +0000 (16:57 +0200)]
configure: Improve --with-init-script=check

If we didn't find a match, either because we're cross compiling
or because we're not building on RHEL, we won't install any
init script.

Make sure this is reported correctly in the configure summary.

9 years agotests: add tests for panic device model s390
Boris Fiuczynski [Fri, 29 Apr 2016 13:23:43 +0000 (15:23 +0200)]
tests: add tests for panic device model s390

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoqemu: add default panic device to S390 guests
Boris Fiuczynski [Fri, 29 Apr 2016 13:23:42 +0000 (15:23 +0200)]
qemu: add default panic device to S390 guests

This patch adds by default a panic device with model s390 to S390 guests.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoqemu: add panic device support for S390
Boris Fiuczynski [Fri, 29 Apr 2016 13:23:41 +0000 (15:23 +0200)]
qemu: add panic device support for S390

If a panic device is being defined without a model in a domain
the default value is always overwritten with model ISA. An ISA
bus does not exist on S390 and therefore specifying a panic device
results in an unsupported configuration.
Since the S390 architecture inherently provides a crash detection
capability the panic device should be defined in the domain xml.

This patch adds an s390 panic device model and prevents setting a
device address on it.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
9 years agoqemu: merge S390 and S390X default device creation
Boris Fiuczynski [Fri, 29 Apr 2016 13:23:45 +0000 (15:23 +0200)]
qemu: merge S390 and S390X default device creation

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoqemu: fix error message for default panic device
Boris Fiuczynski [Fri, 29 Apr 2016 13:23:46 +0000 (15:23 +0200)]
qemu: fix error message for default panic device

Adding the default bus type ISA to the message.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agodocs: align spelling of S390
Boris Fiuczynski [Fri, 29 Apr 2016 13:23:44 +0000 (15:23 +0200)]
docs: align spelling of S390

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agofdstream: don't raise error on SIGPIPE if abort requested
Cole Robinson [Mon, 25 Apr 2016 18:00:58 +0000 (14:00 -0400)]
fdstream: don't raise error on SIGPIPE if abort requested

The iohelper dies on SIGPIPE if the stream is closed before all data
is processed. IMO this should be an error condition for virStreamFinish
according to docs like:

  * This method is a synchronization point for all asynchronous
  * errors, so if this returns a success code the application can
  * be sure that all data has been successfully processed.

However for virStreamAbort, not so much:

  * Request that the in progress data transfer be cancelled
  * abnormally before the end of the stream has been reached.
  * For output streams this can be used to inform the driver
  * that the stream is being terminated early. For input
  * streams this can be used to inform the driver that it
  * should stop sending data.

Without this, virStreamAbort will realistically always error for
active streams like domain console. So, treat the SIGPIPE case
as non-fatal if abort is requested.

Note, this will only affect an explicit user requested abort. An
abnormal abort, like from a server error, always raises an error
in the daemon.

9 years agodaemon: stream: Don't force error when client aborts
Cole Robinson [Sun, 24 Apr 2016 20:28:18 +0000 (16:28 -0400)]
daemon: stream: Don't force error when client aborts

Every time a client aborts a stream via the virStreamAbort API,
the daemon always logs an error like:

  error : daemonStreamHandleAbort:617 : stream aborted at client request

and that same error is returned to the client. Meaning virStreamAbort
always returns -1, which seems strange.

This reworks the error handling to only raise an error on virStreamAbort
if the actual server side abort call raises an error. This is similar
to how virStreamFinish works.

If the abort code path is triggered by an unexpected message type
then we continue to raise an unconditional error. Also drop a redundant
VIR_WARN call there, since virReportError will raise a VIR_ERROR anyways

9 years agorpc: protocol: Clarify VIR_NET_ERROR usage with streams
Cole Robinson [Sun, 24 Apr 2016 20:27:19 +0000 (16:27 -0400)]
rpc: protocol: Clarify VIR_NET_ERROR usage with streams

The described protocol semantics really only apply to server initiated
stream messages. Document the semantics for client messages.

9 years agodaemon: stream: set stream->closed on removal
Cole Robinson [Mon, 25 Apr 2016 18:16:07 +0000 (14:16 -0400)]
daemon: stream: set stream->closed on removal

These are the only places where we don't set stream->closed when
aborting the stream. This leads to spurious errors when the client
hangs up unexpectedly:

error : virFDStreamUpdateCallback:127 : internal error: stream is not open

9 years agodaemon: stream: don't update events if stream->closed
Cole Robinson [Mon, 25 Apr 2016 17:18:26 +0000 (13:18 -0400)]
daemon: stream: don't update events if stream->closed

Calling virStreamFinish prematurely seems to trigger this code path
even after the stream is closed, which ends up hitting this error
message later:

error : virFDStreamUpdateCallback:127 : internal error: stream is not open

Skip this function if stream->closed, which is used in many other places
like read/write handlers

9 years agodaemon: stream: Close stream on send failure
Cole Robinson [Mon, 25 Apr 2016 17:15:48 +0000 (13:15 -0400)]
daemon: stream: Close stream on send failure

This is the only place in daemon/stream.c that sets
'stream->closed = true' but neglects to actually abort the stream
and remove the callback, which seems wrong.

9 years agofdstream: Raise explicit error when iohelper gets SIGPIPE
Cole Robinson [Mon, 25 Apr 2016 16:43:44 +0000 (12:43 -0400)]
fdstream: Raise explicit error when iohelper gets SIGPIPE

This happens when virStreamFinish/Abort are called, but iohelper
still has data to process.

9 years agofdstream: Report error with virProcessTranslateStatus
Cole Robinson [Mon, 25 Apr 2016 16:34:14 +0000 (12:34 -0400)]
fdstream: Report error with virProcessTranslateStatus

Rather than poorly duplicate it

9 years agofdstream: separate out virCommandPtr cleanup
Cole Robinson [Mon, 25 Apr 2016 16:31:00 +0000 (12:31 -0400)]
fdstream: separate out virCommandPtr cleanup

Let's us de-nest some of the logic, and will simplify upcoming
patches

9 years agonwfilter: Save config to disk if we generated a UUID
Cole Robinson [Sun, 24 Apr 2016 23:04:10 +0000 (19:04 -0400)]
nwfilter: Save config to disk if we generated a UUID

libvirt-daemon-config-nwfilter will put a bunch of xml configs
into /etc/libvirt/nwfilter. These configs don't hardcode a UUID
and depends on libvirt to generate one. However the generated UUID
is never saved to disk, unless the user manually calls Define.

This makes daemon reload quite noisy with many errors like:

error : virNWFilterObjAssignDef:3101 : operation failed: filter 'allow-incoming-ipv4' already exists with uuid 50def3b5-48d6-46a3-b005-cc22df4e5c5c

Because a new UUID is generated every time the config is read from
disk, so libvirt constantly thinks it's finding a new nwfilter.

Detect if we generated a UUID when the config file is loaded; if so,
resave the new contents to disk to ensure the UUID is persisteny.

This is similar to what was done in commit a47ae7c0 with virtual
networks and generated MAC addresses

9 years agonwfilter: Push configFile building into LoadConfig
Cole Robinson [Sun, 24 Apr 2016 22:56:06 +0000 (18:56 -0400)]
nwfilter: Push configFile building into LoadConfig

This matches the pattern used for network object APIs, and we want
configDir in LoadConfig for upcoming patches

9 years agonwfilter: Fix potential locking problems on ObjLoad failure
Cole Robinson [Sun, 24 Apr 2016 22:49:02 +0000 (18:49 -0400)]
nwfilter: Fix potential locking problems on ObjLoad failure

In virNWFilterObjLoad we can still fail after virNWFilterObjAssignDef,
but we don't unlock and free the created virNWFilterObjPtr in the
cleanup path.

The bit we are trying to do after AssignDef is just STRDUP in the
configFile path. However caching the configFile in the NWFilterObj
is largely redundant and doesn't follow the same pattern we use
for domain and network objects.

So just remove all the configFile caching which fixes the latent
bug as a side effect.

9 years agonetwork: Fix segfault on daemon reload
Cole Robinson [Sun, 24 Apr 2016 21:37:13 +0000 (17:37 -0400)]
network: Fix segfault on daemon reload

We will segfault of a daemon reload picks up a new network config
that needs to be autostarted. We shouldn't be passing NULL for
network_driver here. This seems like it was missed in the larger
rework in commit 1009a61e

9 years agosend default USB controller in xml to destination during migration
Shivaprasad G Bhat [Fri, 29 Apr 2016 14:01:51 +0000 (19:31 +0530)]
send default USB controller in xml to destination during migration

The default USB controller is not sent to destination as the older versions
of libvirt(0.9.4 or earlier as I see in commit log of 409b5f54) didn't
support them. For some archs where the support started much later can
safely send the USB controllers without this worry. So, send the controller
to destination for all archs except x86. Moreover this is not very applicable
to x86 as the USB controller has model ich9_ehci1 on q35 and for pc-i440fx,
there cant be any slots before USB as it is fixed on slot 1.

The patch fixes a bug that, if the USB controller happens to occupy
a slot after disks/interfaces and one of them is hot-unplugged, then
the default USB controller added on destination takes the smallest slot
number and that would lead to savestate mismatch and migration
failure. Seen and verified on PPC64.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
9 years agoconf: format runtime DAC seclabel, unless MIGRATABLE
Cole Robinson [Sat, 23 Apr 2016 17:46:25 +0000 (13:46 -0400)]
conf: format runtime DAC seclabel, unless MIGRATABLE

We historically format runtime seclabel selinux/apparmor values,
however we skip formatting runtime DAC values. This was added in

commit 990e46c4542349f838e001d30638872576c389e9
Author: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Date:   Fri Aug 31 13:40:41 2012 +0200

    conf: Avoid formatting auto-generated DAC labels

to maintain migration compatibility with libvirt < 0.10.0.

However the formatting was skipped unconditionally. Instead only
skip formatting in the VIR_DOMAIN_DEF_FORMAT_MIGRATABLE case.

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

9 years agoconf: storage: pool: reject name containing '/'
Cole Robinson [Tue, 26 Apr 2016 18:51:33 +0000 (14:51 -0400)]
conf: storage: pool: reject name containing '/'

Trying to define a pool name containing an embedded '/'
will immediately fail when trying to write the XML to disk.
This patch explicitly rejects names containing a '/'

Besides our stateful driver, there are two other storage impls:
esx and phyp. esx doesn't support pool creation, so this should
doesn't apply.

phyp does support pool creation, and the name is passed to the
'mksp' tool, which google doesn't reveal whether it accepts '/'
or not. IMO the likeliness of this impacting any users is near zero

9 years agoconf: network: reject name containing '/'
Cole Robinson [Tue, 26 Apr 2016 16:47:42 +0000 (12:47 -0400)]
conf: network: reject name containing '/'

Trying to define a network name containing an embedded '/'
will immediately fail when trying to write the XML to disk.
This patch explicitly rejects names containing a '/'

Besides the network bridge driver, the only other network
implementation is a very thin one for virtualbox, which seems to
use the network name as a host interface name, which won't
accept '/' anyways, so I think this is fine to do unconitionally.

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

9 years agoconf: domain: reject name containing '/'
Cole Robinson [Tue, 26 Apr 2016 15:23:12 +0000 (11:23 -0400)]
conf: domain: reject name containing '/'

Trying to define a domain name containing an embedded '/'
will immediately fail when trying to write the XML to disk for
our stateful drivers. This patch explicitly rejects names
containing a '/', and provides an xmlopt feature for drivers
to avoid this validation check, which is enabled in every
non-stateful driver that already has xmlopt handling wired up.

(Technically this could reject a previously accepted vmname like
 '/foo', however at least for the qemu driver that falls over
 later when starting qemu)

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

9 years agoconf: Parse more of our nodedev XML
Martin Kletzander [Sun, 3 Apr 2016 19:01:06 +0000 (21:01 +0200)]
conf: Parse more of our nodedev XML

We were lacking tests that are checking for the completeness of our
nodedev XMLs and also whether we output properly formatted ones.  This
patch adds parsing for the capability elements inside the <capability
type='pci'> element.  Also bunch of tests are added to show everything
works properly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoschemas: Update nodedev schema to match reality
Martin Kletzander [Sun, 3 Apr 2016 18:57:58 +0000 (20:57 +0200)]
schemas: Update nodedev schema to match reality

There were few things done in the nodedev code but we were lacking tests
for it.  And because of that we missed that the schema was not updated
either.  Fix the schema and add various test files to show the schema
is correct.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoMove capability formatting together
Martin Kletzander [Sun, 3 Apr 2016 18:36:40 +0000 (20:36 +0200)]
Move capability formatting together

All sub-PCI capabilities should be next to each other for clarity.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoChange virDevicePCIAddress to virPCIDeviceAddress
Martin Kletzander [Sun, 3 Apr 2016 18:16:51 +0000 (20:16 +0200)]
Change virDevicePCIAddress to virPCIDeviceAddress

We had both and the only difference was that the latter also included
information about multifunction setting.  The problem with that was that
we couldn't use functions made for only one of the structs (e.g.
parsing).  To consolidate those two structs, use the one in virpci.h,
include that in domain_conf.h and add the multifunction member in it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: hotplug: Fix possible memory leak of props
John Ferlan [Mon, 11 Apr 2016 14:00:32 +0000 (10:00 -0400)]
qemu: hotplug: Fix possible memory leak of props

If we failed to build the aliases or attach the chardev, then the props
would be leaked - fix that.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: hotplug: Adjust error path for attach hostdev scsi disk
John Ferlan [Mon, 11 Apr 2016 17:32:12 +0000 (13:32 -0400)]
qemu: hotplug: Adjust error path for attach hostdev scsi disk

Adjust error path logic to make it clearer how to undo the failed add.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: hotplug: Adjust error path for attach virtio disk
John Ferlan [Mon, 11 Apr 2016 13:16:54 +0000 (09:16 -0400)]
qemu: hotplug: Adjust error path for attach virtio disk

Adjust error path logic to make it clearer how to undo the failed add.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: hotplug: Adjust error path for attach scsi disk
John Ferlan [Mon, 11 Apr 2016 13:42:54 +0000 (09:42 -0400)]
qemu: hotplug: Adjust error path for attach scsi disk

Adjust error path logic to make it clearer how to undo the failed add.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Use qemuDomainSecretInfoPtr in qemuBuildNetworkDriveURI
John Ferlan [Thu, 7 Apr 2016 18:53:14 +0000 (14:53 -0400)]
qemu: Use qemuDomainSecretInfoPtr in qemuBuildNetworkDriveURI

Rather than take username and password as parameters, now take
a qemuDomainSecretInfoPtr and decode within the function.

NB: Having secinfo implies having the username for a plain type
    from a successful virSecretGetSecretString

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuDomainSecretHostdevPrepare and Destroy
John Ferlan [Wed, 6 Apr 2016 14:41:33 +0000 (10:41 -0400)]
qemu: Introduce qemuDomainSecretHostdevPrepare and Destroy

Similar to the qemuDomainSecretDiskPrepare, generate the secret
for the Hostdev's prior to call qemuProcessLaunch which calls
qemuBuildCommandLine. Additionally, since the secret is not longer
added as part of building the command, the hotplug code will need
to make the call to add the secret in the hostdevPriv.

Since this then is the last requirement to pass a virConnectPtr
to qemuBuildCommandLine, we now can remove that as part of these
changes. That removal has cascading effects through various callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>