]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agodomain: Allow 'model' attribute for ide controller
Dawid Zamirski [Tue, 24 Oct 2017 19:35:32 +0000 (15:35 -0400)]
domain: Allow 'model' attribute for ide controller

The optional values are 'piix3', 'piix4' or 'ich6'. Those will be
needed to allow setting IDE controller model in VirtualBox driver.

7 years agovbox: Add more IStorageController API mappings
Dawid Zamirski [Tue, 24 Oct 2017 19:35:31 +0000 (15:35 -0400)]
vbox: Add more IStorageController API mappings

This patch exposes additional methods of the native VBOX API to the
libvirt 'unified' vbox API to deal with IStorageController. The exposed
methods are:

* IStorageController->GetStorageControllerType()
* IStorageController->SetStorageControllerType()
* IMachine->GetStorageControllers()

7 years agovbox: Support empty removable drives.
Dawid Zamirski [Tue, 24 Oct 2017 19:35:30 +0000 (15:35 -0400)]
vbox: Support empty removable drives.

Original code was checking for non empty disk source before proceeding
to actually attach disk device to VM. This prevented from creating
empty removable devices like DVD or floppy. Therefore, this patch
re-organizes the loop work-flow to allow such configurations as well as
makes the code follow better libvirt practices. Additionally, adjusted
debug logs to be more helpful - removed old ones and added new which
give more valuable info for troubleshooting.

7 years agovbox: Errors in vboxAttachDrives are now critical
Dawid Zamirski [Tue, 24 Oct 2017 19:35:29 +0000 (15:35 -0400)]
vbox: Errors in vboxAttachDrives are now critical

Previously, if one tried to define a VBOX VM and the API failed to
perform the requested actions for some reason, it would just log the
error and move on to process remaining disk definitions. This is not
desired as it could result in incorrectly defined VM without the caller
even knowing about it. So now all the code paths that call
virReportError are now treated as hard failures as they should have
been.

7 years agovbox: Remove unused mediumEmpty
Dawid Zamirski [Fri, 3 Nov 2017 11:49:32 +0000 (07:49 -0400)]
vbox: Remove unused mediumEmpty

Remove the setting since it's unused as of commit 34364df3 which should
have never copied it in from the old code which ended up getting removed
as part of commit c7c286c6.

7 years agovbox: Cleanup vboxAttachDrives implementation
Dawid Zamirski [Tue, 24 Oct 2017 19:35:28 +0000 (15:35 -0400)]
vbox: Cleanup vboxAttachDrives implementation

This commit primes vboxAttachDrives for further changes so when they
are made, the diff is less noisy:

* move variable declarations to the top of the function
* add disk variable to replace all the def->disks[i] instances
* add cleanup at the end of the loop body, so it's all in one place
  rather than scattered through the loop body. It's purposefully
  called 'cleanup' rather than 'skip' or 'continue' because future
  commit will treat errors as hard-failures.

7 years agovbox: vboxAttachDrives now relies on address info
Dawid Zamirski [Tue, 24 Oct 2017 19:35:27 +0000 (15:35 -0400)]
vbox: vboxAttachDrives now relies on address info

Previously, the driver was computing VBOX's devicePort/deviceSlot values
based on device name and max port/slot values. While this worked, it
completely ignored <address> values. Additionally, libvirt's built-in
virDomainDiskDefAssignAddress already does a good job  setting default
values on virDomainDeviceDriveAddress struct which we can use to set
devicePort and deviceSlot and accomplish the same result while allowing
the customizing those via XML. Also, this allows to remove some code
which will make further patches smaller.

7 years agovbox: Close media when undefining domains
Dawid Zamirski [Tue, 24 Oct 2017 19:35:25 +0000 (15:35 -0400)]
vbox: Close media when undefining domains

When registering a VM we call OpenMedium on each disk image which adds it
to vbox's global media registry. Therefore, we should make sure to call
Close when unregistering VM so we cleanup the media registry entries
after ourselves - this does not remove disk image files. This follows
the behaviour of the VBoxManage unregistervm command.

7 years agovbox: Update ATTRIBUTE_UNUSED usage
Dawid Zamirski [Tue, 24 Oct 2017 19:35:24 +0000 (15:35 -0400)]
vbox: Update ATTRIBUTE_UNUSED usage

Since the removal of VBOX <= 3x, the function arguments are actually
used so they should not be marked with ATTRIBUTE_UNUSED anymore.

7 years agocfg.mk: Prohibit backspace alignment attempts
Andrea Bolognani [Tue, 31 Oct 2017 13:12:52 +0000 (14:12 +0100)]
cfg.mk: Prohibit backspace alignment attempts

Now that our codebase is clean, we can add a syntax-check rule
to ensure it will remain so.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoRemove backslash alignment attempts
Andrea Bolognani [Fri, 3 Nov 2017 12:09:47 +0000 (13:09 +0100)]
Remove backslash alignment attempts

Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: domain: skip chain detection to end of backing chain
Peter Krempa [Fri, 29 Sep 2017 10:02:29 +0000 (12:02 +0200)]
qemu: domain: skip chain detection to end of backing chain

When a user provides the backing chain, we will not need to re-detect
all the backing stores again, but should move to the end of the user
specified chain. Additionally if a user provides a full terminated chain
we should not attempt any further detection.

7 years agoqemu: domain: Prepare TLS data for the whole backing chain
Peter Krempa [Fri, 20 Oct 2017 13:33:35 +0000 (15:33 +0200)]
qemu: domain: Prepare TLS data for the whole backing chain

Iterate through the backing chain when setting up TLS for disks.

7 years agoqemu: domain: Remove pointless alias check
Peter Krempa [Fri, 20 Oct 2017 13:12:49 +0000 (15:12 +0200)]
qemu: domain: Remove pointless alias check

When attaching the disks, aliases are always generated.

7 years agoqemu: domain: Destroy secrets for complete backing chain
Peter Krempa [Fri, 20 Oct 2017 12:16:28 +0000 (14:16 +0200)]
qemu: domain: Destroy secrets for complete backing chain

7 years agoqemu: domain: Extract setup for disk source secrets
Peter Krempa [Fri, 20 Oct 2017 11:50:23 +0000 (13:50 +0200)]
qemu: domain: Extract setup for disk source secrets

Separate it so that it deals only with single virStorageSource, so that
it can later be reused for full backing chain support.

Two aliases are passed since authentication is more relevant to the
'storage backend' whereas encryption is more relevant to the protocol
layer. When using node names, the aliases will be different.

7 years agoqemu: domain: Simplify using DAC permissions of top of backing chain
Peter Krempa [Mon, 16 Oct 2017 12:10:09 +0000 (14:10 +0200)]
qemu: domain: Simplify using DAC permissions of top of backing chain

qemuDomainGetImageIds and qemuDomainStorageFileInit are helpful when
trying to access a virStorageSource from the qemu driver since they
figure out the correct uid and gid for the image.

When accessing members of a backing chain the permissions for the top
level would be used. To allow using specific permissions per backing
chain level but still allow inheritance from the parent of the chain we
need to add a new parameter to the image ID APIs.

7 years agosecurity: selinux: Take parent security label into account
Peter Krempa [Tue, 17 Oct 2017 06:03:42 +0000 (08:03 +0200)]
security: selinux: Take parent security label into account

Until now we ignored user-provided backing chains and while detecting
the code inherited labels of the parent device. With user provided
chains we should keep this functionality, so label of the parent image
in the backing chain will be applied if an image-specific label is not
present.

7 years agosecurity: dac: Take parent security label into account
Peter Krempa [Tue, 17 Oct 2017 06:03:42 +0000 (08:03 +0200)]
security: dac: Take parent security label into account

Until now we ignored user-provided backing chains and while detecting
the code inherited labels of the parent device. With user provided
chains we should keep this functionality, so label of the parent image
in the backing chain will be applied if an image-specific label is not
present.

7 years agosecurity: selinux: Pass parent storage source into image labeling helper
Peter Krempa [Tue, 17 Oct 2017 05:25:51 +0000 (07:25 +0200)]
security: selinux: Pass parent storage source into image labeling helper

virSecuritySELinuxSetImageLabelInternal assigns different labels to
backing chain members than to the parent image. This was done via the
'first' flag. Convert it to passing in pointer to the parent
virStorageSource. This will allow us to use the parent virStorageSource
in further changes.

7 years agostorage: Extract error reporting for broken chains
Peter Krempa [Mon, 16 Oct 2017 11:53:30 +0000 (13:53 +0200)]
storage: Extract error reporting for broken chains

Simplify reporting the error if backing chain is broken for further
callers by extracting it into a separate function.

7 years agostorage: Add feature check for storage file backend supporting access check
Peter Krempa [Mon, 16 Oct 2017 11:42:21 +0000 (13:42 +0200)]
storage: Add feature check for storage file backend supporting access check

When the user provides backing chain, we don't need the full support for
traversing the backing chain. This patch adds a feature check for the
virStorageSourceAccess API.

7 years agostorage: Extract common code to retrieve driver backend for support check
Peter Krempa [Mon, 16 Oct 2017 11:23:51 +0000 (13:23 +0200)]
storage: Extract common code to retrieve driver backend for support check

The 'file access' module of the storage driver has few feature checks to
determine whether libvirt supports given storage driver method. The code
to retrieve the driver struct needed for the check is the same so it can
be extracted.

7 years agoqemu: Add support for block-incremental migration parameter
Jiri Denemark [Thu, 26 Oct 2017 19:51:37 +0000 (21:51 +0200)]
qemu: Add support for block-incremental migration parameter

We handle incremental storage migration in a different way. The support
for this new (as of QEMU 2.10) parameter is only needed for full
coverage of migration parameters used by QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Add support for max-bandwidth migration parameter
Jiri Denemark [Thu, 26 Oct 2017 18:47:16 +0000 (20:47 +0200)]
qemu: Add support for max-bandwidth migration parameter

We already support several ways of setting migration bandwidth and this
is not adding another one. With this patch we are able to read and write
this parameter using query-migrate-parameters and migrate-set-parameters
in one call with all other parameters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Rename TLS related migration parameters
Jiri Denemark [Thu, 26 Oct 2017 18:11:47 +0000 (20:11 +0200)]
qemu: Rename TLS related migration parameters

The parameters used "migrate" prefix which is pretty redundant and
qemuMonitorMigrationParams structure is our internal representation of
QEMU migration parameters and it is supposed to use names which match
QEMU names.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Add support for setting downtime-limit migration parameter
Jiri Denemark [Mon, 23 Oct 2017 14:55:02 +0000 (16:55 +0200)]
qemu: Add support for setting downtime-limit migration parameter

We already support setting the maximum downtime with a dedicated
virDomainMigrateSetMaxDowntime API. This patch does not implement
another way of setting the downtime by adding a new public migration
parameter. It just makes sure any parameter we are able to get from a
QEMU monitor by query-migrate-parameters can be passed back to QEMU via
migrate-set-parameters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemumonitorjsontest: Rename 2nd CHECK macro in migration params test
Jiri Denemark [Thu, 26 Oct 2017 18:52:32 +0000 (20:52 +0200)]
qemumonitorjsontest: Rename 2nd CHECK macro in migration params test

The second CHECK macro was used for string parameters. Let's rename it
to CHECK_STR and move it up to have all checks in one place.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemumonitorjsontest: Rename 1st CHECK macro in migration params test
Jiri Denemark [Thu, 26 Oct 2017 18:50:35 +0000 (20:50 +0200)]
qemumonitorjsontest: Rename 1st CHECK macro in migration params test

The first CHECK macro in the test is used for checking integer values.
Let's make it a bit more generic to be usable for any numeric type and
use it for a new CHECK_INT macro.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Drop giant if statement from qemuMonitorSetMigrationParams
Jiri Denemark [Thu, 26 Oct 2017 20:10:31 +0000 (22:10 +0200)]
qemu: Drop giant if statement from qemuMonitorSetMigrationParams

The check can be easily replaced with a simple test in the JSON
implementation and we don't need to update it every time a new parameter
is added.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use macro for setting string migration parameters
Jiri Denemark [Mon, 23 Oct 2017 15:06:57 +0000 (17:06 +0200)]
qemu: Use macro for setting string migration parameters

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Generalize APPEND macro in qemuMonitorJSONSetMigrationParams
Jiri Denemark [Mon, 23 Oct 2017 15:03:25 +0000 (17:03 +0200)]
qemu: Generalize APPEND macro in qemuMonitorJSONSetMigrationParams

The APPEND macro is now be usable for any type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use macro for parsing ull migration parameters
Jiri Denemark [Mon, 23 Oct 2017 15:17:58 +0000 (17:17 +0200)]
qemu: Use macro for parsing ull migration parameters

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use macro for parsing string migration parameters
Jiri Denemark [Mon, 23 Oct 2017 15:15:32 +0000 (17:15 +0200)]
qemu: Use macro for parsing string migration parameters

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Generalize PARSE macro in qemuMonitorJSONGetMigrationParams
Jiri Denemark [Mon, 23 Oct 2017 15:11:10 +0000 (17:11 +0200)]
qemu: Generalize PARSE macro in qemuMonitorJSONGetMigrationParams

The macro (now called PARSE_SET) is now usable for any type which needs
a *_set bool for indicating a valid value.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocpu_map: Add cqm alternative name for cmt
Jiri Denemark [Thu, 2 Nov 2017 13:03:14 +0000 (14:03 +0100)]
cpu_map: Add cqm alternative name for cmt

Linux kernel shows our "cmt" feature as "cqm". Let's mention the name in
the cpu_map.xml to make it easier to find.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoPost-release version bump to 3.10.0
Jiri Denemark [Thu, 2 Nov 2017 20:43:00 +0000 (21:43 +0100)]
Post-release version bump to 3.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoRelease of libvirt-3.9.0
Daniel Veillard [Thu, 2 Nov 2017 17:12:45 +0000 (18:12 +0100)]
Release of libvirt-3.9.0

* docs/news.xml: update for release
* po/*po*: regenerated

7 years agonews: Update for 3.9.0 release
Andrea Bolognani [Wed, 1 Nov 2017 16:12:21 +0000 (17:12 +0100)]
news: Update for 3.9.0 release

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Skip tests requiring JSON_MODELS if QEMU is disabled
Jiri Denemark [Wed, 1 Nov 2017 17:35:57 +0000 (18:35 +0100)]
cputest: Skip tests requiring JSON_MODELS if QEMU is disabled

Some tests require JSON_MODELS to be parsed into qemuCaps and applied
when computing CPU models and such test cannot succeed if QEMU driver is
disabled. Let's mark the tests with JSON_MODELS_REQUIRED and skip the
appropriate parts if building without QEMU.

On the other hand, CPU tests with JSON_MODELS should succeed even if
model definitions from QEMU are not parsed and applied. Let's explicitly
test this by repeating the tests without JSON_MODELS set.

This fixes the build with QEMU driver disabled, e.g., on some
architectures on RHEL/CentOS.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agospec: Restart libvirtd in posttrans
Jiri Denemark [Mon, 23 Oct 2017 11:06:44 +0000 (13:06 +0200)]
spec: Restart libvirtd in posttrans

When upgrading libvirt packages, there's no strict ordering for the
installation or removal of the individual libvirt sub packages. Thus
libvirt-daemon may be upgraded (and its %postun scriptlet) started
before all sub packages with driver libraries are upgraded. When
libvirt-daemon's %postun scriptlet restarts the daemon old drivers may
still be laying around and the daemon may crash when it tries to use
them.

Let's restart the daemon in %posttrans to make sure libvirtd is
restarted only after all sub packages are at the same version.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agovirNetDevSupportBandwidth: Enable QoS for vhostuser
Michal Privoznik [Wed, 25 Oct 2017 10:45:03 +0000 (12:45 +0200)]
virNetDevSupportBandwidth: Enable QoS for vhostuser

Since vhostuser type is really a tap that is just plugged into
different type of bridge, supporting QoS is trivial.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuDomainSetInterfaceParameters: Explicitly reject unsupported net types
Michal Privoznik [Wed, 25 Oct 2017 10:42:41 +0000 (12:42 +0200)]
qemuDomainSetInterfaceParameters: Explicitly reject unsupported net types

For instance, NET_TYPE_MCAST doesn't support setting QoS. Instead
of claiming success and doing nothing, we should be explicit
about that and report an error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuhotplugtest: Test user supplied alias
Michal Privoznik [Sun, 22 Oct 2017 13:42:45 +0000 (15:42 +0200)]
qemuhotplugtest: Test user supplied alias

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu.conf: Clarify the various _tls_x509_cert_dir descriptions
John Ferlan [Fri, 27 Oct 2017 09:23:25 +0000 (05:23 -0400)]
qemu.conf: Clarify the various _tls_x509_cert_dir descriptions

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

Apparantly commit id 'dc4c2f75a' wasn't specific enough, so here's
a few more clarifications.

7 years agodocs: Add news article
John Ferlan [Fri, 6 Oct 2017 20:47:13 +0000 (16:47 -0400)]
docs: Add news article

7 years agostorage: Allow creation of a LUKS using logical volume
John Ferlan [Fri, 6 Oct 2017 20:30:47 +0000 (16:30 -0400)]
storage: Allow creation of a LUKS using logical volume

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

Use virStorageBackendCreateVolUsingQemuImg to apply the LUKS information
to the logical volume just created.  As part of the processing of the
lvcreate command add 2MB to the capacity to account for the LUKS header
when it's determined that the volume desires to use encryption.

7 years agostorage: Introduce virStorageBackendCreateVolUsingQemuImg
John Ferlan [Fri, 6 Oct 2017 20:29:21 +0000 (16:29 -0400)]
storage: Introduce virStorageBackendCreateVolUsingQemuImg

Create a shim that will allow other backends to make use of qemu-img
functionality to create or possibly modify the volume.

7 years agostorage: Extract out the LVCREATE
John Ferlan [Fri, 6 Oct 2017 16:45:01 +0000 (12:45 -0400)]
storage: Extract out the LVCREATE

Refactor to extract out the LVCREATE command.  This also removes the
need for the local @created since the error path can now only be reached
after the creation of the logical volume.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Add news article for bug fix
John Ferlan [Fri, 6 Oct 2017 18:12:21 +0000 (14:12 -0400)]
docs: Add news article for bug fix

7 years agostorage: Properly resize a local volume using LUKS
John Ferlan [Fri, 6 Oct 2017 16:04:19 +0000 (12:04 -0400)]
storage: Properly resize a local volume using LUKS

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

Turns out the virStorageBackendVolResizeLocal did not differentiate
whether the target volume was a LUKS volume or not and just blindly
did the ftruncate() on the target volume.

Follow the volume creation logic (in general) and create a qemu-img
resize command to resize the target volume for LUKS ensuring that
the --object secret is provided as well as the '--image-opts' used
by the qemu-img resize logic to describe the path and secret ensuring
that it's using the luks driver on the volume of course.

7 years agostorage: Alter storageBackendCreateQemuImgSecretObject args
John Ferlan [Fri, 6 Oct 2017 15:06:13 +0000 (11:06 -0400)]
storage: Alter storageBackendCreateQemuImgSecretObject args

Since all that was really needed was a couple of fields and building
the object can be more generic, let's alter the args a bit. This will
be useful shortly for adding the secret object for a volume resize
operation on a luks volume that will need a secret object.

7 years agostorage: Add error path for virStorageBackendCreateQemuImgCmdFromVol
John Ferlan [Fri, 6 Oct 2017 16:12:38 +0000 (12:12 -0400)]
storage: Add error path for virStorageBackendCreateQemuImgCmdFromVol

Rather than inline the various free's and return NULL, just create
an error label.

7 years agostorage: Alter args to storageBackendResizeQemuImg
John Ferlan [Fri, 6 Oct 2017 14:08:36 +0000 (10:08 -0400)]
storage: Alter args to storageBackendResizeQemuImg

Rather than passing just the path, pass the virStorageVolDefPtr as we're
going to need it shortly.

Also fix the order of code and stack variables in the calling function
virStorageBackendVolResizeLocal.

7 years agovirt-aa-helper-test: only fails go to stdout by default
Christian Ehrhardt [Thu, 26 Oct 2017 13:22:11 +0000 (15:22 +0200)]
virt-aa-helper-test: only fails go to stdout by default

By Default (without -d) the tests will only print Failures.
So a log should follow general "no message is a good message" style.

But the testfw checks always emit the skip info to stdout. Instead
they should use the redirection that is controlled by -d.

This avoids mesages like the following to clutter the log:
  Skipping FW AAVMF32 test. Could not find /usr/share/AAVMF/AAVMF32_CODE.fd

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agovirt-aa-helper: apparmor wildcards to forbidden chars
Christian Ehrhardt [Thu, 26 Oct 2017 13:22:10 +0000 (15:22 +0200)]
virt-aa-helper: apparmor wildcards to forbidden chars

Some globbing chars in the domain name could be used to break out of
apparmor rules, so lets forbid these when in virt-aa-helper.

Also adding a test to ensure all those cases were detected as bad char.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoqemu: Fix memory leak in virQEMUCapsLoadCPUModels
Marc Hartmayer [Fri, 27 Oct 2017 07:53:03 +0000 (09:53 +0200)]
qemu: Fix memory leak in virQEMUCapsLoadCPUModels

Don't leak @blockNodes in the loop.

==226576== 7,120 bytes in 60 blocks are definitely lost in loss record 122 of 125
==226576==    at 0x4835214: calloc (vg_replace_malloc.c:711)
==226576==    by 0x4950D7B: virAllocN (viralloc.c:191)
==226576==    by 0x49EB5BB: virXPathNodeSet (virxml.c:676)
==226576==    by 0x104DB67: virQEMUCapsLoadCPUModels (qemu_capabilities.c:3738)
==226576==    by 0x105510D: virQEMUCapsLoadCache (qemu_capabilities.c:3929)
==226576==    by 0x104459F: qemuTestParseCapabilities (testutilsqemu.c:498)
==226576==    by 0x1040DC9: testQemuCapsCopy (qemucapabilitiestest.c:105)
==226576==    by 0x1041F07: virTestRun (testutils.c:180)
==226576==    by 0x1040B45: mymain (qemucapabilitiestest.c:181)
==226576==    by 0x104320F: virTestMain (testutils.c:1119)
==226576==    by 0x1041149: main (qemucapabilitiestest.c:193)

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agodaemon: remove minsize directive from hypervisor logrotate files
Jim Fehlig [Thu, 26 Oct 2017 17:23:07 +0000 (11:23 -0600)]
daemon: remove minsize directive from hypervisor logrotate files

Commit 6c43149c removed the minsize directive from the qemu logrotate
file but missed other hypervisors. Remove minsize from the libxl, lxc,
and uml logrotate files as well.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: logrotate: drop minsize directive
Jim Fehlig [Wed, 25 Oct 2017 21:09:20 +0000 (15:09 -0600)]
qemu: logrotate: drop minsize directive

On a cloud host it is possible to create 100's of unique instances
per day, each leaving behind a /var/log/libvirt/qemu/instance-name.log
file that is < 100k. With the current 'minsize 100k' directive, these
files are never rotated and hence never removed. Over months of time,
tens of thousands of these files can accumulate on the host.

Dropping 'minsize 100k' allows rotating small files, which will
increase the number of log files, but 'rotate 4' ensures they will
be removed after a month.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agovirt-aa-helper: fix libusb access to udev usb descriptions
Christian Ehrhardt [Wed, 25 Oct 2017 12:42:08 +0000 (14:42 +0200)]
virt-aa-helper: fix libusb access to udev usb descriptions

In bf3a4140 "virt-aa-helper: fix libusb access to udev usb data" the
libusb access to properly detect the device/bus ids was fixed.

The path /run/udev/data/+usb* contains a subset of that information we
already allow to be read and are currently not needed for the function
qemu needs libusb for. But on the init of libusb all those files are
still read so a lot of apparmor denials can be seen when using usb host
devices, like:
  apparmor="DENIED" operation="open" name="/run/udev/data/+usb:2-1.2:1.0"
  comm="qemu-system-x86" requested_mask="r" denied_mask="r"

Today we could silence the warnings with a deny rule without breaking
current use cases. But since the data in there is only a subset of those
it can read already it is no additional information exposure. And on the
other hand a future udev/libusb/qemu combination might need it so allow
the access in the default apparmor profile.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agovirt-aa-helper: grant locking permission on -f
Christian Ehrhardt [Tue, 24 Oct 2017 14:54:59 +0000 (16:54 +0200)]
virt-aa-helper: grant locking permission on -f

Hot-adding disks does not parse the full XML to generate apparmor rules.
Instead it uses -f <PATH> to append a generic rule for that file path.

580cdaa7: "virt-aa-helper: locking disk files for qemu 2.10" implemented
the qemu 2.10 requirement to allow locking on disks images that are part of
the domain xml.

But on attach-device a user will still trigger an apparmor deny by going
through virt-aa-helper -f, to fix that add the lock "k" permission to the
append file case of virt-aa-helper.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoconf: Avoid leaking blockers from virDomainCapsCPUModel
Jiri Denemark [Thu, 26 Oct 2017 10:20:45 +0000 (12:20 +0200)]
conf: Avoid leaking blockers from virDomainCapsCPUModel

When adding CPU usability blockers I forgot to properly free them when
in virDomainCapsCPUModelsDispose.

Reported-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoIncrease default file handle limits for virtlockd
Christian Ehrhardt [Wed, 18 Oct 2017 09:19:30 +0000 (11:19 +0200)]
Increase default file handle limits for virtlockd

The assumption so far was an average of 4 disks per guest.
But some architectures, like s390x, still often use plenty of smaller disks.

To include those in the considerations an assumption of an average of 10
disks is more reasonable.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoIncrease default file handle limits for virtlogd
Christian Ehrhardt [Wed, 18 Oct 2017 09:19:29 +0000 (11:19 +0200)]
Increase default file handle limits for virtlogd

The initial assumption was ~2 files per guest, but some common setups
like Openstack drive up to 4 files per guest.

E.g. on Arm where the following XML leads to 4 file handles:
    <serial type='file'>
      <source path='/var/lib/nova/instances/7c0dcd78-.../console.log'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='file'>
      <source path='/var/lib/nova/instances/7c0dcd78-.../console.log'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>

With that in mind and the target to support 4k guests by default we
should raise the limit to 16k.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoqemu: Enabled pause-before-switchover migration capability
Jiri Denemark [Fri, 20 Oct 2017 08:12:21 +0000 (10:12 +0200)]
qemu: Enabled pause-before-switchover migration capability

QEMU identified a race condition between the device state serialization
and the end of storage migration. Both QEMU and libvirt needs to be
updated to fix this.

Our migration work flow is modified so that after starting the migration
we to wait for QEMU to enter "pre-switchover", "postcopy-active", or
"completed" state. Once there, we cancel all block jobs as usual. But if
QEMU is in "pre-switchover", we need to resume the migration afterwards
and wait again for the real end (either "postcopy-active" or
"completed" state).

Old QEMU will just enter either "postcopy-active" or "completed"
directly, which is still correctly handled even by new libvirt. The
"pre-switchover" state will only be entered if QEMU supports it and the
pause-before-switchover capability was enabled. Thus all combinations of
libvirt and QEMU will work, but only new QEMU with new libvirt will
avoid the race condition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Add pause-before-switchover migration capability
Jiri Denemark [Fri, 20 Oct 2017 08:11:32 +0000 (10:11 +0200)]
qemu: Add pause-before-switchover migration capability

This new capability enables a pause before device state serialization so
that we can finish all block jobs without racing with the end of the
migration. The pause is indicated by "pre-switchover" state. Once we're
done QEMU enters "device" migration state.

This patch just defines the new capability and QEMU migration states and
their mapping to our job states.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Add support for migrate-continue QMP command
Jiri Denemark [Fri, 20 Oct 2017 07:17:09 +0000 (09:17 +0200)]
qemu: Add support for migrate-continue QMP command

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agodocs: Drop mention that WWN for disks must be unique
Peter Krempa [Thu, 26 Oct 2017 08:28:12 +0000 (10:28 +0200)]
docs: Drop mention that WWN for disks must be unique

For multipath disks it might be useful to have the same WWN for multiple
disks. It's the users choice to do so. Since we dropped the check that
disallows using duplicate WWNs drop the docs as well.

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

7 years agovbox: Read runtime RDP port and handle autoport
Dawid Zamirski [Tue, 24 Oct 2017 21:09:17 +0000 (17:09 -0400)]
vbox: Read runtime RDP port and handle autoport

VirutalBox has a IVRDEServerInfo structure available that
gives the effective runtime port that the VM is using when it's
running. This is useful when the "TCP/Ports" VBox property was set to
port range (e.g. via autoport = "yes" or via VBoxManage) in which
case it would be impossible to get the "active" port otherwise.

7 years agovbox: Make autoport set RDP port range.
Dawid Zamirski [Tue, 24 Oct 2017 21:09:16 +0000 (17:09 -0400)]
vbox: Make autoport set RDP port range.

Originally autoport in vbox driver was setting the port to default value
(3389) which caused multiple VM instances use the same port. Since
libvirt XML does not allow to set port ranges, this patch changes the
"autoport" behavior to set VBox's "TCP/Ports" property to an arbitrary
port range (3389-3689) to avoid that issue.

7 years agovbox: Remove old unflexible macros
Dawid Zamirski [Tue, 24 Oct 2017 21:09:15 +0000 (17:09 -0400)]
vbox: Remove old unflexible macros

The VBOX_SESSION_OPEN/CLOSE macros are only called in
_vboxDomainSnapshotRestore and they are unflexible because:

* assume the caller will have variable named "data"
* can only create Write lock type

As per above, it's not that hard to simply use the VBOX API directly.

7 years agovirsh: domain: Fix option handling in domxml-to-native
Peter Krempa [Tue, 10 Oct 2017 15:19:10 +0000 (17:19 +0200)]
virsh: domain: Fix option handling in domxml-to-native

Commit fdeac7a05fdf85458d72e89efcfa0f444525aaad tried to fix the output
of 'virsh domxml-to-native --help' by switching types around. One of the
changes broke the option parser. VSH_OT_ARGV should be used only for
variable argument count, not to make the help generator look pretty.

The correct option type in this case is VSH_OT_STRING as it's not
mandatory now since it can be substituted by using --domain.

This makes --help for this command look incorrect, but the parser works
as it should.

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

7 years agoqemu: Reset hasManagedSave after removing a corrupted image
Jiri Denemark [Tue, 24 Oct 2017 08:32:03 +0000 (10:32 +0200)]
qemu: Reset hasManagedSave after removing a corrupted image

When starting a domain with managed save image, we try to restore it
first. If the image is corrupted, we silently unlink it and just
normally start the domain. At this point the domain has no managed save
image, yet we did not reset the hasManagedSave flag.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoiohelper: use saferead if later write with O_DIRECT
Nikolay Shirokovskiy [Thu, 28 Sep 2017 07:06:47 +0000 (10:06 +0300)]
iohelper: use saferead if later write with O_DIRECT

One of the usecases of iohelper is to read from pipe and write
to file with O_DIRECT. As we read from pipe we can have partial
read and then we fail to write this data because output file
is open with O_DIRECT and buffer size is not aligned.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Set correct job status when qemuMigrationRun fails
Jiri Denemark [Thu, 19 Oct 2017 12:26:24 +0000 (14:26 +0200)]
qemu: Set correct job status when qemuMigrationRun fails

Instead of enumerating all states which need to be turned into
QEMU_DOMAIN_JOB_STATUS_FAILED (and failing to add all of them), it's
better to mention just the one which needs to be left alone.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Consistently use exit_monitor in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 12:22:53 +0000 (14:22 +0200)]
qemu: Consistently use exit_monitor in qemuMigrationRun

Almost every failure in qemuMigrationRun while we are talking to QEMU
monitor results in a jump to exit_monitor label. The only exception is
removed by this patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Don't misuse "ret" in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 12:21:00 +0000 (14:21 +0200)]
qemu: Don't misuse "ret" in qemuMigrationRun

The "ret" variable is used for storing the return value of a function
and should not be used as a temporary variable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Unite error handling in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 12:15:46 +0000 (14:15 +0200)]
qemu: Unite error handling in qemuMigrationRun

Merge cancel and cancelPostCopy sections with the generic error section,
where we can easily decide whether canceling the ongoing migration is
required.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Split cleanup and error code in qemuMigrationRun
Jiri Denemark [Thu, 19 Oct 2017 13:09:25 +0000 (15:09 +0200)]
qemu: Split cleanup and error code in qemuMigrationRun

Let cleanup only do things common to both failure and success paths and
move error handling code inside the new "error" section.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Refactor qemuMigrationRun a bit
Jiri Denemark [Wed, 18 Oct 2017 13:34:31 +0000 (15:34 +0200)]
qemu: Refactor qemuMigrationRun a bit

Some code which was supposed to be executed only when migration
succeeded was buried inside the cleanup code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use switch in qemuMigrationCompleted
Jiri Denemark [Tue, 17 Oct 2017 19:27:55 +0000 (21:27 +0200)]
qemu: Use switch in qemuMigrationCompleted

When adding a new job state it's useful to let the compiler complain
about places where we need to think about what to do with the new
state.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonews: Document user aliases
Michal Privoznik [Fri, 20 Oct 2017 14:19:07 +0000 (16:19 +0200)]
news: Document user aliases

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agotests: Test user set aliases for qemu
Michal Privoznik [Fri, 20 Oct 2017 14:48:14 +0000 (16:48 +0200)]
tests: Test user set aliases for qemu

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Parse alias from inactive XMLs
Michal Privoznik [Thu, 19 Oct 2017 06:39:40 +0000 (08:39 +0200)]
qemu: Parse alias from inactive XMLs

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

This way users can uniquely identify devices at define time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodocs: Document user aliases
Michal Privoznik [Wed, 18 Oct 2017 11:48:46 +0000 (13:48 +0200)]
docs: Document user aliases

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Format alias even for inactive XMLs
Michal Privoznik [Wed, 18 Oct 2017 11:12:08 +0000 (13:12 +0200)]
conf: Format alias even for inactive XMLs

We need to format alias even for inactive XMLs since that's the
way how users are going to identify their devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuhotplugtest: Load active XML
Michal Privoznik [Tue, 17 Oct 2017 11:13:08 +0000 (13:13 +0200)]
qemuhotplugtest: Load active XML

The point of this test is to load live XML and test hotplug. But
even though the XMLs we are parsing are live, the parsing is done
with VIR_DOMAIN_DEF_PARSE_INACTIVE flag.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuxml2argvdata: Drop device aliases
Michal Privoznik [Tue, 17 Oct 2017 11:27:01 +0000 (13:27 +0200)]
qemuxml2argvdata: Drop device aliases

The qemuxml2argvtest expects the domain XMLs to be inactive ones.
Therefore we should pass inactive XMLs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuDomainABIStabilityCheck: Check for memory aliases too
Michal Privoznik [Tue, 17 Oct 2017 08:42:54 +0000 (10:42 +0200)]
qemuDomainABIStabilityCheck: Check for memory aliases too

Since we will be allowing users to set device aliases and memory
devices are fragile when it comes to aliases we have to make sure
they won't change during migration. Other devices should be fine.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Validate user supplied aliases
Michal Privoznik [Wed, 18 Oct 2017 15:46:18 +0000 (17:46 +0200)]
conf: Validate user supplied aliases

They have to be unique within the domain. As usual, backwards
compatibility takes its price. In this particular situation we
have a device that is represented twice in a domain and so is its
alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Parse user supplied aliases
Michal Privoznik [Wed, 18 Oct 2017 12:59:01 +0000 (14:59 +0200)]
conf: Parse user supplied aliases

If driver that is calling the parse supports user supplied
aliases, they can be parsed even for inactive XMLs. However, to
avoid any clashes with aliases that libvirt generates, the user
ones have to have "ua-" prefix.

Note, that some drivers don't have notion of device aliases at
all. Also, in order to support user supplied aliases some extra
checks need to be done (e.g. during hotplug). Therefore we can't
just enable this feature for all the drivers. Thus we need a flag
that drivers set to tell parsing code that they can handle user
supplied device aliases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu_alias: Be more tolerant if alias don't follow our format
Michal Privoznik [Fri, 20 Oct 2017 11:24:41 +0000 (13:24 +0200)]
qemu_alias: Be more tolerant if alias don't follow our format

When assigning alias to a device we usually iterate over other
devices of its kind trying to find next index. We do this by
stripping down the prefix and then parsing number at the end,
Usually, if the prefix doesn't match the one we are expecting, we
just continue with next iteration. Except for couple of
functions: qemuGetNextChrDevIndex(),
qemuAssignDeviceRedirdevAlias() and qemuAssignDeviceShmemAlias().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoconf: Rename [n]macs and maxmacs to [n]names and maxnames
John Ferlan [Fri, 20 Oct 2017 18:48:23 +0000 (14:48 -0400)]
conf: Rename [n]macs and maxmacs to [n]names and maxnames

To avoid further confusion - rename the array elements to what they are.

7 years agoconf: duplicate interface name instead of MAC provided to lookup the interface
Pavel Hrdina [Fri, 20 Oct 2017 14:01:03 +0000 (16:01 +0200)]
conf: duplicate interface name instead of MAC provided to lookup the interface

Introduced by 6094d6ec7fc9ea3e28c18c880b76858f06a8b129.
Found by running libvirt-perl tests.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: Missing 'removeTimeoutImpl' check variable inside virEventRegisterImpl() function.
Julio Faracco [Thu, 19 Oct 2017 15:35:03 +0000 (13:35 -0200)]
util: Missing 'removeTimeoutImpl' check variable inside virEventRegisterImpl() function.

The function virEventRegisterImpl() checks the attempt to replace the
registered events. But there is a duplicate variable inside the IF statement.
The variable 'removeHandleImpl' was wrongly repeated. One of them needs to be
replaced by 'removeTimeoutImpl'.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Enhance debug message in qemuMonitorSetMigrationCapability
Jiri Denemark [Wed, 18 Oct 2017 10:46:39 +0000 (12:46 +0200)]
qemu: Enhance debug message in qemuMonitorSetMigrationCapability

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Drop qemuMonitorGetMigrationCapability
Jiri Denemark [Tue, 17 Oct 2017 20:01:01 +0000 (22:01 +0200)]
qemu: Drop qemuMonitorGetMigrationCapability

The only remaining user of qemuMonitorGetMigrationCapability is our test
suite. Let's replace qemuMonitorGetMigrationCapability with
qemuMonitorGetMigrationCapabilities there and drop the unused function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use bitmap with migration capabilities
Jiri Denemark [Tue, 17 Oct 2017 20:00:35 +0000 (22:00 +0200)]
qemu: Use bitmap with migration capabilities

All calls to qemuMonitorGetMigrationCapability in QEMU driver are
replaced with qemuMigrationCapsGet.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Store supported migration capabilities in a bitmap
Jiri Denemark [Tue, 17 Oct 2017 19:39:41 +0000 (21:39 +0200)]
qemu: Store supported migration capabilities in a bitmap

Each time we need to check whether a given migration capability is
supported by QEMU, we call query-migrate-capabilities QMP command and
lookup the capability in the returned list. Asking for the list of
supported capabilities once when we connect to QEMU and storing the
result in a bitmap is much better and we don't need to enter a monitor
just to check whether a migration capability is supported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Create a wrapper around qemuMonitorSetCapabilities
Jiri Denemark [Mon, 16 Oct 2017 10:52:36 +0000 (12:52 +0200)]
qemu: Create a wrapper around qemuMonitorSetCapabilities

The new function is called qemuProcessInitMonitor and it will enter/exit
the monitor so that the caller doesn't have to deal with this.

The goal of this patch is to simplify the code in qemuConnectMonitor
which would otherwise be a bit hairy after the following patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>