]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: expand domain memory statistics with 'last-update' timestamp
Derbyshev Dmitry [Wed, 1 Jun 2016 17:07:07 +0000 (20:07 +0300)]
qemu: expand domain memory statistics with 'last-update' timestamp

QEMU reports timestamp along with other memory statistics, but this information is not saved into domain statistics.
It could be useful to determine if the data reported is fresh or not.
Balloon statistics are not reported in hrf, so no modifications are made in qemu_monitor_text.c.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
8 years agoqemu: expand domain memory statistics with 'usable'
Derbyshev Dmitry [Wed, 1 Jun 2016 17:07:06 +0000 (20:07 +0300)]
qemu: expand domain memory statistics with 'usable'

'memtotal' in virtio drivers and qemu corresponds to 'available' in libvirt.
Because of that, 'stat-available-memory' is renamed into 'usable'.
Balloon statistics are not reported in hrf, so no modifications are made in qemu_monitor_text.c.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
8 years agoqemu: remove ccwaddrs caching
Tomasz Flendrich [Sat, 23 Jul 2016 01:47:11 +0000 (03:47 +0200)]
qemu: remove ccwaddrs caching

Dropping the caching of ccw address set.
The cached set is not required anymore, because the set is now being
recalculated from the domain definition on demand, so the cache
can be deleted.

8 years agoqemu_hotplug: generate ccw address list on demand
Tomasz Flendrich [Sat, 23 Jul 2016 01:47:10 +0000 (03:47 +0200)]
qemu_hotplug: generate ccw address list on demand

Dropping the caching of ccw address set.
Instead of using the cached address set, functions in qemu_hotplug.c
now recalculate it on demand.

8 years agoAdd qemuDomainCCWAddrSetCreateFromDomain
Tomasz Flendrich [Sat, 23 Jul 2016 01:47:09 +0000 (03:47 +0200)]
Add qemuDomainCCWAddrSetCreateFromDomain

The address sets (pci, ccw, virtio serial) are currently cached
in qemu private data, but all the information required to recreate
these sets is in the domain definition. Therefore I am removing
the redundant data and adding a way to recalculate these sets.

Add a function that calculates the ccw address set
from the domain definition.

8 years agoqemu: remove vioserialaddrs caching
Tomasz Flendrich [Sat, 23 Jul 2016 01:47:08 +0000 (03:47 +0200)]
qemu: remove vioserialaddrs caching

Dropping the caching of virtio serial address set.
The cached set is not required anymore, because the set is now being
recalculated from the domain definition on demand, so the cache
can be deleted.

Credit goes to Cole Robinson.

8 years agoqemu_hotplug: generate vioserial address list on demand
Tomasz Flendrich [Sat, 23 Jul 2016 01:47:07 +0000 (03:47 +0200)]
qemu_hotplug: generate vioserial address list on demand

Dropping the caching of virtio serial address set.
Instead of using the cached address set, a function in qemu_hotplug.c
now recalculates it on demand.

Credit goes to Cole Robinson.

8 years agoadd virDomainVirtioSerialAddrSetCreateFromDomain
Tomasz Flendrich [Sat, 23 Jul 2016 01:47:06 +0000 (03:47 +0200)]
add virDomainVirtioSerialAddrSetCreateFromDomain

The address sets (pci, ccw, virtio serial) are currently cached
in qemu private data, but all the information required to recreate
these sets is in the domain definition. Therefore I am removing
the redundant data and adding a way to recalculate these sets.

Add a function that calculates the virtio serial address set
from the domain definition.

Credit goes to Cole Robinson.

8 years agocgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape
Ján Tomko [Tue, 14 Jun 2016 06:02:30 +0000 (08:02 +0200)]
cgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape

Use virAsprintf to prepend an underscore to make the code more
readable.

8 years agoutil: systemd: Define MSG_NOSIGNAL if needed
Andrea Bolognani [Wed, 20 Jul 2016 13:46:56 +0000 (15:46 +0200)]
util: systemd: Define MSG_NOSIGNAL if needed

The symbol being missing has been reported as causing build
failures on OS X. If it's not already defined, define it to
zero so that it won't have any effect.

8 years agoqemu_monitor: search memballoon QOM device path using alias
Pavel Hrdina [Mon, 25 Jul 2016 15:07:38 +0000 (17:07 +0200)]
qemu_monitor: search memballoon QOM device path using alias

Commit 4a585a88 introduced searching QOM device path by alias, let's use it for
memballoon too.  This may speedup the search because in most cases we will find
the correct QOM device path directly by using alias without the need for the
recursion code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_monitor_json: add support to search QOM device path by device alias
Pavel Hrdina [Mon, 25 Jul 2016 08:47:00 +0000 (10:47 +0200)]
qemu_monitor_json: add support to search QOM device path by device alias

Commit ce745914 introduced detection of actual video ram sizes to fix migration
if QEMU decide to modify the values provided by libvirt.  This works perfectly
for domains with number of video devices up to two.

If there are more than two video devices in the guest all the secondary devices
in the XML will have the same memory values.  This is because our current code
search for QOM device path only by the device type name and all the secondary
video devices has the same name "qxl".

This patch introduces a new search function that will try to search a QOM device
path using also device's alias if the alias is available. After that it will
fallback to the old recursive code if the alias search found no results.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoSplit qemuDomainDetachDeviceFlags in two
Tomasz Flendrich [Sat, 16 Jul 2016 00:42:50 +0000 (02:42 +0200)]
Split qemuDomainDetachDeviceFlags in two

Previously, qemuDomainDetachDeviceFlags was doing two things:
handling the job and detaching devices. Now the second part is
in a new function.

8 years agoNarrow down a parameter in qemuDomainDetachDeviceFlags
Tomasz Flendrich [Sat, 16 Jul 2016 00:42:49 +0000 (02:42 +0200)]
Narrow down a parameter in qemuDomainDetachDeviceFlags

This will make splitting up qemuDomainDetachDeviceFlags into two
functions easier.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoSplit qemuDomainAttachDeviceFlags in two
Tomasz Flendrich [Sat, 16 Jul 2016 00:42:48 +0000 (02:42 +0200)]
Split qemuDomainAttachDeviceFlags in two

Previously, qemuDomainAttachDeviceFlags was doing two things:
handling the job and attaching devices. Now the second part is
in a new function.

This change is required to make it possible to test more complex
device attachment situations, like attaching a device to both
config and live at once.

8 years agoqemu: Remove an unnecessary variables
Tomasz Flendrich [Sat, 16 Jul 2016 00:42:47 +0000 (02:42 +0200)]
qemu: Remove an unnecessary variables

qemuCaps is no longer used anywhere in these functions,
so it can be deleted.

8 years agoChange parameters to qemuDomainAttachDeviceLive
Tomasz Flendrich [Sat, 16 Jul 2016 00:42:46 +0000 (02:42 +0200)]
Change parameters to qemuDomainAttachDeviceLive

We want to be able to pass a NULL instead of the connection
and use this function in tests. To achieve this, the virConnectPtr
is passed instead of virDomainPtr, and the driver is a new separate
parameter.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemuhotplugtest: Add tests for ccw devices
Tomasz Flendrich [Fri, 22 Jul 2016 18:10:47 +0000 (20:10 +0200)]
qemuhotplugtest: Add tests for ccw devices

There's a plan to rework the address handling, so testcases
that verify hotplugging ccw devices will help in avoiding
regression.

In this commit, some files are duplicated because of the way
qemuhotplug.c calculates the expected xml filenames.
I plan on changing that to explicitly stating the basis domain
xml, the device xml, and the expected xml.

8 years agolxc: Don't crash by forgetting to ref transient domains
Martin Kletzander [Wed, 20 Jul 2016 07:23:03 +0000 (09:23 +0200)]
lxc: Don't crash by forgetting to ref transient domains

So commit 306b3a8504 tried mimicking behaviour of commit 540c339a25, but
added a virObjectRef(vm) only after virDomainObjListAdd() in
lxcDomainDefineXMLFlags() and not in lxcDomainCreateXMLWithFiles().
That way undefining a domain that was started with different XML than
defined will leave the domain object in a state with not enough
references to then remove it.  Hence any lxcDomainDestroyFlags() called
afterwards crashes the daemon.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirt-aa-helper: Make help output match option name
Guido Günther [Fri, 22 Jul 2016 10:09:09 +0000 (12:09 +0200)]
virt-aa-helper: Make help output match option name

8 years agoqemu: hotplug: fix changeable media ejection
Bjoern Walk [Fri, 8 Jul 2016 10:30:26 +0000 (12:30 +0200)]
qemu: hotplug: fix changeable media ejection

Since return code is checked globally at the end of the function, let's
make sure that we set it correctly at any point.

This fixes a regression introduced in commit 0aa19f35 where the first
command to eject changeable media would fail unconditionally.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agolxc: make container's init process session leader
Katerina Koukiou [Thu, 21 Jul 2016 15:37:24 +0000 (15:37 +0000)]
lxc: make container's init process session leader

This patch forces container's init process, to become a session leader,
that is its session ID is made the same as its process ID.
That might seem unnecessary in general, but if we want to checkpoint a
container with CRIU, which is needed for container migration,
we must ensure that the SID of each process inside the container points
to a process that lives in the same PID namespace as the container.
Therefore, we force that the session leader is the init.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
8 years agoAuto-add one hub if there are too many USB devices
Ján Tomko [Fri, 17 Jun 2016 07:49:54 +0000 (09:49 +0200)]
Auto-add one hub if there are too many USB devices

When parsing a command line with USB devices that have
no address specified, QEMU automatically adds a USB hub
if the device would fill up all the available USB ports.

To help most of the users, add one hub if there are more
USB devices than available ports. For wilder configurations,
expect the user to provide us with more hubs and/or controllers.

8 years agoAssign addresses on USB device hotplug
Ján Tomko [Wed, 12 Aug 2015 14:52:19 +0000 (16:52 +0200)]
Assign addresses on USB device hotplug

USB disks, redirected devices, host devices and serial devices
are supported.

8 years agoAssign addresses to USB devices
Ján Tomko [Wed, 12 Aug 2015 14:52:18 +0000 (16:52 +0200)]
Assign addresses to USB devices

Automatically assign addresses to USB devices.

Just like reserving, this is only done for newly defined domains.

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

8 years agoAdd tests for USB address assignment
Ján Tomko [Mon, 18 Jul 2016 15:16:33 +0000 (17:16 +0200)]
Add tests for USB address assignment

Introduce tests with the ich9, xhci and the default (piix3) usb
controller to demonstrate the effect of the next patch.

8 years agoReserve existing USB addresses
Ján Tomko [Wed, 12 Aug 2015 14:52:17 +0000 (16:52 +0200)]
Reserve existing USB addresses

Check if they fit on the USB controllers the domain has,
and error out if two devices try to use the same address.

8 years agoAdd functions for adding USB hubs to addrs
Ján Tomko [Wed, 27 Apr 2016 13:54:14 +0000 (15:54 +0200)]
Add functions for adding USB hubs to addrs

Walk through all the usb hubs in the domain definition
that have a USB address specified, create the
corresponding structures in the virDomainUSBAddressSet
and mark the port it occupies as used.

8 years agoAdd functions for adding USB controllers to addrs
Ján Tomko [Wed, 12 Aug 2015 14:52:16 +0000 (16:52 +0200)]
Add functions for adding USB controllers to addrs

Walk through all the usb controllers in the domain definition
and create the corresponding structures in the virDomainUSBAddressSet.

8 years agoIntroduce virDomainUSBAddressSet
Ján Tomko [Wed, 12 Aug 2015 14:52:15 +0000 (16:52 +0200)]
Introduce virDomainUSBAddressSet

A new type to track USB addresses.

Every <controller type='usb' index='i'/> is represented by an
object of type virDomainUSBAddressHub located at buses[i].

Each of these hubs has up to 'nports' ports.
If a port is occupied, it has the corresponding bit set in
the 'ports' bitmap, e.g. port 1 would have the 0th bit set.
If there is a hub on this port, then hubs[i] will point
to this hub.

8 years agovz: handle gracefully races on undefining domain
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:34 +0000 (18:00 +0300)]
vz: handle gracefully races on undefining domain

Undefine procedure drops domain lock while waiting for detaching
disks vz sdk call. Meanwhile vz sdk event domain-config-changed
arrives, its handler finds domain and is blocked waiting for job
condition. After undefine API call finishes event processing procedes
and tries to refreshes domain config thru existing vz sdk domain handle.
Domain does not exists anymore and event processing fails. Everything
is fine we just don't want to see error message in log for this
particular case.

Fortunately domain has flag that domain is removed from list. This
also imply that vz sdk domain is also undefined. Thus if we check
for this flag right after domain is locked again on accuiring
job condition we gracefully handle this situation.

Actually the race can happen in other situations too. Any
time we wait for job condition in mutualy exclusive job in
time when we acquire it vz sdk domain can cease to exist.
So instead of general internal error we can return domain
not found which is easier to handle. We don't need to patch
other places in mutually exclusive jobs where domain lock
is dropped as if job is started domain can't be undefine
by mutually exclusive undefine job.

The code of this patch is quite similar to qemu driver checks
for is domain is active after acquiring a job. The difference
only while qemu domain is operational while process is active
vz domain is operational while domain exists.

8 years agovz: make vz driver more responsive
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:33 +0000 (18:00 +0300)]
vz: make vz driver more responsive

Current vz driver implementation is not usable when it comes to
long runnig operations. Migration or saving a domain blocks all
other operations even query ones which are expecteted to be available.
This patch addresses this problem.

All vz driver API calls fall into next 3 groups:
1. only query domain cache (virDomainObj, vz cache statistic)
   examples are vzDomainGetState, vzDomainGetXMLDesc etc.
2. use thread shared sdkdom object
   examples are vzDomainSetMemoryFlags, vzDomainAttachDevice etc.
3. use no thread shared sdkdom object nor domain cache
   examples are vzDomainSnapshotListNames, vzDomainSnapshotGetXMLDesc etc

API calls from group 1 don't need to be changed as they hold domain lock only
for short period of time. These calls [1] are easily distinguished. They query
domain object thru libvirt common code or query vz sdk statistics handle thru
vz sdk sync operations.

vzDomainInterfaceStats is the only exception. It uses sdkdom object to
convert interface name to its vz sdk stack index which could not be saved in
domain cache. Interface statistics is available thru this stack index as a key
rather than name. As a result we can have accidental 'not known interface'
errors on quering intrerface stats. The reason is that in the process of
updating domain configuration we drop all devices and then recreate them again
in sdkdom object and domain lock can be dropped meanwhile (to remove networks
for existing bridged interfaces and(or) (re)create new ones). We can fix this
by changing the way we support bridged interfaces or by reordering operations
and changing bridged networks beforehand. Anyway this is better than moving
this API call into 2 group and making it an exclusive job.

As to API calls from group 2, first thread shared sdkdom object needs to be
explained. vz sdk has only one handle for a given domain, thus threads need
exclusive access to operate on it. These calls are fixed to drop and reacquire
domain lock on any lengthy operations - namely waiting the result of async vz
sdk operation. As lock is dropped we need to take extra reference to domain
object if it is not taken already as domain object can be deleted from list
while lock is dropped. As this operations use thread shared sdkdom object, the
simplest way to make calls from group 2 be consistent to each other is to make
them mutually exclusive. This is done by taking/releasing job condition thru
calling correspondent job routine. This approach makes group 1 and group
2 calls consistent to each other too. Not all calls of group 2 change the
domain cache but those that do update it thru prlsdkUpdateDomain which holds
the lock thoughout the update.

API calls from group [2] are easily distinguished too. They use
beginEdit/commit to change domain configuration (vzDomainSetMemoryFlags) or/and
update domain cache from sdkdom at the end of operation (vzDomainSuspend).

There is a known issue however. Frankly speaking it was introduced by ealier
patch '[PATCH 6/9] vz: cleanup loading domain code' from a different series.
The patch significantly reduced amount of time when the driver lock is held when
creating domain from API call or as a result of domain added event from vz sdk.
The problem is these two paths race on using thread shared sdkdom as we don't
have libvirt domain object and can not lock on it. However this don't
invalidates the patch as we can't use the former approach of preadding domain
into the list as we need name at least and name is not given by event. Anyway
i'm against adding half baked object into the list. Eventually this race can be
fixed by extra measures. As to current situation races with different
configurations are unlikely and race when adding domain thru vz driver and
simultaneous event from vz sdk is not dangerous as configuration is the same.

The last group [3] is API calls that need only sdkdom object to make vz sdk
call and don't change thread shared sdkdom object or domain cache in any way.
For now these are mostly domain snapshot API calls. The changes are similar to
those of group 2 - they add extra reference and drop/reacquire the lock on waiting
vz async call result. One can simply take the immutable sdkdom object from the
cache and drop the lock for the rest of operations but the chosen approach
makes implementation of these API calls somewhat similar to those of from group
2 and thus a bit futureproof. As calls of group 3 don't need vz driver
domain/vz sdk cache in any way, they are consistent with respect to API calls from
groups 1 and 3.

There is another exception. Calls to make-snapshot/revert-to-snapshot/migrate
are moved to group 2. That is they are made mutually exclusive. The reason
is that libvirt API supports control/query only for one job per domain and
these are jobs that are likely to be queried/aborted.

Appendix.

[1] API calls that only query domain cache.
(marked [*] are included for a different reason)

.domainLookupByID = vzDomainLookupByID,    /* 0.10.0 */
.domainLookupByUUID = vzDomainLookupByUUID,        /* 0.10.0 */
.domainLookupByName = vzDomainLookupByName,        /* 0.10.0 */
.domainGetOSType = vzDomainGetOSType,    /* 0.10.0 */
.domainGetInfo = vzDomainGetInfo,  /* 0.10.0 */
.domainGetState = vzDomainGetState,        /* 0.10.0 */
.domainGetXMLDesc = vzDomainGetXMLDesc,    /* 0.10.0 */
.domainIsPersistent = vzDomainIsPersistent,        /* 0.10.0 */
.domainGetAutostart = vzDomainGetAutostart,        /* 0.10.0 */
.domainGetVcpus = vzDomainGetVcpus, /* 1.2.6 */
.domainIsActive = vzDomainIsActive, /* 1.2.10 */
.domainIsUpdated = vzDomainIsUpdated,     /* 1.2.21 */
.domainGetVcpusFlags = vzDomainGetVcpusFlags, /* 1.2.21 */
.domainGetMaxVcpus = vzDomainGetMaxVcpus, /* 1.2.21 */
.domainHasManagedSaveImage = vzDomainHasManagedSaveImage, /* 1.2.13 */
.domainGetMaxMemory = vzDomainGetMaxMemory, /* 1.2.15 */
.domainBlockStats = vzDomainBlockStats, /* 1.2.17 */
.domainBlockStatsFlags = vzDomainBlockStatsFlags, /* 1.2.17 */
.domainInterfaceStats = vzDomainInterfaceStats, /* 1.2.17 */                   [*]
.domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */
.domainMigrateBegin3Params = vzDomainMigrateBegin3Params, /* 1.3.5 */
.domainMigrateConfirm3Params = vzDomainMigrateConfirm3Params, /* 1.3.5 */

[2] API calls that use thread shared sdkdom object
(marked [*] are included for a different reason)

.domainSuspend = vzDomainSuspend,    /* 0.10.0 */
.domainResume = vzDomainResume,    /* 0.10.0 */
.domainDestroy = vzDomainDestroy,  /* 0.10.0 */
.domainShutdown = vzDomainShutdown, /* 0.10.0 */
.domainCreate = vzDomainCreate,    /* 0.10.0 */
.domainCreateWithFlags = vzDomainCreateWithFlags, /* 1.2.10 */
.domainReboot = vzDomainReboot, /* 1.3.0 */
.domainDefineXML = vzDomainDefineXML,      /* 0.10.0 */
.domainDefineXMLFlags = vzDomainDefineXMLFlags, /* 1.2.12 */ (update part)
.domainUndefine = vzDomainUndefine, /* 1.2.10 */
.domainAttachDevice = vzDomainAttachDevice, /* 1.2.15 */
.domainAttachDeviceFlags = vzDomainAttachDeviceFlags, /* 1.2.15 */
.domainDetachDevice = vzDomainDetachDevice, /* 1.2.15 */
.domainDetachDeviceFlags = vzDomainDetachDeviceFlags, /* 1.2.15 */
.domainSetUserPassword = vzDomainSetUserPassword, /* 1.3.6 */
.domainManagedSave = vzDomainManagedSave, /* 1.2.14 */
.domainSetMemoryFlags = vzDomainSetMemoryFlags, /* 1.3.4 */
.domainSetMemory = vzDomainSetMemory, /* 1.3.4 */
.domainRevertToSnapshot = vzDomainRevertToSnapshot, /* 1.3.5 */                  [*]
.domainSnapshotCreateXML = vzDomainSnapshotCreateXML, /* 1.3.5 */                [*]
.domainMigratePerform3Params = vzDomainMigratePerform3Params, /* 1.3.5 */        [*]
.domainUpdateDeviceFlags = vzDomainUpdateDeviceFlags, /* 2.0.0 */
prlsdkHandleVmConfigEvent

[3] API calls that do not use thread shared sdkdom object

.domainManagedSaveRemove = vzDomainManagedSaveRemove, /* 1.2.14 */
.domainSnapshotNum = vzDomainSnapshotNum, /* 1.3.5 */
.domainSnapshotListNames = vzDomainSnapshotListNames, /* 1.3.5 */
.domainListAllSnapshots = vzDomainListAllSnapshots, /* 1.3.5 */
.domainSnapshotGetXMLDesc = vzDomainSnapshotGetXMLDesc, /* 1.3.5 */
.domainSnapshotNumChildren = vzDomainSnapshotNumChildren, /* 1.3.5 */
.domainSnapshotListChildrenNames = vzDomainSnapshotListChildrenNames, /* 1.3.5 */
.domainSnapshotListAllChildren = vzDomainSnapshotListAllChildren, /* 1.3.5 */
.domainSnapshotLookupByName = vzDomainSnapshotLookupByName, /* 1.3.5 */
.domainHasCurrentSnapshot = vzDomainHasCurrentSnapshot, /* 1.3.5 */
.domainSnapshotGetParent = vzDomainSnapshotGetParent, /* 1.3.5 */
.domainSnapshotCurrent = vzDomainSnapshotCurrent, /* 1.3.5 */
.domainSnapshotIsCurrent = vzDomainSnapshotIsCurrent, /* 1.3.5 */
.domainSnapshotHasMetadata = vzDomainSnapshotHasMetadata, /* 1.3.5 */
.domainSnapshotDelete = vzDomainSnapshotDelete, /* 1.3.5 */

[4] Known issues.

1. accidental errors on getting network statistics
2. race with simultaneous use of thread shared domain object on paths
 of adding domain thru API and adding domain on vz sdk domain added event.

8 years agovz: keep naming convention for domain objects
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:32 +0000 (18:00 +0300)]
vz: keep naming convention for domain objects

see 4385b868

8 years agovz: remove redundant variable in prlsdkHandleVmAddedEvent
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:31 +0000 (18:00 +0300)]
vz: remove redundant variable in prlsdkHandleVmAddedEvent

8 years agovz: use state variable sdkdom in prlsdkApplyConfig
Nikolay Shirokovskiy [Wed, 20 Jul 2016 15:00:30 +0000 (18:00 +0300)]
vz: use state variable sdkdom in prlsdkApplyConfig

sdk domain handle is unique per connection so there is
no sense to query it again if we have it in vzDomObjPtr.
Side effect of prlsdkSdkDomainLookupByUUID is refreshing
domain config is of no use too as PrlVm_BeginEdit do it too.

8 years agostorage: Add extra failure condition for luks volume creation
John Ferlan [Tue, 19 Jul 2016 17:54:55 +0000 (13:54 -0400)]
storage: Add extra failure condition for luks volume creation

Commit id '5e46d7d6' did not take into account that usage of a luks
volume will require usage of the master key encrypted passphrase for
a QEMU environment.  So rather than allow creation of something that
won't be usable, just fail the creation.

8 years agoqemu: Disallow usage of luks encryption if aes secret not possible
John Ferlan [Tue, 19 Jul 2016 17:40:41 +0000 (13:40 -0400)]
qemu: Disallow usage of luks encryption if aes secret not possible

Resolves a CI test integration failure with a RHEL6/Centos6 environment.

In order to use a LUKS encrypted device, the design decision was to
generate an encrypted secret based on the master key. However, commit
id 'da86c6c' missed checking for that specifically.

When qemuDomainSecretSetup was implemented, a design decision was made
to "fall back" to a plain text secret setup if the specific cipher was
not available (e.g. virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC))
as well as the QEMU_CAPS_OBJECT_SECRET. For the luks encryption setup
there is no fall back to the plaintext secret, thus if that gets set
up by qemuDomainSecretSetup, then we need to fail.

Also, while the qemuxml2argvtest has set the QEMU_CAPS_OBJECT_SECRET
bit, it didn't take into account the second requirement that the
ability to generate the encrypted secret is possible. So modify the
test to not attempt to run the luks-disk if we know we don't have
the encryption algorithm.

8 years agostorage: Fix error path
John Ferlan [Tue, 19 Jul 2016 17:25:58 +0000 (13:25 -0400)]
storage: Fix error path

virStorageBackendCreateQemuImgCheckEncryption didn't return -1 if there
were no secrets.

8 years agoqemu: Move setting of encobjAdded for qemuDomainAttachSCSIDisk
John Ferlan [Tue, 19 Jul 2016 14:50:40 +0000 (10:50 -0400)]
qemu: Move setting of encobjAdded for qemuDomainAttachSCSIDisk

A post push realization that the boolean should be set inside the condition

8 years agoqemu: Move setting of obj bools for qemuDomainAttachVirtioDiskDevice
John Ferlan [Tue, 19 Jul 2016 14:48:10 +0000 (10:48 -0400)]
qemu: Move setting of obj bools for qemuDomainAttachVirtioDiskDevice

A post push realization that the setting of the boolean needed to be
inside the if condition.

8 years agohvsupport: skip non-matching lines early
Ján Tomko [Tue, 28 Jun 2016 13:23:58 +0000 (15:23 +0200)]
hvsupport: skip non-matching lines early

Most of the lines we look at are not going to match one of the
driver types contained in $groups_regex.

Move on to the next line if it does not contain any of them early.
This speeds up the script execution by 50%, since this simple regex
does not have any capture groups.

8 years agohvsupport: construct the group regex upfront
Ján Tomko [Tue, 28 Jun 2016 13:16:01 +0000 (15:16 +0200)]
hvsupport: construct the group regex upfront

The %groups hash contains all the driver types (e.g.
virHypervisorDriver or virSecretDriver).

When searching for all the APIs that are implemented by a driver
of that specific driver type, we keep iterating over the %groups
hash on every line we look at, then matching against the driver type.

This is inefficient because it prevents perl from caching the regex
and it executes the regex once for every driver type, even though
one regex matching excludes all the others, since all the driver types
are different.

Construct the regex containing all the driver types upfront to save
about 6.4s (~98%) of the script execution time.

8 years agohvsupport: use a regex instead of XML::XPath
Ján Tomko [Tue, 28 Jun 2016 11:28:48 +0000 (13:28 +0200)]
hvsupport: use a regex instead of XML::XPath

When generating the hvsupport.html.in file, we parse the -api.xml
files generated by apibuild.py to know in which HTML file the API
function is.

Doing an XPath query for every single 'function' element in the
file is inefficient.

Since the XML file is generated by another of our build scripts
(apibuild.py, using Python's standard 'output.write' XML library),
just find the function name->file mapping by a regex upfront.

Also add a note about this next to the line that generates it
in apibuild.py and do not check if XML::XPath is installed in
bootstrap since we no longer use it.

8 years agolxc: errors after the handshake won't be reported
Cédric Bosdonnat [Tue, 19 Jul 2016 14:23:25 +0000 (16:23 +0200)]
lxc: errors after the handshake won't be reported

Any error happening after the hand shake in the lxc controller
will not result in a failure as errors are checked during the handshake.
Move the handshake after the last possible error.

8 years agovirt-aa-helper: better write denials handling
Cédric Bosdonnat [Mon, 18 Jan 2016 10:22:32 +0000 (11:22 +0100)]
virt-aa-helper: better write denials handling

Better fix replacing c726af2d: introducing an 'R' permission to
add read rule, but no explicit deny write rule.

8 years agoqemu: Add luks support for domain disk
John Ferlan [Thu, 2 Jun 2016 20:28:28 +0000 (16:28 -0400)]
qemu: Add luks support for domain disk

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

Generate the luks command line using the AES secret key to encrypt the
luks secret. A luks secret object will be in addition to a an AES secret.

For hotplug, check if the encinfo exists and if so, add the AES secret
for the passphrase for the secret object used to decrypt the device.

Modify/augment the fakeSecret* in qemuxml2argvtest in order to handle
find a uuid or a volume usage with a specific path prefix in the XML
(corresponds to the already generated XML tests). Add error message
when the 'usageID' is not 'mycluster_myname'. Commit id '1d632c39'
altered the error message generation to rely on the errors from the
secret_driver (or it's faked replacement).

Add the .args output for adding the LUKS disk to the domain

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Alter the qemuDomainGetSecretAESAlias to add new arg
John Ferlan [Fri, 24 Jun 2016 19:31:57 +0000 (15:31 -0400)]
qemu: Alter the qemuDomainGetSecretAESAlias to add new arg

Soon we will be adding luks encryption support. Since a volume could require
both a luks secret and a secret to give to the server to use of the device,
alter the alias generation to create a slightly different alias so that
we don't have two objects with the same alias.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add secinfo for hotplug virtio disk
John Ferlan [Wed, 22 Jun 2016 11:07:49 +0000 (07:07 -0400)]
qemu: Add secinfo for hotplug virtio disk

Commit id 'a1344f70a' added AES secret processing for RBD when starting
up a guest. As such, when the hotplug code calls qemuDomainSecretDiskPrepare
an AES secret could be added to the disk about to be hotplugged. If an AES
secret was added, then the hotplug code would need to generate the secret
object because qemuBuildDriveStr would add the "password-secret=" to the
returned 'driveStr' rather than the base64 encoded password.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Add support to create a luks volume
John Ferlan [Thu, 2 Jun 2016 15:33:47 +0000 (11:33 -0400)]
storage: Add support to create a luks volume

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

If the volume xml was looking to create a luks volume take the necessary
steps in order to make that happen.

The processing will be:
 1. create a temporary file (virStorageBackendCreateQemuImgSecretPath)
   1a. use the storage driver state dir path that uses the pool and
       volume name as a base.

 2. create a secret object (virStorageBackendCreateQemuImgSecretObject)
   2a. use an alias combinding the volume name and "_luks0"
   2b. add the file to the object

 3. create/add luks options to the commandline (virQEMUBuildLuksOpts)
   3a. at the very least a "key-secret=%s" using the secret object alias
   3b. if found in the XML the various "cipher" and "ivgen" options

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovsh: Properly initialize res
John Ferlan [Mon, 18 Jul 2016 18:37:38 +0000 (14:37 -0400)]
vsh: Properly initialize res

The 'res' variable was only being initialized to NULL in the
if (!state) path; however, that path never used res and evenutally
res is assigned one of two results based on a pair of if then else if
conditions. If for some reason neither of those paths was taken and
the (!state) path wasn't taken, then 'res' would be indeterminate.

Found by Coverity, probably a false positive based on code paths, but
better safe than sorry for the future.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Need to check for glisten before accessing
John Ferlan [Mon, 18 Jul 2016 18:30:59 +0000 (14:30 -0400)]
conf: Need to check for glisten before accessing

When formatting the graphics data for TYPE_SPICE, check if the glisten
is NULL before blindly referencing

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests: Need to check return of virGetLastError
John Ferlan [Mon, 18 Jul 2016 18:25:43 +0000 (14:25 -0400)]
tests: Need to check return of virGetLastError

Cannot assume virGetLastError returns non-NULL value - modify the code to
fetch err and check if err && err->code

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotools: Fix comparison in virLoginShellGetShellArgv
John Ferlan [Mon, 18 Jul 2016 18:07:42 +0000 (14:07 -0400)]
tools: Fix comparison in virLoginShellGetShellArgv

Commit id '740e4d70' altered the logic to fetch the sysconf values and
added a new virConfGetValueStringList which returns -1 on failure, 0 if
missing, and 1 if the value was present.

However, the caller only checked !shargv which caught Coverity's attention
since the following VIR_ALLOC_N(*shargv, 2) would be a NULL ptr deref

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Fix incorrect VIR_FREE in virConfGetValueStringList
John Ferlan [Mon, 18 Jul 2016 17:58:52 +0000 (13:58 -0400)]
util: Fix incorrect VIR_FREE in virConfGetValueStringList

Since we VIR_ALLOC_N to *values, the VIR_FREE should be done likewise

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agovirt-admin: Output srv-threadpool-info data as unsigned int rather than signed
Erik Skultety [Mon, 18 Jul 2016 08:45:17 +0000 (10:45 +0200)]
virt-admin: Output srv-threadpool-info data as unsigned int rather than signed

Internally, all the data are represented as unsigned int, it is also documented
in the header file that users should use our exported constants that also
indicate that the data should be unsigned int. However, when polling for the
current server threadpool's configuration, virt-admin uses an incorrect
formatting parameter '%d' for printf. Instead, virt-admin should use formatting
parameter '%u'.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Move and rename qemuBufferEscapeComma
John Ferlan [Fri, 15 Jul 2016 11:02:05 +0000 (07:02 -0400)]
qemu: Move and rename qemuBufferEscapeComma

Move to virqemu and rename to virQEMUBuildBufferEscapeComma. This can then
be shared by the storage driver when it builds the command line for qemuimg

8 years agoqemu: Alter error path cleanup for qemuDomainAttachMemory
John Ferlan [Fri, 15 Jul 2016 11:27:48 +0000 (07:27 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachMemory

A recent adjustment to qemuDomainAttachRNGDevice to properly cleanup
the props object after a qemuMonitorAddObject also would affect this
code. Alter the cleanup to be similar to RNG changes.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachRNGDevice
John Ferlan [Thu, 14 Jul 2016 22:13:50 +0000 (18:13 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachRNGDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachChrDevice
John Ferlan [Thu, 14 Jul 2016 21:55:05 +0000 (17:55 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachChrDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachSCSIDisk
John Ferlan [Thu, 14 Jul 2016 21:47:13 +0000 (17:47 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachSCSIDisk

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachVirtioDiskDevice
John Ferlan [Thu, 14 Jul 2016 21:28:53 +0000 (17:28 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachVirtioDiskDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agoqemu: Alter error path cleanup for qemuDomainAttachHostSCSIDevice
John Ferlan [Thu, 14 Jul 2016 21:15:10 +0000 (17:15 -0400)]
qemu: Alter error path cleanup for qemuDomainAttachHostSCSIDevice

Based on recent review comment - rather than have a spate of goto failxxxx,
change to a boolean based model. Ensures that the original error can be
preserved and cleanup is a bit more orderly if more objects are added.

8 years agofs: Fix '<' comparison of value produced by logical not '!'
Erik Skultety [Tue, 19 Jul 2016 07:27:32 +0000 (09:27 +0200)]
fs: Fix '<' comparison of value produced by logical not '!'

Commit da665fbd introduced the following condition to virLXCProcessEnsureRootFS
and openvzReadFSConf:

if (!(<some_var> = virDomainFSDefNew()) < 0)

which broke the build on fedora with GCC 5.3.1: "logical not is only applied to
the left hand side of comparison".

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agosecurity: compilation error due to wrong parameter for vah_add_path().
Julio Faracco [Tue, 19 Jul 2016 01:09:20 +0000 (22:09 -0300)]
security: compilation error due to wrong parameter for vah_add_path().

The commit da665fbd introduced virStorageSourcePtr inside the structure
_virDomainFSDef. This is causing an error when libvirt is being compiled.

make[3]: Entering directory `/media/julio/8d65c59c-6ade-4740-9cdc-38016a4cb8ae
/home/julio/Desktop/virt/libvirt/src'
  CC       security/virt_aa_helper-virt-aa-helper.o
security/virt-aa-helper.c: In function 'get_files':
security/virt-aa-helper.c:1087:13: error: passing argument 2 of 'vah_add_path'
from incompatible pointer type [-Werror]
             if (vah_add_path(&buf, fs->src, "rw", true) != 0)
             ^
security/virt-aa-helper.c:732:1: note: expected 'const char *' but argument is
of type 'virStorageSourcePtr'
 vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool
recursive)
 ^
cc1: all warnings being treated as errors

Adding the attribute "path" from virStorageSourcePtr fixes this issue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
8 years agovz: add tcp and udp serial device support
Nikolay Shirokovskiy [Tue, 31 May 2016 09:38:33 +0000 (12:38 +0300)]
vz: add tcp and udp serial device support

vz supports only a subset of tcp and udp parameters.

1. tcp type supports only 'raw' protocol.
2. udp type supports only same parameters of 'host' and 'service'
for 'bind' and 'connect'.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: add mode of unix socket serial device to xml dump
Nikolay Shirokovskiy [Tue, 31 May 2016 09:38:32 +0000 (12:38 +0300)]
vz: add mode of unix socket serial device to xml dump

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: don't fail unregister on sending event error
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:46:00 +0000 (11:46 +0300)]
vz: don't fail unregister on sending event error

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: use single variable for domain
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:59 +0000 (11:45 +0300)]
vz: use single variable for domain

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: dont remove domain from list on client object error
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:58 +0000 (11:45 +0300)]
vz: dont remove domain from list on client object error

After domain is in the domains list let's keep it there. This
is approach taken by qemu driver and vz vzDomainMigrateFinish3Params too.
It quite reasonable, driver domain object is fully constructed and
can be discovered by client later.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: cleanup loading domain code
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:57 +0000 (11:45 +0300)]
vz: cleanup loading domain code

  9c14a9ab introduced vzNewDomain function to enlist libvirt domain
object before actually creating vz sdk domain. Fix should fix
race on same vz sdk domain added event where libvirt domain object is
enlisted too. But later eb5e9c1e added locked checks for
adding livirtd domain object to list on vz sdk domain added event.
Thus now approach of 9c14a9ab is unnecessary complicated.

  See we have otherwise unuseful prlsdkGetDomainIds function only
to create minimal domain definition to create libvirt domain object.
Also vzNewDomain is difficult to use as it creates partially
constructed domain object.

  Let's move back to original approach where prlsdkLoadDomain do
all the necessary job. Another benefit is that we can now
take driver lock for bare minimum and in single place. Reducing
locking time have small disadvatage of double parsing on race
conditions which is typical if domain is added thru vz driver.
Well we have this double parse inevitably with current vz sdk api
on any domain updates so i would not take it here seriously.

  Performance events subscribtion is done before locked check and
therefore could be done twice on races but this is not the problem.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: use domain list infrastructure to deal with private domain
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:56 +0000 (11:45 +0300)]
vz: use domain list infrastructure to deal with private domain

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: make error handling idiomatic in prlsdkCreateVm
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:55 +0000 (11:45 +0300)]
vz: make error handling idiomatic in prlsdkCreateVm

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix leaks in prlsdkCreate* functions
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:54 +0000 (11:45 +0300)]
vz: fix leaks in prlsdkCreate* functions

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: restore accidentally removed locks around close callback calls
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:53 +0000 (11:45 +0300)]
vz: restore accidentally removed locks around close callback calls

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: remove unnecessary labels in simple API calls
Nikolay Shirokovskiy [Tue, 14 Jun 2016 08:45:52 +0000 (11:45 +0300)]
vz: remove unnecessary labels in simple API calls

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: support filesystem type volume
Olga Krishtal [Thu, 14 Jul 2016 13:52:41 +0000 (16:52 +0300)]
vz: support filesystem type volume

Vz containers are able to use ploop volumes from storage pools
to work upon.

To use filesystem type volume, pool name and volume name should be
specifaed in <source> :
   <filesystem type='volume' accessmode='passthrough'>
      <driver type='ploop' format='ploop'/>
      <source pool='guest_images' volume='TEST_POOL_CT'/>
      <target dir='/'/>
   </filesystem>

The information about pool and volume is stored in ct dom configuration:
<StorageURL>libvirt://localhost/pool_name/vol_name</StorageURL>
and can be easily obtained via PrlVmDevHd_GetStorageURL sdk call.

The only shorcoming: if storage pool is moved somewhere the ct
should be redefined in order to refresh the information aboot path
to root.hdd

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agovz: refactoring of prlsdkCreateCt
Olga Krishtal [Thu, 14 Jul 2016 13:52:40 +0000 (16:52 +0300)]
vz: refactoring of prlsdkCreateCt

We do not need to check domainf fs type there,
because it is done in prlsdkCheckUnsupportedParams.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agodevices: filesystems: added volume type
Olga Krishtal [Thu, 14 Jul 2016 13:52:39 +0000 (16:52 +0300)]
devices: filesystems: added volume type

New type of <devices> <filesystem type= 'volume'> is introduced.
This patch allows to use volumes for storing the filesystem, that is
accessed from the guest e.g. root directory for container.

To take advantage of volumes as a backend of filesystem volume
and pool names should be specified:
<filesystem type= 'volume'>
 <source pool='pool name' volume='volume name'/>

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agofilesystem: adds possibility to use storage pool as fs source
Olga Krishtal [Thu, 14 Jul 2016 13:52:38 +0000 (16:52 +0300)]
filesystem: adds possibility to use storage pool as fs source

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agovz: fixed null-pointer dereference in applying graphic params
Olga Krishtal [Wed, 29 Jun 2016 17:23:18 +0000 (20:23 +0300)]
vz: fixed null-pointer dereference in applying graphic params

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
8 years agovz: fix destination domain synchronization
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:22 +0000 (10:17 +0300)]
vz: fix destination domain synchronization

Adding domain to domain list on preparation step is not correct.
First domain is not fully constructed - domain definition is
missing. Second we can't use VIR_MIGRATE_PARAM_DEST_XML parameter
to parse definition as vz sdk can patch it by itself. Let's add/remove
domain on finish step. This is for synchronization purpose only so domain
is present/absent on destination after migration completion. Actually
domain object will probably be created right after actual vz sdk
migration start by vz sdk domain defined event.

We can not and should not sync domain cache on error path in finish step
of migration. We can not as we really don't know what is the reason of
cancelling and we should not as user should not make assumptions on
state on error path. What we should do is cleaning up temporary migration
state that is induced on prepare step but we don't have one. Thus
cancellation should be noop.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix memory leaks in prlsdkLoadDomains
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:21 +0000 (10:17 +0300)]
vz: fix memory leaks in prlsdkLoadDomains

Free sdkdom on any result of prlsdkNewDomainByHandle.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix missed defined domain event
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:20 +0000 (10:17 +0300)]
vz: fix missed defined domain event

libvirt domain defined event is issued only on correspondent vz sdk
event. But in case event delivered before domain is added to
domain list we can mistakenly skip this event if prlsdkNewDomainByHandle
return NULL in case of domain is discovered in the list under
the driver lock. Let's return domain object in this case.
Now prlsdkNewDomainByHandle returns NULL only in case of
error which is more convinient.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: don't pass empty and unused fields in migration cookie
Nikolay Shirokovskiy [Wed, 8 Jun 2016 07:17:19 +0000 (10:17 +0300)]
vz: don't pass empty and unused fields in migration cookie

The first version of migration cookie was rather dumb resulting
in passing empty or unused fields here and there. Add flags to
specify what to bake to and eat from cookie so we deal only
with meaningful data. However for backwards compatibility
we still need to pass at least some faked fields sometimes.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agoqemu: Fix migration from old libvirt
Jiri Denemark [Mon, 18 Jul 2016 11:17:28 +0000 (13:17 +0200)]
qemu: Fix migration from old libvirt

Older libvirt versions send persistent XML in a migration cookie even
when VIR_MIGRATE_PERSIST_DEST flag is not used, but current libvirt
properly fails if the cookie contains unexpected flags. Thus migration
from old libvirt fails with

    internal error: Unsupported migration cookie feature persistent

unless VIR_MIGRATE_PERSIST_DEST flag is set.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotest: Add scsi vport nodedev to test:///default
Cole Robinson [Fri, 1 Jul 2016 11:33:10 +0000 (07:33 -0400)]
test: Add scsi vport nodedev to test:///default

A nodedev device definition like this is required for testing
NodeDeviceCreateXML and NodeDeviceDestroy. So unless it's part
of the stock test:///default set there's no way to actually
invoke those functions for the default URI

8 years agotest: Have test:///default open use file parsing helpers
Cole Robinson [Mon, 27 Jun 2016 22:09:14 +0000 (18:09 -0400)]
test: Have test:///default open use file parsing helpers

Convert the individual XML documents into one big XML document
in the format expected by the non-default test://$PATH URI, and
use the same internal helpers for assembling the driver contents.

8 years agotest: Move testOpenDefault definition later
Cole Robinson [Mon, 27 Jun 2016 21:06:43 +0000 (17:06 -0400)]
test: Move testOpenDefault definition later

Upcoming patches need this defined later

8 years agotest: Introduce testOpenParse
Cole Robinson [Mon, 27 Jun 2016 21:03:07 +0000 (17:03 -0400)]
test: Introduce testOpenParse

8 years agoutil: conf: Rename VIR_CONF_{U,}LONG -> VIR_CONF_{U,}LLONG
Andrea Bolognani [Fri, 15 Jul 2016 15:36:32 +0000 (17:36 +0200)]
util: conf: Rename VIR_CONF_{U,}LONG -> VIR_CONF_{U,}LLONG

Since commit 6381c89f8cce, we're storing long long integers
instead of long integers. Rename the corresponding virConfType
value accordingly.

8 years agoutil: conf: Clarify choice between VIR_CONF_LONG and VIR_CONF_ULONG
Andrea Bolognani [Fri, 15 Jul 2016 15:20:03 +0000 (17:20 +0200)]
util: conf: Clarify choice between VIR_CONF_LONG and VIR_CONF_ULONG

We use unsigned long long integers unless we need to store a
negative value. Rewrite the condition to make this more obvious.

8 years agoutil: conf: Fix parameters alignment
Andrea Bolognani [Fri, 15 Jul 2016 15:26:58 +0000 (17:26 +0200)]
util: conf: Fix parameters alignment

The parameters for virConfGetValueLLong() were not aligned
properly.

8 years agoutil: conf: Fix comment for virConfGetValueULLong()
Andrea Bolognani [Fri, 15 Jul 2016 15:11:18 +0000 (17:11 +0200)]
util: conf: Fix comment for virConfGetValueULLong()

The name of the function is not virConfGetValueULongLong().

8 years agoutil: conf: Claim the proper range for signed numbers
Andrea Bolognani [Fri, 15 Jul 2016 15:47:01 +0000 (17:47 +0200)]
util: conf: Claim the proper range for signed numbers

virConfGetValueLLong() errors out if the value is too big to
fit into a long long integer, but claims the supported range
to be (0,LLONG_MAX) instead of (LLONG_MIN,LLONG_MAX).

8 years agoutil: conf: Add integer casts
Andrea Bolognani [Fri, 15 Jul 2016 16:48:07 +0000 (18:48 +0200)]
util: conf: Add integer casts

For good measure.

8 years agoutil: conf: Improve virConfGet*() logic
Andrea Bolognani [Fri, 15 Jul 2016 15:07:38 +0000 (17:07 +0200)]
util: conf: Improve virConfGet*() logic

When parsing numeric values, we always store them as unsigned
unless they're negative. We can use this fact to simplify the
logic by removing a bunch of unnecessary checks.

8 years agoutil: conf: Use long long when parsing
Andrea Bolognani [Fri, 15 Jul 2016 11:53:57 +0000 (13:53 +0200)]
util: conf: Use long long when parsing

Commit 6381c89f8cce changed virConfValue to store long long
integers instead of long integers; however, the temporary variable
used in virConfParseLong() was not updated accordingly, causing
trouble for 32-bit machines.

8 years agohvsupport: Introduce parseSymsFile
Ján Tomko [Tue, 28 Jun 2016 10:37:50 +0000 (12:37 +0200)]
hvsupport: Introduce parseSymsFile

The code for parsing the different public syms files only differs
in the filenames and version prefix.

Unify it to a single subroutine.

8 years agoStore USB port path as an array of integers
Ján Tomko [Wed, 12 Aug 2015 14:52:13 +0000 (16:52 +0200)]
Store USB port path as an array of integers

In preparation to tracking which USB addresses are occupied.
Introduce two helper functions for printing the port path
as a string and appending it to a virBuffer.

8 years agoAllow omitting USB port
Ján Tomko [Fri, 1 Jul 2016 12:20:44 +0000 (14:20 +0200)]
Allow omitting USB port

We were requiring a USB port path in the schema, but not enforcing it.
Omitting the USB port would lead to libvirt formatting it as (null).
Such domain cannot be started and will disappear after libvirtd restart
(since it cannot parse back the XML).

Only format the port if it has been specified and mark it as optional
in the XML schema.