Commit Graph

12780 Commits

Author SHA1 Message Date
Stefan Berger
c772feb069 Add test case for TPM passthrough
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:46 -04:00
Stefan Berger
291cfb83f3 TPM support for QEMU command line
For TPM passthrough device support create command line parameters like:

-tpmdev passthrough,id=tpm-tpm0,path=/dev/tpm0,cancel-path=/sys/class/misc/tpm0/device/cancel -device tpm-tis,tpmdev=tpm-tpm0,id=tpm0

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:46 -04:00
Stefan Berger
22feb0d3e7 QEMU Cgroup support for TPM passthrough
Some refactoring for virDomainChrSourceDef type of devices so
we can use common code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:46 -04:00
Stefan Berger
2c9a063973 Audit the starting of a guest using TPM passthrough
When a VM with a TPM passthrough device is started, the audit daemon
logs the following type of message:

type=VIRT_RESOURCE msg=audit(1365170222.460:3378): pid=16382 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 msg='virt=kvm resrc=dev reason=start vm="TPM-PT" uuid=a4d7cd22-da89-3094-6212-079a48a309a1 device="/dev/tpm0" exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=? res=success'

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:46 -04:00
Stefan Berger
2a40a09220 Add SELinux and DAC labeling support for TPM passthrough
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:46 -04:00
Stefan Berger
f447ff5982 Convert QMP strings into QEMU capability bits
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:45 -04:00
Stefan Berger
6ecff413e1 Parse TPM passthrough XML in the domain XML
Parse the domain XML with TPM passthrough support.
The TPM passthrough XML may look like this:

    <tpm model='tpm-tis'>
      <backend type='passthrough'>
        <device path='/dev/tpm0'/>
      </backend>
    </tpm>


Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:45 -04:00
Stefan Berger
06ba4bff91 Helper functions for host TPM support
Implement helper function to create the TPM's sysfs cancel file.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:45 -04:00
Stefan Berger
5eac4f600c Add documentation and schema for TPM passthrough
Supported TPM passthrough XML may look as follows:

    <tpm model='tpm-tis'>
      <backend type='passthrough'>
        <device path='/dev/tpm0'/>
      </backend>
    </tpm>

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:45 -04:00
Stefan Berger
069219577b Add function to find a needle in a string array
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:45 -04:00
Stefan Berger
ed1f031850 Add QMP probing for TPM
Probe for QEMU's QMP TPM support by querying the lists of
supported TPM models (query-tpm-models) and backend types
(query-tpm-types). 

The setting of the capability flags following the strings
returned from the commands above is only provided in the
patch where domain_conf.c gets TPM support due to dependencies
on functions only introduced there. 

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Tested-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
2013-04-12 16:55:45 -04:00
Peter Krempa
039a3283fc conf: Allow for non-contiguous device boot orders
This patch adds the ability to configure non-contiguous boot orders on boot
devices. This allows unplugging devices that have boot order specified without
breaking migration.

The new code now uses a slightly less memory efficient approach to store the
boot order fields in a hashtable instead of a bitmap.
2013-04-12 14:43:12 +02:00
Daniel P. Berrange
e7b0382945 Tweak EOF handling of streams
Typically when you get EOF on a stream, poll will return
POLLIN|POLLHUP at the same time. Thus when we deal with
stream reads, if we see EOF during the read, we can then
clear the VIR_STREAM_EVENT_HANGUP & VIR_STREAM_EVENT_ERROR
event bits.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-04-12 11:27:57 +01:00
Li Zhang
a6e37aedff Add USB option capability
To avoid the collision for creating USB controllers in machine->init()
and -device xx command line, it needs to set usb=off to avoid one USB
controller created in machine->init(). So that libvirt can use -device
or -usb to create USB controller sucessfully.
So QEMU_CAPS_MACHINE_USB_OPT capability is added, and it is for QEMU
v1.3.0 onwards which supports USB option.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
2013-04-12 10:56:03 +01:00
John Ferlan
6528b7044f Add error handling to optional arguments in cmdCPUStats 2013-04-11 18:53:35 -04:00
John Ferlan
ad86ebb286 Remove extraneous comma in info_cpu_stats and opts_cpu_stats 2013-04-11 18:40:59 -04:00
Jiri Denemark
88624b5d4c qemu: Do not report unsafe migration for local files
When migrating a domain with disk images stored locally (and using
storage migration), we should not complain about unsafe migration no
matter what cache policy is used for that disk.
2013-04-11 21:57:50 +02:00
Peter Krempa
b83b31d87a virsh: Document that using incomplete XML files may have unexpected results
Explicitly state that using incomplete XML definition snippets for hot-management
commands may have unexpected results due to autogenerating values for some of
the fields if they aren't specified explicitly.
2013-04-11 16:44:38 +02:00
Peter Krempa
608d149e97 qemu: Try to use QMP for send-key if supported
Instead of always using HMP use the QMP send-key command introduced in qemu 1.3.
2013-04-11 16:42:30 +02:00
Michal Privoznik
0aa8397c62 virsh: Update list of shutdown/reboot modes
As of 76d9f65644 we are supporting two new modes: initctl and signal.
However, these are missing in help listing.
2013-04-11 13:03:55 +02:00
Michal Privoznik
7f15ebc7a2 qemu: Set correct migrate host in client_migrate_info
https://bugzilla.redhat.com/show_bug.cgi?id=920441

Currently, we are discarding listen attribute from qemu cookie even though
we strive to gather it. This result in not so cool bug: if user have
different networks, one for management/migration, and one for VNC/SPICE we
pass incorrect host to the qemu in client_migrate_info. What we actually
pass is remote hostname, while we should be passing remote listen address.
It doesn't matter as long as these two are the same, but they don't need
necessary to be like that.
2013-04-11 12:32:17 +02:00
Ján Tomko
74bff25090 qemu: fix crash in qemuOpen
If the path part of connection URI is not present, cfg is used
unitialized.

https://bugzilla.redhat.com/show_bug.cgi?id=950855
2013-04-11 11:41:22 +02:00
Ján Tomko
4e54714c72 conf: fix error for parallel port mismatch 2013-04-11 09:13:32 +02:00
Osier Yang
f4279c5320 cleanup: Change datatype of secret->private to boolean 2013-04-11 11:54:37 +08:00
Osier Yang
4258a548d2 cleanup: Change datatype of secret->ephemeral to boolean 2013-04-11 11:50:23 +08:00
Osier Yang
ba474c7844 cleanup: Change datatype of fs->readonly to boolean 2013-04-11 11:36:47 +08:00
Osier Yang
e9e37538bb cleanup: Change datatype of disk->readonly to boolean 2013-04-11 11:36:44 +08:00
Osier Yang
71dae03f9b cleanup: Change datatype of disk->transient to boolean 2013-04-11 11:36:41 +08:00
Osier Yang
a29bafd5de cleanup: Change datatype of disk->shared to boolean 2013-04-11 11:36:37 +08:00
Osier Yang
7a984d5713 cleanup: Change datatype of auth->expires to boolean 2013-04-11 11:36:33 +08:00
Osier Yang
1bbc1e7524 cleanup: Change datatype of hostdev->missing to boolean 2013-04-11 11:36:28 +08:00
Osier Yang
cc7da958c8 Cleanup: Change datatype of origstate's members to boolean
Members of struct virPCIDevice are changed together.
2013-04-11 11:35:17 +08:00
Osier Yang
9fda2f5cc9 Cleanup: Change datatype of hostdev->managed to boolean 2013-04-11 11:31:02 +08:00
Guannan Ren
2fff380105 conf: fix a memory leak when parsing nat port XML nodes
==5306== 8 bytes in 1 blocks are definitely lost in loss record 24 of 277
 ==5306==    at 0x4C28B2F: calloc (vg_replace_malloc.c:593)
 ==5306==    by 0x5293CAF: virAllocN (viralloc.c:152)
 ==5306==    by 0x52DFEAE: virXPathNodeSet (virxml.c:611)
 ==5306==    by 0x5313DD9: virNetworkDefParseXML (network_conf.c:1408)
 ==5306==    by 0x53170F6: virNetworkObjUpdateParseFile (network_conf.c:2031)
 ==5306==    by 0x131DA63C: networkStartup (bridge_driver.c:279)
 ==5306==    by 0x53481DF: virStateInitialize (libvirt.c:822)
 ==5306==    by 0x40DF44: daemonRunStateInit (libvirtd.c:877)
 ==5306==    by 0x52D2FF5: virThreadHelper (virthreadpthread.c:161)
 ==5306==    by 0x5D00C52: start_thread (in /usr/lib64/libpthread-2.17.so)
 ==5306==    by 0x6410ECC: clone (in /usr/lib64/libc-2.17.so)
2013-04-11 09:55:11 +08:00
Peter Krempa
b7c98329cb conf: Fix race between looking up a domain object and freeing it
This patch fixes crash of the daemon that happens due to the following race
condition:

Let's have two threads in the libvirtd daemon's qemu driver:
A - thread executing undefine on the same domain
B - thread executing a API call to get information about a domain

Assume following serialization of operations done by the threads:
1) A has the lock on the domain object and is executing some code prior to
   virDomainObjListRemove()
2) B takes the lock on the domain object list, looks up the domain object
pointer and blocks in the attempt to lock the domain object as A is holding the
lock
3) A reaches virDomainObjListRemove() and unlocks the lock on the domain object
4) A blocks on the attempt to get the domain list lock
5) B is able to lock the domain object now and unlocks the domain list
6) A is now able to lock the domain list, and sheds the last reference on the
domain object, this triggers the freeing function.
6) B starts executing the code on the pointer that is being freed
7) The libvirtd daemon crashes while attempting to access invalid pointer in
thread B.

This patch fixes the race by acquiring a reference on the domain object before
unlocking it in virDomainObjListRemove() and re-locks the object prior to
removing and freeing it. This ensures that no thread holds a lock on the domain
object at the time it is removed from the list, and that doing a list lookup
will never find a domain that is about to vanish.

This is a minimal fix of the problem, but a better solution will be to switch to
full reference counting for domain objects.
2013-04-10 09:32:03 +02:00
Eric Blake
cdb1c3b6e2 docs: fix typo when using Kerberos principals
Kerberos uses 'primary' or 'key' files (principals), not 'abstract
ideal' or 'rule' files (principles).  Reported by Jason Meinzer.

Reflow a paragraph to fit in 80 columns in the process.

* docs/auth.html.in: Fix spelling.
2013-04-09 16:46:04 -06:00
Eric Blake
d7468b7d47 maint: update to latest gnulib
While this update doesn't address any reported problems in libvirt,
doing a post-release update to latest gnulib makes it easier to
stay in sync with best upstream practices.

* .gnulib: Update to latest.
* bootstrap: Resynchronize.
2013-04-09 14:22:09 -06:00
Laine Stump
9579b6bc20 Fix crash in virNetDevGetVirtualFunctions
Commit 9a3ff01d7f (which was ACKed at
the end of January, but for some reason didn't get pushed until during
the 1.0.4 freeze) fixed the logic in virPCIGetVirtualFunctions().
Unfortunately, a typo in the fix (replacing VIR_REALLOC_N with
VIR_ALLOC_N during code movement) caused not only a memory leak, but
also resulted in most of the elements of the result array being
replaced with NULL. virNetDevGetVirtualFunctions() assumed (and I think
rightly so) that virPCIGetVirtualFunctions() wouldn't return any NULL
elements in the array, so it ended up segfaulting.

This was found when attempting to use a virtual network with an
auto-created pool of SRIOV VFs, e.g.:

    <forward mode='hostdev' managed='yes'>
      <pf dev='eth4'/>
    </forward>

(the pool of PCI addresses is discovered by calling
virNetDevGetVirtualFunctions() on the PF dev).
2013-04-09 14:26:12 -04:00
Ján Tomko
96c45f66fb docs: use MiB/s instead of Mbps for migration speed
https://bugzilla.redhat.com/show_bug.cgi?id=948821
2013-04-09 16:45:24 +02:00
Han Cheng
0f5837aac2 schemas: Move PortNumber and sourceinfoadapter to basictypes.rng
The definiton of scsi adapter in storagespool.rng (sourceinfoadapter)
can be used by scsi hostdev in later patch. Move it to basictypes.rng.

PortNumber is defined in both domaincommon.rng and storagespool.rng,
simplify it by moving it to basictypes.rng.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
2013-04-09 22:34:02 +08:00
Osier Yang
8de8d46acc docs: Add the missed <pre> tag 2013-04-09 22:29:39 +08:00
Han Cheng
5bc5a44db9 conf: Change help function
The helper function to look up disk controller model may be used by scsi
hostdev. But it should be changed to use device info.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
2013-04-09 22:21:16 +08:00
Peter Krempa
b0216da8ee qemu: Remove now obsolete assignment of default network card model for s390 hosts
This effectively reverts commit 539d73dbf6 as the
changes aren't needed after introduction of the XML post parse callbacks.
2013-04-09 15:47:58 +02:00
Peter Krempa
74ba039f82 qemu: Clean up network device CLI generator
With the default model assigned in the parse callback, this code is now obsolete.
2013-04-09 15:47:58 +02:00
Viktor Mihajlovski
d8ddf522a0 qemu: Use correct default model on s390
Commit a68d672667 breaks networking on s390 as it
changes the default network card model.
2013-04-09 15:47:58 +02:00
Alex Jia
c3e33e68d9 sanlock: add missing test command in virt-sanlock-cleanup.in
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=949483

Signed-off-by: Alex Jia <ajia@redhat.com>
2013-04-09 13:01:33 +08:00
Milos Vyletel
396c4d34f8 Generate RFC4122 compliant UUIDs
Even though http://libvirt.org/formatdomain.html#elementsMetadata
states that it requires RFC4122 compliance UUIDs that are generated
by virUUIDGenerate() are not. Following patch modifies generated
UUIDs to conform to rules described in RFC.

Signed-off-by: Milos Vyletel <milos.vyletel@sde.cz>
2013-04-08 13:18:07 -06:00
Daniel P. Berrange
1bd955ed60 Unmount existing filesystems under user specified mounts in LXC
If the user requests a mount for /run, this may hide any existing
mounts that are lower down in /run. The result is that the
container still sees the mounts in /proc/mounts, but cannot
access them

sh-4.2# df
df: '/run/user/501/gvfs': No such file or directory
df: '/run/media/berrange/LIVE': No such file or directory
df: '/run/media/berrange/SecureDiskA1': No such file or directory
df: '/run/libvirt/lxc/sandbox': No such file or directory
Filesystem                      1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_t500wlan-lv_root 151476396 135390200   8384900  95% /
tmpfs                             1970888      3204   1967684   1% /run
/dev/sda1                          194241    155940     28061  85% /boot
devfs                                  64         0        64   0% /dev
tmpfs                                  64         0        64   0% /sys/fs/cgroup
tmpfs                             1970888      1200   1969688   1% /etc/libvirt-sandbox/scratch

Before mounting any filesystem at a particular location, we
must recursively unmount anything at or below the target mount
point

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-04-08 17:40:08 +01:00
Daniel P. Berrange
2863ca22f3 Move lxcContainerUnmountSubtree further up in file
Ensure lxcContainerUnmountSubtree is at the top of the
lxc_container.c file so it is easily referenced from
any other method. No functional change

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-04-08 17:40:08 +01:00
Bogdan Purcareata
442d6a0527 Implement support for <hostdev caps=net>
This allows a container-type domain to have exclusive access to one of
the host's NICs.

Wire <hostdev caps=net> with the lxc_controller - when moving the newly
created veth devices into a new namespace, also look for any hostdev
devices that should be moved. Note: once the container domain has been
destroyed, there is no code that moves the interfaces back to the
original namespace. This does happen, though, probably due to default
cleanup on namespace destruction.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
2013-04-08 17:40:08 +01:00