Commit Graph

19460 Commits

Author SHA1 Message Date
Cole Robinson
28c547ed6d storage: fs: Don't try to chown directory unless user requested
Currently we try to chown any directory passed to virDirCreate,
even if the user didn't request any explicit owner/group via the
pool/vol XML.

This causes issues with qemu:///session: try to build a pool of
a root owned directory like /tmp, and it fails trying to chown the
directory to the session user. Instead it should just leave things
as they are, unless the user requests changing permissions via
the pool XML.

Similarly this is annoying if creating a storage pool via system
libvirtd of an existing directory in user $HOME, it's now owned
by root.

The virDirCreate function is pretty convoluted, since it needs to
fork off in certain specific cases. Try to document that, to make
it clear where exactly we are changing behavior.
2015-05-04 12:56:38 -04:00
Cole Robinson
262b3c05dd storage: fs: Don't attempt directory creation if it already exists
The current code attempts to handle this, but it only catches mkdir
failing with EEXIST. However if say trying to build /tmp for an
unprivileged qemu:///session, mkdir will fail with EPERM.

Rather than catch any errors, just don't attempt mkdir if the directory
already exists.
2015-05-04 12:56:38 -04:00
Cole Robinson
d6f8b35db5 storage: fs: Fill in permissions on pool refresh
This means pool XML actually reports accurate user/group/mode/label.

This uses UpdateVolTargetInfoFD in a bit of a hackish way, but it works
2015-05-04 12:56:38 -04:00
Cole Robinson
27a4c492f5 storage: fs: Don't overwrite virDirCreate error
virDirCreate will give us fine grained details about what actually failed.
2015-05-04 12:56:38 -04:00
Jiri Denemark
05cda3d3a4 virsh: Don't check migrate parameters
Just pass anything a user specified to the appropriate API. It's the API
or libvirtd that should be responsible for checking its parameters.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-05-04 15:06:33 +02:00
Jiri Denemark
b45ec56f58 qemu: Forbid unsupported parameters for tunnelled migration
Neither migrate URI nor lister address make any sense for tunnelled
migration.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-05-04 15:06:33 +02:00
Andrea Bolognani
320e61b26c tests: Fix grammar in comments.
Replace all occurrences of "stream write to differences to"
with "stream to write differences to".
2015-05-04 15:01:27 +02:00
Marc-André Lureau
620655f353 tests: add machine vmport qemu test
Check that the vmport feature is correctly used in qemu commande line.
2015-05-04 13:19:38 +02:00
Marc-André Lureau
7d3dc7a084 qemu: add machine vmport argument
Fill qemu command line vmport argument as required.
2015-05-04 13:19:38 +02:00
Marc-André Lureau
f5a5f2b7d4 qemu: add virQEMUCapsSupportsVmport
The vmport machine argument works with pc machine kind, not with xen for
example.
2015-05-04 13:19:38 +02:00
Marc-André Lureau
46ae6b7fc7 qemu: move qemuDomainMachineIs{I440FX,Q35}
Move common functions being used by the following
virQEMUCapsSupportsVmport commit.
2015-05-04 13:19:38 +02:00
Marc-André Lureau
384a06f5f2 qemu: add QEMU_CAPS_MACHINE_VMPORT_OPT
Set the capability based on qmp query, or qemu version.  The qmp query
includes vmport with 2.2, but no longer with 2.3. It lists only
non-machine specific capabilities, so check the qemu version too until a
machine-specific query is supported.
2015-05-04 13:19:38 +02:00
Marc-André Lureau
39343bc82c domain/conf: add VIR_DOMAIN_FEATURE_VMPORT 2015-05-04 13:19:38 +02:00
Marc-André Lureau
208abbcbd7 docs: add domain vmport feature
A new feature that can be turned on or off.

The QEMU machine vmport option allows to set the VMWare IO port
emulation. This emulation is useful for absolute pointer input when the
guest has vmware input drivers, and is enabled by default for kvm.

However it is unnecessary for Spice-enabled VM, since the agent already
handles absolute pointer and multi-monitors. Furthermore, it prevents
Spice from switching to relative input since the regular ps/2 pointer
driver is replaced by the vmware driver. It is thus advised to disable
vmport when using a Spice VM. This will permit the Spice client to
switch from absolute to relative pointer, as it may be required for
certain games or applications.
2015-05-04 13:19:38 +02:00
Jiri Denemark
811fb55988 Bump version to 1.2.16 for new dev cycle 2015-05-04 13:04:39 +02:00
Luyao Huang
3f7cad7a8f qemu: fix the vm deadlock when deleting a nonexistent iothread
https://bugzilla.redhat.com/show_bug.cgi?id=1218145

Jump to endjob instead of cleanup to fix this deadlock.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-05-04 12:18:55 +02:00
Luyao Huang
3dae162db7 tools: fix the wrong check when use virsh setvcpus --maximum
The --maximum option wasn't properly parsed and the equivalent flag
wasn't set.  Fix this bug and also rewrite the way we check this option
by using new macro.  The new approach is that --maximum requires
--config, no other combination is allowed, because they don't make sense.

The new error will be:

 # virsh setvcpus test --maximum 10
 error: Option --config is required by option --maximum

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 10:26:57 +02:00
Pavel Hrdina
170fb72c70 virsh: introduce new macros to help check flag requirements
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 09:20:01 +02:00
Pavel Hrdina
28ca8520bb qemu: use new macros for setvcpus to check flags and cleanup the code
Now that we have macros for exclusive flags and flag requirements we can
use them to cleanup the code for setvcpus and error out for all wrong
flag combination.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 09:20:01 +02:00
Pavel Hrdina
6e3f9cbc9c use new macro helpers to check flag requirements
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 09:20:01 +02:00
Pavel Hrdina
ff3f93bcc2 use new macro helpers to check exclusive flags
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 09:20:00 +02:00
Pavel Hrdina
0fb03395a0 internal: introduce macro helpers to check flag requirements
Similar to VIR_EXLUSIVE_FLAGS, it will error out if flag requirement is
not met.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 09:20:00 +02:00
Pavel Hrdina
e86a94ee4c internal: introduce macro helpers to reject exclusive flags
Inspired by commit 7e437ee7 that introduced similar macros for virsh
commands so we don't have to repeat the same code all over.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-05-04 09:20:00 +02:00
Daniel Veillard
b978b85b24 Release of libvirt-1.2.15
- docs/news.html.in libvirt.spec.in: update for the release
- po/*.po*: regenerated
2015-05-04 11:43:04 +08:00
John Ferlan
63a368012d qemu: Fix bus and lun checks when scsi-disk.channel not present
Found by Laine and discussed a bit on internal IRC.

Commit id c56fe7f1d6 added support for creating a command line to support
scsi-disk.channel.

Series was here:
http://www.redhat.com/archives/libvir-list/2012-February/msg01052.html

Which pointed to a design proposal here:
http://permalink.gmane.org/gmane.comp.emulators.libvirt/50428

Which states (in part):

Libvirt should check for the QEMU "scsi-disk.channel" property.  If it
is unavailable, QEMU will only support channel=lun=0 and 0<=target<=7.

However, the check added was ensuring that bus != lun *and* bus != 0. So
if bus == lun and both were non zero, we'd never make the second check.
Changing this to an *or* check fixes the check, but still is less readable
than the just checking each for 0
2015-04-30 16:21:38 -04:00
Pavel Hrdina
bb3cc43cd4 main: add new generated files to .gitignore
This means new libxl-lockd.conf and libxl-sanlock.conf

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-04-30 18:39:34 +02:00
Pavel Hrdina
62b18d981c rpm-build: update %files section for libxl
Recent commit 198cc1d3 introduced integration of lockd and sanlock into
libxl, but forget to update libvirt.spec.in to also list new files
distributed via package.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-04-30 17:21:07 +02:00
Peter Krempa
f06d7daaa9 qemu: blockjob: Call qemuDomainSupportsBlockJobs only on online VMs
Since the qemu capabilities are not initialized for offline VMs the
caller might get suboptimal error message:

$ virsh blockjob VM PATH --bandwidth 1
error: unsupported configuration: block jobs not supported with this QEMU binary

Move the checks after we make sure that the VM is alive.
2015-04-30 16:46:42 +02:00
Jiri Denemark
6280294574 qemu: Check address type for USB disks
Only USB addresses are allowed for USB disks. Report an error if another
address is configured.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-30 15:34:57 +02:00
Jiri Denemark
01ecee247a cpu: Honor vendor_id override in host-model
https://bugzilla.redhat.com/show_bug.cgi?id=858147

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-30 15:34:57 +02:00
Ján Tomko
a41b1f196c iscsi: do not fail to stop a stopped pool
Just as we allow stopping filesystem pools when they were unmounted
externally, do not fail to stop an iscsi pool when someone else
closed the session externally.

Reported at:
https://bugzilla.redhat.com/show_bug.cgi?id=1171984
2015-04-30 13:05:10 +02:00
Jim Fehlig
198cc1d339 libxl: provide integration with lock manager
Provide integration with libvirt's lock manager in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-29 10:51:36 -06:00
Cole Robinson
066f7c7c3a domain: conf: Drop unused OSTYPE_AIX
The phyp driver stuffed it into a DomainDefPtr during its attachdevice
routine, but the value is never advertised via capabilities so it should
be safe to drop.

Have the phyp driver use OSTYPE_LINUX, which is what it advertises via
capabilities.
2015-04-29 09:42:26 -04:00
Michael Chapman
99725f946c qemu: migration: use sync block job helpers
In qemuMigrationDriveMirror we can start all disk mirrors in parallel.
We wait until they are all ready, or one of them aborts.

In qemuMigrationCancelDriveMirror, we wait until all mirrors are
properly stopped. This is necessary to ensure that destination VM is
fully in sync with the (paused) source VM.

If a drive mirror can not be cancelled, then the destination is not in a
consistent state. In this case it is not safe to continue with the
migration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-04-29 13:11:42 +02:00
Michael Chapman
1e106fee57 qemuDomainBlockJobAbort: use sync block job helpers
The !modern code path needs to call qemuBlockJobEventProcess directly.
the modern code path will call it via qemuBlockJobSyncWait.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-04-29 13:11:42 +02:00
Michael Chapman
1ec03c8772 qemuProcessStop: wake up pending sync block jobs
Other threads may be blocked in qemuBlockJobSyncWait. Ensure that
they're woken up when the domain is stopped.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-04-29 13:11:42 +02:00
Michael Chapman
89a5e25d05 qemuBlockJobSync*: introduce sync block job helpers
qemuBlockJobSyncBegin and qemuBlockJobSyncEnd delimit a region of code
where block job events are processed "synchronously".
qemuBlockJobSyncWait and qemuBlockJobSyncWaitWithTimeout wait for an
event generated by a block job.

The Wait* functions may be called multiple times while the synchronous
block job is active. Any pending block job event will be processed by
only when Wait* or End is called.  disk->blockJobStatus is reset by
these functions, so if it is needed a pointer to a
virConnectDomainEventBlockJobStatus variable should be passed as the
last argument. It is safe to pass NULL if you do not care about the
block job status.

All functions assume the VM object is locked. The Wait* functions will
unlock the object for as long as they are waiting. They will return -1
and report an error if the domain exits before an event is received.

Typical use is as follows:

  virQEMUDriverPtr driver;
  virDomainObjPtr vm; /* locked */
  virDomainDiskDefPtr disk;
  virConnectDomainEventBlockJobStatus status;

  qemuBlockJobSyncBegin(disk);

  ... start block job ...

  if (qemuBlockJobSyncWait(driver, vm, disk, &status) < 0) {
      /* domain died while waiting for event */
      ret = -1;
      goto error;
  }

  ... possibly start other block jobs
      or wait for further events ...

  qemuBlockJobSyncEnd(driver, vm, disk, NULL);

To perform other tasks periodically while waiting for an event:

  virQEMUDriverPtr driver;
  virDomainObjPtr vm; /* locked */
  virDomainDiskDefPtr disk;
  virConnectDomainEventBlockJobStatus status;
  unsigned long long timeout = 500 * 1000ull; /* milliseconds */

  qemuBlockJobSyncBegin(disk);

  ... start block job ...

  do {
      ... do other task ...

      if (qemuBlockJobSyncWaitWithTimeout(driver, vm, disk,
                                          timeout, &status) < 0) {
          /* domain died while waiting for event */
          ret = -1;
          goto error;
      }
  } while (status == -1);

  qemuBlockJobSyncEnd(driver, vm, disk, NULL);

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-04-29 13:11:42 +02:00
Michael Chapman
206dbf3f0a qemuBlockJobEventProcess: move to new source file
We will want to use synchronous block jobs from qemu_migration as well,
so split this function out into a new source file.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-04-29 13:11:42 +02:00
Peter Krempa
a83b2e253f qemu: Validate available slot count for memory devices
While qemu would reject the configuration we can check whether it makes
sense to plug the device upfront.
2015-04-29 09:40:16 +02:00
Peter Krempa
6705d828fc qemu: command: Validate that memory devices slot ID is in range
slot id, if specified, has to be less than the slots count.
2015-04-29 09:40:16 +02:00
Peter Krempa
406944e476 qemu: conf: Reject memory device if it would exceed configured max size
If the added memory device would exceed the maximum memory size, reject
it.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1216046
2015-04-29 09:40:16 +02:00
Peter Krempa
ebe0bd5590 qemu: blockCopy: Allow reuse of raw image for shallow block copy
The documentation states that for shallow block copy the image has to
have the same guest visible content as backing file of the current
image if the file is being reused. This condition can be achieved also
with a raw file (or a qcow without a backing file) so remove the
condition that would disallow it.

(This patch additionally fixes crash described in
 https://bugzilla.redhat.com/show_bug.cgi?id=1215569 )
2015-04-29 09:32:53 +02:00
Maxim Nestratov
18f24c65d5 parallels: implement domainDetachDevice and domainDetachDeviceFlags
New functions utilize previosly added prlsdkDelDisk and prlsdkGetDiskIndex
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-04-28 19:00:53 +03:00
Maxim Nestratov
0d20195e53 parallels: add prlsdkDelDisk and prlsdkGetDiskIndex functions
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-04-28 18:58:48 +03:00
Martin Kletzander
922563e73a Fix building virnetserverclientmock with MinGW
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-28 17:37:58 +02:00
Zhang Bo
e6bb622032 tests: free ChardevInfo correctly in qemumonitorjsontest
The free callback should be qemuMonitorChardevInfoFree rather
than just 'free' when virHashCreate'ing the chardevInfo hash.

==29959== 24 bytes in 2 blocks are definitely lost in loss record 19 of 53
==29959==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==29959==    by 0xB95C679: strdup (in /lib64/libc-2.20.so)
==29959==    by 0x63C6546: virStrdup (virstring.c:709)
==29959==    by 0x4805ED: qemuMonitorJSONExtractChardevInfo (qemu_monitor_json.c:3429)
==29959==    by 0x4807A5: qemuMonitorJSONGetChardevInfo (qemu_monitor_json.c:3479)
==29959==    by 0x434AEC: testQemuMonitorJSONqemuMonitorJSONGetChardevInfo (qemumonitorjsontest.c:1824)
==29959==    by 0x436F2F: virtTestRun (testutils.c:211)
==29959==    by 0x436932: mymain (qemumonitorjsontest.c:2404)
==29959==    by 0x4382EA: virtTestMain (testutils.c:863)
==29959==    by 0x436B27: main (qemumonitorjsontest.c:2423)

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
2015-04-28 17:01:16 +02:00
Zhang Bo
6f5d29f40d qemu: make qemuMonitorChardevInfoFree non-static
It would be used in qemumonitorjsontest, thus we make it non-static.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
2015-04-28 16:50:11 +02:00
Cole Robinson
56476f6a2d storage: fs: Ignore volumes that fail to open with EACCESS/EPERM
Trying to use qemu:///session to create a storage pool pointing at
/tmp will usually fail with something like:

$ virsh pool-start tmp
error: Failed to start pool tmp
error: cannot open volume '/tmp/systemd-private-c38cf0418d7a4734a66a8175996c384f-colord.service-kEyiTA': Permission denied

If any volume in an FS pool can't be opened by the daemon, the refresh
fails, and the pool can't be used.

This causes pain for virt-install/virt-manager though. Imaging a user
downloads a disk image to /tmp. virt-manager wants to import /tmp as
a storage pool, so we can detect what disk format it is, and set the
XML correctly. However this case will likely fail as explained above.

Change the logic here to skip volumes that fail to open. This could
conceivably cause user complaints along the lines of 'why doesn't
libvirt show $ROOT-OWNED-VOLUME-FOO', but figuring that currently
the pool won't even startup, I don't think there are any current
users that care about that case.

https://bugzilla.redhat.com/show_bug.cgi?id=1103308
2015-04-28 09:42:19 -04:00
Cole Robinson
65fc824666 storage: If driver startup state syncing fails, delete statefile
If you end up with a state file for a pool that no longer starts up
or refreshes correctly, the state file is never removed and adds
noise to the logs everytime libvirtd is started.

If the initial state syncing fails, delete the statefile.
2015-04-28 09:37:58 -04:00
Cole Robinson
af9dc75c1f storage: Break out storageDriverLoadPoolState
Will simplify a future patch
2015-04-28 09:37:57 -04:00