sdk/emulator/qemu.git
14 years agovirtio-9p: Add support for removing xattr
Aneesh Kumar K.V [Thu, 26 Aug 2010 05:45:23 +0000 (11:15 +0530)]
virtio-9p: Add support for removing xattr

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Fix the memset usage
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:07 +0000 (11:09 +0530)]
virtio-9p: Fix the memset usage

The arguments are wrong. Use qemu_mallocz directly

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Use lchown which won't follow symlink
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:07 +0000 (11:09 +0530)]
virtio-9p: Use lchown which won't follow symlink

We should always use functions which don't follow
symlink on the server

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Add SM_NONE security model
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:07 +0000 (11:09 +0530)]
virtio-9p: Add SM_NONE security model

This is equivalent to SM_PASSTHROUGH security model.
The only exception is, failure of privilige operation like chown
are ignored. This makes a passthrough like security model usable
for people who runs kvm as non root

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Hide user.virtfs xattr in case of mapped security.
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:07 +0000 (11:09 +0530)]
virtio-9p: Hide user.virtfs xattr in case of mapped security.

With mapped security mode we use "user.virtfs" namespace is used
to store the virtFs related attributes. So hide it from user.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Implement TXATTRCREATE
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:07 +0000 (11:09 +0530)]
virtio-9p: Implement TXATTRCREATE

TXATTRCREATE:  Prepare a fid for setting xattr value on a file system object.

 size[4] TXATTRCREATE tag[2] fid[4] name[s] attr_size[8] flags[4]
 size[4] RXATTRWALK tag[2]

txattrcreate gets a fid pointing to xattr. This fid can later be
used to get set the xattr value.

flag value is derived from set Linux setxattr. The manpage says
"The flags parameter can be used to refine the semantics of the operation.
XATTR_CREATE specifies a pure create, which fails if the named attribute
exists already. XATTR_REPLACE specifies a pure replace operation, which
fails if the named attribute does not already exist. By default (no flags),
the extended attribute will be created if need be, or will simply replace
the value if the attribute exists."

The actual setxattr operation happens when the fid is clunked. At that point
the written byte count and the attr_size specified in TXATTRCREATE should be
same otherwise an error will be returned.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Implement TXATTRWALK
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:06 +0000 (11:09 +0530)]
virtio-9p: Implement TXATTRWALK

TXATTRWALK: Descend a ATTR namespace

 size[4] TXATTRWALK tag[2] fid[4] newfid[4] name[s]
 size[4] RXATTRWALK tag[2] size[8]

txattrwalk gets a fid pointing to xattr. This fid can later be
used to get read the xattr value. If name is NULL the fid returned
can be used to get the list of extended attribute associated to
the file system object.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years agovirtio-9p: Add fidtype so that we can do type specific operation
Aneesh Kumar K.V [Thu, 2 Sep 2010 05:39:06 +0000 (11:09 +0530)]
virtio-9p: Add fidtype so that we can do type specific operation

We want to add type specific operation during read/write

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
14 years ago[virtio-9p] qemu: virtio-9p: Implement LOPEN
M. Mohan Kumar [Tue, 22 Jun 2010 14:17:04 +0000 (19:47 +0530)]
[virtio-9p] qemu: virtio-9p: Implement LOPEN

Implement 9p2000.L version of open(LOPEN) interface in qemu 9p server.

For LOPEN, no need to convert the flags to and from 9p mode to VFS mode.

Synopsis:

    size[4] Tlopen tag[2] fid[4] mode[4]

    size[4] Rlopen tag[2] qid[13] iounit[4]

Current qemu 9p server does not support following flags:
    O_NOCTTY, O_NONBLOCK, O_ASYNC & O_CLOEXEC

[Fix mode format - jvrao@linux.vnet.ibm.com]

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agorename - change name of file or directory
M. Mohan Kumar [Tue, 22 Jun 2010 06:59:41 +0000 (12:29 +0530)]
rename - change name of file or directory

size[4] Trename tag[2] fid[4] newdirfid[4] name[s]
size[4] Rrename tag[2]

Implement the 2000.L rename operation. A new function
v9fs_complete_rename is introduced that acts as a common entry point
for 2000.L rename operation and 2000.U rename opearation (via wstat).
As part of this change the field 'nname' (used only for rename) is
removed from the structure V9fsWstatState. Instead a new structure
V9fsRenameState is used for rename operations both by 2000.U and 2000.L
code paths. Both 2000.U and 2000.L rename code paths construct the
V9fsRenameState structure and passes that to v9fs_complete_rename
function.

Changes from previous version:
 Use qemu_mallocz to initialize
 Use strcpy,strcat functions instead of memcpy
 Changed the variable name to newdirfid
 Introduced post rename function
 Error checking
 Removed nname field from V9fsWstatState

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agoqemu: virtio-9p: Implement TMKDIR
M. Mohan Kumar [Tue, 22 Jun 2010 06:55:22 +0000 (12:25 +0530)]
qemu: virtio-9p: Implement TMKDIR

Synopsis

    size[4] Tmkdir tag[2] fid[4] name[s] mode[4] gid[4]

    size[4] Rmkdir tag[2] qid[13]

Description

    mkdir asks the file server to create a directory with given name,
    mode and gid. The qid for the new directory is returned with
    the mkdir reply message.

Note: 72 is selected as the opcode for TMKDIR from the reserved list.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
[jvrao@linux.vnet.ibm.com: Fix perm handling when creating directory]

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agoqemu: virtio-9p: Implement TMKNOD
M. Mohan Kumar [Tue, 22 Jun 2010 06:54:09 +0000 (12:24 +0530)]
qemu: virtio-9p: Implement TMKNOD

Implement TMKNOD as part of 2000.L Work

Synopsis

    size[4] Tmknod tag[2] fid[4] name[s] mode[4] major[4] minor[4] gid[4]

    size[4] Rmknod tag[2] qid[13]

Description

    mknod asks the file server to create a device node with given device
    type, mode and gid. The qid for the new device node is returned with
    the mknod reply message.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years ago[virtio-9p] This patch implements TLCREATE for 9p2000.L protocol.
Venkateswararao Jujjuri (JV) [Fri, 18 Jun 2010 01:27:24 +0000 (18:27 -0700)]
[virtio-9p]  This patch implements TLCREATE for 9p2000.L protocol.

SYNOPSIS

    size[4] Tlcreate tag[2] fid[4] name[s] flags[4] mode[4] gid[4]

    size[4] Rlcreate tag[2] qid[13] iounit[4]

DESCRIPTION

The Tlreate request asks the file server to create a new regular file with the
name supplied, in the directory (dir) represented by fid.
The mode argument specifies the permissions to use. New file is created with
the uid if the fid and with supplied gid.

The flags argument represent Linux access mode flags with which the caller
is requesting to open the file with. Protocol allows all the Linux access
modes but it is upto the server to allow/disallow any of these acess modes.
If the server doesn't support any of the access mode, it is expected to
return error.

To start with we will not restricit/limit any Linux flags on this server.
If needed, We can start restricting as we move forward with various use cases.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years ago[virtio-9p] Define and implement TSYMLINK for 9P2000.L
Venkateswararao Jujjuri (JV) [Wed, 9 Jun 2010 21:02:08 +0000 (14:02 -0700)]
[virtio-9p] Define and implement TSYMLINK for 9P2000.L

This patch implements creating a symlink for TSYMLINK request
and responds with RSYMLINK. In the case of error, we return RERROR.

SYNOPSIS

    size[4] Tsymlink tag[2] fid[4] name[s] symtgt[s] gid[4]

    size[4] Rsymlink tag[2] qid[13]

    DESCRIPTION

    Create a symbolic link named 'name' pointing to 'symtgt'.
    gid represents the effective group id of the caller.
    The  permissions of a symbolic link are irrelevant hence it is omitted
    from the protocol.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years ago[virtio-9p] Implement TLINK for 9P2000.L
Venkateswararao Jujjuri (JV) [Wed, 9 Jun 2010 18:21:15 +0000 (11:21 -0700)]
[virtio-9p] Implement TLINK for 9P2000.L

Create a Hardlink.

SYNOPSIS

size[4] Tlink tag[2] dfid[4] oldfid[4] newpath[s]

size[4] Rlink tag[2]

DESCRIPTION

Create a link 'newpath' in directory pointed by dfid linking to oldfid path.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agovirtio-9p: Implement server side of setattr for 9P2000.L protocol.
Sripathi Kodi [Thu, 17 Jun 2010 12:48:47 +0000 (18:18 +0530)]
virtio-9p: Implement server side of setattr for 9P2000.L protocol.

SYNOPSIS

      size[4] Tsetattr tag[2] attr[n]

      size[4] Rsetattr tag[2]

   DESCRIPTION

      The setattr command changes some of the file status information.
      attr resembles the iattr structure used in Linux kernel. It
      specifies which status parameter is to be changed and to what
      value. It is laid out as follows:

         valid[4]
            specifies which status information is to be changed. Possible
            values are:
            ATTR_MODE       (1 << 0)
            ATTR_UID        (1 << 1)
            ATTR_GID        (1 << 2)
            ATTR_SIZE       (1 << 3)
            ATTR_ATIME      (1 << 4)
            ATTR_MTIME      (1 << 5)
            ATTR_CTIME      (1 << 5)
            ATTR_ATIME_SET  (1 << 7)
            ATTR_MTIME_SET  (1 << 8)

            The last two bits represent whether the time information
            is being sent by the client's user space. In the absense
            of these bits the server always uses server's time.

         mode[4]
            File permission bits

         uid[4]
            Owner id of file

         gid[4]
            Group id of the file

         size[8]
            File size

         atime_sec[8]
            Time of last file access, seconds

         atime_nsec[8]
            Time of last file access, nanoseconds

         mtime_sec[8]
            Time of last file modification, seconds

         mtime_nsec[8]
            Time of last file modification, nanoseconds

Explanation of the patches:
--------------------------

*) The kernel just copies relevent contents of iattr structure to p9_iattr_dotl
   structure and passes it down to the client. The only check it has is calling
   inode_change_ok()
*) The p9_iattr_dotl structure does not have ctime and ia_file parameters because
   I don't think these are needed in our case. The client user space can request
   updating just ctime by calling chown(fd, -1, -1). This is handled on server
   side without a need for putting ctime on the wire.
*) The server currently supports changing mode, time, ownership and size of the
   file.
*) 9P RFC says "Either all the changes in wstat request happen, or none of them
   does: if the request succeeds, all changes were made; if it fails, none were."
   I have not done anything to implement this specifically because I don't see
   a reason.

[jvrao@linux.vnet.ibm.com: Parts of code for handling chown(-1,-1)

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years ago[virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat.
Sripathi Kodi [Wed, 9 Jun 2010 13:44:38 +0000 (19:14 +0530)]
[virtio-9p] Make v9fs_do_utimensat accept timespec structures instead of v9stat.

Currently v9fs_do_utimensat takes a V9fsStat argument and builds
timespec structures. It sets tv_nsec values to 0 by default. Instead
of this it should take struct timespec[2] and pass it down to the
system directly. This will make it more generic and useful
elsewhere.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agovirtio-9p: Do not reset atime
M. Mohan Kumar [Wed, 9 Jun 2010 13:44:38 +0000 (19:14 +0530)]
virtio-9p: Do not reset atime

    Current code resets file's atime to 0 when there is a change in mtime.
    This results in resetting the atime to "1970-01-01 05:30:00". For
    example, truncate -s 0 filename results in changing the mtime to the
    truncate time, but resets the atime to "1970-01-01 05:30:00". utime
    system call does not have any provision to set only mtime or atime. So
    change v9fs_wstat_post_chmod function to use utimensat function to change
    the atime and mtime fields. If tv_nsec field is set to the special value
    "UTIME_OMIT", corresponding file time stamp is not updated.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agovirtio-9p: getattr server implementation for 9P2000.L protocol.
Sripathi Kodi [Tue, 20 Jul 2010 06:14:41 +0000 (11:44 +0530)]
virtio-9p: getattr server implementation for 9P2000.L protocol.

           SYNOPSIS

              size[4] Tgetattr tag[2] fid[4] request_mask[8]

              size[4] Rgetattr tag[2] lstat[n]

           DESCRIPTION

              The getattr transaction inquires about the file identified by fid.
              request_mask is a bit mask that specifies which fields of the
              stat structure is the client interested in.

              The reply will contain a machine-independent directory entry,
              laid out as follows:

                 st_result_mask[8]
                    Bit mask that indicates which fields in the stat structure
                    have been populated by the server

                 qid.type[1]
                    the type of the file (directory, etc.), represented as a bit
                    vector corresponding to the high 8 bits of the file's mode
                    word.

                 qid.vers[4]
                    version number for given path

                 qid.path[8]
                    the file server's unique identification for the file

                 st_mode[4]
                    Permission and flags

                 st_uid[4]
                    User id of owner

                 st_gid[4]
                    Group ID of owner

                 st_nlink[8]
                    Number of hard links

                 st_rdev[8]
                    Device ID (if special file)

                 st_size[8]
                    Size, in bytes

                 st_blksize[8]
                    Block size for file system IO

                 st_blocks[8]
                    Number of file system blocks allocated

                 st_atime_sec[8]
                    Time of last access, seconds

                 st_atime_nsec[8]
                    Time of last access, nanoseconds

                 st_mtime_sec[8]
                    Time of last modification, seconds

                 st_mtime_nsec[8]
                    Time of last modification, nanoseconds

                 st_ctime_sec[8]
                    Time of last status change, seconds

                 st_ctime_nsec[8]
                    Time of last status change, nanoseconds

                 st_btime_sec[8]
                    Time of creation (birth) of file, seconds

                 st_btime_nsec[8]
                    Time of creation (birth) of file, nanoseconds

                 st_gen[8]
                    Inode generation

                 st_data_version[8]
                    Data version number

              request_mask and result_mask bit masks contain the following bits
                 #define P9_STATS_MODE          0x00000001ULL
                 #define P9_STATS_NLINK         0x00000002ULL
                 #define P9_STATS_UID           0x00000004ULL
                 #define P9_STATS_GID           0x00000008ULL
                 #define P9_STATS_RDEV          0x00000010ULL
                 #define P9_STATS_ATIME         0x00000020ULL
                 #define P9_STATS_MTIME         0x00000040ULL
                 #define P9_STATS_CTIME         0x00000080ULL
                 #define P9_STATS_INO           0x00000100ULL
                 #define P9_STATS_SIZE          0x00000200ULL
                 #define P9_STATS_BLOCKS        0x00000400ULL

                 #define P9_STATS_BTIME         0x00000800ULL
                 #define P9_STATS_GEN           0x00001000ULL
                 #define P9_STATS_DATA_VERSION  0x00002000ULL

                 #define P9_STATS_BASIC         0x000007ffULL
                 #define P9_STATS_ALL           0x00003fffULL

        This patch implements the client side of getattr implementation for 9P2000.L.
        It introduces a new structure p9_stat_dotl for getting Linux stat information
        along with QID. The data layout is similar to stat structure in Linux user
        space with the following major differences:

        inode (st_ino) is not part of data. Instead qid is.

        device (st_dev) is not part of data because this doesn't make sense on the
        client.

        All time variables are 64 bit wide on the wire. The kernel seems to use
        32 bit variables for these variables. However, some of the architectures
        have used 64 bit variables and glibc exposes 64 bit variables to user
        space on some architectures. Hence to be on the safer side we have made
        these 64 bit in the protocol. Refer to the comments in
        include/asm-generic/stat.h

        There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
        st_data_version apart from the bitmask, st_result_mask. The bit mask
        is filled by the server to indicate which stat fields have been
        populated by the server. Currently there is no clean way for the
        server to obtain these additional fields, so it sends back just the
        basic fields.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
14 years agovirtio-9p: Compute iounit based on host filesystem block size
M. Mohan Kumar [Wed, 9 Jun 2010 13:44:28 +0000 (19:14 +0530)]
virtio-9p: Compute iounit based on host filesystem block size

Compute iounit based on the host filesystem block size and pass it to
client with open/create response. Also return iounit as statfs's f_bsize
for optimal block size transfers.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Reviewd-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years ago[V4] virtio-9p: readdir implementation for 9p2000.L
Sripathi Kodi [Wed, 9 Jun 2010 09:27:57 +0000 (14:57 +0530)]
[V4] virtio-9p: readdir implementation for 9p2000.L

This patch implements the server part of readdir() implementation for
9p2000.L

    SYNOPSIS

    size[4] Treaddir tag[2] fid[4] offset[8] count[4]
    size[4] Rreaddir tag[2] count[4] data[count]

    DESCRIPTION

    The readdir request asks the server to read the directory specified by 'fid'
    at an offset specified by 'offset' and return as many dirent structures as
    possible that fit into count bytes. Each dirent structure is laid out as
    follows.

            qid.type[1]
              the type of the file (directory, etc.), represented as a bit
              vector corresponding to the high 8 bits of the file's mode
              word.

            qid.vers[4]
              version number for given path

            qid.path[8]
              the file server's unique identification for the file

            offset[8]
              offset into the next dirent.

            type[1]
              type of this directory entry.

            name[256]
              name of this directory entry.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agovirtio-9p: Return correct error from v9fs_remove
Sripathi Kodi [Wed, 9 Jun 2010 09:03:22 +0000 (14:33 +0530)]
virtio-9p: Return correct error from v9fs_remove

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
In v9fs_remove_post_remove() we currently ignore the error returned by
the previous call to remove() and return an error only if freeing the
fid fails. However, the client expects to see the error from remove().
Currently the client falsely thinks that the remove call has always
succeeded. For example, doing rmdir on a non-empty directory does
not return ENOTEMPTY.

With this patch we ignore the error from free_fid(). The client cannot
use this error value anyway.

Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agoqemu: virtio-9p: Implement statfs support in server
M. Mohan Kumar [Mon, 10 May 2010 06:41:03 +0000 (12:11 +0530)]
qemu: virtio-9p: Implement statfs support in server

Implement statfs support in qemu server based on Sripathi's
initial statfs patch.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agoqemu: virtio-9p: Recognize 9P2000.L protocol
M. Mohan Kumar [Thu, 27 May 2010 08:27:29 +0000 (13:57 +0530)]
qemu: virtio-9p: Recognize 9P2000.L protocol

Make 9P server recognize 9P2000.L protocol version

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
14 years agovnc: use bswapNN() rather than bswap_NN()
Izumi Tsutsui [Sun, 8 Aug 2010 09:54:05 +0000 (18:54 +0900)]
vnc: use bswapNN() rather than bswap_NN()

bswap_NN() variants are not always available in CONFIG_MACHINE_BSWAP_H case
and bswapNN() are public APIs in "bswap.h".

Signed-off-by: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agovnc: tight: remove unused variable
Serge Ziryukin [Sat, 28 Aug 2010 20:24:33 +0000 (23:24 +0300)]
vnc: tight: remove unused variable

Signed-off-by: Serge Ziryukin <ftrvxmtrx@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix ivshmem build on 32-bit hosts
Avi Kivity [Sun, 29 Aug 2010 09:43:15 +0000 (12:43 +0300)]
Fix ivshmem build on 32-bit hosts

stat() fields can be more or less anything depending on configuration, cast
explicitly to uint64_t to avoid printf() format mismatches.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agovirtio-9p: Make sure -virtfs option works correctly
Aneesh Kumar K.V [Thu, 2 Sep 2010 16:17:59 +0000 (21:47 +0530)]
virtio-9p: Make sure -virtfs option works correctly

When making copy of arguments we were doing partial copy

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agohw/ivshmem.c don't check for negative values on unsigned data types
Jes Sorensen [Mon, 30 Aug 2010 10:31:33 +0000 (12:31 +0200)]
hw/ivshmem.c don't check for negative values on unsigned data types

There is no need to check for dest < 0 or vector >= 0 as both are
uint16_t.

This should fix problems with broken build with aggressive compiler
flags. Reported by Xudong Hao <xudong.hao@intel.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Acked-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoload_multiboot(): get_image_size() returns int
Jes Sorensen [Tue, 31 Aug 2010 07:30:38 +0000 (09:30 +0200)]
load_multiboot(): get_image_size() returns int

Do not store return of get_image_size() in a uint32_t as it makes it
impossible to detect error returns from get_image_size.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoChange DPRINTF() to do{}while(0) to avoid compiler warning
Jes Sorensen [Tue, 31 Aug 2010 07:30:37 +0000 (09:30 +0200)]
Change DPRINTF() to do{}while(0) to avoid compiler warning

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosize_t is unsigned, change to ssize_t to handle errors from tight_compress_data()
Jes Sorensen [Tue, 31 Aug 2010 07:30:36 +0000 (09:30 +0200)]
size_t is unsigned, change to ssize_t to handle errors from tight_compress_data()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix repeated typo: was "end if list" instead of "end of list"
Jes Sorensen [Tue, 31 Aug 2010 07:30:35 +0000 (09:30 +0200)]
Fix repeated typo: was "end if list" instead of "end of list"

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRespect return value from nbd_client()
Jes Sorensen [Tue, 31 Aug 2010 07:30:34 +0000 (09:30 +0200)]
Respect return value from nbd_client()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRemove unused argument for nbd_client()
Jes Sorensen [Tue, 31 Aug 2010 07:30:33 +0000 (09:30 +0200)]
Remove unused argument for nbd_client()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix OpenBSD linker warning
Blue Swirl [Tue, 31 Aug 2010 20:16:59 +0000 (20:16 +0000)]
Fix OpenBSD linker warning

Fix a warning from OpenBSD linker:
../libhw32/vl.o(.text+0x5c3c): In function `main':
/src/qemu/vl.c:2335: warning: sprintf() is often misused, please use snprintf()

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi: fix file size check with -acpitable.
Isaku Yamahata [Wed, 28 Jul 2010 23:08:42 +0000 (23:08 +0000)]
acpi: fix file size check with -acpitable.

acpi table file can be modified during load so file size check
should be more strict.
pointer calculation should be after qemu_realloc(). not before realloc().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoisapc: fix segfault.
Isaku Yamahata [Wed, 4 Aug 2010 08:43:20 +0000 (17:43 +0900)]
isapc: fix segfault.

https://bugs.launchpad.net/bugs/611646
reports that ./i386-softmmu/qemu -M isapc segfaults.
This patch fixes the segfault introduced by
f885f1eaa8711c06033ceb1599e3750fb37c306f

It's because i440fx_state in pc_init1() isn't initialized.

> Core was generated by `./i386-softmmu/qemu -M isapc'.
> Program terminated with signal 11, Segmentation fault.
> [New process 19686]
>     at qemu/hw/piix_pci.c:136
> (gdb) where
>     at qemu/hw/piix_pci.c:136
>     boot_device=0x7fffe1f5b040 "cad", kernel_filename=0x0,
>     kernel_cmdline=0x6469bf "", initrd_filename=0x0,
>     cpu_model=0x654d10 "486", pci_enabled=0)
>     at qemu/hw/pc_piix.c:178
>     boot_device=0x7fffe1f5b040 "cad", kernel_filename=0x0,
>     kernel_cmdline=0x6469bf "", initrd_filename=0x0, cpu_model=0x654d10 "486")
>     at qemu/hw/pc_piix.c:207
>     envp=0x7fffe1f5b188)
>     at qemu/vl.c:2871

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix segfault in mmio subpage handling code.
Gleb Natapov [Thu, 29 Jul 2010 07:41:45 +0000 (10:41 +0300)]
Fix segfault in mmio subpage handling code.

It is possible that subpage mmio is registered over existing memory
page. When this happens "memory" will have real memory address and not
index into io_mem array so next access to the page will generate
segfault. It is uncommon to have some part of a page to be accessed as
memory and some as mmio, but qemu shouldn't crash even when guest does
stupid things. So lets just pretend that the rest of the page is
unassigned if guest configure part of the memory page as mmio.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoetraxfs_eth: correct use of ! and &
Blue Swirl [Thu, 26 Aug 2010 18:04:18 +0000 (18:04 +0000)]
etraxfs_eth: correct use of ! and &

Combining bitwise AND and logical NOT is suspicious.

Fixed by this Coccinelle script:
// From http://article.gmane.org/gmane.linux.kernel/646367
@@ expression E1,E2; @@
(
 !E1 & !E2
|
- !E1 & E2
+ !(E1 & E2)
)

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoSparc: update OpenBIOS images to r859
Blue Swirl [Thu, 26 Aug 2010 17:57:47 +0000 (17:57 +0000)]
Sparc: update OpenBIOS images to r859

Update Sparc32 and Sparc64 OpenBIOS images to SVN revision 859.

Bring also pc-bios/README up to date including the update performed by
419ef5f1c6a9614e8ddcb0b0f826de692e7e4a43.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses
Hollis Blanchard [Thu, 5 Aug 2010 00:21:37 +0000 (17:21 -0700)]
ppc4xx: load Bamboo kernel, initrd, and fdt at fixed addresses

We can't use the return value of load_uimage() for the kernel because it
can't account for BSS size, and the PowerPC kernel does not relocate
blobs before zeroing BSS.

Instead, we now load at the fixed addresses chosen by u-boot (the normal
firmware for the board).

Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
14 years agoppc4xx: don't unregister RAM at reset
Hollis Blanchard [Thu, 5 Aug 2010 00:21:36 +0000 (17:21 -0700)]
ppc4xx: don't unregister RAM at reset

The PowerPC 4xx SDRAM controller emulation unregisters RAM in its reset
callback. However, qemu_system_reset() is now called at initialization
time, so all RAM is unregistered before starting the guest (!).

Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
14 years agoppc4xx: correct SDRAM controller warning message condition
Hollis Blanchard [Thu, 5 Aug 2010 00:21:35 +0000 (17:21 -0700)]
ppc4xx: correct SDRAM controller warning message condition

The message "Truncating memory to %d MiB to fit SDRAM controller limits"
should be displayed only when a user chooses an amount of RAM which
can't be represented by the PPC 4xx SDRAM controller (e.g. 129MB, which
would only be valid if the controller supports a bank size of 1MB).

Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
14 years agoFix "make install" with a cross toolchain
Hollis Blanchard [Thu, 5 Aug 2010 00:21:34 +0000 (17:21 -0700)]
Fix "make install" with a cross toolchain

We must be able to use a non-native strip executable, but not all
versions of 'install' support the --strip-program option (e.g.
OpenBSD). Accordingly, we can't use 'install -s', and we must run strip
separately.

Signed-off-by: Hollis Blanchard <hollis@penguinppc.org>
Cc: blauwirbel@gmail.com
14 years agoPPC: Update openbios binary to r859
Alexander Graf [Thu, 26 Aug 2010 16:15:20 +0000 (18:15 +0200)]
PPC: Update openbios binary to r859

This updates the openBIOS binary to r589, adding support for PPC PV feature
pass-through in KVM.

Signed-off-by: Alexander Graf <agraf@suse.de>
14 years agoPPC: Add PV hypercall transport through fw_cfg
Alexander Graf [Tue, 3 Aug 2010 13:22:42 +0000 (15:22 +0200)]
PPC: Add PV hypercall transport through fw_cfg

On KVM for PPC we need to tell the guest which instructions to use when
doing a hypercall. The clean way to do this is to go through an ioctl
from userspace and passing it on to the guest using the device tree.

So let's do the qemu part here: read out the hypercall and pass it on
to the guest's fw_cfg so openBIOS can read it out and expose it again.

Signed-off-by: Alexander Graf <agraf@suse.de>
14 years agoRearrange block headers
Blue Swirl [Tue, 24 Aug 2010 15:22:24 +0000 (15:22 +0000)]
Rearrange block headers

Changing block.h or blockdev.h resulted in recompiling most objects.

Move DriveInfo typedef and BlockInterfaceType enum definitions
to qemu-common.h and rearrange blockdev.h use to decrease churn.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoMerge remote branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Mon, 23 Aug 2010 20:10:12 +0000 (15:10 -0500)]
Merge remote branch 'qemu-kvm/uq/master' into staging

14 years agocompile -fsdev and -virtfs cmd line options unconditionally.
Gerd Hoffmann [Fri, 20 Aug 2010 11:52:02 +0000 (13:52 +0200)]
compile -fsdev and -virtfs cmd line options unconditionally.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQemuOpts: make most qemu_*_opts static
Gerd Hoffmann [Fri, 20 Aug 2010 11:52:01 +0000 (13:52 +0200)]
QemuOpts: make most qemu_*_opts static

Switch tree to lookup-by-name using qemu_find_opts().
Also hook up virtfs options so qemu_find_opts works for them too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQemuOpts: allow new option groups be registered at runtime.
Gerd Hoffmann [Fri, 20 Aug 2010 11:52:00 +0000 (13:52 +0200)]
QemuOpts: allow new option groups be registered at runtime.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoVGA: Don't register deprecated VBE range
Alex Williamson [Fri, 20 Aug 2010 21:34:16 +0000 (15:34 -0600)]
VGA: Don't register deprecated VBE range

Old versions of the BOCHs VGA BIOS (cira 2003) made use of VBE
registers at 0xff80/81.  In VBE API version 0xb0c2 these were
moved to 0x1ce/cf.  Unfortunately, QEMU still registers handlers
for the old range.  If a guest attempts to assign an I/O device
overlapping this region, QEMU exits with a hw_error.  Windows
guests seem to like to assign I/O devices to the high end of
the address space, so it's pretty easy to hot add an rtl8139
to a Win2k8 guest and trigger the bug.  I can't find any reason
to register these handlers, so let's remove the cruft.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: Update README file
Luiz Capitulino [Fri, 20 Aug 2010 19:42:32 +0000 (16:42 -0300)]
QMP: Update README file

A number of changes I prefer to do in one shot:

- Fix example
- Small clarifications
- Add multiple monitors example
- Add 'Development Process' section

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP doc: Add 'Stability Considerations' section
Luiz Capitulino [Fri, 20 Aug 2010 19:42:31 +0000 (16:42 -0300)]
QMP doc: Add 'Stability Considerations' section

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP/monitor: update do_info_version() to output broken down version string
Miguel Di Ciurcio Filho [Fri, 20 Aug 2010 19:42:30 +0000 (16:42 -0300)]
QMP/monitor: update do_info_version() to output broken down version string

This code was originally developed by Daniel P. Berrange <berrange@redhat.com>

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQMP: update 'query-version' documentation
Miguel Di Ciurcio Filho [Fri, 20 Aug 2010 19:42:29 +0000 (16:42 -0300)]
QMP: update 'query-version' documentation

Update the documentation of 'query-version' to output the string version broken
down.

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovnc: check fd before calling qemu_set_fd_handler2() in vnc_client_write()
Yoshiaki Tamura [Fri, 20 Aug 2010 10:10:41 +0000 (19:10 +0900)]
vnc: check fd before calling qemu_set_fd_handler2() in vnc_client_write()

Setting fd = -1 to qemu_set_fd_handler2() causes bus error at FD_SET
in main_loop_wait().

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovirtio-serial: Cleanup on device hot-unplug
Amit Shah [Thu, 19 Aug 2010 01:21:04 +0000 (06:51 +0530)]
virtio-serial: Cleanup on device hot-unplug

Free malloc'ed memory, unregister from savevm and clean up virtio-common
bits on device hot-unplug.

This was found performing a migration after device hot-unplug.

Reported-by: <lihuang@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agotarget-i386: svm: Fix MSRPM check
Adam Lackorzynski [Sun, 15 Aug 2010 13:58:32 +0000 (15:58 +0200)]
target-i386: svm: Fix MSRPM check

Correct the calculation of the offset in the msrpm
for the MSR range 0 - 0x1fff.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoexec: remove code duplication in qemu_ram_alloc() and qemu_ram_alloc_from_ptr()
Yoshiaki Tamura [Wed, 18 Aug 2010 06:41:49 +0000 (15:41 +0900)]
exec: remove code duplication in qemu_ram_alloc() and qemu_ram_alloc_from_ptr()

Since most of the code in qemu_ram_alloc() and
qemu_ram_alloc_from_ptr() are duplicated, let
qemu_ram_alloc_from_ptr() to switch by checking void *host, and change
qemu_ram_alloc() to a wrapper.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoexec: replace tabs by spaces.
Yoshiaki Tamura [Wed, 18 Aug 2010 04:30:13 +0000 (13:30 +0900)]
exec: replace tabs by spaces.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoarch_init: replace tabs by spaces.
Yoshiaki Tamura [Wed, 18 Aug 2010 04:30:12 +0000 (13:30 +0900)]
arch_init: replace tabs by spaces.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agopckbd: support for commands 0xf0-0xff: Pulse output bit
Bernhard Kohl [Thu, 19 Aug 2010 12:52:12 +0000 (14:52 +0200)]
pckbd: support for commands 0xf0-0xff: Pulse output bit

I have a guest OS which sends the command 0xfd to the keyboard
controller during initialization. To get rid of the message
"qemu: unsupported keyboard cmd=0x%02x\n" I added support for
the pulse output bit commands.

I found the following explanation here:
http://www.win.tue.nl/~aeb/linux/kbd/scancodes-11.html#ss11.3

Command 0xf0-0xff: Pulse output bit
Bits 3-0 of the output port P2 of the keyboard controller may
be pulsed low for approximately 6 µseconds. Bits 3-0 of this
command specify the output port bits to be pulsed. 0: Bit should
be pulsed. 1: Bit should not be modified. The only useful version
of this command is Command 0xfe.
(For MCA, replace 3-0 by 1-0 in the above.)

Command 0xfe: System reset
Pulse bit 0 of the output port P2 of the keyboard controller.
This will reset the CPU.

Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoReplace qemu_malloc + memset with qemu_mallocz
Blue Swirl [Fri, 20 Aug 2010 21:04:37 +0000 (21:04 +0000)]
Replace qemu_malloc + memset with qemu_mallocz

Replace a qemu_malloc call, followed by a memset, with qemu_mallocz.

Found with this Coccinelle semantic patch, adapted from
Coccinelle test package rule 94:
@@
type T;
expression x;
expression E;
@@

- x = (T)qemu_malloc(E)
+ x = qemu_mallocz(E)
  ...
(
- memset(x,0,E);
|
- memset(x,0,sizeof(*x));
)

Some files (tests/*) had to be filtered out.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoUse ARRAY_SIZE macro
Blue Swirl [Fri, 20 Aug 2010 21:03:24 +0000 (21:03 +0000)]
Use ARRAY_SIZE macro

Replace array size calculations with ARRAY_SIZE macro.

Implemented with this Coccinelle semantic patch, adapted from
Linux kernel:
@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

Some files (*-dis.c, tests/*) had to be filtered out.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRemove useless NULL check for qemu_strdup return value
Blue Swirl [Thu, 19 Aug 2010 20:24:43 +0000 (20:24 +0000)]
Remove useless NULL check for qemu_strdup return value

Found with this Coccinelle semantic patch:
@@
expression E;
identifier ptr;
identifier fn ~= "qemu_strn?dup";
@@

-ptr = fn(E);
-if (ptr == NULL) { ... }
-
+ptr = fn(E);

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoRemove useless NULL checks for qemu_malloc return value
Blue Swirl [Thu, 19 Aug 2010 20:24:39 +0000 (20:24 +0000)]
Remove useless NULL checks for qemu_malloc return value

Found with this Coccinelle semantic patch:
@@
expression E;
identifier ptr;
identifier fn ~= "qemu_mallocz*";
@@

-ptr = fn(E);
-if (ptr == NULL) { ... }
-
+ptr = fn(E);

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosavevm: Reset last block info at beginning of each save
Alex Williamson [Thu, 19 Aug 2010 13:18:42 +0000 (10:18 -0300)]
savevm: Reset last block info at beginning of each save

If we save more than once we need to reset the last block info or else
only the first save has the actual block info and each subsequent save
will only use continue flags, making them unloadable independently.

Found-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoset proper migration status on ->write error (v5)
Marcelo Tosatti [Thu, 19 Aug 2010 13:18:39 +0000 (10:18 -0300)]
set proper migration status on ->write error (v5)

If ->write fails, declare migration status as MIG_STATE_ERROR.

Also, in buffered_file.c, ->close the object in case of an
error.

Fixes "migrate -d "exec:dd of=file", where dd fails to open file.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agortc: Remove TARGET_I386 from qemu-config.c, enables driftfix
Amit Shah [Wed, 23 Jun 2010 14:44:04 +0000 (20:14 +0530)]
rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix

qemu-config.c doesn't contain any target-specific code, and the
TARGET_I386 conditional code didn't get compiled as a result. Removing
this enables the driftfix parameter for rtc.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoQEMUFileBuffered: indicate that we're ready when the underlying file is ready
Avi Kivity [Wed, 7 Jul 2010 16:44:22 +0000 (19:44 +0300)]
QEMUFileBuffered: indicate that we're ready when the underlying file is ready

QEMUFileBuffered stops writing when the underlying QEMUFile is not ready,
and tells its producer so.  However, when the underlying QEMUFile becomes
ready, it neglects to pass that information along, resulting in stoppage
of all data until the next tick (a tenths of a second).

Usually this doesn't matter, because most QEMUFiles used with QEMUFileBuffered
are almost always ready, but in the case of exec: migration this is not true,
due to the small pipe buffers used to connect to the target process.  The
result is very slow migration.

Fix by detecting the readiness notification and propagating it.  The detection
is a little ugly since QEMUFile overloads put_buffer() to send it, but that's
the suject for a different patch.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agosparc escc IUS improvements (SunOS 4.1.4 fix)
Artyom Tarasenko [Sun, 15 Aug 2010 14:04:41 +0000 (16:04 +0200)]
sparc escc IUS improvements (SunOS 4.1.4 fix)

According to scc_escc_um.pdf:
 - Reset Highest IUS must update irq status to allow processing
   of the next priority interrupt.
 - rx interrupt has always higher priority than tx on same channel

The documentation only explicitly says that Reset Highest IUS
command (0x38) clears IUS bits, not that it clears the corresponding
interrupt too, so don't clear interrupts on this command.

The patch allows SunOS 4.1.4 to use the serial ports

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix mingw32 build
Blue Swirl [Sun, 15 Aug 2010 09:46:24 +0000 (09:46 +0000)]
Fix mingw32 build

Don't define qemu_chr_open_eventfd() on Windows.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agowin32: Avoid compiler warning (WIN32_LEAN_AND_MEAN redefined)
Stefan Weil [Thu, 1 Apr 2010 04:20:07 +0000 (04:20 +0000)]
win32: Avoid compiler warning (WIN32_LEAN_AND_MEAN redefined)

configure adds the macro WIN32_LEAN_AND_MEAN to
QEMU_CFLAGS, and SDL_syswm.h defines it, too.

This results in a compiler warning (redefinition of
WIN32_LEAN_AND_MEAN in SDL_syswm.h. That warning prevents
compilations for win32 with warning = error).

Fix this by removing the definition of WIN32_LEAN_AND_MEAN
before including SDL_syswm.h.

[blauwirbel@gmail.com: rebased]
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agowin32: Add missing function setenv
Stefan Weil [Thu, 1 Jul 2010 00:47:49 +0000 (00:47 +0000)]
win32: Add missing function setenv

Mingw32 does not provide a declaration and implementation of function
setenv (which is used in sdl.c), so this patch adds both.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoDisable build of ivshmem on non-KVM systems
Cam Macdonell [Sat, 14 Aug 2010 23:47:31 +0000 (17:47 -0600)]
Disable build of ivshmem on non-KVM systems

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoAdd kvm_set_ioeventfd_mmio_long definition for non-KVM systems
Cam Macdonell [Sat, 14 Aug 2010 23:47:30 +0000 (17:47 -0600)]
Add kvm_set_ioeventfd_mmio_long definition for non-KVM systems

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoTCG: Revert ppc64 tcg_out_movi32 change
Andreas Färber [Sat, 14 Aug 2010 20:52:56 +0000 (22:52 +0200)]
TCG: Revert ppc64 tcg_out_movi32 change

3b6dac34161bc0a342336072643c2f6d17e0ec45 apparently broke the ppc64 TCG target
compilation in the code path without guest base.

Reverting this line fixes the build.

Signed-off-by: Andreas F?rber <andreas.faerber@web.de>
Cc: malc <av1474@comtv.ru>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: malc <av1474@comtv.ru>
14 years agoTCG: Fix Darwin/ppc calling convention recognition
Andreas Färber [Sat, 14 Aug 2010 18:51:50 +0000 (20:51 +0200)]
TCG: Fix Darwin/ppc calling convention recognition

5da79c86a3744e3a901c7986c109dd06951befd2 broke compilation on Mac OS X v10.5 ppc.
Apple's GCC 4.0.1 does not define _CALL_DARWIN. Recognize __APPLE__ again as well.

Signed-off-by: Andreas F?rber <andreas.faerber@web.de>
Cc: malc <av1474@comtv.ru>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: J?rgen Lock <nox@jelal.kn-bremen.de>
Cc: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: malc <av1474@comtv.ru>
14 years agoRESEND: Inter-VM shared memory PCI device
Cam Macdonell [Tue, 27 Jul 2010 16:54:13 +0000 (10:54 -0600)]
RESEND: Inter-VM shared memory PCI device

resend for bug fix related to removal of irqfd

Support an inter-vm shared memory device that maps a shared-memory object as a
PCI device in the guest.  This patch also supports interrupts between guest by
communicating over a unix domain socket.  This patch applies to the qemu-kvm
repository.

    -device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>]

Interrupts are supported between multiple VMs by using a shared memory server
by using a chardev socket.

    -device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>]
           [,chardev=<id>][,msi=on][,ioeventfd=on][,vectors=n][,role=peer|master]
    -chardev socket,path=<path>,id=<id>

The shared memory server, sample programs and init scripts are in a git repo here:

    www.gitorious.org/nahanni

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoSupport marking a device as non-migratable
Cam Macdonell [Tue, 27 Jul 2010 00:11:00 +0000 (18:11 -0600)]
Support marking a device as non-migratable

A non-migratable device should be removed before migration and re-added after.

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd function to assign ioeventfd to MMIO.
Cam Macdonell [Tue, 27 Jul 2010 00:10:59 +0000 (18:10 -0600)]
Add function to assign ioeventfd to MMIO.

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoDevice specification for shared memory PCI device
Cam Macdonell [Tue, 27 Jul 2010 00:10:58 +0000 (18:10 -0600)]
Device specification for shared memory PCI device

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoAdd qemu_ram_alloc_from_ptr function
Cam Macdonell [Tue, 27 Jul 2010 00:10:57 +0000 (18:10 -0600)]
Add qemu_ram_alloc_from_ptr function

Provide a function to add an allocated region of memory to the qemu RAM.

This patch is copied from Marcelo's qemu_ram_map() in qemu-kvm and given the
clearer name qemu_ram_alloc_from_ptr().

Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 9 Aug 2010 13:25:12 +0000 (08:25 -0500)]
Merge remote branch 'kwolf/for-anthony' into staging

14 years agomicroblaze: Fix the target version of stat64 struct
Edgar E. Iglesias [Mon, 9 Aug 2010 08:13:33 +0000 (10:13 +0200)]
microblaze: Fix the target version of stat64 struct

MicroBlaze needs TARGET_STAT64_HAS_BROKEN_ST_INO.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
14 years agoaudio/sdl: return on error
malc [Sat, 7 Aug 2010 16:03:05 +0000 (20:03 +0400)]
audio/sdl: return on error

Signed-off-by: malc <av1474@comtv.ru>
14 years agomips: Add support for VInt and VEIC irq modes
Edgar E. Iglesias [Fri, 6 Aug 2010 10:21:16 +0000 (12:21 +0200)]
mips: Add support for VInt and VEIC irq modes

Signed-off-by: Edgar E. Iglesias <edgar@axis.com>
14 years agoaudio/sdl: be more anal about errors
malc [Fri, 6 Aug 2010 09:09:41 +0000 (13:09 +0400)]
audio/sdl: be more anal about errors

Signed-off-by: malc <av1474@comtv.ru>
14 years agoaudio: make audio_pt_init block all signals
malc [Fri, 6 Aug 2010 09:08:46 +0000 (13:08 +0400)]
audio: make audio_pt_init block all signals

Signed-off-by: malc <av1474@comtv.ru>
14 years agokvm: remove guest triggerable abort()
Gleb Natapov [Wed, 28 Jul 2010 15:13:23 +0000 (18:13 +0300)]
kvm: remove guest triggerable abort()

This abort() condition is easily triggerable by a guest if it configures
pci bar with unaligned address that overlaps main memory.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
14 years agokvm: Don't walk memory_size == 0 slots in kvm_client_migration_log
Alex Williamson [Wed, 14 Jul 2010 19:36:49 +0000 (13:36 -0600)]
kvm: Don't walk memory_size == 0 slots in kvm_client_migration_log

If we've unregistered a memory area, we should avoid calling
qemu_get_ram_ptr() on the left over phys_offset cruft in the
slot array.  Now that we support removing ramblocks, the
phys_offset ram_addr_t can go away and cause a lookup fault
and abort.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
14 years agosparc32: use FW_CFG_CMDLINE_SIZE
Blue Swirl [Tue, 3 Aug 2010 21:00:58 +0000 (21:00 +0000)]
sparc32: use FW_CFG_CMDLINE_SIZE

Add support for getting kernel command line size with
FW_CFG_CMDLINE_SIZE.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoide: Avoid canceling IDE DMA
Andrea Arcangeli [Tue, 27 Jul 2010 19:04:36 +0000 (21:04 +0200)]
ide: Avoid canceling IDE DMA

The reason for not actually canceling the I/O is because with
virtualization and lots of VM running, a guest fs may mistake a
overload of the host, as an IDE timeout. So rather than canceling the
I/O, it's safer to wait I/O completion and simulate that the I/O has
completed just before the io cancellation was requested by the
guest. This way if ntfs or an app writes data without checking for
-EIO retval, and it thinks the write has succeeded, it's less likely
to run into troubles. Similar issues for reads.

Furthermore because the DMA operation is splitted into many synchronous
aio_read/write if there's more than one entry in the SG table, without this
patch the DMA would be cancelled in the middle, something we've no idea if it
happens on real hardware too or not. Overall this seems a great risk for zero
gain.

This approach is sure safer than previous code given we can't pretend all guest
fs code out there to check for errors and reply the DMA if it was completed
partially, given a timeout would never materialize on a real harddisk unless
there are defective blocks (and defective blocks are practically only an issue
for reads never for writes in any recent hardware as writing to blocks is the
way to fix them) or the harddisk breaks as a whole.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Change bdrv_eject() not to drop the image
Markus Armbruster [Tue, 27 Jul 2010 12:02:01 +0000 (14:02 +0200)]
block: Change bdrv_eject() not to drop the image

bdrv_eject() gets called when a device model opens or closes the tray.

If the block driver implements method bdrv_eject(), that method gets
called.  Drivers host_cdrom implements it, and it opens and closes the
physical tray, and nothing else.  When a device model opens, then
closes the tray, media changes only if the user actively changes the
physical media while the tray is open.  This is matches how physical
hardware behaves.

If the block driver doesn't implement method bdrv_eject(), we do
something quite different: opening the tray severs the connection to
the image by calling bdrv_close(), and closing the tray does nothing.
When the device model opens, then closes the tray, media is gone,
unless the user actively inserts another one while the tray is open,
with a suitable change command in the monitor.  This isn't how
physical hardware behaves.  Rather inconvenient when programs
"helpfully" eject media to give you a chance to change it.  The way
bdrv_eject() behaves here turns that chance into a must, which is not
what these programs or their users expect.

Change the default action not to call bdrv_close().  Instead, note the
tray status in new BlockDriverState member tray_open.  Use it in
bdrv_is_inserted().

Arguably, the device models should keep track of tray status
themselves.  But this is less invasive.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Fix bdrv_has_zero_init
Kevin Wolf [Wed, 28 Jul 2010 09:26:29 +0000 (11:26 +0200)]
block: Fix bdrv_has_zero_init

Assuming that any image on a block device is not properly zero-initialized is
actually wrong: Only raw images have this problem. Any other image format
shouldn't care about it, they initialize everything properly themselves.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock migration: replace tabs by spaces.
Yoshiaki Tamura [Mon, 26 Jul 2010 04:25:41 +0000 (13:25 +0900)]
block migration: replace tabs by spaces.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoloadvm: improve tests before bdrv_snapshot_goto()
Miguel Di Ciurcio Filho [Mon, 19 Jul 2010 18:25:01 +0000 (15:25 -0300)]
loadvm: improve tests before bdrv_snapshot_goto()

This patch improves the resilience of the load_vmstate() function, doing
further and better ordered tests.

In load_vmstate(), if there is any error on bdrv_snapshot_goto(), except if the
error is on VM state device, load_vmstate() will return zero and the VM will be
started with major corruption chances.

The current process:
- test if there is any writable device without snapshot support
    - if exists return -error
- get the device that saves the VM state, possible return -error but unlikely
because it was tested earlier
- flush I/O
- run bdrv_snapshot_goto() on devices
    - if fails, give an warning and goes to the next (not good!)
    - if fails on the VM state device, return zero (not good!)
- check if the requested snapshot exists on the device that saves the VM state
and the state is not zero
    - if fails return -error
- open the file with the VM state
    - if fails return -error
- load the VM state
    - if fails return -error
- return zero

New behavior:
- get the device that saves the VM state
    - if fails return -error
- check if the requested snapshot exists on the device that saves the VM state
and the state is not zero
    - if fails return -error
- test if there is any writable device without snapshot support
    - if exists return -error
- test if the devices with snapshot support have the requested snapshot
    - if anyone fails, return -error
- flush I/O
- run snapshot_goto() on devices
    - if anyone fails, return -error
- open the file with the VM state
    - if fails return -error
- load the VM state
    - if fails return -error
- return zero

do_loadvm must not call vm_start if any error has occurred in load_vmstate.

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Change bdrv_commit to handle multiple sectors at once
Kevin Wolf [Fri, 16 Jul 2010 15:17:01 +0000 (17:17 +0200)]
block: Change bdrv_commit to handle multiple sectors at once

bdrv_commit copies the image to its backing file sector by sector, which
is (surprise!) relatively slow. Let's take a larger buffer and handle more
sectors at once if possible.

With a 1G qcow2 file, this brought the time bdrv_commit takes down from
5:06 min to 1:14 min for me.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>