Re: [Qemu-devel] [PATCH -V3 09/32] virtio-9p: Implement P9_TWRITE/ Thread model in QEMU

2010-03-28 Thread jvrao
Aneesh Kumar K.V wrote:
> From: Anthony Liguori 

We have implemented all the vfs calls in state machine model so that we are 
prepared
for the model where the VCPU thread(s) does the initial work until it needs to 
block then it
submits that work (via a function pointer) to a thread pool.  A thread in that 
thread pool
picks up the work, and completes the blocking call, when blocking call returns 
a callback is
invoked in the IO thread.  Then the IO thread runs until the next blocking 
function, and goto start.

Basically the VCPU/IO threads does all the non-blocking work, and let the 
threads in the
thread pool work on the blocking calls like mkdir() stat() etc.

My question is, why not let the whole work done by the thread in the thread 
pool?
VCPU thread receives the PDU and hands over the entire job to worker thread.
When all work is completed, either the worker thread or the IO thread(we can 
switch back at this point if needed) marks the request as completed in the 
virtqueue and injects an
interrupt to notify the guest.

We can still keep the same number of threads in the thread pool. 
This way, we are not increasing #of threads employed by QEMU...also it makes 
code lot 
more easy to read/maintain.

I may be missing something..but would like to know more on the advantages of 
this model.

Thanks,
JV

> 
> This gets write to file to work
> 
> Signed-off-by: Anthony Liguori 
> Signed-off-by: Venkateswararao Jujjuri 
> Signed-off-by: Aneesh Kumar K.V 
> ---
>  hw/virtio-9p-local.c |7 
>  hw/virtio-9p.c   |   97 -
>  2 files changed, 102 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
> index d77ecc2..c5d1db3 100644
> --- a/hw/virtio-9p-local.c
> +++ b/hw/virtio-9p-local.c
> @@ -129,6 +129,12 @@ static off_t local_lseek(void *opaque, int fd, off_t 
> offset, int whence)
>  return lseek(fd, offset, whence);
>  }
> 
> +static ssize_t local_writev(void *opaque, int fd, const struct iovec *iov,
> + int iovcnt)
> +{
> +return writev(fd, iov, iovcnt);
> +}
> +
>  static V9fsPosixFileOperations ops = {
>  .lstat = local_lstat,
>  .setuid = local_setuid,
> @@ -143,6 +149,7 @@ static V9fsPosixFileOperations ops = {
>  .seekdir = local_seekdir,
>  .readv = local_readv,
>  .lseek = local_lseek,
> +.writev = local_writev,
>  };
> 
>  V9fsPosixFileOperations *virtio_9p_init_local(const char *path)
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index 3ac6255..bc26d66 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -168,6 +168,12 @@ static off_t posix_lseek(V9fsState *s, int fd, off_t 
> offset, int whence)
>  return s->ops->lseek(s->ops->opaque, fd, offset, whence);
>  }
> 
> +static int posix_writev(V9fsState *s, int fd, const struct iovec *iov,
> +   int iovcnt)
> +{
> +return s->ops->writev(s->ops->opaque, fd, iov, iovcnt);
> +}
> +
>  static void v9fs_string_init(V9fsString *str)
>  {
>  str->data = NULL;
> @@ -1319,10 +1325,97 @@ out:
>  complete_pdu(s, pdu, err);
>  }
> 
> +typedef struct V9fsWriteState {
> +V9fsPDU *pdu;
> +size_t offset;
> +int32_t fid;
> +int32_t len;
> +int32_t count;
> +int32_t total;
> +int64_t off;
> +V9fsFidState *fidp;
> +struct iovec iov[128]; /* FIXME: bad, bad, bad */
> +struct iovec *sg;
> +int cnt;
> +} V9fsWriteState;
> +
> +static void v9fs_write_post_writev(V9fsState *s, V9fsWriteState *vs,
> +   ssize_t err)
> +{
> +BUG_ON(vs->len < 0);
> +vs->total += vs->len;
> +vs->sg = adjust_sg(vs->sg, vs->len, &vs->cnt);
> +if (vs->total < vs->count && vs->len > 0) {
> +do {
> +if (0)
> +print_sg(vs->sg, vs->cnt);
> +vs->len =  posix_writev(s, vs->fidp->fd, vs->sg, vs->cnt);
> +} while (vs->len == -1 && errno == EINTR);
> +v9fs_write_post_writev(s, vs, err);
> +}
> +vs->offset += pdu_marshal(vs->pdu, vs->offset, "d", vs->total);
> +
> +err = vs->offset;
> +complete_pdu(s, vs->pdu, err);
> +qemu_free(vs);
> +}
> +
> +static void v9fs_write_post_lseek(V9fsState *s, V9fsWriteState *vs, ssize_t 
> err)
> +{
> +BUG_ON(err == -1);
> +
> +vs->sg = cap_sg(vs->sg, vs->count, &vs->cnt);
> +
> +if (vs->total < vs->count) {
> +do {
> +if (0)
> +print_sg(vs->sg, vs->cnt);
> +vs->len = posix_writev(s, vs->fidp->fd, vs->sg, vs->cnt);
> +} while (vs->len == -1 && errno == EINTR);
> +
> +v9fs_write_post_writev(s, vs, err);
> +return;
> +}
> +
> +complete_pdu(s, vs->pdu, err);
> +qemu_free(vs);
> +}
> +
>  static void v9fs_write(V9fsState *s, V9fsPDU *pdu)
>  {
> -if (debug_9p_pdu)
> -pprint_pdu(pdu);
> +V9fsWriteState *vs;
> +ssize_t err;
> +
> +vs = qemu_malloc(sizeof(*vs));
> +
> +vs->pdu = pdu;
> +   

[Qemu-devel] [PATCH] ignore patch related files

2010-03-28 Thread Mike Frysinger
Signed-off-by: Mike Frysinger 
---
 .gitignore |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index dfc8e5b..def23c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,10 @@ qemu-monitor.texi
 *.o
 .pc
 patches
+*.diff
+*.patch
+*.rej
+*.orig
 pc-bios/bios-pq/status
 pc-bios/vgabios-pq/status
 pc-bios/optionrom/linuxboot.bin
-- 
1.7.0.3





Re: [Qemu-devel] [PATCH -V3 25/32] virtio-9p: Move V9fs File system specific options to a separate header file.

2010-03-28 Thread jvrao
Aneesh Kumar K.V wrote:

Missed one more point in my previous response. 


> 
> -static int local_lstat(V9fsState *s, const char *path, struct stat *stbuf)
> +static int local_lstat(FsContext *s, const char *path, struct stat *stbuf)

We have been using 's' for V9fsState For FsContext it is better to use something
else (ctx?).. which makes the code easy to read and even for search/cscope.

Thanks,
JV

>  {
>  return lstat(rpath(s, path), stbuf);
>  }
> 
> -static int local_setuid(V9fsState *s, uid_t uid)
> +static int local_setuid(FsContext *s, uid_t uid)
>  {
>  struct passwd *pw;
>  gid_t groups[33];
> @@ -70,80 +70,80 @@ static int local_setuid(V9fsState *s, uid_t uid)
>  return 0;
>  }
> 
> -static ssize_t local_readlink(V9fsState *s, const char *path,
> +static ssize_t local_readlink(FsContext *s, const char *path,
> char *buf, size_t bufsz)
>  {
>  return readlink(rpath(s, path), buf, bufsz);
>  }
> 
> -static int local_close(V9fsState *s, int fd)
> +static int local_close(FsContext *s, int fd)
>  {
>  return close(fd);
>  }
> 
> -static int local_closedir(V9fsState *s, DIR *dir)
> +static int local_closedir(FsContext *s, DIR *dir)
>  {
>  return closedir(dir);
>  }
> 
> -static int local_open(V9fsState *s, const char *path, int flags)
> +static int local_open(FsContext *s, const char *path, int flags)
>  {
>  return open(rpath(s, path), flags);
>  }
> 
> -static DIR *local_opendir(V9fsState *s, const char *path)
> +static DIR *local_opendir(FsContext *s, const char *path)
>  {
>  return opendir(rpath(s, path));
>  }
> 
> -static void local_rewinddir(V9fsState *s, DIR *dir)
> +static void local_rewinddir(FsContext *s, DIR *dir)
>  {
>  return rewinddir(dir);
>  }
> 
> -static off_t local_telldir(V9fsState *s, DIR *dir)
> +static off_t local_telldir(FsContext *s, DIR *dir)
>  {
>  return telldir(dir);
>  }
> 
> -static struct dirent *local_readdir(V9fsState *s, DIR *dir)
> +static struct dirent *local_readdir(FsContext *s, DIR *dir)
>  {
>  return readdir(dir);
>  }
> 
> -static void local_seekdir(V9fsState *s, DIR *dir, off_t off)
> +static void local_seekdir(FsContext *s, DIR *dir, off_t off)
>  {
>  return seekdir(dir, off);
>  }
> 
> -static ssize_t local_readv(V9fsState *s, int fd, const struct iovec *iov,
> +static ssize_t local_readv(FsContext *s, int fd, const struct iovec *iov,
>  int iovcnt)
>  {
>  return readv(fd, iov, iovcnt);
>  }
> 
> -static off_t local_lseek(V9fsState *s, int fd, off_t offset, int whence)
> +static off_t local_lseek(FsContext *s, int fd, off_t offset, int whence)
>  {
>  return lseek(fd, offset, whence);
>  }
> 
> -static ssize_t local_writev(V9fsState *s, int fd, const struct iovec *iov,
> +static ssize_t local_writev(FsContext *s, int fd, const struct iovec *iov,
>   int iovcnt)
>  {
>  return writev(fd, iov, iovcnt);
>  }
> 
> -static int local_chmod(V9fsState *s, const char *path, mode_t mode)
> +static int local_chmod(FsContext *s, const char *path, mode_t mode)
>  {
>  return chmod(rpath(s, path), mode);
>  }
> 
> -static int local_mknod(V9fsState *s, const char *path, mode_t mode, dev_t 
> dev)
> +static int local_mknod(FsContext *s, const char *path, mode_t mode, dev_t 
> dev)
>  {
>  return mknod(rpath(s, path), mode, dev);
>  }
> 
> -static int local_mksock(V9fsState *s2, const char *path)
> +static int local_mksock(FsContext *s2, const char *path)
>  {
>  struct sockaddr_un addr;
>  int s;
> @@ -164,28 +164,28 @@ static int local_mksock(V9fsState *s2, const char *path)
>  return 0;
>  }
> 
> -static int local_mkdir(V9fsState *s, const char *path, mode_t mode)
> +static int local_mkdir(FsContext *s, const char *path, mode_t mode)
>  {
>  return mkdir(rpath(s, path), mode);
>  }
> 
> -static int local_fstat(V9fsState *s, int fd, struct stat *stbuf)
> +static int local_fstat(FsContext *s, int fd, struct stat *stbuf)
>  {
>  return fstat(fd, stbuf);
>  }
> 
> -static int local_open2(V9fsState *s, const char *path, int flags, mode_t 
> mode)
> +static int local_open2(FsContext *s, const char *path, int flags, mode_t 
> mode)
>  {
>  return open(rpath(s, path), flags, mode);
>  }
> 
> -static int local_symlink(V9fsState *s, const char *oldpath,
> +static int local_symlink(FsContext *s, const char *oldpath,
>const char *newpath)
>  {
>  return symlink(oldpath, rpath(s, newpath));
>  }
> 
> -static int local_link(V9fsState *s, const char *oldpath, const char *newpath)
> +static int local_link(FsContext *s, const char *oldpath, const char *newpath)
>  {
>  char *tmp = qemu_strdup(rpath(s, oldpath));
>  int err, serrno = 0;
> @@ -205,12 +205,12 @@ static int local_link(V9fsState *s, const char 
> *oldpath, const char *newpath)
>  return err;
>  }
> 
> -static int local_truncate(V9fsState *s, const char *path, off_t size)
> +static int local_truncate(FsContext

Re: [Qemu-devel] [PATCH -V3 25/32] virtio-9p: Move V9fs File system specific options to a separate header file.

2010-03-28 Thread jvrao
Aneesh Kumar K.V wrote:
> Move the V9fs File System specific operations structs into a different header
> file.
> 
> Also introduce a new struct named context which is the subset of the V9fsState
> to be passed to the individual file-system operations.
> 
> Signed-off-by: Aneesh Kumar K.V 
> Signed-off-by: Gautham R Shenoy 
> ---
>  hw/file-op.h |   60 ++
>  hw/virtio-9p-local.c |   64 
>  hw/virtio-9p.c   |  209 
> +-
>  hw/virtio-9p.h   |   43 +-

I think we should add 9p to the file-op file too.   

May be fileop-9p.h ?

Thanks,
JV

>  4 files changed, 202 insertions(+), 174 deletions(-)
>  create mode 100644 hw/file-op.h
> 
> diff --git a/hw/file-op.h b/hw/file-op.h
> new file mode 100644
> index 000..f84767f
> --- /dev/null
> +++ b/hw/file-op.h
> @@ -0,0 +1,60 @@
> +/*
> + * Virtio 9p
> + *
> + * Copyright IBM, Corp. 2010
> + *
> + * Authors:
> + *  Aneesh Kumar K.V 
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + *
> + */
> +#ifndef _FILEOP_H
> +#define _FILEOP_H
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +typedef struct FsContext
> +{
> +char *fs_root;
> +uid_t uid;
> +} FsContext;
> +
> +typedef struct FileOperations
> +{
> +int (*lstat)(FsContext *, const char *, struct stat *);
> +ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
> +int (*chmod)(FsContext *, const char *, mode_t);
> +int (*chown)(FsContext *, const char *, uid_t, gid_t);
> +int (*mknod)(FsContext *, const char *, mode_t, dev_t);
> +int (*mksock)(FsContext *, const char *);
> +int (*utime)(FsContext *, const char *, const struct utimbuf *);
> +int (*remove)(FsContext *, const char *);
> +int (*symlink)(FsContext *, const char *, const char *);
> +int (*link)(FsContext *, const char *, const char *);
> +int (*setuid)(FsContext *, uid_t);
> +int (*close)(FsContext *, int);
> +int (*closedir)(FsContext *, DIR *);
> +DIR *(*opendir)(FsContext *, const char *);
> +int (*open)(FsContext *, const char *, int);
> +int (*open2)(FsContext *, const char *, int, mode_t);
> +void (*rewinddir)(FsContext *, DIR *);
> +off_t (*telldir)(FsContext *, DIR *);
> +struct dirent *(*readdir)(FsContext *, DIR *);
> +void (*seekdir)(FsContext *, DIR *, off_t);
> +ssize_t (*readv)(FsContext *, int, const struct iovec *, int);
> +ssize_t (*writev)(FsContext *, int, const struct iovec *, int);
> +off_t (*lseek)(FsContext *, int, off_t, int);
> +int (*mkdir)(FsContext *, const char *, mode_t);
> +int (*fstat)(FsContext *, int, struct stat *);
> +int (*rename)(FsContext *, const char *, const char *);
> +int (*truncate)(FsContext *, const char *, off_t);
> +int (*fsync)(FsContext *, int);
> +void *opaque;
> +} FileOperations;
> +#endif
> diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
> index 4584bf6..690ba3f 100644
> --- a/hw/virtio-9p-local.c
> +++ b/hw/virtio-9p-local.c
> @@ -22,7 +22,7 @@
>  #include 
>  #include 
> 
> -static const char *rpath(V9fsState *s, const char *path)
> +static const char *rpath(FsContext *s, const char *path)
>  {
>  /* FIXME: so wrong... */
>  static char buffer[4096];
> @@ -30,12 +30,12 @@ static const char *rpath(V9fsState *s, const char *path)
>  return buffer;
>  }
> 
> -static int local_lstat(V9fsState *s, const char *path, struct stat *stbuf)
> +static int local_lstat(FsContext *s, const char *path, struct stat *stbuf)
>  {
>  return lstat(rpath(s, path), stbuf);
>  }
> 
> -static int local_setuid(V9fsState *s, uid_t uid)
> +static int local_setuid(FsContext *s, uid_t uid)
>  {
>  struct passwd *pw;
>  gid_t groups[33];
> @@ -70,80 +70,80 @@ static int local_setuid(V9fsState *s, uid_t uid)
>  return 0;
>  }
> 
> -static ssize_t local_readlink(V9fsState *s, const char *path,
> +static ssize_t local_readlink(FsContext *s, const char *path,
> char *buf, size_t bufsz)
>  {
>  return readlink(rpath(s, path), buf, bufsz);
>  }
> 
> -static int local_close(V9fsState *s, int fd)
> +static int local_close(FsContext *s, int fd)
>  {
>  return close(fd);
>  }
> 
> -static int local_closedir(V9fsState *s, DIR *dir)
> +static int local_closedir(FsContext *s, DIR *dir)
>  {
>  return closedir(dir);
>  }
> 
> -static int local_open(V9fsState *s, const char *path, int flags)
> +static int local_open(FsContext *s, const char *path, int flags)
>  {
>  return open(rpath(s, path), flags);
>  }
> 
> -static DIR *local_opendir(V9fsState *s, const char *path)
> +static DIR *local_opendir(FsContext *s, const char *path)
>  {
>  return opendir(rpath(s, path));
>  }
> 
> -static void local_rewinddir(V9fsState *s, DIR *dir)
> +static void local_rewinddir(FsContext *s, DIR *dir)
>  {
>  return rewin

[Qemu-devel] [PATCH 1/5] linux-user/ia64: workaround ia64 strangenesses

2010-03-28 Thread Aurelien Jarno
ia64 has some strangenesses that need to be workaround:
- it has a __clone2() syscall instead of the using clone() one, with
  different arguments, and which is not declared in the usual headers.
- ucontext.uc_sigmask is declared with type long int, while it is
  actually of type sigset_t.
- uc_mcontext, uc_sigmask, uc_stack, uc_link are declared using #define,
  which clashes with the target_ucontext fields. Change their names to
  tuc_*, as already done for some target architectures.
---
 cpu-exec.c   |6 +-
 linux-user/signal.c  |  208 +-
 linux-user/syscall.c |6 +-
 3 files changed, 114 insertions(+), 106 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index bcfcda2..372aeac 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -81,7 +81,11 @@ void cpu_resume_from_signal(CPUState *env1, void *puc)
 if (puc) {
 /* XXX: use siglongjmp ? */
 #ifdef __linux__
+#ifdef __ia64
+sigprocmask(SIG_SETMASK, (sigset_t *)&uc->uc_sigmask, NULL);
+#else
 sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
+#endif
 #elif defined(__OpenBSD__)
 sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL);
 #endif
@@ -1150,7 +1154,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, void 
*puc)
 }
 return handle_cpu_signal(ip, (unsigned long)info->si_addr,
  is_write,
- &uc->uc_sigmask, puc);
+ (sigset_t *)&uc->uc_sigmask, puc);
 }
 
 #elif defined(__s390__)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index e327c3d..a72c15c 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2052,10 +2052,10 @@ typedef struct {
 } target_mcontext_t;
 
 struct target_ucontext {
-struct target_ucontext *uc_link;
-abi_ulong uc_flags;
-target_sigset_t uc_sigmask;
-target_mcontext_t uc_mcontext;
+struct target_ucontext *tuc_link;
+abi_ulong tuc_flags;
+target_sigset_t tuc_sigmask;
+target_mcontext_t tuc_mcontext;
 };
 
 /* A V9 register window */
@@ -2081,7 +2081,7 @@ void sparc64_set_context(CPUSPARCState *env)
 ucp_addr = env->regwptr[UREG_I0];
 if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1))
 goto do_sigsegv;
-grp  = &ucp->uc_mcontext.mc_gregs;
+grp  = &ucp->tuc_mcontext.mc_gregs;
 err  = __get_user(pc, &((*grp)[MC_PC]));
 err |= __get_user(npc, &((*grp)[MC_NPC]));
 if (err || ((pc | npc) & 3))
@@ -2091,11 +2091,11 @@ void sparc64_set_context(CPUSPARCState *env)
 sigset_t set;
 
 if (TARGET_NSIG_WORDS == 1) {
-if (__get_user(target_set.sig[0], &ucp->uc_sigmask.sig[0]))
+if (__get_user(target_set.sig[0], &ucp->tuc_sigmask.sig[0]))
 goto do_sigsegv;
 } else {
 abi_ulong *src, *dst;
-src = ucp->uc_sigmask.sig;
+src = ucp->tuc_sigmask.sig;
 dst = target_set.sig;
 for (i = 0; i < sizeof(target_sigset_t) / sizeof(abi_ulong);
  i++, dst++, src++)
@@ -2129,8 +2129,8 @@ void sparc64_set_context(CPUSPARCState *env)
 err |= __get_user(env->regwptr[UREG_I6], (&(*grp)[MC_O6]));
 err |= __get_user(env->regwptr[UREG_I7], (&(*grp)[MC_O7]));
 
-err |= __get_user(fp, &(ucp->uc_mcontext.mc_fp));
-err |= __get_user(i7, &(ucp->uc_mcontext.mc_i7));
+err |= __get_user(fp, &(ucp->tuc_mcontext.mc_fp));
+err |= __get_user(i7, &(ucp->tuc_mcontext.mc_i7));
 
 w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6];
 if (put_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), 
@@ -2139,20 +2139,20 @@ void sparc64_set_context(CPUSPARCState *env)
 if (put_user(i7, w_addr + offsetof(struct target_reg_window, ins[7]), 
  abi_ulong) != 0)
 goto do_sigsegv;
-err |= __get_user(fenab, &(ucp->uc_mcontext.mc_fpregs.mcfpu_enab));
-err |= __get_user(env->fprs, &(ucp->uc_mcontext.mc_fpregs.mcfpu_fprs));
+err |= __get_user(fenab, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_enab));
+err |= __get_user(env->fprs, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fprs));
 {
 uint32_t *src, *dst;
-src = ucp->uc_mcontext.mc_fpregs.mcfpu_fregs.sregs;
+src = ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs;
 dst = env->fpr;
 /* XXX: check that the CPU storage is the same as user context */
 for (i = 0; i < 64; i++, dst++, src++)
 err |= __get_user(*dst, src);
 }
 err |= __get_user(env->fsr,
-  &(ucp->uc_mcontext.mc_fpregs.mcfpu_fsr));
+  &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fsr));
 err |= __get_user(env->gsr,
-  &(ucp->uc_mcontext.mc_fpregs.mcfpu_gsr));
+  &(ucp->tuc_mcontext.mc_fpregs.mcfpu_gsr));
 if (err)
 goto do_sigsegv;
 unlock_user_struct(ucp, ucp_addr, 0);
@@ -2178,7 +2178,7 @@ void sparc64_get_context(CPUSPARCState *env)
 if (!lock_user_struct(VERIFY_WRITE, u

[Qemu-devel] [PATCH 4/5] tcg: align static_code_gen_buffer to CODE_GEN_ALIGN

2010-03-28 Thread Aurelien Jarno
On ia64, the default memory alignement is not enough for a code
alignement. To fix that, force static_code_gen_buffer alignment
to CODE_GEN_ALIGN.

Signed-off-by: Aurelien Jarno 
---
 exec.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/exec.c b/exec.c
index 1b0fe52..5c13524 100644
--- a/exec.c
+++ b/exec.c
@@ -447,7 +447,8 @@ static void tlb_unprotect_code_phys(CPUState *env, 
ram_addr_t ram_addr,
 #endif
 
 #ifdef USE_STATIC_CODE_GEN_BUFFER
-static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE];
+static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]
+   __attribute__((aligned (CODE_GEN_ALIGN)));
 #endif
 
 static void code_gen_alloc(unsigned long tb_size)
-- 
1.7.0.2





[Qemu-devel] [PATCH 2/5] linux-user: fix page_unprotect when host page size > target page size

2010-03-28 Thread Aurelien Jarno
When the host page size is bigger that the target one, unprotecting a
page should:
- mark all the target pages corresponding to the host page as writable
- invalidate all tb corresponding to the host page (and not the target
  page)

Signed-off-by: Aurelien Jarno 
---
 exec.c |   45 ++---
 1 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/exec.c b/exec.c
index 0916208..1b0fe52 100644
--- a/exec.c
+++ b/exec.c
@@ -2447,8 +2447,8 @@ int page_check_range(target_ulong start, target_ulong 
len, int flags)
page. Return TRUE if the fault was successfully handled. */
 int page_unprotect(target_ulong address, unsigned long pc, void *puc)
 {
-unsigned int page_index, prot, pindex;
-PageDesc *p, *p1;
+unsigned int prot;
+PageDesc *p;
 target_ulong host_start, host_end, addr;
 
 /* Technically this isn't safe inside a signal handler.  However we
@@ -2456,37 +2456,36 @@ int page_unprotect(target_ulong address, unsigned long 
pc, void *puc)
practice it seems to be ok.  */
 mmap_lock();
 
-host_start = address & qemu_host_page_mask;
-page_index = host_start >> TARGET_PAGE_BITS;
-p1 = page_find(page_index);
-if (!p1) {
+p = page_find(address >> TARGET_PAGE_BITS);
+if (!p) {
 mmap_unlock();
 return 0;
 }
-host_end = host_start + qemu_host_page_size;
-p = p1;
-prot = 0;
-for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
-prot |= p->flags;
-p++;
-}
+
 /* if the page was really writable, then we change its
protection back to writable */
-if (prot & PAGE_WRITE_ORG) {
-pindex = (address - host_start) >> TARGET_PAGE_BITS;
-if (!(p1[pindex].flags & PAGE_WRITE)) {
-mprotect((void *)g2h(host_start), qemu_host_page_size,
- (prot & PAGE_BITS) | PAGE_WRITE);
-p1[pindex].flags |= PAGE_WRITE;
+if ((p->flags & PAGE_WRITE_ORG) && !(p->flags & PAGE_WRITE)) {
+host_start = address & qemu_host_page_mask;
+host_end = host_start + qemu_host_page_size;
+
+prot = 0;
+for (addr = host_start ; addr < host_end ; addr += TARGET_PAGE_SIZE) {
+p = page_find(addr >> TARGET_PAGE_BITS);
+p->flags |= PAGE_WRITE;
+prot |= p->flags;
+
 /* and since the content will be modified, we must invalidate
the corresponding translated code. */
-tb_invalidate_phys_page(address, pc, puc);
+tb_invalidate_phys_page(addr, pc, puc);
 #ifdef DEBUG_TB_CHECK
-tb_invalidate_check(address);
+tb_invalidate_check(addr);
 #endif
-mmap_unlock();
-return 1;
 }
+mprotect((void *)g2h(host_start), qemu_host_page_size,
+ prot & PAGE_BITS);
+
+mmap_unlock();
+return 1;
 }
 mmap_unlock();
 return 0;
-- 
1.7.0.2





[Qemu-devel] ia64 support

2010-03-28 Thread Aurelien Jarno
This patch series adds host Itanium support to QEMU.

System mode works correctly except a few unaligned access in the slirp
code (fixed by the kernel). It has been tested by booting debian 
installer on arm, i386, mips, mipsel, ppc, sparc, and x86_64. A full 
installation has been done on sparc.

User mode works correctly for static binaries, but fails for some
dynamic binaries, due to mmap emulation not working correctly when
host page size is bigger than the target one.





[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Cam Macdonell
On Sat, Mar 27, 2010 at 11:48 AM, Avi Kivity  wrote:
> On 03/26/2010 07:14 PM, Cam Macdonell wrote:
>>
>>> I'm not familiar with the uio internals, but for the interface, an
>>> ioctl()
>>> on the fd to assign an eventfd to an MSI vector.  Similar to ioeventfd,
>>> but
>>> instead of mapping a doorbell to an eventfd, it maps a real MSI to an
>>> eventfd.
>>>
>>
>> uio will never support ioctls.
>
> Why not?

Perhaps I spoke too strongly, but it was rejected before

http://thread.gmane.org/gmane.linux.kernel/756481

With a compelling case perhaps it could be added.




Re: [Qemu-devel] [PATCH 23/48] multi-mmc support in init call

2010-03-28 Thread Filip Navara
I see neither the change to sd_init implementation nor the implementation
of sd_is_mmc.

Best regards,
Filip Navara

On Fri, Mar 26, 2010 at 5:06 PM, Riku Voipio  wrote:

> From: Juha Riihimäki 
>
> change sd_init convention to allow multiple entries
>
> Signed-Off-By: Riku Voipio 
> Signed-Off-By: Juha Riihimäki 
>
> ---
>  hw/omap_mmc.c|4 ++--
>  hw/pl181.c   |2 +-
>  hw/pxa2xx_mmci.c |2 +-
>  hw/sd.h  |4 +++-
>  hw/ssi-sd.c  |2 +-
>  5 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hw/omap_mmc.c b/hw/omap_mmc.c
> index 15cbf06..7c94d91 100644
> --- a/hw/omap_mmc.c
> +++ b/hw/omap_mmc.c
> @@ -590,7 +590,7 @@ struct omap_mmc_s *omap_mmc_init(target_phys_addr_t
> base,
> cpu_register_physical_memory(base, 0x800, iomemtype);
>
> /* Instantiate the storage */
> -s->card = sd_init(bd, 0);
> +s->card = sd_init(bd, 0, 0);
>
> return s;
>  }
> @@ -616,7 +616,7 @@ struct omap_mmc_s *omap2_mmc_init(struct
> omap_target_agent_s *ta,
> omap_l4_attach(ta, 0, iomemtype);
>
> /* Instantiate the storage */
> -s->card = sd_init(bd, 0);
> +s->card = sd_init(bd, 0, 0);
>
> s->cdet = qemu_allocate_irqs(omap_mmc_cover_cb, s, 1)[0];
> sd_set_cb(s->card, NULL, s->cdet);
> diff --git a/hw/pl181.c b/hw/pl181.c
> index 1924053..fd5ee81 100644
> --- a/hw/pl181.c
> +++ b/hw/pl181.c
> @@ -458,7 +458,7 @@ static int pl181_init(SysBusDevice *dev)
> sysbus_init_irq(dev, &s->irq[0]);
> sysbus_init_irq(dev, &s->irq[1]);
> bd = qdev_init_bdrv(&dev->qdev, IF_SD);
> -s->card = sd_init(bd, 0);
> +s->card = sd_init(bd, 0, 0);
> qemu_register_reset(pl181_reset, s);
> pl181_reset(s);
> /* ??? Save/restore.  */
> diff --git a/hw/pxa2xx_mmci.c b/hw/pxa2xx_mmci.c
> index a415349..01e7f1e 100644
> --- a/hw/pxa2xx_mmci.c
> +++ b/hw/pxa2xx_mmci.c
> @@ -532,7 +532,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t
> base,
> cpu_register_physical_memory(base, 0x0010, iomemtype);
>
> /* Instantiate the actual storage */
> -s->card = sd_init(bd, 0);
> +s->card = sd_init(bd, 0, 0);
>
> register_savevm("pxa2xx_mmci", 0, 0,
> pxa2xx_mmci_save, pxa2xx_mmci_load, s);
> diff --git a/hw/sd.h b/hw/sd.h
> index ac4b7c4..96450f2 100644
> --- a/hw/sd.h
> +++ b/hw/sd.h
> @@ -67,7 +67,8 @@ typedef struct {
>
>  typedef struct SDState SDState;
>
> -SDState *sd_init(BlockDriverState *bs, int is_spi);
> +SDState *sd_init(BlockDriverState *bs, int is_spi, int is_mmc);
> +void sd_reset(SDState *sd);
>  int sd_do_command(SDState *sd, SDRequest *req,
>   uint8_t *response);
>  void sd_write_data(SDState *sd, uint8_t value);
> @@ -75,5 +76,6 @@ uint8_t sd_read_data(SDState *sd);
>  void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert);
>  int sd_data_ready(SDState *sd);
>  void sd_enable(SDState *sd, int enable);
> +int sd_is_mmc(SDState *sd);
>
>  #endif /* __hw_sd_h */
> diff --git a/hw/ssi-sd.c b/hw/ssi-sd.c
> index 5e74e5d..a5d350d 100644
> --- a/hw/ssi-sd.c
> +++ b/hw/ssi-sd.c
> @@ -236,7 +236,7 @@ static int ssi_sd_init(SSISlave *dev)
>
> s->mode = SSI_SD_CMD;
> bs = qdev_init_bdrv(&dev->qdev, IF_SD);
> -s->sd = sd_init(bs, 1);
> +s->sd = sd_init(bs, 1, 0);
> register_savevm("ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
> return 0;
>  }
> --
> 1.6.5
>
>
>
>


Re: [Qemu-devel] [PATCH 1/4] linux-user: add pselect syscall

2010-03-28 Thread Jamie Lokier
Paul Brook wrote:
> >This patch adds support for the pselect syscall in linux-user emulation
> >and also adds several support functions required to translate the
> >timespec structs between the target and the host.
> 
> IIUC the whole point of the pselect is that it should be atomic. By
> emulating this in a non-atomic fasion I think you're re-introducing
> the race condition that it is designed to avoid.
>
> Wouldn't it be better to just return ENOSYS and let the guest deal with the 
> problem?

Imho, it's very important to return ENOSYS if the atomic behaviour is
not provided.

The patch actually calls the host's pselect() - it looks almost ok...

But actually, host's pselect() may be Glibc or some other equally
buggy libc, which "emulates" pselect wrongly.  FreeBSD's pselect has
the same problem going back years - with a very recent patch to
support it in the kernel.  It's not just Glibc.

Careful apps detect and avoid libc's bug by calling the pselect syscall
directly.  If it returns ENOSYS, they just use a different (but
slightly slower) race-free technique, or abort - at least they don't
have a quiet corruption bug.

But here we're providing the kernel syscall to guest apps.  There's no
way for them to detect if it's really atomic or not.  And the ones
written carefully to avoid buggy libc will wrongly use it, because
they think it's a kernel call.

I think it's really important we don't pass on libc's buggy behaviour
to the emulated kernel interface, to even break careful apps.

Solution, Riku: Instead of calling pselect(...), qemu should call
syscall(SYS_pselect, ...), with a comment like:

/*
 * Glibc and some other libcs unhelpfully "emulate" pselect()
 * using select() when the real system call isn't available, and
 * break the atomic guarantee which is the entire point of
 * pselect().  To avoid these libc bugs, go straight to the host
 * kernel using syscall().  If the host kernel doesn't support
 * pselect() it will return ENOSYS, which is what we want to
 * return to the guest.
 */

There might need to be some header file included to get syscall() and
SYS_pselect, which sometimes has other names like NR_pselect.  And
unfortunately the call arguments aren't quite the same, at least on
Linux.

Same goes for ppoll() if that is ever added.

-- Jamie




[Qemu-devel] BlueTooth RFCOMM?

2010-03-28 Thread Samuel Thibault
Hello,

I am trying to add support for Bluetooth braille devices, but I seem to
be missing something. Basically, it should be using the RFCOMM PSM, but
running

rfcomm connect 0 BA:BE:BA:D0:00:01

in the Linux guest hangs for some time and then the connect() system
call returns EINPROGRESS. Am I perhaps missing some call to the qemu bt
core?

Samuel

diff --git a/Makefile.objs b/Makefile.objs
index e791dd5..b7c8fa6 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -78,7 +78,7 @@ common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o
 common-obj-y += qemu-config.o block-migration.o
 
-common-obj-$(CONFIG_BRLAPI) += baum.o
+common-obj-$(CONFIG_BRLAPI) += baum.o bt-baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
 
 audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
diff --git a/hw/baum.h b/hw/baum.h
index 8af710f..1fe30a7 100644
--- a/hw/baum.h
+++ b/hw/baum.h
@@ -22,5 +22,9 @@
  * THE SOFTWARE.
  */
 
+#include "qemu-char.h"
+#include "bt.h"
 /* char device */
 CharDriverState *chr_baum_init(QemuOpts *opts);
+/* bluetooth device */
+struct bt_device_s *bt_baum_init(struct bt_scatternet_s *net);
diff --git a/hw/bt-baum.c b/hw/bt-baum.c
new file mode 100644
index 000..568b8a1
--- /dev/null
+++ b/hw/bt-baum.c
@@ -0,0 +1,158 @@
+/*
+ * QEMU Bluetooth Baum driver.
+ *
+ * Copyright (C) 2010 Samuel Thibault 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, if not, see .
+ */
+
+#include "qemu-common.h"
+#include "baum.h"
+#include "bt.h"
+
+#define BT_BAUM_MTU1000
+
+struct bt_baum_device_s {
+struct bt_l2cap_device_s btdev;
+struct bt_l2cap_conn_params_s *ch;
+
+CharDriverState *cdrv;
+};
+
+static int bt_baum_can_read(void *opaque)
+{
+struct bt_baum_device_s *s = opaque;
+/* Is there room in the bluetooth socket? */
+
+if (!s->ch)
+return 0;
+
+return s->ch->remote_mtu;
+}
+
+static void bt_baum_read(void *opaque, const uint8_t *buf, int size)
+{
+/* Got data from the Baum device to send over bluetooth to the guest */
+struct bt_baum_device_s *s = opaque;
+uint8_t *pkt;
+int len;
+struct bt_l2cap_conn_params_s *ch = s->ch;
+
+if (!ch)
+return;
+
+while (size) {
+len = MIN(size, ch->remote_mtu);
+pkt = ch->sdu_out(ch, size);
+memcpy(pkt, buf, size);
+ch->sdu_submit(ch);
+size -= len;
+buf += len;
+};
+}
+
+static void bt_baum_sdu(void *opaque, const uint8_t *data, int len)
+{
+/* Got data from bluetooth, to be sent to the Baum device */
+struct bt_baum_device_s *s = opaque;
+qemu_chr_write(s->cdrv, data, len);
+}
+
+static void bt_baum_close_ch(void *opaque)
+{
+struct bt_baum_device_s *s = opaque;
+
+s->btdev.device.page_scan = 1;
+s->btdev.device.inquiry_scan = 1;
+
+s->ch = NULL;
+printf("close connection\n");
+}
+
+static int bt_baum_new_ch(struct bt_l2cap_device_s *dev,
+struct bt_l2cap_conn_params_s *params)
+{
+struct bt_baum_device_s *s = (struct bt_baum_device_s *) dev;
+
+if (s->ch) {
+printf("already there: %p\n", s->ch);
+return 1;
+}
+
+printf("new connection\n");
+s->ch = params;
+s->ch->opaque = s;
+s->ch->close = bt_baum_close_ch;
+s->ch->sdu_in = bt_baum_sdu;
+
+s->btdev.device.page_scan = 0;
+s->btdev.device.inquiry_scan = 0;
+
+return 0;
+}
+
+static void bt_baum_destroy(struct bt_device_s *dev)
+{
+struct bt_baum_device_s *s = (struct bt_baum_device_s *) dev;
+
+bt_l2cap_device_done(&s->btdev);
+
+qemu_chr_close(s->cdrv);
+
+qemu_free(s);
+}
+
+struct bt_device_s *bt_baum_init(struct bt_scatternet_s *net)
+{
+struct bt_baum_device_s *s;
+/* FIXME */
+uint32_t class =
+/* Format type */
+(0 << 0) |
+/* Device class */
+(0 << 2) |
+(5 << 8) |  /* "Peripheral" */
+/* Service classes */
+(1 << 13) | /* Limited discoverable mode */
+(1 << 19);  /* Capturing device (?) */
+
+s = qemu_mallocz(sizeof(*s));
+if (!s)
+return NULL;
+
+s->cdrv = qemu_chr_open("braille", "braille",  NULL);
+
+if (!s->cdrv) {
+qemu_free(s);
+return NULL;
+}
+
+bt_l2cap_device_init(&s->btdev, net);
+bt_l2cap_sdp_init(&s->btdev);
+
+s->btdev.device.lmp_n

Re: [Qemu-devel] Significant performance regression in qemu-system-mips.

2010-03-28 Thread Rob Landley
On Sunday 28 March 2010 09:57:09 Aurelien Jarno wrote:
> > If you want the code actually cleaned up instead of minimally changed,
> > here's a stab at that.  (Unfortunately I haven't got a ppc64 setup to
> > test it with yet, but ppc32 still works.)
>
> Not necessarily a code cleanup, but at least a patch which doesn't
> introduce useless changes. Anyway applied.

The original change was to eliminate an "unused variable pos" warning when the 
BSD code was #ifdefed out.

Yay applied.  Thanks,

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds




[Qemu-devel] [PATCH] baum: add destroy hook

2010-03-28 Thread Samuel Thibault
Hello,

This adds a destroy hook for the baum character device, to properly
close the BrlAPI connection and free resources.

Signed-off-by: Samuel Thibault 
 
commit 447c41758cfda0022ea6e09aaf81137b2b27b915
Author: Samuel Thibault 
Date:   Sun Mar 28 20:38:38 2010 +0200

baum: add destroy hook

Add a destroy hook for the baum character device, to properly close the 
BrlAPI
connection.

diff --git a/hw/baum.c b/hw/baum.c
index 18633f4..21326ae 100644
--- a/hw/baum.c
+++ b/hw/baum.c
@@ -564,6 +564,18 @@ static void baum_chr_read(void *opaque)
 }
 }
 
+static void baum_close(struct CharDriverState *chr)
+{
+BaumDriverState *baum = chr->opaque;
+
+qemu_free_timer(baum->cellCount_timer);
+if (baum->brlapi) {
+brlapi__closeConnection(baum->brlapi);
+qemu_free(baum->brlapi);
+}
+qemu_free(baum);
+}
+
 CharDriverState *chr_baum_init(QemuOpts *opts)
 {
 BaumDriverState *baum;
@@ -581,6 +593,7 @@ CharDriverState *chr_baum_init(QemuOpts *opts)
 chr->chr_write = baum_write;
 chr->chr_send_event = baum_send_event;
 chr->chr_accept_input = baum_accept_input;
+chr->chr_close = baum_close;
 
 handle = qemu_mallocz(brlapi_getHandleSize());
 baum->brlapi = handle;




[Qemu-devel] [PATCH 3/3] qemu-nbd: Improve error reporting

2010-03-28 Thread Ryota Ozaki
- use err(3) instead of errx(3) if errno is available
  to report why failed
- let fail prior to daemon(3) if opening a nbd file
  is likely to fail after daemonizing to avoid silent
  failure exit
- add missing 'ret = 1' when unix_socket_outgoing failed

Signed-off-by: Ryota Ozaki 
---
 qemu-nbd.c |   17 -
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 7ef409f..d3e1814 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -324,7 +324,7 @@ int main(int argc, char **argv)
 if (disconnect) {
 fd = open(argv[optind], readonly ? O_RDONLY : O_RDWR);
 if (fd == -1) {
-errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
+err(EXIT_FAILURE, "Cannot open %s", argv[optind]);
 }
 
 nbd_disconnect(fd);
@@ -343,25 +343,31 @@ int main(int argc, char **argv)
 return 1;
 }
 
-if (bdrv_open(bs, argv[optind], flags) < 0) {
-return 1;
+if ((ret = bdrv_open(bs, argv[optind], flags)) < 0) {
+errno = -ret;
+err(EXIT_FAILURE, "Failed to bdrv_open '%s'", argv[optind]);
 }
 
 fd_size = bs->total_sectors * 512;
 
 if (partition != -1 &&
 find_partition(bs, partition, &dev_offset, &fd_size)) {
-errx(EXIT_FAILURE, "Could not find partition %d", partition);
+err(EXIT_FAILURE, "Could not find partition %d", partition);
 }
 
 if (device) {
 pid_t pid;
 int sock;
 
+/* want to fail before daemonizing */
+if (access(device, readonly ? R_OK : R_OK|W_OK) == -1) {
+err(EXIT_FAILURE, "Could not access '%s'", device);
+}
+
 if (!verbose) {
 /* detach client and server */
 if (daemon(0, 0) == -1) {
-errx(EXIT_FAILURE, "Failed to daemonize");
+err(EXIT_FAILURE, "Failed to daemonize");
 }
 }
 
@@ -386,6 +392,7 @@ int main(int argc, char **argv)
 sock = unix_socket_outgoing(socket);
 if (sock == -1) {
 if (errno != ENOENT && errno != ECONNREFUSED) {
+ret = 1;
 goto out;
 }
 sleep(1);  /* wait children */
-- 
1.6.5.2





[Qemu-devel] [PATCH 2/3] qemu-nbd: Extend read-only option to nbd device file

2010-03-28 Thread Ryota Ozaki
This patch allows to operate on nbd device file
without write permission for the file if read-only
option is specified.

Signed-off-by: Ryota Ozaki 
---
 qemu-nbd.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 00b8896..7ef409f 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -162,7 +162,7 @@ static int find_partition(BlockDriverState *bs, int 
partition,
 return -1;
 }
 
-static void show_parts(const char *device)
+static void show_parts(const char *device, bool readonly)
 {
 if (fork() == 0) {
 int nbd;
@@ -172,7 +172,7 @@ static void show_parts(const char *device)
  * but remember to load the module with max_part != 0 :
  * modprobe nbd max_part=63
  */
-nbd = open(device, O_RDWR);
+nbd = open(device, readonly ? O_RDONLY : O_RDWR);
 if (nbd != -1) {
   close(nbd);
 }
@@ -322,7 +322,7 @@ int main(int argc, char **argv)
 }
 
 if (disconnect) {
-fd = open(argv[optind], O_RDWR);
+fd = open(argv[optind], readonly ? O_RDONLY : O_RDWR);
 if (fd == -1) {
 errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
 }
@@ -392,7 +392,7 @@ int main(int argc, char **argv)
 }
 } while (sock == -1);
 
-fd = open(device, O_RDWR);
+fd = open(device, readonly ? O_RDONLY : O_RDWR);
 if (fd == -1) {
 ret = 1;
 goto out;
@@ -415,7 +415,7 @@ int main(int argc, char **argv)
 
/* update partition table */
 
-show_parts(device);
+show_parts(device, readonly);
 
 nbd_client(fd, sock);
 close(fd);
-- 
1.6.5.2





[Qemu-devel] [PATCH 1/3] qemu-nbd: Fix coding style

2010-03-28 Thread Ryota Ozaki
Follow "Every indented statement is braced; even if the block
contains just one statement." described in CODING_STYLE.

Signed-off-by: Ryota Ozaki 
---
 qemu-nbd.c |   60 
 1 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 6d854d3..00b8896 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -113,8 +113,9 @@ static int find_partition(BlockDriverState *bs, int 
partition,
 int i;
 int ext_partnum = 4;
 
-if (bdrv_read(bs, 0, data, 1))
+if (bdrv_read(bs, 0, data, 1)) {
 errx(EXIT_FAILURE, "error while reading");
+}
 
 if (data[510] != 0x55 || data[511] != 0xaa) {
 errno = -EINVAL;
@@ -124,21 +125,24 @@ static int find_partition(BlockDriverState *bs, int 
partition,
 for (i = 0; i < 4; i++) {
 read_partition(&data[446 + 16 * i], &mbr[i]);
 
-if (!mbr[i].nb_sectors_abs)
+if (!mbr[i].nb_sectors_abs) {
 continue;
+}
 
 if (mbr[i].system == 0xF || mbr[i].system == 0x5) {
 struct partition_record ext[4];
 uint8_t data1[512];
 int j;
 
-if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))
+if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1)) {
 errx(EXIT_FAILURE, "error while reading");
+}
 
 for (j = 0; j < 4; j++) {
 read_partition(&data1[446 + 16 * j], &ext[j]);
-if (!ext[j].nb_sectors_abs)
+if (!ext[j].nb_sectors_abs) {
 continue;
+}
 
 if ((ext_partnum + j + 1) == partition) {
 *offset = (uint64_t)ext[j].start_sector_abs << 9;
@@ -169,8 +173,9 @@ static void show_parts(const char *device)
  * modprobe nbd max_part=63
  */
 nbd = open(device, O_RDWR);
-if (nbd != -1)
+if (nbd != -1) {
   close(nbd);
+}
 exit(0);
 }
 }
@@ -262,15 +267,18 @@ int main(int argc, char **argv)
 break;
 case 'P':
 partition = strtol(optarg, &end, 0);
-if (*end)
+if (*end) {
 errx(EXIT_FAILURE, "Invalid partition `%s'", optarg);
-if (partition < 1 || partition > 8)
+}
+if (partition < 1 || partition > 8) {
 errx(EXIT_FAILURE, "Invalid partition %d", partition);
+}
 break;
 case 'k':
 socket = optarg;
-if (socket[0] != '/')
+if (socket[0] != '/') {
 errx(EXIT_FAILURE, "socket path must be absolute\n");
+}
 break;
 case 'd':
 disconnect = true;
@@ -315,8 +323,9 @@ int main(int argc, char **argv)
 
 if (disconnect) {
 fd = open(argv[optind], O_RDWR);
-if (fd == -1)
+if (fd == -1) {
 errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
+}
 
 nbd_disconnect(fd);
 
@@ -330,17 +339,20 @@ int main(int argc, char **argv)
 bdrv_init();
 
 bs = bdrv_new("hda");
-if (bs == NULL)
+if (bs == NULL) {
 return 1;
+}
 
-if (bdrv_open(bs, argv[optind], flags) < 0)
+if (bdrv_open(bs, argv[optind], flags) < 0) {
 return 1;
+}
 
 fd_size = bs->total_sectors * 512;
 
 if (partition != -1 &&
-find_partition(bs, partition, &dev_offset, &fd_size))
+find_partition(bs, partition, &dev_offset, &fd_size)) {
 errx(EXIT_FAILURE, "Could not find partition %d", partition);
+}
 
 if (device) {
 pid_t pid;
@@ -360,8 +372,9 @@ int main(int argc, char **argv)
 }
 
 pid = fork();
-if (pid < 0)
+if (pid < 0) {
 return 1;
+}
 if (pid != 0) {
 off_t size;
 size_t blocksize;
@@ -372,8 +385,9 @@ int main(int argc, char **argv)
 do {
 sock = unix_socket_outgoing(socket);
 if (sock == -1) {
-if (errno != ENOENT && errno != ECONNREFUSED)
+if (errno != ENOENT && errno != ECONNREFUSED) {
 goto out;
+}
 sleep(1);  /* wait children */
 }
 } while (sock == -1);
@@ -422,14 +436,16 @@ int main(int argc, char **argv)
 sharing_fds[0] = tcp_socket_incoming(bindto, port);
 }
 
-if (sharing_fds[0] == -1)
+if (sharing_fds[0] == -1) {
 return 1;
+}
 max_fd = sharing_fds[0];
 nb_fds++;
 
 data = qemu_memalign(512, NBD_BUFFER_SIZE);
-if (data == NULL)
+if (data == NULL) {
 errx(EXIT_FAILURE, "Cannot allocate data buffer");
+}
 
 do {
 
@@ -438,11 +454,13 @@ int main(int argc, char **argv)
 FD_SET(sharing_fds[i], &fds);
 
 ret = select(max_fd + 1, &fds, NULL, NULL, NULL);
-

[Qemu-devel] Re: Significant performance regression in qemu-system-mips.

2010-03-28 Thread Paolo Bonzini

On 03/24/2010 09:34 PM, Rob Landley wrote:

Unfortunately, I can't revert that patch in current origin/master because most
of the hunks fail...


Try this, or try disabling dynticks as a stopgap measure:

http://permalink.gmane.org/gmane.comp.emulators.qemu/65821

Paolo




[Qemu-devel] [PATCH] Compile qemu-timer only once

2010-03-28 Thread Blue Swirl
Arrange various declarations so that also non-CPU code can access
them, adjust users.

Move CPU specific code to cpus.c.

Signed-off-by: Blue Swirl 
---
The patch also available in my rebased tree:
git://repo.or.cz/qemu/blueswirl.git
http://repo.or.cz/r/qemu/blueswirl.git

 Makefile.objs  |1 +
 Makefile.target|1 -
 cpu-all.h  |  147 -
 cpus.c |   16 +
 exec-all.h |   14 
 exec.c |1 +
 gen-icount.h   |2 +
 linux-user/main.c  |2 +-
 qemu-common.h  |8 +-
 qemu-timer.c   |   20 +--
 qemu-timer.h   |  167 
 softmmu_template.h |2 +
 translate-all.c|1 +
 13 files changed, 197 insertions(+), 185 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index c02f9d5..7ac8920 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -105,6 +105,7 @@ common-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_IOTHREAD) += qemu-thread.o
 common-obj-y += notify.o
+common-obj-y += qemu-timer.o

 slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
 slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
diff --git a/Makefile.target b/Makefile.target
index 5ed20ec..a90add6 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -162,7 +162,6 @@ endif #CONFIG_BSD_USER
 ifdef CONFIG_SOFTMMU

 obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o
-obj-y += qemu-timer.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial-bus.o
diff --git a/cpu-all.h b/cpu-all.h
index 9942d49..927445c 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -771,10 +771,6 @@ void QEMU_NORETURN cpu_abort(CPUState *env, const
char *fmt, ...)
 extern CPUState *first_cpu;
 extern CPUState *cpu_single_env;

-int64_t qemu_icount_round(int64_t count);
-extern int64_t qemu_icount;
-extern int use_icount;
-
 #define CPU_INTERRUPT_HARD   0x02 /* hardware interrupt pending */
 #define CPU_INTERRUPT_EXITTB 0x04 /* exit the current TB (use for x86
a20 case) */
 #define CPU_INTERRUPT_TIMER  0x08 /* internal timer exception pending */
@@ -921,149 +917,6 @@ void dump_exec_info(FILE *f,
 int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
 uint8_t *buf, int len, int is_write);

-/***/
-/* host CPU ticks (if available) */
-
-#if defined(_ARCH_PPC)
-
-static inline int64_t cpu_get_real_ticks(void)
-{
-int64_t retval;
-#ifdef _ARCH_PPC64
-/* This reads timebase in one 64bit go and includes Cell workaround from:
-   http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html
- */
-__asm__ __volatile__ (
-"mftb%0\n\t"
-"cmpwi   %0,0\n\t"
-"beq-$-8"
-: "=r" (retval));
-#else
-/* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */
-unsigned long junk;
-__asm__ __volatile__ (
-"mftbu   %1\n\t"
-"mftb%L0\n\t"
-"mftbu   %0\n\t"
-"cmpw%0,%1\n\t"
-"bne $-16"
-: "=r" (retval), "=r" (junk));
-#endif
-return retval;
-}
-
-#elif defined(__i386__)
-
-static inline int64_t cpu_get_real_ticks(void)
-{
-int64_t val;
-asm volatile ("rdtsc" : "=A" (val));
-return val;
-}
-
-#elif defined(__x86_64__)
-
-static inline int64_t cpu_get_real_ticks(void)
-{
-uint32_t low,high;
-int64_t val;
-asm volatile("rdtsc" : "=a" (low), "=d" (high));
-val = high;
-val <<= 32;
-val |= low;
-return val;
-}
-
-#elif defined(__hppa__)
-
-static inline int64_t cpu_get_real_ticks(void)
-{
-int val;
-asm volatile ("mfctl %%cr16, %0" : "=r"(val));
-return val;
-}
-
-#elif defined(__ia64)
-
-static inline int64_t cpu_get_real_ticks(void)
-{
-   int64_t val;
-   asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory");
-   return val;
-}
-
-#elif defined(__s390__)
-
-static inline int64_t cpu_get_real_ticks(void)
-{
-int64_t val;
-asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc");
-return val;
-}
-
-#elif defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) ||
defined(__sparc_v9__)
-
-static inline int64_t cpu_get_real_ticks (void)
-{
-#if defined(_LP64)
-uint64_trval;
-asm volatile("rd %%tick,%0" : "=r"(rval));
-return rval;
-#else
-union {
-uint64_t i64;
-struct {
-uint32_t high;
-uint32_t low;
-}   i32;
-} rval;
-asm volatile("rd %%tick,%1; srlx %1,32,%0"
-: "=r"(rval.i32.high), "=r"(rval.i32.low));
-return rval.i64;
-#endif
-}
-
-#elif defined(__mips__) && \
-  ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux_

Re: [Qemu-devel] Re: [PATCH 10/15] virtio-serial: Add QMP events for failed port/device add

2010-03-28 Thread Jamie Lokier
Amit Shah wrote:
> > Without this specific thing, which is an indicator that guest has lost
> > state outside its control, the guest<->host communication is
> > unreliable (even for things like "cut and paste"), so every app that
> > cares has to implement a packet framing protocol with no binary data
> > (to reserve an escaping byte), or with CRCs like
> > PPP-over-virtio-serial, which is complicated and silly imho.  If it
> > were a real serial port, not emulated, that's the sort of thing apps
> > would actually do (or use timeouts, which are more dubious in
> > emulator-land).  But I hope we're not that sadistic :-)
> 
> I agree. So: ports have in-qemu users, they get guest_open /
> guest_close callbacks and get data which they can pass on to external
> apps. Looks like we're fine there?

Provided the guest_open / guest_close callbacks are synchronous with
the data - so that data sent/received following guest_open exactly
matches what the guest sends/receives from its beginning, that
internal interface looks fine to me.

We can tidy up the chardev later as needed :-)

-- Jamie

> > *Inband* open/close indication aren't 100% guarantees of reliability,
> > but I think they raise it to the point where an app can usefully count
> > on it.




[Qemu-devel] Re: [PATCH v2] qemu-io: fix aio help texts

2010-03-28 Thread Aurelien Jarno
On Sun, Mar 28, 2010 at 12:19:31PM +0200, Christoph Hellwig wrote:
> Fix a few typos in the help texts for the various aio commands.
> 
> Signed-off-by: Christoph Hellwig 

Thanks, applied.

> Index: qemu/qemu-io.c
> ===
> --- qemu.orig/qemu-io.c   2010-03-16 19:07:43.089009269 +0100
> +++ qemu/qemu-io.c2010-03-16 19:08:36.597005148 +0100
> @@ -904,8 +904,8 @@ aio_read_help(void)
>  "\n"
>  " Reads a segment of the currently open file, optionally dumping it to the\n"
>  " standard output stream (with -v option) for subsequent inspection.\n"
> -" The read is performed asynchronously and should the aio_flush command \n"
> -" should be used to ensure all outstanding aio requests have been 
> completed\n"
> +" The read is performed asynchronously and the aio_flush command must be\n"
> +" to ensure all outstanding aio requests have been completed\n"
>  " -C, -- report statistics in a machine parsable format\n"
>  " -P, -- use a pattern to verify read data\n"
>  " -v, -- dump buffer to standard output\n"
> @@ -1003,8 +1003,8 @@ aio_write_help(void)
>  "\n"
>  " Writes into a segment of the currently open file, using a buffer\n"
>  " filled with a set pattern (0xcdcdcdcd).\n"
> -" The write is performed asynchronously and should the aio_flush command \n"
> -" should be used to ensure all outstanding aio requests have been 
> completed\n"
> +" The write is performed asynchronously and the aio_flush command must be\n"
> +" used to ensure all outstanding aio requests have been completed\n"
>  " -P, -- use different pattern to fill file\n"
>  " -C, -- report statistics in a machine parsable format\n"
>  " -q, -- quite mode, do not show I/O statistics\n"
> @@ -1095,7 +1095,7 @@ aio_flush_f(int argc, char **argv)
>  static const cmdinfo_t aio_flush_cmd = {
>   .name   = "aio_flush",
>   .cfunc  = aio_flush_f,
> - .oneline= "completes all outstanding aio requets"
> + .oneline= "completes all outstanding aio requests"
>  };
>  
>  static int
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net




[Qemu-devel] Re: [PATCH] tcg/arm: Replace qemu_ld32u (left over from previous commit)

2010-03-28 Thread Aurelien Jarno
On Sun, Mar 28, 2010 at 11:44:29AM +0200, Stefan Weil wrote:
> Commit 86feb1c860dc38e9c89e787c5210e8191800385e
> did not change all occurrences of INDEX_op_qemu_ld32u
> for tcg/arm.
> 
> Please note that I could not test this patch
> (I have currently no arm system available).
> 
> Cc: Richard Henderson 
> Cc: Aurelien Jarno 
> Signed-off-by: Stefan Weil 

Good catch, applied.

> ---
>  tcg/arm/tcg-target.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
> index abd2187..f0f669d 100644
> --- a/tcg/arm/tcg-target.c
> +++ b/tcg/arm/tcg-target.c
> @@ -1585,7 +1585,7 @@ static const TCGTargetOpDef arm_op_defs[] = {
>  { INDEX_op_qemu_ld8s, { "r", "x" } },
>  { INDEX_op_qemu_ld16u, { "r", "x" } },
>  { INDEX_op_qemu_ld16s, { "r", "x" } },
> -{ INDEX_op_qemu_ld32u, { "r", "x" } },
> +{ INDEX_op_qemu_ld32, { "r", "x" } },
>  { INDEX_op_qemu_ld64, { "d", "r", "x" } },
>  
>  { INDEX_op_qemu_st8, { "x", "x" } },
> -- 
> 1.7.0
> 
> 

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net




Re: [Qemu-devel] Significant performance regression in qemu-system-mips.

2010-03-28 Thread Aurelien Jarno
On Sat, Mar 27, 2010 at 06:01:39PM -0500, Rob Landley wrote:
> On Saturday 27 March 2010 07:32:41 Aurelien Jarno wrote:
> > On Fri, Mar 26, 2010 at 04:47:51PM -0500, Rob Landley wrote:
> > > On Friday 26 March 2010 14:00:00 Aurelien Jarno wrote:
> > > > I am pretty fine applying a correct patch if you send a new one.
> > >
> > > By which you mean rip out the whole #ifdef block?
> >
> > Yes.
> >
> > > Here you go:
> >
> > This looks much better. Can you please resend it with the changes below
> > and a Signed-off-by: ?
> 
> If you want the code actually cleaned up instead of minimally changed,
> here's a stab at that.  (Unfortunately I haven't got a ppc64 setup to test it
> with yet, but ppc32 still works.)

Not necessarily a code cleanup, but at least a patch which doesn't
introduce useless changes. Anyway applied.

> Signed-off-by: Rob Landley 
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 682a813..3c3ef21 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -517,31 +517,12 @@ do {
> \
>  
>  static inline void init_thread(struct target_pt_regs *_regs, struct 
> image_info *infop)
>  {
> -abi_ulong pos = infop->start_stack;
> -abi_ulong tmp;
> -#if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
> -abi_ulong entry, toc;
> -#endif
> -
>  _regs->gpr[1] = infop->start_stack;
>  #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
> -entry = ldq_raw(infop->entry) + infop->load_addr;
> -toc = ldq_raw(infop->entry + 8) + infop->load_addr;
> -_regs->gpr[2] = toc;
> -infop->entry = entry;
> +_regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_addr;
> +infop->entry = ldq_raw(infop->entry) + infop->load_addr;
>  #endif
>  _regs->nip = infop->entry;
> -/* Note that isn't exactly what regular kernel does
> - * but this is what the ABI wants and is needed to allow
> - * execution of PPC BSD programs.
> - */
> -/* FIXME - what to for failure of get_user()? */
> -get_user_ual(_regs->gpr[3], pos);
> -pos += sizeof(abi_ulong);
> -_regs->gpr[4] = pos;
> -for (tmp = 1; tmp != 0; pos += sizeof(abi_ulong))
> -tmp = ldl(pos);
> -_regs->gpr[5] = pos;
>  }
>  
>  #define ELF_EXEC_PAGESIZE4096
> 
> > > Ok, I agree I was a bit harsh.  (He's the one who introduced his employer
> > > into the discussion, but I suspect I read more into that than he meant by
> > > it.)
> >
> > I think you misunderstood him. You were talking about Super-Hitachi
> > which is a train [1] from Hitachi (not his employer), while he was talking
> > about Super-H which is a CPU [2] from Renesas (his employer).
> 
> So essentially he's insisting he works for Freescale, not Motorola, because
> Motorola stopped being interested in the m68k and divested itself of its
> processor manufacturing operations.  And I'm confusing his product with
> something _else_ Motorola used to do.

He is insisted on the fact the name of the CPU is Super-H and not
Super-Hitachi.

> Only transliterated to Japan.
> 
> *shrug*  The "SuperH" chipset was developed by Hitachi.  I thought the H stood
> for "Hitachi".  I hadn't actually noticed that Hitachi had divested itself of
> its chip design operations, and was trying to avoid referring to it as "sh4"
> because that's an architecture generation, not a chip family.  (There used to
> be sh3 and similar, and I thought there might be an sh5 someday but now that
> I've looked into it I can understand why they don't seem too worried about
> that happening.)
> 
> My project is trying to get all the architectures Linux and QEMU support to
> behave the same way.  Thus I'm no more an sh4 expert than I am a ppc expert, I
> just poke at it and look stuff up when it doesn't work (which is frequently).
> 
> Speaking of which, qemu-system-ppc in 0.12.3 segfaults accessing /dev/hdc, and
> the one in current -git has the missed IRQ issue when accessing /dev/hda.  Is
> there any chance of 0.12.4 in the near future?  (I hate to point people
> interested in PPC at a random non-current git snapshot.)

It is something fixed in the stable-0.12. Someone has to roll out 0.12.4.

> > He has the right to not care about trains ;-)
> 
> It was more the "I can build it, I don't care if you still can" issue, when
> the commit in question was a primarily cosmetic change to code that was only
> theoretically broken.  (Not only did it work for me, but it was so broken
> nobody actually noticed the issue in question for years.)
> 
> I got the impression that the reason he didn't care about my use case was
> because I was not a customer of his company.  That he was acting on behalf
> of his employer, not in an impartial purely technical capacity.  I have
> no commercial interest in sh4, and never did, so I stopped bothering him.
> 
> Rob
> -- 
> Latency is more important than throughput. It's that simple. - Linus Torvalds
> 

-- 
Aurelien Jarno  

Re: [Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread malc
On Sun, 28 Mar 2010, Jamie Lokier wrote:

> Avi Kivity wrote:
> > ioctls encode the buffer size into the ioctl number, so in theory strace 
> > doesn't need to be taught about an ioctl to show its buffer.
> 
> Unfortunately ioctl numbers don't always follow that rule :-(

It's not a rule to begin with, since there's no way to enforce it.

> But maybe that's just awful proprietary drivers that I've seen.
> 
> Anyway, strace should be taught how to read kernel headers to get
> ioctl types ;-)
> 
> -- Jamie
> 
> 

-- 
mailto:av1...@comtv.ru




Re: [Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Jamie Lokier
Avi Kivity wrote:
> ioctls encode the buffer size into the ioctl number, so in theory strace 
> doesn't need to be taught about an ioctl to show its buffer.

Unfortunately ioctl numbers don't always follow that rule :-(
But maybe that's just awful proprietary drivers that I've seen.

Anyway, strace should be taught how to read kernel headers to get
ioctl types ;-)

-- Jamie




Re: [Qemu-devel] [RFC][PATCH 7/7] qcow2: Trigger blkdebug events

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:35PM +0100, Kevin Wolf wrote:
> This adds blkdebug events to qcow2 to allow injecting I/O errors in specific
> places.

Looks good,


Reviewed-by: Christoph Hellwig 





Re: [Qemu-devel] [RFC][PATCH 6/7] blkdebug: Add events and rules

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:34PM +0100, Kevin Wolf wrote:
> +fprintf(stderr, "bdrv_debug_event: %d\n", event);

Is this supposed to be in the final version or a leftover debugging aid?

> +#define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt)

Why not call bdrv_debug_event directly?

> +config = strdup(filename);
> +config[c - filename] = '\0';
> +ret = read_config(s, config);
> +if (ret < 0) {
> +return ret;
> +}
> +filename = c + 1;
> +
> +/* Open the backing file */
> +ret = bdrv_file_open(&s->hd, filename, flags);
> +if (ret < 0) {
> +return ret;
> +}
> +
> +return 0;

Don't we need to free config somewhere?





Re: [Qemu-devel] [PATCH 3/3] qemu-nbd: Improve error reporting

2010-03-28 Thread Ryota Ozaki
On Sat, Mar 27, 2010 at 10:02 PM, Aurelien Jarno  wrote:
> On Sat, Mar 20, 2010 at 03:23:24PM +0900, Ryota Ozaki wrote:
>> - use err(3) instead of errx(3) if errno is available
>>   to report why failed
>> - let fail prior to daemon(3) if opening a nbd file
>>   is likely to fail after daemonizing to avoid silent
>>   failure exit
>>
>> Signed-off-by: Ryota Ozaki 
>> ---
>>  qemu-nbd.c |   16 +++-
>>  1 files changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/qemu-nbd.c b/qemu-nbd.c
>> index 6d854d3..8fb8cc3 100644
>> --- a/qemu-nbd.c
>> +++ b/qemu-nbd.c
>> @@ -316,7 +316,7 @@ int main(int argc, char **argv)
>>      if (disconnect) {
>>          fd = open(argv[optind], O_RDWR);
>>          if (fd == -1)
>> -            errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
>> +            err(EXIT_FAILURE, "Cannot open %s", argv[optind]);
>>
>>          nbd_disconnect(fd);
>>
>> @@ -333,23 +333,29 @@ int main(int argc, char **argv)
>>      if (bs == NULL)
>>          return 1;
>>
>> -    if (bdrv_open(bs, argv[optind], flags) < 0)
>> -        return 1;
>> +    if ((ret = bdrv_open(bs, argv[optind], flags)) < 0) {
>> +        errno = -ret;
>> +        err(EXIT_FAILURE, "Failed to bdrv_open '%s'", argv[optind]);
>> +    }
>>
>>      fd_size = bs->total_sectors * 512;
>>
>>      if (partition != -1 &&
>>          find_partition(bs, partition, &dev_offset, &fd_size))
>> -        errx(EXIT_FAILURE, "Could not find partition %d", partition);
>> +        err(EXIT_FAILURE, "Could not find partition %d", partition);
>>
>>      if (device) {
>>          pid_t pid;
>>          int sock;
>>
>> +        /* want to fail before daemonizing */
>> +        if (access(device, R_OK|W_OK) == -1)
>> +            err(EXIT_FAILURE, "Could not access '%s'", device);
>> +
>
> First of all you need to put this line between curly braces. Secondly,

Oh, sorry.

> qemu-nbd as a read-only option to export a block device as read-only.
> The test has to be improved to also take care of that.

I guess the option is intended to be only for disk image, because
open(2) for nbd device file doesn't care about the option.

Nonetheless, extending the option to operations to nbd device file
makes sense, because the option allows to open nbd device
file without write permission.

So I'll correct it as well as fixing the problems you pointed out.

Thanks,
  ozaki-r

>
>>          if (!verbose) {
>>              /* detach client and server */
>>              if (daemon(0, 0) == -1) {
>> -                errx(EXIT_FAILURE, "Failed to daemonize");
>> +                err(EXIT_FAILURE, "Failed to daemonize");
>>              }
>>          }
>>
>> --
>> 1.6.5.2
>>
>>
>>
>>
>
> --
> Aurelien Jarno                          GPG: 1024D/F1BCDB73
> aurel...@aurel32.net                 http://www.aurel32.net
>




Re: [Qemu-devel] [RFC][PATCH 5/7] Make qemu-config available for tools

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:33PM +0100, Kevin Wolf wrote:
> available in the tools. This involves moving two functions that can only be
> built in the context of the emulator.
> 
> Signed-off-by: Kevin Wolf 

Looks good,


Reviewed-by: Christoph Hellwig 




Re: [Qemu-devel] [RFC][PATCH 4/7] blkdebug: Inject errors

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:32PM +0100, Kevin Wolf wrote:
> Add a mechanism to inject errors instead of passing requests on. With no
> further patches applied, you can use it by setting inject_errno in gdb.
> 
> Signed-off-by: Kevin Wolf 

The magic iocb is quite a hack, but it should work good enough for now.


Reviewed-by: Christoph Hellwig 




Re: [Qemu-devel] [RFC][PATCH 3/7] blkdebug: Basic request passthrough

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:31PM +0100, Kevin Wolf wrote:
> This isn't doing anything interesting. It creates the blkdebug block driver as
> a protocol which just passes everything through to raw.
> 
> Signed-off-by: Kevin Wolf 
> ---
>  Makefile.objs|2 +-
>  block/blkdebug.c |  104 
> ++

Not a big fan of the blkdebug: prefix, but that's how qemu works
elsewhere, too.  Also it's not passing through any of the ioctl
magic, but that's probably not needed for now.


Reviewed-by: Christoph Hellwig 




Re: [Qemu-devel] [RFC][PATCH 2/7] qemu-config: Make qemu_config_parse more generic

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:30PM +0100, Kevin Wolf wrote:
> qemu_config_parse gets the option groups as a parameter now instead of
> hardcoding the VM configuration groups. This way it can be used for other
> configurations, too.
> 
> Signed-off-by: Kevin Wolf 

Looks good,


Reviewed-by: Christoph Hellwig 





Re: [Qemu-devel] [RFC][PATCH 1/7] qemu-config: qemu_read_config_file() reads the normal config file

2010-03-28 Thread Christoph Hellwig
On Mon, Mar 15, 2010 at 06:08:29PM +0100, Kevin Wolf wrote:
> Introduce a new function qemu_read_config_file which reads the VM 
> configuration
> from a config file. Unlike qemu_config_parse it doesn't take a open file but a
> filename and reduces code duplication as a side effect.
> 
> Signed-off-by: Kevin Wolf 

Looks good,


Reviewed-by: Christoph Hellwig 





[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Avi Kivity

On 03/28/2010 01:31 PM, Michael S. Tsirkin wrote:



Aren't ioctls a lot simpler?

Multiplexing multiple functions on write()s is just ioctls done uglier.
 

I don't have an opinion here.

Writes do have an advantage that strace can show the buffer
content without being patched.
   


ioctls encode the buffer size into the ioctl number, so in theory strace 
doesn't need to be taught about an ioctl to show its buffer.



Further, something along the lines proposed above means that
we do not need to depend in a system header to get
the functionality.
   


Yes, point users at the code and let them figure out how to do stuff.

--
error compiling committee.c: too many arguments to function





Re: [Qemu-devel] [PATCH] qemu-img: add FUSE-based image access

2010-03-28 Thread Christoph Hellwig
On Thu, Mar 25, 2010 at 06:52:59PM +0100, Jan Kiszka wrote:
> This adds the "map" subcommand to qemu-img. It is able to expose the raw
> content of a disk image via a FUSE filesystem. Both the whole disk can
> be accessed, e.g. to run partitioning tools against it, as well as
> individual partitions. This allows to create new filesystems in the
> image or loop-back mount exiting ones. Using the great mountlo tool
> from the FUSE collection [1][2], the latter can even be done by non-root
> users (the former anyway).

Is there a good reason to throw this into qemu-img instead of making
a separate qemu-fuse or similar tool?  It's doing something quite
different than the rest of qemu-img.





[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Michael S. Tsirkin
On Sun, Mar 28, 2010 at 12:45:02PM +0300, Avi Kivity wrote:
> On 03/28/2010 12:40 PM, Michael S. Tsirkin wrote:
 uio accepts 32 bit writes to the char device file. We can encode
 the fd number there, and use the high bit to signal assign/deassign.


>>> Ugh.  Very unexpandable.
>>>  
>> It currently fails on any non-4 byte write.
>> So if we need more bits in the future we can always teach it
>> about e.g. 8 byte writes.
>>
>> Do you think it's worth it doing it now already, and using
>> 8 byte writes for msi mapping?
>>
>
> Aren't ioctls a lot simpler?
>
> Multiplexing multiple functions on write()s is just ioctls done uglier.

I don't have an opinion here.

Writes do have an advantage that strace can show the buffer
content without being patched.

Further, something along the lines proposed above means that
we do not need to depend in a system header to get
the functionality.

> -- 
> error compiling committee.c: too many arguments to function




[Qemu-devel] [PATCH v2] qemu-io: fix aio help texts

2010-03-28 Thread Christoph Hellwig
Fix a few typos in the help texts for the various aio commands.

Signed-off-by: Christoph Hellwig 

Index: qemu/qemu-io.c
===
--- qemu.orig/qemu-io.c 2010-03-16 19:07:43.089009269 +0100
+++ qemu/qemu-io.c  2010-03-16 19:08:36.597005148 +0100
@@ -904,8 +904,8 @@ aio_read_help(void)
 "\n"
 " Reads a segment of the currently open file, optionally dumping it to the\n"
 " standard output stream (with -v option) for subsequent inspection.\n"
-" The read is performed asynchronously and should the aio_flush command \n"
-" should be used to ensure all outstanding aio requests have been completed\n"
+" The read is performed asynchronously and the aio_flush command must be\n"
+" to ensure all outstanding aio requests have been completed\n"
 " -C, -- report statistics in a machine parsable format\n"
 " -P, -- use a pattern to verify read data\n"
 " -v, -- dump buffer to standard output\n"
@@ -1003,8 +1003,8 @@ aio_write_help(void)
 "\n"
 " Writes into a segment of the currently open file, using a buffer\n"
 " filled with a set pattern (0xcdcdcdcd).\n"
-" The write is performed asynchronously and should the aio_flush command \n"
-" should be used to ensure all outstanding aio requests have been completed\n"
+" The write is performed asynchronously and the aio_flush command must be\n"
+" used to ensure all outstanding aio requests have been completed\n"
 " -P, -- use different pattern to fill file\n"
 " -C, -- report statistics in a machine parsable format\n"
 " -q, -- quite mode, do not show I/O statistics\n"
@@ -1095,7 +1095,7 @@ aio_flush_f(int argc, char **argv)
 static const cmdinfo_t aio_flush_cmd = {
.name   = "aio_flush",
.cfunc  = aio_flush_f,
-   .oneline= "completes all outstanding aio requets"
+   .oneline= "completes all outstanding aio requests"
 };
 
 static int




[Qemu-devel] [PATCH] Documentation: Update chapter on installation

2010-03-28 Thread Stefan Weil
* Replace broken links by link to QEMU wiki.

* Separate sections for Linux / Windows / Mac OS X
  are no longer needed: the wiki link will provide
  additional links, so we don't need them here.

* Add hint for (Open) Solaris.

Signed-off-by: Stefan Weil 
---
 qemu-doc.texi   |   38 +++---
 qemu-options.hx |8 
 2 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index 34182ae..b3a3a9a 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -122,33 +122,17 @@ Alpha, ColdFire(m68k), CRISv32 and MicroBlaze CPUs are 
supported.
 
 If you want to compile QEMU yourself, see @ref{compilation}.
 
-...@menu
-* install_linux::   Linux
-* install_windows:: Windows
-* install_mac:: Macintosh
-...@end menu
+Precompiled packages are available for most Linux distributions,
+so you just have to install it.
 
-...@node install_linux
-...@section Linux
-...@cindex installation (Linux)
+For other operating systems (Max OS X, Open Solaris, Windows),
+binaries are provided by user groups or individuals.
 
-If a precompiled package is available for your distribution - you just
-have to install it. Otherwise, see @ref{compilation}.
-
-...@node install_windows
-...@section Windows
-...@cindex installation (Windows)
-
-Download the experimental binary installer at
-...@url{http://www.free.oszoo.org/@/download.html}.
-TODO (no longer available)
-
-...@node install_mac
-...@section Mac OS X
+See @url{http://wiki.qemu.org/Download} for links to binary distributions
+and some @ref{disk images} for testing.
 
-Download the experimental binary installer at
-...@url{http://www.free.oszoo.org/@/download.html}.
-TODO (no longer available)
+QEMU @ref{disk images} for several guest operating systems are also available
+from the FreeOsZoo project (@url{http://www.oszoo.org/}).
 
 @node QEMU PC System emulator
 @chapter QEMU PC System emulator
@@ -160,7 +144,7 @@ TODO (no longer available)
 * sec_invocation:: Invocation
 * pcsys_keys:: Keys
 * pcsys_monitor::  QEMU Monitor
-* disk_images::Disk Images
+* disk images::Disk Images
 * pcsys_network::  Network emulation
 * direct_linux_boot::  Direct Linux Boot
 * pcsys_usb::  USB emulation
@@ -386,7 +370,7 @@ The monitor understands integers expressions for every 
integer
 argument. You can use register names to get the value of specifics
 CPU registers by prefixing them with @emph{$}.
 
-...@node disk_images
+...@node disk images
 @section Disk Images
 
 Since version 0.6.1, QEMU supports many disk image formats, including
@@ -763,7 +747,7 @@ Pointer device that uses absolute coordinates (like a 
touchscreen).
 This means qemu is able to report the mouse position without having
 to grab the mouse.  Also overrides the PS/2 mouse emulation when activated.
 @item disk:@var{file}
-Mass storage device based on @var{file} (@pxref{disk_images})
+Mass storage device based on @var{file} (@pxref{disk images})
 @item host:@var{bus.addr}
 Pass through the host device identified by @var{bus.addr}
 (Linux only)
diff --git a/qemu-options.hx b/qemu-options.hx
index e2a5ca6..3cfadd9 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -80,7 +80,7 @@ STEXI
 @item -fdb @var{file}
 @findex -fda
 @findex -fdb
-Use @var{file} as floppy disk 0/1 image (@pxref{disk_images}). You can
+Use @var{file} as floppy disk 0/1 image (@pxref{disk images}). You can
 use the host floppy by using @file{/dev/fd0} as filename (@pxref{host_drives}).
 ETEXI
 
@@ -99,7 +99,7 @@ STEXI
 @findex -hdb
 @findex -hdc
 @findex -hdd
-Use @var{file} as hard disk 0, 1, 2 or 3 image (@pxref{disk_images}).
+Use @var{file} as hard disk 0, 1, 2 or 3 image (@pxref{disk images}).
 ETEXI
 
 DEF("cdrom", HAS_ARG, QEMU_OPTION_cdrom,
@@ -126,7 +126,7 @@ Define a new drive. Valid options are:
 
 @table @option
 @item fi...@var{file}
-This option defines which disk image (@pxref{disk_images}) to use with
+This option defines which disk image (@pxref{disk images}) to use with
 this drive. If the filename contains comma, you must double it
 (for instance, "file=my,,file" to use file "my,file").
 @item i...@var{interface}
@@ -300,7 +300,7 @@ STEXI
 @findex -snapshot
 Write to temporary files instead of disk image files. In this case,
 the raw disk image you use is not written back. You can however force
-the write back by pressing @key{C-a s} (@pxref{disk_images}).
+the write back by pressing @key{C-a s} (@pxref{disk images}).
 ETEXI
 
 DEF("m", HAS_ARG, QEMU_OPTION_m,
-- 
1.7.0





[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Avi Kivity

On 03/28/2010 12:40 PM, Michael S. Tsirkin wrote:

uio accepts 32 bit writes to the char device file. We can encode
the fd number there, and use the high bit to signal assign/deassign.

   

Ugh.  Very unexpandable.
 

It currently fails on any non-4 byte write.
So if we need more bits in the future we can always teach it
about e.g. 8 byte writes.

Do you think it's worth it doing it now already, and using
8 byte writes for msi mapping?
   


Aren't ioctls a lot simpler?

Multiplexing multiple functions on write()s is just ioctls done uglier.

--
error compiling committee.c: too many arguments to function





[Qemu-devel] [PATCH] tcg/arm: Replace qemu_ld32u (left over from previous commit)

2010-03-28 Thread Stefan Weil
Commit 86feb1c860dc38e9c89e787c5210e8191800385e
did not change all occurrences of INDEX_op_qemu_ld32u
for tcg/arm.

Please note that I could not test this patch
(I have currently no arm system available).

Cc: Richard Henderson 
Cc: Aurelien Jarno 
Signed-off-by: Stefan Weil 
---
 tcg/arm/tcg-target.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
index abd2187..f0f669d 100644
--- a/tcg/arm/tcg-target.c
+++ b/tcg/arm/tcg-target.c
@@ -1585,7 +1585,7 @@ static const TCGTargetOpDef arm_op_defs[] = {
 { INDEX_op_qemu_ld8s, { "r", "x" } },
 { INDEX_op_qemu_ld16u, { "r", "x" } },
 { INDEX_op_qemu_ld16s, { "r", "x" } },
-{ INDEX_op_qemu_ld32u, { "r", "x" } },
+{ INDEX_op_qemu_ld32, { "r", "x" } },
 { INDEX_op_qemu_ld64, { "d", "r", "x" } },
 
 { INDEX_op_qemu_st8, { "x", "x" } },
-- 
1.7.0





[Qemu-devel] [PATCH] Fix compilation with missing inotify_init1

2010-03-28 Thread Stefan Weil
Commit c05c7a7306a23a4b01d1606172b142c45caffc92
breaks cross compilation for mips (and other
compilations without CONFIG_INOTIFY1):

make[1]: Entering directory `/qemu/bin/mips'
  CCi386-linux-user/syscall.o
cc1: warnings being treated as errors
/qemu/linux-user/syscall.c: In function ‘do_syscall’:
/qemu/linux-user/syscall.c:7067: error: implicit declaration of function 
‘sys_inotify_init1’

Cc: Riku Voipio 
Cc: Aurelien Jarno 
Signed-off-by: Stefan Weil 
---
 linux-user/syscall.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 29c9c09..aa3cbb8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7062,11 +7062,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 ret = get_errno(sys_inotify_init());
 break;
 #endif
+#ifdef CONFIG_INOTIFY1
 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)
 case TARGET_NR_inotify_init1:
 ret = get_errno(sys_inotify_init1(arg1));
 break;
 #endif
+#endif
 #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
 case TARGET_NR_inotify_add_watch:
 p = lock_user_string(arg2);
-- 
1.7.0





[Qemu-devel] [PATCH] Fix cross compilation

2010-03-28 Thread Stefan Weil
This patch enhances the algorithm which finds the correct settings for SDL.
For cross compilations (when cross_prefix is set), it looks for sdl-config
with cross prefix. Here is the complete search order:

${cross_prefix}sdl_config  (new, only used for cross compilation)
$(cross_prefix}pkg-config  (old)
pkg-config (old, needs PATH)
sdl-config (old, needs PATH)

Cross SDL packages (or the user) now can simply set a link (for example
/usr/bin/i586-mingw32msvc-sdl-config -> /usr/i586-mingw32msvc/bin/sdl-config)
which allows cross compilations without PATH modifications.

Without the patch, configure and make (which calls configure) typically
need a non-standard PATH. Failing to set this special PATH results in
broken builds.

Signed-off-by: Stefan Weil 
---
 configure |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 664c920..eb2d759 100755
--- a/configure
+++ b/configure
@@ -1047,7 +1047,10 @@ fi
 ##
 # SDL probe
 
-if $pkgconfig sdl --modversion >/dev/null 2>&1; then
+if test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
+  sdlconfig="${cross_prefix}sdl-config"
+  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
+elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
   sdlconfig="$pkgconfig sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
 elif has sdl-config; then
-- 
1.7.0





[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Michael S. Tsirkin
On Sun, Mar 28, 2010 at 11:02:11AM +0300, Avi Kivity wrote:
> On 03/28/2010 10:47 AM, Michael S. Tsirkin wrote:
>>>
 Maybe irqcontrol could be extended?


>>> What's irqcontrol?
>>>  
>> uio accepts 32 bit writes to the char device file. We can encode
>> the fd number there, and use the high bit to signal assign/deassign.
>>
>
> Ugh.  Very unexpandable.

It currently fails on any non-4 byte write.
So if we need more bits in the future we can always teach it
about e.g. 8 byte writes.

Do you think it's worth it doing it now already, and using
8 byte writes for msi mapping?


> -- 
> error compiling committee.c: too many arguments to function




[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Avi Kivity

On 03/28/2010 10:47 AM, Michael S. Tsirkin wrote:



Maybe irqcontrol could be extended?

   

What's irqcontrol?
 

uio accepts 32 bit writes to the char device file. We can encode
the fd number there, and use the high bit to signal assign/deassign.
   


Ugh.  Very unexpandable.

--
error compiling committee.c: too many arguments to function





[Qemu-devel] [PATCH] Fix conditional compilation case CONFIG_INOTIFY && !CONFIG_INOTIFY1.

2010-03-28 Thread takasi-y
There is undefined reference to sys_inotify_init1() at do_syscall() when
CONFIG_INOTIFY=y and CONFIG_INOTIFY1=n.

We should undef TARGET_NR_inotify_init1 if CONFIG_INOTIFY1 is undefined, as
it seems to be the strategy of conditional compilation here.

Signed-off-by: Takashi YOSHII 
---
 linux-user/syscall.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9ea990d..5050e60 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -506,22 +506,24 @@ static int sys_inotify_rm_watch(int fd, int32_t wd)
   return (inotify_rm_watch(fd, wd));
 }
 #endif
-#ifdef CONFIG_INOTIFY1
-#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)
-static int sys_inotify_init1(int flags)
-{
-  return (inotify_init1(flags));
-}
-#endif
-#endif
 #else
 /* Userspace can usually survive runtime without inotify */
 #undef TARGET_NR_inotify_init
-#undef TARGET_NR_inotify_init1
 #undef TARGET_NR_inotify_add_watch
 #undef TARGET_NR_inotify_rm_watch
 #endif /* CONFIG_INOTIFY  */
 
+#ifdef CONFIG_INOTIFY1
+#include 
+#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)
+static int sys_inotify_init1(int flags)
+{
+  return (inotify_init1(flags));
+}
+#endif
+#else
+#undef TARGET_NR_inotify_init1
+#endif /* CONFIG_INOTIFY1 */
 
 extern int personality(int);
 extern int flock(int, int);
-- 
1.6.5





[Qemu-devel] Re: [PATCH v3 1/1] Shared memory uio_pci driver

2010-03-28 Thread Michael S. Tsirkin
On Sat, Mar 27, 2010 at 08:48:34PM +0300, Avi Kivity wrote:
> On 03/26/2010 07:14 PM, Cam Macdonell wrote:
>>
>>> I'm not familiar with the uio internals, but for the interface, an ioctl()
>>> on the fd to assign an eventfd to an MSI vector.  Similar to ioeventfd, but
>>> instead of mapping a doorbell to an eventfd, it maps a real MSI to an
>>> eventfd.
>>>  
>> uio will never support ioctls.
>
> Why not?
>
>> Maybe irqcontrol could be extended?
>>
>
> What's irqcontrol?

uio accepts 32 bit writes to the char device file. We can encode
the fd number there, and use the high bit to signal assign/deassign.

> -- 
> Do not meddle in the internals of kernels, for they are subtle and quick to 
> panic.