]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: add vcpu.n.halted to vcpu domain stats
Viktor Mihajlovski [Thu, 13 Oct 2016 11:42:46 +0000 (13:42 +0200)]
qemu: add vcpu.n.halted to vcpu domain stats

Extended qemuDomainGetStatsVcpu to include the per vcpu halted
indicator if reported by QEMU. The key for new boolean value
has the format "vcpu.<n>.halted".

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: Add domain support for VCPU halted state
Viktor Mihajlovski [Thu, 13 Oct 2016 11:42:45 +0000 (13:42 +0200)]
qemu: Add domain support for VCPU halted state

Adding a field to the domain's private vcpu object to hold the halted
state information.
Adding two functions in support of the halted state:
- qemuDomainGetVcpuHalted: retrieve the halted state from a
  private vcpu object
- qemuDomainRefreshVcpuHalted: obtain the per-vcpu halted states
  via qemu monitor and store the results in the private vcpu objects

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Hao QingFeng <haoqf@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agoqemu: Add monitor support for CPU halted state
Viktor Mihajlovski [Thu, 13 Oct 2016 11:42:44 +0000 (13:42 +0200)]
qemu: Add monitor support for CPU halted state

Extended the qemuMonitorCPUInfo with a halted flag. Extract the halted
flag for both text and JSON monitor.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agoqemu: replace calls to virDomainPCIAddressReserveNext*() with static function
Laine Stump [Fri, 2 Sep 2016 20:39:18 +0000 (16:39 -0400)]
qemu: replace calls to virDomainPCIAddressReserveNext*() with static function

An upcoming commit will remove the "flag" argument from all the calls
to reserve the next available address|slot, but I don't want to change
the arguments in the hypervisor-agnostic
virDomainPCIAddressReserveNext*() functions, so this patch places a
simple qemu-specific wrapper around those functions - the new
functions don't take a flags arg, but grab it from the device's
info->pciConnectFlags.

8 years agoconf: make virDomainPCIAddressGetNextSlot() a local static function
Laine Stump [Thu, 1 Sep 2016 15:38:02 +0000 (11:38 -0400)]
conf: make virDomainPCIAddressGetNextSlot() a local static function

This function is no longer needed outside of domain_addr.c.

8 years agoqemu: use virDomainPCIAddressReserveNextAddr in qemuDomainAssignDevicePCISlots
Laine Stump [Thu, 1 Sep 2016 15:23:06 +0000 (11:23 -0400)]
qemu: use virDomainPCIAddressReserveNextAddr in qemuDomainAssignDevicePCISlots

instead of calling virDomainPCIAddressGetNextSlot() (which I want to
turn into a local static in domain_addr.c).

8 years agoconf: new function virDomainPCIAddressReserveNextAddr()
Laine Stump [Thu, 1 Sep 2016 13:29:01 +0000 (09:29 -0400)]
conf: new function virDomainPCIAddressReserveNextAddr()

There is an existing virDomainPCIAddressReserveNextSlot() which will
reserve all functions of the next available PCI slot. One place in the
qemu PCI address assignment code requires reserving a *single*
function of the next available PCI slot. This patch modifies and
renames virDomainPCIAddressReserveNextSlot() so that it can fulfill
both the original purpose and the need to reserve a single function.

(This is being done so that the abovementioned code in qemu can have
its "kind of open coded" solution replaced with a call to this new
function).

8 years agodomain: fix migration to older libvirt
Pavel Hrdina [Fri, 21 Oct 2016 14:42:26 +0000 (16:42 +0200)]
domain: fix migration to older libvirt

Since TLS was introduced hostwide for libvirt 2.3.0 and a domain
configurable haveTLS was implemented for libvirt 2.4.0, we have to
modify the migratable XML for specific case where the 'tls' attribute
is based on setting from qemu.conf.

The "tlsFromConfig" is libvirt internal attribute and is stored only in
status XML to ensure that when libvirtd is restarted this internal flag
is not lost by the restart.

That flag is used to decide whether we should put *tls* attribute to
migratable XML or not.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agodomain: Add optional 'tls' attribute for TCP chardev
Pavel Hrdina [Mon, 24 Oct 2016 12:05:54 +0000 (14:05 +0200)]
domain: Add optional 'tls' attribute for TCP chardev

Add an optional "tls='yes|no'" attribute for a TCP chardev.

For QEMU, this will allow for disabling the host config setting of the
'chardev_tls' for a domain chardev channel by setting the value to "no" or
to attempt to use a host TLS environment when setting the value to "yes"
when the host config 'chardev_tls' setting is disabled, but a TLS environment
is configured via either the host config 'chardev_tls_x509_cert_dir' or
'default_tls_x509_cert_dir'

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agodomain_conf: remove union for one member from redirdev struct
Pavel Hrdina [Mon, 24 Oct 2016 12:24:51 +0000 (14:24 +0200)]
domain_conf: remove union for one member from redirdev struct

Currently the union has only one member so remove that union.  If there
is a need to add a new type of source for new bus in the future this
will force the author to add a union and properly check bus type before
any access to union member.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agodomain_conf: fix memory leak in virDomainDefAddConsoleCompat
Pavel Hrdina [Fri, 21 Oct 2016 19:20:37 +0000 (21:20 +0200)]
domain_conf: fix memory leak in virDomainDefAddConsoleCompat

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: Add TLS hotplug for qemuDomainAttachRNGDevice
John Ferlan [Fri, 21 Oct 2016 14:06:50 +0000 (10:06 -0400)]
qemu: Add TLS hotplug for qemuDomainAttachRNGDevice

Commit id '2c322378' missed the nuance that the rng backend could be
using a TCP chardev and if TLS is enabled on the host, thus will need
to have the TLS object added.

8 years agoqemu: Add TLS hotplug for qemuDomainAttachRedirdevDevice
John Ferlan [Fri, 21 Oct 2016 13:59:53 +0000 (09:59 -0400)]
qemu: Add TLS hotplug for qemuDomainAttachRedirdevDevice

Commit id '2c322378' missed the nuance that the redirdev backend could
be using a TCP chardev and if TLS is enabled on the host, thus will need
to have the TLS object added.

8 years agoqemu: Clean up error path in qemuDomainAttachRedirdevDevice
John Ferlan [Fri, 21 Oct 2016 13:53:30 +0000 (09:53 -0400)]
qemu: Clean up error path in qemuDomainAttachRedirdevDevice

It's about to get more complicated - let's alter the logic to handle
various failures. Adds saving of the error as well.

8 years agoqemu: Introduce qemuDomainGetChardevTLSObjects for hotplug
John Ferlan [Fri, 21 Oct 2016 13:38:18 +0000 (09:38 -0400)]
qemu: Introduce qemuDomainGetChardevTLSObjects for hotplug

As it turns out more than one place will need these objects, so rather
than cut-copy-paste in each, make a helper

8 years agoconf: Use virDomainChrSourceDefNew for virDomainRNGDef allocation
John Ferlan [Fri, 21 Oct 2016 22:33:41 +0000 (18:33 -0400)]
conf: Use virDomainChrSourceDefNew for virDomainRNGDef allocation

Rather than VIR_ALLOC() the data, use virDomainChrSourceDefNew in order
to get the private data if necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Use virDomainChrSourceDefPtr for _virDomainRedirdevDef 'source.chr'
John Ferlan [Fri, 21 Oct 2016 22:27:52 +0000 (18:27 -0400)]
conf: Use virDomainChrSourceDefPtr for _virDomainRedirdevDef 'source.chr'

Use a pointer and the virDomainChrSourceDefNew() function in order to
allocate the structure for _virDomainRedirdevDef.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Use virDomainChrSourceDefPtr for _virDomainSmartcardDef 'passthru'
John Ferlan [Fri, 21 Oct 2016 22:08:02 +0000 (18:08 -0400)]
conf: Use virDomainChrSourceDefPtr for _virDomainSmartcardDef 'passthru'

Use a pointer and the virDomainChrSourceDefNew() function in order to
allocate the structure for _virDomainSmartcardDef.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoxenFormatXLDisk: Unify commas pattern for arguments
Michal Privoznik [Thu, 20 Oct 2016 13:59:01 +0000 (21:59 +0800)]
xenFormatXLDisk: Unify commas pattern for arguments

instead of:

  virBufferAdd(buf, "arg1,");
  virBufferAdd(buf, "arg2");

lets have:

  virBufferAdd(buf, "arg1");
  virBufferAdd(buf, ",arg2");

Because it's better. Consider we want to add conditionally arg3.
With this change, it's simple:

  if (cond)
    virBufferAdd(buf, ",arg3");

with current code there might be a comma hanging at EOL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: change first arg of qemuDomainAttachChrDeviceAssignAddr()
Laine Stump [Wed, 12 Oct 2016 19:24:57 +0000 (15:24 -0400)]
qemu: change first arg of qemuDomainAttachChrDeviceAssignAddr()

from virDomainDefPtr to virDomainObjPtr so that the function has
access to the other parts of the virDomainObjPtr. Take advantage of
this by removing the "priv" arg and retrieving it from the
virDomainObjPtr instead.

No functional change.

8 years agoqemu: make error message in qemuDomainPCIAddressSetCreate more clear.
Laine Stump [Thu, 13 Oct 2016 18:50:23 +0000 (14:50 -0400)]
qemu: make error message in qemuDomainPCIAddressSetCreate more clear.

This error should only ever be seen by a developer anyway, but the
existing message made even less sense that this new version.

8 years agoqemu: remove superfluous setting of addrs->nbuses
Laine Stump [Thu, 13 Oct 2016 18:49:12 +0000 (14:49 -0400)]
qemu: remove superfluous setting of addrs->nbuses

This is already set by virDomainPCIAddressSetAlloc().

8 years agoconf: add typedef for anonymous enum used for memballoon device model
Laine Stump [Fri, 7 Oct 2016 19:51:30 +0000 (15:51 -0400)]
conf: add typedef for anonymous enum used for memballoon device model

For some reason the values of memballoon model are set using an
anonymous enum, making it impossible to perform nice tricks like
demanding there are cases for all possible values in a switch. This
patch turns the anonymous enum into virDomainMemballoonModel.

8 years agoqemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound"
Laine Stump [Wed, 12 Oct 2016 19:01:32 +0000 (15:01 -0400)]
qemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound"

More occurences of repeatedly dereferencing the same pointer stored in
an array are replaced with the definition of a temporary pointer that
is then used directly. No functional change.

8 years agoqemu: replace a lot of "def->controllers[i]" with equivalent "cont"
Laine Stump [Tue, 6 Sep 2016 18:35:26 +0000 (14:35 -0400)]
qemu: replace a lot of "def->controllers[i]" with equivalent "cont"

There's no functional change here. This pointer was just used so many
times that the extra long lines became annoying.

8 years agoconf: Move the privateData from virDomainChrDef to virDomainChrSourceDef
John Ferlan [Fri, 21 Oct 2016 12:31:37 +0000 (08:31 -0400)]
conf: Move the privateData from virDomainChrDef to virDomainChrSourceDef

Commit id '5f2a132786' should have placed the data in the host source
def structure since that's also used by smartcard, redirdev, and rng in
order to provide a backend tcp channel.  The data in the private structure
will be necessary in order to provide the secret properly.

This also renames the previous names from "Chardev" to "ChrSource" for
the private data structures and API's

8 years agoIntroduce virDomainChrSourceDefNew for virDomainChrDefPtr
John Ferlan [Fri, 21 Oct 2016 11:45:54 +0000 (07:45 -0400)]
Introduce virDomainChrSourceDefNew for virDomainChrDefPtr

Change the virDomainChrDef to use a pointer to 'source' and allocate
that pointer during virDomainChrDefNew.

This has tremendous "fallout" in the rest of the code which mainly
has to change source.$field to source->$field.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovmx: Use the allocator virDomainChrDefNew
John Ferlan [Fri, 21 Oct 2016 12:09:51 +0000 (08:09 -0400)]
vmx: Use the allocator virDomainChrDefNew

Rather than VIR_ALLOC of the virDomainChrDefPtr

8 years agodoc: Describe the VCPU states returned by virsh vcpuinfo
Viktor Mihajlovski [Thu, 13 Oct 2016 11:08:01 +0000 (13:08 +0200)]
doc: Describe the VCPU states returned by virsh vcpuinfo

Added a brief description of the VCPU states.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
8 years agoqemuBuildHostNetStr: remove dead code
Ján Tomko [Fri, 14 Oct 2016 14:17:06 +0000 (16:17 +0200)]
qemuBuildHostNetStr: remove dead code

This function is never called for VIR_DOMAIN_NET_TYPE_HOSTDEV,
and the dead code comment agrees.

Introduced by commit 1dcbef8a.

8 years agoqemuBuildHostNetStr: do not start options with a comma
Ján Tomko [Fri, 14 Oct 2016 14:23:18 +0000 (16:23 +0200)]
qemuBuildHostNetStr: do not start options with a comma

Put the comma at the end and trim it later for consistency.

8 years agoqemuBuildHostNetStr: use type_sep earlier
Ján Tomko [Fri, 14 Oct 2016 13:16:46 +0000 (15:16 +0200)]
qemuBuildHostNetStr: use type_sep earlier

When hotplugging networks with ancient QEMUs not supporting
QEMU_CAPS_NETDEV, we use space instead of a comma as the separator
between the network type and other options.

Except for "user", all the network types pass other options
and use up the first separator by the time we get to the section
that adds the alias (or vlan for QEMUs without CAPS_NETDEV).

Since the alias/vlan is mandatory, convert all preceding code to add
the separator at the end, removing the need to rewrite type_sep for
all types but NET_TYPE_USER.

8 years agovz: set something in disk driver name
Nikolay Shirokovskiy [Thu, 22 Sep 2016 14:55:42 +0000 (17:55 +0300)]
vz: set something in disk driver name

Absent driver name attribute is invalid xml. Which in turn makes
unusable 'virsh edit' for example. The value does not make
much sense and ignored on input so nobody will hurt.

8 years agovz: add serial number to disk devices
Nikolay Shirokovskiy [Thu, 22 Sep 2016 14:55:41 +0000 (17:55 +0300)]
vz: add serial number to disk devices

vz sdk supports setting serial number only for disk devices.
Getting serial upon cdrom(for example) is error however
setting is just ignored. Let's check for disk device
explicitly for clarity in both cases.

Setting serial number for other devices is ignored
with an info note just as before.

We need usual conversion from "" to NULL in direction
vz sdk -> libvirt, because "" is not valid for libvirt
and "" means unspecifiend in vz sdk which is NULL for libvirt.

8 years agobhyve: Need to add parameter to virDomainChrDefNew
John Ferlan [Fri, 21 Oct 2016 11:52:26 +0000 (07:52 -0400)]
bhyve: Need to add parameter to virDomainChrDefNew

Commit id '5f2a13278' missed this one.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovz: set localhost as vnc address
Mikhail Feoktistov [Tue, 18 Oct 2016 16:19:04 +0000 (12:19 -0400)]
vz: set localhost as vnc address

We should set localhost as vnc address in case of empty string.
Because Virtuozzo sets 0.0.0.0 as default vnc address.

8 years agovirt-wireshark.m4: Defer $(prefix) substitution
Michal Privoznik [Thu, 20 Oct 2016 02:25:13 +0000 (10:25 +0800)]
virt-wireshark.m4: Defer $(prefix) substitution

The autoconf manual says we shouldn't be using this variable (and
some others) outside of Makefiles as it prevents users providing
their own prefix at the installation phase.

https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonetworkValidate: Forbid new-line char in network name
Sławek Kapłoński [Wed, 19 Oct 2016 20:57:48 +0000 (22:57 +0200)]
networkValidate: Forbid new-line char in network name

New line character in name of network is now forbidden because it
mess virsh output and can be confusing for users.  Validation of
name is done in network driver, after parsing XML to avoid
problems with disappeared network which was already created with
new-line char in name.

Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=818064
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonetwork: Use new util function to check name
Sławek Kapłoński [Wed, 19 Oct 2016 20:57:47 +0000 (22:57 +0200)]
network: Use new util function to check name

New util function virXMLCheckIllegalChars is now used to test if
parsed network contains illegal char '/' in it's name.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirxml: Add function to check if string contains some illegal chars
Sławek Kapłoński [Wed, 19 Oct 2016 20:57:46 +0000 (22:57 +0200)]
virxml: Add function to check if string contains some illegal chars

This new function can be used to check if e.g. name of XML
node don't contains forbidden chars like "/" or "\n".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Introduce qemuDomainChardevPrivatePtr
John Ferlan [Fri, 17 Jun 2016 10:36:11 +0000 (06:36 -0400)]
qemu: Introduce qemuDomainChardevPrivatePtr

Modeled after the qemuDomainHostdevPrivatePtr (commit id '27726d8c'),
create a privateData pointer in the _virDomainChardevDef to allow storage
of private data for a hypervisor in order to at least temporarily store
secret data for usage during qemuBuildCommandLine.

NB: Since the qemu_parse_command (qemuParseCommandLine) code is not
expecting to restore the secret data, there's no need to add code
code to handle this new structure there.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce {default|chardev}_tls_x509_secret_uuid
John Ferlan [Thu, 8 Sep 2016 14:04:59 +0000 (10:04 -0400)]
conf: Introduce {default|chardev}_tls_x509_secret_uuid

Add a new qemu.conf variables to store the UUID for the secret that could
be used to present credentials to access the TLS chardev.  Since this will
be a server level and it's possible to use some sort of default, introduce
both the default and chardev logic at the same time making the setting of
the chardev check for it's own value, then if not present checking whether
the default value had been set.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoxl: fix 8126d870 broken test
Cédric Bosdonnat [Wed, 19 Oct 2016 18:51:15 +0000 (20:51 +0200)]
xl: fix 8126d870 broken test

xlconfigtest expects the comma, don't clean it up even if there is
no target to write.

8 years agospec: Drop support for Fedora < 23
Andrea Bolognani [Wed, 19 Oct 2016 14:49:17 +0000 (16:49 +0200)]
spec: Drop support for Fedora < 23

We only claim support for OSs that are still supported by the
respective vendors, which means anything older than Fedora 23
is out. Reword the comment a bit to highlight the criteria.

8 years agoxl: don't output (null) target in domxml-to-native
Cédric Bosdonnat [Mon, 17 Oct 2016 07:57:22 +0000 (09:57 +0200)]
xl: don't output (null) target in domxml-to-native

When converting a domain xml containing a CDROM device without
any attached source, don't add a target=(null) to the libxl config
disk definition: xen doesn't like it at all and would fail to start
the domain.

8 years agoqemu: always generate the same alias for tls-creds-x509 object
Pavel Hrdina [Tue, 18 Oct 2016 13:33:00 +0000 (15:33 +0200)]
qemu: always generate the same alias for tls-creds-x509 object

There was inconsistency between alias used to create tls-creds-x509
object and alias used to link that object to chardev while hotpluging.
Hotplug ends with this error:

  error: Failed to detach device from channel-tcp.xml
  error: internal error: unable to execute QEMU command 'chardev-add':
  No TLS credentials with id 'objcharchannel3_tls0'

In XML we have for example alias "serial0", but on qemu command line we
generate "charserial0".

The issue was that code, that creates QMP command to hotplug chardev
devices uses only the second alias "charserial0" and that alias is also
used to link the tls-creds-x509 object.

This patch unifies the aliases for tls-creds-x509 to be always generated
from "charserial0".

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: create prefixed alias to separate variable
Pavel Hrdina [Tue, 18 Oct 2016 13:27:32 +0000 (15:27 +0200)]
qemu_command: create prefixed alias to separate variable

Instead of typing the prefix every time we want to append parameters
to qemu command line use a variable that contains prefixed alias.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_alias: introduce qemuAliasChardevFromDevAlias helper
Pavel Hrdina [Tue, 18 Oct 2016 14:37:23 +0000 (16:37 +0200)]
qemu_alias: introduce qemuAliasChardevFromDevAlias helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_hotplug: fix crash in hot(un)plugging chardev devices
Pavel Hrdina [Tue, 18 Oct 2016 06:59:14 +0000 (08:59 +0200)]
qemu_hotplug: fix crash in hot(un)plugging chardev devices

We need to make sure that the chardev is TCP.  Without this check we
may access different part of union and corrupt pointers.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: Remove unnecessary NULL arg check
John Ferlan [Mon, 17 Oct 2016 14:46:00 +0000 (10:46 -0400)]
qemu: Remove unnecessary NULL arg check

qemuDomainSecret{Disk|Hostdev}Prepare has a prototype that checks for
ATTRIBUTE_NONNULL(1) for 'conn'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add 'verify-peer=yes' test for chardev TCP TLS
John Ferlan [Mon, 17 Oct 2016 15:31:43 +0000 (11:31 -0400)]
qemu: Add 'verify-peer=yes' test for chardev TCP TLS

Missing the option to set verify-peer to yes

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Remove unnecessary cfg fetch/unref
John Ferlan [Mon, 17 Oct 2016 14:44:11 +0000 (10:44 -0400)]
qemu: Remove unnecessary cfg fetch/unref

qemuProcessPrepareDomain has no need to fetch/unref the cfg, so remove it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Explain some code in more detail
Andrea Bolognani [Wed, 12 Oct 2016 15:02:37 +0000 (17:02 +0200)]
conf: Explain some code in more detail

The code is entirely correct, but it still managed to trip me
up when I first ran into it because I did not realize right away
that VIR_PCI_CONNECT_TYPES_ENDPOINT was not a single flag, but
rather a mask including both VIR_PCI_CONNECT_TYPE_PCI_DEVICE and
VIR_PCI_CONNECT_TYPE_PCIE_DEVICE.

In order to save the next distracted traveler in PCI Address Land
some time, document this fact with a comment. Add a test case for
the behavior as well.

8 years agoconf: restrict what type of buses will accept a pci-bridge
Laine Stump [Sun, 7 Aug 2016 21:13:58 +0000 (17:13 -0400)]
conf: restrict what type of buses will accept a pci-bridge

A pci-bridge has *almost* the same rules as a legacy PCI endpoint
device for where it can be automatically connected, and until now both
had been considered identical. There is one pairing that is okay when
specifically requested by the user (i.e. manual assignment), but we
want to avoid it when auto-assigning addresses - plugging a pci-bridge
directly into pcie-root (it is cleaner to plug in a dmi-to-pci-bridge,
then plug the pci-bridge into that).

In order to allow that difference, this patch makes a separate
CONNECT_TYPE for pci-bridge, and uses it to restrict auto-assigned
addresses for pci-bridges to be only on pci-root, pci-expander-bus,
dmi-to-pci-bridge, or on another pci-bridge.

NB: As with other discouraged-but-seem-to-work configurations
(e.g. plugging a legacy PCI device into a pcie-root-port) if someone
*really* wants to, they can still force a pci-bridge to be plugged
into pcie-root (by manually specifying its PCI address.)

8 years agoutil: Alter return value of virReadFCHost and fix mem leak
John Ferlan [Tue, 11 Oct 2016 15:21:19 +0000 (11:21 -0400)]
util: Alter return value of virReadFCHost and fix mem leak

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

Rather than return a 0 or -1 and the *result string, return just the result
string to the caller.  Alter all the callers to handle the different return.

As a side effect or result of this, it's much clearer that we cannot just
assign the returned string into the scsi_host wwnn, wwpn, and fabric_wwn
fields - rather we should fetch a temporary string, then as long as our
fetch was good, VIR_FREE what may have been there, and STEAL what we just got.
This fixes a memory leak in the virNodeDeviceCreateXML code path through
find_new_device and nodeDeviceLookupSCSIHostByWWN which will continually
call nodeDeviceSysfsGetSCSIHostCaps until the expected wwnn/wwpn is found
in the device object capabilities.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Honour flags in virDomainPanicDefParseXML
Martin Kletzander [Thu, 13 Oct 2016 07:56:14 +0000 (09:56 +0200)]
conf: Honour flags in virDomainPanicDefParseXML

Without them we're keeping <alias/> even for inactive XML.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoschema: Allow alias for panic device
Martin Kletzander [Thu, 13 Oct 2016 07:55:27 +0000 (09:55 +0200)]
schema: Allow alias for panic device

As with all other devices, it's not part of 'address'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu_hotplug: Support interface type of vhost-user hotplug
Michal Privoznik [Mon, 15 Aug 2016 16:01:55 +0000 (18:01 +0200)]
qemu_hotplug: Support interface type of vhost-user hotplug

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

There are couple of things that needs to be done in order to
allow vhost-user hotplug. Firstly, vhost-user requires a chardev
which is connected to vhost-user bridge and through which qemu
communicates with the bridge (no acutal guest traffic is sent
through there, just some metadata). In order to generate proper
chardev alias, we must assign device alias way sooner.

Then, because we are plugging the chardev first, we need to do
the proper undo if something fails - that is remove netdev too.
We don't want anything to be left over in case attach fails at
some point.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildHostNetStr: Support VIR_DOMAIN_NET_TYPE_VHOSTUSER
Michal Privoznik [Tue, 16 Aug 2016 10:55:02 +0000 (12:55 +0200)]
qemuBuildHostNetStr: Support VIR_DOMAIN_NET_TYPE_VHOSTUSER

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

So far, this function lacked support for
VIR_DOMAIN_NET_TYPE_VHOSTUSER leaving callers to hack around the
problem by constructing the command line on their own. This is
not ideal as it blocks hot plug support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildVhostuserCommandLine: Unify -netdev creation
Michal Privoznik [Tue, 16 Aug 2016 10:21:49 +0000 (12:21 +0200)]
qemuBuildVhostuserCommandLine: Unify -netdev creation

Currently, what we do for vhost-user network is generate the
following part of command line:

-netdev type=vhost-user,id=hostnet0,chardev=charnet0

There's no need for 'type=' it is the default. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr
Michal Privoznik [Mon, 15 Aug 2016 14:15:44 +0000 (16:15 +0200)]
qemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr

There's no need to reinvent the wheel here. We already have a
function to format virDomainChrSourceDefPtr. It's called
qemuBuildChrChardevStr(). Use that instead of some dummy
virBufferAsprintf().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildChrChardevStr: Introduce @nowait argument
Michal Privoznik [Tue, 16 Aug 2016 11:06:46 +0000 (13:06 +0200)]
qemuBuildChrChardevStr: Introduce @nowait argument

This alone makes not much sense. But the aim is to reuse this
function in qemuBuildVhostuserCommandLine() where 'nowait' is not
supported for vhost-user devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildHostNetStr: Explicitly enumerate net types
Michal Privoznik [Tue, 16 Aug 2016 06:48:04 +0000 (08:48 +0200)]
qemuBuildHostNetStr: Explicitly enumerate net types

We tend to prevent using 'default' in switches. And it is for a
good reason - control may end up in paths we wouldn't want for
new values. In this specific case, if qemuBuildHostNetStr is
called over VIR_DOMAIN_NET_TYPE_VHOSTUSER it would produce
meaningless output. Fortunately, there no such call yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainAttachNetDevice: Explicitly list allowed types for hotplug
Michal Privoznik [Mon, 26 Sep 2016 09:53:58 +0000 (11:53 +0200)]
qemuDomainAttachNetDevice: Explicitly list allowed types for hotplug

Instead of blindly claim support for hot-plugging of every
interface type out there we should copy approach we have for
device types: white listing supported types and explicitly error
out on unsupported ones.
For instance, trying to hotplug vhostuser interface results in
nothing usable from guest currently. vhostuser typed interfaces
require additional work on our side.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainAttachNetDevice: Move hostdev handling a bit further
Michal Privoznik [Mon, 26 Sep 2016 09:41:36 +0000 (11:41 +0200)]
qemuDomainAttachNetDevice: Move hostdev handling a bit further

The idea is to have function that does some checking at its
beginning and then have one big switch for all the interface
types it supports.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildInterfaceCommandLine: Move from if-else forest to switch
Michal Privoznik [Mon, 26 Sep 2016 09:05:00 +0000 (11:05 +0200)]
qemuBuildInterfaceCommandLine: Move from if-else forest to switch

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildInterfaceCommandLine: Move vhostuser handling a bit further
Michal Privoznik [Mon, 26 Sep 2016 08:32:44 +0000 (10:32 +0200)]
qemuBuildInterfaceCommandLine: Move vhostuser handling a bit further

The idea is to have function that does some checking of the
arguments at its beginning and then have one big switch for all
the interface types it supports. Each one of them generating the
corresponding part of the command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildInterfaceCommandLine: Move hostdev handling a bit further
Michal Privoznik [Mon, 26 Sep 2016 07:54:26 +0000 (09:54 +0200)]
qemuBuildInterfaceCommandLine: Move hostdev handling a bit further

The idea is to have function that does some checking of the
arguments at its beginning and then have one big switch for all
the interface types it supports. Each one of them generating the
corresponding part of the command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirDomainNetGetActualType: Return type is virDomainNetType
Michal Privoznik [Fri, 23 Sep 2016 15:04:53 +0000 (17:04 +0200)]
virDomainNetGetActualType: Return type is virDomainNetType

This function for some weird reason returns integer instead of
virDomainNetType type. It is important to return the correct type
so that we know what values we can expect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirDomainNetDefParseXML: Realign
Michal Privoznik [Mon, 26 Sep 2016 09:06:43 +0000 (11:06 +0200)]
virDomainNetDefParseXML: Realign

There are couple of formatting issues. No functional change
though.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirLogDefineOutputs: Fix build without syslog.h
Michal Privoznik [Fri, 14 Oct 2016 02:09:03 +0000 (10:09 +0800)]
virLogDefineOutputs: Fix build without syslog.h

Not every system out there has syslog, that's why we check for it
in our configure script. However, in 640b58abdf while fixing
another issue, some variables and functions are called that are
defined only when syslog.h is present. But these function
calls/variables were not guarded by #ifdef-s.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoschema: smbios: allow any strings
Peter Krempa [Mon, 10 Oct 2016 15:49:03 +0000 (17:49 +0200)]
schema: smbios: allow any strings

The smbios docs allow any string to be passed and libvirt does not
really do any validation on them. Allow passing any string.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373535

8 years agoqemu: command: escape smbios entry strings
Peter Krempa [Mon, 10 Oct 2016 04:26:50 +0000 (06:26 +0200)]
qemu: command: escape smbios entry strings

We pass free-form strings from the users to qemu, thus we need escape
commas since they are passed to qemu monitor.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373535

8 years agoqemu: command: Don't bother reporting errors in smbios formatters
Peter Krempa [Mon, 10 Oct 2016 04:03:57 +0000 (06:03 +0200)]
qemu: command: Don't bother reporting errors in smbios formatters

qemuBuildSmbiosBiosStr and qemuBuildSmbiosSystemStr return NULL if
there's nothing to format on the commandline. Reporting errors from
buffer creation doesn't make sense since it would be ignored.

8 years agoqemu: command: Fix up coding style of smbios commandine formatters
Peter Krempa [Mon, 10 Oct 2016 04:01:25 +0000 (06:01 +0200)]
qemu: command: Fix up coding style of smbios commandine formatters

8 years agosrc: Treat PID as signed
Michal Privoznik [Thu, 6 Oct 2016 14:54:41 +0000 (16:54 +0200)]
src: Treat PID as signed

This initially started as a fix of some debug printing in
virCgroupDetect. However it turned out that other places suffer
from the similar problem. While dealing with pids, esp. in cases
where we cannot use pid_t for ABI stability reasons, we often
chose an unsigned integer type. This makes no sense as pid_t is
signed.
Also, new syntax-check rule is introduced so we won't repeat this
mistake.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: Be explicit that vol-resize is an offline operation.
Ivan Baldo [Tue, 11 Oct 2016 20:13:57 +0000 (17:13 -0300)]
virsh: Be explicit that vol-resize is an offline operation.

It is stated in the manual already, so let's mention the same thing in
the description to avoid causing problems.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotestNodeGetCellsFreeMemory: Fix off by one error
Michal Privoznik [Thu, 15 Sep 2016 15:42:36 +0000 (17:42 +0200)]
testNodeGetCellsFreeMemory: Fix off by one error

Consider the following scenario:

  virsh # freecell --all
      0:       2048 KiB
      1:       4096 KiB
  --------------------
  Total:       6144 KiB

  virsh # freecell 0
  0: 2048 KiB

  virsh # freecell 1
  1: 4096 KiB

And now before this change:

  virsh # freecell 2

After this change:

  virsh # freecell 2
  error: invalid argument: Range exceeds available cells

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotestOpenDefault: Rename loop variable
Michal Privoznik [Thu, 15 Sep 2016 15:10:15 +0000 (17:10 +0200)]
testOpenDefault: Rename loop variable

We have inclination to calling our loop variables i, j, k, not u.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: Fix typos in manpage
Nitesh Konkar [Mon, 10 Oct 2016 14:07:14 +0000 (19:37 +0530)]
virsh: Fix typos in manpage

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agovirsh: Fix commas in manpage to enhance readability.
Nitesh Konkar [Mon, 10 Oct 2016 14:07:13 +0000 (19:37 +0530)]
virsh: Fix commas in manpage to enhance readability.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoqemu_command: add support to use virtio as secondary video device
Pavel Hrdina [Mon, 10 Oct 2016 18:19:06 +0000 (20:19 +0200)]
qemu_command: add support to use virtio as secondary video device

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: introduce enum of secondary models for video device
Pavel Hrdina [Wed, 12 Oct 2016 15:39:02 +0000 (17:39 +0200)]
qemu_command: introduce enum of secondary models for video device

There are two video devices with models without VGA compatibility mode.
They are primary used as secondary video devices, but in some cases it
is required to use them also as primary video devices.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: cleanup qemuBuildVideoCommandLine
Pavel Hrdina [Tue, 11 Oct 2016 15:20:39 +0000 (17:20 +0200)]
qemu_command: cleanup qemuBuildVideoCommandLine

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: properly detect which model to use for video device
Pavel Hrdina [Fri, 30 Sep 2016 12:41:37 +0000 (14:41 +0200)]
qemu_command: properly detect which model to use for video device

This improves commit 706b5b6277 in a way that we check qemu capabilities
instead of what architecture we are running on to detect whether we can
use *virtio-vga* model or not.  This is not a case only for arm/aarch64.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_capabilities: check for existence of virtio-vga
Pavel Hrdina [Tue, 11 Oct 2016 12:07:58 +0000 (14:07 +0200)]
qemu_capabilities: check for existence of virtio-vga

Commit 21373feb added support for primary virtio-vga device but it was
checking for virtio-gpu.  Let's check for existence of virtio-vga if we
want to use it.

Virtio video device is currently represented by three different models
*virtio-gpu-device*, *virtio-gpu-pci* and *virtio-vga*.  The first two
models are tied together and if virtio video devices is compiled in they
both exist.  However, the *virtio-vga* model doesn't have to exist on
some architectures even if the first two models exist.  So we cannot
group all three together.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: pass only video device to qemuBuildVgaVideoCommand
Pavel Hrdina [Tue, 11 Oct 2016 15:56:41 +0000 (17:56 +0200)]
qemu_command: pass only video device to qemuBuildVgaVideoCommand

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: separate code for video device via -vga attribute
Pavel Hrdina [Tue, 11 Oct 2016 15:55:32 +0000 (17:55 +0200)]
qemu_command: separate code for video device via -vga attribute

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: always check capabilities for video devices
Pavel Hrdina [Mon, 10 Oct 2016 15:51:38 +0000 (17:51 +0200)]
qemu_process: always check capabilities for video devices

Before this patch we've checked qemu capabilities for video devices
only while constructing qemu command line using "-device" option.

Since we support qemu only if "-device" option is present we can use
the same capabilities to check also video devices while using "-vga"
option to construct qemu command line.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: move video validation out of qemu_command
Pavel Hrdina [Tue, 11 Oct 2016 15:53:50 +0000 (17:53 +0200)]
qemu_process: move video validation out of qemu_command

Runtime validation that depend on qemu capabilities should be moved
into qemuProcessStartValidateXML.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_domain: move video validation out of qemu_command
Pavel Hrdina [Tue, 11 Oct 2016 15:48:59 +0000 (17:48 +0200)]
qemu_domain: move video validation out of qemu_command

All definition validation that doesn't depend on qemu capabilities
and was allowed previously as valid definition should be placed into
qemuDomainDefValidate.

The check whether video type is supported or not was based on an enum
that translates type into model.  Use switch to ensure that if new
video type is added, it will be properly handled.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_capabilities: detect properties for virtio-gpu-device
Pavel Hrdina [Mon, 10 Oct 2016 15:56:35 +0000 (17:56 +0200)]
qemu_capabilities: detect properties for virtio-gpu-device

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_capabilities: rename QEMU_CAPS_VIRTIO_GPU_VIRGL
Pavel Hrdina [Tue, 11 Oct 2016 12:06:53 +0000 (14:06 +0200)]
qemu_capabilities: rename QEMU_CAPS_VIRTIO_GPU_VIRGL

We generally uses QEMU_CAPS_DEVICE_$NAME to probe for existence of some
device and QEMU_CAPS_$NAME_$PROP to probe for existence of some property
of that device.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_capabilities: mark QEMU_CAPS_VGA_QXL capability as deprecated
Pavel Hrdina [Tue, 11 Oct 2016 15:46:39 +0000 (17:46 +0200)]
qemu_capabilities: mark QEMU_CAPS_VGA_QXL capability as deprecated

If QEMU in question supports QMP, this capability is set if
QEMU_CAPS_DEVICE_QXL was set based on existence of "-device qxl". If
libvirt needs to parse *help*, because there is no QMP support, it
checks for existence of "-vga qxl", but it also parses output of
"-device ?" and sets QEMU_CAPS_DEVICE_QXL too.

Now that libvirt supports only QEMU that has "-device" implemented it's
safe to drop this capability and stop using it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_capabilities: join capabilities for qxl and qxl-vga devices
Pavel Hrdina [Tue, 11 Oct 2016 15:42:37 +0000 (17:42 +0200)]
qemu_capabilities: join capabilities for qxl and qxl-vga devices

This patch simplifies QEMU capabilities for QXL video device.  QEMU
exposes this device as *qxl-vga* and *qxl* and they are both the same
device with the same set of parameters, the only difference is that
*qxl-vga* includes VGA compatibility.

Based on QEMU code they are tied together so it's safe to check only for
presence of only one of them.

This patch also removes an invalid test case "video-qxl-sec-nodevice"
where there is only *qxl-vga* device and *qxl* device is not present.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: fix some QXL capability combinations that don't make sense
Pavel Hrdina [Wed, 21 Sep 2016 16:26:21 +0000 (18:26 +0200)]
tests: fix some QXL capability combinations that don't make sense

If one of QEMU_CAPS_DEVICE_QXL_VGA or QEMU_CAPS_DEVICE_QXL is set the
other one will always be set as well because both devices are tied
together in QEMU.

The change of args files is caused by the presence of capability
QEMU_CAPS_DEVICE_VIDEO_PRIMARY which means it's safe to use
"-device qxl-vga" instead of "-vga qxl", see commit (e3f2686b) and
by the fact that if QEMU_CAPS_VGA_QXL is set QEMU_CAPS_DEVICE_QXL_VGA
and QEMU_CAPS_DEVICE_QXL would be set too (since we support only qemu
with "-device" option).

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_command: remove xenner leftover from video device code
Pavel Hrdina [Tue, 11 Oct 2016 15:37:45 +0000 (17:37 +0200)]
qemu_command: remove xenner leftover from video device code

Qemu supports *xen* video device only with XEN and this code was part
of xenner code.  We dropped support for xenner in commit de9be0a.

Before this patch if you used 'xen' video type you ended up with
domain without any video device at all.  Now we don't allow to start
such domain.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: move qemuProcessStartValidateGraphics to correct place
Pavel Hrdina [Mon, 10 Oct 2016 17:55:17 +0000 (19:55 +0200)]
qemu_process: move qemuProcessStartValidateGraphics to correct place

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agovirsh: vcpuinfo: Report proper vcpu numbers and data for offline VMs
Peter Krempa [Tue, 11 Oct 2016 16:03:50 +0000 (18:03 +0200)]
virsh: vcpuinfo: Report proper vcpu numbers and data for offline VMs

If the VM is offline virsh attempted to at least report the pinning
information for the VM. This would not work properly now that the vcpus
can be sparse. Fix it by getting the vcpu states from the XML.

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

8 years agovirsh: Extract fallback handling in cmdVcpuinfo
Peter Krempa [Thu, 29 Sep 2016 14:37:35 +0000 (16:37 +0200)]
virsh: Extract fallback handling in cmdVcpuinfo

Put it into a separate function so that more fallback handling can be
added without making a mess.