]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agovz: implement managed migration
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:06 +0000 (11:11 +0300)]
vz: implement managed migration

The newest version of migration protocol - version 3 with parameters is implemented.
Supported flags is VIR_MIGRATE_PAUSED only. Supported parameters are
VIR_MIGRATE_PARAM_URI and VIR_MIGRATE_PARAM_DEST_NAME. VIR_MIGRATE_PARAM_DEST_XML
is in VZ_MIGRATION_PARAMETERS for technical onyl reasons.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix const correctness case
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:05 +0000 (11:11 +0300)]
vz: fix const correctness case

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: save session uuid on login
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:04 +0000 (11:11 +0300)]
vz: save session uuid on login

This session uuid acts as authN token for different multihost vz operations one
of which is migration. Unfortunately we can't get it from server at any time
thus we need to save it at login.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovirt-admin: Introduce commands srv-clients-info and srv-clients-set
Erik Skultety [Sat, 9 Apr 2016 16:49:44 +0000 (18:49 +0200)]
virt-admin: Introduce commands srv-clients-info and srv-clients-set

Finally wire-up virAdmServer{Get,Set}ClientLimits APIs into virt-admin client.
Update the virt-admin's man page accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Introduce virAdmServerSetClientLimits
Erik Skultety [Mon, 4 Apr 2016 12:24:52 +0000 (14:24 +0200)]
admin: Introduce virAdmServerSetClientLimits

Opposite operation to virAdmServerGetClientLimits. Understandably though,
setting values for current number of clients connected or still waiting
for authentication does not make sense, since changes to these values are event
dependent, i.e. a client connects - counter is increased. Thus only the limits
to maximum clients connected and waiting for authentication can be set. Should
a request for other controls to be set arrive (provided such a setting will
be first introduced to the config), the set of configuration controls can be
later expanded (thanks to typed params). This patch also introduces a
constraint that the maximum number of clients waiting for authentication has to
be less than the overall maximum number of clients connected and any attempt to
violate this constraint will be denied.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Introduce virAdmServerGetClientLimits
Erik Skultety [Mon, 4 Apr 2016 08:28:22 +0000 (10:28 +0200)]
admin: Introduce virAdmServerGetClientLimits

Enable retrieval of the number of maximum clients connected to all sockets
combined, as well as the number of maximum clients waiting for authentication,
in order to be successfully connected. These are the attributes configurable
through libvirtd.conf, however, it could be handy to not only know values for
these limits, but also the values for the current number of clients
connected and number of clients currently waiting for authentication which are
changing dynamically. This API does both, retrieves the limits as well as the
current dynamic values.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Introduce some public constants related to server's client limits
Erik Skultety [Wed, 11 May 2016 10:05:15 +0000 (12:05 +0200)]
admin: Introduce some public constants related to server's client limits

In order for typed params validation to pass on daemon side, we should
encourage users to use our exported constants with typed params to diminish
to avoid any potential problems related to argument validity.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirnetserver: Introduce server's client-related limits getters
Erik Skultety [Sat, 9 Apr 2016 17:07:11 +0000 (19:07 +0200)]
virnetserver: Introduce server's client-related limits getters

Add some trivial getters for client related attributes to virnetserver before
any admin method can be introduced.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu_cgroup: allow access to /dev/dri for virtio-vga
Ján Tomko [Thu, 19 May 2016 07:29:17 +0000 (09:29 +0200)]
qemu_cgroup: allow access to /dev/dri for virtio-vga

QEMU needs access to the /dev/dri/render* device for
virgl to work.

Allow access to all /dev/dri/* devices for domains with
<video>
  <model type='virtio' heads='1' primary='yes'>
    <acceleration accel3d='yes'/>
  </model>
</video>

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

8 years agoqemu: address: Remove QEMU_CAPS_DEVICE usage
Cole Robinson [Sat, 14 May 2016 20:36:16 +0000 (16:36 -0400)]
qemu: address: Remove QEMU_CAPS_DEVICE usage

All qemu versions we support have QEMU_CAPS_DEVICE, so checking
for it is redundant. Remove the usage.

The code diff isn't clear, but all that code is just inindented
with no other change.

Test cases that hit qemuDomainAssignAddresses but don't have
infrastructure for specifying qemuCaps values see lots of
churn, since now PCI addresses are in the XML output.

8 years agotests: qemuargv2xmltest: Drop disk for s390 aes tests
Cole Robinson [Sat, 14 May 2016 21:28:44 +0000 (17:28 -0400)]
tests: qemuargv2xmltest: Drop disk for s390 aes tests

Upcoming patches are going to make the disk portion of these
test cases fail. In order to make it work, we would need to
extend the qemuargv2xml test infrastructure to handle qemuCaps.
This is worthwhile to do at some point but isn't critical.

Instead just drop the offending portion, which isn't even the
target of the test cases anyways

8 years agoqemu: Call virDomainDefPostParse via CONFIG hotplug
Cole Robinson [Sat, 14 May 2016 19:14:44 +0000 (15:14 -0400)]
qemu: Call virDomainDefPostParse via CONFIG hotplug

hotplug APIs with the AFFECT_CONFIG flag are essentially replicating
'insert <device> into XML document, and redefine XML'. Thinking of
it this way, it's natural that we call virDomainDefPostParse after
manually editing the XML here.

Not only does doing so allow us to drop a bunch of open coded calls
to qemuDomainAssignAddresses, but it also means we are going through
the standard channels for XML validation and potentially catching
errors in user submitted XML.

8 years agoqemu: Assign device addresses in PostParse
Cole Robinson [Sat, 14 May 2016 18:52:45 +0000 (14:52 -0400)]
qemu: Assign device addresses in PostParse

This wires up qemuDomainAssignAddresses into the new
virDomainDefAssignAddressesCallback, so it's always triggered
via virDomainDefPostParse. We are essentially doing this already
with open coded calls sprinkled about.

qemu argv parse output changes slightly since previously it wasn't
hitting qemuDomainAssignAddresses.

8 years agodomain: Add virDomainDefAssignAddressesCallback
Cole Robinson [Sat, 14 May 2016 18:47:23 +0000 (14:47 -0400)]
domain: Add virDomainDefAssignAddressesCallback

This will be called at the end of virDomainDefPostParse to
allow hypervisor drivers to fill in device addresses.

8 years agoRevert "qemu_hotplug: fix checking graphics ports"
Pavel Hrdina [Mon, 16 May 2016 10:59:12 +0000 (12:59 +0200)]
Revert "qemu_hotplug: fix checking graphics ports"

This reverts commit 1ccc7fbff34ea44e5b0cf01a359d127a4c62a695.

We cannot check ports if autoport is set because we set ports to 0 while
parsing device XML.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agovz: drop prlsdkDomainHasSnapshots
Nikolay Shirokovskiy [Mon, 2 May 2016 09:33:08 +0000 (12:33 +0300)]
vz: drop prlsdkDomainHasSnapshots

Let's use introduced domain snapshots infrastructure instead.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: add domain snapshots functionality
Nikolay Shirokovskiy [Mon, 2 May 2016 09:33:07 +0000 (12:33 +0300)]
vz: add domain snapshots functionality

This solution does not keep snapshots cache because vz sdk lacks good support
for snapshot related events.

Libvirt and vz sdk has different approach to snapshot ids. vz sdk always
auto generate them while libvirt has ability to specify id by user.
Thus I have no other choice rather than simply ignore ids set by user
or generated by libvirt.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agoiscsi: Remove initiatoriqn from virISCSIScanTargets
John Ferlan [Fri, 13 May 2016 15:38:45 +0000 (11:38 -0400)]
iscsi: Remove initiatoriqn from virISCSIScanTargets

No longer necessary to have it, so remove it.

8 years agoutil: Remove disabling of autologin for iscsi-targets
Fritz Elfert [Fri, 13 May 2016 15:19:09 +0000 (11:19 -0400)]
util: Remove disabling of autologin for iscsi-targets

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

Instead of disabling auto-login of all scsi targets (even those
that do not "belong" to libvirt), use iscsiadm's "--op nonpersistent"
during discovery of iSCSI targets (e.g. "iscsiadm --mode discovery
--type sendtargets") in order to avoid the node database being altered
which led to the need for the "large hammer" approach taken by
commit id '3c12b654'.

This commit removes the virISCSITargetAutologin adjustment (eg. the setting
of node.startup to "manual"). The iscsiadm command has supported this mode
of operation as of commit id 'ad873767' to open-iscsi.

8 years agoiscsi: Add exit status checking for virISCSIGetSession
John Ferlan [Fri, 13 May 2016 17:25:30 +0000 (13:25 -0400)]
iscsi: Add exit status checking for virISCSIGetSession

Utilize the exit status parameter for virCommandRunRegex in order to
check the return error from the 'iscsiadm --mode session' command.
Without this enabled, if there are no sessions running then virCommandRun
would have displayed an error such as:

    2016-05-13 15:17:15.165+0000: 10920: error : virCommandWait:2553 :
               internal error: Child process (iscsiadm --mode session)
               unexpected exit status 21: iscsiadm: No active sessions.

It is possible that for certain paths (when probe is true) we only care
whether it's running or not to make certain decisions.  Spitting out
the error for those paths is unnecessary.

If we do have a situation where probe = false and there's an error,
then display the error from iscsiadm if it's there.

8 years agoutil: Add exitstatus parameter to virCommandRunRegex
John Ferlan [Fri, 13 May 2016 16:36:39 +0000 (12:36 -0400)]
util: Add exitstatus parameter to virCommandRunRegex

Rather than have virCommandRun just spit out the error, allow callers
to decide to pass the exitstatus so the caller can make intelligent
decisions based on the error.

8 years agotests: Try different usable GIC versions
Andrea Bolognani [Tue, 10 May 2016 10:36:10 +0000 (12:36 +0200)]
tests: Try different usable GIC versions

The only case where the hardware capabilities influence the result
is when no <gic/> element was provided.

The test programs now ensure both that the correct GIC version is
picked in that case, and that hardware capabilities are not taken
into account when the user has already picked a GIC version.

8 years agotests: Prepare to have different usable GIC versions
Andrea Bolognani [Tue, 10 May 2016 09:35:43 +0000 (11:35 +0200)]
tests: Prepare to have different usable GIC versions

Now that we choose the GIC version based on hardware features when
no <gic/> element has been provided, we need a way to fake the GIC
capabilities of the host.

Update the qemuxml2argv and qemuxml2xml tests to allow this.

8 years agoqemu: Add virQEMUCapsSetGICCapabilities()
Andrea Bolognani [Tue, 10 May 2016 08:50:34 +0000 (10:50 +0200)]
qemu: Add virQEMUCapsSetGICCapabilities()

For use in the test suite.

8 years agoqemu: Automatically choose usable GIC version
Andrea Bolognani [Mon, 9 May 2016 13:38:55 +0000 (15:38 +0200)]
qemu: Automatically choose usable GIC version

When the <gic/> element in not present in the domain XML, use the
domain capabilities to figure out what GIC version is usable and
choose that one automatically.

This allows guests to be created on hardware that only supports
GIC v3 without having to update virt-manager and similar tools.

Keep using the default GIC version if the <gic/> element has been
added to the domain XML but no version has been specified, as not
to break existing guests.

8 years agoqemu: Add virQEMUCapsSupportsGICVersion()
Andrea Bolognani [Mon, 16 May 2016 11:23:01 +0000 (13:23 +0200)]
qemu: Add virQEMUCapsSupportsGICVersion()

This utility function extracts some of the logic from
virQEMUCapsFillDomainFeatureGICCaps() so that it can be used
in a different context.

8 years agoChange return value of VIR_APPEND*INPLACE* to void
Jiri Denemark [Tue, 17 May 2016 10:59:43 +0000 (12:59 +0200)]
Change return value of VIR_APPEND*INPLACE* to void

The INPLACE variants of the VIR_APPEND macros cannot fail and they are
inherently quiet.

8 years agoRemove virDomainRNGInsert
Jiri Denemark [Tue, 17 May 2016 11:08:34 +0000 (13:08 +0200)]
Remove virDomainRNGInsert

It was just a useless wrapper around VIR_APPEND_ELEMENT*.

8 years agoxlconfigtest: add test case for type=vif in xl format
Chunyan Liu [Tue, 17 May 2016 09:34:46 +0000 (17:34 +0800)]
xlconfigtest: add test case for type=vif in xl format

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agoxenFormatNet: correct `type=netfront' to 'type=vif' to match libxl
Chunyan Liu [Tue, 17 May 2016 09:34:45 +0000 (17:34 +0800)]
xenFormatNet: correct `type=netfront' to 'type=vif' to match libxl

According to current xl.cfg docs and xl codes, it uses type=vif
instead of type=netfront.

Currently after domxml-to-native, libvirt xml model=netfront will be
converted to xl type=netfront. This has no problem before, xen codes
for a long time just check type=ioemu, if not, set type to _VIF.

Since libxl uses parse_nic_config to avoid duplicate codes, it
compares 'type=vif' and 'type=ioemu' for valid parameters, others
are considered as invalid, thus we have problem with type=netfront
in xl config file.
 #xl create sles12gm-hvm.orig
 Parsing config from sles12gm-hvm.orig
 Invalid parameter `type'.

Correct the conversion in libvirt, so that it matchs libxl codes
and also xl.cfg.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agoextract XEN_CONFIG_FORMAT_XM/XL to xen_common.h
Chunyan Liu [Tue, 17 May 2016 09:34:44 +0000 (17:34 +0800)]
extract XEN_CONFIG_FORMAT_XM/XL to xen_common.h

Unify XEN_CONFIG_FORMAT_x and LIBXL_CONFIG_FORMAT_x to
XEN_CONFIG_FORMAT_x, and move to xen_common.h.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
8 years agobhyve: implement virConnectIsSecure
Fabian Freyer [Tue, 17 May 2016 12:49:21 +0000 (14:49 +0200)]
bhyve: implement virConnectIsSecure

Trivially return 1, since bhyve is considered a local connection that
should not be vulnerable to eavesdropping.

8 years agobhyve: Implement virConnectIsEncrypted
Fabian Freyer [Tue, 17 May 2016 12:49:20 +0000 (14:49 +0200)]
bhyve: Implement virConnectIsEncrypted

Being a local connection, bhyve does not support encryption. Therefore
trivially return 0.

8 years agospec: Remove %defattr usage
Cole Robinson [Sun, 15 May 2016 21:31:42 +0000 (17:31 -0400)]
spec: Remove %defattr usage

It was only needed for rpm versions that are much older than our
minimally supported distro

Some more details here: https://fedorahosted.org/fpc/ticket/77

8 years agoRevert "vz: handle sourceless cdroms"
Maxim Nestratov [Tue, 17 May 2016 12:11:35 +0000 (15:11 +0300)]
Revert "vz: handle sourceless cdroms"

This reverts commit 071fe092.
It was committed by a mistake and correct patch was committed
earlier as baad90fb.

8 years agoqemu: hotplug: Report error if we hit tray status timeout
Cole Robinson [Mon, 2 May 2016 23:07:34 +0000 (19:07 -0400)]
qemu: hotplug: Report error if we hit tray status timeout

If we exceed the timeout waiting for the tray status to change,
we don't report an error. Fix it

8 years agodocs: formatdomain: document virtio-mmio device addresses
Cole Robinson [Sun, 15 May 2016 21:58:19 +0000 (17:58 -0400)]
docs: formatdomain: document virtio-mmio device addresses

8 years agoadmin: include: Rename argument dmn to conn in virAdmConnectListServers
Erik Skultety [Tue, 17 May 2016 10:39:02 +0000 (12:39 +0200)]
admin: include: Rename argument dmn to conn in virAdmConnectListServers

This is just a trivial cosmetic change, throughout all the APIs the argument
is called conn as from 'connection', having 'dmn' at just this single place
might look odd, so better change it now when the interface is still explicitly
disabled and we still have the ability to alter the signatures and public
names before officially enabling it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovz: make error path code idiomatic
Nikolay Shirokovskiy [Fri, 8 Apr 2016 07:41:36 +0000 (10:41 +0300)]
vz: make error path code idiomatic

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix template ct creation
Mikhail Feoktistov [Fri, 8 Apr 2016 07:41:35 +0000 (10:41 +0300)]
vz: fix template ct creation

First we don't need to add disk in this case. Second flag should
be skipped.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix error message for readonly fs
Nikolay Shirokovskiy [Fri, 8 Apr 2016 07:41:34 +0000 (10:41 +0300)]
vz: fix error message for readonly fs

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: handle sourceless cdroms
Mikhail Feoktistov [Fri, 8 Apr 2016 07:41:33 +0000 (10:41 +0300)]
vz: handle sourceless cdroms

SDK handles empty cdroms all right. We just need to
pass "" instead of NULL (not setting is good too).

However we can get problems here. Disk detaching treats source
as ids. Fortunately disk detaching is not supported for cdroms
yet and for hard disks we can not get empty source - this is prohibitited
by xml parsing code.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix vzCheckUnsupportedDisks format checks for cdroms
Nikolay Shirokovskiy [Fri, 8 Apr 2016 07:41:32 +0000 (10:41 +0300)]
vz: fix vzCheckUnsupportedDisks format checks for cdroms

Current version of the function does not check format of cdroms at all.
At the same time prlsdkGetDiskInfo give hints that cdroms always
have format VIR_STORAGE_FILE_RAW. So fix vzCheckUnsupportedDisks.

About structure of checks. As we don't have means to store format
in SDK we always have only one format in every situation. So instead
of setting boolean let's get allowed format instead and finally compare
it to the requested. This structure of checks seems stable to me
because we have only one format in every situation.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: remove check for auto file format for disks
Nikolay Shirokovskiy [Fri, 8 Apr 2016 07:41:31 +0000 (10:41 +0300)]
vz: remove check for auto file format for disks

VIR_STORAGE_FILE_AUTO can not be set from xml description.
At the same time we don't set disks format to this value
as for example qemu does. Thus this we can never get this
value in format.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agodomain_conf: cleanup virDomainGraphicsListenDefParseXML
Pavel Hrdina [Mon, 2 May 2016 12:49:38 +0000 (14:49 +0200)]
domain_conf: cleanup virDomainGraphicsListenDefParseXML

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agographics: make address attribute for listen type='address' optional
Pavel Hrdina [Mon, 9 May 2016 13:50:54 +0000 (15:50 +0200)]
graphics: make address attribute for listen type='address' optional

We support omitting listen attribute of graphics element so we should
also support omitting address attribute of listen element.  This patch
also updates libvirt to always add a listen element into domain XML
except for VNC graphics if socket attribute is specified.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agodomain_conf: parse listen attribute while parsing listen elements
Pavel Hrdina [Fri, 6 May 2016 12:54:59 +0000 (14:54 +0200)]
domain_conf: parse listen attribute while parsing listen elements

Move the compatibility code out of virDomainGraphicsListensParseXML()
into virDomainGraphicsListenDefParseXML().  This also fixes a small
inconsistency between the code and error message itself.

Before this patch we would search first listen element that is
type='address' to validate listen and address attributes. After this
patch we always take the first listen element regardless of the type.

This shouldn't break anything since all drivers supports only one
listen.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agographics: don't parse listens if socket attribute is present
Pavel Hrdina [Fri, 29 Apr 2016 10:19:03 +0000 (12:19 +0200)]
graphics: don't parse listens if socket attribute is present

If socket attribute is present we start VNC that listens only on that
unix socket.  This makes the parser behave the same way as we actually
use the socket attribute.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: Allow all volume modes for disk type='lun' sources
Peter Krempa [Wed, 11 May 2016 08:25:24 +0000 (10:25 +0200)]
conf: Allow all volume modes for disk type='lun' sources

Commit 82ba41108acd0f3f made possible to use direct mapped iSCSI
volumes in qemu as disk sources but didn't remove the define time check.

Rework the check by simplifying the condition and allow any volumes to
be used with disk type='lun'.

8 years agoqemu: Drop QEMU_CAPS_VIRTIO_BLK_SG_IO
Andrea Bolognani [Mon, 16 May 2016 08:29:57 +0000 (10:29 +0200)]
qemu: Drop QEMU_CAPS_VIRTIO_BLK_SG_IO

The only QEMU versions that don't have such capability are <0.11,
which we no longer support anyway

8 years agoqemu: Drop QEMU_CAPS_CPU_HOST
Andrea Bolognani [Mon, 16 May 2016 08:08:29 +0000 (10:08 +0200)]
qemu: Drop QEMU_CAPS_CPU_HOST

The only QEMU versions that don't have such capability are <0.11,
which we no longer support anyway

8 years agoqemu: Drop QEMU_CAPS_PCI_ROMBAR
Andrea Bolognani [Mon, 16 May 2016 07:51:42 +0000 (09:51 +0200)]
qemu: Drop QEMU_CAPS_PCI_ROMBAR

The only QEMU versions that don't have such capability are <0.12,
which we no longer support anyway.

Additionally, this solves the issue of some QEMU binaries being
reported as not having such capability just because they lacked
the {kvm-}pci-assign QMP object.

8 years agolibxl: Free migration cookie
John Ferlan [Mon, 16 May 2016 12:20:46 +0000 (08:20 -0400)]
libxl: Free migration cookie

Commit id 'f9edcfa4' added cookie manipulation for libxl; however, some
cookie crumb cleanup was missed. Found by Coverity.

In libxlDomainMigrationBegin, the cookie is allocated and baked; however,
the mig ingredients weren't cleaned up.

In libxlDomainMigrationPrepare, when the 'mig' cookie is added to the
args, set the 'mig = NULL'; otherwise, other failure paths between when
the code ate the cookie data and when it was added to args would fail
to clean up the crumbs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: More qemu_monitor_json cleanups
John Ferlan [Mon, 16 May 2016 11:47:26 +0000 (07:47 -0400)]
qemu:  More qemu_monitor_json cleanups

Recent adjustments to the code produced a litany of coverity false
positives, but only because the "standard" procedure of setting a
variable to NULL after it was assigned to something else and keeping
the *Free/*FREE call in the cleanup path wasn't kept. So this patch
makes those adjustments (assign variable to NULL and remove the if
'ret < 0' condition to clean it up).

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agobhyve: implement virConnectIsAlive
Fabian Freyer [Fri, 13 May 2016 19:22:57 +0000 (21:22 +0200)]
bhyve: implement virConnectIsAlive

bhyve connections are local, and a "connection will be classed as alive
if it is [...] local".

8 years agoqemu: command: Use -name guest= if available
Cole Robinson [Fri, 22 Apr 2016 22:39:09 +0000 (18:39 -0400)]
qemu: command: Use -name guest= if available

-name guest= is the explicit parameter for passing a VM name. Using
it is required to allow a VM with an '=' in the name

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

8 years agoqemu: command: escape commas in chardev socket path
Cole Robinson [Fri, 22 Apr 2016 22:27:44 +0000 (18:27 -0400)]
qemu: command: escape commas in chardev socket path

After this, a default virt-manager VM will startup with a comma
in the VM name:

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

8 years agoqemu: command: escape commas in VNC socket path
Cole Robinson [Sun, 8 May 2016 18:33:50 +0000 (14:33 -0400)]
qemu: command: escape commas in VNC socket path

This path can be dependent on the VM libdir, which contains its name

8 years agoqemu: command: escape commas in secret master path
Cole Robinson [Fri, 22 Apr 2016 22:22:05 +0000 (18:22 -0400)]
qemu: command: escape commas in secret master path

Need to convert the local function to virBuffer usage, so we
can use qemuBufferEscapeComma

8 years agoqemu: command: escape commas in VM name
Cole Robinson [Fri, 22 Apr 2016 14:40:57 +0000 (10:40 -0400)]
qemu: command: escape commas in VM name

This isn't sufficient on its own, since the VM name is used for things
like monitor paths, which we don't escape yet

8 years agoqemu: command: Add qemuBufferEscapeComma
Cole Robinson [Sun, 8 May 2016 18:22:13 +0000 (14:22 -0400)]
qemu: command: Add qemuBufferEscapeComma

Centralize the magic invocation for escaping commas on the qemu
command line, and document it a bit

8 years agoqemu: alias: Remove QEMU_CAPS_DEVICE
Cole Robinson [Sun, 15 May 2016 21:24:54 +0000 (17:24 -0400)]
qemu: alias: Remove QEMU_CAPS_DEVICE

QEMU_CAPS_DEVICE is always set nowadays, so drop code that depends
on not-DEVICE

8 years agoadmin: Fix passing an incorrect readonly attribute to virNetServerServiceNew
Erik Skultety [Sat, 14 May 2016 17:10:39 +0000 (19:10 +0200)]
admin: Fix passing an incorrect readonly attribute to virNetServerServiceNew

When registering admin UNIX socket, a new service is created for it. This
service is incorrectly initialized to be readonly, which is later inherited by
all clients connected to the socket. In libvirt-admin's case there currently
isn't any use for the attribute anyway, but since the socket has root-only
access permissions, the least we can do is to make every admin client
connected to it report readonly as false.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agocpu: Properly report errors when parsing CPU map XML
Jiri Denemark [Fri, 13 May 2016 16:27:09 +0000 (18:27 +0200)]
cpu: Properly report errors when parsing CPU map XML

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Check vendor early
Jiri Denemark [Thu, 12 May 2016 14:02:09 +0000 (16:02 +0200)]
cpu_x86: Check vendor early

When searching for the best CPU model for CPUID data we can easily
ignore models with non-matching vendor before spending time on CPUID
data to virCPUDef conversion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Don't ignore parsing errors in x86ModelLoad
Jiri Denemark [Thu, 12 May 2016 13:34:27 +0000 (15:34 +0200)]
cpu_x86: Don't ignore parsing errors in x86ModelLoad

CPU map XML is our internal data file, it makes no sense to tolerate any
errors in it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Don't ignore parsing errors in x86FeatureLoad
Jiri Denemark [Thu, 12 May 2016 13:30:45 +0000 (15:30 +0200)]
cpu_x86: Don't ignore parsing errors in x86FeatureLoad

CPU map XML is our internal data file, it makes no sense to tolerate any
errors in it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Don't ignore parsing errors in x86VendorLoad
Jiri Denemark [Thu, 12 May 2016 13:29:49 +0000 (15:29 +0200)]
cpu_x86: Don't ignore parsing errors in x86VendorLoad

CPU map XML is our internal data file, it makes no sense to tolerate any
errors in it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Simplify insertions into a linked list
Jiri Denemark [Thu, 12 May 2016 13:18:26 +0000 (15:18 +0200)]
cpu_x86: Simplify insertions into a linked list

The next pointer is initialized to NULL, overwriting to with another
NULL doesn't hurt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Remove comparisons to NULL
Jiri Denemark [Thu, 12 May 2016 13:06:25 +0000 (15:06 +0200)]
cpu_x86: Remove comparisons to NULL

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Use for loop in x86Decode
Jiri Denemark [Thu, 12 May 2016 12:53:31 +0000 (14:53 +0200)]
cpu_x86: Use for loop in x86Decode

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename cleanup labels
Jiri Denemark [Thu, 12 May 2016 12:52:26 +0000 (14:52 +0200)]
cpu_x86: Rename cleanup labels

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Compare CPU candidates in a separate function
Jiri Denemark [Thu, 12 May 2016 12:50:17 +0000 (14:50 +0200)]
cpu_x86: Compare CPU candidates in a separate function

Splitting the comparison into a separate function makes the code cleaner
and easier to update in the future.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename struct virCPUx86DataIterator
Jiri Denemark [Wed, 11 May 2016 10:39:15 +0000 (12:39 +0200)]
cpu_x86: Rename struct virCPUx86DataIterator

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename enum compare_result
Jiri Denemark [Wed, 11 May 2016 10:36:43 +0000 (12:36 +0200)]
cpu_x86: Rename enum compare_result

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename struct x86_map
Jiri Denemark [Wed, 11 May 2016 10:30:04 +0000 (12:30 +0200)]
cpu_x86: Rename struct x86_map

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename struct x86_model
Jiri Denemark [Wed, 11 May 2016 10:03:48 +0000 (12:03 +0200)]
cpu_x86: Rename struct x86_model

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename struct x86_kvm_feature
Jiri Denemark [Wed, 11 May 2016 09:59:29 +0000 (11:59 +0200)]
cpu_x86: Rename struct x86_kvm_feature

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename struct x86_feature
Jiri Denemark [Wed, 11 May 2016 09:56:14 +0000 (11:56 +0200)]
cpu_x86: Rename struct x86_feature

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Rename struct x86_vendor
Jiri Denemark [Wed, 11 May 2016 08:47:21 +0000 (10:47 +0200)]
cpu_x86: Rename struct x86_vendor

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: command: Ignore QEMU_CAPS_DEVICE when building drive alias
Cole Robinson [Sun, 15 May 2016 20:33:27 +0000 (16:33 -0400)]
qemu: command: Ignore QEMU_CAPS_DEVICE when building drive alias

QEMU_CAPS_DEVICE is always set nowadays, so we can drop the
non-DEVICE code paths

8 years agocpuGetModels: Fix memory leak on error
Jiri Denemark [Fri, 29 Apr 2016 08:43:31 +0000 (10:43 +0200)]
cpuGetModels: Fix memory leak on error

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Add support for clflushopt and tsc_adjust Intel features
Alexander Burluka [Sat, 14 May 2016 10:06:56 +0000 (13:06 +0300)]
cpu: Add support for clflushopt and tsc_adjust Intel features

Corresponding QEMU commits:
    clflushopt f7fda280948a5e74aeb076ef346b991ecb173c56
    tsc_adjust 7b458bfd12a71b3da6b531daedc417492c9334e0

Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
8 years agosecret: Alter virSecretGetSecretString
John Ferlan [Thu, 12 May 2016 15:43:39 +0000 (11:43 -0400)]
secret: Alter virSecretGetSecretString

Rather than returning a "char *" indicating perhaps some sized set of
characters that is NUL terminated, alter the function to return 0 or -1
for success/failure and add two parameters to handle returning the
buffer and it's size.

The function no longer encodes the returned secret, rather it returns
the unencoded secret forcing callers to make the necessary adjustments.

Alter the callers to handle the adjusted model.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: domain: Fix names for functions that clear security info
Peter Krempa [Fri, 13 May 2016 14:46:47 +0000 (16:46 +0200)]
qemu: domain: Fix names for functions that clear security info

They don't free the structure itself so they should be called *Clear
rather than *Free.

8 years agoutil: string: Introduce helper to determine whether a byte buffer is printable
John Ferlan [Thu, 12 May 2016 15:43:39 +0000 (11:43 -0400)]
util: string: Introduce helper to determine whether a byte buffer is printable

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: string: Introduce virStringEncodeBase64
Peter Krempa [Fri, 13 May 2016 11:15:15 +0000 (13:15 +0200)]
util: string: Introduce virStringEncodeBase64

Add a new helper that sanitizes error semantics of base64_encode_alloc.

8 years agosecret: util: Refactor virSecretGetSecretString
Peter Krempa [Fri, 13 May 2016 11:32:48 +0000 (13:32 +0200)]
secret: util: Refactor virSecretGetSecretString

Call the internal driver callbacks rather than the public APIs to avoid
calling unnecessarily the error dispatching code and don't overwrite
the error messages provided by the APIs. They are good enough to
describe which secret is missing either by UUID or the usage (basically
name).

8 years agoutil: alloc: Introduce freeing helpers that clear the memory before freeing
Peter Krempa [Fri, 13 May 2016 12:59:01 +0000 (14:59 +0200)]
util: alloc: Introduce freeing helpers that clear the memory before freeing

For a few cases where we handle secret information it's good to clear
the buffers containing sensitive data before freeing them.

Introduce VIR_DISPOSE, VIR_DISPOSE_N and VIR_DISPOSE_STRING that allow
simple clearing fo the buffers holding sensitive information on cleanup
paths.

8 years agocapabilities: Advertise cpuselection if -cpu host is usable
Jiri Denemark [Wed, 13 Apr 2016 07:06:23 +0000 (09:06 +0200)]
capabilities: Advertise cpuselection if -cpu host is usable

When -cpu host is supported by a QEMU binary, a user can use
<cpu mode='host-passthrough'/> in domain XML even when libvirtd failed
to find a matching model for the host CPU. Let's make it obvious by
advertising <cpuselection/> guest capability whenever -cpu host is
supported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuaincapstest: Give better names to test data files
Jiri Denemark [Tue, 10 May 2016 18:39:11 +0000 (20:39 +0200)]
qemuaincapstest: Give better names to test data files

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodomaincapstest: Give better names to test data files
Jiri Denemark [Tue, 10 May 2016 18:29:17 +0000 (20:29 +0200)]
domaincapstest: Give better names to test data files

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodomaincapstest: Use arch strings
Jiri Denemark [Tue, 10 May 2016 17:59:48 +0000 (19:59 +0200)]
domaincapstest: Use arch strings

They are shorter and most of the code requires the strings anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotests: Introduce check-file-access.pl
Michal Privoznik [Mon, 18 Apr 2016 14:15:35 +0000 (16:15 +0200)]
tests: Introduce check-file-access.pl

This script will check output generated by virtestmock against a
white list. All non matching records found are printed out. So
far, the white list is rather sparse at the moment.
This test should be ran only after all other tests finished, and
should cleanup the temporary file before their execution. Because
I'm unable to reflect these requirements in Makefile.am
correctly, I've introduced new target 'check-access' under which
this test is available.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirtestmock: Print invalid file accesses into a file
Michal Privoznik [Mon, 18 Apr 2016 12:10:33 +0000 (14:10 +0200)]
virtestmock: Print invalid file accesses into a file

All the accesses to files outside our build or source directories
are now identified and appended into a file for later processing.
The location of the file that contains all the records can be
controlled via VIR_TEST_FILE_ACCESS env variable and defaults to
abs_builddir "/test_file_access.txt".

The script that will process the access file is to be added in
next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotests: Introduce global mock library
Michal Privoznik [Fri, 13 May 2016 12:08:29 +0000 (14:08 +0200)]
tests: Introduce global mock library

The intent is that this library is going to be called every time
to check if we are not touching anything outside srcdir or
builddir.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirmock.h: Introduce VIR_MOCK_CALL_STAT
Michal Privoznik [Fri, 13 May 2016 11:42:13 +0000 (13:42 +0200)]
virmock.h: Introduce VIR_MOCK_CALL_STAT

There is some magic going on when it comes to stat() or lstat().
Basically, stat() can either be a regular function, an inline
function that calls __xstat(_STAT_VER, ...) or a macro that does
the same as the inline func. Don't ask why is that, just read the
documentation in sys/stat.h and make sure you have a bucket next
to you. Anyway, currently there will not be both stat and __xstat
symbols at the same time, as one of them gets overwritten to the
other one during compilation. But this is not true anymore once
we start chaining our mocking libraries. Therefore we need a
wrapper that calls desired function from glibc.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agosecurityselinuxhelper: Adapt to virmock.h
Michal Privoznik [Fri, 13 May 2016 10:46:35 +0000 (12:46 +0200)]
securityselinuxhelper: Adapt to virmock.h

Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonssmock: Adapt to virmock.h
Michal Privoznik [Fri, 13 May 2016 10:46:35 +0000 (12:46 +0200)]
nssmock: Adapt to virmock.h

Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovircgroupmock: Adapt to virmock.h
Michal Privoznik [Fri, 13 May 2016 10:46:35 +0000 (12:46 +0200)]
vircgroupmock: Adapt to virmock.h

Instead of introducing our own wrapper for dlsym()
we can use the one provided by virmock.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>