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

8 years agovirsh: Extract cpumap formatting in cmdVcpuinfo
Peter Krempa [Thu, 29 Sep 2016 10:59:37 +0000 (12:59 +0200)]
virsh: Extract cpumap formatting in cmdVcpuinfo

cmdVcpuinfo will be split in upcomming patches thus extract the common
code that formats pinning cpumaps for the vcpus.

8 years agovirsh: Fix xpath queries for retrieving vcpu count
Peter Krempa [Tue, 11 Oct 2016 13:40:31 +0000 (15:40 +0200)]
virsh: Fix xpath queries for retrieving vcpu count

The fallback code used if virDomainGetVcpusFlags is not supported used
wrong XPath queries and basically did not work at all. Fix them to point
to the <domain> <vcpu> element instead of <vcpus> which was not present
until lately.

8 years agovirsh: domain: Fix broken indentation in virshCPUCountCollect
Peter Krempa [Mon, 3 Oct 2016 14:46:11 +0000 (16:46 +0200)]
virsh: domain: Fix broken indentation in virshCPUCountCollect

I managed to space most of the code by 5 spaces instead of 4 when
orignally implementing this function.

8 years agoutil: bitmap: Make bitmaps const in virBitmapNewData and virBitmapDataToString
Peter Krempa [Thu, 29 Sep 2016 10:56:58 +0000 (12:56 +0200)]
util: bitmap: Make bitmaps const in virBitmapNewData and virBitmapDataToString

The functions just read the passed pointer so it can be marked as const.

8 years agolibvirt-guests: Weaken dependency on libvirtd
Andrea Bolognani [Fri, 7 Oct 2016 08:10:42 +0000 (10:10 +0200)]
libvirt-guests: Weaken dependency on libvirtd

The Requires relationship is very strong, in that it prevents
a unit from running unless all the units it Requires are
running as well.

This turns out to be a problem because we want to be able to
restart libvirtd at any time without having libvirt-guests
suspend or shutdown running guests.

Turn the Requires relationship into a Wants relationship:
this way starting libvirt-guests will cause systemd to (attempt
to) start libvirtd as well, but stopping or restarting libvirtd
will not alter libvirt-guests' running state.

8 years agoqemu: Disable migration with ivshmem
Martin Kletzander [Tue, 20 Sep 2016 09:24:49 +0000 (11:24 +0200)]
qemu: Disable migration with ivshmem

It was never safe anyway and as such shouldn't have been enabled in the
first place.  Future patches will allow hot-(un)pluging of some ivshmem
devices as a workaround.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoconf: Don't complicate find loop
Martin Kletzander [Fri, 7 Oct 2016 13:56:40 +0000 (15:56 +0200)]
conf: Don't complicate find loop

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoconf: Fix virDomainShmemDefFind
Martin Kletzander [Wed, 21 Sep 2016 13:14:46 +0000 (15:14 +0200)]
conf: Fix virDomainShmemDefFind

Due to the switch of parameters in a call to virDomainShmemDefEquals()
no device was found when looking for device with all the information
except address.  Also fix the indentation.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoClean timer in virObjectEventStateFlush
Martin Kletzander [Tue, 11 Oct 2016 11:44:21 +0000 (13:44 +0200)]
Clean timer in virObjectEventStateFlush

If the last event callback is unregistered while the event loop is
dispatching, it is only marked as deleted, but not removed.  The number
of callbacks is more than zero in that case, so the timer is not
removed.  Because it can be removed in this function now (but also
accessed afterwards so that we set 'isDispatching = false' and have it
locked), we need to temporarily increase the reference counter of the
state for the duration of this function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoDe-duplicate code into virObjectEventStateCleanupTimer()
Martin Kletzander [Tue, 11 Oct 2016 11:35:18 +0000 (13:35 +0200)]
De-duplicate code into virObjectEventStateCleanupTimer()

There is a repeating pattern of code that removes the timer if it's not
needed.  So let's move it to a new function.  We'll also use it later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoReference state when using it as opaque
Martin Kletzander [Tue, 11 Oct 2016 11:30:11 +0000 (13:30 +0200)]
Reference state when using it as opaque

There should be one more reference because it is being kept in the list
of callbacks as an opaque.  We also unref it properly using
virObjectFreeCallback.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoChange virDomainEventState to virObjectLockable
Martin Kletzander [Tue, 11 Oct 2016 07:48:36 +0000 (09:48 +0200)]
Change virDomainEventState to virObjectLockable

This way we get reference counting and we can get rid of locking
function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: migration: Disallow migration of read only disk
Corey S. McQuay [Mon, 26 Sep 2016 17:16:00 +0000 (13:16 -0400)]
qemu: migration: Disallow migration of read only disk

Currently Libvirt allows attempts to migrate read only disks. Qemu
cannot handle this as read only disks cannot be written to on the
destination system. The end result is a cryptic error message and a
failed migration.

This patch causes migration to fail earlier and provides a meaningful
error message stating that migrating read only disks is not supported.

Signed-off-by: Corey S. McQuay <csmcquay@linux.vnet.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agoqemu: Reuse virDomainDeGetVcpusTopology to calculate total vcpu count
Peter Krempa [Mon, 10 Oct 2016 13:57:54 +0000 (15:57 +0200)]
qemu: Reuse virDomainDeGetVcpusTopology to calculate total vcpu count

Rather than multiplying sockets, cores, and threads use the new helper
for getting the vcpu count resulting from the topology.

8 years agoconf: Sanitize cpu topology numbers
Peter Krempa [Mon, 10 Oct 2016 13:46:25 +0000 (15:46 +0200)]
conf: Sanitize cpu topology numbers

Make sure that the topology results into a sane number of cpus (up to
UINT_MAX) so that it can be sanely compared to the vcpu count of the VM.

Additionally the helper added in this patch allows to fetch the total
number the topology results to so that it does not have to be
reimplemented later.

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

8 years agoutil: Remove need for local 'nelems'
John Ferlan [Mon, 10 Oct 2016 20:08:39 +0000 (16:08 -0400)]
util: Remove need for local 'nelems'

Since it's only used in loop - just go direct.

8 years agotests: Need to initialize data
John Ferlan [Mon, 10 Oct 2016 15:08:26 +0000 (11:08 -0400)]
tests: Need to initialize data

If not initialized and the virAsprintf to jsonreply or fulllablel fails,
then the call to qemuMonitorTestFree will take stack data.

8 years agovsh: Fix some issues in auto completion code
John Ferlan [Mon, 10 Oct 2016 13:01:18 +0000 (09:01 -0400)]
vsh: Fix some issues in auto completion code

1. Move the declaration of const vshCmdDef *help - it should be at the
   top of the "if" rather than in the middle.

2. Change a comparison from && to || - without doing so we could crash
   on commands like 'virsh list' which would allow completion of some
   non -- option based on whatever was found in the current working
   directory and then as soon as that was completed, the next <tab>
   would crash since "opt" would be returned as NULL, but the check
   was dereferencing "&& opt->type"

3. Before dereferencing opt->completer, be sure opt isn't NULL.

8 years agoutil: Resolve memory leaks in virLogParse{Output|Filter}
John Ferlan [Mon, 10 Oct 2016 11:18:30 +0000 (07:18 -0400)]
util: Resolve memory leaks in virLogParse{Output|Filter}

In both virLogParseOutput and virLogParseFilter, rather than returning
NULL, goto cleanup since it's possible that for each the first condition
passes, but the || condition doesn't and thus we leak memory.

8 years agotests: Prefer virGetLastErrorMessage in testSELinuxLabeling
John Ferlan [Mon, 10 Oct 2016 10:30:28 +0000 (06:30 -0400)]
tests: Prefer virGetLastErrorMessage in testSELinuxLabeling

Yet another case of not needing virGetLastError processing