]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agoqemu: Remove support for legacy block jobs
Peter Krempa [Wed, 13 Sep 2017 13:28:46 +0000 (15:28 +0200)]
qemu: Remove support for legacy block jobs

Block job QMP commands with underscores rather than dashes were never
released in upstream qemu, (they were added, but modified in the same
release [1]), but a certain distro managed to backport the version in the
middle.

The change also slightly modified semantics for the abort command, which
made us have a lot of code which was only ever present in certain
downstream distros.

Clean the upstream code from the legacy cruft and support only the
upstream implementations.

[1] See qemu commit v1.0-2176-gdb58f9c060

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoqemu: Clean up qemuDomainSecretPrepare
John Ferlan [Wed, 30 Aug 2017 19:40:58 +0000 (15:40 -0400)]
qemu: Clean up qemuDomainSecretPrepare

No need to pass a @driver parameter since all that's done is deref
the @cfg especially since the only caller can just pass an already
referenced @cfg.

Also, looks like commit id '0298531b' at one time had a different
name for the API, so I took the liberty of fixing the comments too
since I would already be updating them for the @cfg variable.

7 years agovirsh.pod: Fix units for dommemstat and domstats
Michal Privoznik [Tue, 12 Sep 2017 13:47:14 +0000 (15:47 +0200)]
virsh.pod: Fix units for dommemstat and domstats

The documentation mistakenly states that the unit for returned
values is kB (multiple of 1000), while in fact we are returning
KiB (multiple of 1024).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agosecurity: dac: relabel spice rendernode
Cole Robinson [Mon, 17 Jul 2017 12:57:57 +0000 (08:57 -0400)]
security: dac: relabel spice rendernode

For a logged in user this a path like /dev/dri/renderD128 will have
default ownership root:video which won't work for the qemu:qemu user,
so we need to chown it.

We only do this when mount namespaces are enabled in the qemu driver,
so the chown'ing doesn't interfere with other users of the shared
render node path

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

7 years agosecurity: add MANAGER_MOUNT_NAMESPACE flag
Cole Robinson [Sun, 27 Aug 2017 15:23:47 +0000 (11:23 -0400)]
security: add MANAGER_MOUNT_NAMESPACE flag

The VIR_SECURITY_MANAGER_MOUNT_NAMESPACE flag informs the DAC driver
if mount namespaces are in use for the VM. Will be used for future
changes.

Wire it up in the qemu driver

7 years agostorage: Adjust expected format for Disk startup processing
John Ferlan [Mon, 11 Sep 2017 21:11:25 +0000 (17:11 -0400)]
storage: Adjust expected format for Disk startup processing

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

If a Disk pool was defined/created using XML that either didn't
specify a specific format or specified format type='unknown', then
restarting a pool after an initial disk backend build with overwrite
would fail after a libvirtd restart for a non-autostarted pool.

This is because the persistent pool data is not updated during pool
build w/ overwrite processing to have the VIR_STORAGE_POOL_DISK_DOS
default format.

So in addition to the alteration done during disk build processing,
alter the default expectation for disk startup to be DOS if nothing
has been defined yet. That will either succeed if the pool had been
successfully built previously using the default DOS format or fail
with a message indicating the format is something else that does not
match the expect format 'dos'.

7 years agoqemu: Provide default LUN=0 for iSCSI if not provided
John Ferlan [Mon, 11 Sep 2017 23:18:21 +0000 (19:18 -0400)]
qemu: Provide default LUN=0 for iSCSI if not provided

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

If the "/#" is missing from the provided iSCSI path, then we need
to provide the default LUN of /0; otherwise, QEMU will fail to parse
the URL causing a failure to either create the guest or hotplug
attach the storage.

During post parse, for any iSCSI disk or hostdev, scan the source
path looking for the presence of '/', if found, then we can assume
the LUN is provided.  If not found, alter the input XML to add the
"/0".  This will cause the generated XML to have the generated
value when the domain config is saved after post parse.

7 years agoqemu: blockcopy: Probe image format only with VIR_DOMAIN_BLOCK_COPY_REUSE_EXT
Peter Krempa [Tue, 12 Sep 2017 12:53:59 +0000 (14:53 +0200)]
qemu: blockcopy: Probe image format only with VIR_DOMAIN_BLOCK_COPY_REUSE_EXT

Commit 703abf1d7 changed the logic so that we don't attempt to re-create
the image if it's a block device. This was done by modifying the
'reuse' variable. Unfortunately after modifying it one of the uses was
to infer whether we should probe the disk format. After changes in the
commit mentioned above we would attempt the probe if the target of the
copy is a block device and the format was not provided explicitly rather
than using the format of the disk.

Fix it by explicitly checking whether the user requested a reuse of the
disk rather than the modified boolean flag.

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

7 years agoqemu: cold-unplug of watchdog
Michal Privoznik [Tue, 5 Sep 2017 08:13:05 +0000 (10:13 +0200)]
qemu: cold-unplug of watchdog

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

Again, no special here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: cold-plug of watchdog
Michal Privoznik [Tue, 5 Sep 2017 07:51:46 +0000 (09:51 +0200)]
qemu: cold-plug of watchdog

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

With this patch users can cold plug a watchdog. Things are pretty
simple because a domain can have at most one watchdog device.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuBuildHostNetStr: Don't leak buffer
Michal Privoznik [Mon, 11 Sep 2017 08:48:33 +0000 (10:48 +0200)]
qemuBuildHostNetStr: Don't leak buffer

If there was an error when constructing the buffer, NULL is
returned. The buffer is never freed though.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agorng: Fix formatting
Michal Privoznik [Thu, 7 Sep 2017 10:16:04 +0000 (12:16 +0200)]
rng: Fix formatting

Some elements are offset just one space compared to their parent,
some are misaligned completely, and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agorng: Drop useless <choice/>
Michal Privoznik [Thu, 7 Sep 2017 09:58:26 +0000 (11:58 +0200)]
rng: Drop useless <choice/>

If we have <choice/> with just one value to chose from, it's no
choice.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirnetserver: fix mesage vs message typo
Guido Günther [Fri, 8 Sep 2017 14:28:38 +0000 (16:28 +0200)]
virnetserver: fix mesage vs message typo

7 years agoqemu_driver: fix existance vs existence typo
Guido Günther [Fri, 8 Sep 2017 14:27:41 +0000 (16:27 +0200)]
qemu_driver: fix existance vs existence typo

7 years agostoragefile: fix defintion vs definition typo
Guido Günther [Fri, 8 Sep 2017 14:25:40 +0000 (16:25 +0200)]
storagefile: fix defintion vs definition typo

7 years agoqemu: Don't report failure to destroy a destroyed domain
Jiri Denemark [Fri, 8 Sep 2017 18:44:34 +0000 (20:44 +0200)]
qemu: Don't report failure to destroy a destroyed domain

When destroying a domain libvirt marks it internally with a
beingDestroyed flag to make sure the qemuDomainDestroyFlags API itself
cleans up after the domain rather than letting an uninformed EOF handler
do it. However, when the domain is being started at the moment libvirt
was asked to destroy it, only the starting thread can properly clean up
after the domain and thus it ignores the beingDestroyed flag. Once
qemuDomainDestroyFlags finally gets a job, the domain may not be running
anymore, which should not be reported as an error if the domain has been
starting up.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
7 years agovirsh: migrate --timeout-postcopy requires --postcopy
Jiri Denemark [Fri, 8 Sep 2017 16:15:13 +0000 (18:15 +0200)]
virsh: migrate --timeout-postcopy requires --postcopy

Requesting an automated switch to a post-copy migration (using
--timeout-postcopy) without actually enabling post-copy migration (using
--postcopy) doesn't really do anything. Let's make this dependency
explicit to avoid unexpected behavior.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoconf: validate IOMMU interrupt remapping setting
Ján Tomko [Wed, 23 Aug 2017 17:15:06 +0000 (19:15 +0200)]
conf: validate IOMMU interrupt remapping setting

This option requires:
  <ioapic driver='qemu'/>

Report an error in case someone tries to combine
it with different ioapic setting.

Setting 'eim' on without enabling 'intremap' does not make sense.

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

7 years agotests: merge iommu tests
Ján Tomko [Tue, 29 Aug 2017 15:23:19 +0000 (17:23 +0200)]
tests: merge iommu tests

Using intremap without <ioapic driver='qemu'/> does not work.
Merge the tests to avoid a duplicit test once we start validating it.

7 years agoconf: use virXMLFormatElement for <iommu>
Ján Tomko [Tue, 29 Aug 2017 16:37:39 +0000 (18:37 +0200)]
conf: use virXMLFormatElement for <iommu>

Simplify the formatting function even further.

7 years agoconf: use virXMLFormatElement for <iommu><driver>
Ján Tomko [Tue, 29 Aug 2017 16:20:48 +0000 (18:20 +0200)]
conf: use virXMLFormatElement for <iommu><driver>

Use the new helper to simplify the code.
This also fixes the bug of not formatting 'eim' in the useless
case if it's the only enabled attribute.

7 years agovirsh: man: Document the --validate option for create and define cmds
Erik Skultety [Thu, 7 Sep 2017 13:48:14 +0000 (15:48 +0200)]
virsh: man: Document the --validate option for create and define cmds

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Update --timeout description in libvirtd's man page
Erik Skultety [Thu, 7 Sep 2017 13:47:51 +0000 (15:47 +0200)]
docs: Update --timeout description in libvirtd's man page

Since commit @ae2163f8, only active client connections or running
domains are allowed to inhibit daemon shutdown. The man page however
wasn't updated appropriately.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Clean up qemuBuildControllerDevCommandLine()
Andrea Bolognani [Mon, 4 Sep 2017 16:05:43 +0000 (18:05 +0200)]
qemu: Clean up qemuBuildControllerDevCommandLine()

Add a 'cleanup' label and improve the readability of one of the
checks by making it conform to our formatting standard and moving
the corresponding comment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
7 years agotpm: Use /dev/null for cancel path if none was found
Stefan Berger [Thu, 29 Jun 2017 18:01:11 +0000 (14:01 -0400)]
tpm: Use /dev/null for cancel path if none was found

TPM 2 does not implement sysfs files for cancellation of commands.
We therefore use /dev/null for the cancel path passed to QEMU.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu: Add new EPYC CPU model
Brijesh Singh [Wed, 23 Aug 2017 18:49:41 +0000 (13:49 -0500)]
cpu: Add new EPYC CPU model

Add a new CPU model called 'EPYC' to model processors from AMD EPYC
family (which includes EPYC 76xx,75xx,74xx, 73xx and 72xx).

The following features bits have been added/removed compare to Opteron_G5

Added: monitor, movbe, rdrand, mmxext, ffxsr, rdtscp, cr8legacy, osvw,
       fsgsbase, bmi1, avx2, smep, bmi2, rdseed, adx, smap, clfshopt, sha
       xsaveopt, xsavec, xgetbv1, arat

Removed: xop, fma4, tbm

The patch is depend on EPYC CPU model supported introduced in qemu [1]

[1] https://patchwork.kernel.org/patch/9902205/

Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: Add CPUID data for AMD EPYC 7601 32-Core Processor
Jiri Denemark [Thu, 7 Sep 2017 10:58:41 +0000 (12:58 +0200)]
tests: Add CPUID data for AMD EPYC 7601 32-Core Processor

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: Add CPUID data for AMD Ryzen 7 1800X Eight-Core Processor
Jiri Denemark [Fri, 28 Apr 2017 12:09:45 +0000 (14:09 +0200)]
tests: Add CPUID data for AMD Ryzen 7 1800X Eight-Core Processor

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: migration: don't expose incomplete job as complete
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:31 +0000 (09:49 +0300)]
qemu: migration: don't expose incomplete job as complete

In case of real migration (not migrating to file on save, dump etc)
migration info is not complete at time qemu finishes migration
in normal (non postcopy) mode. We need to update disks stats,
downtime info etc. Thus let's not expose this job status as
completed.

To archive this let's set status to 'qemu completed' after
qemu reports migration is finished. It is not visible as complete
job to clients. Cookie code on confirm phase will finally turn
job into completed. As we don't need more things to do when
migrating to file status is set to 'completed' as before
in this case.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: migrate: add mirror stats to migration stats
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:30 +0000 (09:49 +0300)]
qemu: migrate: add mirror stats to migration stats

When getting job info in case mirror does not reach ready phase
fetch mirror stats from qemu. Otherwise mirror stats are already
saved in current job.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: always get job condition on getting job stats
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:29 +0000 (09:49 +0300)]
qemu: always get job condition on getting job stats

Looks like it is more simple to drop this optimization as we are
going to add getting disks stats during migration via quering qemu
process and checking if we have to acquire job condition becomes
more complicate.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: introduce migrating job status
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:28 +0000 (09:49 +0300)]
qemu: introduce migrating job status

Instead of checking stat.status let's set status to migrating
as soon as migrate command is send (waiting for completion
is a good place too).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: start all async job with job status active
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:27 +0000 (09:49 +0300)]
qemu: start all async job with job status active

Setting status to none has little value - getting job status
will not return even elapsed time.

After this patch getting job stats stays correct in a sence
it will not fetch migration stats because it consults
stats.status before doing the fetch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: fail querying destination migration statistics always
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:26 +0000 (09:49 +0300)]
qemu: fail querying destination migration statistics always

Querying destination migration statistics may result in getting
a failure or getting a elapsed time value depending on stats.status
value which is odd. Instead let's always fail. Clients should
be ready to handle this as currently getting failure period
can be considerable.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: simplify getting completed job stats
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:25 +0000 (09:49 +0300)]
qemu: simplify getting completed job stats

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: refactor fetching migration stats
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:24 +0000 (09:49 +0300)]
qemu: refactor fetching migration stats

qemuMigrationFetchJobStatus is rather inconvinient. Some of its
callers don't need status to be updated, some don't need to update
elapsed time right away. So let's update status or elapsed time
in callers instead.

This patch drops updating job status on getting job stats by
client. This way we will not provide status 'completed' while
it is not yet updated by migration routine.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: drop excessive zero-out in qemuMigrationFetchJobStatus
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:23 +0000 (09:49 +0300)]
qemu: drop excessive zero-out in qemuMigrationFetchJobStatus

qemuMonitorGetMigrationStats will do it for us anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: drop QEMU_MIGRATION_COMPLETED_UPDATE_STATS
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:22 +0000 (09:49 +0300)]
qemu: drop QEMU_MIGRATION_COMPLETED_UPDATE_STATS

This way we get stats only in one place. The former code waits for
complete/postcopy status basically and don't need to mess with stats.

The patch drops raising an error on stats updates failure. This
does not make much sense anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:21 +0000 (09:49 +0300)]
qemu: introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY

Let's introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY state for job.current->status
instead of checking job.current->stats.status. The latter can be changed
when fetching migration statistics. Moving state function from the variable
and leave only store function seems more managable.

This patch removes all state checking usage of stats except for
qemuDomainGetJobStatsInternal. This place will be handled separately.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: introduce qemu domain job status
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:20 +0000 (09:49 +0300)]
qemu: introduce qemu domain job status

This patch simply switches code from using VIR_DOMAIN_JOB_* to
introduced QEMU_DOMAIN_JOB_STATUS_*. Later this gives us freedom
to introduce states for postcopy and mirroring phases.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: drop code for VIR_DOMAIN_JOB_BOUNDED and timeRemaining
Nikolay Shirokovskiy [Fri, 1 Sep 2017 06:49:19 +0000 (09:49 +0300)]
qemu: drop code for VIR_DOMAIN_JOB_BOUNDED and timeRemaining

qemu driver does not have VIR_DOMAIN_JOB_BOUNDED jobs and
timeRemaining is always 0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agotravis: Install gettext
Andrea Bolognani [Wed, 6 Sep 2017 12:48:48 +0000 (14:48 +0200)]
travis: Install gettext

msgmerge(1) and friends are required to build libvirt, so the
corresponding package should be installed in the Travis worker.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agotravis: Sort build dependencies
Andrea Bolognani [Wed, 6 Sep 2017 12:46:07 +0000 (14:46 +0200)]
travis: Sort build dependencies

Keeping the list of build dependencies sorted alphabetically
makes it way easier to visually scan it for issues.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Validate device on update-device
Michal Privoznik [Tue, 5 Sep 2017 14:24:14 +0000 (16:24 +0200)]
conf: Validate device on update-device

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

Whenever a device is being updated via
virDomainUpdateDeviceFlags() API, we parse the device XML and
ideally run some generic checks to validate the configuration
(e.g. if device defines per-device boot order but the domain has
os/boot element already). Well, that's the theory - due to a
missing check we've jumped early from that check function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agom4: Disable -Wdisabled-optimization
Andrea Bolognani [Tue, 5 Sep 2017 14:37:50 +0000 (16:37 +0200)]
m4: Disable -Wdisabled-optimization

After b4f7793ce269, qemuxml2xmltest has apparently become big enough
to trigger a compilation error when using --enable-test-coverage on
aarch64:

    CC       qemuxml2xmltest.o
  qemuxml2xmltest.c: In function 'mymain':
  qemuxml2xmltest.c:1216:1: error: const/copy propagation disabled: 4361 basic blocks and 99285 registers [-Werror=disabled-optimization]
   }
   ^
  qemuxml2xmltest.c:1216:1: error: PRE disabled: 4361 basic blocks and 99285 registers [-Werror=disabled-optimization]
  qemuxml2xmltest.c:1216:1: error: const/copy propagation disabled: 4361 basic blocks and 99285 registers [-Werror=disabled-optimization]
  qemuxml2xmltest.c:1216:1: error: const/copy propagation disabled: 4361 basic blocks and 99285 registers [-Werror=disabled-optimization]

However, as the GCC documentation states, this warning is not really
caused by issues in our code, so it makes sense to disable it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Remove unused params from qemuDomainDeviceDefValidate
John Ferlan [Fri, 1 Sep 2017 17:16:17 +0000 (13:16 -0400)]
qemu: Remove unused params from qemuDomainDeviceDefValidate

Neither @cfg nor (now) @driver is used in the API, so remove them
and mark @opaque as UNUSED.

NB: Commit id 'fa3c558596' dropped the unused @qemuCaps which was the
last consumer of @driver other than @cfg, but even @cfg was never used
even in the original implementation from commit id 'd987f63a'.

7 years agoqemu: Default to video type=virtio for machvirt
Cole Robinson [Sun, 27 Aug 2017 15:04:42 +0000 (11:04 -0400)]
qemu: Default to video type=virtio for machvirt

arm/aarch64 -M virt on KVM doesn't and will never work with standard
VGA card emulation. The recommended method is to use type=virtio, so
let's make it the default for video devices without an explicit type
set by the user.

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoqemu: Set default video type in qemu PostParse
Cole Robinson [Sun, 27 Aug 2017 15:04:41 +0000 (11:04 -0400)]
qemu: Set default video type in qemu PostParse

And not generic domain_conf code. We will need qemu private functions
in a bit.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoconf: domain: move video type validation to DeviceDefValidate
Cole Robinson [Sun, 27 Aug 2017 15:04:40 +0000 (11:04 -0400)]
conf: domain: move video type validation to DeviceDefValidate

This allows drivers to set their own default. But if a driver neglects
to fill one in, we still error like we previously would at parse time.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoconf: domain: add VIDEO_TYPE_DEFAULT
Cole Robinson [Sun, 27 Aug 2017 15:04:39 +0000 (11:04 -0400)]
conf: domain: add VIDEO_TYPE_DEFAULT

Will be needed for future patches to pull the default video type
setting out of XML parsing routines.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agomaint: Fix incorrect parenthesis placement causing true/false assignment
Erik Skultety [Tue, 5 Sep 2017 08:06:33 +0000 (10:06 +0200)]
maint: Fix incorrect parenthesis placement causing true/false assignment

There were a few places in our code where the following pattern in 'if'
condition occurred:

if ((foo = bar() < 0))
    do something;

This patch adjusts the conditions to the expected format:

if ((foo = bar()) < 0)
    do something;

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoMakefile.nonreentrant: Rebuild against Fedora 26
Andrea Bolognani [Mon, 4 Sep 2017 13:06:16 +0000 (15:06 +0200)]
Makefile.nonreentrant: Rebuild against Fedora 26

According to the comments in the file and the git history, the
list of forbidden symbols was originally built against Fedora 9
in 2009 (!) and pretty much never refreshed afterwards.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agodocs: Fix typo deamon -> daemon
Andrea Bolognani [Mon, 4 Sep 2017 12:04:10 +0000 (14:04 +0200)]
docs: Fix typo deamon -> daemon

Suggested-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoevent: ignore attempts to replace the event loop impl
Daniel P. Berrange [Fri, 1 Sep 2017 12:47:04 +0000 (13:47 +0100)]
event: ignore attempts to replace the event loop impl

Although not previously explicitly documented, the expectation for
the libvirt event loop is that an implementation is registered early
in application startup, before calling any libvirt APIs and then
run forever after. Replacing a previously registered event loop is
not safe & subject to races even if virConnectClose has been called
on open handles, due to delayed deregistration of callbacks during
conenction close.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoAdd libxslt as build requires for mingw RPMs
Daniel P. Berrange [Mon, 4 Sep 2017 11:42:46 +0000 (12:42 +0100)]
Add libxslt as build requires for mingw RPMs

The libxslt package is needed since:

  commit 94d2d6429d686c5af95115d09c01f3c6bd5ea7c6
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Jul 26 17:40:44 2017 +0100

    docs: make xmllint & xsltproc compulsory

The native RPM had it already, but mingw build was missing it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agolxcStateInitialize: Don't leak driver's caps
Michal Privoznik [Tue, 29 Aug 2017 16:11:08 +0000 (18:11 +0200)]
lxcStateInitialize: Don't leak driver's caps

Funny thing. So when initializing LXC driver's capabilities,
firstly the virLXCDriverGetCapabilities() is called. This creates
new capabilities, stores them under driver->caps, ref() them and
return them. However, the return value is ignored. Secondly, the
function is called yet again and since we have driver->caps set,
they are ref()-ed again an returned. So in the end, driver's
capabilities have refcount of three when in fact they should have
refcount of one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoPost-release version bump to 3.8.0
Michal Privoznik [Mon, 4 Sep 2017 10:29:55 +0000 (12:29 +0200)]
Post-release version bump to 3.8.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoRelease of libvirt-3.7.0
Daniel Veillard [Mon, 4 Sep 2017 10:14:11 +0000 (12:14 +0200)]
Release of libvirt-3.7.0

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

7 years agovmx: Expose VMware Managed Object Reference (moref) in XML.
Richard W.M. Jones [Fri, 25 Aug 2017 13:36:58 +0000 (14:36 +0100)]
vmx: Expose VMware Managed Object Reference (moref) in XML.

If you use the VDDK library to access virtual machines remotely, you
really need to know the Managed Object Reference ("moref") of the VM.
This must be passed each time you connect to the API.

For example nbdkit's VDDK plugin requires a moref to be passed to
mount up a VM's disk remotely:

 nbdkit vddk user=root password=+/tmp/rootpw \
             server=esxi.example.com thumbprint=xx:xx:xx:... \
             vm=moref=2 \
             file="[datastore1] Fedora/Fedora.vmdk"

Getting the moref is a huge pain.  To get some idea of what it is, why
it is needed, and how much trouble it is to get it, see:
https://blogs.vmware.com/vsphere/2012/02/uniquely-identifying-virtual-machines-in-vsphere-and-vcloud-part-1-overview.html
https://blogs.vmware.com/vsphere/2012/02/uniquely-identifying-virtual-machines-in-vsphere-and-vcloud-part-2-technical.html

However the moref is available conveniently in the internals of the
libvirt VMX driver.  This patch exposes it as a custom XML element
using the same "vmware:" namespace which was previously used for the
datacenterpath (see libvirt commit 636a99058758a044).

It appears in the XML like this:

<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
  <name>Fedora</name>
...
  <vmware:datacenterpath>ha-datacenter</vmware:datacenterpath>
  <vmware:moref>2</vmware:moref>
</domain>

Note that the moref can appear as either a simple ID (for esx://
connections) or as a "vm-<ID>" (for vpx:// connections).  It should be
treated by users as an opaque string.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
7 years agodocs: Remove <code> from <summary> entries due to RNG error
John Ferlan [Sat, 2 Sep 2017 12:05:32 +0000 (08:05 -0400)]
docs: Remove <code> from <summary> entries due to RNG error

commit '96e55048' caused make check failure for virschematest:

1929) Checking ../docs/news.xml against ../news.rng                     ... libvirt: XML Util error : XML document failed to validate against schema: Unable to validate doc against /home/jferlan/git/libvirt.work/docs/schemas/../news.rng
Datatype element summary has child elements
Element summary failed to validate content
Datatype element summary has child elements
Element summary failed to validate content
^[[31m^[[1mFAILED^[[0m

That's because <code> elements don't appear to be allowed in the schema.
Rather than attempt to fix the schema, figured it was simpler to just
remove them and let the schema fix happen later.

7 years agonews: Prepare for 3.7.0 release
Andrea Bolognani [Fri, 1 Sep 2017 14:17:44 +0000 (16:17 +0200)]
news: Prepare for 3.7.0 release

Documents some changes that have slipped through the cracks
during the development cycle.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Document managedsave-edit commands support
Kothapally Madhu Pavan [Wed, 30 Aug 2017 10:53:54 +0000 (16:23 +0530)]
docs: Document managedsave-edit commands support

This patch documents support for managedsave-dumpxml,
managedsave-define and managedsave-edit commands.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agonews: Add stuff for 3.7.0
Peter Krempa [Fri, 1 Sep 2017 12:57:01 +0000 (14:57 +0200)]
news: Add stuff for 3.7.0

7 years agovirnetdaemon: Don't deadlock when talking to D-Bus
Michal Privoznik [Fri, 1 Sep 2017 08:33:12 +0000 (10:33 +0200)]
virnetdaemon: Don't deadlock when talking to D-Bus

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

In ace45e67abbd I tried to fix a problem that we get the reply to
a D-Bus call while we were sleeping. In that case the callback
was never set. So I changed the code that the callback is called
directly in this case. However, I hadn't realized that since the
callback is called out of order it locks the virNetDaemon.
Exactly the very same virNetDaemon object that we are dealing
with right now and that we have locked already (in
virNetDaemonAddShutdownInhibition())

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: handle -1 for pid in qemuDomainGetMachineName
Nikolay Shirokovskiy [Thu, 31 Aug 2017 09:01:44 +0000 (12:01 +0300)]
qemu: handle -1 for pid in qemuDomainGetMachineName

We call qemuDomainGetMachineName on domain start. On first
start (after daemon start) pid is 0 and virSystemdGetMachineNameByPID
don't get called. But after domain shutting down pid became -1 so
on next start virSystemdGetMachineNameByPID is called and returned an error.
Error is ignored so it is not critical. But at least on my system
(systemd-219 with extra patches) systemd-machined is crashed on
this request.

This behaviour is triggered by eaf2c9f89.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Forbid rx/tx_queue_size change explicitly
Michal Privoznik [Thu, 31 Aug 2017 09:33:06 +0000 (11:33 +0200)]
qemu: Forbid rx/tx_queue_size change explicitly

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

When updating a virtio enabled vNIC and trying to change either
of rx_queue_size or tx_queue_size success is reported although no
operation is actually performed. Moreover, there's no way how to
change these on the fly. This is due to way we check for changes:
explicitly for each struct member. Therefore it's easy to miss
one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodocs: Add entry for ZStack to apps page
Shuang He [Tue, 29 Aug 2017 08:14:32 +0000 (16:14 +0800)]
docs: Add entry for ZStack to apps page

Signed-off-by: Shuang He <shuang.he@zstack.io>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonews: add an entry for chardev reconnect feature
Pavel Hrdina [Thu, 31 Aug 2017 10:32:35 +0000 (12:32 +0200)]
news: add an entry for chardev reconnect feature

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agostorage: Use virStorageBackendRefreshVolTargetUpdate after wipeVol
John Ferlan [Thu, 24 Aug 2017 22:19:14 +0000 (18:19 -0400)]
storage: Use virStorageBackendRefreshVolTargetUpdate after wipeVol

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

Rather than using refreshVol which essentially only updates the
allocation, capacity, and permissions for the volume, but not
the format which does get updated in a pool refresh - let's use
the same helper that pool refresh uses in order to update the
volume target.

7 years agostorage: Introduce virStorageBackendRefreshVolTargetUpdate
John Ferlan [Thu, 24 Aug 2017 21:56:47 +0000 (17:56 -0400)]
storage: Introduce virStorageBackendRefreshVolTargetUpdate

Create a separate function to handle the volume target update
via probe processing.

7 years agoqemu: set bind mode for chardev while parsing XML
Pavel Hrdina [Wed, 30 Aug 2017 13:56:52 +0000 (15:56 +0200)]
qemu: set bind mode for chardev while parsing XML

Currently while parsing domain XML we clear the UNIX path if it matches
one of the auto-generated paths by libvirt.  After that when the guest
is started new path is generated but the mode is also changed to "bind".

In the real-world use-case the mode should not change, it only happens
if a user provides a mode='connect' and path that matches one of the
auto-generated path or not provides a path at all.

Before *reconnect* feature was introduced there was no issue, but with
the new feature we need to make sure that it's used only with "connect"
mode, therefore we need to move the mode change into parsing in order
to have a proper error reported by validation code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: don't use unix socket path that matches auto-generated path
Pavel Hrdina [Tue, 29 Aug 2017 15:51:07 +0000 (17:51 +0200)]
tests: don't use unix socket path that matches auto-generated path

The test was introduced by 60135b22db6d.

The auto-generated path is removed by post-parse callback which
also changes the mode from "connect" to "bind" since the auto-generated
path makes sense only for "bind" mode.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: add reconnect to virDomainChrSourceDef(Copy|IsEqual)
Pavel Hrdina [Tue, 29 Aug 2017 11:38:28 +0000 (13:38 +0200)]
conf: add reconnect to virDomainChrSourceDef(Copy|IsEqual)

Missed by 9aa72a6dd5b3.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: remove unused file
Pavel Hrdina [Tue, 29 Aug 2017 10:09:24 +0000 (12:09 +0200)]
tests: remove unused file

Introduced by 95fd63b1700d.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoFix TLS test suites with gnutls 3.6.0
Daniel P. Berrange [Tue, 29 Aug 2017 15:24:26 +0000 (16:24 +0100)]
Fix TLS test suites with gnutls 3.6.0

With gnutls 3.6.0, SHA1 is no longer accepted for certificate
signatures. We must usw SHA256 instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agodoc: Fix docs/news.xml structure
Kothapally Madhu Pavan [Wed, 30 Aug 2017 10:14:35 +0000 (15:44 +0530)]
doc: Fix docs/news.xml structure

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agotests: Fix virnetsockettest after SSH command line changes
Martin Kletzander [Wed, 30 Aug 2017 08:50:17 +0000 (10:50 +0200)]
tests: Fix virnetsockettest after SSH command line changes

Commit e4cb8500810a changed the way ssh command line is created by
adding '--' before the hostname in order to fix a potential security
flaw.  However it failed to modify the tests, so let's do that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Document yet another limitation of tx_queue_size
Michal Privoznik [Tue, 29 Aug 2017 15:01:16 +0000 (17:01 +0200)]
docs: Document yet another limitation of tx_queue_size

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

Turns out, only vhostuser type of interfaces are supported
currently.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agorpc: avoid ssh interpreting malicious hostname as arguments
Daniel P. Berrange [Fri, 11 Aug 2017 16:19:53 +0000 (17:19 +0100)]
rpc: avoid ssh interpreting malicious hostname as arguments

Inspired by the recent GIT / Mercurial security flaws
(http://blog.recurity-labs.com/2017-08-10/scm-vulns),
consider someone/something manages to feed libvirt a bogus
URI such as:

  virsh -c qemu+ssh://-oProxyCommand=gnome-calculator/system

In this case, the hosname "-oProxyCommand=gnome-calculator"
will get interpreted as an argument to ssh, not a hostname.
Fortunately, due to the set of args we have following the
hostname, SSH will then interpret our bit of shell script
that runs 'nc' on the remote host as a cipher name, which is
clearly invalid. This makes ssh exit during argv parsing and
so it never tries to run gnome-calculator.

We are lucky this time, but lets be more paranoid, by using
'--' to explicitly tell SSH when it has finished seeing
command line options. This forces it to interpret
"-oProxyCommand=gnome-calculator" as a hostname, and thus
see a fail from hostname lookup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoqemu: Also treat directories properly when using namespaces
Martin Kletzander [Fri, 18 Aug 2017 15:33:08 +0000 (17:33 +0200)]
qemu: Also treat directories properly when using namespaces

When recreating folders with namespaces, the directory type was not
being handled at all.  It's not special, we probably just didn't know
that that can be used as a volume path as well.  The code failed
gracefully, but we want to allow that so that we can use <disk
type='dir'> in domains again.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Don't mangle the storage format for type='dir'
Martin Kletzander [Fri, 25 Aug 2017 12:45:56 +0000 (14:45 +0200)]
qemu: Don't mangle the storage format for type='dir'

Our backing probing code handles directory file types properly in
virStorageFileGetMetadataRecurse(), by that I mean it leaves them
alone.  However its caller, the virStorageFileGetMetadata() resets the
type to raw before probing, without even checking the type.  We need
to special-case TYPE_DIR in order to achieve desired results.

Also, in order to properly test this, we need to stop resetting format
of volumes in tests for TYPE_DIR (probably the reason why we didn't
catch that and why the test data didn't need to be modified).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agovirsh: Implement managedsave-edit command
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:55 +0000 (13:32 +0530)]
virsh: Implement managedsave-edit command

Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agovirsh: Implement managedsave-dumpxml command
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:54 +0000 (13:32 +0530)]
virsh: Implement managedsave-dumpxml command

Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agovirsh: Implement managedsave-define command
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:53 +0000 (13:32 +0530)]
virsh: Implement managedsave-define command

Add a simple virsh command handler which makes use of the new API.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agoqemu: Implement qemuDomainManagedSaveDefineXML
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:52 +0000 (13:32 +0530)]
qemu: Implement qemuDomainManagedSaveDefineXML

This commit adds qemu driver implementation to edit xml
configuration of managed save state file of a domain.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agoqemu: Implement qemuDomainManagedSaveGetXMLDesc
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:51 +0000 (13:32 +0530)]
qemu: Implement qemuDomainManagedSaveGetXMLDesc

This commit adds qemu driver implementation to get xml description
for managed save state domain.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agolib: Add API to edit domain's managed save state xml configuration
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:50 +0000 (13:32 +0530)]
lib: Add API to edit domain's managed save state xml configuration

Similar to domainSaveImageDefineXML this commit adds domainManagedSaveDefineXML
API which allows to edit domain's managed save state xml configuration.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agolib: Add API to dump xml configuration of managed save state domain
Kothapally Madhu Pavan [Tue, 8 Aug 2017 08:02:49 +0000 (13:32 +0530)]
lib: Add API to dump xml configuration of managed save state domain

Similar to domainSaveImageGetXMLDesc this commit adds domainManagedSaveGetXMLDesc
API which allows to get the xml of managed save state domain.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
7 years agoqemu: Honour <on_reboot/>
Michal Privoznik [Mon, 31 Jul 2017 14:55:58 +0000 (16:55 +0200)]
qemu: Honour <on_reboot/>

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

For some reason, we completely ignore <on_reboot/> setting for
domains. The implementation is simply not there. It never was.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemuDomainUndefineFlags: Grab QEMU_JOB_MODIFY
Michal Privoznik [Mon, 7 Aug 2017 11:28:48 +0000 (13:28 +0200)]
qemuDomainUndefineFlags: Grab QEMU_JOB_MODIFY

This API is definitely modifying state of @vm. Therefore it
should grab a job.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Introduce and use qemuDomainRemoveInactiveJob
Michal Privoznik [Tue, 15 Aug 2017 07:12:43 +0000 (09:12 +0200)]
qemu: Introduce and use qemuDomainRemoveInactiveJob

At some places we either already have synchronous job or we just
released it. Also, some APIs might want to use this code without
having to release their job. Anyway, the job acquire code is
moved out to qemuDomainRemoveInactiveJob so that
qemuDomainRemoveInactive does just what it promises.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: Clean up and report error in virDomainGenerateMachineName
Martin Kletzander [Mon, 21 Aug 2017 07:02:09 +0000 (09:02 +0200)]
conf: Clean up and report error in virDomainGenerateMachineName

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoconf: Clean up and report error in virDomainCapsFormat
Martin Kletzander [Mon, 21 Aug 2017 06:50:47 +0000 (08:50 +0200)]
conf: Clean up and report error in virDomainCapsFormat

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoutil: Use virBufferCheckError to its full potential.
Martin Kletzander [Mon, 21 Aug 2017 06:38:34 +0000 (08:38 +0200)]
util: Use virBufferCheckError to its full potential.

We can now check for the error and not care about the return value as
it will be properly handled in virBufferContentAndReset() anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoutil: Umark virBufferCheckErrorInternal as ATTRIBUTE_RETURN_CHECK
Martin Kletzander [Wed, 16 Aug 2017 09:09:47 +0000 (11:09 +0200)]
util: Umark virBufferCheckErrorInternal as ATTRIBUTE_RETURN_CHECK

The function is useful even without using the return value.  And if
needed, the return value can be obtained by other calls as well.  The
potential for clean-up can be seen in the following patch.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Update news with domain name bug fixes
Martin Kletzander [Wed, 23 Aug 2017 11:46:36 +0000 (13:46 +0200)]
docs: Update news with domain name bug fixes

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Use short domain name in qemuDomainGetPreservedMountPath
Martin Kletzander [Wed, 23 Aug 2017 08:39:57 +0000 (10:39 +0200)]
qemu: Use short domain name in qemuDomainGetPreservedMountPath

Otherwise longer domain names might generate paths that are too long
to be created.  This follows what other parts of the code do as well.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoconf: Properly truncate wide character names in virDomainObjGetShortName
Martin Kletzander [Wed, 23 Aug 2017 11:18:19 +0000 (13:18 +0200)]
conf: Properly truncate wide character names in virDomainObjGetShortName

We always truncated the name at 20 bytes instead of characters.  In
case 20 bytes were in the middle of a multi-byte character, then the
string became invalid and various parts of the code would error
out (e.g. XML parsing of that string).  Let's instead properly
truncate it after 20 characters instead.

We cannot test this in our test suite because we would need to know
what locales are installed on the system where the tests are ran and
if there is supported one (most probably there will be, but we cannot
be 100% sure), we could initialize gettext in qemuxml2argvtest, but
there would still be a chance of getting two different (both valid,
though) results.

In order to test this it is enough to start a machine with a name for
which trimming it after 20 bytes would create invalid sequence (e.g.
1234567890123456789č where č is any multi-byte character).  Then start
the domain and restart libvirtd.  The domain would disappear because
such illegal sequence will not go through the XML parser.  And that's
not a bug of the parser, it should not be in the XML in the first
place, but since we don't use any sophisticated formatter, just
mash some strings together, the formatting succeeds.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agovirsh: Honour --readonly with cmdConnect and no name
Martin Kletzander [Fri, 18 Aug 2017 14:35:23 +0000 (16:35 +0200)]
virsh: Honour --readonly with cmdConnect and no name

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>