OSDN Git Service

qmiga/qemu.git
8 years agolinux-user,sh4: fix signal retcode address
Laurent Vivier [Mon, 23 Nov 2015 10:38:26 +0000 (11:38 +0100)]
linux-user,sh4: fix signal retcode address

To return from a signal, setup_frame() puts an instruction to
be executed in the stack. This sequence calls the syscall sigreturn().

The address of the instruction must be set in the PR register
to be executed.

This patch fixes this: the current code sets the register to the address
of the instruction in the host address space (which can be 64bit whereas
PR is only 32bit), but the virtual CPU can't access this address space,
so we put in PR the address of the instruction in the guest address space.

This patch also removes an useless variable (ret) in the modified functions.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: check fd is >= 0 in fd_trans_host_to_target_data/fd_trans_host_to_target_addr
Laurent Vivier [Wed, 28 Oct 2015 20:40:46 +0000 (21:40 +0100)]
linux-user: check fd is >= 0 in fd_trans_host_to_target_data/fd_trans_host_to_target_addr

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: manage bind with a socket of SOCK_PACKET type.
Laurent Vivier [Wed, 28 Oct 2015 20:40:45 +0000 (21:40 +0100)]
linux-user: manage bind with a socket of SOCK_PACKET type.

This is obsolete, but if we want to use dhcp with an old distro (like debian
etch), we need it. Some users (like dhclient) use SOCK_PACKET with AF_PACKET
and the kernel allows that.

packet(7)

  In Linux 2.0, the only way to  get  a  packet  socket  was  by calling
  socket(AF_INET,  SOCK_PACKET,  protocol).   This is still supported but
  strongly deprecated.  The main difference between the  two methods  is
  that  SOCK_PACKET uses the old struct sockaddr_pkt to specify an inter‐
  face, which doesn't provide physical layer independence.

     struct sockaddr_pkt {
         unsigned short spkt_family;
         unsigned char  spkt_device[14];
         unsigned short spkt_protocol;
     };

  spkt_family contains the device type, spkt_protocol is the  IEEE 802.3
  protocol  type  as  defined  in <sys/if_ether.h> and spkt_device is the
  device name as a null-terminated string, for example, eth0.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: add a function hook to translate sockaddr
Laurent Vivier [Wed, 28 Oct 2015 20:40:44 +0000 (21:40 +0100)]
linux-user: add a function hook to translate sockaddr

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: rename TargetFdFunc to TargetFdDataFunc, and structure fields accordingly
Laurent Vivier [Wed, 28 Oct 2015 20:40:43 +0000 (21:40 +0100)]
linux-user: rename TargetFdFunc to TargetFdDataFunc, and structure fields accordingly

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: SOCK_PACKET uses network endian to encode protocol in socket()
Laurent Vivier [Wed, 28 Oct 2015 20:40:42 +0000 (21:40 +0100)]
linux-user: SOCK_PACKET uses network endian to encode protocol in socket()

in PACKET(7) :

  packet_socket = socket(AF_PACKET, int socket_type, int protocol);
[...]
                                   protocol is the  IEEE  802.3 protocol
  number in network order.  See the <linux/if_ether.h> include file for a
  list of allowed protocols.  When protocol is  set  to htons(ETH_P_ALL)
  then all protocols are received.  All incoming packets of that protocol
  type will be passed to the packet socket before they are passed to the
  protocols implemented in the kernel.
[...]
Compatibility

  In Linux 2.0, the only way to  get  a  packet  socket  was  by  calling
  socket(AF_INET,  SOCK_PACKET,  protocol).

We need to tswap16() the protocol because on big-endian, the ABI is
waiting for, for instance for ETH_P_ALL, 0x0003 (big endian ==
network order), whereas on little-endian it is waiting for 0x0300.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0()
Harmandeep Kaur [Tue, 6 Oct 2015 16:17:12 +0000 (21:47 +0530)]
linux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0()

Convert malloc()/ calloc() calls to g_malloc()/ g_try_malloc()/ g_new0()

All heap memory allocation should go through glib so that we can take
advantage of a single memory allocator and its debugging/tracing features.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: in poll(), if nfds is 0, pfd can be NULL
Laurent Vivier [Mon, 5 Oct 2015 23:20:48 +0000 (01:20 +0200)]
linux-user: in poll(), if nfds is 0, pfd can be NULL

This problem appears with yum in Fedora 20 / PPC64 container.

test case:

    #include <stdio.h>
    #include <poll.h>

    int main(void)
    {
        int ret;

        ret = poll(NULL, 0, 1000);
        printf("%d\n", ret);
    }

target test environment: Fedora 20 / PPC64
host test environment: Ubuntu 14.0.2 / x86_64

original test result: -1

    13451 poll(0,0,1000,274886297496,268566664,268566648) = -1 errno=14 (Bad address)

patched test result: 0

    13536 poll(0,0,1000,274886297496,268566664,268566648) = 0

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: correctly align target_epoll_event
Laurent Vivier [Sat, 3 Oct 2015 15:14:06 +0000 (17:14 +0200)]
linux-user: correctly align target_epoll_event

According to comments in /usr/include/linux/eventpoll.h,
poll_event is packed only on x86_64.

And to be sure fields are correctly aligned in epoll_data,
use abi_XXX types for all of them.

Moreover, fd type is wrong: fd is int, not ulong.

This has been tested with a ppc guest on an x86_64 host:
without this patch, systemd crashes (core).

CC: Alexander Graf <agraf@suse.de>
CC: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agolinux-user: add signalfd/signalfd4 syscalls
Laurent Vivier [Fri, 2 Oct 2015 12:48:09 +0000 (14:48 +0200)]
linux-user: add signalfd/signalfd4 syscalls

This patch introduces a system very similar to the one used in the kernel
to attach specific functions to a given file descriptor.

In this case, we attach a specific "host_to_target()" translator to the fd
returned by signalfd() to be able to byte-swap the signalfd_siginfo
structure provided by read().

This patch allows to execute the example program given by
man signalfd(2):

 #include <sys/signalfd.h>
 #include <signal.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>

 #define handle_error(msg) \
     do { perror(msg); exit(EXIT_FAILURE); } while (0)

 int
 main(int argc, char *argv[])
 {
     sigset_t mask;
     int sfd;
     struct signalfd_siginfo fdsi;
     ssize_t s;

     sigemptyset(&mask);
     sigaddset(&mask, SIGINT);
     sigaddset(&mask, SIGQUIT);

     /* Block signals so that they aren't handled
        according to their default dispositions */

     if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1)
         handle_error("sigprocmask");

     sfd = signalfd(-1, &mask, 0);
     if (sfd == -1)
         handle_error("signalfd");

     for (;;) {
         s = read(sfd, &fdsi, sizeof(struct signalfd_siginfo));
         if (s != sizeof(struct signalfd_siginfo))
             handle_error("read");

         if (fdsi.ssi_signo == SIGINT) {
             printf("Got SIGINT\n");
         } else if (fdsi.ssi_signo == SIGQUIT) {
             printf("Got SIGQUIT\n");
             exit(EXIT_SUCCESS);
         } else {
             printf("Read unexpected signal\n");
         }
     }
 }

 $ ./signalfd_demo
 ^CGot SIGINT
 ^CGot SIGINT
 ^\Got SIGQUIT

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-crypto-fixes-2015-12-23...
Peter Maydell [Wed, 23 Dec 2015 13:53:32 +0000 (13:53 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/pull-crypto-fixes-2015-12-23-1' into staging

Merge misc crypto changes & fixes

# gpg: Signature made Wed 23 Dec 2015 11:11:54 GMT using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"

* remotes/berrange/tags/pull-crypto-fixes-2015-12-23-1:
  crypto: fix transposed arguments in cipher error message
  crypto: ensure qapi/crypto.json is listed in qapi-modules
  crypto: move QCryptoCipherAlgorithm/Mode enum definitions into QAPI
  crypto: move QCryptoHashAlgorithm enum definition into QAPI
  crypto: add ability to query hash digest len
  crypto: add additional query accessors for cipher instances

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging
Peter Maydell [Wed, 23 Dec 2015 13:29:47 +0000 (13:29 +0000)]
Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging

Fix a 2.5 regression.

# gpg: Signature made Wed 23 Dec 2015 10:57:00 GMT using DSA key ID 0101DBC2
# gpg: Good signature from "Greg Kurz <gkurz@fr.ibm.com>"
# gpg:                 aka "Greg Kurz <groug@free.fr>"
# gpg:                 aka "Greg Kurz <gkurz@linux.vnet.ibm.com>"
# gpg:                 aka "Gregory Kurz (Groug) <groug@free.fr>"
# gpg:                 aka "Gregory Kurz (Cimai Technology) <gkurz@cimai.com>"
# gpg:                 aka "Gregory Kurz (Meiosys Technology) <gkurz@meiosys.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 2BD4 3B44 535E C0A7 9894  DBA2 02FC 3AEB 0101 DBC2

* remotes/gkurz/tags/for-upstream:
  virtio-9p: use accessor to get thread_pool

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-io-fixes-2015-12-23-1' into...
Peter Maydell [Wed, 23 Dec 2015 12:55:55 +0000 (12:55 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/pull-io-fixes-2015-12-23-1' into staging

Merge misc I/O channel fixes

# gpg: Signature made Wed 23 Dec 2015 10:54:52 GMT using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"

* remotes/berrange/tags/pull-io-fixes-2015-12-23-1:
  io: fix stack allocation when sending of file descriptors
  io: fix setting of QIO_CHANNEL_FEATURE_FD_PASS on server connections
  io: bind to loopback IP addrs in test suite

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Peter Maydell [Wed, 23 Dec 2015 12:27:51 +0000 (12:27 +0000)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

acpi, pc features

pxb support for q35
nvdimm support
most of ipmi support
part of DSDT rewrite

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Tue 22 Dec 2015 16:47:18 GMT using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream: (55 commits)
  acpi: extend aml_and() to accept target argument
  acpi: extend aml_or() to accept target argument
  acpi add aml_dma()
  acpi: add aml_to_buffer()
  acpi: add aml_to_hexstring()
  acpi: extend aml_field() to support LockRule
  acpi: add aml_lgreater()
  acpi: add aml_lor()
  acpi: add aml_sleep()
  acpi: add aml_alias()
  acpi: extend aml_shiftright() to accept target argument
  acpi: add aml_to_integer()
  acpi: add aml_call0() helper
  acpi: add aml_decrement() and aml_subtract()
  acpi: extend aml_add() to accept target argument
  acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
  acpi: add aml_create_qword_field()
  acpi: add aml_mutex(), aml_acquire(), aml_release()
  acpi: add aml_lgreater_equal()
  acpi: add aml_sizeof
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/sstabellini/tags/xen-2015-12-22' into staging
Peter Maydell [Wed, 23 Dec 2015 12:04:01 +0000 (12:04 +0000)]
Merge remote-tracking branch 'remotes/sstabellini/tags/xen-2015-12-22' into staging

Xen 2015/12/22

# gpg: Signature made Tue 22 Dec 2015 16:17:57 GMT using RSA key ID 70E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"

* remotes/sstabellini/tags/xen-2015-12-22:
  xen_disk: treat "vhd" as "vpc"
  xen/pass-through: correctly deal with RW1C bits
  xen/MSI-X: really enforce alignment
  xen/MSI-X: latch MSI-X table writes

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agocrypto: fix transposed arguments in cipher error message
Daniel P. Berrange [Fri, 20 Nov 2015 16:15:42 +0000 (16:15 +0000)]
crypto: fix transposed arguments in cipher error message

When reporting an incorrect key length for a cipher, we
mixed up the actual vs expected arguments.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: ensure qapi/crypto.json is listed in qapi-modules
Daniel P. Berrange [Thu, 19 Nov 2015 17:18:39 +0000 (17:18 +0000)]
crypto: ensure qapi/crypto.json is listed in qapi-modules

The rebuild of qapi-types.c/h is not correctly triggered
when qapi/crypto.json is changed because it was missing
from the list of files in the qapi-modules variable.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: move QCryptoCipherAlgorithm/Mode enum definitions into QAPI
Daniel P. Berrange [Thu, 19 Nov 2015 17:09:01 +0000 (17:09 +0000)]
crypto: move QCryptoCipherAlgorithm/Mode enum definitions into QAPI

The QCryptoCipherAlgorithm and QCryptoCipherMode enums are
defined in the crypto/cipher.h header. In the future some
QAPI types will want to reference the hash enums, so move
the enum definition into QAPI too.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: move QCryptoHashAlgorithm enum definition into QAPI
Daniel P. Berrange [Thu, 19 Nov 2015 17:09:01 +0000 (17:09 +0000)]
crypto: move QCryptoHashAlgorithm enum definition into QAPI

The QCryptoHashAlgorithm enum is defined in the crypto/hash.h
header. In the future some QAPI types will want to reference
the hash enums, so move the enum definition into QAPI too.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: add ability to query hash digest len
Daniel P. Berrange [Fri, 23 Oct 2015 15:14:50 +0000 (16:14 +0100)]
crypto: add ability to query hash digest len

Add a qcrypto_hash_digest_len() method which allows querying of
the raw digest size for a given hash algorithm.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: add additional query accessors for cipher instances
Daniel P. Berrange [Fri, 23 Oct 2015 15:13:50 +0000 (16:13 +0100)]
crypto: add additional query accessors for cipher instances

Adds new methods to allow querying the length of the cipher
key, block size and initialization vectors.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoio: fix stack allocation when sending of file descriptors
Daniel P. Berrange [Mon, 21 Dec 2015 11:58:51 +0000 (11:58 +0000)]
io: fix stack allocation when sending of file descriptors

When sending file descriptors over a socket, we have to
allocate a data buffer to hold the FDs in the scmsghdr.
Unfortunately we allocated the buffer on the stack inside
an if () {} block, but called sendmsg() outside the block.
So the stack bytes holding the FDs were liable to be
overwritten with other data. By luck this was not a problem
when sending 1 FD, but if sending 2 or more then it would
fail.

The fix is to simply move the variables outside the nested
'if' block. To keep valgrind quiet we also zero-initialize
the 'control' buffer.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirtio-9p: use accessor to get thread_pool
Greg Kurz [Wed, 23 Dec 2015 09:56:58 +0000 (10:56 +0100)]
virtio-9p: use accessor to get thread_pool

The aio_context_new() function does not allocate a thread pool. This is
deferred to the first call to the aio_get_thread_pool() accessor. It is
hence forbidden to access the thread_pool field directly, as it may be
NULL. The accessor *must* be used always.

Fixes: ebac1202c95a4f1b76b6ef3f0f63926fa76e753e
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-stable@nongnu.org
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
8 years agoio: fix setting of QIO_CHANNEL_FEATURE_FD_PASS on server connections
Daniel P. Berrange [Mon, 21 Dec 2015 12:04:21 +0000 (12:04 +0000)]
io: fix setting of QIO_CHANNEL_FEATURE_FD_PASS on server connections

The QIO_CHANNEL_FEATURE_FD_PASS feature flag is set in the
qio_channel_socket_set_fd() method, however, this only deals
with client side connections.

To ensure server side connections also have the feature flag
set, we must set it in qio_channel_socket_accept() too. This
also highlighted a typo fix where the code updated the
sockaddr struct in the wrong object instance.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoio: bind to loopback IP addrs in test suite
Daniel P. Berrange [Tue, 22 Dec 2015 15:43:42 +0000 (15:43 +0000)]
io: bind to loopback IP addrs in test suite

The test suite currently binds to 0.0.0.0 or ::, which covers
all interfaces of the machine. It is bad practice for test
suite to open publically accessible ports on a machine, so
switch to use loopback addrs 127.0.0.1 or ::1.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoacpi: extend aml_and() to accept target argument
Igor Mammedov [Wed, 9 Dec 2015 23:41:17 +0000 (00:41 +0100)]
acpi: extend aml_and() to accept target argument

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: extend aml_or() to accept target argument
Igor Mammedov [Wed, 9 Dec 2015 23:41:16 +0000 (00:41 +0100)]
acpi: extend aml_or() to accept target argument

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi add aml_dma()
Igor Mammedov [Wed, 9 Dec 2015 23:41:15 +0000 (00:41 +0100)]
acpi add aml_dma()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: add aml_to_buffer()
Igor Mammedov [Wed, 9 Dec 2015 23:41:14 +0000 (00:41 +0100)]
acpi: add aml_to_buffer()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_to_hexstring()
Igor Mammedov [Wed, 9 Dec 2015 23:41:13 +0000 (00:41 +0100)]
acpi: add aml_to_hexstring()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: extend aml_field() to support LockRule
Igor Mammedov [Wed, 9 Dec 2015 23:41:12 +0000 (00:41 +0100)]
acpi: extend aml_field() to support LockRule

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: add aml_lgreater()
Igor Mammedov [Wed, 9 Dec 2015 23:41:11 +0000 (00:41 +0100)]
acpi: add aml_lgreater()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_lor()
Igor Mammedov [Wed, 9 Dec 2015 23:41:10 +0000 (00:41 +0100)]
acpi: add aml_lor()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_sleep()
Igor Mammedov [Wed, 9 Dec 2015 23:41:08 +0000 (00:41 +0100)]
acpi: add aml_sleep()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_alias()
Igor Mammedov [Wed, 9 Dec 2015 23:41:07 +0000 (00:41 +0100)]
acpi: add aml_alias()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: extend aml_shiftright() to accept target argument
Igor Mammedov [Wed, 9 Dec 2015 23:41:06 +0000 (00:41 +0100)]
acpi: extend aml_shiftright() to accept target argument

it allows to express ShiftRight(A,B,C) syntax

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_to_integer()
Igor Mammedov [Wed, 9 Dec 2015 23:41:05 +0000 (00:41 +0100)]
acpi: add aml_to_integer()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_call0() helper
Igor Mammedov [Wed, 9 Dec 2015 23:41:04 +0000 (00:41 +0100)]
acpi: add aml_call0() helper

it will help to call a method with 0 arguments

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_decrement() and aml_subtract()
Igor Mammedov [Wed, 9 Dec 2015 23:41:03 +0000 (00:41 +0100)]
acpi: add aml_decrement() and aml_subtract()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: extend aml_add() to accept target argument
Igor Mammedov [Wed, 9 Dec 2015 23:41:02 +0000 (00:41 +0100)]
acpi: extend aml_add() to accept target argument

it allows to express following ASL expression:
 Add(arg1, arg2, result)

usecases that do not need to store result
should pass NULL as 3rd arg that would express
 Add(arg1, arg2,)
construct.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern
Igor Mammedov [Wed, 9 Dec 2015 23:41:01 +0000 (00:41 +0100)]
acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern

Currently AML API doesn't compose terms in form of
following pattern:

   Opcode Arg2 Arg2 [Dst]

but ASL used in piix4/q35 DSDT ACPI tables uses that
form, so for clean conversion of it, AML API should
be able to handle an optional 'Dst' argumet used there.

Since above pattern is used by arithmetic/bit ops,
introduce helper that they could reuse.
It reduces code duplication in existing 5 aml_foo()
functions and also will prevent more duplication
when exiting functions are extended to support
optional 'Dst' argument.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
8 years agoacpi: add aml_create_qword_field()
Igor Mammedov [Wed, 9 Dec 2015 23:41:00 +0000 (00:41 +0100)]
acpi: add aml_create_qword_field()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoacpi: add aml_mutex(), aml_acquire(), aml_release()
Xiao Guangrong [Wed, 9 Dec 2015 23:40:59 +0000 (00:40 +0100)]
acpi: add aml_mutex(), aml_acquire(), aml_release()

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: add aml_lgreater_equal()
Igor Mammedov [Wed, 9 Dec 2015 23:40:58 +0000 (00:40 +0100)]
acpi: add aml_lgreater_equal()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
8 years agoacpi: add aml_sizeof
Xiao Guangrong [Wed, 9 Dec 2015 23:40:57 +0000 (00:40 +0100)]
acpi: add aml_sizeof

Implement SizeOf term which is used by NVDIMM _DSM method in later patch

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: add aml_derefof
Xiao Guangrong [Wed, 9 Dec 2015 23:40:56 +0000 (00:40 +0100)]
acpi: add aml_derefof

Implement DeRefOf term which is used by NVDIMM _DSM method in later patch

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agonvdimm: add maintain info
Xiao Guangrong [Wed, 2 Dec 2015 07:21:00 +0000 (15:21 +0800)]
nvdimm: add maintain info

Add NVDIMM maintainer

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agonvdimm acpi: build ACPI nvdimm devices
Xiao Guangrong [Wed, 2 Dec 2015 07:20:59 +0000 (15:20 +0800)]
nvdimm acpi: build ACPI nvdimm devices

NVDIMM devices is defined in ACPI 6.0 9.20 NVDIMM Devices

There is a root device under \_SB and specified NVDIMM devices are under the
root device. Each NVDIMM device has _ADR which returns its handle used to
associate MEMDEV structure in NFIT

Currently, we do not support any function on _DSM, that means, NVDIMM
label data has not been supported yet

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agonvdimm acpi: build ACPI NFIT table
Xiao Guangrong [Wed, 2 Dec 2015 07:20:58 +0000 (15:20 +0800)]
nvdimm acpi: build ACPI NFIT table

NFIT is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT)

Currently, we only support PMEM mode. Each device has 3 structures:
- SPA structure, defines the PMEM region info

- MEM DEV structure, it has the @handle which is used to associate specified
  ACPI NVDIMM  device we will introduce in later patch.
  Also we can happily ignored the memory device's interleave, the real
  nvdimm hardware access is hidden behind host

- DCR structure, it defines vendor ID used to associate specified vendor
  nvdimm driver. Since we only implement PMEM mode this time, Command
  window and Data window are not needed

The NVDIMM functionality is controlled by the parameter, 'nvdimm', which
is introduced for the machine, there is a example to enable it:
-machine pc,nvdimm -m 8G,maxmem=100G,slots=100  -object \
memory-backend-file,id=mem1,share,mem-path=/tmp/nvdimm1,size=10G -device \
nvdimm,memdev=mem1,id=nv1

It is disabled on default

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: support specified oem table id for build_header
Xiao Guangrong [Wed, 2 Dec 2015 07:20:57 +0000 (15:20 +0800)]
acpi: support specified oem table id for build_header

Let build_header() support specified OEM table id so that we can build
multiple SSDT later

If the oem table id is not specified (aka, NULL), we use the default id
instead as the previous behavior

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agonvdimm: implement NVDIMM device abstract
Xiao Guangrong [Wed, 2 Dec 2015 07:20:56 +0000 (15:20 +0800)]
nvdimm: implement NVDIMM device abstract

Introduce "nvdimm" device which is based on pc-dimm device type

Currently, nothing is specific for nvdimm but hotplug is disabled

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agodocs/pci_expander_bridge: fix typo
Cao jin [Tue, 22 Dec 2015 12:00:43 +0000 (20:00 +0800)]
docs/pci_expander_bridge: fix typo

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agohw/compat.h: Change indentation of HW_COMPAT_* to 4 spaces
Eduardo Habkost [Mon, 30 Nov 2015 14:56:38 +0000 (12:56 -0200)]
hw/compat.h: Change indentation of HW_COMPAT_* to 4 spaces

Cosmetic change only.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agopc: Change indentation of PC_COMPAT_* to 4 spaces
Eduardo Habkost [Mon, 30 Nov 2015 14:56:37 +0000 (12:56 -0200)]
pc: Change indentation of PC_COMPAT_* to 4 spaces

Cosmetic change only.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agopc: Add pc-*-2.6 machine classes
Eduardo Habkost [Mon, 30 Nov 2015 14:56:36 +0000 (12:56 -0200)]
pc: Add pc-*-2.6 machine classes

Add pc-i440fx-2.6 and pc-q35-2.6 machine classes.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agopc: Remove redundant code from pc-*-2.3 machine classes
Eduardo Habkost [Mon, 30 Nov 2015 14:56:35 +0000 (12:56 -0200)]
pc: Remove redundant code from pc-*-2.3 machine classes

Remove the redundant 'alias = NULL' and 'is_default = 0' lines
from older machine-types. pc_*_2_4_machine_options() already
clear those fields, so they don't need to be cleared by
pc_*_2_3_machine_options().

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agoq35: skip q35-acpi-dsdt.aml load if not needed
Gerd Hoffmann [Thu, 17 Dec 2015 10:40:49 +0000 (11:40 +0100)]
q35: skip q35-acpi-dsdt.aml load if not needed

Only old machine types which don't use the acpi builder (qemu 1.7 + older)
have to load that file for proper acpi support.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a force off function
Corey Minyard [Thu, 17 Dec 2015 18:50:19 +0000 (12:50 -0600)]
ipmi: Add a force off function

Allow the IPMI interface to request a forced power off.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add firmware registration to the ISA interface
Corey Minyard [Thu, 17 Dec 2015 18:50:13 +0000 (12:50 -0600)]
ipmi: Add firmware registration to the ISA interface

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a firmware configuration repository
Corey Minyard [Thu, 17 Dec 2015 18:50:12 +0000 (12:50 -0600)]
ipmi: Add a firmware configuration repository

Add a way for IPMI devices to register their firmware information
with the IPMI subsystem so that various firmware entities can pull
that information later for adding to firmware tables.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add migration capability to the IPMI devices.
Corey Minyard [Thu, 17 Dec 2015 18:50:11 +0000 (12:50 -0600)]
ipmi: Add migration capability to the IPMI devices.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add documentation
Corey Minyard [Thu, 17 Dec 2015 18:50:10 +0000 (12:50 -0600)]
ipmi: Add documentation

Add some basic documentation for the IPMI device.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add tests
Corey Minyard [Thu, 17 Dec 2015 18:50:09 +0000 (12:50 -0600)]
ipmi: Add tests

Test the KCS interface with a local BMC and a BT interface with an
external BMC.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a BT low-level interface
Corey Minyard [Thu, 17 Dec 2015 18:50:08 +0000 (12:50 -0600)]
ipmi: Add a BT low-level interface

This provides the simulation of the BT hardware interface for
IPMI.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add an ISA KCS low-level interface
Corey Minyard [Thu, 17 Dec 2015 18:50:07 +0000 (12:50 -0600)]
ipmi: Add an ISA KCS low-level interface

This provides the simulation of the KCS hardware interface.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add an external connection simulation interface
Corey Minyard [Thu, 17 Dec 2015 18:50:06 +0000 (12:50 -0600)]
ipmi: Add an external connection simulation interface

This adds an interface for IPMI that connects to a remote
BMC over a chardev (generally a TCP socket).  The OpenIPMI
lanserv simulator describes this interface, see that for
interface details.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a local BMC simulation
Corey Minyard [Thu, 17 Dec 2015 18:50:05 +0000 (12:50 -0600)]
ipmi: Add a local BMC simulation

This provides a minimal local BMC, basically enough to comply with the
spec and provide a complete watchdog timer (including a sensor, SDR,
and event).

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoAdd a base IPMI interface
Corey Minyard [Thu, 17 Dec 2015 18:50:04 +0000 (12:50 -0600)]
Add a base IPMI interface

Add the basic IPMI types and infrastructure to QEMU.  Low-level
interfaces and simulation interfaces will register with this; it's
kind of the go-between to tie them together.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Group and document related PCMachineState/PCMachineclass fields
Eduardo Habkost [Fri, 11 Dec 2015 18:42:21 +0000 (16:42 -0200)]
pc: Group and document related PCMachineState/PCMachineclass fields

Group related PCMachineState and PCMachineClass fields into
sections, and move existing field descriptions to doc comments.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoq35: Remove MCHPCIState.guest_info field
Eduardo Habkost [Fri, 11 Dec 2015 18:42:20 +0000 (16:42 -0200)]
q35: Remove MCHPCIState.guest_info field

The field is not used for anything.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agohw/i386: extend pxb query for all PC machines
Marcel Apfelbaum [Thu, 26 Nov 2015 16:00:28 +0000 (18:00 +0200)]
hw/i386: extend pxb query for all PC machines

Add bus property to PC machines and use it when looking
for primary PCI root bus (bus 0).

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
8 years agohw/pxb: introduce pxb-pcie expander for PCIe machines
Marcel Apfelbaum [Thu, 26 Nov 2015 16:00:27 +0000 (18:00 +0200)]
hw/pxb: introduce pxb-pcie expander for PCIe machines

The pxb-pcie is the counterpart of pxb for PCI express machines.
The new device re-uses the pxb code, but appears to the guests
as a different device. The pxb-pcie device does not have an internal
pci-pci bridge and exposes a PCIe root bus instead of a PCI one.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agohw/acpi: merge pxb adjacent memory/IO ranges
Marcel Apfelbaum [Thu, 26 Nov 2015 16:00:26 +0000 (18:00 +0200)]
hw/acpi: merge pxb adjacent memory/IO ranges

A generic PCI Bus Expander doesn't necessary have a built-in PCI bridge.
Int this case the ACPI will include IO/MEM ranges per device. Try to merge
adjacent resources to reduce the ACPI tables length.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:08 +0000 (20:58 -0200)]
pc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass

This way, these settings can be simply set on the corresponding
machine_options() function, instead of requiring code in
pc_compat_*() functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agopc: Remove enforce-aligned-dimm QOM property
Eduardo Habkost [Tue, 1 Dec 2015 22:58:07 +0000 (20:58 -0200)]
pc: Remove enforce-aligned-dimm QOM property

The property is read-only and not used for anything.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Move enforce_aligned_dimm to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:06 +0000 (20:58 -0200)]
pc: Move enforce_aligned_dimm to PCMachineClass

enforce_aligned_dimm never changes after the machine is
initialized, so it can be simply set in PCMachineClass like all
the other compat fields.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Move acpi_data_size global to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:05 +0000 (20:58 -0200)]
pc: Move acpi_data_size global to PCMachineClass

This way we don't need code in pc_compat_*() functions to set the legacy
acpi_data_size value.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agopc: Move legacy_acpi_table_size global to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:04 +0000 (20:58 -0200)]
pc: Move legacy_acpi_table_size global to PCMachineClass

This way we can set legacy_acpi_table_size on the machine_options()
functions, instead of requirng code in pc_compat_*() functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agopc: Move compat boolean globals to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:03 +0000 (20:58 -0200)]
pc: Move compat boolean globals to PCMachineClass

This way the compat flags can be initialized in the machine_options()
function. This will help us to eventually eliminate the pc_compat_*()
functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agommap-alloc: tweak a comment on ppc64
Michael S. Tsirkin [Thu, 3 Dec 2015 08:35:31 +0000 (10:35 +0200)]
mmap-alloc: tweak a comment on ppc64

The comment I put in mmap-alloc to document the ppc64 rules
refers to the previous revision of the patch:
we don't look at memory alignment anymore, we check
the fs from which the fd is mapped, instead.

It's also not clear what does "in this case" refer
to, rearrange text to make it clearer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Tue, 22 Dec 2015 14:21:42 +0000 (14:21 +0000)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

# gpg: Signature made Tue 22 Dec 2015 08:52:55 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  sdhci: add optional quirk property to disable card insertion/removal interrupts
  sdhci: don't raise a command index error for an unexpected response
  sd: sdhci: Delete over-zealous power check
  scripts/gdb: Fix a python exception in mtree.py
  parallels: add format spec
  block/mirror: replace IOV_MAX with blk_get_max_iov()
  block: replace IOV_MAX with BlockLimits.max_iov
  block-backend: add blk_get_max_iov()
  block: add BlockLimits.max_iov field
  virtio-blk: trivial code optimization

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agosdhci: add optional quirk property to disable card insertion/removal interrupts
Andrew Baumann [Mon, 21 Dec 2015 22:47:49 +0000 (14:47 -0800)]
sdhci: add optional quirk property to disable card insertion/removal interrupts

This is needed for a quirk of the Raspberry Pi (bcm2835/6) MMC
controller, where the card insert bit is documented as unimplemented
(always reads zero, doesn't generate interrupts) but is in fact
observed on hardware as set at power on, but is cleared (and remains
clear) on subsequent controller resets.

Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1450738069-18664-4-git-send-email-Andrew.Baumann@microsoft.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agosdhci: don't raise a command index error for an unexpected response
Andrew Baumann [Mon, 21 Dec 2015 22:47:48 +0000 (14:47 -0800)]
sdhci: don't raise a command index error for an unexpected response

This deletes a block of code that raised a command index error if a
command returned response data, but the guest did not set the
appropriate bits in the response register to handle such a response. I
cannot find any documentation that suggests the controller should
behave in this way, the error code doesn't make sense (command index
error is defined for the case where the index in a response does not
match that of the issued command), and in at least one case (CMD23
issued by UEFI on Raspberry Pi 2), actual hardware does not do this.

Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1450738069-18664-3-git-send-email-Andrew.Baumann@microsoft.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agosd: sdhci: Delete over-zealous power check
Peter Crosthwaite [Mon, 21 Dec 2015 22:47:47 +0000 (14:47 -0800)]
sd: sdhci: Delete over-zealous power check

This check was conditionalising SD card operation on the card being
powered by the SDHCI host controller. It is however possible
(particularly in embedded systems) for the power control of the SD card
to be managed outside of SDHCI. This can be as trivial as hard-wiring
the SD slot VCC to a constant power-rail.

This means the guest SDHCI can validly opt-out of the SDHCI power
control feature while still using the card. So delete this check to
allow operation of the card with SDHCI power control.

This is needed for at least Xilinx Zynq and Raspberry Pi, and
also makes Freescale i.MX25 work for me. The digilent Zybo board
has a public schematic which shows SD VCC hardwiring:

http://digilentinc.com/Data/Products/ZYBO/ZYBO_sch_VB.3.pdf
bottom of page 3.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Sai Pavan Boddu <saipava@xilinx.com>
Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Message-id: 1450738069-18664-2-git-send-email-Andrew.Baumann@microsoft.com
[AB: Add Pi to list of devices fixed in commit message]
Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoscripts/gdb: Fix a python exception in mtree.py
Yang Wei [Sat, 5 Dec 2015 11:52:20 +0000 (19:52 +0800)]
scripts/gdb: Fix a python exception in mtree.py

The following exception is threw:
Python Exception <class 'NameError'> name 'long' is not defined:
Error occurred in Python command: name 'long' is not defined

Python 2.4+, int()/long() have been unified, so replace long
with int.

Signed-off-by: Yang Wei <w90p710@gmail.com>
Message-id: 1449316340-4030-1-git-send-email-w90p710@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoparallels: add format spec
Vladimir Sementsov-Ogievskiy [Fri, 27 Nov 2015 12:20:06 +0000 (15:20 +0300)]
parallels: add format spec

This specifies Parallels image format as implemented in Parallels Cloud
Server 6.10

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Message-id: 1448626806-17591-1-git-send-email-den@openvz.org
CC: Eric Blake <eblake@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock/mirror: replace IOV_MAX with blk_get_max_iov()
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:47 +0000 (10:56 +0100)]
block/mirror: replace IOV_MAX with blk_get_max_iov()

Use blk_get_max_iov() instead of hardcoding IOV_MAX, which may not apply
to all BlockDrivers.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock: replace IOV_MAX with BlockLimits.max_iov
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:46 +0000 (10:56 +0100)]
block: replace IOV_MAX with BlockLimits.max_iov

Request merging must not result in a huge request that exceeds the
maximum number of iovec elements.  Use BlockLimits.max_iov instead of
hardcoding IOV_MAX.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock-backend: add blk_get_max_iov()
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:45 +0000 (10:56 +0100)]
block-backend: add blk_get_max_iov()

Add a function to query BlockLimits.max_iov.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock: add BlockLimits.max_iov field
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:44 +0000 (10:56 +0100)]
block: add BlockLimits.max_iov field

The maximum number of struct iovec elements depends on the
BlockDriverState.  The raw-posix and iSCSI protocols have a maximum of
IOV_MAX but others could have different values.

Cc: Peter Lieven <pl@kamp.de>
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agovirtio-blk: trivial code optimization
Gonglei [Wed, 11 Nov 2015 01:59:26 +0000 (09:59 +0800)]
virtio-blk: trivial code optimization

1. avoid possible superflous checking
2. make code more robustness

["make code more robustness" refers to avoiding integer
underflows/overflows.
--Stefan]

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Message-id: 1447207166-12612-1-git-send-email-arei.gonglei@huawei.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging
Peter Maydell [Fri, 18 Dec 2015 18:47:17 +0000 (18:47 +0000)]
Merge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging

NUMA queue, 2015-12-18

# gpg: Signature made Fri 18 Dec 2015 17:53:48 GMT using RSA key ID 984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"

* remotes/ehabkost/tags/numa-pull-request:
  numa: Clean up query-memdev error handling

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agonuma: Clean up query-memdev error handling
Markus Armbruster [Mon, 23 Nov 2015 08:35:31 +0000 (09:35 +0100)]
numa: Clean up query-memdev error handling

qmp_query_memdev() has two error paths:

* When object_get_objects_root() returns null.  It never does, so
  simply drop the useless error handling.

* When query_memdev() fails.  It leaks err then.  But any failure
  there is actually a programming error.  Switch it to &error_abort,
  and drop the useless error handling.

Messed up in commit 76b5d85 "qmp: add query-memdev".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-secrets-base-2015...
Peter Maydell [Fri, 18 Dec 2015 17:04:15 +0000 (17:04 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-secrets-base-2015-12-18-1' into staging

Merge QCryptoSecret object support

# gpg: Signature made Fri 18 Dec 2015 16:51:21 GMT using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"

* remotes/berrange/tags/pull-qcrypto-secrets-base-2015-12-18-1:
  crypto: add support for loading encrypted x509 keys
  crypto: add QCryptoSecret object class for password/key handling
  qga: convert to use error checked base64 decode
  qemu-char: convert to use error checked base64 decode
  util: add base64 decoding function

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Fri, 18 Dec 2015 16:34:44 +0000 (16:34 +0000)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

# gpg: Signature made Fri 18 Dec 2015 13:41:03 GMT using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (48 commits)
  block/qapi: allow best-effort query
  qemu-img: abort when full_backing_filename not present
  block/qapi: explicitly warn if !has_full_backing_filename
  block/qapi: always report full_backing_filename
  block/qapi: do not redundantly print "actual path"
  qemu-iotests: s390x: fix test 068
  qemu-iotests: s390x: fix test 051
  qemu-iotests: refine common.config
  block: fix bdrv_ioctl called from coroutine
  block: use drained section around bdrv_snapshot_delete
  iotests: Update comments for bdrv_swap() in 094
  block: Remove prototype of bdrv_swap from header
  raw-posix: Make aio=native option binding
  qcow2: insert assert into qcow2_get_specific_info()
  iotests: Extend test 112 for qemu-img amend
  qcow2: Point to amend function in check
  qcow2: Invoke refcount order amendment function
  qcow2: Add function for refcount order amendment
  qcow2: Use intermediate helper CB for amend
  qcow2: Split upgrade/downgrade paths for amend
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agocrypto: add support for loading encrypted x509 keys
Daniel P. Berrange [Thu, 15 Oct 2015 15:14:42 +0000 (16:14 +0100)]
crypto: add support for loading encrypted x509 keys

Make use of the QCryptoSecret object to support loading of
encrypted x509 keys. The optional 'passwordid' parameter
to the tls-creds-x509 object type, provides the ID of a
secret object instance that holds the decryption password
for the PEM file.

 # printf "123456" > mypasswd.txt
 # $QEMU \
    -object secret,id=sec0,filename=mypasswd.txt \
    -object tls-creds-x509,passwordid=sec0,id=creds0,\
            dir=/home/berrange/.pki/qemu,endpoint=server \
    -vnc :1,tls-creds=creds0

This requires QEMU to be linked to GNUTLS >= 3.1.11. If
GNUTLS is too old an error will be reported if an attempt
is made to pass a decryption password.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: add QCryptoSecret object class for password/key handling
Daniel P. Berrange [Wed, 14 Oct 2015 08:58:38 +0000 (09:58 +0100)]
crypto: add QCryptoSecret object class for password/key handling

Introduce a new QCryptoSecret object class which will be used
for providing passwords and keys to other objects which need
sensitive credentials.

The new object can provide secret values directly as properties,
or indirectly via a file. The latter includes support for file
descriptor passing syntax on UNIX platforms. Ordinarily passing
secret values directly as properties is insecure, since they
are visible in process listings, or in log files showing the
CLI args / QMP commands. It is possible to use AES-256-CBC to
encrypt the secret values though, in which case all that is
visible is the ciphertext.  For ad hoc developer testing though,
it is fine to provide the secrets directly without encryption
so this is not explicitly forbidden.

The anticipated scenario is that libvirtd will create a random
master key per QEMU instance (eg /var/run/libvirt/qemu/$VMNAME.key)
and will use that key to encrypt all passwords it provides to
QEMU via '-object secret,....'.  This avoids the need for libvirt
(or other mgmt apps) to worry about file descriptor passing.

It also makes life easier for people who are scripting the
management of QEMU, for whom FD passing is significantly more
complex.

Providing data inline (insecure, only for ad hoc dev testing)

  $QEMU -object secret,id=sec0,data=letmein

Providing data indirectly in raw format

  printf "letmein" > mypasswd.txt
  $QEMU -object secret,id=sec0,file=mypasswd.txt

Providing data indirectly in base64 format

  $QEMU -object secret,id=sec0,file=mykey.b64,format=base64

Providing data with encryption

  $QEMU -object secret,id=master0,file=mykey.b64,format=base64 \
        -object secret,id=sec0,data=[base64 ciphertext],\
           keyid=master0,iv=[base64 IV],format=base64

Note that 'format' here refers to the format of the ciphertext
data. The decrypted data must always be in raw byte format.

More examples are shown in the updated docs.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqga: convert to use error checked base64 decode
Daniel P. Berrange [Mon, 23 Nov 2015 15:37:07 +0000 (15:37 +0000)]
qga: convert to use error checked base64 decode

Switch from using g_base64_decode over to qbase64_decode
in order to get error checking of the base64 input data.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu-char: convert to use error checked base64 decode
Daniel P. Berrange [Mon, 23 Nov 2015 15:29:59 +0000 (15:29 +0000)]
qemu-char: convert to use error checked base64 decode

Switch from using g_base64_decode over to qbase64_decode
in order to get error checking of the base64 input data.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoutil: add base64 decoding function
Daniel P. Berrange [Mon, 23 Nov 2015 15:24:50 +0000 (15:24 +0000)]
util: add base64 decoding function

The standard glib provided g_base64_decode doesn't provide any
kind of sensible error checking on its input. Add a QEMU custom
wrapper qbase64_decode which can be used with untrustworthy
input that can contain invalid base64 characters, embedded
NUL characters, or not be NUL terminated at all.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>