[Qemu-devel] [PATCH] qemu: virtio-9p: Do not reset atime

2010-05-31 Thread M. Mohan Kumar
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 mo...@in.ibm.com
---
 hw/file-op-9p.h  |2 +-
 hw/virtio-9p-local.c |8 
 hw/virtio-9p.c   |   28 
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index dd82ac7..120c803 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -52,7 +52,7 @@ typedef struct FileOperations
 int (*chmod)(FsContext *, const char *, FsCred *);
 int (*chown)(FsContext *, const char *, FsCred *);
 int (*mknod)(FsContext *, const char *, FsCred *);
-int (*utime)(FsContext *, const char *, const struct utimbuf *);
+int (*utimensat)(FsContext *, const char *, const struct timespec *);
 int (*remove)(FsContext *, const char *);
 int (*symlink)(FsContext *, const char *, const char *, FsCred *);
 int (*link)(FsContext *, const char *, const char *);
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index ecd5db9..dd60354 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -451,10 +451,10 @@ static int local_chown(FsContext *fs_ctx, const char 
*path, FsCred *credp)
 return -1;
 }
 
-static int local_utime(FsContext *ctx, const char *path,
-const struct utimbuf *buf)
+static int local_utimensat(FsContext *s, const char *path,
+  const struct timespec *buf)
 {
-return utime(rpath(ctx, path), buf);
+return utimensat(AT_FDCWD, rpath(s, path), buf, AT_SYMLINK_NOFOLLOW);
 }
 
 static int local_remove(FsContext *ctx, const char *path)
@@ -496,7 +496,7 @@ FileOperations local_ops = {
 .truncate = local_truncate,
 .rename = local_rename,
 .chown = local_chown,
-.utime = local_utime,
+.utimensat = local_utimensat,
 .remove = local_remove,
 .fsync = local_fsync,
 .statfs = local_statfs,
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 1615924..f087122 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -238,10 +238,25 @@ static int v9fs_do_chown(V9fsState *s, V9fsString *path, 
uid_t uid, gid_t gid)
 return s-ops-chown(s-ctx, path-data, cred);
 }
 
-static int v9fs_do_utime(V9fsState *s, V9fsString *path,
-const struct utimbuf *buf)
+static int v9fs_do_utimensat(V9fsState *s, V9fsString *path, V9fsStat v9stat)
 {
-return s-ops-utime(s-ctx, path-data, buf);
+struct timespec ts[2];
+
+if (v9stat.atime != -1) {
+ts[0].tv_sec = v9stat.atime;
+ts[0].tv_nsec = 0;
+} else {
+ts[0].tv_nsec = UTIME_OMIT;
+}
+
+if (v9stat.mtime != -1) {
+ts[1].tv_sec = v9stat.mtime;
+ts[1].tv_nsec = 0;
+} else {
+ts[1].tv_nsec = UTIME_OMIT;
+}
+
+return s-ops-utimensat(s-ctx, path-data, ts);
 }
 
 static int v9fs_do_remove(V9fsState *s, V9fsString *path)
@@ -2184,11 +2199,8 @@ static void v9fs_wstat_post_chmod(V9fsState *s, 
V9fsWstatState *vs, int err)
 goto out;
 }
 
-if (vs-v9stat.mtime != -1) {
-struct utimbuf tb;
-tb.actime = 0;
-tb.modtime = vs-v9stat.mtime;
-if (v9fs_do_utime(s, vs-fidp-path, tb)) {
+if (vs-v9stat.mtime != -1 || vs-v9stat.atime != -1) {
+if (v9fs_do_utimensat(s, vs-fidp-path, vs-v9stat)) {
 err = -errno;
 }
 }
-- 
1.6.6.1




[Qemu-devel] Re: [SeaBIOS] SMBIOS strings

2010-05-31 Thread Jes Sorensen
On 05/28/10 17:44, Gleb Natapov wrote:
 On Fri, May 28, 2010 at 05:24:47PM +0200, Jes Sorensen wrote:
 I guess the Socket Designation in particular might have been done for a
 reason?

 It was part of commit cf2affa6de. And was a result of moving to
 snprintf() instead of direct string manipulation. Before that
 string was created like that:
 memcpy((char *)start, CPU   \0  \0 , 7);
((char *)start)[4] = cpu_number + '0';
 Which start to produce strange cpu numbers for cpus greater then 9. I
 doubt we want to go back to that ;)

Hi Gleb,

I see. Well I guess we could do something slightly more compatible by
printing along the lines:

printf(CPU:);
if (nr  10)
printf( );
snprintf()

Not sure if it is worth it, but it should be doable without reverting to
memcpy().

Thoughts?

Cheers,
Jes



[Qemu-devel] Re: [SeaBIOS] SMBIOS strings

2010-05-31 Thread Jes Sorensen
On 05/29/10 14:49, Sebastian Herbszt wrote:
 Jes Sorensen wrote:
 We were looking at the dmidecode output from qemu-kvm pre-seabios and
 current qemu-kvm and noticed some of the strings have changed.

 The main problem with this is that certain OSes are quite sensitive to
 system changes and avoiding to change things unnecessarily would
 probably be a good thing.
 
 Which OSes do care? Windows only?

The problem with this kind of stuff is that we don't know what is
sensitive and what doesn't care. Most of the Open Source OSes should be
fine, but still Windows is a pretty big customer in the virtualization
guest space.

 Handle 0x0401, DMI type 4, 32 bytes
 Processor Information
 -   Socket Designation: CPU 1
 +   Socket Designation: CPU01
Type: Central Processor
Family: Other
 -   Manufacturer: QEMU
 -   ID: 63 06 00 00 FD FB 8B 07
 +   Manufacturer: Bochs
 +   ID: 23 06 00 00 FD FB 8B 07
Version: Not Specified
Voltage: Unknown
External Clock: Unknown

 I guess the Socket Designation in particular might have been done for a
 reason?

 Otherwise, if there are no objections, I'll look at adding some patches
 to make it more backwards compatible.
 
 Is the different ID displayed on the same VM configuration (esp. -cpu
 option) ?
 The value is gained by calling CPUID so it should not be different.
 
 Which pre-seabios qemu-kvm bios are you comparing to?

Hmmm good point, I'll go back and dig some more on this.

Cheers,
Jes



[Qemu-devel] Re: [PATCHv2-RFC 0/2] virtio: put last seen used index into ring itself

2010-05-31 Thread Jes Sorensen
On 05/30/10 13:22, Michael S. Tsirkin wrote:
 On Fri, May 28, 2010 at 11:56:54AM +0200, Jes Sorensen wrote:
 It looks pretty good to me, however one thing I have been thinking of
 while reading through it:

 Rather than storing a pointer within the ring struct, pointing into a
 position within the same struct. How about storing a byte offset instead
 and using a cast to get to the pointer position? That would avoid the
 pointer dereference, which is less effective cache wise and harder for
 the CPU to predict.

 Not sure whether it really matters performance wise, just a thought.
 
 I think this won't work: when PUBLUSH_USED_IDX is negotiated,
 the pointer is to within the ring.

Hmmm shame, it would be a nice optimization.

Maybe it's time to introduce the v2 ring format, rather than having
adding more kludges to the existing one?

Cheers,
Jes



Re: [Qemu-devel] Re: [RFT][PATCH 07/15] qemu_irq: Add IRQ handlers with delivery feedback

2010-05-31 Thread Jan Kiszka
Blue Swirl wrote:
 On Sun, May 30, 2010 at 12:24 PM, Jan Kiszka jan.kis...@web.de wrote:
 Blue Swirl wrote:
 Linux don't use RTC as time source and I don't know about BSD, so no
 Linux or BSD test case for you, sorry. Run WindowXP standard HAL and put
 heavy load on the host. You can run video inside the gust to trigger
 coalescing more easily.
 I don't have Windows XP, sorry.
 ReactOS [1], at least its 32-bit version, appears to use the RTC as well.
 
 I tried LiveCD and QEMU versions, both seem to hang at boot. Is that expected?

Live-CD works for me (in contrast to the pre-installed image in KVM
mode), but it doesn't show the desired RTC usage.

Jan



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] Re: [PATCHv2-RFC 0/2] virtio: put last seen used index into ring itself

2010-05-31 Thread Rusty Russell
On Thu, 27 May 2010 05:20:35 am Michael S. Tsirkin wrote:
 Here's a rewrite of the original patch with a new layout.
 I haven't tested it yet so no idea how this performs, but
 I think this addresses the cache bounce issue raised by Avi.
 Posting for early flames/comments.

Sorry, not without some evidence that it'll actually reduce cacheline
bouncing.  I *think* it will, but it's not obvious: the host may keep
looking at avail_idx as we're updating last_seen.  Or does qemu always
look at both together anyway?

Can someone convince me this is a win?
Rusty.



[Qemu-devel] Re: [SeaBIOS] SMBIOS strings

2010-05-31 Thread Gleb Natapov
On Mon, May 31, 2010 at 09:32:08AM +0200, Jes Sorensen wrote:
 On 05/28/10 17:44, Gleb Natapov wrote:
  On Fri, May 28, 2010 at 05:24:47PM +0200, Jes Sorensen wrote:
  I guess the Socket Designation in particular might have been done for a
  reason?
 
  It was part of commit cf2affa6de. And was a result of moving to
  snprintf() instead of direct string manipulation. Before that
  string was created like that:
  memcpy((char *)start, CPU   \0  \0 , 7);
 ((char *)start)[4] = cpu_number + '0';
  Which start to produce strange cpu numbers for cpus greater then 9. I
  doubt we want to go back to that ;)
 
 Hi Gleb,
 
 I see. Well I guess we could do something slightly more compatible by
 printing along the lines:
 
 printf(CPU:);
 if (nr  10)
 printf( );
 snprintf()
 
You mean snprintf() not printf?  AFAIR you can tell snprintf to pad with
spaces not zeroes.

 Not sure if it is worth it, but it should be doable without reverting to
 memcpy().
 
 Thoughts?
 
I don't care much as long as we will not have CPU :. It looks like something
that can change after BIOS upgrade, so it is hard to believe Windows
will stop working because of this change.


--
Gleb.



Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs

2010-05-31 Thread Markus Armbruster
[cc: kraxel]

Avi Kivity a...@redhat.com writes:

 On 05/29/2010 11:01 AM, Markus Armbruster wrote:
 Jan Kiszkajan.kis...@web.de  writes:


 From: Jan Kiszkajan.kis...@siemens.com

 As the user may specify ambiguous device IDs, let's search for their
 official names first before considering the user-supplied identifiers.

 Signed-off-by: Jan Kiszkajan.kis...@siemens.com
  
 The problem is letting the user specify ambiguous device IDs in the
 first place!  That way is madness...


 Agreed, we're sowing the seeds for future problems.

On closer look, we have some protection against duplicate IDs, but it
got holes.

We don't assign IDs to default devices.

-device and device_add use the ID of a qemu_device_opts.  Which rejects
duplicate IDs.

pci_add nic -net use either the ID or option name of qemu_net_opts.
And there's our hole.  Reproducible with -net user -net nic,id=foo
-device lsi,id=foo.

We better check for duplicates right where we create qdevs.  Gerd, what
do you think about the appended patch?


diff --git a/hw/qdev.c b/hw/qdev.c
index b91bed1..beb4235 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -40,6 +40,7 @@ DeviceInfo *device_info_list;
 static BusState *qbus_find_recursive(BusState *bus, const char *name,
  const BusInfo *info);
 static BusState *qbus_find(const char *path);
+static DeviceState *qdev_find_recursive(BusState *bus, const char *id);
 
 /* Register a new device type.  */
 void qdev_register(DeviceInfo *info)
@@ -242,6 +243,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
 qdev = qdev_create_from_info(bus, info);
 id = qemu_opts_id(opts);
 if (id) {
+if (qdev_find_recursive(main_system_bus, id)) {
+qerror_report(QERR_DUPLICATE_ID, id, device);
+return NULL;
+}
 qdev-id = id;
 }
 if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {



Re: [Qemu-devel] [PATCH] all vga: refuse hotplugging.

2010-05-31 Thread Gerd Hoffmann

On 05/28/10 16:21, Paul Brook wrote:

Try to pci hotplug a vga card, watch qemu die with hw_error().
This patch fixes it.


I think this is wrong. There's no reason why VGA adapters shouldn't be
hotplugged.  You should fix the underlying problems that prevent hotplugging


The qemu code base simply isn't prepared for that.  Making vga hotplug 
requires alot of infrastructure work within qemu, see discussion with 
Stefano in this thread.  I'm also not fully sure it is possible to 
hotplug the primary vga due to the legacy vga i/o ports.



(or make them fail gracefully).


Make hotplug fail gracefully is exactly what the patch does because 
making hotplug work is impossible short-term IMHO.


cheers,
  Gerd



Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

2010-05-31 Thread Markus Armbruster
Jan Kiszka jan.kis...@web.de writes:

 Avi Kivity wrote:
 On 05/29/2010 11:14 AM, Jan Kiszka wrote:
 Currently breaks down when IDs contain '/', but permitting that is a
 bug.  There may be more problems; the path lookup code is way too
 clever.
  
 Indeed. Less can sometimes be more. My impression is that some of the
 cleverness was motivated by lacking qtree completion for the HMP.

 
 Can we disable abbreviations for QMP and only allow them for HMP?
 
 We can support that by adding a hidden argument to commands specifying
 whether the input comes from a human or machine.  Abbreviations are
 dangerous if they become ambiguous; a human can recover while a machine
 can't.
 

 Both QMP _and_ HMP suffer from ambitious and inconsistent addressing
 schemes. Therefore, I'm more and more in favor of [1]. We just need to
 add command line completion for option values, something that would be
 beneficial for 'drive_add file=...' as well.

 Jan

 [1] http://article.gmane.org/gmane.comp.emulators.qemu/72152

[1] = abolish the clever abbreviations in path lookup.  I agree we
should do that.



Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

2010-05-31 Thread Jan Kiszka
Markus Armbruster wrote:
 Jan Kiszka jan.kis...@web.de writes:
 
 Avi Kivity wrote:
 On 05/29/2010 11:14 AM, Jan Kiszka wrote:
 Currently breaks down when IDs contain '/', but permitting that is a
 bug.  There may be more problems; the path lookup code is way too
 clever.
  
 Indeed. Less can sometimes be more. My impression is that some of the
 cleverness was motivated by lacking qtree completion for the HMP.

 Can we disable abbreviations for QMP and only allow them for HMP?

 We can support that by adding a hidden argument to commands specifying
 whether the input comes from a human or machine.  Abbreviations are
 dangerous if they become ambiguous; a human can recover while a machine
 can't.

 Both QMP _and_ HMP suffer from ambitious and inconsistent addressing
 schemes. Therefore, I'm more and more in favor of [1]. We just need to
 add command line completion for option values, something that would be
 beneficial for 'drive_add file=...' as well.

 Jan

 [1] http://article.gmane.org/gmane.comp.emulators.qemu/72152
 
 [1] = abolish the clever abbreviations in path lookup.  I agree we
 should do that.

Fine. No concerns regarding overlaying IDs and path specifications as well?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux



[Qemu-devel] Re: [PATCH 00/14] Block-related fixes and cleanups

2010-05-31 Thread Gerd Hoffmann

On 05/28/10 15:38, Markus Armbruster wrote:

I'm working on cleanly separating block device host and guest parts.
I'd like to route all this work through Kevin's block tree.  This is
just preliminaries.

Markus Armbruster (14):
   blockdev: Belatedly remove MAX_DRIVES
   blockdev: Belatedly remove driveopts
   usb: Remove unused usb_device_add() parameter is_hotplug
   ide: Remove useless IDEDeviceInfo members unit, drive
   ide: Remove redundant IDEState member conf
   ide: Split ide_init1() off ide_init2()
   ide: Change ide_init_drive() to require valid dinfo argument
   ide: Split non-qdev code off ide_init2()
   qdev: New qdev_prop_set_string()
   qdev: Don't leak string property value on hot unplug
   ide: Turn drive serial into a qdev property ide-drive.serial
   ide: Fix info qtree for ide-drive.ver
   scsi: Turn drive serial into a qdev property scsi-disk.serial
   scsi: Fix info qtree for scsi-disk.ver


Nice cleanups.

Acked-by: Gerd Hoffmann kra...@redhat.com

cheers,
  Gerd




[Qemu-devel] How does env_to_regs and regs_to_env works?

2010-05-31 Thread 曹莹
Now, I’m working with Qemu source study, but I have some difficulties. Could 
someday give me some help or advice.

 

At the beginning of cpu_exec, there is a function call env_to_regs, but I 
cannot understand the behavior of env_to_regs. In my understanding, env_to_regs 
stores environment context pointer(pointer that points to X86CPUState)  and 
other critical Qemu defined variable to real host register, that is to say 
function env_to_regs accomplishes the task register mapping for translating 
optimization. That is my understanding, but I really understand the codes in 
env_to_regs and regs_to_env. Codes in env_to_regs are like this:

#ifdef reg_EAX

EAX = env-regs[R_EAX];



I cannot find where the micro reg_EAX is defined, actually, I insert one line: 
printf(“reg_EAX is defined!\n”) after #ifdef reg_EAX into Qemu source, compile 
it and run Qemu, there is no output information, so I think, env_to_regs is 
actually a void function (For other micro define, situations are the same). But 
if this is true, how did Qemu’s register mapping accomplished? 

 

If I suppose that reg_EAX has already defined somewhere in Qemu source, but how 
does EAX = env-regs[R_EAX] works? EAX is also a micro definition like this 
#define EAX (env-regs[R_EAX]). Then the code becomes like this: 
env-regs[R_EAX]= env-regs[R_EAX]. Left side and right side of “=” is the same 
. So how does regs_to_env and regs_to_env work? How to understand the 
functionality of the two functions, Could anyone give me some advice. I will 
own my thankfulness for all of you. Thank you very much.

 

[Qemu-devel] Re: [PATCH] usb-serial: Fail instead of crash when chardev is missing

2010-05-31 Thread Gerd Hoffmann

On 05/28/10 17:03, Markus Armbruster wrote:


Signed-off-by: Markus Armbrusterarm...@redhat.com


Nice catch.

Acked-by: Gerd Hoffmann kra...@redhat.com

cheers,
  Gerd



[Qemu-devel] [PATCH] qemu: virtio-9p: Implement TMKNOD

2010-05-31 Thread M. Mohan Kumar
Implement TMKNOD as part of 2000.L Work

Synopsis

size[4] Tmknod tag[2] fid[4] name[s] mode[4] dev[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.

Note:
Existing v9fs_do_mknod function is changed to accomodate the dotl mknod
version.

Signed-off-by: M. Mohan Kumar mo...@in.ibm.com
---
 hw/virtio-9p.c |   76 ++-
 hw/virtio-9p.h |   13 +
 2 files changed, 82 insertions(+), 7 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index c217fa5..9307cc3 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -161,15 +161,16 @@ static int v9fs_do_chmod(V9fsState *s, V9fsString *path, 
mode_t mode)
 return s-ops-chmod(s-ctx, path-data, cred);
 }
 
-static int v9fs_do_mknod(V9fsState *s, V9fsCreateState *vs, mode_t mode,
-dev_t dev)
+static int v9fs_do_mknod(V9fsState *s, char *name,
+mode_t mode, dev_t dev, uid_t uid, gid_t gid)
 {
 FsCred cred;
 cred_init(cred);
-cred.fc_uid = vs-fidp-uid;
+cred.fc_uid = uid;
+cred.fc_gid = gid;
 cred.fc_mode = mode;
 cred.fc_rdev = dev;
-return s-ops-mknod(s-ctx, vs-fullname.data, cred);
+return s-ops-mknod(s-ctx, name, cred);
 }
 
 static int v9fs_do_mkdir(V9fsState *s, V9fsCreateState *vs)
@@ -2043,13 +2044,16 @@ static void v9fs_create_post_lstat(V9fsState *s, 
V9fsCreateState *vs, int err)
 }
 
 nmode |= vs-perm  0777;
-err = v9fs_do_mknod(s, vs, nmode, makedev(major, minor));
+err = v9fs_do_mknod(s, vs-fullname.data, nmode,
+makedev(major, minor), vs-fidp-uid, -1);
 v9fs_create_post_perms(s, vs, err);
 } else if (vs-perm  P9_STAT_MODE_NAMED_PIPE) {
-err = v9fs_do_mknod(s, vs, S_IFIFO | (vs-perm  0777), 0);
+err = v9fs_do_mknod(s, vs-fullname.data, S_IFIFO | (vs-perm  0777),
+0, vs-fidp-uid, -1);
 v9fs_post_create(s, vs, err);
 } else if (vs-perm  P9_STAT_MODE_SOCKET) {
-err = v9fs_do_mknod(s, vs, S_IFSOCK | (vs-perm  0777), 0);
+err = v9fs_do_mknod(s, vs-fullname.data, S_IFSOCK | (vs-perm  0777),
+0, vs-fidp-uid, -1);
 v9fs_post_create(s, vs, err);
 } else {
 vs-fidp-fd = v9fs_do_open2(s, vs);
@@ -2461,12 +2465,70 @@ out:
 qemu_free(vs);
 }
 
+static void v9fs_mknod_post_mknod(V9fsState *s, V9fsMknodState *vs, int err)
+{
+if (err == -1) {
+err = -errno;
+goto out;
+}
+
+err = v9fs_do_lstat(s, vs-fullname, vs-stbuf);
+if (err == -1) {
+   err = -errno;
+   goto out;
+}
+stat_to_qid(vs-stbuf, vs-qid);
+vs-offset += pdu_marshal(vs-pdu, vs-offset, Q, vs-qid);
+err = vs-offset;
+out:
+complete_pdu(s, vs-pdu, err);
+v9fs_string_free(vs-fullname);
+v9fs_string_free(vs-name);
+qemu_free(vs);
+}
+
+static void v9fs_mknod(V9fsState *s, V9fsPDU *pdu)
+{
+int32_t fid;
+V9fsMknodState *vs;
+ssize_t err = 0;
+V9fsFidState *fidp;
+gid_t gid;
+
+vs = qemu_malloc(sizeof(*vs));
+vs-pdu = pdu;
+vs-offset = 7;
+
+v9fs_string_init(vs-fullname);
+pdu_unmarshal(vs-pdu, vs-offset, dsddd, fid, vs-name, vs-mode,
+vs-rdev, gid);
+
+fidp = lookup_fid(s, fid);
+if (fidp == NULL) {
+err = -ENOENT;
+goto out;
+}
+
+v9fs_string_sprintf(vs-fullname, %s/%s, fidp-path.data, 
vs-name.data);
+err = v9fs_do_mknod(s, vs-fullname.data, vs-mode, vs-rdev,
+fidp-uid, gid);
+v9fs_mknod_post_mknod(s, vs, err);
+return;
+
+out:
+complete_pdu(s, vs-pdu, err);
+v9fs_string_free(vs-fullname);
+v9fs_string_free(vs-name);
+qemu_free(vs);
+}
+
 typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
 
 static pdu_handler_t *pdu_handlers[] = {
 [P9_TREADDIR] = v9fs_readdir,
 [P9_TSTATFS] = v9fs_statfs,
 [P9_TGETATTR] = v9fs_getattr,
+[P9_TMKNOD] = v9fs_mknod,
 [P9_TVERSION] = v9fs_version,
 [P9_TATTACH] = v9fs_attach,
 [P9_TSTAT] = v9fs_stat,
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index cb0b0ed..9c4ab1d 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -15,6 +15,8 @@
 enum {
 P9_TSTATFS = 8,
 P9_RSTATFS,
+P9_TMKNOD = 18,
+P9_RMKNOD,
 P9_TGETATTR = 24,
 P9_RGETATTR,
 P9_TREADDIR = 40,
@@ -310,6 +312,17 @@ typedef struct V9fsStatStateDotl {
 struct stat stbuf;
 } V9fsStatStateDotl;
 
+typedef struct V9fsMknodState {
+V9fsPDU *pdu;
+size_t offset;
+V9fsQID qid;
+int mode;
+dev_t rdev;
+struct stat stbuf;
+V9fsString name;
+V9fsString fullname;
+} V9fsMknodState;
+
 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
 size_t offset, size_t size, int pack);
 
-- 
1.6.6.1




Re: [Qemu-devel] [PATCH v2 03/15] qdev: Allow device addressing via 'driver.instance'

2010-05-31 Thread Markus Armbruster
Jan Kiszka jan.kis...@web.de writes:

 Markus Armbruster wrote:
 Jan Kiszka jan.kis...@web.de writes:
 
 From: Jan Kiszka jan.kis...@siemens.com

 Extend qbus_find_dev to allow addressing of devices without an unique id
 via an optional per-bus instance number. The new formats are
 'driver.instance' and 'alias.instance'.

 Signed-off-by: Jan Kiszka jan.kis...@siemens.com
 ---
  docs/qdev-device-use.txt |   12 +++-
  hw/qdev.c|   23 ++-
  2 files changed, 29 insertions(+), 6 deletions(-)

 diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
 index 9ac1fa1..5939481 100644
 --- a/docs/qdev-device-use.txt
 +++ b/docs/qdev-device-use.txt
 @@ -1,6 +1,6 @@
  = How to convert to -device  friends =
  
 -=== Specifying Bus and Address on Bus ===
 +=== Specifying Bus, Address on Bus, and Devices ===
  
  In qdev, each device has a parent bus.  Some devices provide one or
  more buses for children.  You can specify a device's parent bus with
 @@ -24,6 +24,16 @@ Furthermore, if a device only hosts a single bus, the 
 bus name can be
  omitted in the path.  Example: /i440FX-pcihost/PIIX3 abbreviates
  /i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings.
  
 +Existing devices can be addressed either via a unique ID if it was
 +assigned during creation or via the device tree path:
 +
 +/full_bus_address/driver_name[.instance_number]
 +or
 +abbreviated_bus_address/driver_name[.instance_number]
 +
 +Example: /i440FX-pcihost/pci.0/e1000.2 addresses the second e1000
 +adapter on the bus 'pci.0'.
 +
  Note: the USB device address can't be controlled at this time.
 
 instance number isn't defined in this document.

 True, only implicitly via the example.

 
 I understand the problem you're trying to solve; I've had it myself many
 times.  But is inventing an instance number the right solution?
 
 The two e1000 devices already have a perfectly fine unique identifier on
 their bus: their bus address.  What about recognizing bus addresses in
 paths?  Requires a suitable restriction on device names and IDs to avoid
 ambiguity, say start with letter.
 
 qdev currently doesn't abstract bus addresses, but that's fixable.

 You would also have to specify unique addressing scheme to those buses
 that do not have it yet. E.g. what should be the address of a ISA bus
 device? The base of its first ioport range? But if it does not have any
 as it only injects ISA IRQs?

Hmm, instance numbers are the lesser evil in this case.

Define them properly, and make info qtree show them, and we'll be okay,
I guess.



Re: [Qemu-devel] [PATCH] target-ppc: remove useless line

2010-05-31 Thread Alexander Graf

On 29.05.2010, at 15:31, Andreas Färber wrote:

 Am 28.05.2010 um 21:00 schrieb Thomas Monjalon:
 
 From: Thomas Monjalon tho...@monjalon.net
 
 This line was a bit clear.
 The next lines set or reset this bit (LE) depending of another bit (ILE).
 So the first line is useless.
 
 Signed-off-by: Thomas Monjalon tho...@monjalon.net
 ---
 target-ppc/helper.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
 
 diff --git a/target-ppc/helper.c b/target-ppc/helper.c
 index 3d843b5..dabf1fd 100644
 --- a/target-ppc/helper.c
 +++ b/target-ppc/helper.c
 @@ -2591,7 +2591,6 @@ static inline void powerpc_excp(CPUState *env, int 
 excp_model, int excp)
 #if 0 /* Fix this: not on all targets */
new_msr = ~((target_ulong)1  MSR_PMM);
 #endif
 -new_msr = ~((target_ulong)1  MSR_LE);
if (msr_ile)
new_msr |= (target_ulong)1  MSR_LE;
else
 
 Following line is
new_msr = ~((target_ulong)1  MSR_LE);
 so this should be fine.
 
 Reviewed-by: Andreas Faerber andreas.faer...@web.de

Thomas, have you verified that it still boots a ppc64 guest?

Alex




[Qemu-devel] Re: [QEMU-KVM]: Megasas + TCM_Loop + SG_IO into Windows XP guests

2010-05-31 Thread Gerd Hoffmann

  Hi,


Also it's worth mentioning that I am still running C: on QEMU IDE
emulation, as I could not quite figure out how to boot for a megasas LD
with option-rom.  What QEMU CLI ops where requried to make this work
again..?


-option-rom $file

or

-device megasas,romfile=$file

cheers,
  Gerd




[Qemu-devel] Re: [PATCH 0/2] Setup scsi-bus xfer and xfer_mode for PR IN/OUT and Maintenance IN/OUT

2010-05-31 Thread Gerd Hoffmann

On 05/31/10 03:42, Nicholas A. Bellinger wrote:

From: Nicholas Bellingern...@linux-iscsi.org

Greetings Gerd, Kevin and Co,

Attached are two patches to add the necesary CDB parsing to determine 
SCSIRequest-cmd.xfer
(length) and SCSIRequest-cmd.mode (direction) for Persistent Reservation IN/OUT
CDBs and for Maintenance IN/OUT CDBs used for Asymmetric Logical Unit Access, 
et al.
There is a special case for the latter Maintenance CDBs with TYPE_ROM that has 
been
included in scsi_req_length().

Also, I should mention this is a temporary measure in order to ensure that we 
can actually
do passthrough of these CDBs into KVM Guest for lsi and megaraid HBA emulation. 
 What will
need to eventually happen is to get rid of scsi_req_xfer_mode() all together 
and just setup
SCSIRequest-cmd.mode based on CDB type in scsi_req_length(), instead of having 
to have another
switch(cdb[0]) statement for every SCSI WRITE CDB on the planet to set 
SCSI_XFER_TO_DEV.

Anyways, I will look at doing this conversion in scsi_req_length() at some 
point, but please
apply these for the moment so folks can get access to their SPC-4 Port LUNs 
with QEMU.  ;)


Patches look fine to me.

Acked-by: Gerd Hoffmann kra...@redhat.com

cheers,
  Gerd



Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs

2010-05-31 Thread Gerd Hoffmann

pci_add nic -net use either the ID or option name of qemu_net_opts.
And there's our hole.  Reproducible with -net user -net nic,id=foo
-device lsi,id=foo.


Oh.  Well.  Yes, better plug that.


@@ -242,6 +243,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
  qdev = qdev_create_from_info(bus, info);
  id = qemu_opts_id(opts);
  if (id) {
+if (qdev_find_recursive(main_system_bus, id)) {
+qerror_report(QERR_DUPLICATE_ID, id, device);
+return NULL;
+}
  qdev-id = id;
  }
  if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {


Looks good..

Acked-by: Gerd Hoffmann kra...@redhat.com

cheers,
  Gerd



Re: [Qemu-devel] [PATCH v2] savevm: Really verify if a drive supports snapshots

2010-05-31 Thread Kevin Wolf
Am 29.05.2010 21:55, schrieb Miguel Di Ciurcio Filho:
 Both bdrv_can_snapshot() and bdrv_has_snapshot() does not work as advertized.
 
 First issue: Their names implies different porpouses, but they do the same 
 thing
 and have exactly the same code. Maybe copied and pasted and forgotten?
 bdrv_has_snapshot() is called in various places for actually checking if there
 is snapshots or not.
 
 Second issue: the way bdrv_can_snapshot() verifies if a block driver supports 
 or
 not snapshots does not catch all cases. E.g.: a raw image.
 
 So when do_savevm() is called, first thing it does is to set a global
 BlockDriverState to save the VM memory state calling get_bs_snapshots().
 
 static BlockDriverState *get_bs_snapshots(void)
 {
 BlockDriverState *bs;
 DriveInfo *dinfo;
 
 if (bs_snapshots)
 return bs_snapshots;
 QTAILQ_FOREACH(dinfo, drives, next) {
 bs = dinfo-bdrv;
 if (bdrv_can_snapshot(bs))
 goto ok;
 }
 return NULL;
  ok:
 bs_snapshots = bs;
 return bs;
 }
 
 bdrv_can_snapshot() may return a BlockDriverState that does not support
 snapshots and do_savevm() goes on.
 
 Later on in do_savevm(), we find:
 
 QTAILQ_FOREACH(dinfo, drives, next) {
 bs1 = dinfo-bdrv;
 if (bdrv_has_snapshot(bs1)) {
 /* Write VM state size only to the image that contains the state 
 */
 sn-vm_state_size = (bs == bs1 ? vm_state_size : 0);
 ret = bdrv_snapshot_create(bs1, sn);
 if (ret  0) {
 monitor_printf(mon, Error while creating snapshot on '%s'\n,
bdrv_get_device_name(bs1));
 }
 }
 }
 
 bdrv_has_snapshot(bs1) is not checking if the device does support or has
 snapshots as explained above. Only in bdrv_snapshot_create() the device is
 actually checked for snapshot support.
 
 So, in cases where the first device supports snapshots, and the second does 
 not,
 the snapshot on the first will happen anyways. I believe this is not a good
 behavior. It should be an all or nothing process.
 
 This patch addresses these issues by making bdrv_can_snapshot() actually do
 what it must do and enforces better tests to avoid errors in the middle of
 do_savevm(). bdrv_has_snapshot() is removed and replaced by 
 bdrv_can_snapshot()
 where appropriate.
 
 bdrv_can_snapshot() was moved from savevm.c to block.c. It makes more sense 
 to me.
 
 The loadvm_state() function was updated too to enforce that when loading a VM 
 at
 least all writable devices must support snapshots too.
 
 Signed-off-by: Miguel Di Ciurcio Filho miguel.fi...@gmail.com
 ---
  block.c   |   21 -
  block.h   |1 +
  monitor.c |5 -
  savevm.c  |   58 --
  4 files changed, 57 insertions(+), 28 deletions(-)
 
 diff --git a/block.c b/block.c
 index cd70730..1115a60 100644
 --- a/block.c
 +++ b/block.c
 @@ -1720,15 +1720,26 @@ void bdrv_debug_event(BlockDriverState *bs, 
 BlkDebugEvent event)
  /**/
  /* handling of snapshots */
  
 +int bdrv_can_snapshot(BlockDriverState *bs)
 +{
 +BlockDriver *drv = bs-drv;
 +if (!drv || !drv-bdrv_snapshot_create || bdrv_is_removable(bs) ||
 +bdrv_is_read_only(bs)) {
 +return 0;
 +}
 +
 +return 1;
 +}
 +
  int bdrv_snapshot_create(BlockDriverState *bs,
   QEMUSnapshotInfo *sn_info)
  {
  BlockDriver *drv = bs-drv;
 -if (!drv)
 -return -ENOMEDIUM;
 -if (!drv-bdrv_snapshot_create)
 -return -ENOTSUP;
 -return drv-bdrv_snapshot_create(bs, sn_info);
 +if (bdrv_can_snapshot(bs)) {
 +return drv-bdrv_snapshot_create(bs, sn_info);
 +}
 +
 +return -1;

Not -ENOTSUP as before?

  }
  
  int bdrv_snapshot_goto(BlockDriverState *bs,
 diff --git a/block.h b/block.h
 index 24efeb6..fbcd8af 100644
 --- a/block.h
 +++ b/block.h
 @@ -173,6 +173,7 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo 
 *bdi);
  const char *bdrv_get_encrypted_filename(BlockDriverState *bs);
  void bdrv_get_backing_filename(BlockDriverState *bs,
 char *filename, int filename_size);
 +int bdrv_can_snapshot(BlockDriverState *bs);
  int bdrv_snapshot_create(BlockDriverState *bs,
   QEMUSnapshotInfo *sn_info);
  int bdrv_snapshot_goto(BlockDriverState *bs,
 diff --git a/monitor.c b/monitor.c
 index ad50f12..8b4a1d7 100644
 --- a/monitor.c
 +++ b/monitor.c
 @@ -2468,8 +2468,11 @@ static void do_loadvm(Monitor *mon, const QDict *qdict)
  
  vm_stop(0);
  
 -if (load_vmstate(name) = 0  saved_vm_running)
 +if (load_vmstate(name) = 0  saved_vm_running) {
  vm_start();
 +} else {
 +monitor_printf(mon, Failed to load VM state. VM stopped.\n);
 +}

If the VM was stopped before, this will print the error message even if
everything went 

[Qemu-devel] RE: English proof-reading services for your research/academic/scientific documents

2010-05-31 Thread Academic Proofreading Services


Dear Researcher

 

Please excuse us for contacting you directly. We are offering an efficient
service to help you and your colleagues ensure that your academic and
professional work is written in perfect English. We will check the grammar
and style of your work and return it to you to meet your requirements and
deadlines.

 

We can provide you with a professional proofreading service at a very
reasonable rate. All our proofreaders are highly qualified native English
speakers. Many work as leading academics in their fields and all have
extensive experience of proofreading to the highest standards.

 

If you are interested in our service, please take a look at our website. All
you have to do is send us your document as a word attachment with the
deadline and we will guarantee delivery of a perfectly written document to
give you complete confidence when you submit your work. The fee is worked
out on a flat rate (£7.49 per thousand words or 0.749 pence per word), so
you know exactly how much the proofreading will cost in advance.

 

Additionally, we offer translation services for academic and non-academic
documents in almost any language.

 

If you have not heard from us within 2 hours during normal business hours
after you have sent your work it is possible that your email has not been
received. Please resend it from a webmail account such as Hotmail, Yahoo or
GMAIL.

 

We look forward to hearing from you!

 

Yours faithfully

 

Robert Johnson

 

P.S. If you did not want to receive this email please reply with
‘unsubscribe‘ in the subject line. We will take you off our database.

 

 

 

image001.gif

[Qemu-devel] Re: RFC: blockdev_add friends, brief rationale, QMP docs

2010-05-31 Thread Markus Armbruster
Avi Kivity a...@redhat.com writes:

 On 05/28/2010 09:21 PM, Markus Armbruster wrote:

 snip, agreed

 Summary of the host / guest split:

 -drive options  host or guest?
 bus, unit, if, index, addr  guest, already covered by qdev
 cyls, heads, secs, transguest, new qdev properties
(but defaults depend on image)
 media   guest
 snapshot, file, cache, aio, format  host, blockdev_add options


 We expose some of the cache property to the guest.  IMO we need the
 cache property to be both guest and host, with qemu bridging the
 impedance mismatch if needed.

Yes.

How should the device properties look like?

 rerror, werror  host, guest drivers will reject
values they don't support


 Did you mean 'block format drivers will reject'?

No.  Actual implementation is in the guest drivers,
e.g. ide_handle_rw_error().

I see this as the host outsourcing the actual work to guest drivers.
Guest drivers that can't do the work should complain.  Right now, they
silently ignore the order.

 serial  guest, new qdev properties
 readonlyboth host  guest, qdev will refuse
to connect readonly host to read/
write guest

 QMP command docs:

 blockdev_add
 

 Add host block device.

 Arguments:

 - id: the host block device's ID, must be unique (json-string)


 Unique in which namespace?  A global ID namespace if fine.

The device ID namespace.

We have numerous ID namespaces already: each QemuOptsList, device IDs
(which happens to be a superset of QemuOptsList qemu_device_opts),
perhaps more.

 - file: the disk image file to use (json-string, optional)
 - format: disk format (json-string, optional)
  - Possible values: raw, qcow2, ...


 Need some way to list supported formats.

See below.

 - aio: host AIO (json-string, optional)
  - Possible values: threads (default), native


 Need some way to list supported options.

 - cache: host cache usage (json-string, optional)
  - Possible values: writethrough (default), writeback, unsafe,
 none


 ...

 - readonly: open image read-only (json-bool, optional, default false)
 - rerror: what to do on read error (json-string, optional)
  - Possible values: report (default), ignore, stop


 ...

 - werror: what to do on write error (json-string, optional)
  - Possible values: enospc (default), report, ignore, stop


 ...
 - snapshot: enable snapshot (json-bool, optional, default false)



 An alternative to the Need some way to list * is to provide another
 query capability, akin to KVM_CAP_..., but I think listing is
 superior.

 Example:

 -  { execute: blockdev_add,
   arguments: { format: raw, id: blk1,
  file: fedora.img } }
 - { return: {} }

 Notes:

 (1) If argument file is missing, all other optional arguments must be
  missing as well.  This defines a block device with no media
  inserted.

 (2) It's possible to list supported disk formats by running QEMU with
  arguments -blockdev_add \?.


 Ok, so there's a partial answer here.

For human users, we need accurate interactive help, both for fixed sets
of options like cache, and for configurable sets like format.
-blockdev_add \? simply follows existing usage there.

We need to make QMP self-documenting: describe commands, arguments,
argument values and so forth with sufficient completeness.  In
particular, for arguments that are enumerations, enumerate all possible
values.

 blockdev_change
 ---

 Change host block device media.

 Arguments are exactly like blockdev_add.

 Notes:

 (1) If argument file is missing, all other optional arguments must be
  missing as well.  This ejects the media without inserting a new one.


 Maybe we want an explicit blockdev_eject instead, not sure.

Either blockdev_change (can eject, insert with auto-eject) or completely
orthogonal blockdev_eject (can only eject) + blockdev_insert (can only
insert, no auto-eject), I'd say.

Thanks for the review!



Re: [Qemu-devel] Re: RFC: blockdev_add friends, brief rationale, QMP docs

2010-05-31 Thread Markus Armbruster
Avi Kivity a...@redhat.com writes:

 On 05/28/2010 10:24 PM, Luiz Capitulino wrote:

 If a password is needed, we should throw an error and let the QMP client
 set the password and try again.
  
   It's what we do today, a password should be set with block_passwd before
 issuing the change command. Otherwise an error is throw.


 Is the password some kind of global or per-monitor property?  In that
 case it doesn't work with parallel execution of commands; better to
 have a password field (or assign IDs to passwords and require a
 passwordid=... argument).

It sets the password in the host BlockDriverState.  Which must already
exist, i.e. you do it after blockdev_add.

What happens if the guest device accesses the host drive before the key
is set?

Anything wrong with passing the password as argument?  Did we avoid that
to protect naive users from exposing their password via argv[]?  That
argument doesn't apply to QMP.



Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

2010-05-31 Thread Markus Armbruster
Jan Kiszka jan.kis...@siemens.com writes:

 Markus Armbruster wrote:
 Jan Kiszka jan.kis...@web.de writes:
 
 Avi Kivity wrote:
 On 05/29/2010 11:14 AM, Jan Kiszka wrote:
 Currently breaks down when IDs contain '/', but permitting that is a
 bug.  There may be more problems; the path lookup code is way too
 clever.
  
 Indeed. Less can sometimes be more. My impression is that some of the
 cleverness was motivated by lacking qtree completion for the HMP.

 Can we disable abbreviations for QMP and only allow them for HMP?

 We can support that by adding a hidden argument to commands specifying
 whether the input comes from a human or machine.  Abbreviations are
 dangerous if they become ambiguous; a human can recover while a machine
 can't.

 Both QMP _and_ HMP suffer from ambitious and inconsistent addressing
 schemes. Therefore, I'm more and more in favor of [1]. We just need to
 add command line completion for option values, something that would be
 beneficial for 'drive_add file=...' as well.

 Jan

 [1] http://article.gmane.org/gmane.comp.emulators.qemu/72152
 
 [1] = abolish the clever abbreviations in path lookup.  I agree we
 should do that.

 Fine. No concerns regarding overlaying IDs and path specifications as well?

I'm fine with that.

Calling the overlayed argument id is not so nice.  We got a bunch of
other not-so-nice names in QMP, maybe we'll have a flag day to clean
them all up.



Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

2010-05-31 Thread Jan Kiszka
Markus Armbruster wrote:
 Jan Kiszka jan.kis...@siemens.com writes:
 
 Markus Armbruster wrote:
 Jan Kiszka jan.kis...@web.de writes:

 Avi Kivity wrote:
 On 05/29/2010 11:14 AM, Jan Kiszka wrote:
 Currently breaks down when IDs contain '/', but permitting that is a
 bug.  There may be more problems; the path lookup code is way too
 clever.
  
 Indeed. Less can sometimes be more. My impression is that some of the
 cleverness was motivated by lacking qtree completion for the HMP.

 Can we disable abbreviations for QMP and only allow them for HMP?

 We can support that by adding a hidden argument to commands specifying
 whether the input comes from a human or machine.  Abbreviations are
 dangerous if they become ambiguous; a human can recover while a machine
 can't.

 Both QMP _and_ HMP suffer from ambitious and inconsistent addressing
 schemes. Therefore, I'm more and more in favor of [1]. We just need to
 add command line completion for option values, something that would be
 beneficial for 'drive_add file=...' as well.

 Jan

 [1] http://article.gmane.org/gmane.comp.emulators.qemu/72152
 [1] = abolish the clever abbreviations in path lookup.  I agree we
 should do that.
 Fine. No concerns regarding overlaying IDs and path specifications as well?
 
 I'm fine with that.
 
 Calling the overlayed argument id is not so nice.  We got a bunch of
 other not-so-nice names in QMP, maybe we'll have a flag day to clean
 them all up.

For this case (device_del and device_show), I think we should simply
call it 'device'.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux



Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs

2010-05-31 Thread Markus Armbruster
Gerd Hoffmann kra...@redhat.com writes:

 pci_add nic -net use either the ID or option name of qemu_net_opts.
 And there's our hole.  Reproducible with -net user -net nic,id=foo
 -device lsi,id=foo.

 Oh.  Well.  Yes, better plug that.

 @@ -242,6 +243,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
   qdev = qdev_create_from_info(bus, info);
   id = qemu_opts_id(opts);
   if (id) {
 +if (qdev_find_recursive(main_system_bus, id)) {
 +qerror_report(QERR_DUPLICATE_ID, id, device);
 +return NULL;
 +}
   qdev-id = id;
   }
   if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {

 Looks good..

 Acked-by: Gerd Hoffmann kra...@redhat.com

I'll repost it as a well-formed patch.  While there, I'll outlaw /.

What about requiring IDs to start with a letter?  Just in case we ever
want to add alias names that must not clash with user-specified IDs.



[Qemu-devel] Re: RFC: blockdev_add friends, brief rationale, QMP docs

2010-05-31 Thread Avi Kivity

On 05/31/2010 01:54 PM, Markus Armbruster wrote:



We expose some of the cache property to the guest.  IMO we need the
cache property to be both guest and host, with qemu bridging the
impedance mismatch if needed.
 

Yes.

How should the device properties look like?
   


write_cache=enabled|disabled|none? (disabled can be enabled by the 
guest, but none cannot)

barrier=supported|unsupported?

Need to look at our supported interfaces and see what's the LCM.


rerror, werror  host, guest drivers will reject
values they don't support

   

Did you mean 'block format drivers will reject'?
 

No.  Actual implementation is in the guest drivers,
e.g. ide_handle_rw_error().
   


That is not a guest driver.  It is a device model.  A guest driver is 
something you modprobe.



I see this as the host outsourcing the actual work to guest drivers.
Guest drivers that can't do the work should complain.  Right now, they
silently ignore the order.
   


With the terminology change, it makes a bit of sense.




Maybe we want an explicit blockdev_eject instead, not sure.
 

Either blockdev_change (can eject, insert with auto-eject) or completely
orthogonal blockdev_eject (can only eject) + blockdev_insert (can only
insert, no auto-eject), I'd say.
   


I prefer the latter, especially as eject has numerous variants (software 
locked eject button, force=true to unwrap paper clip and insert into 
pinhole, tray ejects violently knocking down hot beverage, etc).


--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.




[Qemu-devel] Re: RFC: blockdev_add friends, brief rationale, QMP docs

2010-05-31 Thread Markus Armbruster
Avi Kivity a...@redhat.com writes:

 On 05/31/2010 01:54 PM, Markus Armbruster wrote:

 We expose some of the cache property to the guest.  IMO we need the
 cache property to be both guest and host, with qemu bridging the
 impedance mismatch if needed.
  
 Yes.

 How should the device properties look like?


 write_cache=enabled|disabled|none? (disabled can be enabled by the
 guest, but none cannot)
 barrier=supported|unsupported?

 Need to look at our supported interfaces and see what's the LCM.

I figure we Can flesh it out later.

 rerror, werror  host, guest drivers will reject
 values they don't support


 Did you mean 'block format drivers will reject'?
  
 No.  Actual implementation is in the guest drivers,
 e.g. ide_handle_rw_error().


 That is not a guest driver.  It is a device model.  A guest driver is
 something you modprobe.

Sorry, sloppy QEMU terminology seeping into my writing :(

 I see this as the host outsourcing the actual work to guest drivers.
 Guest drivers that can't do the work should complain.  Right now, they
 silently ignore the order.


 With the terminology change, it makes a bit of sense.


 Maybe we want an explicit blockdev_eject instead, not sure.
  
 Either blockdev_change (can eject, insert with auto-eject) or completely
 orthogonal blockdev_eject (can only eject) + blockdev_insert (can only
 insert, no auto-eject), I'd say.


 I prefer the latter, especially as eject has numerous variants
 (software locked eject button, force=true to unwrap paper clip and
 insert into pinhole, tray ejects violently knocking down hot beverage,
 etc).

Okay.



[Qemu-devel] [Bug 513273] Re: kvm with -vga std is broken since karmic

2010-05-31 Thread sotirovlyu
Forgot to mention that I'm also getting constantly the error message:

BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters

-- 
kvm with -vga std is broken since karmic
https://bugs.launchpad.net/bugs/513273
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: Invalid
Status in “qemu-kvm” package in Ubuntu: Invalid
Status in “seabios” package in Ubuntu: Invalid
Status in “vgabios” package in Ubuntu: Fix Released
Status in “qemu-kvm” source package in Lucid: Invalid
Status in “seabios” source package in Lucid: Invalid
Status in “vgabios” source package in Lucid: Fix Released

Bug description:
Binary package hint: qemu-kvm

it works with -vga cirrus, with -vga std I got:

BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters


And driver do not work properly (I can not set screen resolution) ...
virtual machine almost works, only screen problem in winxp guest

ProblemType: Bug
Architecture: amd64
Date: Wed Jan 27 15:15:49 2010
DistroRelease: Ubuntu 10.04
KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: 
UIDPID  PPID  CSZ   RSS PSR STIME TTY  TIME CMD

[Qemu-devel] [Bug 513273] Re: kvm with -vga std is broken since karmic

2010-05-31 Thread sotirovlyu
I'm using qemu-kvm 0.12.3 with -vga std and with res like 1680x1050,
1440x900 and a few other it crashes/quits immediately with message
Could not open SDL display. It happens for me both when switching with
ctrl-alt-f or with cmd line option -full-screen. With 1024x768 for
example it does not happen, may be other. I'm using the package provided
with Ubuntu 10.4

We discussed on #...@freenode with a guy nicknamed mjt (said he's
debian qemu-kvm package maintainer) that this is for sure a bug after
testing it by himself and according to him is present also in the
current qemu-kvm 0.12.4., but easy to spot and hopefully to fix.

By the way, should I open new bug report ot posting it here is enough?

P.S. I'm particularly interested to know how can I track the progress of
fixing of this bug, as I'm currently researching a solution to implement
KVM as a virtualization platfrom for desktops using the resolutions
mentioned in the beginning. Unfortunately the way KVM quits and closes
the whole machine while encoutering this bug scares me a bit about the
stability of -vga std.

-- 
kvm with -vga std is broken since karmic
https://bugs.launchpad.net/bugs/513273
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: Invalid
Status in “qemu-kvm” package in Ubuntu: Invalid
Status in “seabios” package in Ubuntu: Invalid
Status in “vgabios” package in Ubuntu: Fix Released
Status in “qemu-kvm” source package in Lucid: Invalid
Status in “seabios” source package in Lucid: Invalid
Status in “vgabios” source package in Lucid: Fix Released

Bug description:
Binary package hint: qemu-kvm

it works with -vga cirrus, with -vga std I got:

BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: kvm_dirty_pages_log_disable_slot: invalid parameters
BUG: kvm_dirty_pages_log_enable_slot: invalid parameters
BUG: 

Re: [Qemu-devel] [PATCH v2] savevm: Really verify if a drive supports snapshots

2010-05-31 Thread Miguel Di Ciurcio Filho
On Mon, May 31, 2010 at 6:59 AM, Kevin Wolf kw...@redhat.com wrote:
  int bdrv_snapshot_create(BlockDriverState *bs,
                           QEMUSnapshotInfo *sn_info)
  {
      BlockDriver *drv = bs-drv;
 -    if (!drv)
 -        return -ENOMEDIUM;
 -    if (!drv-bdrv_snapshot_create)
 -        return -ENOTSUP;
 -    return drv-bdrv_snapshot_create(bs, sn_info);
 +    if (bdrv_can_snapshot(bs)) {
 +        return drv-bdrv_snapshot_create(bs, sn_info);
 +    }
 +
 +    return -1;

 Not -ENOTSUP as before?

Oops, I will leave as it was before.


 -    if (load_vmstate(name) = 0  saved_vm_running)
 +    if (load_vmstate(name) = 0  saved_vm_running) {
          vm_start();
 +    } else {
 +        monitor_printf(mon, Failed to load VM state. VM stopped.\n);
 +    }

 If the VM was stopped before, this will print the error message even if
 everything went fine.

Same here, I will leave as it was before. Luiz is cooking something
for this area AFAIK.

Thanks



[Qemu-devel] [PATCH 0/5] Add '-device help' output for device params and help text

2010-05-31 Thread Amit Shah
Hello,

This patch series adds support to specify some descriptive help text
to qdev device parameters. This series adds some help text to the
virtserialport and net family of devices as an example, and the new
output is shown in the respective commits.

This series also adds a new '-device help' option that lists all the
available qdev devices (which is avl. via -device ? now), and adds
each device's parameters to the output listing. This output also shows
the descriptive text.

The idea is to auto-generate documentation from code and to populate
some wiki / qemu-doc.texi using this new target.

Changes from previous send:
- Removed the 'RFC' tag
- Not using macros in net.h (Markus)

It'll be helpful to have people submit some short descriptive text for
the subsystems they care about.

Amit Shah (5):
  qdev: Add a description field for qdev properties for documentation
  virtio-serial: Add description fields for qdev properties
  net.h: Add description fields for qdev properites
  qdev: Re-arrange code to have device properties shown from own
function
  qdev: Add new '-device help' option, shows all devices and properties

 block_int.h   |   10 +++---
 hw/a9mpcore.c |2 +-
 hw/acpi_piix4.c   |2 +-
 hw/arm11mpcore.c  |4 +-
 hw/arm_sysctl.c   |4 +-
 hw/armv7m.c   |2 +-
 hw/cs4231a.c  |6 ++--
 hw/debugcon.c |6 ++--
 hw/eccmemctl.c|2 +-
 hw/escc.c |   16 +-
 hw/etraxfs_pic.c  |3 +-
 hw/fdc.c  |   10 +++---
 hw/gus.c  |8 ++--
 hw/i2c.c  |2 +-
 hw/ide/cmd646.c   |2 +-
 hw/ide/isa.c  |6 ++--
 hw/ide/qdev.c |4 +-
 hw/integratorcp.c |2 +-
 hw/lance.c|2 +-
 hw/m48t59.c   |   12 
 hw/mc146818rtc.c  |2 +-
 hw/ne2000-isa.c   |4 +-
 hw/parallel.c |8 ++--
 hw/pci.c  |   10 +++---
 hw/qdev-addr.h|4 +-
 hw/qdev.c |   51 +
 hw/qdev.h |   75 ++---
 hw/s390-virtio-bus.c  |2 +-
 hw/sb16.c |   10 +++---
 hw/scsi-bus.c |2 +-
 hw/scsi-disk.c|2 +-
 hw/serial.c   |8 ++--
 hw/slavio_timer.c |2 +-
 hw/smbus_eeprom.c |2 +-
 hw/sparc32_dma.c  |2 +-
 hw/sun4m.c|2 +-
 hw/sun4m_iommu.c  |2 +-
 hw/sun4u.c|2 +-
 hw/syborg_fb.c|4 +-
 hw/syborg_interrupt.c |2 +-
 hw/syborg_keyboard.c  |2 +-
 hw/syborg_pointer.c   |4 +-
 hw/syborg_serial.c|2 +-
 hw/syborg_timer.c |2 +-
 hw/tcx.c  |   10 +++---
 hw/usb-ohci.c |4 +-
 hw/usb-serial.c   |   12 
 hw/vga-pci.c  |4 +-
 hw/virtio-blk.h   |4 +-
 hw/virtio-console.c   |   19 
 hw/virtio-net.h   |   51 +
 hw/virtio-pci.c   |   16 +-
 hw/virtio-serial.h|   13 
 hw/virtio.h   |2 +-
 hw/xilinx_ethlite.c   |6 ++-
 hw/xilinx_intc.c  |3 +-
 hw/xilinx_timer.c |4 +-
 net.h |9 --
 usb-linux.c   |8 ++--
 59 files changed, 268 insertions(+), 208 deletions(-)




[Qemu-devel] [PATCH 1/5] qdev: Add a description field for qdev properties for documentation

2010-05-31 Thread Amit Shah
Add a 'description' along with each qdev property to document the input
each qdev property takes.

Signed-off-by: Amit Shah amit.s...@redhat.com
---
 block_int.h   |   10 +++---
 hw/a9mpcore.c |2 +-
 hw/acpi_piix4.c   |2 +-
 hw/arm11mpcore.c  |4 +-
 hw/arm_sysctl.c   |4 +-
 hw/armv7m.c   |2 +-
 hw/cs4231a.c  |6 ++--
 hw/debugcon.c |6 ++--
 hw/eccmemctl.c|2 +-
 hw/escc.c |   16 +-
 hw/etraxfs_pic.c  |3 +-
 hw/fdc.c  |   10 +++---
 hw/gus.c  |8 ++--
 hw/i2c.c  |2 +-
 hw/ide/cmd646.c   |2 +-
 hw/ide/isa.c  |6 ++--
 hw/ide/qdev.c |4 +-
 hw/integratorcp.c |2 +-
 hw/lance.c|2 +-
 hw/m48t59.c   |   12 
 hw/mc146818rtc.c  |2 +-
 hw/ne2000-isa.c   |4 +-
 hw/parallel.c |8 ++--
 hw/pci.c  |   10 +++---
 hw/qdev-addr.h|4 +-
 hw/qdev.c |3 +-
 hw/qdev.h |   75 ++---
 hw/s390-virtio-bus.c  |2 +-
 hw/sb16.c |   10 +++---
 hw/scsi-bus.c |2 +-
 hw/scsi-disk.c|2 +-
 hw/serial.c   |8 ++--
 hw/slavio_timer.c |2 +-
 hw/smbus_eeprom.c |2 +-
 hw/sparc32_dma.c  |2 +-
 hw/sun4m.c|2 +-
 hw/sun4m_iommu.c  |2 +-
 hw/sun4u.c|2 +-
 hw/syborg_fb.c|4 +-
 hw/syborg_interrupt.c |2 +-
 hw/syborg_keyboard.c  |2 +-
 hw/syborg_pointer.c   |4 +-
 hw/syborg_serial.c|2 +-
 hw/syborg_timer.c |2 +-
 hw/tcx.c  |   10 +++---
 hw/usb-ohci.c |4 +-
 hw/usb-serial.c   |   12 
 hw/vga-pci.c  |4 +-
 hw/virtio-blk.h   |4 +-
 hw/virtio-console.c   |   16 ++
 hw/virtio-net.h   |   51 +
 hw/virtio-pci.c   |   16 +-
 hw/virtio.h   |2 +-
 hw/xilinx_ethlite.c   |6 ++-
 hw/xilinx_intc.c  |3 +-
 hw/xilinx_timer.c |4 +-
 net.h |6 ++--
 usb-linux.c   |8 ++--
 58 files changed, 218 insertions(+), 191 deletions(-)

diff --git a/block_int.h b/block_int.h
index 1a7240c..767cd29 100644
--- a/block_int.h
+++ b/block_int.h
@@ -231,12 +231,12 @@ static inline unsigned int 
get_physical_block_exp(BlockConf *conf)
 }
 
 #define DEFINE_BLOCK_PROPERTIES(_state, _conf)  \
-DEFINE_PROP_DRIVE(drive, _state, _conf.dinfo),\
+DEFINE_PROP_DRIVE(drive, _state, _conf.dinfo, ),\
 DEFINE_PROP_UINT16(logical_block_size, _state,\
-   _conf.logical_block_size, 512),  \
+   _conf.logical_block_size, 512, ),  \
 DEFINE_PROP_UINT16(physical_block_size, _state,   \
-   _conf.physical_block_size, 512), \
-DEFINE_PROP_UINT16(min_io_size, _state, _conf.min_io_size, 512),  \
-DEFINE_PROP_UINT32(opt_io_size, _state, _conf.opt_io_size, 512)
+   _conf.physical_block_size, 512, ), \
+DEFINE_PROP_UINT16(min_io_size, _state, _conf.min_io_size, 512, ), \
+DEFINE_PROP_UINT32(opt_io_size, _state, _conf.opt_io_size, 512, )
 
 #endif /* BLOCK_INT_H */
diff --git a/hw/a9mpcore.c b/hw/a9mpcore.c
index b5e5328..174f5d5 100644
--- a/hw/a9mpcore.c
+++ b/hw/a9mpcore.c
@@ -16,7 +16,7 @@ static SysBusDeviceInfo mpcore_priv_info = {
 .qdev.name  = a9mpcore_priv,
 .qdev.size  = sizeof(mpcore_priv_state),
 .qdev.props = (Property[]) {
-DEFINE_PROP_UINT32(num-cpu, mpcore_priv_state, num_cpu, 1),
+DEFINE_PROP_UINT32(num-cpu, mpcore_priv_state, num_cpu, 1, ),
 DEFINE_PROP_END_OF_LIST(),
 }
 };
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 0fce958..fa65cc2 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -410,7 +410,7 @@ static PCIDeviceInfo piix4_pm_info = {
 .init   = piix4_pm_initfn,
 .config_write   = pm_write_config,
 .qdev.props = (Property[]) {
-DEFINE_PROP_UINT32(smb_io_base, PIIX4PMState, smb_io_base, 0),
+DEFINE_PROP_UINT32(smb_io_base, PIIX4PMState, smb_io_base, 0, ),
 DEFINE_PROP_END_OF_LIST(),
 }
 };
diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
index 3bbd885..a3a7a9d 100644
--- a/hw/arm11mpcore.c
+++ b/hw/arm11mpcore.c
@@ -88,7 +88,7 @@ static SysBusDeviceInfo mpcore_rirq_info = {
 .qdev.name  = realview_mpcore,
 .qdev.size  = sizeof(mpcore_rirq_state),
 .qdev.props = (Property[]) {
-DEFINE_PROP_UINT32(num-cpu, mpcore_rirq_state, num_cpu, 1),
+DEFINE_PROP_UINT32(num-cpu, mpcore_rirq_state, num_cpu, 1, ),
 DEFINE_PROP_END_OF_LIST(),
 }
 };
@@ -98,7 +98,7 @@ static SysBusDeviceInfo mpcore_priv_info = {
 .qdev.name  = 

[Qemu-devel] [PATCH 2/5] virtio-serial: Add description fields for qdev properties

2010-05-31 Thread Amit Shah
Document the parameters for the virtserialport and virtioconsole
devices.

Example:

$ ./x86_64-softmmu/qemu-system-x86_64 -device virtserialport,?
virtserialport.nr=uint32, The 'number' for the port for \
predictable port numbers. Use this to spawn ports if you \
plan to migrate the guest.

virtserialport.chardev=chr, The chardev to associate this port with.

virtserialport.name=string, Name for the port that's exposed to \
the guest for port discovery.

Signed-off-by: Amit Shah amit.s...@redhat.com
---
 hw/virtio-console.c |   17 ++---
 hw/virtio-serial.h  |   13 +
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index ccd277a..8a99a99 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -95,11 +95,13 @@ static VirtIOSerialPortInfo virtconsole_info = {
 .init  = virtconsole_initfn,
 .exit  = virtconsole_exitfn,
 .qdev.props = (Property[]) {
-DEFINE_PROP_UINT8(is_console, VirtConsole, port.is_console, 1, ),
+DEFINE_PROP_UINT8(is_console, VirtConsole, port.is_console, 1,
+  PROP_VIRTSERIAL_IS_CONSOLE_DESC),
 DEFINE_PROP_UINT32(nr, VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID,
-   ),
-DEFINE_PROP_CHR(chardev, VirtConsole, chr, ),
-DEFINE_PROP_STRING(name, VirtConsole, port.name, ),
+   PROP_VIRTSERIAL_NR_DESC),
+DEFINE_PROP_CHR(chardev, VirtConsole, chr, PROP_VIRTSERIAL_CHR_DESC),
+DEFINE_PROP_STRING(name, VirtConsole, port.name,
+   PROP_VIRTSERIAL_NAME_DESC),
 DEFINE_PROP_END_OF_LIST(),
 },
 };
@@ -133,9 +135,10 @@ static VirtIOSerialPortInfo virtserialport_info = {
 .exit  = virtconsole_exitfn,
 .qdev.props = (Property[]) {
 DEFINE_PROP_UINT32(nr, VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID,
-   ),
-DEFINE_PROP_CHR(chardev, VirtConsole, chr, ),
-DEFINE_PROP_STRING(name, VirtConsole, port.name, ),
+   PROP_VIRTSERIAL_NR_DESC),
+DEFINE_PROP_CHR(chardev, VirtConsole, chr, PROP_VIRTSERIAL_CHR_DESC),
+DEFINE_PROP_STRING(name, VirtConsole, port.name,
+   PROP_VIRTSERIAL_NAME_DESC),
 DEFINE_PROP_END_OF_LIST(),
 },
 };
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index a93b545..91f3da3 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -58,6 +58,19 @@ struct virtio_console_control {
 
 /* == In-qemu interface == */
 
+#define PROP_VIRTSERIAL_IS_CONSOLE_DESC \
+An hvc console will be spawned in the guest if this is set.
+
+#define PROP_VIRTSERIAL_NR_DESC \
+The 'number' for the port for predictable port numbers. Use this to  \
+spawn ports if you plan to migrate the guest.
+
+#define PROP_VIRTSERIAL_CHR_DESC\
+The chardev to associate this port with.
+
+#define PROP_VIRTSERIAL_NAME_DESC\
+Name for the port that's exposed to the guest for port discovery.
+
 typedef struct VirtIOSerial VirtIOSerial;
 typedef struct VirtIOSerialBus VirtIOSerialBus;
 typedef struct VirtIOSerialPort VirtIOSerialPort;
-- 
1.7.0.1




[Qemu-devel] [PATCH 4/5] qdev: Re-arrange code to have device properties shown from own function

2010-05-31 Thread Amit Shah
Instead of printing out the device properties help messages from
qdev_device_help(), split it off into a new function. This way, we have
two separate function calls for device help and device properties help.

This will be later used to show all the devices and all the properties
associated with the device as part of a complete coverage for all
devices and options associated with each of them.

Signed-off-by: Amit Shah amit.s...@redhat.com
---
 hw/qdev.c |   41 -
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 2cd205b..89ba986 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -151,27 +151,11 @@ static int set_property(const char *name, const char 
*value, void *opaque)
 return 0;
 }
 
-int qdev_device_help(QemuOpts *opts)
+static int show_device_props(const char *driver)
 {
-const char *driver;
 DeviceInfo *info;
 Property *prop;
 
-driver = qemu_opt_get(opts, driver);
-if (driver  !strcmp(driver, ?)) {
-for (info = device_info_list; info != NULL; info = info-next) {
-if (info-no_user) {
-continue;   /* not available, don't show */
-}
-qdev_print_devinfo(info);
-}
-return 1;
-}
-
-if (!qemu_opt_get(opts, ?)) {
-return 0;
-}
-
 info = qdev_find_info(NULL, driver);
 if (!info) {
 return 0;
@@ -193,6 +177,29 @@ int qdev_device_help(QemuOpts *opts)
 return 1;
 }
 
+int qdev_device_help(QemuOpts *opts)
+{
+const char *driver;
+DeviceInfo *info;
+
+driver = qemu_opt_get(opts, driver);
+if (driver  !strcmp(driver, ?)) {
+for (info = device_info_list; info != NULL; info = info-next) {
+if (info-no_user) {
+continue;   /* not available, don't show */
+}
+qdev_print_devinfo(info);
+}
+return 1;
+}
+
+if (!qemu_opt_get(opts, ?)) {
+return 0;
+}
+
+return show_device_props(driver);
+}
+
 DeviceState *qdev_device_add(QemuOpts *opts)
 {
 const char *driver, *path, *id;
-- 
1.7.0.1




[Qemu-devel] Re: [PULL] pci, vhost fixes

2010-05-31 Thread Paolo Bonzini

On 05/30/2010 08:19 PM, Blue Swirl wrote:

We have PRI*64 just for this purpose, so let's use them. The
discussion about that was earlier.


How does mingw matter for vhost-net specific code?

Paolo




[Qemu-devel] [PATCH 5/5] qdev: Add new '-device help' option, shows all devices and properties

2010-05-31 Thread Amit Shah
The new '-device help' option shows all the devices that are registered
with qdev and prints out all the properties each device has, along with
the description for each property.

This is useful in creating automatic documentation for all the options
that we have and support.

Signed-off-by: Amit Shah amit.s...@redhat.com
---
 hw/qdev.c |   15 +++
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 89ba986..4be2f66 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -151,7 +151,7 @@ static int set_property(const char *name, const char 
*value, void *opaque)
 return 0;
 }
 
-static int show_device_props(const char *driver)
+static int show_device_props(const char *driver, const char *prefix)
 {
 DeviceInfo *info;
 Property *prop;
@@ -161,6 +161,10 @@ static int show_device_props(const char *driver)
 return 0;
 }
 
+if (!prefix) {
+prefix = ;
+}
+
 for (prop = info-props; prop  prop-name; prop++) {
 /*
  * TODO Properties without a parser are just for dirty hacks.
@@ -171,7 +175,7 @@ static int show_device_props(const char *driver)
 if (!prop-info-parse) {
 continue;   /* no way to set it, don't show */
 }
-error_printf(%s.%s=%s, %s\n, info-name, prop-name,
+error_printf(%s%s.%s=%s, %s\n, prefix, info-name, prop-name,
  prop-info-name, prop-desc ?: );
 }
 return 1;
@@ -183,12 +187,15 @@ int qdev_device_help(QemuOpts *opts)
 DeviceInfo *info;
 
 driver = qemu_opt_get(opts, driver);
-if (driver  !strcmp(driver, ?)) {
+if (driver  (!strcmp(driver, ?) || !strcmp(driver, help))) {
 for (info = device_info_list; info != NULL; info = info-next) {
 if (info-no_user) {
 continue;   /* not available, don't show */
 }
 qdev_print_devinfo(info);
+if (!strcmp(driver, help)) {
+show_device_props(info-name, \t);
+}
 }
 return 1;
 }
@@ -197,7 +204,7 @@ int qdev_device_help(QemuOpts *opts)
 return 0;
 }
 
-return show_device_props(driver);
+return show_device_props(driver, NULL);
 }
 
 DeviceState *qdev_device_add(QemuOpts *opts)
-- 
1.7.0.1




[Qemu-devel] [PATCH 3/5] net.h: Add description fields for qdev properites

2010-05-31 Thread Amit Shah
This results in an output like:

$ ./x86_64-softmmu/qemu-system-x86_64 -device virtio-net-pci,?

...

virtio-net-pci.mac=macaddr, The MAC address for the NIC.
virtio-net-pci.vlan=vlan, The VLAN to associate the NIC with.
virtio-net-pci.netdev=netdev, The peer net device to associate with this 
virtual NIC.

Signed-off-by: Amit Shah amit.s...@redhat.com
---
 net.h |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/net.h b/net.h
index 0e9cc5d..9ffd4d0 100644
--- a/net.h
+++ b/net.h
@@ -21,9 +21,12 @@ typedef struct NICConf {
 } NICConf;
 
 #define DEFINE_NIC_PROPERTIES(_state, _conf)\
-DEFINE_PROP_MACADDR(mac,   _state, _conf.macaddr, ),\
-DEFINE_PROP_VLAN(vlan, _state, _conf.vlan, ),   \
-DEFINE_PROP_NETDEV(netdev, _state, _conf.peer, )
+DEFINE_PROP_MACADDR(mac,   _state, _conf.macaddr, \
+The MAC address for the NIC.),\
+DEFINE_PROP_VLAN(vlan, _state, _conf.vlan,\
+ The VLAN to associate the NIC with.),\
+DEFINE_PROP_NETDEV(netdev, _state, _conf.peer,\
+   The peer net device to associate with this virtual 
NIC.)
 
 /* VLANs support */
 
-- 
1.7.0.1




Re: [Qemu-devel] [PATCH] target-ppc: remove useless line

2010-05-31 Thread Thomas Monjalon
Alexander Graf wrote:
 Thomas, have you verified that it still boots a ppc64 guest?

No, but I don't see any specific link between ppc64 and this change.

This is the current (pseudo)code:
LE = 0
if ILE == 1
LE = 1
else
LE = 0
In all cases, LE will be overwritten after the first line.

I cannot see any justification to keep the first line.
-- 
Thomas



[Qemu-devel] Re: [PATCHv2-RFC 0/2] virtio: put last seen used index into ring itself

2010-05-31 Thread Michael S. Tsirkin
On Mon, May 31, 2010 at 09:36:00AM +0200, Jes Sorensen wrote:
 On 05/30/10 13:22, Michael S. Tsirkin wrote:
  On Fri, May 28, 2010 at 11:56:54AM +0200, Jes Sorensen wrote:
  It looks pretty good to me, however one thing I have been thinking of
  while reading through it:
 
  Rather than storing a pointer within the ring struct, pointing into a
  position within the same struct. How about storing a byte offset instead
  and using a cast to get to the pointer position? That would avoid the
  pointer dereference, which is less effective cache wise and harder for
  the CPU to predict.
 
  Not sure whether it really matters performance wise, just a thought.
  
  I think this won't work: when PUBLUSH_USED_IDX is negotiated,
  the pointer is to within the ring.
 
 Hmmm shame, it would be a nice optimization.
 
 Maybe it's time to introduce the v2 ring format, rather than having
 adding more kludges to the existing one?
 
 Cheers,
 Jes

There has been discussion about a ring format that does not
use indexes at all. My guess is that would be a good point
for v2 ring format. But making that a product
and tuning might take a while. So definitely something to
keep in mind but I would not want that to block this optimization.

-- 
MST



[Qemu-devel] Re: [PULL] pci, vhost fixes

2010-05-31 Thread Michael S. Tsirkin
On Mon, May 31, 2010 at 02:51:26PM +0200, Paolo Bonzini wrote:
 On 05/30/2010 08:19 PM, Blue Swirl wrote:
 We have PRI*64 just for this purpose, so let's use them. The
 discussion about that was earlier.

 How does mingw matter for vhost-net specific code?

 Paolo

Good point. That code is linux-only, so we are safe using %lld.
By the time someone ports vhost to windows, there's a chance
debian will update it's mingw.  Blue Swirl?

-- 
MST



Re: [Qemu-devel] Re: RFC: blockdev_add friends, brief rationale, QMP docs

2010-05-31 Thread Luiz Capitulino
On Mon, 31 May 2010 13:05:37 +0200
Markus Armbruster arm...@redhat.com wrote:

 Avi Kivity a...@redhat.com writes:
 
  On 05/28/2010 10:24 PM, Luiz Capitulino wrote:
 
  If a password is needed, we should throw an error and let the QMP client
  set the password and try again.
   
It's what we do today, a password should be set with block_passwd before
  issuing the change command. Otherwise an error is throw.
 
 
  Is the password some kind of global or per-monitor property?  In that
  case it doesn't work with parallel execution of commands; better to
  have a password field (or assign IDs to passwords and require a
  passwordid=... argument).
 
 It sets the password in the host BlockDriverState.  Which must already
 exist, i.e. you do it after blockdev_add.
 
 What happens if the guest device accesses the host drive before the key
 is set?

 It's supposed to fail, right Kevin?

 
 Anything wrong with passing the password as argument?  Did we avoid that
 to protect naive users from exposing their password via argv[]?  That
 argument doesn't apply to QMP.
 




[Qemu-devel] Re: [PATCH v3 0/3]: QMP: Commands doc

2010-05-31 Thread Luiz Capitulino
On Sat, 29 May 2010 10:50:55 +0200
Jan Kiszka jan.kis...@web.de wrote:

 Luiz Capitulino wrote:
  This new version moves the documentation to qemu-monitor.hx and now
  QMP/qmp-commands.txt is generated from there (thanks Jan!).
  
  I hope I've addressed all review comments in this version and now it should
  describe reality.
  
  Next step is to fix glitches (after this series is merged, of course).
 
 This is a fragile series, breaking quickly when something changes in
 qemu-monitor.hx (as just happened). Can we get this rebased and merged ASAP?

 Will rebase and resend later today.



Re: [Qemu-devel] Re: RFC: blockdev_add friends, brief rationale, QMP docs

2010-05-31 Thread Kevin Wolf
Am 31.05.2010 15:48, schrieb Luiz Capitulino:
 On Mon, 31 May 2010 13:05:37 +0200
 Markus Armbruster arm...@redhat.com wrote:
 
 Avi Kivity a...@redhat.com writes:

 On 05/28/2010 10:24 PM, Luiz Capitulino wrote:

 If a password is needed, we should throw an error and let the QMP client
 set the password and try again.
  
   It's what we do today, a password should be set with block_passwd before
 issuing the change command. Otherwise an error is throw.


 Is the password some kind of global or per-monitor property?  In that
 case it doesn't work with parallel execution of commands; better to
 have a password field (or assign IDs to passwords and require a
 passwordid=... argument).

 It sets the password in the host BlockDriverState.  Which must already
 exist, i.e. you do it after blockdev_add.

 What happens if the guest device accesses the host drive before the key
 is set?
 
  It's supposed to fail, right Kevin?

I don't think it's a situation that is even supposed to happen. Which is
exactly why I proposed an additional field to avoid it in the first place.

As far as I know in the old monitor the user would be prompted for the
password and as long as he doesn't enter it the VM is stopped, so we
don't get in the same situation there. But if you enter a wrong password
(I'm not sure if it's the same), it just seems to read garbage.

Kevin



[Qemu-devel] [PATCH] qdev: Reject duplicate and anti-social device IDs

2010-05-31 Thread Markus Armbruster
We need Device IDs to be unique and not contain '/' so device tree
nodes can always be unambigously referenced by tree path.

We already have some protection against duplicate IDs, but it got
holes:

* We don't assign IDs to default devices.

* -device and device_add use the ID of a qemu_device_opts.  Which
  rejects duplicate IDs.

* pci_add nic -net use either the ID or option name of
  qemu_net_opts.  And there's our hole.  Reproducible with -net user
  -net nic,id=foo -device lsi,id=foo.

Also require IDs to start with a letter to provide for possible future
extensions.

Signed-off-by: Markus Armbruster arm...@redhat.com
---
Note: If requiring IDs to start with a letter should turn out to be
controversial, I'm happy to respin without that part.

 hw/qdev.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index af17486..877cdf4 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -40,6 +40,7 @@ DeviceInfo *device_info_list;
 static BusState *qbus_find_recursive(BusState *bus, const char *name,
  const BusInfo *info);
 static BusState *qbus_find(const char *path);
+static DeviceState *qdev_find_recursive(BusState *bus, const char *id);
 
 /* Register a new device type.  */
 void qdev_register(DeviceInfo *info)
@@ -242,6 +243,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
 qdev = qdev_create_from_info(bus, info);
 id = qemu_opts_id(opts);
 if (id) {
+if (!qemu_isalpha(id[0]) || strchr(id, '/')) {
+qerror_report(QERR_INVALID_PARAMETER_VALUE, id,
+  an identifier starting with a letter, 
+  and not containing '/');
+return NULL;
+}
+if (qdev_find_recursive(main_system_bus, id)) {
+qerror_report(QERR_DUPLICATE_ID, id, device);
+return NULL;
+}
 qdev-id = id;
 }
 if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
-- 
1.6.6.1




[Qemu-devel] [PATCH] virtio-serial: Simplify virtio_serial_load()

2010-05-31 Thread Markus Armbruster
For all i, ports_map[i] is used in and only in the i-th iteration.
Replace the dynamic array by a scalar variable.

Signed-off-by: Markus Armbruster arm...@redhat.com
---
 hw/virtio-serial-bus.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 3ce95e8..bcc6d5d 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -492,8 +492,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, 
int version_id)
 {
 VirtIOSerial *s = opaque;
 VirtIOSerialPort *port;
-size_t ports_map_size;
-uint32_t max_nr_ports, nr_active_ports, *ports_map;
+uint32_t max_nr_ports, nr_active_ports, ports_map;
 unsigned int i;
 
 if (version_id  2) {
@@ -517,22 +516,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, 
int version_id)
 return -EINVAL;
 }
 
-ports_map_size = sizeof(uint32_t) * (max_nr_ports + 31) / 32;
-ports_map = qemu_malloc(ports_map_size);
-
 for (i = 0; i  (max_nr_ports + 31) / 32; i++) {
-qemu_get_be32s(f, ports_map[i]);
+qemu_get_be32s(f, ports_map);
 
-if (ports_map[i] != s-ports_map[i]) {
+if (ports_map != s-ports_map[i]) {
 /*
  * Ports active on source and destination don't
  * match. Fail migration.
  */
-qemu_free(ports_map);
 return -EINVAL;
 }
 }
-qemu_free(ports_map);
 
 qemu_get_be32s(f, nr_active_ports);
 
-- 
1.6.6.1




Re: [Qemu-devel] [PATCH v2 1/6] MIPS: Initial support of bonito north bridge used by fulong mini pc

2010-05-31 Thread chen huacai
On Sat, May 29, 2010 at 4:31 AM, Aurelien Jarno aurel...@aurel32.net wrote:
 Please find my comments below. Note that I don't feel very comfortable
 with PCI code, so a review from someone know this part of QEMU would be
 nice.

 On Wed, May 19, 2010 at 10:26:32PM +0800, Huacai Chen wrote:
 Signed-off-by: Huacai Chen zltjiang...@gmail.com
 ---
  Makefile.target                      |    1 +
  default-configs/mips64el-softmmu.mak |    1 +
  hw/bonito.c                          |  950 
 ++
  hw/mips.h                            |    3 +
  4 files changed, 955 insertions(+), 0 deletions(-)
  create mode 100644 hw/bonito.c

 diff --git a/Makefile.target b/Makefile.target
 index a22484e..247a2eb 100644
 --- a/Makefile.target
 +++ b/Makefile.target
 @@ -221,6 +221,7 @@ obj-mips-y += dma.o vga.o i8259.o
  obj-mips-y += g364fb.o jazz_led.o
  obj-mips-y += gt64xxx.o pckbd.o mc146818rtc.o
  obj-mips-y += piix4.o cirrus_vga.o
 +obj-mips-$(CONFIG_FULONG) += bonito.o

  obj-microblaze-y = petalogix_s3adsp1800_mmu.o

 diff --git a/default-configs/mips64el-softmmu.mak 
 b/default-configs/mips64el-softmmu.mak
 index 6fa54a3..b731c74 100644
 --- a/default-configs/mips64el-softmmu.mak
 +++ b/default-configs/mips64el-softmmu.mak
 @@ -27,3 +27,4 @@ CONFIG_DP8393X=y
  CONFIG_DS1225Y=y
  CONFIG_MIPSNET=y
  CONFIG_PFLASH_CFI01=y
 +CONFIG_FULONG=y
 diff --git a/hw/bonito.c b/hw/bonito.c
 new file mode 100644
 index 000..246c12a
 --- /dev/null
 +++ b/hw/bonito.c
 @@ -0,0 +1,950 @@
 +/*
 + * bonito north bridge support
 + *
 + * Copyright (c) 2008 yajin (ya...@vm-kernel.org)
 + * Copyright (c) 2010 Huacai Chen (zltjiang...@gmail.com)
 + *
 + * This code is licensed under the GNU GPL v2.
 + */
 +
 +/*
 + * fulong 2e mini pc has a bonito north bridge.
 + */
 +
 +/* what is the meaning of devfn in qemu and IDSEL in bonito northbridge?
 + *
 + * devfn   pci_slot3  + funno
 + * one pci bus can have 32 devices and each device can have 8 functions.
 + *
 + * In bonito north bridge, pci slot = IDSEL bit - 12.
 + * For example, PCI_IDSEL_VIA686B = 17,
 + * pci slot = 17-12=5
 + *
 + * so
 + * VT686B_FUN0's devfn = (53)+0
 + * VT686B_FUN1's devfn = (53)+1
 + *
 + * qemu also uses pci address for north bridge to access pci config 
 register.
 + * bus_no   [23:16]
 + * dev_no   [15:11]
 + * fun_no   [10:8]
 + * reg_no   [7:2]
 + *
 + * so function bonito_sbridge_pciaddr for the translation from
 + * north bridge address to pci address.
 + */
 +
 +#include assert.h
 +
 +#include hw.h
 +#include pci.h
 +#include pc.h
 +#include mips.h
 +
 +typedef target_phys_addr_t pci_addr_t;
 +#include pci_host.h
 +
 +//#define DEBUG_BONITO
 +
 +#ifdef DEBUG_BONITO
 +#define DPRINTF(fmt, ...) fprintf(stderr, %s:  fmt, __FUNCTION__, 
 ##__VA_ARGS__)
 +#else
 +#define DPRINTF(fmt, ...)
 +#endif
 +
 +/* from linux soure code. include/asm-mips/mips-boards/bonito64.h*/
 +#define BONITO_BOOT_BASE        0x1fc0
 +#define BONITO_BOOT_SIZE        0x0010
 +#define BONITO_BOOT_TOP         (BONITO_BOOT_BASE+BONITO_BOOT_SIZE-1)
 +#define BONITO_FLASH_BASE       0x1c00
 +#define BONITO_FLASH_SIZE       0x0300
 +#define BONITO_FLASH_TOP        (BONITO_FLASH_BASE+BONITO_FLASH_SIZE-1)
 +#define BONITO_SOCKET_BASE      0x1f80
 +#define BONITO_SOCKET_SIZE      0x0040
 +#define BONITO_SOCKET_TOP       (BONITO_SOCKET_BASE+BONITO_SOCKET_SIZE-1)
 +#define BONITO_REG_BASE         0x1fe0
 +#define BONITO_REG_SIZE         0x0004
 +#define BONITO_REG_TOP          (BONITO_REG_BASE+BONITO_REG_SIZE-1)
 +#define BONITO_DEV_BASE         0x1ff0
 +#define BONITO_DEV_SIZE         0x0010
 +#define BONITO_DEV_TOP          (BONITO_DEV_BASE+BONITO_DEV_SIZE-1)
 +#define BONITO_PCILO_BASE       0x1000
 +#define BONITO_PCILO_BASE_VA    0xb000
 +#define BONITO_PCILO_SIZE       0x0c00
 +#define BONITO_PCILO_TOP        (BONITO_PCILO_BASE+BONITO_PCILO_SIZE-1)
 +#define BONITO_PCILO0_BASE      0x1000
 +#define BONITO_PCILO1_BASE      0x1400
 +#define BONITO_PCILO2_BASE      0x1800
 +#define BONITO_PCIHI_BASE       0x2000
 +#define BONITO_PCIHI_SIZE       0x2000
 +#define BONITO_PCIHI_TOP        (BONITO_PCIHI_BASE+BONITO_PCIHI_SIZE-1)
 +#define BONITO_PCIIO_BASE       0x1fd0
 +#define BONITO_PCIIO_BASE_VA    0xbfd0
 +#define BONITO_PCIIO_SIZE       0x0001
 +#define BONITO_PCIIO_TOP        (BONITO_PCIIO_BASE+BONITO_PCIIO_SIZE-1)
 +#define BONITO_PCICFG_BASE      0x1fe8
 +#define BONITO_PCICFG_SIZE      0x0008
 +#define BONITO_PCICFG_TOP       (BONITO_PCICFG_BASE+BONITO_PCICFG_SIZE-1)
 +
 +
 +#define BONITO_PCICONFIGBASE    0x00
 +#define BONITO_REGBASE          0x100
 +
 +#define BONITO_PCICONFIG_BASE   (BONITO_PCICONFIGBASE+BONITO_REG_BASE)
 +#define BONITO_PCICONFIG_SIZE   (0x100)
 +
 +#define BONITO_INTERNAL_REG_BASE  (BONITO_REGBASE+BONITO_REG_BASE)
 +#define BONITO_INTERNAL_REG_SIZE  (0x70)
 +
 +#define BONITO_SPCICONFIG_BASE  (BONITO_PCICFG_BASE)
 +#define 

Re: [Qemu-devel] [PATCH v2 5/6] MIPS: Initial support of fulong mini pc (CPU definition, machine construction, etc.)

2010-05-31 Thread chen huacai
On Sat, May 29, 2010 at 4:56 AM, Aurelien Jarno aurel...@aurel32.net wrote:
 Please find my comments below.

 On Wed, May 19, 2010 at 10:28:36PM +0800, Huacai Chen wrote:
 Signed-off-by: Huacai Chen zltjiang...@gmail.com
 ---
  Makefile.target              |    2 +-
  hw/mips_fulong2e.c           |  421 
 ++
  target-mips/translate_init.c |   35 
  3 files changed, 457 insertions(+), 1 deletions(-)
  create mode 100644 hw/mips_fulong2e.c

 diff --git a/Makefile.target b/Makefile.target
 index 9ed4a8d..db4badd 100644
 --- a/Makefile.target
 +++ b/Makefile.target
 @@ -221,7 +221,7 @@ obj-mips-y += dma.o vga.o i8259.o
  obj-mips-y += g364fb.o jazz_led.o
  obj-mips-y += gt64xxx.o pckbd.o mc146818rtc.o
  obj-mips-y += piix4.o cirrus_vga.o
 -obj-mips-$(CONFIG_FULONG) += bonito.o vt82c686.o
 +obj-mips-$(CONFIG_FULONG) += bonito.o vt82c686.o mips_fulong2e.o

  obj-microblaze-y = petalogix_s3adsp1800_mmu.o

 diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
 new file mode 100644
 index 000..3e6ed7e
 --- /dev/null
 +++ b/hw/mips_fulong2e.c
 @@ -0,0 +1,421 @@
 +/*
 + * QEMU fulong 2e mini pc support
 + *
 + * Copyright (c) 2008 yajin (ya...@vm-kernel.org)
 + * Copyright (c) 2009 chenming (chenm...@rdc.faw.com.cn)
 + * Copyright (c) 2010 Huacai Chen (zltjiang...@gmail.com)
 + * This code is licensed under the GNU GPL v2.
 + */
 +
 +/*
 + * Fulong 2e mini pc is based on ICT/ST Loongson 2e CPU (MIPS III like, 
 800MHz)
 + * http://www.linux-mips.org/wiki/Fulong
 + *
 + * Loongson 2e user manual:
 + * http://www.loongsondeveloper.com/doc/Loongson2EUserGuide.pdf
 + */
 +
 +#include hw.h
 +#include pc.h
 +#include fdc.h
 +#include net.h
 +#include boards.h
 +#include smbus.h
 +#include block.h
 +#include flash.h
 +#include mips.h
 +#include mips_cpudevs.h
 +#include pci.h
 +#include usb-uhci.h
 +#include qemu-char.h
 +#include sysemu.h
 +#include audio/audio.h
 +#include qemu-log.h
 +#include loader.h
 +#include mips-bios.h
 +#include ide.h
 +#include elf.h
 +#include mc146818rtc.h
 +
 +#define DEBUG_FULONG2E_INIT
 +
 +#define ENVP_ADDR       0x80002000l
 +#define ENVP_NB_ENTRIES              16
 +#define ENVP_ENTRY_SIZE              256
 +
 +#define MAX_IDE_BUS 2
 +
 +/* PCI SLOT in fulong 2e */
 +#define FULONG2E_VIA_SLOT        5
 +#define FULONG2E_ATI_SLOT        6
 +#define FULONG2E_RTL8139_SLOT    7
 +
 +static PITState *pit;
 +
 +static struct _loaderparams {
 +    int ram_size;
 +    const char *kernel_filename;
 +    const char *kernel_cmdline;
 +    const char *initrd_filename;
 +} loaderparams;
 +
 +static void mips_qemu_writel (void *opaque, target_phys_addr_t addr,
 +                           uint32_t val)
 +{
 +    if ((addr  0x) == 0  val == 42)
 +        qemu_system_reset_request ();
 +    else if ((addr  0x) == 4  val == 42)
 +        qemu_system_shutdown_request ();

 Coding style

 +}
 +
 +static uint32_t mips_qemu_readl (void *opaque, target_phys_addr_t addr)
 +{
 +    return 0;
 +}
 +
 +static CPUWriteMemoryFunc *mips_qemu_write[] = {
 +    mips_qemu_writel,
 +    mips_qemu_writel,
 +    mips_qemu_writel,
 +};
 +
 +static CPUReadMemoryFunc *mips_qemu_read[] = {
 +    mips_qemu_readl,
 +    mips_qemu_readl,
 +    mips_qemu_readl,
 +};

 If the same function is used for all width, it's probably better to call
 it with a name not ending with l.

Do you means I should use mips_qemu_read to replace mips_qemu_readl? I
think this may be more confusing, besides, I see too many examples to
use an l suffix in qemu code.

 +static int mips_qemu_iomemtype = 0;
 +
 +static void prom_set(uint32_t* prom_buf, int index, const char *string, ...)
 +{
 +    va_list ap;
 +    int32_t table_addr;
 +
 +    if (index = ENVP_NB_ENTRIES)
 +        return;
 +
 +    if (string == NULL) {
 +        prom_buf[index] = 0;
 +        return;
 +    }
 +
 +    table_addr = sizeof(int32_t) * ENVP_NB_ENTRIES + index * 
 ENVP_ENTRY_SIZE;
 +    prom_buf[index] = tswap32(ENVP_ADDR + table_addr);
 +
 +    va_start(ap, string);
 +    vsnprintf((char *)prom_buf + table_addr, ENVP_ENTRY_SIZE, string, ap);
 +    va_end(ap);
 +}
 +
 +static int64_t load_kernel (CPUState *env)
 +{
 +    int64_t kernel_entry, kernel_low, kernel_high;
 +    int index = 0;
 +    long initrd_size;
 +    ram_addr_t initrd_offset;
 +    uint32_t *prom_buf;
 +    long prom_size;
 +
 +    if (load_elf(loaderparams.kernel_filename, cpu_mips_kseg0_to_phys, NULL,
 +                 (uint64_t *)kernel_entry, (uint64_t *)kernel_low,
 +                 (uint64_t *)kernel_high, 0, ELF_MACHINE, 1)  0) {
 +        fprintf(stderr, qemu: could not load kernel '%s'\n,
 +                loaderparams.kernel_filename);
 +        exit(1);
 +    }
 +
 +    /* load initrd */
 +    initrd_size = 0;
 +    initrd_offset = 0;
 +    if (loaderparams.initrd_filename) {
 +        initrd_size = get_image_size (loaderparams.initrd_filename);
 +        if (initrd_size  0) {
 +            initrd_offset = (kernel_high + ~TARGET_PAGE_MASK)  
 

[Qemu-devel] Re: [PATCH 05/14] ide: Remove redundant IDEState member conf

2010-05-31 Thread Kevin Wolf
Am 28.05.2010 15:38, schrieb Markus Armbruster:
 Commit 428c149b added IDEState member conf to let commit 0009baf1 find
 the BlockConf from there.  It exists only for qdev drives, created via
 ide_drive_initfn(), not for drives created via ide_init2().
 
 But for a qdev drive, we can just as well reach its IDEDevice, which
 contains the BlockConf.  Do that, and revert the parts of commit
 428c149b that add IDEState member conf.
 
 Signed-off-by: Markus Armbruster arm...@redhat.com
 ---
  hw/ide/core.c |   16 +++-
  hw/ide/internal.h |4 +---
  hw/ide/qdev.c |3 +--
  3 files changed, 9 insertions(+), 14 deletions(-)
 
 diff --git a/hw/ide/core.c b/hw/ide/core.c
 index 066fecb..c3334b1 100644
 --- a/hw/ide/core.c
 +++ b/hw/ide/core.c
 @@ -98,6 +98,7 @@ static void ide_identify(IDEState *s)
  {
  uint16_t *p;
  unsigned int oldsize;
 +IDEDevice *dev;
  
  if (s-identify_set) {
   memcpy(s-io_buffer, s-identify_data, sizeof(s-identify_data));
 @@ -165,8 +166,9 @@ static void ide_identify(IDEState *s)
  put_le16(p + 101, s-nb_sectors  16);
  put_le16(p + 102, s-nb_sectors  32);
  put_le16(p + 103, s-nb_sectors  48);
 -if (s-conf  s-conf-physical_block_size)
 -put_le16(p + 106, 0x6000 | get_physical_block_exp(s-conf));
 +dev = s-unit ? s-bus-slave : s-bus-master;
 +if (dev  dev-conf.physical_block_size)

If this is meant to be the same condition it would be dev-conf  ...

I can't really tell right now if it can happen that either dev or
dev-conf can be NULL here. In a quick attempt I couldn't get either one.

So, which version is correct, or should the first part be dropped
completely?

Kevin



Re: [Qemu-devel] [PATCH] target-ppc: remove useless line

2010-05-31 Thread Alexander Graf
Thomas Monjalon wrote:
 Alexander Graf wrote:
   
 Thomas, have you verified that it still boots a ppc64 guest?
 

 No, but I don't see any specific link between ppc64 and this change.

 This is the current (pseudo)code:
 LE = 0
 if ILE == 1
 LE = 1
 else
 LE = 0
 In all cases, LE will be overwritten after the first line.

 I cannot see any justification to keep the first line.
   

I agree.

Alex




[Qemu-devel] Re: [PATCH] target-ppc: fix RFI by clearing some bits of MSR

2010-05-31 Thread Alexander Graf
Thomas Monjalon wrote:
 From: Thomas Monjalon tho...@monjalon.net

 Since commit 2ada0ed, Return From Interrupt is broken for PPC processors
 because some interrupt specifics bits of SRR1 are copied to MSR.

 SRR1 is a save of MSR during interrupt.
 During RFI, MSR must be restored from SRR1.
 But some bits of SRR1 are interrupt-specific and are not used for MSR saving.

 This is the specification (ISA 2.06) at chapter 6.4.3 (Interrupt Processing):
 2. Bits 33:36 and 42:47 of SRR1 or HSRR1 are loaded with information specific
 to the interrupt type.
  3. Bits 0:32, 37:41, and 48:63 of SRR1 or HSRR1 are loaded with a copy of the
 corresponding bits of the MSR.

 Below is a representation of MSR bits which are not saved:
 0:15 16:31 32  33:3637:41  42:47 48:63
 ——— | ——— | — X X X X — — — — — X X X X X X | 
   |7   |   8   |   3   |   F| 

 History:
 In the initial Qemu implementation (e1833e1), the mask 0x783F was used for
 saving MSR in SRR1. But all the bits 32:47 were cleared during RFI restoring.
 This was wrong. The commit 2ada0ed explains that this breaks Altivec.
 Indeed, bit 38 (for Altivec support) must be saved and restored.
 The change of 2ada0ed was to restore all the bits of SRR1 to MSR.
 But it's also wrong.

 Explanation:
 As an example, let's see what's happening after a TLB miss.
 According to the e300 manual (E300CORERM table 5-6), the TLB miss interrupts
 set the bits 44-47 for KEY, I/D, WAY and S/L. These bits are specifics to the
 interrupt and must not be copied into MSR at the end of the interrupt.
 With the current implementation, a TLB miss overwrite bits POW, TGPR and ILE.

 Fix:
 It shouldn't be needed to filter-out bits on MSR saving when interrupt occurs.
 Specific bits overwrite MSR ones in SRR1.
 But at the end of interrupt (RFI), specifics bits must be cleared before
 restoring MSR from SRR1. The mask 0x783F apply here.

 Discussion:
 The bits of the mask 0x783F are cleared after an interrupt.
 I cannot find a specification which talks about this
 but I assume it is the truth since Linux can run this way.
 Maybe it's not perfect but it's better (works for e300).

 Signed-off-by: Thomas Monjalon tho...@monjalon.net
 Cc: Alexander Graf ag...@suse.de
   

Acked-by: Alexander Graf ag...@suse.de





[Qemu-devel] Re: [PATCH 05/14] ide: Remove redundant IDEState member conf

2010-05-31 Thread Markus Armbruster
Kevin Wolf kw...@redhat.com writes:

 Am 28.05.2010 15:38, schrieb Markus Armbruster:
 Commit 428c149b added IDEState member conf to let commit 0009baf1 find
 the BlockConf from there.  It exists only for qdev drives, created via
 ide_drive_initfn(), not for drives created via ide_init2().
 
 But for a qdev drive, we can just as well reach its IDEDevice, which
 contains the BlockConf.  Do that, and revert the parts of commit
 428c149b that add IDEState member conf.
 
 Signed-off-by: Markus Armbruster arm...@redhat.com
 ---
  hw/ide/core.c |   16 +++-
  hw/ide/internal.h |4 +---
  hw/ide/qdev.c |3 +--
  3 files changed, 9 insertions(+), 14 deletions(-)
 
 diff --git a/hw/ide/core.c b/hw/ide/core.c
 index 066fecb..c3334b1 100644
 --- a/hw/ide/core.c
 +++ b/hw/ide/core.c
 @@ -98,6 +98,7 @@ static void ide_identify(IDEState *s)
  {
  uint16_t *p;
  unsigned int oldsize;
 +IDEDevice *dev;
  
  if (s-identify_set) {
  memcpy(s-io_buffer, s-identify_data, sizeof(s-identify_data));
 @@ -165,8 +166,9 @@ static void ide_identify(IDEState *s)
  put_le16(p + 101, s-nb_sectors  16);
  put_le16(p + 102, s-nb_sectors  32);
  put_le16(p + 103, s-nb_sectors  48);
 -if (s-conf  s-conf-physical_block_size)
 -put_le16(p + 106, 0x6000 | get_physical_block_exp(s-conf));
 +dev = s-unit ? s-bus-slave : s-bus-master;
 +if (dev  dev-conf.physical_block_size)

 If this is meant to be the same condition it would be dev-conf  ...

 I can't really tell right now if it can happen that either dev or
 dev-conf can be NULL here. In a quick attempt I couldn't get either one.

 So, which version is correct, or should the first part be dropped
 completely?

dev-conf can't ever be null:

struct IDEDevice {
DeviceState qdev;
uint32_t unit;
BlockConf conf;
char *version;
char *serial;
};

If s-bus was set up by ide_qdev_init(), then dev cannot be null.  I
*think* it can be null for non-qdev IDE.  Three places still use that.
Maybe it's time to accidentally break them and wait for the screams ;)



[Qemu-devel] [PATCH v2 03/12] hw/omap2.c : separate gptimer module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target   |2 +-
 hw/omap.h |2 +
 hw/omap2.c|  462 --
 hw/omap_gptimer.c |  484 +
 4 files changed, 487 insertions(+), 463 deletions(-)
 create mode 100644 hw/omap_gptimer.c

diff --git a/Makefile.target b/Makefile.target
index 5628557..70b0b37 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap.h b/hw/omap.h
index a37ee54..14fdb6f 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -631,9 +631,11 @@ struct omap_mpu_timer_s;
 struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk clk);
 
+/* OMAP2 gp timer */
 struct omap_gp_timer_s;
 struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta,
 qemu_irq irq, omap_clk fclk, omap_clk iclk);
+void omap_gp_timer_reset(struct omap_gp_timer_s *s);
 
 struct omap_watchdog_timer_s;
 struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t base,
diff --git a/hw/omap2.c b/hw/omap2.c
index bf5539d..890397b 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -27,468 +27,6 @@
 #include soc_dma.h
 #include audio/audio.h
 
-/* GP timers */
-struct omap_gp_timer_s {
-qemu_irq irq;
-qemu_irq wkup;
-qemu_irq in;
-qemu_irq out;
-omap_clk clk;
-QEMUTimer *timer;
-QEMUTimer *match;
-struct omap_target_agent_s *ta;
-
-int in_val;
-int out_val;
-int64_t time;
-int64_t rate;
-int64_t ticks_per_sec;
-
-int16_t config;
-int status;
-int it_ena;
-int wu_ena;
-int enable;
-int inout;
-int capt2;
-int pt;
-enum {
-gpt_trigger_none, gpt_trigger_overflow, gpt_trigger_both
-} trigger;
-enum {
-gpt_capture_none, gpt_capture_rising,
-gpt_capture_falling, gpt_capture_both
-} capture;
-int scpwm;
-int ce;
-int pre;
-int ptv;
-int ar;
-int st;
-int posted;
-uint32_t val;
-uint32_t load_val;
-uint32_t capture_val[2];
-uint32_t match_val;
-int capt_num;
-
-uint16_t writeh;   /* LSB */
-uint16_t readh;/* MSB */
-};
-
-#define GPT_TCAR_IT(1  2)
-#define GPT_OVF_IT (1  1)
-#define GPT_MAT_IT (1  0)
-
-static inline void omap_gp_timer_intr(struct omap_gp_timer_s *timer, int it)
-{
-if (timer-it_ena  it) {
-if (!timer-status)
-qemu_irq_raise(timer-irq);
-
-timer-status |= it;
-/* Or are the status bits set even when masked?
- * i.e. is masking applied before or after the status register?  */
-}
-
-if (timer-wu_ena  it)
-qemu_irq_pulse(timer-wkup);
-}
-
-static inline void omap_gp_timer_out(struct omap_gp_timer_s *timer, int level)
-{
-if (!timer-inout  timer-out_val != level) {
-timer-out_val = level;
-qemu_set_irq(timer-out, level);
-}
-}
-
-static inline uint32_t omap_gp_timer_read(struct omap_gp_timer_s *timer)
-{
-uint64_t distance;
-
-if (timer-st  timer-rate) {
-distance = qemu_get_clock(vm_clock) - timer-time;
-distance = muldiv64(distance, timer-rate, timer-ticks_per_sec);
-
-if (distance = 0x - timer-val)
-return 0x;
-else
-return timer-val + distance;
-} else
-return timer-val;
-}
-
-static inline void omap_gp_timer_sync(struct omap_gp_timer_s *timer)
-{
-if (timer-st) {
-timer-val = omap_gp_timer_read(timer);
-timer-time = qemu_get_clock(vm_clock);
-}
-}
-
-static inline void omap_gp_timer_update(struct omap_gp_timer_s *timer)
-{
-int64_t expires, matches;
-
-if (timer-st  timer-rate) {
-expires = muldiv64(0x1ll - timer-val,
-timer-ticks_per_sec, timer-rate);
-qemu_mod_timer(timer-timer, timer-time + expires);
-
-if (timer-ce  timer-match_val = timer-val) {
-matches = muldiv64(timer-match_val - timer-val,
-timer-ticks_per_sec, timer-rate);
-qemu_mod_timer(timer-match, timer-time + matches);
-} else
-qemu_del_timer(timer-match);
-} else {
-qemu_del_timer(timer-timer);
-qemu_del_timer(timer-match);
-omap_gp_timer_out(timer, timer-scpwm);
-}
-}
-
-static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
-{
-if (timer-pt)

[Qemu-devel] [PATCH v2 05/12] hw/omap2.c : separate gpmc(general purpose memory controller)

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap.h   |2 +
 hw/omap2.c  |  396 
 hw/omap_gpmc.c  |  419 +++
 4 files changed, 422 insertions(+), 397 deletions(-)
 create mode 100644 hw/omap_gpmc.c

diff --git a/Makefile.target b/Makefile.target
index f6234bc..b932f79 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap.h b/hw/omap.h
index b898230..c596953 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -93,8 +93,10 @@ struct omap_sysctl_s *omap_sysctl_init(struct 
omap_target_agent_s *ta,
 struct omap_sdrc_s;
 struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t base);
 
+/* OMAP2 general purpose memory controller */
 struct omap_gpmc_s;
 struct omap_gpmc_s *omap_gpmc_init(target_phys_addr_t base, qemu_irq irq);
+void omap_gpmc_reset(struct omap_gpmc_s *s);
 void omap_gpmc_attach(struct omap_gpmc_s *s, int cs, int iomemtype,
 void (*base_upd)(void *opaque, target_phys_addr_t new),
 void (*unmap)(void *opaque), void *opaque);
diff --git a/hw/omap2.c b/hw/omap2.c
index e310eef..b1e5aae 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -2988,402 +2988,6 @@ struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t 
base)
 return s;
 }
 
-/* General-Purpose Memory Controller */
-struct omap_gpmc_s {
-qemu_irq irq;
-
-uint8_t sysconfig;
-uint16_t irqst;
-uint16_t irqen;
-uint16_t timeout;
-uint16_t config;
-uint32_t prefconfig[2];
-int prefcontrol;
-int preffifo;
-int prefcount;
-struct omap_gpmc_cs_file_s {
-uint32_t config[7];
-target_phys_addr_t base;
-size_t size;
-int iomemtype;
-void (*base_update)(void *opaque, target_phys_addr_t new);
-void (*unmap)(void *opaque);
-void *opaque;
-} cs_file[8];
-int ecc_cs;
-int ecc_ptr;
-uint32_t ecc_cfg;
-ECCState ecc[9];
-};
-
-static void omap_gpmc_int_update(struct omap_gpmc_s *s)
-{
-qemu_set_irq(s-irq, s-irqen  s-irqst);
-}
-
-static void omap_gpmc_cs_map(struct omap_gpmc_cs_file_s *f, int base, int mask)
-{
-/* TODO: check for overlapping regions and report access errors */
-if ((mask != 0x8  mask != 0xc  mask != 0xe  mask != 0xf) ||
-(base  0 || base = 0x40) ||
-(base  0x0f  ~mask)) {
-fprintf(stderr, %s: wrong cs address mapping/decoding!\n,
-__FUNCTION__);
-return;
-}
-
-if (!f-opaque)
-return;
-
-f-base = base  24;
-f-size = (0x0fff  ~(mask  24)) + 1;
-/* TODO: rather than setting the size of the mapping (which should be
- * constant), the mask should cause wrapping of the address space, so
- * that the same memory becomes accessible at every isize/i bytes
- * starting from ibase/i.  */
-if (f-iomemtype)
-cpu_register_physical_memory(f-base, f-size, f-iomemtype);
-
-if (f-base_update)
-f-base_update(f-opaque, f-base);
-}
-
-static void omap_gpmc_cs_unmap(struct omap_gpmc_cs_file_s *f)
-{
-if (f-size) {
-if (f-unmap)
-f-unmap(f-opaque);
-if (f-iomemtype)
-cpu_register_physical_memory(f-base, f-size, IO_MEM_UNASSIGNED);
-f-base = 0;
-f-size = 0;
-}
-}
-
-static void omap_gpmc_reset(struct omap_gpmc_s *s)
-{
-int i;
-
-s-sysconfig = 0;
-s-irqst = 0;
-s-irqen = 0;
-omap_gpmc_int_update(s);
-s-timeout = 0;
-s-config = 0xa00;
-s-prefconfig[0] = 0x4000;
-s-prefconfig[1] = 0x;
-s-prefcontrol = 0;
-s-preffifo = 0;
-s-prefcount = 0;
-for (i = 0; i  8; i ++) {
-if (s-cs_file[i].config[6]  (1  6))/* 
CSVALID */
-omap_gpmc_cs_unmap(s-cs_file + i);
-s-cs_file[i].config[0] = i ? 1  12 : 0;
-s-cs_file[i].config[1] = 0x101001;
-s-cs_file[i].config[2] = 0x020201;
-s-cs_file[i].config[3] = 0x10031003;
-s-cs_file[i].config[4] = 0x10f;
-s-cs_file[i].config[5] = 0;
-s-cs_file[i].config[6] = 0xf00 | (i ? 0 : 1  6);
-if (s-cs_file[i].config[6]  (1  6))/* 
CSVALID */
-omap_gpmc_cs_map(s-cs_file[i],
-s-cs_file[i].config[6]  0x1f,/* MASKADDR 

[Qemu-devel] [PATCH v2 01/12] hw/omap1.c : separate gpio module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap.h   |1 +
 hw/omap1.c  |  181 -
 hw/omap_gpio.c  |  202 +++
 4 files changed, 204 insertions(+), 182 deletions(-)
 create mode 100644 hw/omap_gpio.c

diff --git a/Makefile.target b/Makefile.target
index d06c679..5628557 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -264,7 +264,7 @@ obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o 
pxa2xx_timer.o pxa2xx_dma.o
 obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
-obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
+obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o
 obj-arm-y += omap2.o omap_dss.o soc_dma.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
diff --git a/hw/omap.h b/hw/omap.h
index d305779..ebd166f 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -671,6 +671,7 @@ void omap_mpuio_key(struct omap_mpuio_s *s, int row, int 
col, int down);
 struct omap_gpio_s;
 struct omap_gpio_s *omap_gpio_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk clk);
+void omap_gpio_reset(struct omap_gpio_s *s);
 qemu_irq *omap_gpio_in_get(struct omap_gpio_s *s);
 void omap_gpio_out_set(struct omap_gpio_s *s, int line, qemu_irq handler);
 
diff --git a/hw/omap1.c b/hw/omap1.c
index 8649dbd..8b78c05 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -2804,187 +2804,6 @@ void omap_mpuio_key(struct omap_mpuio_s *s, int row, 
int col, int down)
 omap_mpuio_kbd_update(s);
 }
 
-/* General-Purpose I/O */
-struct omap_gpio_s {
-qemu_irq irq;
-qemu_irq *in;
-qemu_irq handler[16];
-
-uint16_t inputs;
-uint16_t outputs;
-uint16_t dir;
-uint16_t edge;
-uint16_t mask;
-uint16_t ints;
-uint16_t pins;
-};
-
-static void omap_gpio_set(void *opaque, int line, int level)
-{
-struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
-uint16_t prev = s-inputs;
-
-if (level)
-s-inputs |= 1  line;
-else
-s-inputs = ~(1  line);
-
-if (((s-edge  s-inputs  ~prev) | (~s-edge  ~s-inputs  prev)) 
-(1  line)  s-dir  ~s-mask) {
-s-ints |= 1  line;
-qemu_irq_raise(s-irq);
-}
-}
-
-static uint32_t omap_gpio_read(void *opaque, target_phys_addr_t addr)
-{
-struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
-int offset = addr  OMAP_MPUI_REG_MASK;
-
-switch (offset) {
-case 0x00: /* DATA_INPUT */
-return s-inputs  s-pins;
-
-case 0x04: /* DATA_OUTPUT */
-return s-outputs;
-
-case 0x08: /* DIRECTION_CONTROL */
-return s-dir;
-
-case 0x0c: /* INTERRUPT_CONTROL */
-return s-edge;
-
-case 0x10: /* INTERRUPT_MASK */
-return s-mask;
-
-case 0x14: /* INTERRUPT_STATUS */
-return s-ints;
-
-case 0x18: /* PIN_CONTROL (not in OMAP310) */
-OMAP_BAD_REG(addr);
-return s-pins;
-}
-
-OMAP_BAD_REG(addr);
-return 0;
-}
-
-static void omap_gpio_write(void *opaque, target_phys_addr_t addr,
-uint32_t value)
-{
-struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
-int offset = addr  OMAP_MPUI_REG_MASK;
-uint16_t diff;
-int ln;
-
-switch (offset) {
-case 0x00: /* DATA_INPUT */
-OMAP_RO_REG(addr);
-return;
-
-case 0x04: /* DATA_OUTPUT */
-diff = (s-outputs ^ value)  ~s-dir;
-s-outputs = value;
-while ((ln = ffs(diff))) {
-ln --;
-if (s-handler[ln])
-qemu_set_irq(s-handler[ln], (value  ln)  1);
-diff = ~(1  ln);
-}
-break;
-
-case 0x08: /* DIRECTION_CONTROL */
-diff = s-outputs  (s-dir ^ value);
-s-dir = value;
-
-value = s-outputs  ~s-dir;
-while ((ln = ffs(diff))) {
-ln --;
-if (s-handler[ln])
-qemu_set_irq(s-handler[ln], (value  ln)  1);
-diff = ~(1  ln);
-}
-break;
-
-case 0x0c: /* INTERRUPT_CONTROL */
-s-edge = value;
-break;
-
-case 0x10: /* INTERRUPT_MASK */
-s-mask = value;
-break;
-
-case 0x14: /* INTERRUPT_STATUS */
-s-ints = ~value;
-if (!s-ints)
-qemu_irq_lower(s-irq);
-break;
-
-case 0x18: /* PIN_CONTROL (not in OMAP310 TRM) */
-OMAP_BAD_REG(addr);
-s-pins = value;
-break;
-
-default:
-OMAP_BAD_REG(addr);
-return;
-}
-}
-
-/* *Some* sources say the memory region is 32-bit.  */
-static CPUReadMemoryFunc * const omap_gpio_readfn[] = {
-omap_badwidth_read16,
-omap_gpio_read,
-omap_badwidth_read16,
-};
-
-static CPUWriteMemoryFunc * const 

[Qemu-devel] [PATCH v2 04/12] hw/omap2.c : separate synctimer module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap.h   |   11 +++---
 hw/omap2.c  |   72 +-
 hw/omap_synctimer.c |   96 +++
 4 files changed, 104 insertions(+), 77 deletions(-)
 create mode 100644 hw/omap_synctimer.c

diff --git a/Makefile.target b/Makefile.target
index 70b0b37..f6234bc 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap.h b/hw/omap.h
index 14fdb6f..b898230 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -645,8 +645,11 @@ struct omap_32khz_timer_s;
 struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk clk);
 
-void omap_synctimer_init(struct omap_target_agent_s *ta,
+/* OMAP2 sysctimer */
+struct omap_synctimer_s;
+struct omap_synctimer_s *omap_synctimer_init(struct omap_target_agent_s *ta,
 struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk);
+void omap_synctimer_reset(struct omap_synctimer_s *s);
 
 struct omap_tipb_bridge_s;
 struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t base,
@@ -939,11 +942,7 @@ struct omap_mpu_state_s {
 struct omap_l4_s *l4;
 
 struct omap_gp_timer_s *gptimer[12];
-
-struct omap_synctimer_s {
-uint32_t val;
-uint16_t readh;
-} synctimer;
+struct omap_synctimer_s *synctimer;
 
 struct omap_prcm_s *prcm;
 struct omap_sdrc_s *sdrc;
diff --git a/hw/omap2.c b/hw/omap2.c
index 890397b..e310eef 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -27,74 +27,6 @@
 #include soc_dma.h
 #include audio/audio.h
 
-/* 32-kHz Sync Timer of the OMAP2 */
-static uint32_t omap_synctimer_read(struct omap_synctimer_s *s) {
-return muldiv64(qemu_get_clock(vm_clock), 0x8000, get_ticks_per_sec());
-}
-
-static void omap_synctimer_reset(struct omap_synctimer_s *s)
-{
-s-val = omap_synctimer_read(s);
-}
-
-static uint32_t omap_synctimer_readw(void *opaque, target_phys_addr_t addr)
-{
-struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
-
-switch (addr) {
-case 0x00: /* 32KSYNCNT_REV */
-return 0x21;
-
-case 0x10: /* CR */
-return omap_synctimer_read(s) - s-val;
-}
-
-OMAP_BAD_REG(addr);
-return 0;
-}
-
-static uint32_t omap_synctimer_readh(void *opaque, target_phys_addr_t addr)
-{
-struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
-uint32_t ret;
-
-if (addr  2)
-return s-readh;
-else {
-ret = omap_synctimer_readw(opaque, addr);
-s-readh = ret  16;
-return ret  0x;
-}
-}
-
-static CPUReadMemoryFunc * const omap_synctimer_readfn[] = {
-omap_badwidth_read32,
-omap_synctimer_readh,
-omap_synctimer_readw,
-};
-
-static void omap_synctimer_write(void *opaque, target_phys_addr_t addr,
-uint32_t value)
-{
-OMAP_BAD_REG(addr);
-}
-
-static CPUWriteMemoryFunc * const omap_synctimer_writefn[] = {
-omap_badwidth_write32,
-omap_synctimer_write,
-omap_synctimer_write,
-};
-
-void omap_synctimer_init(struct omap_target_agent_s *ta,
-struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk)
-{
-struct omap_synctimer_s *s = mpu-synctimer;
-
-omap_synctimer_reset(s);
-omap_l4_attach(ta, 0, l4_register_io_memory(
-  omap_synctimer_readfn, omap_synctimer_writefn, s));
-}
-
 /* Multichannel SPI */
 struct omap_mcspi_s {
 qemu_irq irq;
@@ -3473,7 +3405,7 @@ static void omap2_mpu_reset(void *opaque)
 omap_gp_timer_reset(mpu-gptimer[9]);
 omap_gp_timer_reset(mpu-gptimer[10]);
 omap_gp_timer_reset(mpu-gptimer[11]);
-omap_synctimer_reset(mpu-synctimer);
+omap_synctimer_reset(mpu-synctimer);
 omap_sdrc_reset(mpu-sdrc);
 omap_gpmc_reset(mpu-gpmc);
 omap_dss_reset(mpu-dss);
@@ -3634,7 +3566,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long 
sdram_size,
 
 omap_tap_init(omap_l4ta(s-l4, 2), s);
 
-omap_synctimer_init(omap_l4tao(s-l4, 2), s,
+s-synctimer = omap_synctimer_init(omap_l4tao(s-l4, 2), s,
 omap_findclk(s, clk32-kHz),
 omap_findclk(s, core_l4_iclk));
 
diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c
new file mode 100644
index 000..118668a
--- /dev/null
+++ b/hw/omap_synctimer.c
@@ -0,0 +1,96 @@
+/*
+ * TI OMAP2 32kHz sync timer emulation.
+ 

[Qemu-devel] [PATCH v2 12/12] hw/omap : make local function static and remove declaration from header

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 hw/omap.h  |   36 
 hw/omap1.c |   12 ++--
 hw/omap2.c |6 +++---
 3 files changed, 9 insertions(+), 45 deletions(-)

diff --git a/hw/omap.h b/hw/omap.h
index 34443b4..18eb72b 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -108,15 +108,6 @@ struct omap_intr_handler_s 
*omap2_inth_init(target_phys_addr_t base,
 void omap_inth_reset(struct omap_intr_handler_s *s);
 qemu_irq omap_inth_get_pin(struct omap_intr_handler_s *s, int n);
 
-struct omap_prcm_s;
-struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta,
-qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int,
-struct omap_mpu_state_s *mpu);
-
-struct omap_sysctl_s;
-struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
-omap_clk iclk, struct omap_mpu_state_s *mpu);
-
 /* OMAP2 SDRAM controller */
 struct omap_sdrc_s;
 struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t base);
@@ -658,34 +649,18 @@ struct omap_dma_lcd_channel_s {
 # define OMAP24XX_DMA_EXT_DMAREQ5  64
 
 /* omap[123].c */
-struct omap_mpu_timer_s;
-struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
-qemu_irq irq, omap_clk clk);
-
 /* OMAP2 gp timer */
 struct omap_gp_timer_s;
 struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta,
 qemu_irq irq, omap_clk fclk, omap_clk iclk);
 void omap_gp_timer_reset(struct omap_gp_timer_s *s);
 
-struct omap_watchdog_timer_s;
-struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t base,
-qemu_irq irq, omap_clk clk);
-
-struct omap_32khz_timer_s;
-struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
-qemu_irq irq, omap_clk clk);
-
 /* OMAP2 sysctimer */
 struct omap_synctimer_s;
 struct omap_synctimer_s *omap_synctimer_init(struct omap_target_agent_s *ta,
 struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk);
 void omap_synctimer_reset(struct omap_synctimer_s *s);
 
-struct omap_tipb_bridge_s;
-struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t base,
-qemu_irq abort_irq, omap_clk clk);
-
 struct omap_uart_s;
 struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk fclk, omap_clk iclk,
@@ -740,10 +715,6 @@ void omap_mcspi_attach(struct omap_mcspi_s *s,
 int chipselect);
 void omap_mcspi_reset(struct omap_mcspi_s *s);
 
-struct omap_rtc_s;
-struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
-qemu_irq *irq, omap_clk clk);
-
 struct I2SCodec {
 void *opaque;
 
@@ -773,16 +744,9 @@ struct omap_mcbsp_s *omap_mcbsp_init(target_phys_addr_t 
base,
 qemu_irq *irq, qemu_irq *dma, omap_clk clk);
 void omap_mcbsp_i2s_attach(struct omap_mcbsp_s *s, I2SCodec *slave);
 
-struct omap_lpg_s;
-struct omap_lpg_s *omap_lpg_init(target_phys_addr_t base, omap_clk clk);
-
 void omap_tap_init(struct omap_target_agent_s *ta,
 struct omap_mpu_state_s *mpu);
 
-struct omap_eac_s;
-struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
-qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk);
-
 /* omap_lcdc.c */
 struct omap_lcd_panel_s;
 void omap_lcdc_reset(struct omap_lcd_panel_s *s);
diff --git a/hw/omap1.c b/hw/omap1.c
index 301eec5..d400bbb 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -247,7 +247,7 @@ static void omap_mpu_timer_reset(struct omap_mpu_timer_s *s)
 s-it_ena = 1;
 }
 
-struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
+static struct omap_mpu_timer_s *omap_mpu_timer_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk clk)
 {
 int iomemtype;
@@ -371,7 +371,7 @@ static void omap_wd_timer_reset(struct 
omap_watchdog_timer_s *s)
 omap_timer_update(s-timer);
 }
 
-struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t base,
+static struct omap_watchdog_timer_s *omap_wd_timer_init(target_phys_addr_t 
base,
 qemu_irq irq, omap_clk clk)
 {
 int iomemtype;
@@ -473,7 +473,7 @@ static void omap_os_timer_reset(struct omap_32khz_timer_s 
*s)
 s-timer.ar = 1;
 }
 
-struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
+static struct omap_32khz_timer_s *omap_os_timer_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk clk)
 {
 int iomemtype;
@@ -1180,7 +1180,7 @@ static void omap_tipb_bridge_reset(struct 
omap_tipb_bridge_s *s)
 s-enh_control = 0x000f;
 }
 
-struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t base,
+static struct omap_tipb_bridge_s *omap_tipb_bridge_init(target_phys_addr_t 
base,
 qemu_irq abort_irq, omap_clk clk)
 {
 int iomemtype;
@@ -2809,7 +2809,7 @@ static void omap_rtc_reset(struct omap_rtc_s *s)
 omap_rtc_tick(s);
 }
 
-struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
+static struct 

[Qemu-devel] [PATCH v2 02/12] hw/omap2.c : separate gpio module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 hw/omap.h  |3 +
 hw/omap2.c |  523 
 hw/omap_gpio.c |  523 
 3 files changed, 526 insertions(+), 523 deletions(-)

diff --git a/hw/omap.h b/hw/omap.h
index ebd166f..a37ee54 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -668,6 +668,7 @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
 void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler);
 void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down);
 
+/* omap1 gpio module interface */
 struct omap_gpio_s;
 struct omap_gpio_s *omap_gpio_init(target_phys_addr_t base,
 qemu_irq irq, omap_clk clk);
@@ -675,9 +676,11 @@ void omap_gpio_reset(struct omap_gpio_s *s);
 qemu_irq *omap_gpio_in_get(struct omap_gpio_s *s);
 void omap_gpio_out_set(struct omap_gpio_s *s, int line, qemu_irq handler);
 
+/* omap2 gpio interface */
 struct omap_gpif_s;
 struct omap_gpif_s *omap2_gpio_init(struct omap_target_agent_s *ta,
 qemu_irq *irq, omap_clk *fclk, omap_clk iclk, int modules);
+void omap_gpif_reset(struct omap_gpif_s *s);
 qemu_irq *omap2_gpio_in_get(struct omap_gpif_s *s, int start);
 void omap2_gpio_out_set(struct omap_gpif_s *s, int line, qemu_irq handler);
 
diff --git a/hw/omap2.c b/hw/omap2.c
index bd1b35e..bf5539d 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -557,529 +557,6 @@ void omap_synctimer_init(struct omap_target_agent_s *ta,
   omap_synctimer_readfn, omap_synctimer_writefn, s));
 }
 
-/* General-Purpose Interface of OMAP2 */
-struct omap2_gpio_s {
-qemu_irq irq[2];
-qemu_irq wkup;
-qemu_irq *in;
-qemu_irq handler[32];
-
-uint8_t config[2];
-uint32_t inputs;
-uint32_t outputs;
-uint32_t dir;
-uint32_t level[2];
-uint32_t edge[2];
-uint32_t mask[2];
-uint32_t wumask;
-uint32_t ints[2];
-uint32_t debounce;
-uint8_t delay;
-};
-
-static inline void omap_gpio_module_int_update(struct omap2_gpio_s *s,
-int line)
-{
-qemu_set_irq(s-irq[line], s-ints[line]  s-mask[line]);
-}
-
-static void omap_gpio_module_wake(struct omap2_gpio_s *s, int line)
-{
-if (!(s-config[0]  (1  2)))/* ENAWAKEUP */
-return;
-if (!(s-config[0]  (3  3)))/* Force Idle */
-return;
-if (!(s-wumask  (1  line)))
-return;
-
-qemu_irq_raise(s-wkup);
-}
-
-static inline void omap_gpio_module_out_update(struct omap2_gpio_s *s,
-uint32_t diff)
-{
-int ln;
-
-s-outputs ^= diff;
-diff = ~s-dir;
-while ((ln = ffs(diff))) {
-ln --;
-qemu_set_irq(s-handler[ln], (s-outputs  ln)  1);
-diff = ~(1  ln);
-}
-}
-
-static void omap_gpio_module_level_update(struct omap2_gpio_s *s, int line)
-{
-s-ints[line] |= s-dir 
-((s-inputs  s-level[1]) | (~s-inputs  s-level[0]));
-omap_gpio_module_int_update(s, line);
-}
-
-static inline void omap_gpio_module_int(struct omap2_gpio_s *s, int line)
-{
-s-ints[0] |= 1  line;
-omap_gpio_module_int_update(s, 0);
-s-ints[1] |= 1  line;
-omap_gpio_module_int_update(s, 1);
-omap_gpio_module_wake(s, line);
-}
-
-static void omap_gpio_module_set(void *opaque, int line, int level)
-{
-struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
-
-if (level) {
-if (s-dir  (1  line)  ((~s-inputs  s-edge[0]) | s-level[1]))
-omap_gpio_module_int(s, line);
-s-inputs |= 1  line;
-} else {
-if (s-dir  (1  line)  ((s-inputs  s-edge[1]) | s-level[0]))
-omap_gpio_module_int(s, line);
-s-inputs = ~(1  line);
-}
-}
-
-static void omap_gpio_module_reset(struct omap2_gpio_s *s)
-{
-s-config[0] = 0;
-s-config[1] = 2;
-s-ints[0] = 0;
-s-ints[1] = 0;
-s-mask[0] = 0;
-s-mask[1] = 0;
-s-wumask = 0;
-s-dir = ~0;
-s-level[0] = 0;
-s-level[1] = 0;
-s-edge[0] = 0;
-s-edge[1] = 0;
-s-debounce = 0;
-s-delay = 0;
-}
-
-static uint32_t omap_gpio_module_read(void *opaque, target_phys_addr_t addr)
-{
-struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
-
-switch (addr) {
-case 0x00: /* GPIO_REVISION */
-return 0x18;
-
-case 0x10: /* GPIO_SYSCONFIG */
-return s-config[0];
-
-case 0x14: /* GPIO_SYSSTATUS */
-return 0x01;
-
-case 0x18: /* GPIO_IRQSTATUS1 */
-return s-ints[0];
-
-case 0x1c: /* GPIO_IRQENABLE1 */
-case 0x60: /* GPIO_CLEARIRQENABLE1 */
-case 0x64: /* GPIO_SETIRQENABLE1 */
-return s-mask[0];
-
-case 0x20: /* GPIO_WAKEUPENABLE */
-case 0x80: /* GPIO_CLEARWKUENA */
-case 0x84: /* GPIO_SETWKUENA */
-return s-wumask;
-
-case 0x28: /* GPIO_IRQSTATUS2 */
-return s-ints[1];
-
-case 0x2c: /* GPIO_IRQENABLE2 */
-case 0x70: /* GPIO_CLEARIRQENABLE2 */
-case 0x74: 

[Qemu-devel] [PATCH v2 00/12] refactor OMAP implementation

2010-05-31 Thread cmchao
 The following changes since commit aa6f63fff62faf2fe9ffba5a789675d49293614d
 Blue Swirl:
mc146818rtc: improve debugging
Add a separate flag for debugging coalesced interrupts.

 The patches almostly base on http://meego.gitorious.org/qemu-maemo/qemu work 
and
 act as preparatory work to merge their OMAP3 and beagleboard support. All the
 work are to separate modules, which will be shared or extended in OMAP3 
implementation
 and make some local function static

 change from v1 :
  1 fix missing static declaration leading to compilation error in 
patch #12
  2 rebase to newer upstream

 [PATCH v2 01/12] hw/omap1.c : separate gpio module
 [PATCH v2 02/12] hw/omap2.c : separate gpio module
 [PATCH v2 03/12] hw/omap2.c : separate gptimer module
 [PATCH v2 04/12] hw/omap2.c : separate synctimer module
 [PATCH v2 05/12] hw/omap2.c : separate gpmc(general purpose memory controller)
 [PATCH v2 06/12] hw/omap2.c : separate sdrc (sdram controller)
 [PATCH v2 07/12] hw/omap1.c : separate interrupt controller module
 [PATCH v2 08/12] hw/omap2.c : separate spi module
 [PATCH v2 09/12] hw/omap2.c : separate tap module(Test-Chip-level)
 [PATCH v2 10/12] hw/omwp2.c : separate l4 interconnect module
 [PATCH v2 11/12] hw/omap1.c : separate uart module
 [PATCH v2 12/12] hw/omap : make local function static and remove declaration 
from header



[Qemu-devel] [PATCH v2 11/12] hw/omap1.c : separate uart module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |3 +-
 hw/omap1.c  |  170 
 hw/omap_uart.c  |  194 +++
 3 files changed, 196 insertions(+), 171 deletions(-)
 create mode 100644 hw/omap_uart.c

diff --git a/Makefile.target b/Makefile.target
index 55dbf67..b86a110 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -264,7 +264,8 @@ obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o 
pxa2xx_timer.o pxa2xx_dma.o
 obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
-obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o omap_intc.o
+obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o \
+   omap_gpio.o omap_intc.o omap_uart.o
 obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
omap_gpmc.o omap_sdrc.o omap_spi.o omap_tap.o omap_l4.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
diff --git a/hw/omap1.c b/hw/omap1.c
index 21c53fe..301eec5 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -1378,176 +1378,6 @@ static void omap_dpll_init(struct dpll_ctl_s *s, 
target_phys_addr_t base,
 cpu_register_physical_memory(base, 0x100, iomemtype);
 }
 
-/* UARTs */
-struct omap_uart_s {
-target_phys_addr_t base;
-SerialState *serial; /* TODO */
-struct omap_target_agent_s *ta;
-omap_clk fclk;
-qemu_irq irq;
-
-uint8_t eblr;
-uint8_t syscontrol;
-uint8_t wkup;
-uint8_t cfps;
-uint8_t mdr[2];
-uint8_t scr;
-uint8_t clksel;
-};
-
-void omap_uart_reset(struct omap_uart_s *s)
-{
-s-eblr = 0x00;
-s-syscontrol = 0;
-s-wkup = 0x3f;
-s-cfps = 0x69;
-s-clksel = 0;
-}
-
-struct omap_uart_s *omap_uart_init(target_phys_addr_t base,
-qemu_irq irq, omap_clk fclk, omap_clk iclk,
-qemu_irq txdma, qemu_irq rxdma, CharDriverState *chr)
-{
-struct omap_uart_s *s = (struct omap_uart_s *)
-qemu_mallocz(sizeof(struct omap_uart_s));
-
-s-base = base;
-s-fclk = fclk;
-s-irq = irq;
-#ifdef TARGET_WORDS_BIGENDIAN
-s-serial = serial_mm_init(base, 2, irq, omap_clk_getrate(fclk)/16,
-   chr ?: qemu_chr_open(null, null, NULL), 1,
-   1);
-#else
-s-serial = serial_mm_init(base, 2, irq, omap_clk_getrate(fclk)/16,
-   chr ?: qemu_chr_open(null, null, NULL), 1,
-   0);
-#endif
-return s;
-}
-
-static uint32_t omap_uart_read(void *opaque, target_phys_addr_t addr)
-{
-struct omap_uart_s *s = (struct omap_uart_s *) opaque;
-
-addr = 0xff;
-switch (addr) {
-case 0x20: /* MDR1 */
-return s-mdr[0];
-case 0x24: /* MDR2 */
-return s-mdr[1];
-case 0x40: /* SCR */
-return s-scr;
-case 0x44: /* SSR */
-return 0x0;
-case 0x48: /* EBLR (OMAP2) */
-return s-eblr;
-case 0x4C: /* OSC_12M_SEL (OMAP1) */
-return s-clksel;
-case 0x50: /* MVR */
-return 0x30;
-case 0x54: /* SYSC (OMAP2) */
-return s-syscontrol;
-case 0x58: /* SYSS (OMAP2) */
-return 1;
-case 0x5c: /* WER (OMAP2) */
-return s-wkup;
-case 0x60: /* CFPS (OMAP2) */
-return s-cfps;
-}
-
-OMAP_BAD_REG(addr);
-return 0;
-}
-
-static void omap_uart_write(void *opaque, target_phys_addr_t addr,
-uint32_t value)
-{
-struct omap_uart_s *s = (struct omap_uart_s *) opaque;
-
-addr = 0xff;
-switch (addr) {
-case 0x20: /* MDR1 */
-s-mdr[0] = value  0x7f;
-break;
-case 0x24: /* MDR2 */
-s-mdr[1] = value  0xff;
-break;
-case 0x40: /* SCR */
-s-scr = value  0xff;
-break;
-case 0x48: /* EBLR (OMAP2) */
-s-eblr = value  0xff;
-break;
-case 0x4C: /* OSC_12M_SEL (OMAP1) */
-s-clksel = value  1;
-break;
-case 0x44: /* SSR */
-case 0x50: /* MVR */
-case 0x58: /* SYSS (OMAP2) */
-OMAP_RO_REG(addr);
-break;
-case 0x54: /* SYSC (OMAP2) */
-s-syscontrol = value  0x1d;
-if (value  2)
-omap_uart_reset(s);
-break;
-case 0x5c: /* WER (OMAP2) */
-s-wkup = value  0x7f;
-break;
-case 0x60: /* CFPS (OMAP2) */
-s-cfps = value  0xff;
-break;
-default:
-OMAP_BAD_REG(addr);
-}
-}
-
-static CPUReadMemoryFunc * const omap_uart_readfn[] = {
-omap_uart_read,
-omap_uart_read,
-omap_badwidth_read8,
-};
-
-static CPUWriteMemoryFunc * const omap_uart_writefn[] = {
-omap_uart_write,
-omap_uart_write,
-omap_badwidth_write8,
-};
-
-struct omap_uart_s *omap2_uart_init(struct omap_target_agent_s *ta,
-qemu_irq irq, omap_clk fclk, omap_clk iclk,
-   

[Qemu-devel] [PATCH v2 08/12] hw/omap2.c : separate spi module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap.h   |2 +
 hw/omap2.c  |  323 ---
 hw/omap_spi.c   |  346 +++
 4 files changed, 349 insertions(+), 324 deletions(-)
 create mode 100644 hw/omap_spi.c

diff --git a/Makefile.target b/Makefile.target
index 5afafe3..d532dc8 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o omap_intc.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o omap_spi.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap.h b/hw/omap.h
index ea23ec9..fef495a 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -706,12 +706,14 @@ struct omap_uwire_s *omap_uwire_init(target_phys_addr_t 
base,
 void omap_uwire_attach(struct omap_uwire_s *s,
 uWireSlave *slave, int chipselect);
 
+/* OMAP2 spi */
 struct omap_mcspi_s;
 struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum,
 qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk);
 void omap_mcspi_attach(struct omap_mcspi_s *s,
 uint32_t (*txrx)(void *opaque, uint32_t, int), void *opaque,
 int chipselect);
+void omap_mcspi_reset(struct omap_mcspi_s *s);
 
 struct omap_rtc_s;
 struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
diff --git a/hw/omap2.c b/hw/omap2.c
index e6d1b52..ae6394e 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -27,329 +27,6 @@
 #include soc_dma.h
 #include audio/audio.h
 
-/* Multichannel SPI */
-struct omap_mcspi_s {
-qemu_irq irq;
-int chnum;
-
-uint32_t sysconfig;
-uint32_t systest;
-uint32_t irqst;
-uint32_t irqen;
-uint32_t wken;
-uint32_t control;
-
-struct omap_mcspi_ch_s {
-qemu_irq txdrq;
-qemu_irq rxdrq;
-uint32_t (*txrx)(void *opaque, uint32_t, int);
-void *opaque;
-
-uint32_t tx;
-uint32_t rx;
-
-uint32_t config;
-uint32_t status;
-uint32_t control;
-} ch[4];
-};
-
-static inline void omap_mcspi_interrupt_update(struct omap_mcspi_s *s)
-{
-qemu_set_irq(s-irq, s-irqst  s-irqen);
-}
-
-static inline void omap_mcspi_dmarequest_update(struct omap_mcspi_ch_s *ch)
-{
-qemu_set_irq(ch-txdrq,
-(ch-control  1)/* EN */
-(ch-config  (1  14)) /* DMAW */
-(ch-status  (1  1))  /* TXS */
-((ch-config  12)  3) != 1);/* TRM */
-qemu_set_irq(ch-rxdrq,
-(ch-control  1)/* EN */
-(ch-config  (1  15)) /* DMAW */
-(ch-status  (1  0))  /* RXS */
-((ch-config  12)  3) != 2);/* TRM */
-}
-
-static void omap_mcspi_transfer_run(struct omap_mcspi_s *s, int chnum)
-{
-struct omap_mcspi_ch_s *ch = s-ch + chnum;
-
-if (!(ch-control  1))/* EN */
-return;
-if ((ch-status  (1  0))  /* RXS */
-((ch-config  12)  3) != 2/* TRM */
-!(ch-config  (1  19))) /* TURBO */
-goto intr_update;
-if ((ch-status  (1  1))  /* TXS */
-((ch-config  12)  3) != 1) /* TRM */
-goto intr_update;
-
-if (!(s-control  1) ||   /* SINGLE */
-(ch-config  (1  20))) {/* FORCE */
-if (ch-txrx)
-ch-rx = ch-txrx(ch-opaque, ch-tx,  /* WL */
-1 + (0x1f  (ch-config  7)));
-}
-
-ch-tx = 0;
-ch-status |= 1  2;  /* EOT */
-ch-status |= 1  1;  /* TXS */
-if (((ch-config  12)  3) != 2) /* TRM */
-ch-status |= 1  0;  /* RXS */
-
-intr_update:
-if ((ch-status  (1  0))  /* RXS */
-((ch-config  12)  3) != 2/* TRM */
-!(ch-config  (1  19))) /* TURBO */
-s-irqst |= 1  (2 + 4 * chnum);  /* RX_FULL */
-if ((ch-status  (1  1))  /* TXS */
-((ch-config  12)  3) != 1) /* TRM */
-s-irqst |= 1  (0 + 4 * chnum);  /* TX_EMPTY */
-omap_mcspi_interrupt_update(s);
-

[Qemu-devel] [PATCH v2 10/12] hw/omwp2.c : separate l4 interconnect module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |3 +-
 hw/omap.h   |   37 ++--
 hw/omap2.c  |  269 ++-
 hw/omap_l4.c|  271 +++
 4 files changed, 307 insertions(+), 273 deletions(-)
 create mode 100644 hw/omap_l4.c

diff --git a/Makefile.target b/Makefile.target
index b80d5e0..55dbf67 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,8 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o omap_intc.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o omap_spi.o omap_tap.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
+   omap_gpmc.o omap_sdrc.o omap_spi.o omap_tap.o omap_l4.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap.h b/hw/omap.h
index fef495a..34443b4 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -61,15 +61,40 @@ void omap_clk_setrate(omap_clk clk, int divide, int 
multiply);
 int64_t omap_clk_getrate(omap_clk clk);
 void omap_clk_reparent(omap_clk clk, omap_clk parent);
 
-/* omap[123].c */
+/* OMAP2 l4 Interconnect */
 struct omap_l4_s;
+struct omap_l4_region_s {
+target_phys_addr_t offset;
+size_t size;
+int access;
+};
+struct omap_l4_agent_info_s {
+int ta;
+int region;
+int regions;
+int ta_region;
+};
+struct omap_target_agent_s {
+struct omap_l4_s *bus;
+int regions;
+const struct omap_l4_region_s *start;
+target_phys_addr_t base;
+uint32_t component;
+uint32_t control;
+uint32_t status;
+};
 struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num);
 
 struct omap_target_agent_s;
-struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus, int cs);
+struct omap_target_agent_s *omap_l4ta_get(
+struct omap_l4_s *bus,
+const struct omap_l4_region_s *regions,
+const struct omap_l4_agent_info_s *agents,
+int cs);
 target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region,
 int iotype);
-# define l4_register_io_memory cpu_register_io_memory
+int l4_register_io_memory(CPUReadMemoryFunc * const *mem_read,
+CPUWriteMemoryFunc * const *mem_write, void *opaque);
 
 /* OMAP interrupt controller */
 struct omap_intr_handler_s;
@@ -1146,10 +1171,4 @@ inline static int 
debug_register_io_memory(CPUReadMemoryFunc * const *mem_read,
 /* Define when we want to reduce the number of IO regions registered.  */
 /*# define L4_MUX_HACK*/
 
-# ifdef L4_MUX_HACK
-#  undef l4_register_io_memory
-int l4_register_io_memory(CPUReadMemoryFunc * const *mem_read,
-  CPUWriteMemoryFunc * const *mem_write, void *opaque);
-# endif
-
 #endif /* hw_omap_h */
diff --git a/hw/omap2.c b/hw/omap2.c
index 7403077..9bac954 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -795,195 +795,10 @@ static struct omap_sti_s *omap_sti_init(struct 
omap_target_agent_s *ta,
 }
 
 /* L4 Interconnect */
-struct omap_target_agent_s {
-struct omap_l4_s *bus;
-int regions;
-struct omap_l4_region_s *start;
-target_phys_addr_t base;
-uint32_t component;
-uint32_t control;
-uint32_t status;
-};
-
-struct omap_l4_s {
-target_phys_addr_t base;
-int ta_num;
-struct omap_target_agent_s ta[0];
-};
-
-#ifdef L4_MUX_HACK
-static int omap_l4_io_entries;
-static int omap_cpu_io_entry;
-static struct omap_l4_entry {
-CPUReadMemoryFunc * const *mem_read;
-CPUWriteMemoryFunc * const *mem_write;
-void *opaque;
-} *omap_l4_io_entry;
-static CPUReadMemoryFunc * const *omap_l4_io_readb_fn;
-static CPUReadMemoryFunc * const *omap_l4_io_readh_fn;
-static CPUReadMemoryFunc * const *omap_l4_io_readw_fn;
-static CPUWriteMemoryFunc * const *omap_l4_io_writeb_fn;
-static CPUWriteMemoryFunc * const *omap_l4_io_writeh_fn;
-static CPUWriteMemoryFunc * const *omap_l4_io_writew_fn;
-static void **omap_l4_io_opaque;
-
-int l4_register_io_memory(CPUReadMemoryFunc * const *mem_read,
-CPUWriteMemoryFunc * const *mem_write, void *opaque)
-{
-omap_l4_io_entry[omap_l4_io_entries].mem_read = mem_read;
-omap_l4_io_entry[omap_l4_io_entries].mem_write = mem_write;
-omap_l4_io_entry[omap_l4_io_entries].opaque = opaque;
-
-return omap_l4_io_entries ++;
-}
-
-static uint32_t omap_l4_io_readb(void *opaque, target_phys_addr_t addr)
-{
-unsigned int i = (addr - OMAP2_L4_BASE)  TARGET_PAGE_BITS;
-
-return omap_l4_io_readb_fn[i](omap_l4_io_opaque[i], addr);
-}
-
-static uint32_t omap_l4_io_readh(void *opaque, target_phys_addr_t addr)
-{
-unsigned int i = (addr - 

[Qemu-devel] [PATCH v2 07/12] hw/omap1.c : separate interrupt controller module

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap.h   |2 +
 hw/omap1.c  |  576 +
 hw/omap_intc.c  |  598 +++
 4 files changed, 603 insertions(+), 575 deletions(-)
 create mode 100644 hw/omap_intc.c

diff --git a/Makefile.target b/Makefile.target
index 65be71b..5afafe3 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -264,7 +264,7 @@ obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o 
pxa2xx_timer.o pxa2xx_dma.o
 obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
-obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o
+obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o omap_intc.o
 obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
diff --git a/hw/omap.h b/hw/omap.h
index ad4a465..ea23ec9 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -71,6 +71,7 @@ target_phys_addr_t omap_l4_attach(struct omap_target_agent_s 
*ta, int region,
 int iotype);
 # define l4_register_io_memory cpu_register_io_memory
 
+/* OMAP interrupt controller */
 struct omap_intr_handler_s;
 struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base,
 unsigned long size, unsigned char nbanks, qemu_irq **pins,
@@ -80,6 +81,7 @@ struct omap_intr_handler_s 
*omap2_inth_init(target_phys_addr_t base,
 qemu_irq parent_irq, qemu_irq parent_fiq,
 omap_clk fclk, omap_clk iclk);
 void omap_inth_reset(struct omap_intr_handler_s *s);
+qemu_irq omap_inth_get_pin(struct omap_intr_handler_s *s, int n);
 
 struct omap_prcm_s;
 struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta,
diff --git a/hw/omap1.c b/hw/omap1.c
index 8b78c05..21c53fe 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -79,578 +79,6 @@ void omap_badwidth_write32(void *opaque, target_phys_addr_t 
addr,
 cpu_physical_memory_write(addr, (void *) value, 4);
 }
 
-/* Interrupt Handlers */
-struct omap_intr_handler_bank_s {
-uint32_t irqs;
-uint32_t inputs;
-uint32_t mask;
-uint32_t fiq;
-uint32_t sens_edge;
-uint32_t swi;
-unsigned char priority[32];
-};
-
-struct omap_intr_handler_s {
-qemu_irq *pins;
-qemu_irq parent_intr[2];
-unsigned char nbanks;
-int level_only;
-
-/* state */
-uint32_t new_agr[2];
-int sir_intr[2];
-int autoidle;
-uint32_t mask;
-struct omap_intr_handler_bank_s bank[];
-};
-
-static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq)
-{
-int i, j, sir_intr, p_intr, p, f;
-uint32_t level;
-sir_intr = 0;
-p_intr = 255;
-
-/* Find the interrupt line with the highest dynamic priority.
- * Note: 0 denotes the hightest priority.
- * If all interrupts have the same priority, the default order is IRQ_N,
- * IRQ_N-1,...,IRQ_0. */
-for (j = 0; j  s-nbanks; ++j) {
-level = s-bank[j].irqs  ~s-bank[j].mask 
-(is_fiq ? s-bank[j].fiq : ~s-bank[j].fiq);
-for (f = ffs(level), i = f - 1, level = f - 1; f; i += f,
-level = f) {
-p = s-bank[j].priority[i];
-if (p = p_intr) {
-p_intr = p;
-sir_intr = 32 * j + i;
-}
-f = ffs(level  1);
-}
-}
-s-sir_intr[is_fiq] = sir_intr;
-}
-
-static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
-{
-int i;
-uint32_t has_intr = 0;
-
-for (i = 0; i  s-nbanks; ++i)
-has_intr |= s-bank[i].irqs  ~s-bank[i].mask 
-(is_fiq ? s-bank[i].fiq : ~s-bank[i].fiq);
-
-if (s-new_agr[is_fiq]  has_intr  s-mask) {
-s-new_agr[is_fiq] = 0;
-omap_inth_sir_update(s, is_fiq);
-qemu_set_irq(s-parent_intr[is_fiq], 1);
-}
-}
-
-#define INT_FALLING_EDGE   0
-#define INT_LOW_LEVEL  1
-
-static void omap_set_intr(void *opaque, int irq, int req)
-{
-struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque;
-uint32_t rise;
-
-struct omap_intr_handler_bank_s *bank = ih-bank[irq  5];
-int n = irq  31;
-
-if (req) {
-rise = ~bank-irqs  (1  n);
-if (~bank-sens_edge  (1  n))
-rise = ~bank-inputs;
-
-bank-inputs |= (1  n);
-if (rise) {
-bank-irqs |= rise;
-omap_inth_update(ih, 0);
-omap_inth_update(ih, 1);
-}
-} else {
-rise = bank-sens_edge  bank-irqs  (1  n);
-bank-irqs = ~rise;
-bank-inputs = ~(1  n);
-}
-}
-
-/* Simplified version with no edge detection */
-static void omap_set_intr_noedge(void 

[Qemu-devel] [PATCH v2 09/12] hw/omap2.c : separate tap module(Test-Chip-level)

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap2.c  |   90 
 hw/omap_tap.c   |  112 +++
 3 files changed, 113 insertions(+), 91 deletions(-)
 create mode 100644 hw/omap_tap.c

diff --git a/Makefile.target b/Makefile.target
index d532dc8..b80d5e0 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o omap_intc.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o omap_spi.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o omap_spi.o omap_tap.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap2.c b/hw/omap2.c
index ae6394e..7403077 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -1245,96 +1245,6 @@ target_phys_addr_t omap_l4_attach(struct 
omap_target_agent_s *ta, int region,
 return base;
 }
 
-/* TEST-Chip-level TAP */
-static uint32_t omap_tap_read(void *opaque, target_phys_addr_t addr)
-{
-struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
-
-switch (addr) {
-case 0x204:/* IDCODE_reg */
-switch (s-mpu_model) {
-case omap2420:
-case omap2422:
-case omap2423:
-return 0x5b5d902f; /* ES 2.2 */
-case omap2430:
-return 0x5b68a02f; /* ES 2.2 */
-case omap3430:
-return 0x1b7ae02f; /* ES 2 */
-default:
-hw_error(%s: Bad mpu model\n, __FUNCTION__);
-}
-
-case 0x208:/* PRODUCTION_ID_reg for OMAP2 */
-case 0x210:/* PRODUCTION_ID_reg for OMAP3 */
-switch (s-mpu_model) {
-case omap2420:
-return 0x000254f0; /* POP ESHS2.1.1 in N91/93/95, ES2 in N800 */
-case omap2422:
-return 0x000400f0;
-case omap2423:
-return 0x000800f0;
-case omap2430:
-return 0x00f0;
-case omap3430:
-return 0x00f0;
-default:
-hw_error(%s: Bad mpu model\n, __FUNCTION__);
-}
-
-case 0x20c:
-switch (s-mpu_model) {
-case omap2420:
-case omap2422:
-case omap2423:
-return 0xcafeb5d9; /* ES 2.2 */
-case omap2430:
-return 0xcafeb68a; /* ES 2.2 */
-case omap3430:
-return 0xcafeb7ae; /* ES 2 */
-default:
-hw_error(%s: Bad mpu model\n, __FUNCTION__);
-}
-
-case 0x218:/* DIE_ID_reg */
-return ('Q'  24) | ('E'  16) | ('M'  8) | ('U'  0);
-case 0x21c:/* DIE_ID_reg */
-return 0x54  24;
-case 0x220:/* DIE_ID_reg */
-return ('Q'  24) | ('E'  16) | ('M'  8) | ('U'  0);
-case 0x224:/* DIE_ID_reg */
-return ('Q'  24) | ('E'  16) | ('M'  8) | ('U'  0);
-}
-
-OMAP_BAD_REG(addr);
-return 0;
-}
-
-static void omap_tap_write(void *opaque, target_phys_addr_t addr,
-uint32_t value)
-{
-OMAP_BAD_REG(addr);
-}
-
-static CPUReadMemoryFunc * const omap_tap_readfn[] = {
-omap_badwidth_read32,
-omap_badwidth_read32,
-omap_tap_read,
-};
-
-static CPUWriteMemoryFunc * const omap_tap_writefn[] = {
-omap_badwidth_write32,
-omap_badwidth_write32,
-omap_tap_write,
-};
-
-void omap_tap_init(struct omap_target_agent_s *ta,
-struct omap_mpu_state_s *mpu)
-{
-omap_l4_attach(ta, 0, l4_register_io_memory(
-omap_tap_readfn, omap_tap_writefn, mpu));
-}
-
 /* Power, Reset, and Clock Management */
 struct omap_prcm_s {
 qemu_irq irq[3];
diff --git a/hw/omap_tap.c b/hw/omap_tap.c
new file mode 100644
index 000..1f18ddd
--- /dev/null
+++ b/hw/omap_tap.c
@@ -0,0 +1,112 @@
+/*
+ * TI OMAP TEST-Chip-level TAP emulation.
+ *
+ * Copyright (C) 2007-2008 Nokia Corporation
+ * Written by Andrzej Zaborowski and...@openedhand.com
+ *
+ * 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) any later version 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, see http://www.gnu.org/licenses/.
+ 

[Qemu-devel] [PATCH v2 06/12] hw/omap2.c : separate sdrc (sdram controller)

2010-05-31 Thread cmchao

Signed-off-by: cmchao cmc...@gmail.com
---
 Makefile.target |2 +-
 hw/omap.h   |2 +
 hw/omap2.c  |  144 
 hw/omap_sdrc.c  |  165 +++
 4 files changed, 168 insertions(+), 145 deletions(-)
 create mode 100644 hw/omap_sdrc.c

diff --git a/Makefile.target b/Makefile.target
index b932f79..65be71b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o 
pxa2xx_keypad.o
 obj-arm-y += gumstix.o
 obj-arm-y += zaurus.o ide/microdrive.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o 
omap_gpio.o
-obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o
+obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o 
omap_gpmc.o omap_sdrc.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
diff --git a/hw/omap.h b/hw/omap.h
index c596953..ad4a465 100644
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -90,8 +90,10 @@ struct omap_sysctl_s;
 struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
 omap_clk iclk, struct omap_mpu_state_s *mpu);
 
+/* OMAP2 SDRAM controller */
 struct omap_sdrc_s;
 struct omap_sdrc_s *omap_sdrc_init(target_phys_addr_t base);
+void omap_sdrc_reset(struct omap_sdrc_s *s);
 
 /* OMAP2 general purpose memory controller */
 struct omap_gpmc_s;
diff --git a/hw/omap2.c b/hw/omap2.c
index b1e5aae..e6d1b52 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -2844,150 +2844,6 @@ struct omap_sysctl_s *omap_sysctl_init(struct 
omap_target_agent_s *ta,
 return s;
 }
 
-/* SDRAM Controller Subsystem */
-struct omap_sdrc_s {
-uint8_t config;
-};
-
-static void omap_sdrc_reset(struct omap_sdrc_s *s)
-{
-s-config = 0x10;
-}
-
-static uint32_t omap_sdrc_read(void *opaque, target_phys_addr_t addr)
-{
-struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
-
-switch (addr) {
-case 0x00: /* SDRC_REVISION */
-return 0x20;
-
-case 0x10: /* SDRC_SYSCONFIG */
-return s-config;
-
-case 0x14: /* SDRC_SYSSTATUS */
-return 1;  /* RESETDONE */
-
-case 0x40: /* SDRC_CS_CFG */
-case 0x44: /* SDRC_SHARING */
-case 0x48: /* SDRC_ERR_ADDR */
-case 0x4c: /* SDRC_ERR_TYPE */
-case 0x60: /* SDRC_DLLA_SCTRL */
-case 0x64: /* SDRC_DLLA_STATUS */
-case 0x68: /* SDRC_DLLB_CTRL */
-case 0x6c: /* SDRC_DLLB_STATUS */
-case 0x70: /* SDRC_POWER */
-case 0x80: /* SDRC_MCFG_0 */
-case 0x84: /* SDRC_MR_0 */
-case 0x88: /* SDRC_EMR1_0 */
-case 0x8c: /* SDRC_EMR2_0 */
-case 0x90: /* SDRC_EMR3_0 */
-case 0x94: /* SDRC_DCDL1_CTRL */
-case 0x98: /* SDRC_DCDL2_CTRL */
-case 0x9c: /* SDRC_ACTIM_CTRLA_0 */
-case 0xa0: /* SDRC_ACTIM_CTRLB_0 */
-case 0xa4: /* SDRC_RFR_CTRL_0 */
-case 0xa8: /* SDRC_MANUAL_0 */
-case 0xb0: /* SDRC_MCFG_1 */
-case 0xb4: /* SDRC_MR_1 */
-case 0xb8: /* SDRC_EMR1_1 */
-case 0xbc: /* SDRC_EMR2_1 */
-case 0xc0: /* SDRC_EMR3_1 */
-case 0xc4: /* SDRC_ACTIM_CTRLA_1 */
-case 0xc8: /* SDRC_ACTIM_CTRLB_1 */
-case 0xd4: /* SDRC_RFR_CTRL_1 */
-case 0xd8: /* SDRC_MANUAL_1 */
-return 0x00;
-}
-
-OMAP_BAD_REG(addr);
-return 0;
-}
-
-static void omap_sdrc_write(void *opaque, target_phys_addr_t addr,
-uint32_t value)
-{
-struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
-
-switch (addr) {
-case 0x00: /* SDRC_REVISION */
-case 0x14: /* SDRC_SYSSTATUS */
-case 0x48: /* SDRC_ERR_ADDR */
-case 0x64: /* SDRC_DLLA_STATUS */
-case 0x6c: /* SDRC_DLLB_STATUS */
-OMAP_RO_REG(addr);
-return;
-
-case 0x10: /* SDRC_SYSCONFIG */
-if ((value  3) != 0x2)
-fprintf(stderr, %s: bad SDRAM idle mode %i\n,
-__FUNCTION__, value  3);
-if (value  2)
-omap_sdrc_reset(s);
-s-config = value  0x18;
-break;
-
-case 0x40: /* SDRC_CS_CFG */
-case 0x44: /* SDRC_SHARING */
-case 0x4c: /* SDRC_ERR_TYPE */
-case 0x60: /* SDRC_DLLA_SCTRL */
-case 0x68: /* SDRC_DLLB_CTRL */
-case 0x70: /* SDRC_POWER */
-case 0x80: /* SDRC_MCFG_0 */
-case 0x84: /* SDRC_MR_0 */
-case 0x88: /* SDRC_EMR1_0 */
-case 0x8c: /* SDRC_EMR2_0 */
-case 0x90: /* SDRC_EMR3_0 */
-case 0x94: /* SDRC_DCDL1_CTRL */
-case 0x98: /* SDRC_DCDL2_CTRL */
-case 0x9c: /* SDRC_ACTIM_CTRLA_0 */
-case 0xa0: /* SDRC_ACTIM_CTRLB_0 */
-case 0xa4: /* SDRC_RFR_CTRL_0 */
-case 0xa8: /* SDRC_MANUAL_0 */
-case 0xb0: /* SDRC_MCFG_1 */
-case 0xb4: /* SDRC_MR_1 */
-case 0xb8: /* SDRC_EMR1_1 */
-case 0xbc: /* SDRC_EMR2_1 */
-case 0xc0: /* SDRC_EMR3_1 */
-case 

Re: [Qemu-devel] Unable to install Windows XP and 2003 with libvirt

2010-05-31 Thread Laurent Léonard
Le mardi 25 mai 2010 00:27:29, Bruce Rogers a écrit :
   On 5/24/2010 at 05:43 AM, Laurent Léonardlaur...@open-minds.org 
wrote:
  The problem has already been reported on the list here :
  http://lists.nongnu.org/archive/html/qemu-devel/2010-03/msg01725.html
  
  Any information on what can be done to solve that problem ? Is there any
  available patch for KVM ?
  
  Thank you,
 
 I sent privately to Laurent the patch I build kvm with, but it needs some
 tweaking before I resubmit it to address concerns. I hope to get to that
 soon.
 
 Bruce

Any official news about that critical bug for Windows XP users ?

Thank you.

-- 
Laurent Léonard



Re: [Qemu-devel] [PATCH v2 5/6] MIPS: Initial support of fulong mini pc (CPU definition, machine construction, etc.)

2010-05-31 Thread Aurelien Jarno
On Mon, May 31, 2010 at 10:35:03PM +0800, chen huacai wrote:
 On Sat, May 29, 2010 at 4:56 AM, Aurelien Jarno aurel...@aurel32.net wrote:
  Please find my comments below.
 
  On Wed, May 19, 2010 at 10:28:36PM +0800, Huacai Chen wrote:
  Signed-off-by: Huacai Chen zltjiang...@gmail.com
  ---
   Makefile.target              |    2 +-
   hw/mips_fulong2e.c           |  421 
  ++
   target-mips/translate_init.c |   35 
   3 files changed, 457 insertions(+), 1 deletions(-)
   create mode 100644 hw/mips_fulong2e.c
 
  diff --git a/Makefile.target b/Makefile.target
  index 9ed4a8d..db4badd 100644
  --- a/Makefile.target
  +++ b/Makefile.target
  @@ -221,7 +221,7 @@ obj-mips-y += dma.o vga.o i8259.o
   obj-mips-y += g364fb.o jazz_led.o
   obj-mips-y += gt64xxx.o pckbd.o mc146818rtc.o
   obj-mips-y += piix4.o cirrus_vga.o
  -obj-mips-$(CONFIG_FULONG) += bonito.o vt82c686.o
  +obj-mips-$(CONFIG_FULONG) += bonito.o vt82c686.o mips_fulong2e.o
 
   obj-microblaze-y = petalogix_s3adsp1800_mmu.o
 
  diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
  new file mode 100644
  index 000..3e6ed7e
  --- /dev/null
  +++ b/hw/mips_fulong2e.c
  @@ -0,0 +1,421 @@
  +/*
  + * QEMU fulong 2e mini pc support
  + *
  + * Copyright (c) 2008 yajin (ya...@vm-kernel.org)
  + * Copyright (c) 2009 chenming (chenm...@rdc.faw.com.cn)
  + * Copyright (c) 2010 Huacai Chen (zltjiang...@gmail.com)
  + * This code is licensed under the GNU GPL v2.
  + */
  +
  +/*
  + * Fulong 2e mini pc is based on ICT/ST Loongson 2e CPU (MIPS III like, 
  800MHz)
  + * http://www.linux-mips.org/wiki/Fulong
  + *
  + * Loongson 2e user manual:
  + * http://www.loongsondeveloper.com/doc/Loongson2EUserGuide.pdf
  + */
  +
  +#include hw.h
  +#include pc.h
  +#include fdc.h
  +#include net.h
  +#include boards.h
  +#include smbus.h
  +#include block.h
  +#include flash.h
  +#include mips.h
  +#include mips_cpudevs.h
  +#include pci.h
  +#include usb-uhci.h
  +#include qemu-char.h
  +#include sysemu.h
  +#include audio/audio.h
  +#include qemu-log.h
  +#include loader.h
  +#include mips-bios.h
  +#include ide.h
  +#include elf.h
  +#include mc146818rtc.h
  +
  +#define DEBUG_FULONG2E_INIT
  +
  +#define ENVP_ADDR       0x80002000l
  +#define ENVP_NB_ENTRIES              16
  +#define ENVP_ENTRY_SIZE              256
  +
  +#define MAX_IDE_BUS 2
  +
  +/* PCI SLOT in fulong 2e */
  +#define FULONG2E_VIA_SLOT        5
  +#define FULONG2E_ATI_SLOT        6
  +#define FULONG2E_RTL8139_SLOT    7
  +
  +static PITState *pit;
  +
  +static struct _loaderparams {
  +    int ram_size;
  +    const char *kernel_filename;
  +    const char *kernel_cmdline;
  +    const char *initrd_filename;
  +} loaderparams;
  +
  +static void mips_qemu_writel (void *opaque, target_phys_addr_t addr,
  +                           uint32_t val)
  +{
  +    if ((addr  0x) == 0  val == 42)
  +        qemu_system_reset_request ();
  +    else if ((addr  0x) == 4  val == 42)
  +        qemu_system_shutdown_request ();
 
  Coding style
 
  +}
  +
  +static uint32_t mips_qemu_readl (void *opaque, target_phys_addr_t addr)
  +{
  +    return 0;
  +}
  +
  +static CPUWriteMemoryFunc *mips_qemu_write[] = {
  +    mips_qemu_writel,
  +    mips_qemu_writel,
  +    mips_qemu_writel,
  +};
  +
  +static CPUReadMemoryFunc *mips_qemu_read[] = {
  +    mips_qemu_readl,
  +    mips_qemu_readl,
  +    mips_qemu_readl,
  +};
 
  If the same function is used for all width, it's probably better to call
  it with a name not ending with l.
 
 Do you means I should use mips_qemu_read to replace mips_qemu_readl? I
 think this may be more confusing, besides, I see too many examples to
 use an l suffix in qemu code.

IMHO the l suffix is fine as long as your function only works on
longs. Here it also works on bytes and words, so the name is not
correct.

Alternatively you can also define mips_qemu_readb and mips_qemu_readw.

  +static int mips_qemu_iomemtype = 0;
  +
  +static void prom_set(uint32_t* prom_buf, int index, const char *string, 
  ...)
  +{
  +    va_list ap;
  +    int32_t table_addr;
  +
  +    if (index = ENVP_NB_ENTRIES)
  +        return;
  +
  +    if (string == NULL) {
  +        prom_buf[index] = 0;
  +        return;
  +    }
  +
  +    table_addr = sizeof(int32_t) * ENVP_NB_ENTRIES + index * 
  ENVP_ENTRY_SIZE;
  +    prom_buf[index] = tswap32(ENVP_ADDR + table_addr);
  +
  +    va_start(ap, string);
  +    vsnprintf((char *)prom_buf + table_addr, ENVP_ENTRY_SIZE, string, ap);
  +    va_end(ap);
  +}
  +
  +static int64_t load_kernel (CPUState *env)
  +{
  +    int64_t kernel_entry, kernel_low, kernel_high;
  +    int index = 0;
  +    long initrd_size;
  +    ram_addr_t initrd_offset;
  +    uint32_t *prom_buf;
  +    long prom_size;
  +
  +    if (load_elf(loaderparams.kernel_filename, cpu_mips_kseg0_to_phys, 
  NULL,
  +                 (uint64_t *)kernel_entry, (uint64_t *)kernel_low,
  +                 (uint64_t *)kernel_high, 0, 

[Qemu-devel] [PATCH 1/3] monitor: Reorder info documentation

2010-05-31 Thread Luiz Capitulino
From: Jan Kiszka jan.kis...@siemens.com

Push the doc fragments for the info command to the end of
qemu-monitor.hx. This helps to establish a proper layout in the upcoming
QMP documentation.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
---
 qemu-monitor.hx |  186 --
 1 files changed, 96 insertions(+), 90 deletions(-)

diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index f4f88df..b8c765b 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -38,96 +38,6 @@ Commit changes to the disk images (if -snapshot is used) or 
backing files.
 ETEXI
 
 {
-.name   = info,
-.args_type  = item:s?,
-.params = [subcommand],
-.help   = show various information about the system state,
-.user_print = monitor_user_noop,
-.mhandler.cmd_new = do_info,
-},
-
-STEXI
-...@item info @var{subcommand}
-...@findex info
-Show various information about the system state.
-
-...@table @option
-...@item info version
-show the version of QEMU
-...@item info commands
-list QMP available commands
-...@item info network
-show the various VLANs and the associated devices
-...@item info chardev
-show the character devices
-...@item info block
-show the block devices
-...@item info blockstats
-show block device statistics
-...@item info registers
-show the cpu registers
-...@item info cpus
-show infos for each CPU
-...@item info history
-show the command line history
-...@item info irq
-show the interrupts statistics (if available)
-...@item info pic
-show i8259 (PIC) state
-...@item info pci
-show emulated PCI device info
-...@item info tlb
-show virtual to physical memory mappings (i386 only)
-...@item info mem
-show the active virtual memory mappings (i386 only)
-...@item info hpet
-show state of HPET (i386 only)
-...@item info jit
-show dynamic compiler info
-...@item info kvm
-show KVM information
-...@item info numa
-show NUMA information
-...@item info usb
-show USB devices plugged on the virtual USB hub
-...@item info usbhost
-show all USB host devices
-...@item info profile
-show profiling information
-...@item info capture
-show information about active capturing
-...@item info snapshots
-show list of VM snapshots
-...@item info status
-show the current VM status (running|paused)
-...@item info pcmcia
-show guest PCMCIA status
-...@item info mice
-show which guest mouse is receiving events
-...@item info vnc
-show the vnc server status
-...@item info name
-show the current VM name
-...@item info uuid
-show the current VM UUID
-...@item info cpustats
-show CPU statistics
-...@item info usernet
-show user network stack connection states
-...@item info migrate
-show migration status
-...@item info balloon
-show balloon information
-...@item info qtree
-show device tree
-...@item info qdm
-show qdev device model list
-...@item info roms
-show roms
-...@end table
-ETEXI
-
-{
 .name   = q|quit,
 .args_type  = ,
 .params = ,
@@ -1190,6 +1100,102 @@ STEXI
 Enable the specified QMP capabilities
 ETEXI
 
+
+HXCOMM Keep the 'info' command at the end!
+HXCOMM This is required for the QMP documentation layout.
+
+{
+.name   = info,
+.args_type  = item:s?,
+.params = [subcommand],
+.help   = show various information about the system state,
+.user_print = monitor_user_noop,
+.mhandler.cmd_new = do_info,
+},
+
+STEXI
+...@item info @var{subcommand}
+...@findex info
+Show various information about the system state.
+
+...@table @option
+...@item info version
+show the version of QEMU
+...@item info commands
+list QMP available commands
+...@item info network
+show the various VLANs and the associated devices
+...@item info chardev
+show the character devices
+...@item info block
+show the block devices
+...@item info blockstats
+show block device statistics
+...@item info registers
+show the cpu registers
+...@item info cpus
+show infos for each CPU
+...@item info history
+show the command line history
+...@item info irq
+show the interrupts statistics (if available)
+...@item info pic
+show i8259 (PIC) state
+...@item info pci
+show emulated PCI device info
+...@item info tlb
+show virtual to physical memory mappings (i386 only)
+...@item info mem
+show the active virtual memory mappings (i386 only)
+...@item info hpet
+show state of HPET (i386 only)
+...@item info jit
+show dynamic compiler info
+...@item info kvm
+show KVM information
+...@item info numa
+show NUMA information
+...@item info usb
+show USB devices plugged on the virtual USB hub
+...@item info usbhost
+show all USB host devices
+...@item info profile
+show profiling information
+...@item info capture
+show information about active capturing
+...@item info snapshots
+show list of VM snapshots
+...@item info status
+show the current VM status (running|paused)
+...@item info pcmcia
+show guest PCMCIA status
+...@item info mice
+show which guest mouse is receiving 

[Qemu-devel] [PATCH v4 0/3]: QMP: Commands doc

2010-05-31 Thread Luiz Capitulino
Rebase.. Let's try to merge this ASAP, please.

changelog
-

v3 - v4


- Rebased
- Minor commit log clarification

v2 - v3


- Rebased
- Addressed review comments
- Move contents to qemu-monitor.hx (Jan)

v1 - v2


- Rebased
- Addressed Markus's comments
- Changed indentation style
- Minor fixes and clarifications



[Qemu-devel] [PATCH 2/3] QMP: Introduce commands documentation

2010-05-31 Thread Luiz Capitulino
From: Jan Kiszka jan.kis...@siemens.com

One of the most important missing feature in QMP today is its
supported commands documentation.

The plan is to make it part of self-description support, however
self-description is a big task we have been postponing for a
long time now and still don't know when it's going to be done.

In order not to compromise QMP adoption and make users' life easier,
this commit adds a simple text documentation which fully describes
all QMP supported commands.

This is not ideal for a number of reasons (harder to maintain,
text-only, etc) but does improve the current situation. To avoid at
least divering from the user monitor help and texi snippets, QMP bits
are also maintained inside qemu-monitor.hx, and hxtool is extended to
generate a single text file from them.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
Signed-off-by: Luiz Capitulino lcapitul...@redhat.com
---
 Makefile|5 +-
 QMP/README  |5 +-
 configure   |4 +
 hxtool  |   44 ++-
 qemu-monitor.hx | 1322 +++
 5 files changed, 1376 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 7986bf6..3a8a311 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 LIBS+=-lz $(LIBS_TOOLS)
 
 ifdef BUILD_DOCS
-DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8
+DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 
QMP/qmp-commands.txt
 else
 DOCS=
 endif
@@ -259,6 +259,9 @@ qemu-options.texi: $(SRC_PATH)/qemu-options.hx
 qemu-monitor.texi: $(SRC_PATH)/qemu-monitor.hx
$(call quiet-command,sh $(SRC_PATH)/hxtool -t  $  $@,  GEN   $@)
 
+QMP/qmp-commands.txt: $(SRC_PATH)/qemu-monitor.hx
+   $(call quiet-command,sh $(SRC_PATH)/hxtool -q  $  $@,  GEN   $@)
+
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
$(call quiet-command,sh $(SRC_PATH)/hxtool -t  $  $@,  GEN   $@)
 
diff --git a/QMP/README b/QMP/README
index 9334c25..35a80c7 100644
--- a/QMP/README
+++ b/QMP/README
@@ -15,8 +15,9 @@ QMP is JSON[1] based and has the following features:
 
 For more information, please, refer to the following files:
 
-o qmp-spec.txtQEMU Monitor Protocol current specification
-o qmp-events.txt  List of available asynchronous events
+o qmp-spec.txt  QEMU Monitor Protocol current specification
+o qmp-commands.txt  QMP supported commands
+o qmp-events.txtList of available asynchronous events
 
 There are also two simple Python scripts available:
 
diff --git a/configure b/configure
index 3cd2c5f..653c8d2 100755
--- a/configure
+++ b/configure
@@ -2817,3 +2817,7 @@ ln -s $source_path/Makefile.user $d/Makefile
 if test $static = no -a $user_pie = yes ; then
   echo QEMU_CFLAGS+=-fpie  $d/config.mak
 fi
+
+if test $docs = yes ; then
+  mkdir -p QMP
+fi
diff --git a/hxtool b/hxtool
index 8f65532..d499dc0 100644
--- a/hxtool
+++ b/hxtool
@@ -7,7 +7,7 @@ hxtoh()
 case $str in
 HXCOMM*)
 ;;
-STEXI*|ETEXI*) flag=$(($flag^1))
+STEXI*|ETEXI*|SQMP*|EQMP*) flag=$(($flag^1))
 ;;
 *)
 test $flag -eq 1  printf %s\n $str
@@ -38,6 +38,12 @@ hxtotexi()
 fi
 flag=0
 ;;
+SQMP*|EQMP*)
+if test $flag -eq 1 ; then
+echo line $line: syntax error: expected ETEXI, found $str 2
+exit 1
+fi
+;;
 DEFHEADING*)
 echo $(expr $str : DEFHEADING(\(.*\)))
 ;;
@@ -49,9 +55,45 @@ hxtotexi()
 done
 }
 
+hxtoqmp()
+{
+IFS=
+flag=0
+while read -r str; do
+case $str in
+HXCOMM*)
+;;
+SQMP*)
+if test $flag -eq 1 ; then
+echo line $line: syntax error: expected EQMP, found $str 2
+exit 1
+fi
+flag=1
+;;
+EQMP*)
+if test $flag -ne 1 ; then
+echo line $line: syntax error: expected SQMP, found $str 2
+exit 1
+fi
+flag=0
+;;
+STEXI*|ETEXI*)
+if test $flag -eq 1 ; then
+echo line $line: syntax error: expected EQMP, found $str 2
+exit 1
+fi
+;;
+*)
+test $flag -eq 1  echo $str
+;;
+esac
+done
+}
+
 case $1 in
 -h) hxtoh ;;
 -t) hxtotexi ;;
+-q) hxtoqmp ;;
 *) exit 1 ;;
 esac
 
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index b8c765b..f6a94f2 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1,10 +1,48 @@
 HXCOMM Use DEFHEADING() to define headings in both help text and texi
 HXCOMM Text between STEXI and ETEXI are copied to texi version and
 HXCOMM discarded from C version
+HXCOMM Text between SQMP and EQMP is copied to the QMP documention file and
+HXCOMM does not show up in the other formats.
 

[Qemu-devel] [PATCH 3/3] Monitor: Drop QMP documentation from code

2010-05-31 Thread Luiz Capitulino
Previous commit added QMP documentation to the qemu-monitor.hx
file, it's is a copy of this information.

While it's good to keep it near code, maintaining two copies of
the same information is too hard and has little benefit as we
don't expect client writers to consult the code to find how to
use a QMP command.

Signed-off-by: Luiz Capitulino lcapitul...@redhat.com
---
 block.c |   69 
 hw/pci.c|   61 ---
 hw/qdev.c   |   13 ---
 input.c |   18 --
 migration.c |   38 --
 monitor.c   |  102 ---
 net.c   |   22 -
 qemu-char.c |   16 -
 vnc.c   |   29 -
 9 files changed, 0 insertions(+), 368 deletions(-)

diff --git a/block.c b/block.c
index cd70730..67f0998 100644
--- a/block.c
+++ b/block.c
@@ -1444,33 +1444,6 @@ void bdrv_info_print(Monitor *mon, const QObject *data)
 qlist_iter(qobject_to_qlist(data), bdrv_print_dict, mon);
 }
 
-/**
- * bdrv_info(): Block devices information
- *
- * Each block device information is stored in a QDict and the
- * returned QObject is a QList of all devices.
- *
- * The QDict contains the following:
- *
- * - device: device name
- * - type: device type
- * - removable: true if the device is removable, false otherwise
- * - locked: true if the device is locked, false otherwise
- * - inserted: only present if the device is inserted, it is a QDict
- *containing the following:
- *  - file: device file name
- *  - ro: true if read-only, false otherwise
- *  - drv: driver format name
- *  - backing_file: backing file name if one is used
- *  - encrypted: true if encrypted, false otherwise
- *
- * Example:
- *
- * [ { device: ide0-hd0, type: hd, removable: false, locked: false,
- * inserted: { file: /tmp/foobar, ro: false, drv: qcow2 } },
- *   { device: floppy0, type: floppy, removable: true,
- * locked: false } ]
- */
 void bdrv_info(Monitor *mon, QObject **ret_data)
 {
 QList *bs_list;
@@ -1576,48 +1549,6 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
 return res;
 }
 
-/**
- * bdrv_info_stats(): show block device statistics
- *
- * Each device statistic information is stored in a QDict and
- * the returned QObject is a QList of all devices.
- *
- * The QDict contains the following:
- *
- * - device: device name
- * - stats: A QDict with the statistics information, it contains:
- * - rd_bytes: bytes read
- * - wr_bytes: bytes written
- * - rd_operations: read operations
- * - wr_operations: write operations
- * - wr_highest_offset: Highest offset of a sector written since the
- *   BlockDriverState has been opened
- * - parent: A QDict recursively holding the statistics of the underlying
- *protocol (e.g. the host file for a qcow2 image). If there is no
- *underlying protocol, this field is omitted.
- *
- * Example:
- *
- * [ { device: ide0-hd0,
- *   stats: { rd_bytes: 512,
- *  wr_bytes: 0,
- *  rd_operations: 1,
- *  wr_operations: 0,
- *  wr_highest_offset: 0 },
- *   parent: {
- *  stats: { rd_bytes: 1024,
- * wr_bytes: 0,
- * rd_operations: 2,
- * wr_operations: 0,
- * wr_highest_offset: 0,
- *  } } },
- *   { device: ide1-cd0,
- *   stats: { rd_bytes: 0,
- *  wr_bytes: 0,
- *  rd_operations: 0,
- *  wr_operations: 0,
- *  wr_highest_offset: 0 } },
- */
 void bdrv_info_stats(Monitor *mon, QObject **ret_data)
 {
 QObject *obj;
diff --git a/hw/pci.c b/hw/pci.c
index 8d84651..4636193 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1362,67 +1362,6 @@ static QObject *pci_get_bus_dict(PCIBus *bus, int 
bus_num)
 return NULL;
 }
 
-/**
- * do_pci_info(): PCI buses and devices information
- *
- * The returned QObject is a QList of all buses. Each bus is
- * represented by a QDict, which has a key with a QList of all
- * PCI devices attached to it. Each device is represented by
- * a QDict.
- *
- * The bus QDict contains the following:
- *
- * - bus: bus number
- * - devices: a QList of QDicts, each QDict represents a PCI
- *   device
- *
- * The PCI device QDict contains the following:
- *
- * - bus: identical to the parent's bus number
- * - slot: slot number
- * - function: function number
- * - class_info: a QDict containing:
- *  - desc: device class description (optional)
- *  - class: device class number
- * - id: a QDict containing:
- *  - device: device ID
- *  - vendor: vendor ID
- * - irq: device's IRQ if assigned (optional)
- * - qdev_id: qdev 

[Qemu-devel] [Bug 587993] [NEW] qemu-kvm 0.12.4+dfsg-1 from debian squeeze crashes BUG: unable to handle kernel NULL pointer (sym53c8xx)

2010-05-31 Thread Maciek
Public bug reported:

I use eucalyptus software (1.6.2) on debian squeeze with kvm
0.12.4+dfsg-1. Kernel 2.6.32-3-amd64. After a few days machines crash.
There are no logs in host system. Guest is the same kernel and OS as
host. The kvm process use 100% of cpu time. I can not even ping the
guest. Here is the log from virtual machine:

[ 3577.81] sd 0:0:0:0: [sda] ABORT operation started
[ 3582.816047] sd 0:0:0:0: ABORT operation timed-out.
[ 3582.816781] sd 0:0:0:0: [sda] ABORT operation started
[ 3587.816649] sd 0:0:0:0: ABORT operation timed-out.
[ 3587.817379] sd 0:0:0:0: [sda] DEVICE RESET operation started
[ 3592.816062] sd 0:0:0:0: DEVICE RESET operation timed-out.
[ 3592.816882] sd 0:0:0:0: [sda] BUS RESET operation started
[ 3592.820056] sym0: SCSI BUS reset detected.
[ 3592.831538] sym0: SCSI BUS has been reset.
[ 3592.831968] BUG: unable to handle kernel NULL pointer dereference at 
0358
[ 3592.832003] IP: [a01147c4] sym_int_sir+0x62f/0x14e0 [sym53c8xx]
[ 3592.832003] PGD 5f73e067 PUD 5fa53067 PMD 0 
[ 3592.832003] Oops:  [#1] SMP 
[ 3592.832003] last sysfs file: 
/sys/devices/pci:00/:00:05.0/host0/target0:0:0/0:0:0:0/vendor
[ 3592.832003] CPU 0 
[ 3592.832003] Modules linked in: dm_mod openafs(P) ext2 snd_pcsp snd_pcm 
snd_timer serio_raw i2c_piix4 snd virtio_balloon evdev i2c_core soundcore 
psmouse button processor snd_page_alloc ext3 jbd mbcache sd_mod crc_t10dif 
ata_generic libata ide_pci_generic sym53c8xx scsi_transport_spi thermal piix 
uhci_hcd ehci_hcd floppy thermal_sys scsi_mod virtio_pci virtio_ring virtio 
e1000 ide_core usbcore nls_base [last unloaded: scsi_wait_scan]
[ 3592.832003] Pid: 193, comm: scsi_eh_0 Tainted: P   2.6.32-3-amd64 #1 
Bochs
[ 3592.832003] RIP: 0010:[a01147c4]  [a01147c4] 
sym_int_sir+0x62f/0x14e0 [sym53c8xx]
[ 3592.832003] RSP: 0018:880001803cb0  EFLAGS: 00010287
[ 3592.832003] RAX: 000a RBX: 000b RCX: 5f410090
[ 3592.832003] RDX:  RSI: 88005c450800 RDI: c9a5e006
[ 3592.832003] RBP: 88005f41 R08:  R09: 
[ 3592.832003] R10: 003a R11: 813b871e R12: 88005f410090
[ 3592.832003] R13: 0084 R14:  R15: 0001
[ 3592.832003] FS:  () GS:88000180() 
knlGS:
[ 3592.832003] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
[ 3592.832003] CR2: 0358 CR3: 5e269000 CR4: 06f0
[ 3592.832003] DR0:  DR1:  DR2: 
[ 3592.832003] DR3:  DR6: 0ff0 DR7: 0400
[ 3592.832003] Process scsi_eh_0 (pid: 193, threadinfo 88005f6fa000, task 
88005f697880)
[ 3592.832003] Stack:
[ 3592.832003]  88005f3fd000  0130 

[ 3592.832003] 0 88005f407710 c9a64710 ff10 
81195301
[ 3592.832003] 0 0010 00010212 880001803d18 
0018
[ 3592.832003] Call Trace:
[ 3592.832003]  IRQ 
[ 3592.832003]  [81195301] ? __memcpy_toio+0x9/0x19
[ 3592.832003]  [a01164ed] ? sym_interrupt+0x46c/0x6a3 [sym53c8xx]
[ 3592.832003]  [8103fea0] ? update_curr+0xa6/0x147
[ 3592.832003]  [a010fbde] ? sym53c8xx_intr+0x43/0x6a [sym53c8xx]
[ 3592.832003]  [81093bfc] ? handle_IRQ_event+0x58/0x126
[ 3592.832003]  [810954e2] ? handle_fasteoi_irq+0x7d/0xb5
[ 3592.832003]  [81013957] ? handle_irq+0x17/0x1d
[ 3592.832003]  [81012fb1] ? do_IRQ+0x57/0xb6
[ 3592.832003]  [810114d3] ? ret_from_intr+0x0/0x11
[ 3592.832003]  [81053903] ? __do_softirq+0x6e/0x19f
[ 3592.832003]  [8106fa87] ? tick_dev_program_event+0x2d/0x95
[ 3592.832003]  [81011cac] ? call_softirq+0x1c/0x30
[ 3592.832003]  [81013903] ? do_softirq+0x3f/0x7c
[ 3592.832003]  [810537e1] ? irq_exit+0x36/0x76
[ 3592.832003]  [81025837] ? smp_apic_timer_interrupt+0x87/0x95
[ 3592.832003]  [81011673] ? apic_timer_interrupt+0x13/0x20
[ 3592.832003]  EOI 
[ 3592.832003]  [8118e009] ? delay_tsc+0x0/0x73
[ 3592.832003]  [a010f900] ? sym_eh_handler+0x22e/0x2e2 [sym53c8xx]
[ 3592.832003]  [a008e5de] ? scsi_try_bus_reset+0x50/0xd9 [scsi_mod]
[ 3592.832003]  [a008f565] ? scsi_eh_ready_devs+0x50c/0x781 [scsi_mod]
[ 3592.832003]  [a008fd6b] ? scsi_error_handler+0x3c1/0x5b5 [scsi_mod]
[ 3592.832003]  [a008f9aa] ? scsi_error_handler+0x0/0x5b5 [scsi_mod]
[ 3592.832003]  [81064789] ? kthread+0x79/0x81
[ 3592.832003]  [81011baa] ? child_rip+0xa/0x20
[ 3592.832003]  [81064710] ? kthread+0x0/0x81
[ 3592.832003]  [81011ba0] ? child_rip+0x0/0x20
[ 3592.832003] Code: 48 c7 c7 82 92 11 a0 eb 63 48 8b 98 38 01 00 00 48 8d b8 
28 01 00 00 e8 df d5 0f e1 48 89 da 48 89 c6 48 c7 c7 bc 92 11 a0 eb 6d 49 8b 
96 

[Qemu-devel] Re: [PULL] pci, vhost fixes

2010-05-31 Thread Blue Swirl
On Mon, May 31, 2010 at 1:35 PM, Michael S. Tsirkin m...@redhat.com wrote:
 On Mon, May 31, 2010 at 02:51:26PM +0200, Paolo Bonzini wrote:
 On 05/30/2010 08:19 PM, Blue Swirl wrote:
 We have PRI*64 just for this purpose, so let's use them. The
 discussion about that was earlier.

 How does mingw matter for vhost-net specific code?

 Paolo

 Good point. That code is linux-only, so we are safe using %lld.
 By the time someone ports vhost to windows, there's a chance
 debian will update it's mingw.  Blue Swirl?

It's a good point, but there's also consistency: now no '%ll*' formats are used.



Re: [Qemu-devel] [PATCH] target-ppc: fix RFI by clearing some bits of MSR

2010-05-31 Thread Aurelien Jarno
On Fri, May 28, 2010 at 09:07:32PM +0200, Thomas Monjalon wrote:
 From: Thomas Monjalon tho...@monjalon.net
 
 Since commit 2ada0ed, Return From Interrupt is broken for PPC processors
 because some interrupt specifics bits of SRR1 are copied to MSR.
 
 SRR1 is a save of MSR during interrupt.
 During RFI, MSR must be restored from SRR1.
 But some bits of SRR1 are interrupt-specific and are not used for MSR saving.
 
 This is the specification (ISA 2.06) at chapter 6.4.3 (Interrupt Processing):
 2. Bits 33:36 and 42:47 of SRR1 or HSRR1 are loaded with information specific
 to the interrupt type.
  3. Bits 0:32, 37:41, and 48:63 of SRR1 or HSRR1 are loaded with a copy of the
 corresponding bits of the MSR.
 
 Below is a representation of MSR bits which are not saved:
 0:15 16:31 32  33:3637:41  42:47 48:63
 ——— | ——— | — X X X X — — — — — X X X X X X | 
   |7   |   8   |   3   |   F| 
 
 History:
 In the initial Qemu implementation (e1833e1), the mask 0x783F was used for
 saving MSR in SRR1. But all the bits 32:47 were cleared during RFI restoring.
 This was wrong. The commit 2ada0ed explains that this breaks Altivec.
 Indeed, bit 38 (for Altivec support) must be saved and restored.
 The change of 2ada0ed was to restore all the bits of SRR1 to MSR.
 But it's also wrong.
 
 Explanation:
 As an example, let's see what's happening after a TLB miss.
 According to the e300 manual (E300CORERM table 5-6), the TLB miss interrupts
 set the bits 44-47 for KEY, I/D, WAY and S/L. These bits are specifics to the
 interrupt and must not be copied into MSR at the end of the interrupt.
 With the current implementation, a TLB miss overwrite bits POW, TGPR and ILE.
 
 Fix:
 It shouldn't be needed to filter-out bits on MSR saving when interrupt occurs.
 Specific bits overwrite MSR ones in SRR1.
 But at the end of interrupt (RFI), specifics bits must be cleared before
 restoring MSR from SRR1. The mask 0x783F apply here.
 
 Discussion:
 The bits of the mask 0x783F are cleared after an interrupt.
 I cannot find a specification which talks about this
 but I assume it is the truth since Linux can run this way.
 Maybe it's not perfect but it's better (works for e300).
 
 Signed-off-by: Thomas Monjalon tho...@monjalon.net
 Cc: Alexander Graf ag...@suse.de
 ---
  target-ppc/helper.c|1 -
  target-ppc/op_helper.c |6 +++---
  2 files changed, 3 insertions(+), 4 deletions(-)

Thanks, applied.

 diff --git a/target-ppc/helper.c b/target-ppc/helper.c
 index dabf1fd..5035d92 100644
 --- a/target-ppc/helper.c
 +++ b/target-ppc/helper.c
 @@ -2080,7 +2080,6 @@ static inline void powerpc_excp(CPUState *env, int 
 excp_model, int excp)
  srr1 = SPR_SRR1;
  asrr0 = -1;
  asrr1 = -1;
 -msr = ~((target_ulong)0x783F);
  switch (excp) {
  case POWERPC_EXCP_NONE:
  /* Should never happen */
 diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
 index 8f2ee98..3c3aa60 100644
 --- a/target-ppc/op_helper.c
 +++ b/target-ppc/op_helper.c
 @@ -1646,20 +1646,20 @@ static inline void do_rfi(target_ulong nip, 
 target_ulong msr,
  void helper_rfi (void)
  {
  do_rfi(env-spr[SPR_SRR0], env-spr[SPR_SRR1],
 -   ~((target_ulong)0x0), 1);
 +   ~((target_ulong)0x783F), 1);
  }
  
  #if defined(TARGET_PPC64)
  void helper_rfid (void)
  {
  do_rfi(env-spr[SPR_SRR0], env-spr[SPR_SRR1],
 -   ~((target_ulong)0x0), 0);
 +   ~((target_ulong)0x783F), 0);
  }
  
  void helper_hrfid (void)
  {
  do_rfi(env-spr[SPR_HSRR0], env-spr[SPR_HSRR1],
 -   ~((target_ulong)0x0), 0);
 +   ~((target_ulong)0x783F), 0);
  }
  #endif
  #endif
 -- 
 1.7.1
 
 
 
 
 

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



Re: [Qemu-devel] [PATCH] arm: fix arm kernel boot for non zero start addr

2010-05-31 Thread Aurelien Jarno
On Sat, May 08, 2010 at 10:43:35PM +0200, Lars Munch wrote:
 Booting an arm kernel has been broken a while when booting from non zero start
 address. This is due to the order of events: board init loads the kernel and
 sets register 15 to the start address and then qemu_system_reset reset the cpu
 making register 15 zero again.
 
 This patch fixes the usage of the register 15 start address trick in
 combination with arm_load_kernel.

Thanks, applied.

 Signed-off-by: Lars Munch l...@segv.dk
 ---
  hw/arm_boot.c   |1 +
  hw/gumstix.c|4 
  hw/mainstone.c  |3 ---
  hw/nseries.c|7 ---
  hw/omap_sx1.c   |5 -
  hw/palm.c   |4 
  hw/spitz.c  |3 ---
  hw/tosa.c   |3 ---
  target-arm/helper.c |1 -
  9 files changed, 1 insertions(+), 30 deletions(-)
 
 diff --git a/hw/arm_boot.c b/hw/arm_boot.c
 index df031a5..620550b 100644
 --- a/hw/arm_boot.c
 +++ b/hw/arm_boot.c
 @@ -187,6 +187,7 @@ static void main_cpu_reset(void *opaque)
  env-regs[15] = info-entry  0xfffe;
  env-thumb = info-entry  1;
  } else {
 +env-regs[15] = info-loader_start;
  if (old_param) {
  set_kernel_args_old(info, info-initrd_size,
  info-loader_start);
 diff --git a/hw/gumstix.c b/hw/gumstix.c
 index 3fd31f4..b64e04e 100644
 --- a/hw/gumstix.c
 +++ b/hw/gumstix.c
 @@ -74,8 +74,6 @@ static void connex_init(ram_addr_t ram_size,
  exit(1);
  }
  
 -cpu-env-regs[15] = 0x;
 -
  /* Interrupt line of NIC is connected to GPIO line 36 */
  smc91c111_init(nd_table[0], 0x04000300,
  pxa2xx_gpio_in_get(cpu-gpio)[36]);
 @@ -114,8 +112,6 @@ static void verdex_init(ram_addr_t ram_size,
  exit(1);
  }
  
 -cpu-env-regs[15] = 0x;
 -
  /* Interrupt line of NIC is connected to GPIO line 99 */
  smc91c111_init(nd_table[0], 0x04000300,
  pxa2xx_gpio_in_get(cpu-gpio)[99]);
 diff --git a/hw/mainstone.c b/hw/mainstone.c
 index a4379e3..54bacfb 100644
 --- a/hw/mainstone.c
 +++ b/hw/mainstone.c
 @@ -89,9 +89,6 @@ static void mainstone_common_init(ram_addr_t ram_size,
  cpu_register_physical_memory(0, MAINSTONE_ROM,
  qemu_ram_alloc(MAINSTONE_ROM) | IO_MEM_ROM);
  
 -/* Setup initial (reset) machine state */
 -cpu-env-regs[15] = mainstone_binfo.loader_start;
 -
  #ifdef TARGET_WORDS_BIGENDIAN
  be = 1;
  #else
 diff --git a/hw/nseries.c b/hw/nseries.c
 index 0273eee..04a028d 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1016,7 +1016,6 @@ static void n8x0_boot_init(void *opaque)
  n800_dss_init(s-blizzard);
  
  /* CPU setup */
 -s-cpu-env-regs[15] = s-cpu-env-boot_info-loader_start;
  s-cpu-env-GE = 0x5;
  
  /* If the machine has a slided keyboard, open it */
 @@ -1317,11 +1316,6 @@ static void n8x0_init(ram_addr_t ram_size, const char 
 *boot_device,
  if (usb_enabled)
  n8x0_usb_setup(s);
  
 -/* Setup initial (reset) machine state */
 -
 -/* Start at the OneNAND bootloader.  */
 -s-cpu-env-regs[15] = 0;
 -
  if (kernel_filename) {
  /* Or at the linux loader.  */
  binfo-kernel_filename = kernel_filename;
 @@ -1330,7 +1324,6 @@ static void n8x0_init(ram_addr_t ram_size, const char 
 *boot_device,
  arm_load_kernel(s-cpu-env, binfo);
  
  qemu_register_reset(n8x0_boot_init, s);
 -n8x0_boot_init(s);
  }
  
  if (option_rom[0]  (boot_device[0] == 'n' || !kernel_filename)) {
 diff --git a/hw/omap_sx1.c b/hw/omap_sx1.c
 index ca0a7d1..2e9879f 100644
 --- a/hw/omap_sx1.c
 +++ b/hw/omap_sx1.c
 @@ -195,15 +195,10 @@ static void sx1_init(ram_addr_t ram_size,
  
  /* Load the kernel.  */
  if (kernel_filename) {
 -/* Start at bootloader.  */
 -cpu-env-regs[15] = sx1_binfo.loader_start;
 -
  sx1_binfo.kernel_filename = kernel_filename;
  sx1_binfo.kernel_cmdline = kernel_cmdline;
  sx1_binfo.initrd_filename = initrd_filename;
  arm_load_kernel(cpu-env, sx1_binfo);
 -} else {
 -cpu-env-regs[15] = 0x;
  }
  
  /* TODO: fix next line */
 diff --git a/hw/palm.c b/hw/palm.c
 index ba7c398..8db133d 100644
 --- a/hw/palm.c
 +++ b/hw/palm.c
 @@ -243,7 +243,6 @@ static void palmte_init(ram_addr_t ram_size,
  rom_size = load_image_targphys(option_rom[0], OMAP_CS0_BASE,
 flash_size);
  rom_loaded = 1;
 -cpu-env-regs[15] = 0x;
  }
  if (rom_size  0) {
  fprintf(stderr, %s: error loading '%s'\n,
 @@ -258,9 +257,6 @@ static void palmte_init(ram_addr_t ram_size,
  
  /* Load the kernel.  */
  if (kernel_filename) {
 -/* Start at bootloader.  */
 -cpu-env-regs[15] = palmte_binfo.loader_start;
 -
  

Re: [Qemu-devel] [PATCH] Fix leul_to_cpu on big endian hosts

2010-05-31 Thread Alexander Graf
Aurelien Jarno wrote:
 On Tue, May 11, 2010 at 05:38:17PM +0200, Alexander Graf wrote:
   
 Commit 213acd2e introduced leul_to_cpu with a special code path for big 
 endian
 hosts. Unfortunately that code used preprocessor magic that didn't work.

 This patch replaces the explicit ##s by glue() which is proven to work 
 reliably,
 enabling me to compile qemu on ppc again.

 Signed-off-by: Alexander Graf ag...@suse.de
 ---
  bswap.h |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/bswap.h b/bswap.h
 index 956f3fa..20caae6 100644
 --- a/bswap.h
 +++ b/bswap.h
 @@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
  
  #ifdef HOST_WORDS_BIGENDIAN
  #define cpu_to_32wu cpu_to_be32wu
 -#define leul_to_cpu(v) le ## HOST_LONG_BITS ## _to_cpu(v)
 +#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)
  #else
  #define cpu_to_32wu cpu_to_le32wu
  #define leul_to_cpu(v) (v)
 

 While the patch looks correct, I am not able to reproduce the issue. Do
 you have more details about it?
   

When building on a KVM capable PPC host (or S390 for that matter), I get
the following:

cc1: warnings being treated as errors
/home/agraf/release/qemu/kvm-all.c: In function
‘kvm_get_dirty_pages_log_range’:
/home/agraf/release/qemu/kvm-all.c:305: error: implicit declaration of
function ‘leHOST_LONG_BITS_to_cpu’
make[1]: *** [kvm-all.o] Error 1
make[1]: *** Waiting for unfinished jobs
make: *** [subdir-ppc64-softmmu] Error 2


Alex




Re: [Qemu-devel] [PATCH] Fix leul_to_cpu on big endian hosts

2010-05-31 Thread Aurelien Jarno
On Tue, May 11, 2010 at 05:38:17PM +0200, Alexander Graf wrote:
 Commit 213acd2e introduced leul_to_cpu with a special code path for big endian
 hosts. Unfortunately that code used preprocessor magic that didn't work.
 
 This patch replaces the explicit ##s by glue() which is proven to work 
 reliably,
 enabling me to compile qemu on ppc again.
 
 Signed-off-by: Alexander Graf ag...@suse.de
 ---
  bswap.h |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/bswap.h b/bswap.h
 index 956f3fa..20caae6 100644
 --- a/bswap.h
 +++ b/bswap.h
 @@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
  
  #ifdef HOST_WORDS_BIGENDIAN
  #define cpu_to_32wu cpu_to_be32wu
 -#define leul_to_cpu(v) le ## HOST_LONG_BITS ## _to_cpu(v)
 +#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)
  #else
  #define cpu_to_32wu cpu_to_le32wu
  #define leul_to_cpu(v) (v)

While the patch looks correct, I am not able to reproduce the issue. Do
you have more details about it?

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



Re: [Qemu-devel] [PATCH] target-ppc: remove useless line

2010-05-31 Thread Aurelien Jarno
On Fri, May 28, 2010 at 09:00:45PM +0200, Thomas Monjalon wrote:
 From: Thomas Monjalon tho...@monjalon.net
 
 This line was a bit clear.
 The next lines set or reset this bit (LE) depending of another bit (ILE).
 So the first line is useless.

Thanks, applied.

 Signed-off-by: Thomas Monjalon tho...@monjalon.net
 ---
  target-ppc/helper.c |1 -
  1 files changed, 0 insertions(+), 1 deletions(-)
 
 diff --git a/target-ppc/helper.c b/target-ppc/helper.c
 index 3d843b5..dabf1fd 100644
 --- a/target-ppc/helper.c
 +++ b/target-ppc/helper.c
 @@ -2591,7 +2591,6 @@ static inline void powerpc_excp(CPUState *env, int 
 excp_model, int excp)
  #if 0 /* Fix this: not on all targets */
  new_msr = ~((target_ulong)1  MSR_PMM);
  #endif
 -new_msr = ~((target_ulong)1  MSR_LE);
  if (msr_ile)
  new_msr |= (target_ulong)1  MSR_LE;
  else
 -- 
 1.7.1
 
 
 
 
 

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



Re: [Qemu-devel] [PATCH] Fix leul_to_cpu on big endian hosts

2010-05-31 Thread Alexander Graf
Alexander Graf wrote:
 Commit 213acd2e introduced leul_to_cpu with a special code path for big endian
 hosts. Unfortunately that code used preprocessor magic that didn't work.

 This patch replaces the explicit ##s by glue() which is proven to work 
 reliably,
 enabling me to compile qemu on ppc again.
   

Ping?

Alex




[Qemu-devel] [PULLv2] pci fixes

2010-05-31 Thread Michael S. Tsirkin
OK, I dropped the vhost change for now: I still think
we should not bother about mingw for linux-only code,
but at this point it's not important for me.

The following changes since commit aa6f63fff62faf2fe9ffba5a789675d49293614d:

  mc146818rtc: improve debugging (2010-05-30 19:20:07 +)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git for_anthony

Isaku Yamahata (5):
  pci: clean up of pci_set_default_subsystem_id().
  pci: add const to pci_is_express(), pci_config_size().
  pci.h: remove unused constants.
  msix: remove duplicated defines.
  pci-hotplug: make them aware of pci domain.

 hw/msix.c|8 
 hw/pci-hotplug.c |7 ---
 hw/pci.c |   34 ++
 hw/pci.h |   16 +++-
 4 files changed, 33 insertions(+), 32 deletions(-)



[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs

2010-05-31 Thread Gerd Hoffmann

On 05/31/10 16:13, Markus Armbruster wrote:

We need Device IDs to be unique and not contain '/' so device tree
nodes can always be unambigously referenced by tree path.

We already have some protection against duplicate IDs, but it got
holes:

* We don't assign IDs to default devices.

* -device and device_add use the ID of a qemu_device_opts.  Which
   rejects duplicate IDs.

* pci_add nic -net use either the ID or option name of
   qemu_net_opts.  And there's our hole.  Reproducible with -net user
   -net nic,id=foo -device lsi,id=foo.

Also require IDs to start with a letter to provide for possible future
extensions.



Acked-by: Gerd Hoffmann kra...@redhat.com

cheers,
  Gerd




Re: [Qemu-devel] [PATCH] Fix leul_to_cpu on big endian hosts

2010-05-31 Thread Aurelien Jarno
On Mon, May 31, 2010 at 08:44:55PM +0200, Alexander Graf wrote:
 Aurelien Jarno wrote:
  On Tue, May 11, 2010 at 05:38:17PM +0200, Alexander Graf wrote:

  Commit 213acd2e introduced leul_to_cpu with a special code path for big 
  endian
  hosts. Unfortunately that code used preprocessor magic that didn't work.
 
  This patch replaces the explicit ##s by glue() which is proven to work 
  reliably,
  enabling me to compile qemu on ppc again.
 
  Signed-off-by: Alexander Graf ag...@suse.de
  ---
   bswap.h |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
 
  diff --git a/bswap.h b/bswap.h
  index 956f3fa..20caae6 100644
  --- a/bswap.h
  +++ b/bswap.h
  @@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t 
  v)
   
   #ifdef HOST_WORDS_BIGENDIAN
   #define cpu_to_32wu cpu_to_be32wu
  -#define leul_to_cpu(v) le ## HOST_LONG_BITS ## _to_cpu(v)
  +#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)
   #else
   #define cpu_to_32wu cpu_to_le32wu
   #define leul_to_cpu(v) (v)
  
 
  While the patch looks correct, I am not able to reproduce the issue. Do
  you have more details about it?

 
 When building on a KVM capable PPC host (or S390 for that matter), I get
 the following:
 
 cc1: warnings being treated as errors
 /home/agraf/release/qemu/kvm-all.c: In function
 ‘kvm_get_dirty_pages_log_range’:
 /home/agraf/release/qemu/kvm-all.c:305: error: implicit declaration of
 function ‘leHOST_LONG_BITS_to_cpu’
 make[1]: *** [kvm-all.o] Error 1
 make[1]: *** Waiting for unfinished jobs
 make: *** [subdir-ppc64-softmmu] Error 2
 

Ok, that make sense now. I have tried to build on a big endian host, but
KVM was not enabled. Strangely this function is also used at other
places, so I was expecting the build to fail.

Applied now.

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



[Qemu-devel] Re: [QEMU-KVM]: Megasas + TCM_Loop + SG_IO into Windows XP guests

2010-05-31 Thread Alexander Graf


Am 31.05.2010 um 11:52 schrieb Gerd Hoffmann kra...@redhat.com:


 Hi,


Also it's worth mentioning that I am still running C: on QEMU IDE
emulation, as I could not quite figure out how to boot for a  
megasas LD

with option-rom.  What QEMU CLI ops where requried to make this work
again..?


-option-rom $file

or

-device megasas,romfile=$file


Or -drive ...,boot=on if you're using qemu-kvm.

Alex




[Qemu-devel] [PATCH] ceph/rbd block driver for qemu-kvm (v3)

2010-05-31 Thread Christian Brunner
Hi Kevin,

here is an updated patch for the ceph/rbd driver. I hope that everything 
is fine now.

Regards,
Christian


This is a block driver for the distributed file system Ceph
(http://ceph.newdream.net/). This driver uses librados (which
is part of the Ceph server) for direct access to the Ceph object
store and is running entirely in userspace. Therefore it is
called rbd - rados block device.

To compile the driver a recent version of ceph (unstable/testing git
head or 0.20.3 once it is released) is needed.

Additional information is available on the Ceph-Wiki:

http://ceph.newdream.net/wiki/Kvm-rbd

The patch is based on git://repo.or.cz/qemu/kevin.git block


Signed-off-by: Christian Brunner c...@muc.de
---
 Makefile.objs |1 +
 block/rbd.c   |  600 +
 block/rbd_types.h |   64 ++
 configure |   31 +++
 4 files changed, 696 insertions(+), 0 deletions(-)
 create mode 100644 block/rbd.c
 create mode 100644 block/rbd_types.h

diff --git a/Makefile.objs b/Makefile.objs
index 1a942e5..08dc11f 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -18,6 +18,7 @@ block-nested-y += parallels.o nbd.o blkdebug.o
 block-nested-$(CONFIG_WIN32) += raw-win32.o
 block-nested-$(CONFIG_POSIX) += raw-posix.o
 block-nested-$(CONFIG_CURL) += curl.o
+block-nested-$(CONFIG_RBD) += rbd.o
 
 block-obj-y +=  $(addprefix block/, $(block-nested-y))
 
diff --git a/block/rbd.c b/block/rbd.c
new file mode 100644
index 000..4a60dda
--- /dev/null
+++ b/block/rbd.c
@@ -0,0 +1,600 @@
+/*
+ * QEMU Block driver for RADOS (Ceph)
+ *
+ * Copyright (C) 2010 Christian Brunner c...@muc.de
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#include qemu-common.h
+#include qemu-error.h
+#include sys/types.h
+#include stdbool.h
+
+#include qemu-common.h
+
+#include rbd_types.h
+#include module.h
+#include block_int.h
+
+#include stdio.h
+#include stdlib.h
+#include rados/librados.h
+
+#include signal.h
+
+/*
+ * When specifying the image filename use:
+ *
+ * rbd:poolname/devicename
+ *
+ * poolname must be the name of an existing rados pool
+ *
+ * devicename is the basename for all objects used to
+ * emulate the raw device.
+ *
+ * Metadata information (image size, ...) is stored in an
+ * object with the name devicename.rbd.
+ *
+ * The raw device is split into 4MB sized objects by default.
+ * The sequencenumber is encoded in a 12 byte long hex-string,
+ * and is attached to the devicename, separated by a dot.
+ * e.g. devicename.1234567890ab
+ *
+ */
+
+#define OBJ_MAX_SIZE (1UL  OBJ_DEFAULT_OBJ_ORDER)
+
+typedef struct RBDAIOCB {
+BlockDriverAIOCB common;
+QEMUBH *bh;
+int ret;
+QEMUIOVector *qiov;
+char *bounce;
+int write;
+int64_t sector_num;
+int aiocnt;
+int error;
+} RBDAIOCB;
+
+typedef struct RADOSCB {
+int rcbid;
+RBDAIOCB *acb;
+int done;
+int64_t segsize;
+char *buf;
+} RADOSCB;
+
+typedef struct BDRVRBDState {
+rados_pool_t pool;
+char name[RBD_MAX_OBJ_NAME_SIZE];
+uint64_t size;
+uint64_t objsize;
+} BDRVRBDState;
+
+typedef struct rbd_obj_header_ondisk RbdHeader1;
+
+static int rbd_parsename(const char *filename, char *pool, char *name)
+{
+const char *rbdname;
+char *p;
+int l;
+
+if (!strstart(filename, rbd:, rbdname)) {
+return -EINVAL;
+}
+
+pstrcpy(pool, 2 * RBD_MAX_SEG_NAME_SIZE, rbdname);
+p = strchr(pool, '/');
+if (p == NULL) {
+return -EINVAL;
+}
+
+*p = '\0';
+
+l = strlen(pool);
+if(l = RBD_MAX_SEG_NAME_SIZE) {
+error_report(pool name to long);
+return -EINVAL;
+} else if (l = 0) {
+error_report(pool name to short);
+return -EINVAL;
+}
+
+l = strlen(++p);
+if (l = RBD_MAX_OBJ_NAME_SIZE) {
+error_report(object name to long);
+return -EINVAL;
+} else if (l = 0) {
+error_report(object name to short);
+return -EINVAL;
+}
+
+strcpy(name, p);
+
+return l;
+}
+
+static int create_tmap_op(uint8_t op, const char *name, char **tmap_desc)
+{
+uint32_t len = strlen(name);
+/* total_len = encoding op + name + empty buffer */
+uint32_t total_len = 1 + (sizeof(uint32_t) + len) + sizeof(uint32_t);
+char *desc = NULL;
+
+qemu_malloc(total_len);
+
+*tmap_desc = desc;
+
+*desc = op;
+desc++;
+memcpy(desc, len, sizeof(len));
+desc += sizeof(len);
+memcpy(desc, name, len);
+desc += len;
+len = 0;
+memcpy(desc, len, sizeof(len));
+desc += sizeof(len);
+
+return desc - *tmap_desc;
+}
+
+static void free_tmap_op(char *tmap_desc)
+{
+qemu_free(tmap_desc);
+}
+
+static int rbd_register_image(rados_pool_t pool, const char *name)
+{
+char *tmap_desc;
+const char *dir = RBD_DIRECTORY;
+int ret;
+
+ret = create_tmap_op(CEPH_OSD_TMAP_SET, name, tmap_desc);
+if (ret  0) 

[Qemu-devel] [Bug 586424] Re: SMC91C111 failed when booting Linux/ARM(Mainstone) since 0.10.0

2010-05-31 Thread Lars Munch
** Changed in: qemu
   Status: In Progress = Fix Committed

-- 
SMC91C111 failed when booting Linux/ARM(Mainstone) since 0.10.0
https://bugs.launchpad.net/bugs/586424
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: Fix Committed

Bug description:
Since QEMU 0.10.0, the SMC91C111 emulation on a ARM machine like Mainstone, 
fails when performing some read/write.





[Qemu-devel] [Bug 586221] Re: Linux on ARM/Mainstone machine fails at bootstrap

2010-05-31 Thread Lars Munch
Fixed in e03c22a98cf5deffd0dec2f9ff88a600aa330bc4

** Changed in: qemu
   Status: New = Fix Committed

-- 
Linux on ARM/Mainstone machine fails at bootstrap
https://bugs.launchpad.net/bugs/586221
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: Fix Committed

Bug description:
When QEMU (0.12.4) starts a ARM machine which boots a Linux, it immediately 
fails because the initial PC is wrong (is equal to 0 instead of 0xa000). 
First investigations indicate that the reset handlers queue does not return the 
correct opaque structure in main_cpu_reset() which is passed during the 
insertion within arm_load_kernel(). I checked the value of r15 and the value is 
correct at the insertion, but at 0x0 in main_cpu_reset().

There may be still a bug in the new queue management functions (in 
qemu-queue.h).





[Qemu-devel] [PATCH] ahci: drop board_ahci constants

2010-05-31 Thread Sebastian Herbszt
Drop not used board_ahci constants.

Signed-off-by: Sebastian Herbszt herb...@gmx.de

diff --git a/hw/ahci.c b/hw/ahci.c
index 3476cea..4090def 100644
--- a/hw/ahci.c
+++ b/hw/ahci.c
@@ -65,12 +65,6 @@ do { fprintf(stderr,ahci:  fmt , ## __VA_ARGS__); } while 
(0)
 #define RX_FIS_SDB0x58 /* offset of SDB FIS data */
 #define RX_FIS_UNK0x60 /* offset of Unknown FIS data */
 
-#define board_ahci0
-#define board_ahci_pi 1
-#define board_ahci_vt8251 2
-#define board_ahci_ign_iferr  3
-#define board_ahci_sb600  4
-
 /* global controller registers */
 #define HOST_CAP  0x00 /* host capabilities */
 #define HOST_CTL  0x04 /* global host control */




[Qemu-devel] Re: [Qemu-ahci-devel] [PATCH] ahci: drop board_ahci constants

2010-05-31 Thread Alexander Graf

On 31.05.2010, at 22:12, Sebastian Herbszt wrote:

 Drop not used board_ahci constants.
 
 Signed-off-by: Sebastian Herbszt herb...@gmx.de
 
 diff --git a/hw/ahci.c b/hw/ahci.c
 index 3476cea..4090def 100644
 --- a/hw/ahci.c
 +++ b/hw/ahci.c
 @@ -65,12 +65,6 @@ do { fprintf(stderr,ahci:  fmt , ## __VA_ARGS__); } 
 while (0)
 #define RX_FIS_SDB0x58 /* offset of SDB FIS data */
 #define RX_FIS_UNK0x60 /* offset of Unknown FIS data */
 
 -#define board_ahci0
 -#define board_ahci_pi 1
 -#define board_ahci_vt8251 2
 -#define board_ahci_ign_iferr  3
 -#define board_ahci_sb600  4
 -

They weren't used before? Why are they there at all then?

Alex




[Qemu-devel] Re: [Qemu-ahci-devel] [PATCH] ahci: drop board_ahci constants

2010-05-31 Thread Sebastian Herbszt

Alexander Graf wrote:

On 31.05.2010, at 22:12, Sebastian Herbszt wrote:

Drop not used board_ahci constants.

Signed-off-by: Sebastian Herbszt herb...@gmx.de

diff --git a/hw/ahci.c b/hw/ahci.c
index 3476cea..4090def 100644
--- a/hw/ahci.c
+++ b/hw/ahci.c
@@ -65,12 +65,6 @@ do { fprintf(stderr,ahci:  fmt , ## __VA_ARGS__); } while 
(0)
#define RX_FIS_SDB0x58 /* offset of SDB FIS data */
#define RX_FIS_UNK0x60 /* offset of Unknown FIS data */

-#define board_ahci0
-#define board_ahci_pi 1
-#define board_ahci_vt8251 2
-#define board_ahci_ign_iferr  3
-#define board_ahci_sb600  4
-


They weren't used before? Why are they there at all then?

Alex


Copy and paste from the linux kernel (ahci.c/h)?

Sebastian




Re: [Qemu-devel] [PATCH 2/3] QMP: Introduce commands documentation

2010-05-31 Thread Stefan Hajnoczi
On Mon, May 31, 2010 at 6:43 PM, Luiz Capitulino lcapitul...@redhat.com wrote:
Hi Luiz,

I'm interested in QMP, have left some feedback.  As I get up to speed
with QMP my questions and suggestions will hopefully be useful.
Apologies in advance if any of my thoughts here are old news and have
been discussed elsewhere :).

I didn't see documentation on the errors that a command can encounter.
 Error documentation would be useful for commands where the client
needs to react by trying an alternative command.  If errors are opaque
or undocumented, then the client can't perform error recovery, they
can only log the error or prompt the user for help.

 @@ -113,6 +184,35 @@ Password: 

 �...@end table
  ETEXI
 +SQMP
 +change
 +--
 +
 +Change a removable medium or VNC configuration.
 +
 +Arguments:
 +
 +- device: device name (json-string)
 +- target: filename or item (json-string)
 +- arg: additional argument (json-string, optional)
 +
 +Examples:
 +
 +1. Change a removable medium
 +
 +- { execute: change,
 +             arguments: { device: ide1-cd0,
 +                            target: /srv/images/Fedora-12-x86_64-DVD.iso 
 } }
 +- { return: {} }
 +
 +2. Change VNC password
 +
 +- { execute: change,
 +             arguments: { device: vnc, target: password,
 +                            arg: foobar1 } }
 +- { return: {} }
 +
 +EQMP

     {
         .name       = screendump,

For removable media is there a way to use, for instance, sheepdog, or
is the target strictly a file name?

Can the VNC password be removed when arg is the empty string or arg is
not present?

 @@ -532,6 +747,24 @@ STEXI
 �...@findex cpu
  Set the default CPU.
  ETEXI
 +SQMP
 +cpu
 +---
 +
 +Set the default CPU.
 +
 +Arguments:
 +
 +- index: the CPU's index (json-int)
 +
 +Example:
 +
 +- { execute: cpu, arguments: { index: 0 } }
 +- { return: {} }
 +
 +Note: CPUs' indexes are obtained with the 'query-cpus' command.
 +
 +EQMP

     {
         .name       = mouse_move,

I believe this is the per-monitor default cpu for memory dumping and
other per-cpu commands.  The concept of the default cpu makes sense
for an interactive monitor, humans don't want to type the cpu index
for each cpu-specific command.  For QMP it feels cleaner to have a cpu
argument for commands that are per-cpu.  As a newcomer I'm not sure of
the philosophy for QMP commands, 1:1 with monitor commands or as
appropriate for a JSON interface?

If the QMP cpu command is supported in a QEMU release, can it be
phased out later?

Will look more later.

Stefan



[Qemu-devel] Re: [SeaBIOS] SMBIOS strings

2010-05-31 Thread Sebastian Herbszt

Gleb Natapov wrote:

I don't care much as long as we will not have CPU :. It looks like something
that can change after BIOS upgrade, so it is hard to believe Windows
will stop working because of this change.


Maybe it could trigger the Windows activation process?

Sebastian




[Qemu-devel] [PATCH] ahci: drop ATAPI_CMD constants

2010-05-31 Thread Sebastian Herbszt
Drop not used ATAPI_CMD constants.

Signed-off-by: Sebastian Herbszt herb...@gmx.de

diff --git a/hw/ahci.c b/hw/ahci.c
index 9987459..a024706 100644
--- a/hw/ahci.c
+++ b/hw/ahci.c
@@ -179,21 +179,6 @@ do { fprintf(stderr,ahci:  fmt , ## __VA_ARGS__); } 
while (0)
 #define ATA_CMD_WRITE_EXT  0x34/* Write Sectores (with retries) with 
48bit addressing */
 #define ATA_CMD_VRFY_EXT   0x42/* Read Verify  (with retries)  with 
48bit addressing */
 
-/*
- * ATAPI Commands
- */
-#define ATAPI_CMD_IDENT 0xA1 /* Identify AT Atachment Packed Interface Device 
*/
-#define ATAPI_CMD_PACKET 0xA0 /* Packed Command */
-
-
-#define ATAPI_CMD_INQUIRY 0x12
-#define ATAPI_CMD_REQ_SENSE 0x03
-#define ATAPI_CMD_READ_CAP 0x25
-#define ATAPI_CMD_START_STOP 0x1B
-#define ATAPI_CMD_READ_12 0xA8
-
-
-
 typedef struct ahci_control_regs {
uint32_t  cap;
uint32_t  ghc;




[Qemu-devel] Re: [Qemu-ahci-devel] [PATCH] ahci: drop ATAPI_CMD constants

2010-05-31 Thread Alexander Graf

On 31.05.2010, at 22:56, Sebastian Herbszt wrote:

 Drop not used ATAPI_CMD constants.

I'd postpone that. We should get rid of _all_ ATA and ATAPI commands in ahci.c, 
but that'll be part of a bigger cleanup. IMHO we should reuse the IDE core for 
those.


Alex




[Qemu-devel] [PATCH] usb-uhci: fix commit 8e65b7c04965c8355e4ce43211582b6b83054e3d for vmstate

2010-05-31 Thread TeLeMan
The commit 8e65b7c04965c8355e4ce43211582b6b83054e3d introduced
expire_time of UHCIState.
But expire_time is not in vmstate, the second uhci_frame_timer will
not be fired immediately after loadvm.

Signed-off-by: TeLeMan gele...@gmail.com
---
 hw/usb-uhci.c |3 ++-
 1 files changed,[PATCH] usb-uhci: fix commit
8e65b7c04965c8355e4ce43211582b6b83054e3d for vmstate 2 insertions(+),
1 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 624d55b..d9d74c9 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -375,7 +375,7 @@ static const VMStateDescription vmstate_uhci_port = {

 static const VMStateDescription vmstate_uhci = {
 .name = uhci,
-.version_id = 1,
+.version_id = 2,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .pre_save = uhci_pre_save,
@@ -392,6 +392,7 @@ static const VMStateDescription vmstate_uhci = {
 VMSTATE_UINT8(sof_timing, UHCIState),
 VMSTATE_UINT8(status2, UHCIState),
 VMSTATE_TIMER(frame_timer, UHCIState),
+VMSTATE_INT64_V(expire_time, UHCIState, 2),
 VMSTATE_END_OF_LIST()
 }
 };
-- 
1.6.5.1.1367.gcd48
--
SUN OF A BEACH



[Qemu-devel] [PATCH v2] sdl: fix setenv for win32

2010-05-31 Thread TeLeMan
setenv() is not implemented on MinGW, so we have to use putenv().

Signed-off-by: TeLeMan gele...@gmail.com
---
 sdl.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/sdl.c b/sdl.c
index add1148..eac898a 100644
--- a/sdl.c
+++ b/sdl.c
@@ -850,7 +850,14 @@ void sdl_display_init(DisplayState *ds, int
full_screen, int no_frame)
 gui_noframe = 1;

 if (!full_screen) {
+#ifdef _WIN32
+/* setenv() is not implemented on MinGW */
+if(!getenv(SDL_VIDEO_ALLOW_SCREENSAVER)) {
+putenv(SDL_VIDEO_ALLOW_SCREENSAVER=1);
+}
+#else
 setenv(SDL_VIDEO_ALLOW_SCREENSAVER, 1, 0);
+#endif
 }

 flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
-- 
1.6.5.1.1367.gcd48



--
SUN OF A BEACH



[Qemu-devel] [PATCH][RESEND] usb-uhci: fix commit 8e65b7c04965c8355e4ce43211582b6b83054e3d for vmstate

2010-05-31 Thread TeLeMan
The commit 8e65b7c04965c8355e4ce43211582b6b83054e3d introduced
expire_time of UHCIState. But expire_time is not in vmstate, the
second uhci_frame_timer will not be fired immediately after loadvm.

Signed-off-by: TeLeMan gele...@gmail.com
---
 hw/usb-uhci.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 624d55b..d9d74c9 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -375,7 +375,7 @@ static const VMStateDescription vmstate_uhci_port = {

 static const VMStateDescription vmstate_uhci = {
 .name = uhci,
-.version_id = 1,
+.version_id = 2,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .pre_save = uhci_pre_save,
@@ -392,6 +392,7 @@ static const VMStateDescription vmstate_uhci = {
 VMSTATE_UINT8(sof_timing, UHCIState),
 VMSTATE_UINT8(status2, UHCIState),
 VMSTATE_TIMER(frame_timer, UHCIState),
+VMSTATE_INT64_V(expire_time, UHCIState, 2),
 VMSTATE_END_OF_LIST()
 }
 };
-- 
1.6.5.1.1367.gcd48
--
SUN OF A BEACH



[Qemu-devel] [Bug 588127] [NEW] qemu fails to recognize host features SSE4.1, SSE4.2

2010-05-31 Thread fonz
Public bug reported:

Tested on qemu v0.11.0 and v0.12.3:

qemu-kvm -cpu core2duo,+sse4.1,+sse4.2
CPU feature sse4.1 not found
CPU feature sse4.2 not found

egrep model name|flags /proc/cpuinfo | sort -r | uniq
model name  : Intel(R) Xeon(R) CPU   X5570  @ 2.93GHz
flags   : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat 
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm 
constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc 
pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 
popcnt lahf_lm tpr_shadow vnmi flexpriority ept vpid

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
qemu fails to recognize host features SSE4.1, SSE4.2
https://bugs.launchpad.net/bugs/588127
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.

Status in QEMU: New

Bug description:
Tested on qemu v0.11.0 and v0.12.3:

qemu-kvm -cpu core2duo,+sse4.1,+sse4.2
CPU feature sse4.1 not found
CPU feature sse4.2 not found

egrep model name|flags /proc/cpuinfo | sort -r | uniq
model name  : Intel(R) Xeon(R) CPU   X5570  @ 2.93GHz
flags   : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat 
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm 
constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc 
pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 
popcnt lahf_lm tpr_shadow vnmi flexpriority ept vpid





[Qemu-devel] KVM call agenda for June 1

2010-05-31 Thread Chris Wright
Please send in any agenda items you are interested in covering.

If we have a lack of agenda items I'll cancel the week's call.

thanks,
-chris



Re: [Qemu-devel] Re: [PULL] pci, vhost fixes

2010-05-31 Thread Markus Armbruster
Blue Swirl blauwir...@gmail.com writes:

 On Mon, May 31, 2010 at 1:35 PM, Michael S. Tsirkin m...@redhat.com wrote:
 On Mon, May 31, 2010 at 02:51:26PM +0200, Paolo Bonzini wrote:
 On 05/30/2010 08:19 PM, Blue Swirl wrote:
 We have PRI*64 just for this purpose, so let's use them. The
 discussion about that was earlier.

 How does mingw matter for vhost-net specific code?

 Paolo

 Good point. That code is linux-only, so we are safe using %lld.
 By the time someone ports vhost to windows, there's a chance
 debian will update it's mingw.  Blue Swirl?

 It's a good point, but there's also consistency: now no '%ll*' formats are 
 used.

If it ain't broke, don't fix it.  Especially not when the fix is ugly.



  1   2   >