]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: driver: Unset log file watcher after restoring a VM save file
Peter Krempa [Fri, 3 Jun 2016 13:18:48 +0000 (15:18 +0200)]
qemu: driver: Unset log file watcher after restoring a VM save file

qemuProcessStart does not unset the infrastructure that retrieves errors
from the qemu log file in case of migration. As this wasn't handled
properly in qemuDomainSaveImageStartVM we kept the logging context/fd
open for the lifetime of the VM rather than closing it after it's not
needed.

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

8 years agotest: Remove executable permission from Xen xm files
Philipp Hahn [Thu, 19 May 2016 06:24:57 +0000 (08:24 +0200)]
test: Remove executable permission from Xen xm files

The configuration files are not directly executable as they don't have
as hash-bang line.

8 years agoxen: test for driver=tap2 sub-type in xen-xm
Philipp Hahn [Thu, 19 May 2016 06:24:56 +0000 (08:24 +0200)]
xen: test for driver=tap2 sub-type in xen-xm

tap2 only handles 'aio', but not 'raw', which must be explicitly given:

XML:raw needs to be translated to XM:aio for 'tap' and 'tap2' Xen
drivers.

8 years agoxen: Also add sub-type for driver=tap2 in xen-xm
Philipp Hahn [Thu, 19 May 2016 06:24:55 +0000 (08:24 +0200)]
xen: Also add sub-type for driver=tap2 in xen-xm

tap2 only handles 'aio', but not 'raw', which must be explicitly given:

| $ virsh domxml-to-native yyy.xml > yyy.xm
| $ xm new yyy.xm
| Error: tap:/srv/xen/xxx.img not a valid disk type
| $ sed -i -e 's/tap2:/&aio:/' yyy.xm
| $ xm new yyy.xm

Fix reading and writing "xen-xm" format for "tap2" by handling it the
same as "tap".

8 years agoqemu: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Tue, 7 Jun 2016 15:59:57 +0000 (17:59 +0200)]
qemu: Replace VIR_ERROR with standard vir*Error in state driver init

8 years agoxen: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Tue, 7 Jun 2016 15:59:58 +0000 (17:59 +0200)]
xen: Replace VIR_ERROR with standard vir*Error in state driver init

8 years agouml: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Tue, 7 Jun 2016 15:59:56 +0000 (17:59 +0200)]
uml: Replace VIR_ERROR with standard vir*Error in state driver init

8 years agoqemu: migration: Add VM log entry on start of migration
Peter Krempa [Tue, 7 Jun 2016 15:02:14 +0000 (17:02 +0200)]
qemu: migration: Add VM log entry on start of migration

Note the start of migration of a qemu process to the VM log file for
possible debug purposes.

8 years agoqemu: process: Append the "shutting down" message using the new APIs
Peter Krempa [Tue, 7 Jun 2016 14:31:15 +0000 (16:31 +0200)]
qemu: process: Append the "shutting down" message using the new APIs

Use qemuDomainLogAppendMessage rather than attempting to open a new
logging context with file descriptors. The new approach allows to log
the message even if qemu is still running at that point which appens
during migration finish phase where qemuProcessStop is killing qemu.

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

8 years agoqemu: domain: Implement helper for one-shot log entries to the VM log file
Peter Krempa [Tue, 7 Jun 2016 14:19:03 +0000 (16:19 +0200)]
qemu: domain: Implement helper for one-shot log entries to the VM log file

Along with the virtlogd addition of the log file appending API implement
a helper for logging one-shot entries to the log file including the
fallback approach of using direct file access.

This will be used for noting the shutdown of the qemu proces and
possibly other actions such as VM migration and other critical VM
lifecycle events.

8 years agolog: daemon: Add remote protocol handling for the log appending API
Peter Krempa [Tue, 7 Jun 2016 14:15:22 +0000 (16:15 +0200)]
log: daemon: Add remote protocol handling for the log appending API

Implement the RPC dispatcher and caller for the new API.

8 years agolog: handler: Add new API to append to logging files
Peter Krempa [Tue, 7 Jun 2016 14:09:09 +0000 (16:09 +0200)]
log: handler: Add new API to append to logging files

For logging one-shot entries to the VM log file it's quite a waste to
hold open the file descriptor for logging that is provided by the
current API.

This new API will be ideal for logging one-shot entries to the file
e.g. at the point when we shut the VM down rather than having to add the
whole file-descriptor infrastructure.

Additionally this will allow to add the messages even after restart of
libvirtd since virtlogd doesn't allow to obtain a regular context with
filedescriptors while the VM is still active.

8 years agoutil: Perform proper virRandomBytes return value checking
John Ferlan [Tue, 7 Jun 2016 11:24:31 +0000 (07:24 -0400)]
util: Perform proper virRandomBytes return value checking

Document the return value of virRandomBytes as 0 or some errno value and
then make sure all callers make the proper checks.

8 years agoReindent virNetDevSendEthtoolIoctl
Ján Tomko [Tue, 7 Jun 2016 12:00:22 +0000 (14:00 +0200)]
Reindent virNetDevSendEthtoolIoctl

8 years agoReuse the socket in virNetDevGetFeatures
Ján Tomko [Fri, 3 Jun 2016 18:46:05 +0000 (20:46 +0200)]
Reuse the socket in virNetDevGetFeatures

This speeds up node_device_udev driver startup 11x.

8 years agoReturn bool in virNetDevFeatureAvailable
Ján Tomko [Fri, 3 Jun 2016 18:44:23 +0000 (20:44 +0200)]
Return bool in virNetDevFeatureAvailable

Simplify the logic

8 years agoSplit out virNetDevGetEthtoolGFeatures
Ján Tomko [Fri, 3 Jun 2016 18:25:21 +0000 (20:25 +0200)]
Split out virNetDevGetEthtoolGFeatures

Move out the code depending on HAVE_DECL_ETHTOOL_GFEATURES.

8 years agoSplit out virNetDevGetEthtoolFeatures
Ján Tomko [Fri, 3 Jun 2016 18:18:25 +0000 (20:18 +0200)]
Split out virNetDevGetEthtoolFeatures

Split out the features that we probe via various ethtool commands
and ETHTOOL_GFLAGS.

8 years agoMove struct elem out of virNetDevGetFeatures
Ján Tomko [Fri, 3 Jun 2016 18:01:44 +0000 (20:01 +0200)]
Move struct elem out of virNetDevGetFeatures

Rename struct elem to virNetDevEthtoolFeatureCmd and move it
out of the function to allow reusing it.

8 years agoReindent comment of virNetDevFeatureAvailable
Ján Tomko [Tue, 7 Jun 2016 12:06:24 +0000 (14:06 +0200)]
Reindent comment of virNetDevFeatureAvailable

8 years agoqemu: process: Allow VIR_QEMU_PROCESS_START_NEW in qemuProcessLaunch
Peter Krempa [Tue, 7 Jun 2016 11:52:16 +0000 (13:52 +0200)]
qemu: process: Allow VIR_QEMU_PROCESS_START_NEW in qemuProcessLaunch

The new flag was not added to virCheckFlags in commit '0d1c17aa' causing
a regression where VMs were not able to start.

8 years agoutil: Alter virCryptoEncryptData for non GNUTLS builds
John Ferlan [Sun, 22 May 2016 14:07:47 +0000 (10:07 -0400)]
util: Alter virCryptoEncryptData for non GNUTLS builds

Rather than intermixing the ATTRIBUTE_UNUSED - use HAVE_GNUTLS_CIPHER_ENCRYPT
for the whole function instead.

8 years agoAdd nomatch filters when enumerating udev devices
Ján Tomko [Thu, 2 Jun 2016 16:09:56 +0000 (18:09 +0200)]
Add nomatch filters when enumerating udev devices

Filter out some subsystems we are not interested in.

8 years agonode_device_udev: rename labels to cleanup
Ján Tomko [Fri, 3 Jun 2016 17:40:45 +0000 (19:40 +0200)]
node_device_udev: rename labels to cleanup

Instead of the custom out and out_unlock.

8 years agonode_device_udev: remove unnecessary ret variables
Ján Tomko [Fri, 3 Jun 2016 17:37:06 +0000 (19:37 +0200)]
node_device_udev: remove unnecessary ret variables

Remove ret variables and labels from functions where there is no cleanup
to be done.

8 years agoqemu: Move check that validates 'min_guarantee' to qemuDomainDefValidate
Peter Krempa [Tue, 17 May 2016 13:56:51 +0000 (15:56 +0200)]
qemu: Move check that validates 'min_guarantee' to qemuDomainDefValidate

Introduce a validation callback for qemu and move checking of
min_guarantee to the new callback.

8 years agoconf: Move validation of disk LUN device to the appropriate place
Peter Krempa [Thu, 26 May 2016 16:00:57 +0000 (18:00 +0200)]
conf: Move validation of disk LUN device to the appropriate place

Now with the proper domain config validation infrastructure the check
can be moved to a place that doesn't make domains vanish.

8 years agoconf: Move disk info validator to the domain conf validator
Peter Krempa [Fri, 27 May 2016 10:34:14 +0000 (12:34 +0200)]
conf: Move disk info validator to the domain conf validator

Since it will not be called from outside of conf we can unexport it too
if we move it to the appropriate place.

Test suite change is necessary since the error will be reported sooner
now.

8 years agoqemu: process: Call the domain config validator when starting a new VM
Peter Krempa [Fri, 27 May 2016 11:54:26 +0000 (13:54 +0200)]
qemu: process: Call the domain config validator when starting a new VM

To avoid duplicating all the checks when starting a fresh VM from a
possibly unchecked config, call the domain def validator.

8 years agoqemu: process: Convert multiple boolean args to a single flag
Peter Krempa [Fri, 27 May 2016 11:45:05 +0000 (13:45 +0200)]
qemu: process: Convert multiple boolean args to a single flag

Validation of qemu process startup requires to know whether the process
is used for a fresh VM or whether it's reloaded from a
snapshot/migration. Pass this information in via a flag rather than
calculating it from a bunch of bools.

8 years agoqemu: process: Unexport qemuProcessStartValidate
Peter Krempa [Fri, 27 May 2016 11:42:24 +0000 (13:42 +0200)]
qemu: process: Unexport qemuProcessStartValidate

8 years agoconf: Add device def validation callback
Peter Krempa [Fri, 27 May 2016 08:56:56 +0000 (10:56 +0200)]
conf: Add device def validation callback

Similarly to the domain definition validator add a device validator. The
change to the prototype of the domain validator is necessary as
virDomainDeviceInfoIterateInternal requires a non-const pointer.

8 years agoconf: drop 'def' from struct virDomainDefPostParseDeviceIteratorData
Peter Krempa [Thu, 26 May 2016 15:43:33 +0000 (17:43 +0200)]
conf: drop 'def' from struct virDomainDefPostParseDeviceIteratorData

It's passed to all places along with the structure.

8 years agoconf: Add infrastructure for adding configuration validation
Peter Krempa [Thu, 26 May 2016 13:58:53 +0000 (15:58 +0200)]
conf: Add infrastructure for adding configuration validation

Until now we weren't able to add checks that would reject configuration
once accepted by the parser. This patch adds a new callback and
infrastructure to add such checks. In this patch all the places where
rejecting a now-invalid configuration wouldn't be a good idea are marked
with a new parser flag.

8 years agoconf: Rename VIR_DOMAIN_DEF_PARSE_VALIDATE to VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA
Peter Krempa [Tue, 24 May 2016 15:20:20 +0000 (17:20 +0200)]
conf: Rename VIR_DOMAIN_DEF_PARSE_VALIDATE to VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA

Make it obvious that the flag is controlling RNG schema validation.

8 years agonode_device_udev: remove yoda condition
Ján Tomko [Fri, 3 Jun 2016 17:41:43 +0000 (19:41 +0200)]
node_device_udev: remove yoda condition

8 years agoudevSetupSystemDev: return if allocation fails
Ján Tomko [Fri, 3 Jun 2016 17:42:11 +0000 (19:42 +0200)]
udevSetupSystemDev: return if allocation fails

There is no cleanup to be done.

8 years agoReformat udevProcessRemoveableMedia
Ján Tomko [Fri, 3 Jun 2016 17:38:59 +0000 (19:38 +0200)]
Reformat udevProcessRemoveableMedia

Remove unnecessary ret variable and return early if we have no media
to save on indentation.

8 years agoudevProcessStorage: trim all whitespace from model and vendor
Ján Tomko [Fri, 3 Jun 2016 17:33:05 +0000 (19:33 +0200)]
udevProcessStorage: trim all whitespace from model and vendor

Use virTrimSpaces instead of a custom implementation.

8 years agonode_device_udev: switch to using virReportError
Ján Tomko [Fri, 3 Jun 2016 17:03:38 +0000 (19:03 +0200)]
node_device_udev: switch to using virReportError

Also use the more common "Unable to initialize mutex" string
and virReportSystemError instead of virStrerror.

8 years agoRemove PROPERTY_* constants
Ján Tomko [Fri, 3 Jun 2016 16:54:43 +0000 (18:54 +0200)]
Remove PROPERTY_* constants

They are no longer used.

8 years agoOnly return two values in udevGetUintSysfsAttr
Ján Tomko [Fri, 3 Jun 2016 16:49:40 +0000 (18:49 +0200)]
Only return two values in udevGetUintSysfsAttr

Open code the call to udev_device_get_sysattr_value
in the one place where it's needed.

8 years agoOnly return two values in udevGetIntSysfsAttr
Ján Tomko [Fri, 3 Jun 2016 15:39:39 +0000 (17:39 +0200)]
Only return two values in udevGetIntSysfsAttr

Callers only check for an error or a specific integer value.

8 years agoOnly return two values in udevGetStringSysfsAttr
Ján Tomko [Fri, 3 Jun 2016 15:27:48 +0000 (17:27 +0200)]
Only return two values in udevGetStringSysfsAttr

The callers only care for an error, and a missing attribute
is simply NULL.

8 years agoRemove extra allocation in udevGetDeviceSysfsAttr
Ján Tomko [Fri, 3 Jun 2016 15:13:39 +0000 (17:13 +0200)]
Remove extra allocation in udevGetDeviceSysfsAttr

Most of the code paths free it right after converting it to
an integer.

8 years agoOnly return two values in udevGetUintProperty
Ján Tomko [Fri, 3 Jun 2016 14:10:21 +0000 (16:10 +0200)]
Only return two values in udevGetUintProperty

We only care about the failure, not a missing property.

8 years agoOnly return two values in udevGetStringProperty
Ján Tomko [Fri, 3 Jun 2016 13:54:19 +0000 (15:54 +0200)]
Only return two values in udevGetStringProperty

There is no need to differentiate between PROPERTY_FOUND
and PROPERTY_MISSING - we can just look if the string is non-NULL.

8 years agoqemu: Add support to QXL's max_outputs parameter
Martin Kletzander [Fri, 11 Dec 2015 13:43:10 +0000 (14:43 +0100)]
qemu: Add support to QXL's max_outputs parameter

Historically, we added heads=1 to videos, but for example for qxl, we
did not reflect that on the command line.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Check for qxl's max_outputs parameter
Martin Kletzander [Fri, 11 Dec 2015 13:26:24 +0000 (14:26 +0100)]
qemu: Check for qxl's max_outputs parameter

Add capabilities for both qxl and qxl-vga devices.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoRewrite disk type checking in udevProcessStorage
Ján Tomko [Fri, 3 Jun 2016 16:24:43 +0000 (18:24 +0200)]
Rewrite disk type checking in udevProcessStorage

Error out on parsing errors and use a local const char pointer
instead of chained ifs to check whether we found a match.

8 years agoFix the return value in udevKludgeStorageType
Ján Tomko [Fri, 3 Jun 2016 16:04:23 +0000 (18:04 +0200)]
Fix the return value in udevKludgeStorageType

Since the switch to VIR_STRDUP this function returns 1 on success,
but the caller treats any non-zero value as failure.

8 years agoudevProcessFloppy; remove unnecessary allocation
Ján Tomko [Fri, 3 Jun 2016 13:51:28 +0000 (15:51 +0200)]
udevProcessFloppy; remove unnecessary allocation

Use udevHasDeviceProperty instead of udevGetStringProperty.
We do not need to copy the string since we do not need it.

Also add braces around the if body, since the change made
syntax check complain.

8 years agoMove udevHasDeviceProperty earlier
Ján Tomko [Fri, 3 Jun 2016 14:36:35 +0000 (16:36 +0200)]
Move udevHasDeviceProperty earlier

8 years agoDo not VIR_STRDUP the string in udevGetDeviceProperty
Ján Tomko [Fri, 3 Jun 2016 13:25:22 +0000 (15:25 +0200)]
Do not VIR_STRDUP the string in udevGetDeviceProperty

Two out of three callers free it right after converting it to a number.

Also change the comment at the beginning of the function, because
the comment inside the function told me to.

8 years agoRemove udevStrToLong_i
Ján Tomko [Fri, 3 Jun 2016 12:58:51 +0000 (14:58 +0200)]
Remove udevStrToLong_i

Open code the error message.

8 years agoRemove udevStrToLong_ui
Ján Tomko [Fri, 3 Jun 2016 12:49:21 +0000 (14:49 +0200)]
Remove udevStrToLong_ui

Remove the debug message, open code the error in the two udevGetUint
callers and use a more specific error in SCSI and PCI processing.

8 years agoRemove udevStrToLong_ull
Ján Tomko [Fri, 3 Jun 2016 11:56:09 +0000 (13:56 +0200)]
Remove udevStrToLong_ull

The wrapper adds an error message or a debug log.

Since we already log the properties we get from udev as strings,
there is no much use for the debug logs.

Open code the error message and delete the function.

8 years agoRewrite usage of StrToLong_ui in udevProcess{PCI,SCSI}
Ján Tomko [Fri, 3 Jun 2016 12:54:03 +0000 (14:54 +0200)]
Rewrite usage of StrToLong_ui in udevProcess{PCI,SCSI}

Use virStrToLong_ui instead of udevStrToLong_ui, reformat the code
and report a more specific error message.

8 years agoudevProcessSCSIHost: use STRSKIP
Ján Tomko [Fri, 3 Jun 2016 12:41:28 +0000 (14:41 +0200)]
udevProcessSCSIHost: use STRSKIP

Instead of separating it into STRPEFIX and str + strlen.

8 years agoudevGetDMIData: remove unused variable
Ján Tomko [Fri, 3 Jun 2016 11:43:25 +0000 (13:43 +0200)]
udevGetDMIData: remove unused variable

A variable without use is pointless.

Remove it, since we have no use for it.

8 years agoAssign node device driver private data earlier
Ján Tomko [Fri, 3 Jun 2016 10:57:41 +0000 (12:57 +0200)]
Assign node device driver private data earlier

8 years agoDo not call nodeStateCleanup on early initialization error
Ján Tomko [Fri, 3 Jun 2016 10:30:53 +0000 (12:30 +0200)]
Do not call nodeStateCleanup on early initialization error

If we have not allocated driver yet, there is nothing to cleanup.

8 years agoReformat nodeStateCleanup
Ján Tomko [Fri, 3 Jun 2016 10:38:40 +0000 (12:38 +0200)]
Reformat nodeStateCleanup

Remove the ret variable and return early if there is no driver.

8 years agonode_device_udev: initialize libpciaccess after the driver lock
Ján Tomko [Fri, 3 Jun 2016 10:20:41 +0000 (12:20 +0200)]
node_device_udev: initialize libpciaccess after the driver lock

This will simplify cleanup.

8 years agoSplit out pciaccess (de)initialization
Ján Tomko [Fri, 3 Jun 2016 09:03:41 +0000 (11:03 +0200)]
Split out pciaccess (de)initialization

Move pci_system_init and pci_system_cleanup into separate functions,
to make the conditional compilation easier to read.

8 years agoInitialize ret to -1 in nodeStateInitialize
Ján Tomko [Fri, 3 Jun 2016 08:21:23 +0000 (10:21 +0200)]
Initialize ret to -1 in nodeStateInitialize

Most of the code paths had to reset it to -1 and returning 0 was
only possible if we made it to the end of the function.

Initialize it to -1 and only set it to 0 if we reach the end, as we do
in most of libvirt code.

8 years agosystemd: directly notify systemd instead of using sd_notify
Daniel P. Berrange [Mon, 6 Jun 2016 14:03:27 +0000 (15:03 +0100)]
systemd: directly notify systemd instead of using sd_notify

The sd_notify method is used to tell systemd when libvirtd
has finished starting up. All it does is send a datagram
containing the string parameter to systemd on a UNIX socket
named in the NOTIFY_SOCKET environment variable. Rather than
pulling in the systemd libraries for this, just code the
notification directly in libvirt as this is a stable ABI
from systemd's POV which explicitly allows independant
implementations:

See "Reimplementable Independently" column in the
"$NOTIFY_SOCKET Daemon Notifications" row:

https://www.freedesktop.org/wiki/Software/systemd/InterfacePortabilityAndStabilityChart/

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: Move and rename qemuBuildObjectCommandlineFromJSON
John Ferlan [Tue, 31 May 2016 21:35:14 +0000 (17:35 -0400)]
qemu: Move and rename qemuBuildObjectCommandlineFromJSON

Move the module from qemu_command.c to a new module virqemu.c and
rename the API to virQEMUBuildObjectCommandline.

This API will then be shareable with qemu-img and the need to build
a security object for luks support.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Create helper to set input for CreateQemuImg code
John Ferlan [Thu, 2 Jun 2016 11:46:32 +0000 (07:46 -0400)]
storage: Create helper to set input for CreateQemuImg code

Create helper virStorageBackendCreateQemuImgSetInput to set the input

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Split out a helper for encryption checks
John Ferlan [Wed, 25 May 2016 19:08:49 +0000 (15:08 -0400)]
storage: Split out a helper for encryption checks

Split out a helper from virStorageBackendCreateQemuImgCmdFromVol
to check the encryption - soon a new encryption sheriff will be
patroling and that'll mean all sorts of new checks.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Split out setting default secret for encryption
John Ferlan [Wed, 25 May 2016 13:35:09 +0000 (09:35 -0400)]
storage: Split out setting default secret for encryption

Split the qcow setting of encryption secrets into a helper

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Clean up code formatting in virstorageencryption
John Ferlan [Wed, 25 May 2016 10:51:30 +0000 (06:51 -0400)]
util: Clean up code formatting in virstorageencryption

Bring style more in line with more recent code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agodocs: Document our event loop
Michal Privoznik [Sun, 5 Jun 2016 04:58:54 +0000 (06:58 +0200)]
docs: Document our event loop

I was asked the other day what's event loop and how libvirt uses
it. Well, I haven't found any good sources on the Internet so I
thought of writing the documentation on my own.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoDo not check for domain liveness in virDomainObjSetDefTransient
Ján Tomko [Fri, 27 May 2016 12:00:34 +0000 (14:00 +0200)]
Do not check for domain liveness in virDomainObjSetDefTransient

Remove the live attribute and mark the definition as transient
whether the domain is runing or not.

There were only two callers left calling with live=false:
* testDomainStartState, where the domain already is active
  because we assigned vm->def->id just a few lines above the call
* virDomainObjGetPersistentDef, which now only calls
  virDomainObjSetDefTransient for an active domain

8 years agoCheck if the domain is active in virDomainObjGetPersistentDef
Ján Tomko [Fri, 27 May 2016 11:33:04 +0000 (13:33 +0200)]
Check if the domain is active in virDomainObjGetPersistentDef

Calling virDomainObjSetDefTransient with live=false is a no-op
on an inactive domain.

Only call it on an active domain, since this is the only place using
the live bool.

8 years agoClean up redundant usage of virDomainObjSetDefTransient
Ján Tomko [Fri, 27 May 2016 10:56:05 +0000 (12:56 +0200)]
Clean up redundant usage of virDomainObjSetDefTransient

Commit 45ec297d from November 2010:
    Make state driver device hotplug/update actually transient
added virDomainObjSetDefTransient calls to the domain startup
function in several drivers.

In November 2011, commit 8866eed:
    Set aliases for LXC/UML console devices
added a call earlier in the startup function, without removing the
existing ones.

Also, in the UML driver it seems the function never did anything
useful - vm->def->id is set asynchronnously in umlNotifyEvent.
At the time of calling virDomainObjSetDefTransient with live=false,
vm->def->id was likely still -1, making the call a no-op.

8 years agoPost-release version bump to 1.3.6
Ján Tomko [Sun, 1 May 2016 12:28:34 +0000 (08:28 -0400)]
Post-release version bump to 1.3.6

8 years agoRelease of libvirt-1.3.5
Daniel Veillard [Sat, 4 Jun 2016 15:29:59 +0000 (23:29 +0800)]
Release of libvirt-1.3.5

* docs/news.html.in: update with 1.3.5 data

8 years agoRefresh po files from zanata
Daniel P. Berrange [Fri, 3 Jun 2016 13:02:35 +0000 (14:02 +0100)]
Refresh po files from zanata

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoFix building with -Og
Martin Kletzander [Fri, 3 Jun 2016 11:26:30 +0000 (13:26 +0200)]
Fix building with -Og

When building using -Og, gcc sees that some variables can be used
uninitialized  It can be debatable whether it is possible with our
codeflow, but functions should be self-contained and initializations are
always good.  The return instead of goto is due to actualType being used
in the cleanup.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirPerfEventIsEnabled: Don't crash on shut off domains
Michal Privoznik [Fri, 3 Jun 2016 08:09:17 +0000 (10:09 +0200)]
virPerfEventIsEnabled: Don't crash on shut off domains

So imagine the following. You connect read only to a daemon and
try to fetch stats for a shut off domain, e.g.:

  virsh -r domstats $dom

but all of a sudden, virsh instead of printing the stats throws
the following error at you:

  error: Disconnected from qemu:///system due to I/O error
  error: End of file while reading data: Input/output error

The daemon crashed. This is its backtrace:

#0  0x00007fa43e3751a8 in virPerfEventIsEnabled (perf=0x0, type=VIR_PERF_EVENT_MBMT) at util/virperf.c:241
#1  0x00007fa424a9f042 in qemuDomainGetStatsPerf (driver=0x7fa3f4022a30, dom=0x7fa3f40e24c0, record=0x7fa41c000e20, maxparams=0x7fa4360b38d0, privflags=1) at qemu/qemu_driver.c:19110
#2  0x00007fa424a9f2e7 in qemuDomainGetStats (conn=0x7fa41c001b20, dom=0x7fa3f40e24c0, stats=127, record=0x7fa4360b3970, flags=1) at qemu/qemu_driver.c:19213
#3  0x00007fa424a9f672 in qemuConnectGetAllDomainStats (conn=0x7fa41c001b20, doms=0x7fa41c0017f0, ndoms=1, stats=127, retStats=0x7fa4360b3a50, flags=0) at qemu/qemu_driver.c:19303
#4  0x00007fa43e4e15f6 in virDomainListGetStats (doms=0x7fa41c0017f0, stats=0, retStats=0x7fa4360b3a50, flags=0) at libvirt-domain.c:11615

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f28d1a38700 (LWP 16154)]
0x00007f28da4fa1a8 in virPerfEventIsEnabled (perf=0x0, type=VIR_PERF_EVENT_MBMT) at util/virperf.c:241
241         return event->enabled;

Problem is, shut off domains don't have priv->perf allocated.
Therefore if in frame #1 qemuDomainGetStatsPerf() tries to check
if perf events are enabled, NULL is passed to
virPerfEventIsEnabled() which due to some incredible
implementation dereference it. Fix this by checking whether
passed object is not NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoDrop virPerfGetEventFd
Michal Privoznik [Fri, 3 Jun 2016 08:11:59 +0000 (10:11 +0200)]
Drop virPerfGetEventFd

This function is not used anywhere. Moreover, the code that would
use lives in virperf.c and therefore has access to the FD anyway.
Well, for instance virPerfReadEvent is doing just that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirDomainChrGetDomainPtrsInternal: Return an integer
Michal Privoznik [Wed, 1 Jun 2016 12:39:01 +0000 (14:39 +0200)]
virDomainChrGetDomainPtrsInternal: Return an integer

There's this problem on the recent gcc-6.1:

In file included from conf/domain_conf.c:37:0:
conf/domain_conf.c: In function 'virDomainChrPreAlloc':
conf/domain_conf.c:14109:35: error: potential null pointer dereference [-Werror=null-dereference]
     return VIR_REALLOC_N(*arrPtr, *cntPtr + 1);
                                   ^~
./util/viralloc.h:158:73: note: in definition of macro 'VIR_REALLOC_N'
 # define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count), \
                                                                         ^~~~~
conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:14133:21: error: potential null pointer dereference [-Werror=null-dereference]
     for (i = 0; i < *cntPtr; i++) {
                     ^~~~~~~

GCC basically fails to see, that the
virDomainChrGetDomainPtrsInternal will never actually return NULL
because it's never called over a domain char device with _LAST
type. But to make it shut up, lets turn this function into
returning an integer and check in the callers if a zero value
value was returned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirDomainFormatSchedDef: Avoid false positive NULL dereference
Michal Privoznik [Thu, 2 Jun 2016 10:19:57 +0000 (12:19 +0200)]
virDomainFormatSchedDef: Avoid false positive NULL dereference

Okay, I admit that our code here is complex. It's not easy to
spot that NULL deref can't really happen here. So it's no wonder
that a dumb compiler fails to see all the connections and
produces the following errors:

  CC       conf/libvirt_conf_la-domain_conf.lo
conf/domain_conf.c: In function 'virDomainDefFormatInternal':
conf/domain_conf.c:22162:22: error: potential null pointer dereference [-Werror=null-dereference]
             if (sched->policy == i)
                 ~~~~~^~~~~~~~
<snip/>
cc1: all warnings being treated as errors

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoppc64Compute: Avoid possible NULL dereference
Michal Privoznik [Thu, 2 Jun 2016 09:47:11 +0000 (11:47 +0200)]
ppc64Compute: Avoid possible NULL dereference

cpu/cpu_ppc64.c: In function 'ppc64Compute':
cpu/cpu_ppc64.c:620:27: error: potential null pointer dereference [-Werror=null-dereference]
     if (STRNEQ(guest_model->name, host_model->name)) {
                ~~~~~~~~~~~^~~
cpu/cpu_ppc64.c:620:9: note: in expansion of macro 'STRNEQ'
     if (STRNEQ(guest_model->name, host_model->name)) {
         ^~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirNetDevBridgeGet: Don't require users to virNetDevSetupControl
Michal Privoznik [Wed, 1 Jun 2016 09:52:53 +0000 (11:52 +0200)]
virNetDevBridgeGet: Don't require users to virNetDevSetupControl

So far, this function has just three callers. Two of them call
virNetDevSetupControl to create a socket that we can then
optionally use for ioctl() to fetch data. However, querying sysfs
is preferred. Therefore it doesn't make much sense to require
users to set up the socket if they don't even know it will be
used in favour of sysfs. We can set up the socket iff we need to.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonetwork: restart dnsmasq after adding/removing txt and srv records
Laine Stump [Tue, 31 May 2016 15:51:29 +0000 (11:51 -0400)]
network: restart dnsmasq after adding/removing txt and srv records

Although dns host records are stored in a separate configuration file
that is reread by dnsmasq when it receives a SIGHUP, the txt and srv
records are directly in the dnsmasq .conf file which can't be reread
after initial dnsmasq startup. This means that if an srv or txt record
is modified in a network config, libvirt needs to restart the dnsmasq
process rather than just sending a SIGHUP.

This was pointed out in a question in
https://bugzilla.redhat.com/show_bug.cgi?id=988718 , but no separate
BZ was filed.

8 years agoQXL: fix reloading of vram64 attribute
Pavel Hrdina [Wed, 13 Apr 2016 08:13:16 +0000 (10:13 +0200)]
QXL: fix reloading of vram64 attribute

Commit b4a5fd95 introduced vram64 attribute for QXL video device but
there were two issues.  Only function
qemuMonitorJSONUpdateVideoVram64Size should update the vram64 attribute
and also the value is in MiB, not in B.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoesxStorageVolGetXMLDesc: Lookup SCSI lun properly
Michal Privoznik [Tue, 31 May 2016 10:12:13 +0000 (12:12 +0200)]
esxStorageVolGetXMLDesc: Lookup SCSI lun properly

So the idea is as follows: firstly we obtain a list of all the
luns, then iterate over it trying to find the one we want to work
with and after all the iterations we detect whether we have found
something. Now, the last check is broken, because it compares a
value form previous iteration, not the one we've just been
through.

Then, when computing md5 sum of lun's UUID, we use wrong variable
again. Well, @hostScsiDisk which is type of esxVI_HostScsiDisk
extends esxVI_ScsiLun type so they both have the uuid member, but
it just doesn't feel right to access the data via two different
variables in one function call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuMonitorTextGetAllBlockStatsInfo: Fix line validation
Michal Privoznik [Tue, 31 May 2016 10:23:24 +0000 (12:23 +0200)]
qemuMonitorTextGetAllBlockStatsInfo: Fix line validation

There's a bug in the function. We expect the following format for
the data we are parsing here:

  key: value

So we use strchr() to find ':' and then see if it is followed by
space. But the check that does just that is slightly incorrect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirSocketAddrIsPrivate: Work on 32bits platforms
Michal Privoznik [Mon, 30 May 2016 13:45:19 +0000 (15:45 +0200)]
virSocketAddrIsPrivate: Work on 32bits platforms

Yet another one of those where signed int (or long int) is not
enough. And useless to as we're aiming at unsigned anyway.

../../src/util/virsocketaddr.c: In function 'virSocketAddrIsPrivate':
../../src/util/virsocketaddr.c:289:45: error: result of '192l << 24' requires 33 bits to represent, but 'long int' only has 32 bits [-Werror=shift-overflow=]
        return ((val & 0xFFFF0000) == ((192L << 24) + (168 << 16)) ||
                                             ^~
../../src/util/virsocketaddr.c:290:45: error: result of '172l << 24' requires 33 bits to represent, but 'long int' only has 32 bits [-Werror=shift-overflow=]
                (val & 0xFFF00000) == ((172L << 24) + (16  << 16)) ||
                                             ^~
cc1: all warnings being treated as errors

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoapibuild: Substitute only pure number tokens
Michal Privoznik [Mon, 30 May 2016 13:38:07 +0000 (15:38 +0200)]
apibuild: Substitute only pure number tokens

In 38df47c9af1 I've tried to prepare our apibuild.py script for
change made in 0628f3498ce (1U << 31). What I've done in the
former commit was to replace \d+U in parsed tokens with \d.
Problem was, my regular expression there was not quite right as
it also translated VIR_123U_VAL into VIR_123_VAL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agobuild: use gnulib's unsetenv
Michal Privoznik [Sat, 28 May 2016 21:13:26 +0000 (23:13 +0200)]
build: use gnulib's unsetenv

Now that gnulib has lifted it's licensing of unsetenv, we should
use it. Just like we use its counterpart - setenv, already.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoTurn 1<<31 into 1U<<31
Michal Privoznik [Sat, 28 May 2016 11:38:46 +0000 (13:38 +0200)]
Turn 1<<31 into 1U<<31

Apparently, 1 << 31 is signed which in turn does not fit into
a signed integer variable:

../../include/libvirt/libvirt-domain.h:1881:57: error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=]
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */
                                                         ^~
cc1: all warnings being treated as errors

The solution is to make it an unsigned value. I've found only two
such occurrences in our code base.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agodocs: Teach apibuild to deal with (1U << 31) too
Michal Privoznik [Sat, 28 May 2016 11:21:43 +0000 (13:21 +0200)]
docs: Teach apibuild to deal with (1U << 31) too

The apibuild script is a terrifying beast that parses some source
files of ours and produces an XML representation of them. When it
comes to parsing enums we have in some header files, it tries to
be clever and detect a value that an enum member has (or if it is
an alias for a different member). Whilst doing that it has to
deal with values we give to the members in many formats. At some
places we just pass the value in decimal:

    VIR_DOMAIN_BLOCK_JOB_TYPE_PULL = 1,

in other places, we use the aliasing:

    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE = VIR_CONNECT_LIST_DOMAINS_ACTIVE,

and in other places bitwise shifts are used:

    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */

The script tries to parse all of these resulting in the following
tokens: "1", "VIR_CONNECT_LIST_DOMAINS_ACTIVE", "1<<31"; Then, the
script tries to turn these into integers using python's eval()
function. This function succeeds on the first and the last
tokens. But, if we were to modify the last example so that it's
of the following form:

    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1U << 31, /* enforce requested stats */

the token representing enum's member value will then be "1U<<31".
So our parsing is good. Unfortunately, python is not aware of the
difference between signed and unsigned C types, therefore eval()
fails over this token and the parser falls back thinking it's an
alias to another enum member. Well it's not.

The solution is to transform [0-9]U into [0-9] as for our
purposes here it's the same thing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agomaint: update to latest gnulib
Eric Blake [Mon, 4 Jan 2016 20:45:51 +0000 (13:45 -0700)]
maint: update to latest gnulib

Fix a regression in checking for realpath (which caused link
failures regarding duplicate rpl_canonicalize_file_name), and
fix the mingw build regarding unsetenv.

* .gnulib: Update to latest.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agospec: Advertise nvram paths of official fedora edk2 builds
Cole Robinson [Fri, 20 May 2016 19:50:16 +0000 (15:50 -0400)]
spec: Advertise nvram paths of official fedora edk2 builds

Fedora now ships edk2 firmware in its official repos, so adapt
the nvram path list to match. Eventually we can remove the nightly
links as well once some integration kinks have been worked out,
and documentation updated.

Move the macro building into the %build target, which lets us
build up a shell variable and make things a bit more readable

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

8 years agolxc: Fix virLXCDomainObjBeginJob position in lxcDomainSetMemoryParameters
Katerina Koukiou [Fri, 27 May 2016 09:23:20 +0000 (12:23 +0300)]
lxc: Fix virLXCDomainObjBeginJob position in lxcDomainSetMemoryParameters

Adjust the code to perform the virLXCDomainObjBeginJob first
and then the call virDomainLiveConfigHelperMethod.
As Ján Tomko pointed out, in virDomainLiveConfigHelperMethod,
there is a check to see if the domain is active when AFFECT_LIVE is set.
Since virLXCDomainObjBeginJob unlocks the virDomainObjPtr lock,
the domain could possibly be destroyed while we wait for the job
and the check results would no longer be valid.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
8 years agomaint: update to latest gnulib
Eric Blake [Mon, 4 Jan 2016 20:45:51 +0000 (13:45 -0700)]
maint: update to latest gnulib

Pulls in several portability fixes, including the fact that gnulib
now only works on platforms with two's complement signed integers.
Also makes for a smaller delta on the next update (we are waiting
on a license change to unsetenv for the sake of mingw).

* .gnulib: Update to latest.
* bootstrap: Resync from upstream.
* tests/virstringtest.c: Drop use of obsolete probes of integer
properties.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agoesx: do not store escaped password in esxVI_Context.
Dawid Zamirski [Thu, 26 May 2016 15:30:11 +0000 (11:30 -0400)]
esx: do not store escaped password in esxVI_Context.

This patch fixes an issue where screenshot API call was failing when
the esx/vcenter password contains special characters such as
apostrophee. The reason for failures was that passwords were escaped
for XML and stored in esxVI_Context which was then passed to raw CURL
API calls where the password must be passed in original form to
authenticate successfully. So this patch addresses this by storing
original passwords in the esxVI_Context struct and escape only for
esxVI_Login call.