Re: [SeaBIOS] [Qemu-devel] [RFC] Passing boot order from qemu to seabios

2010-10-12 Thread Gleb Natapov
On Mon, Oct 11, 2010 at 02:15:26PM -0700, H. Peter Anvin wrote:
> > I don't disagree.
> > 
> > I think the best thing to do is to let SeaBIOS create a boot order table 
> > that contains descriptive information and then advertise that to QEMU.
> > 
> > QEMU can then try to associate the list of bootable devices with it's 
> > own set of devices and select a preferred order that it can then give 
> > back to SeaBIOS.  SeaBIOS can then present that list to the user for 
> > additional refinement.
> 
> Really, this kind of comes down to having a data structure that anything
> (Qemu, SeaBIOS and if needed the guest OS) can read and modify as needed.
> 
But then QEMU and seabios will have to have shared storage they can
both write too. And this shared storage is part of VM now so you need
to carry it around when you move your VM elsewhere.
 
--
Gleb.



Re: [Qemu-devel] Re: [PATCH v2 3/7] docs: Add QED image format specification

2010-10-12 Thread Kevin Wolf
Am 11.10.2010 19:14, schrieb Anthony Liguori:
> On 10/11/2010 11:18 AM, Anthony Liguori wrote:
>> On 10/11/2010 10:46 AM, Stefan Hajnoczi wrote:
>>> On Mon, Oct 11, 2010 at 05:39:01PM +0200, Avi Kivity wrote:
   On 10/11/2010 05:30 PM, Stefan Hajnoczi wrote:
>>   It was discussed before, but I don't think we came to a 
>> conclusion. Are
>>   there any circumstances under which you don't want to set the
>>   QED_CF_BACKING_FORMAT flag?
> I suggest the following:
>
> QED_CF_BACKING_FORMAT_RAW = 0x1
>
> When set, the backing file is a raw image and should not be probed for
> its file format.  The default (unset) means that the backing image 
> file
> format may be probed.
>
> Now the backing_fmt_{offset,size} are no longer necessary.
 Should it not be an incompatible option?  If the backing disk starts
 with a format magic, it will be probed by an older qemu,
 incorrectly.
>>> Agreed, it should be a non-compat feature bit.
>>
>> If it's just raw or not raw, then I agree it should be non-compat.
>>
>> I think we just need a feature bit then that indicates that the 
>> backing file is non-probeable which certainly simplifies the 
>> implementation.
>>
>> QED_F_BACKING_FORMAT_NOPROBE maybe?
> 
> Er, thinking more, this is still a good idea but we still need 
> QED_CF_BACKING_FORMAT because we specifically need to know when a 
> protocol is specified.  Otherwise, we have no way of doing nbd as a 
> backing file.

Well, the protocol is currently encoded in the file name, separated by a
colon. Of course, we want to get rid of that, but we still don't know
what we want instead. It's completely unrelated to the backing file
format, though, it's about the format of the backing file name.

Kevin



Re: [Qemu-devel] [RFC] Passing boot order from qemu to seabios

2010-10-12 Thread Stefan Hajnoczi
On Mon, Oct 11, 2010 at 6:04 PM, Gleb Natapov  wrote:
> On Mon, Oct 11, 2010 at 12:01:58PM -0500, Anthony Liguori wrote:
>> On 10/11/2010 10:52 AM, Stefan Hajnoczi wrote:
>> >2010/10/11 Gleb Natapov:
>> >>On Mon, Oct 11, 2010 at 01:48:09PM +0100, Stefan Hajnoczi wrote:
>> >>>On Mon, Oct 11, 2010 at 12:16 PM, Bernhard Kohl  
>> >>>wrote:
>> Am 11.10.2010 12:18, schrieb ext Gleb Natapov:
>> >Currently if VM is started with multiple disks it is almost impossible 
>> >to
>> >guess which one of them will be used as boot device especially if there
>> >is a mix of ATA/virtio/SCSI devices. Essentially BIOS decides the order
>> >and without looking into the code you can't tell what the order will
>> >be (and in qemu-kvm if boot=on is used it brings even more havoc). We
>> >should allow fine-grained control of boot order from qemu command line,
>> >or as a minimum control what device will be used for booting.
>> >
>> >To do that along with inventing syntax to specify boot order on qemu
>> >command line we need to communicate boot order to seabios via fw_cfg
>> >interface. For that we need to have a way to unambiguously specify a
>> >disk from qemu to seabios.  PCI bus address is not enough since not all
>> >devices are PCI (do we care about them?) and since one PCI device may
>> >control more then one disk (ATA slave/master, SCSI LUNs). We can do what
>> >EDD specification does. Describe disk as:
>> >     bus type (isa/pci),
>> >     address on a bus (16 bit base address for isa, b/s/f for pci)
>> >     device type (ATA/SCSI/VIRTIO)
>> >     device path (slave/master for ATA, LUN for SCSI, nothing for 
>> > virtio)
>> >
>> >Will it cover all use cased? Any other ideas?
>> I think this also applies to network booting via gPXE. Usually our VMs
>> have 4 NICs, mixed virtio-net and PCI pass-through. 2 of the NICs shall
>> be used for booting, even if there are hard disks or floppy disks
>> connected. This scenario is currently almost impossible to configure.
>> >>>Here is a gPXE to support fw_cfg.  You can pass gPXE script files from
>> >>>the host to gPXE inside the guest.  This means you can boot specific
>> >>>NICs:
>> >>>http://patchwork.ozlabs.org/patch/43777/
>> >>>
>> >>>Just wanted to post the link because it is related to the gPXE side of
>> >>>this discussion.
>> >>>
>> >>Don't we load gPXE for each NIC and seabios passes PCI device to boot from
>> >>when it invokes one of them?
>> >SeaBIOS may do that but gPXE internally just probes all PCI devices.
>> >It does not take advantage of the PCI bus/addr/fn that was passed to
>> >the option ROM.  A gPXE instance will try booting from each available
>> >NIC in sequence.
>>
>> It still registers a BEV entry though, no?

Yes.

>> Does it at least try to boot from the PCI bus/addr/fn of the
>> selected BEV entry?

Not directly.  It probes all PCI devices and tries them in bus/addr/fn
order.  If you have two identical NICs and only have the boot ROM on
the second NIC, the first NIC will still try to network boot first.

Changing this behavior requires stashing away the bus/addr/fn and then
using it later in gPXE's startup.  It's possible but not implemented
today.

Stefan



[Qemu-devel] snapshots

2010-10-12 Thread chandra shekar
Hi,everyone i have applied this  patch
http://lists.nongnu.org/archive/html/qemu-devel/2010-09/msg01662.html  to
qemu source and compiled my qemu source and now i like to
bring the snapshot out of the image file so i used


qemu-img convert -f qcow2 -O qcow2 -s one guest1.img
where:

one -> is the snapshot i created in guest1.img and guest1.img contains
windows xp

 but i get an error

*convert: invalid option -- 's'
qemu-img: Could not open 'one'*

please someone help ,thanks


Re: [Qemu-devel] snapshots

2010-10-12 Thread Stefan Hajnoczi
On Tue, Oct 12, 2010 at 10:13 AM, chandra shekar
 wrote:
>
> Hi,everyone i have applied this  patch
> http://lists.nongnu.org/archive/html/qemu-devel/2010-09/msg01662.html  to
> qemu source and compiled my qemu source and now i like to
> bring the snapshot out of the image file so i used
>
>
> qemu-img convert -f qcow2 -O qcow2 -s one guest1.img
> where:
>
> one -> is the snapshot i created in guest1.img and guest1.img contains
> windows xp
>
>  but i get an error
>
> convert: invalid option -- 's'
> qemu-img: Could not open 'one'

Looks like you used your system qemu-img tool which is not compiled
with the patch.  Make sure to use the patched binary (./qemu-img).

Stefan



Re: [Qemu-devel] Re: [PATCH v2 3/7] docs: Add QED image format specification

2010-10-12 Thread Avi Kivity

 On 10/11/2010 06:10 PM, Anthony Liguori wrote:

On 10/11/2010 11:02 AM, Avi Kivity wrote:

 On 10/11/2010 05:49 PM, Anthony Liguori wrote:

On 10/11/2010 09:58 AM, Avi Kivity wrote:
A leak is unacceptable.  It means an image can grow to an 
unbounded size.  If you are a server provider offering 
multitenancy, then a malicious guest can potentially grow the 
image beyond it's allotted size causing a Denial of Service attack 
against another tenant.



This particular leak cannot grow, and is not controlled by the guest.


As the image gets moved from hypervisor to hypervisor, it can keep 
growing if given a chance to fill up the disk, then trim it all way.


In a mixed hypervisor environment, it just becomes a numbers game.


I don't see how it can grow.  Both the freelist and the clusters it 
points to consume space, which becomes a leak once you move it to a 
hypervisor that doesn't understand the freelist.  The older 
hypervisor then allocates new blocks.  As soon as it performs a 
metadata scan (if ever), the freelist is reclaimed.


Assume you don't ever do a metadata scan (which is really our design 
point).


What about crashes?



If you move to a hypervisor that doesn't support it, then move to a 
hypervisor that does, you create a brand new freelist and start 
leaking more space.  This isn't a contrived scenario if you have a 
cloud environment with a mix of hosts.


It's only a leak if you don't do a metadata scan.



You might not be able to get a ping-pong every time you provision, but 
with enough effort, you could create serious problems.


It's really an issue of correctness.  Making correctness trade-offs 
for the purpose of compatibility is a policy decision and not 
something we should bake into an image format.  If a tool feels 
strongly that it's a reasonable trade off to make, it can always fudge 
the feature bits itself.


I think the effort here is reasonable, clearing a bit on startup is not 
that complicated.




A potential solution here is to treat TRIM a little differently than 
we've been discussing.


When TRIM happens, don't immediately write an unallocated cluster 
entry for the L2.  Leave the L2 entry in-tact.  Don't actually write 
a UCE to the L2 until you actually allocate the block.


This implies a cost because you'll need to do metadata syncs to make 
this work.  However, that eliminates leakage.


The information is lost on shutdown; and you can have a large number 
of unallocated-in-waiting clusters (like a TRIM issued by mkfs, or a 
user expecting a visit from RIAA).


A slight twist on your proposal is to have an allocated-but-may-drop 
bit in a L2 entry.  TRIM or zero detection sets the bit (leaving the 
cluster number intact).  A following write to the cluster needs to 
clear the bit; if we reallocate the cluster we need to replace it 
with a ZCE.


Yeah, this is sort of what I was thinking.  You would still want a 
free list but it becomes totally optional because if it's lost, no 
data is leaked (assuming that the older version understands the bit).


I was suggesting that we store that bit in the free list though 
because that let's us support having older QEMUs with absolutely no 
knowledge still work.


It doesn't - on rewrite an old qemu won't clear the bit, so a newer qemu 
would think it's still free.


The autoclear bit solves it nicely - the old qemu automatically drops 
the allocated-but-may-drop bits, undoing any TRIMs (which is 
unfortunate) but preserving consistency.




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




[Qemu-devel] [PATCH 1/4] Introduce strtosz() library function to convert a string to a byte count.

2010-10-12 Thread Jes . Sorensen
From: Jes Sorensen 

strtosz() returns -1 on error. It now supports human unit formats in
eg. 1.0G, with better error handling.

This version lets strtod() do the actual parsing instead of relying on
strspn, as well as catches NaN input.

The following suffixes are supported:
B/b = bytes
K/k = KB
M/m = MB
G/g = GB
T/t = TB

Signed-off-by: Jes Sorensen 
---
 cutils.c  |   79 +
 qemu-common.h |1 +
 vl.c  |   31 +++---
 3 files changed, 90 insertions(+), 21 deletions(-)

diff --git a/cutils.c b/cutils.c
index 5883737..8e79d92 100644
--- a/cutils.c
+++ b/cutils.c
@@ -23,6 +23,7 @@
  */
 #include "qemu-common.h"
 #include "host-utils.h"
+#include 
 
 void pstrcpy(char *buf, int buf_size, const char *str)
 {
@@ -283,3 +284,81 @@ int fcntl_setfl(int fd, int flag)
 }
 #endif
 
+/*
+ * Convert string to bytes, allowing either B/b for bytes, K/k for KB,
+ * M/m for MB, G/g for GB or T/t for TB. Default without any postfix
+ * is MB. End pointer will be returned in *end, if end is valid.
+ * Return -1 on error.
+ */
+ssize_t strtosz(const char *nptr, char **end)
+{
+ssize_t retval = -1;
+int64_t tmpval;
+char *endptr, c;
+int mul_required = 0;
+double val, mul, integral, fraction;
+
+errno = 0;
+val = strtod(nptr, &endptr);
+if (isnan(val) || endptr == nptr || errno != 0 || val < 0 ||
+val == HUGE_VAL) {
+goto fail;
+}
+integral = modf(val, &fraction);
+if (integral != 0) {
+mul_required = 1;
+}
+/*
+ * Any whitespace character is fine for terminating the number,
+ * otherwise check that the suffix is just one character.
+ */
+c = *endptr++;
+if (isspace(c) || c == '\0') {
+c = 0;
+} else if (!isspace(*endptr) && *endptr != 0) {
+goto fail;
+}
+switch (c) {
+case 'B':
+case 'b':
+mul = 1;
+if (mul_required) {
+goto fail;
+}
+break;
+case 'K':
+case 'k':
+mul = 1 << 10;
+break;
+case 0:
+if (mul_required) {
+goto fail;
+}
+case 'M':
+case 'm':
+mul = 1ULL << 20;
+break;
+case 'G':
+case 'g':
+mul = 1ULL << 30;
+break;
+case 'T':
+case 't':
+mul = 1ULL << 40;
+break;
+default:
+goto fail;
+}
+tmpval = (val * mul);
+if (tmpval >= ~(size_t)0) {
+goto fail;
+}
+retval = tmpval;
+
+if (end) {
+*end = endptr;
+}
+
+fail:
+return retval;
+}
diff --git a/qemu-common.h b/qemu-common.h
index 81aafa0..0a062d4 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -153,6 +153,7 @@ time_t mktimegm(struct tm *tm);
 int qemu_fls(int i);
 int qemu_fdatasync(int fd);
 int fcntl_setfl(int fd, int flag);
+ssize_t strtosz(const char *nptr, char **end);
 
 /* path.c */
 void init_paths(const char *prefix);
diff --git a/vl.c b/vl.c
index df414ef..6043fa2 100644
--- a/vl.c
+++ b/vl.c
@@ -734,16 +734,13 @@ static void numa_add(const char *optarg)
 if (get_param_value(option, 128, "mem", optarg) == 0) {
 node_mem[nodenr] = 0;
 } else {
-value = strtoull(option, &endptr, 0);
-switch (*endptr) {
-case 0: case 'M': case 'm':
-value <<= 20;
-break;
-case 'G': case 'g':
-value <<= 30;
-break;
+ssize_t sval;
+sval = strtosz(option, NULL);
+if (sval < 0) {
+fprintf(stderr, "qemu: invalid numa mem size: %s\n", optarg);
+exit(1);
 }
-node_mem[nodenr] = value;
+node_mem[nodenr] = sval;
 }
 if (get_param_value(option, 128, "cpus", optarg) == 0) {
 node_cpumask[nodenr] = 0;
@@ -2163,18 +2160,10 @@ int main(int argc, char **argv, char **envp)
 exit(0);
 break;
 case QEMU_OPTION_m: {
-uint64_t value;
-char *ptr;
+ssize_t value;
 
-value = strtoul(optarg, &ptr, 10);
-switch (*ptr) {
-case 0: case 'M': case 'm':
-value <<= 20;
-break;
-case 'G': case 'g':
-value <<= 30;
-break;
-default:
+value = strtosz(optarg, NULL);
+if (value < 0) {
 fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
 exit(1);
 }
-- 
1.7.2.3




[Qemu-devel] [PATCH 2/4] Add support for 'o' octet (bytes) format as monitor parameter.

2010-10-12 Thread Jes . Sorensen
From: Jes Sorensen 

Octet format relies on strtosz which supports K/k, M/m, G/g, T/t
suffixes and unit support for humans, like 1.3G

Signed-off-by: Jes Sorensen 
---
 monitor.c |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/monitor.c b/monitor.c
index fbb678d..b0ea5a3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -78,6 +78,11 @@
  * 'l'  target long (32 or 64 bit)
  * 'M'  just like 'l', except in user mode the value is
  *  multiplied by 2^20 (think Mebibyte)
+ * 'o'  octets (aka bytes)
+ *  user mode accepts an optional T, t, G, g, M, m, K, k
+ *  suffix, which multiplies the value by 2^40 for
+ *  suffixes T and t, 2^30 for suffixes G and g, 2^20 for
+ *  M and m, 2^10 for K and k
  * 'f'  double
  *  user mode accepts an optional G, g, M, m, K, k suffix,
  *  which multiplies the value by 2^30 for suffixes G and
@@ -3699,6 +3704,29 @@ static const mon_cmd_t *monitor_parse_command(Monitor 
*mon,
 qdict_put(qdict, key, qint_from_int(val));
 }
 break;
+case 'o':
+{
+ssize_t val;
+char *end;
+
+while (qemu_isspace(*p)) {
+p++;
+}
+if (*typestr == '?') {
+typestr++;
+if (*p == '\0') {
+break;
+}
+}
+val = strtosz(p, &end);
+if (val < 0) {
+monitor_printf(mon, "invalid size\n");
+goto fail;
+}
+qdict_put(qdict, key, qint_from_int(val));
+p = end;
+}
+break;
 case 'f':
 case 'T':
 {
@@ -4196,6 +4224,7 @@ static int check_client_args_type(const QDict 
*client_args,
 case 'i':
 case 'l':
 case 'M':
+case 'o':
 if (qobject_type(client_arg) != QTYPE_QINT) {
 qerror_report(QERR_INVALID_PARAMETER_TYPE, client_arg_name,
   "int");
-- 
1.7.2.3




[Qemu-devel] [PATCH 4/4] Remove obsolete 'f' double parameter type

2010-10-12 Thread Jes . Sorensen
From: Jes Sorensen 

'f' double is no longer used, and we should be using floating point
variables to store byte sizes. Remove it.

Signed-off-by: Jes Sorensen 
---
 monitor.c |   18 +-
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/monitor.c b/monitor.c
index b0ea5a3..078a66e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -83,10 +83,6 @@
  *  suffix, which multiplies the value by 2^40 for
  *  suffixes T and t, 2^30 for suffixes G and g, 2^20 for
  *  M and m, 2^10 for K and k
- * 'f'  double
- *  user mode accepts an optional G, g, M, m, K, k suffix,
- *  which multiplies the value by 2^30 for suffixes G and
- *  g, 2^20 for M and m, 2^10 for K and k
  * 'T'  double
  *  user mode accepts an optional ms, us, ns suffix,
  *  which divides the value by 1e3, 1e6, 1e9, respectively
@@ -3727,7 +3723,6 @@ static const mon_cmd_t *monitor_parse_command(Monitor 
*mon,
 p = end;
 }
 break;
-case 'f':
 case 'T':
 {
 double val;
@@ -3743,17 +3738,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor 
*mon,
 if (get_double(mon, &val, &p) < 0) {
 goto fail;
 }
-if (c == 'f' && *p) {
-switch (*p) {
-case 'K': case 'k':
-val *= 1 << 10; p++; break;
-case 'M': case 'm':
-val *= 1 << 20; p++; break;
-case 'G': case 'g':
-val *= 1 << 30; p++; break;
-}
-}
-if (c == 'T' && p[0] && p[1] == 's') {
+if (p[0] && p[1] == 's') {
 switch (*p) {
 case 'm':
 val /= 1e3; p += 2; break;
@@ -4231,7 +4216,6 @@ static int check_client_args_type(const QDict 
*client_args,
 return -1; 
 }
 break;
-case 'f':
 case 'T':
 if (qobject_type(client_arg) != QTYPE_QINT &&
 qobject_type(client_arg) != QTYPE_QFLOAT) {
-- 
1.7.2.3




[Qemu-devel] [PATCH 3/4] Switch migrate_set_speed() to take an 'o' argument rather than a float.

2010-10-12 Thread Jes . Sorensen
From: Jes Sorensen 

Clarify default value of MB in migration speed argument in monitor, if
no suffix is specified. This differ from previous default of bytes,
but is consistent with the rest of the places where we accept a size
argument.

Signed-off-by: Jes Sorensen 
---
 hmp-commands.hx |5 +++--
 migration.c |4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 81999aa..e5585ba 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -754,9 +754,10 @@ ETEXI
 
 {
 .name   = "migrate_set_speed",
-.args_type  = "value:f",
+.args_type  = "value:o",
 .params = "value",
-.help   = "set maximum speed (in bytes) for migrations",
+.help   = "set maximum speed (in bytes) for migrations. "
+   "Defaults to MB if no size suffix is specified, ie. B/K/M/G/T",
 .user_print = monitor_user_noop,
 .mhandler.cmd_new = do_migrate_set_speed,
 },
diff --git a/migration.c b/migration.c
index 468d517..9ee8b17 100644
--- a/migration.c
+++ b/migration.c
@@ -132,10 +132,10 @@ int do_migrate_cancel(Monitor *mon, const QDict *qdict, 
QObject **ret_data)
 
 int do_migrate_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
-double d;
+int64_t d;
 FdMigrationState *s;
 
-d = qdict_get_double(qdict, "value");
+d = qdict_get_int(qdict, "value");
 d = MAX(0, MIN(UINT32_MAX, d));
 max_throttle = d;
 
-- 
1.7.2.3




[Qemu-devel] [PATCH v6 0/4] Introduce strtosz and make use of it

2010-10-12 Thread Jes . Sorensen
From: Jes Sorensen 

This patch introduces cutils.c: strtosz() and gets rid of the
multiple custom hacks for parsing byte sizes. In addition it adds
supports for specifying human style sizes such as 1.5G. Last it
eliminates the horrible abuse of a float to store the byte size for
migrate_set_speed in the monitor.

New in v6 I rewrote part of the parsing code as suggested by Markus
and Paolo. The new version relies on strtod to do the actual parsing,
eliminating corner cases not caught by the strspn pass. In addition is
should catch incorrect suffixes that are longer than one character,
and uses isspace() instead of just checking for ' '. Last, a B/b
suffix has been added for 'bytes'.

Jes Sorensen (4):
  Introduce strtosz() library function to convert a string to a byte
count.
  Add support for 'o' octet (bytes) format as monitor parameter.
  Switch migrate_set_speed() to take an 'o' argument rather than a
float.
  Remove obsolete 'f' double parameter type

 cutils.c|   79 +++
 hmp-commands.hx |5 ++-
 migration.c |4 +-
 monitor.c   |   47 +
 qemu-common.h   |1 +
 vl.c|   31 +++--
 6 files changed, 125 insertions(+), 42 deletions(-)

-- 
1.7.2.3




Re: [Qemu-devel] virtio_cleanup() missing in virtio-{blk, balloon, 9p}-pci

2010-10-12 Thread M. Mohan Kumar
> Pattern:
> 
> FOO's PCIDeviceInfo method exit is virtio_FOO_exit_pci(), which calls
> virtio_FOO_exit() and virtio_exit_pci().
> 
> virtio_{net,serial}_exit() call virtio_cleanup().
> 
> virtio_blk_exit() doesn't.  Why?
> 
> virtio-balloon-pci uses virtio_exit_pci() as exit method.  No
> virtio_cleanup()?
> 
> virtio-9p-pci doesn't have an exit method.  Doesn't feel right.

9p does not support hot-plug now. We will implement virtio_9p_exit when we are 
adding support for hot-plug



[Qemu-devel] Re: qdev "SUNW,fdtwo" is unusable with -device

2010-10-12 Thread Markus Armbruster
Blue Swirl  writes:

> On Sat, Oct 9, 2010 at 10:09 AM, Markus Armbruster  wrote:
>> Commit 12a71a02 created qdev "SUNW,fdtwo".  It can't be named in
>> -device, because the name contains a comma: "-device SUNW,fdtwo" gets
>> parsed as driver SUNW with property fdtwo.
>>
>> Is this device user-configurable?  Or should no_user be set?
>
> There can be only zero or one floppy controllers. I think no_user
> should be added.

Okay.  What about "sysbus-fdc"?  Only user appears to be mips_jazz.c.

[...]



Re: [Qemu-devel] virtio_cleanup() missing in virtio-{blk, balloon, 9p}-pci

2010-10-12 Thread Markus Armbruster
"M. Mohan Kumar"  writes:

>> Pattern:
>> 
>> FOO's PCIDeviceInfo method exit is virtio_FOO_exit_pci(), which calls
>> virtio_FOO_exit() and virtio_exit_pci().
>> 
>> virtio_{net,serial}_exit() call virtio_cleanup().
>> 
>> virtio_blk_exit() doesn't.  Why?
>> 
>> virtio-balloon-pci uses virtio_exit_pci() as exit method.  No
>> virtio_cleanup()?
>> 
>> virtio-9p-pci doesn't have an exit method.  Doesn't feel right.
>
> 9p does not support hot-plug now. We will implement virtio_9p_exit when we 
> are 
> adding support for hot-plug

If hot plug is not expected to work, perhaps the driver should refuse
it.  Untested sketch:

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 729917d..b09d85d 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -683,6 +683,11 @@ static int virtio_9p_init_pci(PCIDevice *pci_dev)
 VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
 VirtIODevice *vdev;
 
+if (pci_dev->qdev.hotplugged) {
+error_report("Device doesn't support hot plug");
+return -1;
+}
+
 vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
 virtio_init_pci(proxy, vdev,
 PCI_VENDOR_ID_REDHAT_QUMRANET,



[Qemu-devel] Where's gpxe-eepro100-80862449.rom ?

2010-10-12 Thread Markus Armbruster
Commit db667a12 added a reference to ROM file
gpxe-eepro100-80862449.rom, but no such file.  Intentional?



[Qemu-devel] isa-applesmc doesn't handle second instantiation gracefully

2010-10-12 Thread Markus Armbruster
When I try -device isa-applesmc -device isa-applesmc, I get

WARNING: Using AppleSMC with invalid key
qemu: hardware error: register_ioport_read: invalid opaque
[...]

and a core dump.

I know nothing about this device.  Instantiating twice may well make no
sense.  But hw_error() is not a nice way to reject a command line
option.



[Qemu-devel] [Bug 643465] Re: Crash at network boot

2010-10-12 Thread Jes Sorensen
That is really odd, it sounds like memory corruption in the vmware video
driver.

-- 
Crash at network boot
https://bugs.launchpad.net/bugs/643465
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:
When I boot on lan, I crash qemu:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7491a710 (LWP 10614)]
0x005a1de8 in lsi_update_irq (s=0x125d5a0) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/hw/lsi53c895a.c:426
426 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/hw/lsi53c895a.c:
 No such file or directory.
in 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/hw/lsi53c895a.c
(gdb) bt
#0  0x005a1de8 in lsi_update_irq (s=0x125d5a0) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/hw/lsi53c895a.c:426
#1  0x005a4f67 in lsi_mmio_writew (opaque=0x125d5a0, addr=, val=2) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/hw/lsi53c895a.c:1775
#2  0x004fdf3b in cpu_physical_memory_rw (addr=4043505728, 
buf=0x77ff2028 "\002", len=2, is_write=1) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/exec.c:3215
#3  0x0042bf65 in handle_mmio (env=0xcaa6d0) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/qemu-kvm.c:831
#4  kvm_run (env=0xcaa6d0) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/qemu-kvm.c:979
#5  0x0042c249 in kvm_cpu_exec (env=0x125d5a0) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/qemu-kvm.c:1651
#6  0x0042c471 in kvm_main_loop_cpu (_env=) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/qemu-kvm.c:1893
#7  ap_main_loop (_env=) at 
/var/tmp/portage/app-emulation/qemu-kvm-0.12.5-r1/work/qemu-kvm-0.12.5/qemu-kvm.c:1943
#8  0x779c0894 in start_thread (arg=) at 
pthread_create.c:297
#9  0x75ac927d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:115





[Qemu-devel] Re: isa-applesmc doesn't handle second instantiation gracefully

2010-10-12 Thread Alexander Graf

On 12.10.2010, at 14:50, Markus Armbruster wrote:

> When I try -device isa-applesmc -device isa-applesmc, I get
> 
>WARNING: Using AppleSMC with invalid key
>qemu: hardware error: register_ioport_read: invalid opaque
>[...]
> 
> and a core dump.
> 
> I know nothing about this device.  Instantiating twice may well make no
> sense.  But hw_error() is not a nice way to reject a command line
> option.

I'd guess it fails because it defaults to the same port twice, so allocating it 
twice would put two ISA devices on the same PIO port which doesn't work.

I don't think there's any way around this, or is there?


Alex




[Qemu-devel] [PATCH 0/2] usb-ccid device (v2)

2010-10-12 Thread Alon Levy
This patch adds a new device, it is described in full in the second patch
intro and also in the documentation in docs. In brief it provides a standard
smart card reader device.

The first patch is the configure change and docs.
The second patch contains the actual device, I couldn't figure out a good
way to split it to ease review.

v2 changed:
 * all QSIMPLEQ turned into fixed sized rings
 * all allocated buffers turned into fixed size buffers
 * added migration support
 * added a message to tell client qemu has migrated to ip:port
  * for lack of monitor commands ip:port are 0:0, which causes the updated
   vscclient to connect to one port higher on the same host. will add monitor
   commands in a separate patch. tested with current setup.

Alon Levy (2):
  usb-ccid: add CCID device. add configure option.
  usb-ccid: add CCID device (device itself)

 Makefile.objs  |1 +
 configure  |   12 +
 docs/usb-ccid.txt  |  115 +
 hw/usb-ccid.c  | 1376 
 hw/vscard_common.h |  131 +
 5 files changed, 1635 insertions(+), 0 deletions(-)
 create mode 100644 docs/usb-ccid.txt
 create mode 100644 hw/usb-ccid.c
 create mode 100644 hw/vscard_common.h

-- 
1.7.3.1




[Qemu-devel] [PATCH 1/2] usb-ccid: add CCID device. add configure option.

2010-10-12 Thread Alon Levy
This patch adds the configure option --enable-smartcard, adds hw/usb-ccid.c
to Makefile.objs, and adds the documentation. Only an empty hw/usb-ccid.c
is provided (couldn't add an empty file so added initial comment only).

Signed-off-by: Alon Levy 
---
 Makefile.objs  |1 +
 configure  |   12 +
 docs/usb-ccid.txt  |  115 +
 hw/usb-ccid.c  |   13 +
 hw/vscard_common.h |  131 
 5 files changed, 272 insertions(+), 0 deletions(-)
 create mode 100644 docs/usb-ccid.txt
 create mode 100644 hw/usb-ccid.c
 create mode 100644 hw/vscard_common.h

diff --git a/Makefile.objs b/Makefile.objs
index 9c13bb3..4b581e7 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -170,6 +170,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o
 hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o
 hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o
 hw-obj-$(CONFIG_DMA) += dma.o
+hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o
 
 # PPC devices
 hw-obj-$(CONFIG_OPENPIC) += openpic.o
diff --git a/configure b/configure
index e0d34fd..fc59a40 100755
--- a/configure
+++ b/configure
@@ -327,6 +327,7 @@ user_pie="no"
 zero_malloc=""
 trace_backend="nop"
 trace_file="trace"
+smartcard="no"
 
 # OS specific
 if check_define __linux__ ; then
@@ -730,6 +731,10 @@ for opt do
   ;;
   --enable-vhost-net) vhost_net="yes"
   ;;
+  --disable-smartcard) smartcard="no"
+  ;;
+  --enable-smartcard) smartcard="yes"
+  ;;
   --*dir)
   ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
@@ -921,6 +926,8 @@ echo "  --enable-vhost-net   enable vhost-net 
acceleration support"
 echo "  --trace-backend=BTrace backend nop simple ust"
 echo "  --trace-file=NAMEFull PATH,NAME of file to store traces"
 echo "   Default:trace-"
+echo "  --disable-smartcard  disable smartcard support"
+echo "  --enable-smartcard   enable smartcard support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -2285,6 +2292,7 @@ echo "uuid support  $uuid"
 echo "vhost-net support $vhost_net"
 echo "Trace backend $trace_backend"
 echo "Trace output file $trace_file-"
+echo "smartcard support $smartcard"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2540,6 +2548,10 @@ if test "$posix_madvise" = "yes" ; then
   echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
 fi
 
+if test "$smartcard" = "yes" ; then
+  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
+fi
+
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
diff --git a/docs/usb-ccid.txt b/docs/usb-ccid.txt
new file mode 100644
index 000..e418456
--- /dev/null
+++ b/docs/usb-ccid.txt
@@ -0,0 +1,115 @@
+Contents
+1. What is the USB CCID device?
+2. What is it the CCID used for?
+3. How can I remote my smart card reader to the guest?
+4. How do I emulate a smart card using certificates?
+5. Build instructions for qemu with usb-ccid and libcaccard
+6. How does it work?
+
+1. What is the USB CCID device?
+
+The USB CCID device is a USB device implementing the CCID specification, which 
lets one connect smart card readers that implement the same spec. For more 
information see the specification:
+
+ Universal Serial Bus
+ Device Class: Smart Card
+ CCID
+ Specification for
+ Integrated Circuit(s) Cards Interface Devices
+ Revision 1.1
+ April 22rd, 2005
+
+2. What is the CCID used for?
+
+Smartcard are used for authentication, single sign on, decryption in
+public/private schemes and digital signatures. A smartcard reader on the client
+cannot be used on a guest with simple usb passthrough since it will then not be
+available on the client, possibly locking the computer when it is "removed". On
+the other hand this device can let you use the smartcard on both the client and
+the guest machine. It is also possible to have a completely virtual smart card
+reader and smart card (i.e. not backed by a physical device) using this device.
+
+3. How do I remote a smartcard reader to the guest?
+
+After following the building instructions for qemu and vscclient run vscclient 
on the client machine (the one with the smart card reader) and qemu on another 
(possibly the same) machine like this:
+
+Assume we use port 2001 on the qemu machine, which we call qemuhost:
+
+on qemuhost: (run this first, qemu acts as the server)
+
+qemu -chardev socket,server,host=0.0.0.0,port=2001,id=ccid,nowait -usb 
-device usb-ccid,chardev=ccid
+
+on client:
+
+vscclient qemuhost 2001
+
+4. How do I emulate a smartcard using certificates?
+
+qmeu side doesn't change.
+
+on client side:
+create the certificates. vscclient uses libcac_card, which currently uses
+NSS as the backend. To create some self signed certificates using nss:
+
+certutil -d /etc/pki/nssdb -x -t "CT,CT,CT" -S -s "CN=cert1" -n cert1
+
+Note: three certificates are the maximum the emu

[Qemu-devel] [PATCH 2/2] usb-ccid: add CCID device (device itself)

2010-10-12 Thread Alon Levy
A CCID device is a smart card reader. It is a USB device, defined at [2].
The usb-ccid device expects a chardev option and uses the VSCARD protocol
defined in vscard_common.h. It starts as an unattached device
unless auto_attach=1.

The utility vscclient, bundled with libcac_card, provides the client side,
together they provide simultaneous access to the card reader an
the card attached to it, both in the guest and client machines, as opposed t
a simple usb host passthrough. You can also use it to provide a virtual card

 [1] libcac_card http://cgit.freedesktop.org/~alon/cac_card (temporary home)
 written by Robert Relyea 

 [2] http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.

Signed-off-by: Alon Levy 
---
 hw/usb-ccid.c | 1363 +
 1 files changed, 1363 insertions(+), 0 deletions(-)

diff --git a/hw/usb-ccid.c b/hw/usb-ccid.c
index 98805bb..d9d216c 100644
--- a/hw/usb-ccid.c
+++ b/hw/usb-ccid.c
@@ -11,3 +11,1366 @@
  * This code is licenced under the LGPL.
  */
 
+/* References:
+ *
+ * CCID Specification Revision 1.1 April 22nd 2005
+ *  "Universal Serial Bus, Device Class: Smart Card"
+ *  Specification for Integrated Circuit(s) Cards Interface Devices
+ *
+ * KNOWN BUGS
+ * 1. remove/insert can sometimes result in removed state instead of inserted.
+ * This is a result of the following:
+ *  symptom: dmesg shows ERMOTEIO (-121), pcscd shows -99. Thsi happens
+ *  when we send a too short packet, seen in uhci-usb.c, resulting from
+ *  a urb requesting SPD and us returning a smaller packet.
+ *  Not sure which messages trigger this.
+ *
+ */
+
+#include "qemu-common.h"
+#include "qemu-error.h"
+#include "usb.h"
+#include "qemu-char.h"
+
+#include "hw/vscard_common.h"
+
+//#define DEBUG_CCID
+
+static int debug = 0;
+
+#define DPRINTF(lvl, fmt, ...) \
+do { if (lvl <= debug) { printf("usb-ccid: " fmt , ## __VA_ARGS__); } } while 
(0)
+
+#define CCID_DEV_NAME "usb-ccid"
+
+/* The two options for variable sized buffers:
+ * make them constant size, for large enough constant,
+ * or handle the migration complexity - VMState doesn't handle this case.
+ * sizes are expected never to be exceeded, unless client misbehaves. */
+#define BULK_OUT_DATA_SIZE 65536
+#define PENDING_ANSWERS_NUM 128
+#define VSCARD_IN_SIZE 65536
+
+#define BULK_IN_BUF_SIZE 384
+#define BULK_IN_PENDING_NUM 8
+
+#define InterfaceOutClass
((USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE)<<8)
+#define InterfaceInClass ((USB_DIR_IN 
|USB_TYPE_CLASS|USB_RECIP_INTERFACE)<<8)
+
+#define CCID_CONTROL_ABORT  0x1
+#define CCID_CONTROL_GET_CLOCK_FREQUENCIES  0x2
+#define CCID_CONTROL_GET_DATA_RATES 0x3
+
+#define CCID_PRODUCT_DESCRIPTION"QEMU USB CCID"
+#define CCID_VENDOR_DESCRIPTION "QEMU " QEMU_VERSION
+#define CCID_INTERFACE_NAME "CCID Interface"
+#define CCID_SERIAL_NUMBER_STRING   "1"
+/* Using Gemplus Vendor and Product id
+  Effect on various drivers:
+  * usbccid.sys (winxp, others untested) is a class driver so it doesn't care.
+  * linux has a number of class drivers, but openct filters based on
+vendor/product (/etc/openct.conf under fedora), hence Gemplus.
+ */
+#define CCID_VENDOR_ID  0x08e6
+#define CCID_PRODUCT_ID 0x4433
+#define CCID_DEVICE_VERSION 0x
+
+/* BULK_OUT messages from PC to Reader
+   Defined in CCID Rev 1.1 6.1 (page 26)
+ */
+#define CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn  0x62
+#define CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff 0x63
+#define CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus   0x65
+#define CCID_MESSAGE_TYPE_PC_to_RDR_XfrBlock0x6f
+#define CCID_MESSAGE_TYPE_PC_to_RDR_GetParameters   0x6c
+#define CCID_MESSAGE_TYPE_PC_to_RDR_ResetParameters 0x6d
+#define CCID_MESSAGE_TYPE_PC_to_RDR_SetParameters   0x61
+#define CCID_MESSAGE_TYPE_PC_to_RDR_Escape  0x6b
+#define CCID_MESSAGE_TYPE_PC_to_RDR_IccClock0x6e
+#define CCID_MESSAGE_TYPE_PC_to_RDR_T0APDU  0x6a
+#define CCID_MESSAGE_TYPE_PC_to_RDR_Secure  0x69
+#define CCID_MESSAGE_TYPE_PC_to_RDR_Mechanical  0x71
+#define CCID_MESSAGE_TYPE_PC_to_RDR_Abort   0x72
+#define CCID_MESSAGE_TYPE_PC_to_RDR_SetDataRateAndClockFrequency 0x73
+
+/* BULK_IN messages from Reader to PC
+   Defined in CCID Rev 1.1 6.2 (page 48)
+ */
+#define CCID_MESSAGE_TYPE_RDR_to_PC_DataBlock   0x80
+#define CCID_MESSAGE_TYPE_RDR_to_PC_SlotStatus  0x81
+#define CCID_MESSAGE_TYPE_RDR_to_PC_Parameters  0x82
+#define CCID_MESSAGE_TYPE_RDR_to_PC_Escape  0x83
+#define CCID_MESSAGE_TYPE_RDR_to_PC_DataRateAndClockFrequency 0x84
+
+/* INTERRUPT_IN messages from Reader to PC
+   Defined in CCID Rev 1.1 6.3 (page 56)
+ */
+#define CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange0x50
+#define CCID_MESSA

[Qemu-devel] [PATCH 01/39] default compilation tools to environment variables

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   20 +++-
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index d303061..d9f4805 100755
--- a/configure
+++ b/configure
@@ -74,19 +74,13 @@ interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
 sparc_cpu=""
 cross_prefix=""
-cc="gcc"
 audio_drv_list=""
 audio_card_list="ac97 es1370 sb16"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
 block_drv_whitelist=""
 host_cc="gcc"
-ar="ar"
 make="make"
 install="install"
-objcopy="objcopy"
-ld="ld"
-strip="strip"
-windres="windres"
 helper_cflags=""
 libs_softmmu=""
 libs_tools=""
@@ -99,7 +93,7 @@ for opt do
   case "$opt" in
   --cross-prefix=*) cross_prefix="$optarg"
   ;;
-  --cc=*) cc="$optarg"
+  --cc=*) CC="$optarg"
   ;;
   --cpu=*) cpu="$optarg"
   ;;
@@ -128,12 +122,12 @@ done
 # Using uname is really, really broken.  Once we have the right set of checks
 # we can eliminate it's usage altogether
 
-cc="${cross_prefix}${cc}"
-ar="${cross_prefix}${ar}"
-objcopy="${cross_prefix}${objcopy}"
-ld="${cross_prefix}${ld}"
-strip="${cross_prefix}${strip}"
-windres="${cross_prefix}${windres}"
+cc="${cross_prefix}${CC-gcc}"
+ar="${cross_prefix}${AR-ar}"
+objcopy="${cross_prefix}${OBJCOPY-objcopy}"
+ld="${cross_prefix}${LD-ld}"
+strip="${cross_prefix}${STRIP-strip}"
+windres="${cross_prefix}${WINDRES-windres}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
-- 
1.7.2.3





[Qemu-devel] qdev: Some ISA devices don't handle second instantiation gracefully (was: isa-applesmc doesn't handle second instantiation gracefully)

2010-10-12 Thread Markus Armbruster
Markus Armbruster  writes:

> When I try -device isa-applesmc -device isa-applesmc, I get
>
> WARNING: Using AppleSMC with invalid key
> qemu: hardware error: register_ioport_read: invalid opaque
> [...]
>
> and a core dump.
>
> I know nothing about this device.  Instantiating twice may well make no
> sense.  But hw_error() is not a nice way to reject a command line
> option.

Actually, ib700 and isa-debugcon fail the same way.

They call register_ioport_write(), which aborts via hw_error() when the
port is already in use.  This is okay for non-configurable parts of a
board emulation, but not okay for a qdev device, unless it has no_user
set.

Related: when isa_init_irq() finds the requested IRQ already in use, it
fails with exit(1).  Maybe register_ioport_write() & friends should do
that as well.

Or maybe qdev device models should have an "at most one" flag.



[Qemu-devel] [PATCH 02/39] default make and install to environment variables

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   19 ++-
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index d9f4805..598d943 100755
--- a/configure
+++ b/configure
@@ -79,8 +79,6 @@ audio_card_list="ac97 es1370 sb16"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
 block_drv_whitelist=""
 host_cc="gcc"
-make="make"
-install="install"
 helper_cflags=""
 libs_softmmu=""
 libs_tools=""
@@ -360,7 +358,7 @@ GNU/kFreeBSD)
 ;;
 FreeBSD)
   bsd="yes"
-  make="gmake"
+  make="${MAKE-gmake}"
   audio_drv_list="oss"
   audio_possible_drivers="oss sdl esd pa"
   # needed for kinfo_getvmmap(3) in libutil.h
@@ -368,20 +366,20 @@ FreeBSD)
 ;;
 DragonFly)
   bsd="yes"
-  make="gmake"
+  make="${MAKE-gmake}"
   audio_drv_list="oss"
   audio_possible_drivers="oss sdl esd pa"
 ;;
 NetBSD)
   bsd="yes"
-  make="gmake"
+  make="${MAKE-gmake}"
   audio_drv_list="oss"
   audio_possible_drivers="oss sdl esd"
   oss_lib="-lossaudio"
 ;;
 OpenBSD)
   bsd="yes"
-  make="gmake"
+  make="${MAKE-gmake}"
   audio_drv_list="oss"
   audio_possible_drivers="oss sdl esd"
   oss_lib="-lossaudio"
@@ -410,8 +408,8 @@ Darwin)
 ;;
 SunOS)
   solaris="yes"
-  make="gmake"
-  install="ginstall"
+  make="${MAKE-gmake}"
+  install="${INSTALL-ginstall}"
   ld="gld"
   needs_libsunmath="no"
   solarisrev=`uname -r | cut -f2 -d.`
@@ -450,7 +448,7 @@ SunOS)
 ;;
 AIX)
   aix="yes"
-  make="gmake"
+  make="${MAKE-gmake}"
 ;;
 Haiku)
   haiku="yes"
@@ -476,6 +474,9 @@ if [ "$bsd" = "yes" ] ; then
   bsd_user="yes"
 fi
 
+: ${make=${MAKE-make}}
+: ${install=${INSTALL-install}}
+
 if test "$mingw32" = "yes" ; then
   EXESUF=".exe"
   QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
-- 
1.7.2.3





[Qemu-devel] [PATCH 03/39] move feature variables to the top

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |  160 ++--
 1 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/configure b/configure
index 598d943..9e2ae71 100755
--- a/configure
+++ b/configure
@@ -85,6 +85,86 @@ libs_tools=""
 audio_pt_int=""
 audio_win_int=""
 
+target_list=""
+
+# Default value for a variable defining feature "foo".
+#  * foo="no"  feature will only be used if --enable-foo arg is given
+#  * foo=""feature will be searched for, and if found, will be used
+#  unless --disable-foo is given
+#  * foo="yes" this value will only be set by --enable-foo flag.
+#  feature will searched for,
+#  if not found, configure exits with error
+#
+# Always add --enable-foo and --disable-foo command line args.
+# Distributions want to ensure that several features are compiled in, and it
+# is impossible without a --enable-foo that exits if a feature is not found.
+
+bluez=""
+brlapi=""
+curl=""
+curses=""
+docs=""
+fdt=""
+kvm=""
+kvm_para=""
+nptl=""
+sdl=""
+sparse="no"
+uuid=""
+vde=""
+vnc_tls=""
+vnc_sasl=""
+vnc_jpeg=""
+vnc_png=""
+vnc_thread="no"
+xen=""
+linux_aio=""
+attr=""
+vhost_net=""
+
+gprof="no"
+debug_tcg="no"
+debug_mon="no"
+debug="no"
+strip_opt="yes"
+bigendian="no"
+mingw32="no"
+EXESUF=""
+prefix="/usr/local"
+mandir="\${prefix}/share/man"
+datadir="\${prefix}/share/qemu"
+docdir="\${prefix}/share/doc/qemu"
+bindir="\${prefix}/bin"
+sysconfdir="\${prefix}/etc"
+confsuffix="/qemu"
+slirp="yes"
+fmod_lib=""
+fmod_inc=""
+oss_lib=""
+bsd="no"
+linux="no"
+solaris="no"
+profiler="no"
+cocoa="no"
+softmmu="yes"
+linux_user="no"
+darwin_user="no"
+bsd_user="no"
+guest_base=""
+uname_release=""
+io_thread="no"
+mixemu="no"
+kerneldir=""
+aix="no"
+blobs="yes"
+pkgversion=""
+check_utests="no"
+user_pie="no"
+zero_malloc=""
+trace_backend="nop"
+trace_file="trace"
+spice=""
+
 # parse CC options first
 for opt do
   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
@@ -207,7 +287,6 @@ else
   cpu=`uname -m`
 fi
 
-target_list=""
 case "$cpu" in
   alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
 cpu="$cpu"
@@ -245,85 +324,6 @@ case "$cpu" in
   ;;
 esac
 
-# Default value for a variable defining feature "foo".
-#  * foo="no"  feature will only be used if --enable-foo arg is given
-#  * foo=""feature will be searched for, and if found, will be used
-#  unless --disable-foo is given
-#  * foo="yes" this value will only be set by --enable-foo flag.
-#  feature will searched for,
-#  if not found, configure exits with error
-#
-# Always add --enable-foo and --disable-foo command line args.
-# Distributions want to ensure that several features are compiled in, and it
-# is impossible without a --enable-foo that exits if a feature is not found.
-
-bluez=""
-brlapi=""
-curl=""
-curses=""
-docs=""
-fdt=""
-kvm=""
-kvm_para=""
-nptl=""
-sdl=""
-sparse="no"
-uuid=""
-vde=""
-vnc_tls=""
-vnc_sasl=""
-vnc_jpeg=""
-vnc_png=""
-vnc_thread="no"
-xen=""
-linux_aio=""
-attr=""
-vhost_net=""
-
-gprof="no"
-debug_tcg="no"
-debug_mon="no"
-debug="no"
-strip_opt="yes"
-bigendian="no"
-mingw32="no"
-EXESUF=""
-prefix="/usr/local"
-mandir="\${prefix}/share/man"
-datadir="\${prefix}/share/qemu"
-docdir="\${prefix}/share/doc/qemu"
-bindir="\${prefix}/bin"
-sysconfdir="\${prefix}/etc"
-confsuffix="/qemu"
-slirp="yes"
-fmod_lib=""
-fmod_inc=""
-oss_lib=""
-bsd="no"
-linux="no"
-solaris="no"
-profiler="no"
-cocoa="no"
-softmmu="yes"
-linux_user="no"
-darwin_user="no"
-bsd_user="no"
-guest_base=""
-uname_release=""
-io_thread="no"
-mixemu="no"
-kerneldir=""
-aix="no"
-haiku="no"
-blobs="yes"
-pkgversion=""
-check_utests="no"
-user_pie="no"
-zero_malloc=""
-trace_backend="nop"
-trace_file="trace"
-spice=""
-
 # OS specific
 if check_define __linux__ ; then
   targetos="Linux"
-- 
1.7.2.3





[Qemu-devel] [PATCH 00/39] Make configure command line autoconf-compatible

2010-10-12 Thread Paolo Bonzini
Here is the patch series implementing the idea I mentioned a while ago.

The first 14 introduce small changes to group pieces of code together
and help understanding/reviewing the next changes.  Most of them are
just cosmetic changes, though some of them have small behavioral changes.

After these come 19 patches that introduce autoconf-compatible aliases
for options not respecting the autoconf command-line syntax.  The old
versions are deprecated, but there is no change in semantics: the new
aliases take exactly the same syntax.

There are also patches also rename the "interp_prefix" and "source_path"
concepts to "sysroot" and "srcdir", which is consistent with GNU Makefile
standards and with the  with the new aliasesnew aliases.

Patches 34 to 36 introduce new command-line options for cross-compilation
that are again compatible with the GNU standards.  With these changes
it is more or less possible to drop QEMU inside a GCC/binutils tree
configured for cross-compilation and make it build together.

Patch 37 is a simple change to the help text now that the command-line
syntax is finalized.

Patch 38 and 39, finally, make a few more baby steps using host triplets
instead of custom feature detection.

Paolo Bonzini (39):
  default compilation tools to environment variables
  default make and install to environment variables
  move feature variables to the top
  fix sparse support (?)
  test cc with the complete set of chosen flags
  include failed source file in config.log
  do not pass bogus $(srcdir) include paths to cc during configure
  provide portable sizeof(long) test
  fix spelling of $pkg_config, move default together with other cross tools
  do not default to non-prefixed pkg-config when cross compiling
  reorganize sdl-config tests
  move --srcdir detection earlier
  properly detect compiler in tests/Makefile
  remove HOST_CC mention from roms/{sea,vga}bios/config.mak
  let --host-cc slide into oblivion
  introduce CFLAGS= and LDFLAGS= configure command-line options
  introduce CPPFLAGS configure variable
  add autoconfy alias CC= for --cc
  add CPP variable
  add autoconfy aliases MAKE=/INSTALL= for --make and --install
  add autoconfy aliases --with-* for audio library options
  make trace options use autoconfy names
  deprecate --audio-card-list
  add autoconfy alias --enable-audio-drivers alias for --audio-drv-list
  add autoconfy alias --enable-block-drivers for --block-drv-whitelist
  add libtooly alias --enable-static for --static
  add autoconfy alias --with-sysroot for --interp-prefix
  rename interp_prefix to sysroot
  add autoconfy alias --enable-targets for --target-list
  add autoconfy alias --with-headers for --kerneldir
  add autoconfy alias --srcdir= for --source-path
  rename SRC_PATH to srcdir
  rename source_path to srcdir
  add autoconfy --host= option deprecating --cross-prefix
  add autoconfy --build= option to be used instead of undocumented --cpu
  add autoconfy --with-arch= option, compatible with --sparc-cpu
  make more options "standard"
  provide a more gnuish default sysroot
  use host triplets for feature detection

 Makefile   |   54 +-
 Makefile.dis   |6 +-
 Makefile.hw|8 +-
 Makefile.objs  |4 +-
 Makefile.target|   32 +-
 Makefile.user  |6 +-
 bsd-user/main.c|   10 +-
 config.guess   | 1502 ++
 config.sub | 1731 
 configure  |  757 ++-
 create_config  |5 +-
 darwin-user/machload.c |   12 +-
 darwin-user/main.c |6 +-
 darwin-user/syscall.c  |2 +-
 linux-user/main.c  |   10 +-
 pc-bios/optionrom/Makefile |8 +-
 rules.mak  |   10 +-
 tests/Makefile |   16 +-
 tests/cris/Makefile|6 +-
 19 files changed, 3729 insertions(+), 456 deletions(-)
 create mode 100755 config.guess
 create mode 100755 config.sub

-- 
1.7.2.3




[Qemu-devel] [PATCH 04/39] fix sparse support (?)

2010-10-12 Thread Paolo Bonzini
I didn't test with sparse, but the old code using += before a variable
was set was wrong.  Sparse support should probably be ripped out or
redone, but this at least keeps some sanity.

Signed-off-by: Paolo Bonzini 
---
 configure |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 9e2ae71..6b5c323 100755
--- a/configure
+++ b/configure
@@ -2617,17 +2617,17 @@ echo "INSTALL_DATA=$install -m0644 -p" >> 
$config_host_mak
 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 echo "HOST_CC=$host_cc" >> $config_host_mak
-if test "$sparse" = "yes" ; then
-  echo "CC  := REAL_CC=\"\$(CC)\" cgcc"   >> $config_host_mak
-  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
-  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer 
-Wno-non-pointer-null" >> $config_host_mak
-fi
 echo "AR=$ar" >> $config_host_mak
 echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
+if test "$sparse" = "yes" ; then
+  echo "CC   := REAL_CC=\"\$(CC)\" cgcc"   >> $config_host_mak
+  echo "HOST_CC  := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
+  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer 
-Wno-non-pointer-null" >> $config_host_mak
+fi
 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
-- 
1.7.2.3





[Qemu-devel] [PATCH 12/39] move --srcdir detection earlier

2010-10-12 Thread Paolo Bonzini
This will help getting config.guess and config.sub from the srcdir.

Signed-off-by: Paolo Bonzini 
---
 configure |   28 +++-
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index f61c5b8..e059525 100755
--- a/configure
+++ b/configure
@@ -183,6 +183,9 @@ for opt do
   ;;
   --cc=*) CC="$optarg"
   ;;
+  --source-path=*) source_path="$optarg"
+  source_path_used="yes"
+  ;;
   --cpu=*) cpu="$optarg"
   ;;
   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
@@ -229,6 +232,17 @@ QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
 QEMU_CPPFLAGS="-I. -I\$(SRC_PATH)"
 LDFLAGS="-g $LDFLAGS"
 
+# find source path
+source_path=`dirname "$0"`
+source_path_used="no"
+workdir=`pwd`
+if [ -z "$source_path" ]; then
+source_path=$workdir
+else
+source_path=`cd "$source_path"; pwd`
+fi
+[ -f "$workdir/vl.c" ] || source_path_used="yes"
+
 check_define() {
 cat > $TMPC <

[Qemu-devel] [PATCH 06/39] include failed source file in config.log

2010-10-12 Thread Paolo Bonzini
Also clean config.log from distclean.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |2 +-
 configure |   21 +
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index d9971c3..34c2a6c 100644
--- a/Makefile
+++ b/Makefile
@@ -160,7 +160,7 @@ clean:
 done
 
 distclean: clean
-   rm -f config-host.mak config-host.h* config-host.ld $(DOCS) 
qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
+   rm -f config-host.mak config-host.h* config-host.ld $(DOCS) 
qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi config.log
rm -f qemu-options.def
rm -f config-all-devices.mak
rm -f roms/seabios/config.mak roms/vgabios/config.mak
diff --git a/configure b/configure
index 8cd034a..a8738db 100755
--- a/configure
+++ b/configure
@@ -20,16 +20,26 @@ TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
 trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
 rm -f config.log
 
+run_cc() {
+  echo "$cc $@" >&5
+  if $cc "$@" >&5 2>&5; then
+return 0
+  else
+echo exit status is $? >&5
+echo failed program was: >&5
+sed 's/^/| /' $TMPC >&5
+return 1
+  fi
+}
+
 compile_object() {
-  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
-  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
+  run_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
 }
 
 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags 
>> config.log
-  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> 
config.log 2>&1
+  run_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
 }
 
 # check whether a command is available to this shell (may be either an
@@ -906,6 +916,9 @@ echo "NOTE: The object files are built at the place where 
configure is launched"
 exit 1
 fi
 
+# create config.log file
+exec 5>config.log
+
 # check that the C compiler works.
 cat > $TMPC <

[Qemu-devel] [PATCH 13/39] properly detect compiler in tests/Makefile

2010-10-12 Thread Paolo Bonzini
`make speed' only makes sense if not cross-compiling, so sha1 can
use the CC for the system that is hosting qemu.  sha1-i386 is also
wrong, since there is usually no variable for the target CC; guess
some plausible values.

Signed-off-by: Paolo Bonzini 
---
 tests/Makefile |   14 --
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index ff7f787..a789e2d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -64,11 +64,21 @@ linux-test: linux-test.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
 
 # speed test
+ifeq ($(shell uname -m), x86_64)
+CC_I386 = $(CC) -m32
+else
+ifeq ($(shell uname -m), i386)
+CC_I386 = $(CC)
+else
+CC_I386 = i386-pc-linux-gnu-$(CC)
+endif
+endif
+
 sha1-i386: sha1.c
-   $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+   $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
 
 sha1: sha1.c
-   $(HOST_CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+   $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
 
 speed: sha1 sha1-i386
time ./sha1
-- 
1.7.2.3





[Qemu-devel] [PATCH 05/39] test cc with the complete set of chosen flags

2010-10-12 Thread Paolo Bonzini
The "test the C compiler works ok" comes before a bunch of flags
are added for --cpu or just depending on the host.  It helps
debugging if the test is done after these flags are (unconditionally)
added.

Signed-off-by: Paolo Bonzini 
---
 configure |   50 +-
 1 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index 6b5c323..8cd034a 100755
--- a/configure
+++ b/configure
@@ -217,31 +217,6 @@ QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
 QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
 LDFLAGS="-g $LDFLAGS"
 
-gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
-gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers 
$gcc_flags"
-gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
-gcc_flags="-fstack-protector-all $gcc_flags"
-cat > $TMPC << EOF
-int main(void) { return 0; }
-EOF
-for flag in $gcc_flags; do
-if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
-   QEMU_CFLAGS="$flag $QEMU_CFLAGS"
-fi
-done
-
-# check that the C compiler works.
-cat > $TMPC < $TMPC < $TMPC < $TMPC << EOF
+int main(void) { return 0; }
+EOF
+for flag in $gcc_flags; do
+if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
+   QEMU_CFLAGS="$flag $QEMU_CFLAGS"
+fi
+done
+
 #
 # Solaris specific configure tool chain decisions
 #
-- 
1.7.2.3





[Qemu-devel] [PATCH 07/39] do not pass bogus $(SRC_PATH) include paths to cc during configure

2010-10-12 Thread Paolo Bonzini
Non-existent -I paths are dropped silently by the compiler, but still
it is not polite to pass bogus options.  Configure-time tests do not
need any include files from the source path, so only include -I flags
at make time (when they're properly expanded).

Signed-off-by: Paolo Bonzini 
---
 configure |   19 +++
 rules.mak |8 
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index a8738db..cb76177 100755
--- a/configure
+++ b/configure
@@ -224,7 +224,7 @@ QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings 
-Wmissing-prototypes $
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
$QEMU_CFLAGS"
 QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
-QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
+QEMU_CPPFLAGS="-I. -I\$(SRC_PATH)"
 LDFLAGS="-g $LDFLAGS"
 
 check_define() {
@@ -2419,7 +2419,7 @@ if test $profiler = "yes" ; then
 fi
 if test "$slirp" = "yes" ; then
   echo "CONFIG_SLIRP=y" >> $config_host_mak
-  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
+  QEMU_CPPFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CPPFLAGS"
 fi
 if test "$vde" = "yes" ; then
   echo "CONFIG_VDE=y" >> $config_host_mak
@@ -2636,6 +2636,7 @@ echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
+echo "QEMU_CPPFLAGS=$QEMU_CPPFLAGS" >> $config_host_mak
 if test "$sparse" = "yes" ; then
   echo "CC   := REAL_CC=\"\$(CC)\" cgcc"   >> $config_host_mak
   echo "HOST_CC  := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
@@ -2944,19 +2945,20 @@ fi
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
 cflags=""
+cppflags=""
 ldflags=""
 
 if test "$ARCH" = "sparc64" ; then
-  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/sparc $cppflags"
 elif test "$ARCH" = "s390x" ; then
-  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/s390 $cppflags"
 elif test "$ARCH" = "x86_64" ; then
-  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/i386 $cppflags"
 else
-  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cppflags"
 fi
-cflags="-I\$(SRC_PATH)/tcg $cflags"
-cflags="-I\$(SRC_PATH)/fpu $cflags"
+cppflags="-I\$(SRC_PATH)/tcg $cppflags"
+cppflags="-I\$(SRC_PATH)/fpu $cppflags"
 
 if test "$target_user_only" = "yes" ; then
 libdis_config_mak=libdis-user/config.mak
@@ -3081,6 +3083,7 @@ fi
 
 echo "LDFLAGS+=$ldflags" >> $config_target_mak
 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
+echo "QEMU_CPPFLAGS+=$cppflags" >> $config_target_mak
 
 done # for target in $targets
 
diff --git a/rules.mak b/rules.mak
index c843a13..007fc49 100644
--- a/rules.mak
+++ b/rules.mak
@@ -15,15 +15,15 @@ MAKEFLAGS += -rR
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
 %.o: %.c
-   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c 
-o $@ $<,"  CC$(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC$(TARGET_DIR)$@")
 
 %.o: %.S
-   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c 
-o $@ $<,"  AS$(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS$(TARGET_DIR)$@")
 
 %.o: %.m
-   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c 
-o $@ $<,"  OBJC  $(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ 
$(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
+LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(CFLAGS) 
$(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
 
 %$(EXESUF): %.o
$(call LINK,$^)
-- 
1.7.2.3





[Qemu-devel] [PATCH 18/39] add autoconfy alias CC= for --cc

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 7f2e2a4..1ea56f7 100755
--- a/configure
+++ b/configure
@@ -180,7 +180,7 @@ for opt do
   case "$opt" in
   --cross-prefix=*) cross_prefix="$optarg"
   ;;
-  --cc=*) CC="$optarg"
+  CC=*|--cc=*) CC="$optarg"
   ;;
   --source-path=*) source_path="$optarg"
   source_path_used="yes"
@@ -517,7 +517,7 @@ for opt do
   ;;
   --cross-prefix=*)
   ;;
-  --cc=*)
+  CC=*|--cc=*)
   ;;
   --host-cc=*)
   ;;
@@ -828,7 +828,6 @@ echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
-echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo "  --static enable static build [$static]"
@@ -924,10 +923,12 @@ echo "  --disable-spice  disable spice"
 echo "  --enable-spice   enable spice"
 echo ""
 echo "Deprecated options:"
+echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
+echo "  CC  C compiler command"
 echo "  CFLAGS  C compiler flags"
 echo "  CPPFLAGSC preprocessor flags, e.g. -I if you have"
 echo "  headers in a nonstandard directory "
-- 
1.7.2.3





[Qemu-devel] [PATCH 17/39] introduce CPPFLAGS configure variable

2010-10-12 Thread Paolo Bonzini
Be consistent with Autoconf-generated scripts.

Signed-off-by: Paolo Bonzini 
---
 configure |8 
 rules.mak |8 
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 2a2f64e..7f2e2a4 100755
--- a/configure
+++ b/configure
@@ -189,6 +189,8 @@ for opt do
   ;;
   CFLAGS=*) CFLAGS="$CFLAGS"
   ;;
+  CPPFLAGS=*) CPPFLAGS="$CFLAGS"
+  ;;
   LDFLAGS=*) LDFLAGS="$LDFLAGS"
   ;;
   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
@@ -523,6 +525,8 @@ for opt do
   ;;
   --install=*) install="$optarg"
   ;;
+  CPPFLAGS=*)
+  ;;
   CFLAGS=*|--extra-cflags=*)
   ;;
   LDFLAGS=*|--extra-ldflags=*)
@@ -925,6 +929,8 @@ echo "  --extra-ldflags=LDFLAGS  append extra linker flags 
LDFLAGS"
 echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
 echo "  CFLAGS  C compiler flags"
+echo "  CPPFLAGSC preprocessor flags, e.g. -I if you have"
+echo "  headers in a nonstandard directory "
 echo "  LDFLAGS linker flags, e.g. -L if you have libraries in a"
 echo "  nonstandard directory "
 echo ""
@@ -2284,6 +2290,7 @@ fi
 echo "Source path   $source_path"
 echo "C compiler$cc"
 echo "CFLAGS$CFLAGS"
+echo "CPPFLAGS  $CPPFLAGS"
 echo "QEMU_CFLAGS   $QEMU_CFLAGS"
 echo "LDFLAGS   $LDFLAGS"
 echo "make  $make"
@@ -2650,6 +2657,7 @@ echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
+echo "CPPFLAGS=$CPPFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_CPPFLAGS=$QEMU_CPPFLAGS" >> $config_host_mak
 if test "$sparse" = "yes" ; then
diff --git a/rules.mak b/rules.mak
index 007fc49..b4b7e16 100644
--- a/rules.mak
+++ b/rules.mak
@@ -15,15 +15,15 @@ MAKEFLAGS += -rR
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
 %.o: %.c
-   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC$(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<,"  CC$(TARGET_DIR)$@")
 
 %.o: %.S
-   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS$(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<,"  AS$(TARGET_DIR)$@")
 
 %.o: %.m
-   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
+   $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(CFLAGS) 
$(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
+LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(CFLAGS) 
$(CPPFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
 
 %$(EXESUF): %.o
$(call LINK,$^)
-- 
1.7.2.3





[Qemu-devel] [PATCH 20/39] add autoconfy aliases MAKE=/INSTALL= for --make and --install

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 8273f84..547f8e9 100755
--- a/configure
+++ b/configure
@@ -526,9 +526,9 @@ for opt do
   ;;
   --host-cc=*)
   ;;
-  --make=*) make="$optarg"
+  MAKE=*|--make=*) make="$optarg"
   ;;
-  --install=*) install="$optarg"
+  INSTALL=*|--install=*) install="$optarg"
   ;;
   CPPFLAGS=*)
   ;;
@@ -833,8 +833,6 @@ echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
-echo "  --make=MAKE  use specified make [$make]"
-echo "  --install=INSTALLuse specified install [$install]"
 echo "  --static enable static build [$static]"
 echo "  --mandir=PATHinstall man pages in PATH"
 echo "  --datadir=PATH   install firmware in PATH"
@@ -931,6 +929,8 @@ echo "Deprecated options:"
 echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
+echo "  --make=MAKE  use specified make [$make]"
+echo "  --install=INSTALLuse specified install [$install]"
 echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
 echo "  CC  C compiler command"
@@ -940,6 +940,8 @@ echo "  CPPFLAGSC preprocessor flags, e.g. -I if you have"
 echo "  headers in a nonstandard directory "
 echo "  LDFLAGS linker flags, e.g. -L if you have libraries in a"
 echo "  nonstandard directory "
+echo "  MAKEuse specified make [$make]"
+echo "  INSTALL use specified install [$install]"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -980,7 +982,7 @@ if test "$solaris" = "yes" ; then
   if has $install; then
 :
   else
-echo "Solaris install program not found. Use --install=/usr/ucb/install or"
+echo "Solaris install program not found. Use INSTALL=/usr/ucb/install or"
 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
 echo "to get ginstall which is used by default (which lives in 
/opt/csw/bin)"
 exit 1
@@ -988,7 +990,7 @@ if test "$solaris" = "yes" ; then
   if test "`path_of $install`" = "/usr/sbin/install" ; then
 echo "Error: Solaris /usr/sbin/install is not an appropriate install 
program."
 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
-echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
+echo "using pkg-get -i fileutils, or use INSTALL=/usr/ucb/install"
 exit 1
   fi
   if has ar; then
-- 
1.7.2.3





[Qemu-devel] [PATCH 09/39] fix spelling of $pkg_config, move default together with other cross tools

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   34 +-
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/configure b/configure
index 873e4a6..ac11d4e 100755
--- a/configure
+++ b/configure
@@ -216,6 +216,7 @@ objcopy="${cross_prefix}${OBJCOPY-objcopy}"
 ld="${cross_prefix}${LD-ld}"
 strip="${cross_prefix}${STRIP-strip}"
 windres="${cross_prefix}${WINDRES-windres}"
+pkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
@@ -1162,12 +1163,11 @@ EOF
 fi
 
 ##
-# pkgconfig probe
+# pkg-config probe
 
-pkgconfig="${cross_prefix}pkg-config"
-if ! has $pkgconfig; then
+if ! has $pkg_config; then
   # likely not cross compiling, or hope for the best
-  pkgconfig=pkg-config
+  pkg_config=pkg-config
 fi
 
 ##
@@ -1189,15 +1189,15 @@ fi
 # Look for sdl configuration program (pkg-config or sdl-config).
 # Prefer variant with cross prefix if cross compiling,
 # and favour pkg-config with sdl over sdl-config.
-if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
- $pkgconfig sdl --modversion >/dev/null 2>&1; then
-  sdlconfig="$pkgconfig sdl"
+if test -n "$cross_prefix" -a $pkg_config != pkg-config && \
+ $pkg_config sdl --modversion >/dev/null 2>&1; then
+  sdlconfig="$pkg_config sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
 elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
   sdlconfig="${cross_prefix}sdl-config"
   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
-elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
-  sdlconfig="$pkgconfig sdl"
+elif $pkg_config sdl --modversion >/dev/null 2>&1; then
+  sdlconfig="$pkg_config sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
 elif has sdl-config; then
   sdlconfig='sdl-config'
@@ -1277,8 +1277,8 @@ if test "$vnc_tls" != "no" ; then
 #include 
 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; 
}
 EOF
-  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
-  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
+  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
+  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
   if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
 vnc_tls=yes
 libs_softmmu="$vnc_tls_libs $libs_softmmu"
@@ -1571,8 +1571,8 @@ fi
 ##
 # curl probe
 
-if $pkgconfig libcurl --modversion >/dev/null 2>&1; then
-  curlconfig="$pkgconfig libcurl"
+if $pkg_config libcurl --modversion >/dev/null 2>&1; then
+  curlconfig="$pkg_config libcurl"
 else
   curlconfig=curl-config
 fi
@@ -1604,7 +1604,7 @@ if test "$check_utests" != "no" ; then
 #include 
 int main(void) { suite_create("qemu test"); return 0; }
 EOF
-  check_libs=`$pkgconfig --libs check`
+  check_libs=`$pkg_config --libs check`
   if compile_prog "" $check_libs ; then
 check_utests=yes
 libs_tools="$check_libs $libs_tools"
@@ -1623,8 +1623,8 @@ if test "$bluez" != "no" ; then
 #include 
 int main(void) { return bt_error(0); }
 EOF
-  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
-  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
+  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
+  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
   if compile_prog "$bluez_cflags" "$bluez_libs" ; then
 bluez=yes
 libs_softmmu="$bluez_libs $libs_softmmu"
@@ -1668,7 +1668,7 @@ EOF
 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
   fi
   else
-kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
+kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
   fi
   if compile_prog "$kvm_cflags" "" ; then
 kvm=yes
-- 
1.7.2.3





[Qemu-devel] [PATCH 11/39] reorganize sdl-config tests

2010-10-12 Thread Paolo Bonzini
This also allows overriding it with SDL_CONFIG, and warning in suspicious
cross-compilation scenarios.

Signed-off-by: Paolo Bonzini 
---
 configure |   30 +-
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index e072dde..f61c5b8 100755
--- a/configure
+++ b/configure
@@ -217,6 +217,7 @@ ld="${cross_prefix}${LD-ld}"
 strip="${cross_prefix}${STRIP-strip}"
 windres="${cross_prefix}${WINDRES-windres}"
 pkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
+sdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
@@ -1187,21 +1188,17 @@ fi
 ##
 # SDL probe
 
-# Look for sdl configuration program (pkg-config or sdl-config).
-# Prefer variant with cross prefix if cross compiling,
-# and favour pkg-config with sdl over sdl-config.
-if test -n "$cross_prefix" -a $pkg_config != pkg-config && \
- $pkg_config sdl --modversion >/dev/null 2>&1; then
-  sdlconfig="$pkg_config sdl"
-  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
-elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
-  sdlconfig="${cross_prefix}sdl-config"
-  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
-elif $pkg_config sdl --modversion >/dev/null 2>&1; then
+# Look for sdl configuration program (pkg-config or sdl-config).  Try
+# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
+if test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
+  sdl_config=sdl-config
+fi
+
+if $pkg_config sdl --modversion >/dev/null 2>&1; then
   sdlconfig="$pkg_config sdl"
   _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
-elif has sdl-config; then
-  sdlconfig='sdl-config'
+elif has ${sdl_config}; then
+  sdlconfig="$sdl_config"
   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
 else
   if test "$sdl" = "yes" ; then
@@ -1209,6 +1206,13 @@ else
   fi
   sdl=no
 fi
+if test -n "$cross_prefix"; then
+  case "`basename $sdlconfig`" in
+  pkg-config*|sdl-config)
+echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
+echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&5 ;;
+  esac
+fi
 
 sdl_too_old=no
 if test "$sdl" != "no" ; then
-- 
1.7.2.3





[Qemu-devel] [PATCH 26/39] add libtooly alias --enable-static for --static

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 86b1835..d677b53 100755
--- a/configure
+++ b/configure
@@ -546,7 +546,7 @@ for opt do
   ;;
   --enable-gprof) gprof="yes"
   ;;
-  --static)
+  --enable-static|--static)
 static="yes"
 LDFLAGS="-static $LDFLAGS"
   ;;
@@ -838,7 +838,7 @@ echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
-echo "  --static enable static build [$static]"
+echo "  --enable-static  enable static build [$static]"
 echo "  --mandir=PATHinstall man pages in PATH"
 echo "  --datadir=PATH   install firmware in PATH"
 echo "  --docdir=PATHinstall documentation in PATH"
@@ -937,6 +937,7 @@ echo "  --audio-drv-list=LISTset audio drivers list"
 echo "  --block-drv-whitelist=L  set block driver list for QEMU (not qemu-img)"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
+echo "  --static enable static build [$static]"
 echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
 echo "  CC  C compiler command"
-- 
1.7.2.3





[Qemu-devel] [PATCH 21/39] add autoconfy aliases --with-* for audio library options

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   17 +++--
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 547f8e9..76626a4 100755
--- a/configure
+++ b/configure
@@ -564,11 +564,11 @@ for opt do
   ;;
   --enable-sdl) sdl="yes"
   ;;
-  --fmod-lib=*) fmod_lib="$optarg"
+  --with-fmod-lib=*|--fmod-lib=*) fmod_lib="$optarg"
   ;;
-  --fmod-inc=*) fmod_inc="$optarg"
+  --with-fmod-inc=*|--fmod-inc=*) fmod_inc="$optarg"
   ;;
-  --oss-lib=*) oss_lib="$optarg"
+  --with-oss-lib=*) oss_lib="$optarg"
   ;;
   --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
   ;;
@@ -830,6 +830,11 @@ echo "  --interp-prefix=PREFIX   where to find shared 
libraries, etc."
 echo "   use %M for cpu name [$interp_prefix]"
 echo "  --target-list=LIST   set target list [$target_list]"
 echo ""
+echo "Libraries:"
+echo "  --with-fmod-lib  path to FMOD library"
+echo "  --with-fmod-inc  path to FMOD includes"
+echo "  --with-oss-lib   path to OSS library"
+echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
@@ -899,9 +904,6 @@ echo "   emulation targets"
 echo "  --disable-guest-base disable GUEST_BASE support"
 echo "  --enable-user-piebuild usermode emulation targets as PIE"
 echo "  --disable-user-pie   do not build usermode emulation targets as 
PIE"
-echo "  --fmod-lib   path to FMOD library"
-echo "  --fmod-inc   path to FMOD includes"
-echo "  --oss-libpath to OSS library"
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
 echo "  --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, 
v8plus, v8plusa, v9"
 echo "  --disable-uuid   disable uuid support"
@@ -929,6 +931,9 @@ echo "Deprecated options:"
 echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
+echo "  --fmod-lib   path to FMOD library"
+echo "  --fmod-inc   path to FMOD includes"
+echo "  --oss-libpath to OSS library"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo ""
-- 
1.7.2.3





[Qemu-devel] [PATCH 10/39] do not default to non-prefixed pkg-config when cross compiling

2010-10-12 Thread Paolo Bonzini
This can still be requested with PKG_CONFIG=/path/to/pkg-config.
Just do not use it as a default, and print a warning.

Signed-off-by: Paolo Bonzini 
---
 configure |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ac11d4e..e072dde 100755
--- a/configure
+++ b/configure
@@ -1166,8 +1166,9 @@ fi
 # pkg-config probe
 
 if ! has $pkg_config; then
-  # likely not cross compiling, or hope for the best
-  pkg_config=pkg-config
+  echo warning: proceeding without "$pkg_config" >&2
+  echo warning: proceeding without "$pkg_config" >&5
+  pkg_config=/bin/false
 fi
 
 ##
-- 
1.7.2.3





[Qemu-devel] [PATCH 14/39] remove HOST_CC mention from roms/{sea, vga}bios/config.mak

2010-10-12 Thread Paolo Bonzini
Not used in the submodules.

Signed-off-by: Paolo Bonzini 
---
 configure |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index e059525..068b40a 100755
--- a/configure
+++ b/configure
@@ -3129,7 +3129,6 @@ for rom in seabios vgabios ; do
 echo "CPP=${cross_prefix}cpp" >> $config_mak
 echo "OBJCOPY=objcopy" >> $config_mak
 echo "IASL=iasl" >> $config_mak
-echo "HOST_CC=$host_cc" >> $config_mak
 echo "LD=$ld" >> $config_mak
 done
 
-- 
1.7.2.3





[Qemu-devel] [PATCH 29/39] add autoconfy alias --enable-targets for --target-list

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b439bc2..e1eeda2 100755
--- a/configure
+++ b/configure
@@ -538,7 +538,7 @@ for opt do
   ;;
   --cpu=*)
   ;;
-  --target-list=*) target_list="$optarg"
+  --enable-targets=*|--target-list=*) target_list="$optarg"
   ;;
   --enable-trace-backend=*) trace_backend="$optarg"
   ;;
@@ -826,7 +826,6 @@ EOF
 echo "Standard options:"
 echo "  --help   print this message"
 echo "  --prefix=PREFIX  install in PREFIX [$prefix]"
-echo "  --target-list=LIST   set target list [$target_list]"
 echo ""
 echo "Libraries:"
 echo "  --with-fmod-lib  path to FMOD library"
@@ -835,6 +834,7 @@ echo "  --with-oss-lib   path to OSS library"
 echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
+echo "  --enable-targets=LISTchoose compiled targets [$target_list]"
 echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
@@ -940,6 +940,7 @@ echo "  --block-drv-whitelist=L  set block driver list for 
QEMU (not qemu-img)"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo "  --static enable static build [$static]"
+echo "  --target-list=LIST   set target list [$target_list]"
 echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
 echo "  CC  C compiler command"
-- 
1.7.2.3





[Qemu-devel] [PATCH 22/39] make trace options use autoconfy names

2010-10-12 Thread Paolo Bonzini
These are not in any release, so I am just renaming them.

Signed-off-by: Paolo Bonzini 
---
 configure |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 76626a4..5786729 100755
--- a/configure
+++ b/configure
@@ -540,9 +540,9 @@ for opt do
   ;;
   --target-list=*) target_list="$optarg"
   ;;
-  --trace-backend=*) trace_backend="$optarg"
+  --enable-trace-backend=*) trace_backend="$optarg"
   ;;
-  --trace-file=*) trace_file="$optarg"
+  --enable-trace-file=*) trace_file="$optarg"
   ;;
   --enable-gprof) gprof="yes"
   ;;
@@ -921,8 +921,8 @@ echo "  --enable-docsenable documentation build"
 echo "  --disable-docs   disable documentation build"
 echo "  --disable-vhost-net  disable vhost-net acceleration support"
 echo "  --enable-vhost-net   enable vhost-net acceleration support"
-echo "  --trace-backend=BTrace backend nop simple ust"
-echo "  --trace-file=NAMEFull PATH,NAME of file to store traces"
+echo "  --enable-trace-backend=B Trace backend nop simple ust"
+echo "  --enable-trace-file=NAME Full PATH,NAME of file to store traces"
 echo "   Default:trace-"
 echo "  --disable-spice  disable spice"
 echo "  --enable-spice   enable spice"
-- 
1.7.2.3





[Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread Paolo Bonzini
Do not hardcode the list of 64-bit CPUs.

Signed-off-by: Paolo Bonzini 
---
 configure |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index cb76177..873e4a6 100755
--- a/configure
+++ b/configure
@@ -1088,12 +1088,14 @@ esac
 fi
 
 # host long bits test
-hostlongbits="32"
-case "$cpu" in
-  x86_64|alpha|ia64|sparc64|ppc64|s390x)
-hostlongbits=64
-  ;;
-esac
+cat > $TMPC << EOF
+int sizeof_long_is_8[sizeof(long) == 8 ? 1 : -1];
+EOF
+if compile_object; then
+hostlongbits=64
+else
+hostlongbits=32
+fi
 
 
 ##
-- 
1.7.2.3





[Qemu-devel] [PATCH 16/39] introduce CFLAGS= and LDFLAGS= configure command-line options

2010-10-12 Thread Paolo Bonzini
Also, run checks with -O2.  Some headers may provide different code
based on __OPTIMIZE__, so it's good to be consistent.

Signed-off-by: Paolo Bonzini 
---
 configure |   31 +--
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index b387994..2a2f64e 100755
--- a/configure
+++ b/configure
@@ -187,6 +187,10 @@ for opt do
   ;;
   --cpu=*) cpu="$optarg"
   ;;
+  CFLAGS=*) CFLAGS="$CFLAGS"
+  ;;
+  LDFLAGS=*) LDFLAGS="$LDFLAGS"
+  ;;
   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
   ;;
   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
@@ -223,13 +227,17 @@ sdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
-CFLAGS="-g $CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes 
$QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
$QEMU_CFLAGS"
 QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
 QEMU_CPPFLAGS="-I. -I\$(SRC_PATH)"
-LDFLAGS="-g $LDFLAGS"
+
+if test "$debug" = "no" ; then
+  : ${CFLAGS='-O2 -g'}
+else
+  : ${CFLAGS='-g'}
+fi
 
 # find source path
 source_path=`dirname "$0"`
@@ -515,9 +523,9 @@ for opt do
   ;;
   --install=*) install="$optarg"
   ;;
-  --extra-cflags=*)
+  CFLAGS=*|--extra-cflags=*)
   ;;
-  --extra-ldflags=*)
+  LDFLAGS=*|--extra-ldflags=*)
   ;;
   --cpu=*)
   ;;
@@ -817,8 +825,6 @@ echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC  use C compiler CC [$cc]"
-echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
-echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo "  --static enable static build [$static]"
@@ -913,6 +919,15 @@ echo "   Default:trace-"
 echo "  --disable-spice  disable spice"
 echo "  --enable-spice   enable spice"
 echo ""
+echo "Deprecated options:"
+echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
+echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
+echo ""
+echo "Some influential environment variables can be passed on the command 
line:"
+echo "  CFLAGS  C compiler flags"
+echo "  LDFLAGS linker flags, e.g. -L if you have libraries in a"
+echo "  nonstandard directory "
+echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
 fi
@@ -2193,10 +2208,6 @@ fi
 # End of CC checks
 # After here, no more $cc or $ld runs
 
-if test "$debug" = "no" ; then
-  CFLAGS="-O2 $CFLAGS"
-fi
-
 # Consult white-list to determine whether to enable werror
 # by default.  Only enable by default for git builds
 z_version=`cut -f3 -d. $source_path/VERSION`
-- 
1.7.2.3





[Qemu-devel] [PATCH 34/39] add autoconfy --host= option deprecating --cross-prefix

2010-10-12 Thread Paolo Bonzini
Unlike --cross-prefix, if you specify a tool by environment
variables --host will not affect it.  This allows

  SDL_CONFIG=/usr/.../bin/sdl-config ./configure --host=i686-pc-mingw32

to work.

Signed-off-by: Paolo Bonzini 
---
 configure |   41 -
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index 8ed9736..02e69fc 100755
--- a/configure
+++ b/configure
@@ -84,6 +84,9 @@ sysroot="/usr/gnemul/qemu-%M"
 static="no"
 sparc_cpu=""
 cross_prefix=""
+cross_compiling="no"
+default_cross_prefix=""
+host=""
 audio_drv_list=""
 audio_card_list="ac97 es1370 sb16"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
@@ -178,7 +181,17 @@ spice=""
 for opt do
   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
   case "$opt" in
-  --cross-prefix=*) cross_prefix="$optarg"
+  --host=*)
+host="$optarg"
+default_cross_prefix="$host-"
+cross_compiling=yes
+  ;;
+  --cross-prefix=*)
+cross_prefix="$optarg"
+if test -n "$cross_prefix"; then
+  host=`echo "$cross_prefix" | sed 's/-$//' `
+  cross_compiling=yes
+fi
   ;;
   CC=*|--cc=*) CC="$optarg"
   ;;
@@ -220,15 +233,15 @@ done
 # Using uname is really, really broken.  Once we have the right set of checks
 # we can eliminate it's usage altogether
 
-cc="${cross_prefix}${CC-gcc}"
-cpp="${cross_prefix}${CPP-cpp}"
-ar="${cross_prefix}${AR-ar}"
-objcopy="${cross_prefix}${OBJCOPY-objcopy}"
-ld="${cross_prefix}${LD-ld}"
-strip="${cross_prefix}${STRIP-strip}"
-windres="${cross_prefix}${WINDRES-windres}"
-pkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
-sdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
+cc="${cross_prefix}${CC-${default_cross_prefix}gcc}"
+cpp="${cross_prefix}${CPP-${default_cross_prefix}cpp}"
+ar="${cross_prefix}${AR-${default_cross_prefix}ar}"
+objcopy="${cross_prefix}${OBJCOPY-${default_cross_prefix}objcopy}"
+ld="${cross_prefix}${LD-${default_cross_prefix}ld}"
+strip="${cross_prefix}${STRIP-${default_cross_prefix}strip}"
+windres="${cross_prefix}${WINDRES-${default_cross_prefix}windres}"
+pkg_config="${cross_prefix}${PKG_CONFIG-${default_cross_prefix}pkg-config}"
+sdl_config="${cross_prefix}${SDL_CONFIG-${default_cross_prefix}sdl-config}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
@@ -838,7 +851,7 @@ echo "  --srcdir=PATHpath of source code 
[$srcdir]"
 echo "  --enable-targets=LISTchoose compiled targets [$target_list]"
 echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
-echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
+echo "  --host=HOST  cross-compile for host triplet HOST [$host]"
 echo "  --enable-static  enable static build [$static]"
 echo "  --mandir=PATHinstall man pages in PATH"
 echo "  --datadir=PATH   install firmware in PATH"
@@ -928,6 +941,7 @@ echo "Deprecated options:"
 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
 echo "  --source-path=PATH   path of source code [$srcdir]"
+echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
@@ -1101,7 +1115,7 @@ feature_not_found() {
   exit 1;
 }
 
-if test -z "$cross_prefix" ; then
+if test "$cross_compiling" = no; then
 
 # ---
 # big/little endian test
@@ -1247,7 +1261,7 @@ else
   fi
   sdl=no
 fi
-if test -n "$cross_prefix"; then
+if test "$cross_compiling" = yes; then
   case "`basename $sdlconfig`" in
   pkg-config*|sdl-config)
 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
@@ -2309,6 +2323,7 @@ echo "Manual directory  `eval echo $mandir`"
 echo "Target sysroot`eval echo $sysroot`"
 fi
 echo "Source path   $srcdir"
+echo "Host machine  $host"
 echo "C compiler$cc"
 echo "C preprocessor$cpp"
 echo "CFLAGS$CFLAGS"
-- 
1.7.2.3





[Qemu-devel] [PATCH 15/39] let --host-cc slide into oblivion

2010-10-12 Thread Paolo Bonzini
It is not really needed anymore since dyngen's death, and the previous
patches removed the last occurrences.

Signed-off-by: Paolo Bonzini 
---
 configure |8 +---
 create_config |3 ---
 2 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 068b40a..b387994 100755
--- a/configure
+++ b/configure
@@ -88,7 +88,6 @@ audio_drv_list=""
 audio_card_list="ac97 es1370 sb16"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
 block_drv_whitelist=""
-host_cc="gcc"
 helper_cflags=""
 libs_softmmu=""
 libs_tools=""
@@ -510,7 +509,7 @@ for opt do
   ;;
   --cc=*)
   ;;
-  --host-cc=*) host_cc="$optarg"
+  --host-cc=*)
   ;;
   --make=*) make="$optarg"
   ;;
@@ -818,8 +817,6 @@ echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC  use C compiler CC [$cc]"
-echo "  --host-cc=CC use C compiler CC [$host_cc] for code run at"
-echo "   build time"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo "  --make=MAKE  use specified make [$make]"
@@ -2275,7 +2272,6 @@ echo "ELF interp prefix $interp_prefix"
 fi
 echo "Source path   $source_path"
 echo "C compiler$cc"
-echo "Host C compiler   $host_cc"
 echo "CFLAGS$CFLAGS"
 echo "QEMU_CFLAGS   $QEMU_CFLAGS"
 echo "LDFLAGS   $LDFLAGS"
@@ -2638,7 +2634,6 @@ echo "INSTALL_DIR=$install -d -m0755 -p" >> 
$config_host_mak
 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
-echo "HOST_CC=$host_cc" >> $config_host_mak
 echo "AR=$ar" >> $config_host_mak
 echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
@@ -2648,7 +2643,6 @@ echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_CPPFLAGS=$QEMU_CPPFLAGS" >> $config_host_mak
 if test "$sparse" = "yes" ; then
   echo "CC   := REAL_CC=\"\$(CC)\" cgcc"   >> $config_host_mak
-  echo "HOST_CC  := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
   echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer 
-Wno-non-pointer-null" >> $config_host_mak
 fi
 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
diff --git a/create_config b/create_config
index 0098e68..f880a7c 100755
--- a/create_config
+++ b/create_config
@@ -54,9 +54,6 @@ case $line in
  HOST_USB=*)
 # do nothing
 ;;
- HOST_CC=*)
-# do nothing
-;;
  HOST_*=y) # configuration
 name=${line%=*}
 echo "#define $name 1"
-- 
1.7.2.3





[Qemu-devel] [PATCH 19/39] add CPP variable

2010-10-12 Thread Paolo Bonzini
There is already a CPP makefile variable, treat it consistently
with every other tool.

Signed-off-by: Paolo Bonzini 
---
 configure |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 1ea56f7..8273f84 100755
--- a/configure
+++ b/configure
@@ -185,6 +185,8 @@ for opt do
   --source-path=*) source_path="$optarg"
   source_path_used="yes"
   ;;
+  CPP=*) CPP="$optarg"
+  ;;
   --cpu=*) cpu="$optarg"
   ;;
   CFLAGS=*) CFLAGS="$CFLAGS"
@@ -219,6 +221,7 @@ done
 # we can eliminate it's usage altogether
 
 cc="${cross_prefix}${CC-gcc}"
+cpp="${cross_prefix}${CPP-cpp}"
 ar="${cross_prefix}${AR-ar}"
 objcopy="${cross_prefix}${OBJCOPY-objcopy}"
 ld="${cross_prefix}${LD-ld}"
@@ -519,6 +522,8 @@ for opt do
   ;;
   CC=*|--cc=*)
   ;;
+  CPP=*)
+  ;;
   --host-cc=*)
   ;;
   --make=*) make="$optarg"
@@ -930,6 +935,7 @@ echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
 echo "  CC  C compiler command"
 echo "  CFLAGS  C compiler flags"
+echo "  CPP C preprocessor command"
 echo "  CPPFLAGSC preprocessor flags, e.g. -I if you have"
 echo "  headers in a nonstandard directory "
 echo "  LDFLAGS linker flags, e.g. -L if you have libraries in a"
@@ -2290,6 +2296,7 @@ echo "ELF interp prefix $interp_prefix"
 fi
 echo "Source path   $source_path"
 echo "C compiler$cc"
+echo "C preprocessor$cpp"
 echo "CFLAGS$CFLAGS"
 echo "CPPFLAGS  $CPPFLAGS"
 echo "QEMU_CFLAGS   $QEMU_CFLAGS"
@@ -2653,6 +2660,7 @@ echo "INSTALL_DIR=$install -d -m0755 -p" >> 
$config_host_mak
 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
+echo "CPP=$cpp" >> $config_host_mak
 echo "AR=$ar" >> $config_host_mak
 echo "OBJCOPY=$objcopy" >> $config_host_mak
 echo "LD=$ld" >> $config_host_mak
@@ -3140,7 +3148,7 @@ for rom in seabios vgabios ; do
 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
 echo "CC=$cc" >> $config_mak
 echo "BCC=bcc" >> $config_mak
-echo "CPP=${cross_prefix}cpp" >> $config_mak
+echo "CPP=$cpp" >> $config_mak
 echo "OBJCOPY=objcopy" >> $config_mak
 echo "IASL=iasl" >> $config_mak
 echo "LD=$ld" >> $config_mak
-- 
1.7.2.3





[Qemu-devel] [PATCH 32/39] rename SRC_PATH to srcdir

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 Makefile   |   52 ++--
 Makefile.dis   |6 ++--
 Makefile.hw|8 +++---
 Makefile.objs  |4 +-
 Makefile.target|   32 +-
 Makefile.user  |6 ++--
 configure  |   22 +-
 pc-bios/optionrom/Makefile |8 +++---
 rules.mak  |2 +-
 tests/Makefile |2 +-
 tests/cris/Makefile|6 ++--
 11 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/Makefile b/Makefile
index 34c2a6c..2d55512 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,8 @@ ifneq ($(wildcard config-host.mak),)
 # Put the all: rule here so that config-host.mak can contain dependencies.
 all: build-all
 include config-host.mak
-include $(SRC_PATH)/rules.mak
-config-host.mak: $(SRC_PATH)/configure
+include $(srcdir)/rules.mak
+config-host.mak: $(srcdir)/configure
@echo $@ is out-of-date, running configure
@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
 else
@@ -24,7 +24,7 @@ configure: ;
 .PHONY: all clean cscope distclean dvi html info install install-doc \
pdf recurse-all speed tar tarbin test build-all
 
-$(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
+$(call set-vpath, $(srcdir):$(srcdir)/hw)
 
 LIBS+=-lz $(LIBS_TOOLS)
 
@@ -78,7 +78,7 @@ subdir-%: $(GENERATED_HEADERS)
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" 
TARGET_DIR="$*/" all,)
 
 ifneq ($(wildcard config-host.mak),)
-include $(SRC_PATH)/Makefile.objs
+include $(srcdir)/Makefile.objs
 endif
 
 $(common-obj-y): $(GENERATED_HEADERS)
@@ -107,20 +107,20 @@ ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
 trace.h: trace.h-timestamp
-trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h < 
$< > $@,"  GEN   trace.h")
+trace.h-timestamp: $(srcdir)/trace-events config-host.mak
+   $(call quiet-command,sh $(srcdir)/tracetool --$(TRACE_BACKEND) -h < $< 
> $@,"  GEN   trace.h")
@cmp -s $@ trace.h || cp $@ trace.h
 
 trace.c: trace.c-timestamp
-trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak
-   $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -c < 
$< > $@,"  GEN   trace.c")
+trace.c-timestamp: $(srcdir)/trace-events config-host.mak
+   $(call quiet-command,sh $(srcdir)/tracetool --$(TRACE_BACKEND) -c < $< 
> $@,"  GEN   trace.c")
@cmp -s $@ trace.c || cp $@ trace.c
 
 trace.o: trace.c $(GENERATED_HEADERS)
 
 simpletrace.o: simpletrace.c $(GENERATED_HEADERS)
 
-version.o: $(SRC_PATH)/version.rc config-host.mak
+version.o: $(srcdir)/version.rc config-host.mak
$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC$(TARGET_DIR)$@")
 
 version-obj-$(CONFIG_WIN32) += version.o
@@ -135,8 +135,8 @@ qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o 
$(trace-obj-y) $(block-ob
 
 qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(trace-obj-y) 
$(block-obj-y) $(qobject-obj-y) $(version-obj-y)
 
-qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
-   $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
+qemu-img-cmds.h: $(srcdir)/qemu-img-cmds.hx
+   $(call quiet-command,sh $(srcdir)/hxtool -h < $< > $@,"  GEN   $@")
 
 check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o 
check-qjson.o: $(GENERATED_HEADERS)
 
@@ -201,7 +201,7 @@ endif
 
 install-sysconfig:
$(INSTALL_DIR) "$(DESTDIR)$(sysconfdir)/qemu"
-   $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf 
"$(DESTDIR)$(sysconfdir)/qemu"
+   $(INSTALL_DATA) $(srcdir)/sysconfigs/target/target-x86_64.conf 
"$(DESTDIR)$(sysconfdir)/qemu"
 
 install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig
$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
@@ -211,12 +211,12 @@ endif
 ifneq ($(BLOBS),)
$(INSTALL_DIR) "$(DESTDIR)$(datadir)"
set -e; for x in $(BLOBS); do \
-   $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; 
\
+   $(INSTALL_DATA) $(srcdir)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
done
 endif
$(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
set -e; for x in $(KEYMAPS); do \
-   $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x 
"$(DESTDIR)$(datadir)/keymaps"; \
+   $(INSTALL_DATA) $(srcdir)/pc-bios/keymaps/$$x 
"$(DESTDIR)$(datadir)/keymaps"; \
done
for d in $(TARGET_DIRS); do \
$(MAKE) -C $$d $@ || exit 1 ; \
@@ -228,7 +228,7 @@ test speed: all
 
 .PHONY: TAGS
 TAGS:
-   find "$(SRC_PATH)" -name '*.[hc]' -print0 | xargs -0 etags
+   find "$(srcdir)" -name '*.[hc]' -print0 | xargs -0 etags
 
 cscope:
rm -f ./cscope.*
@@ -252,33 +252,33 @@ TEXIFLAG=$(if $(V),,--quiet)
 %.pdf: %.texi
$(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<," 

[Qemu-devel] [PATCH 23/39] deprecate --audio-card-list

2010-10-12 Thread Paolo Bonzini
We have config files now which provide fine-grained control.

Signed-off-by: Paolo Bonzini 
---
 configure |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 5786729..efebaa9 100755
--- a/configure
+++ b/configure
@@ -856,8 +856,6 @@ echo "  --enable-sdl enable SDL"
 echo "  --enable-cocoa   enable COCOA (Mac OS X only)"
 echo "  --audio-drv-list=LISTset audio drivers list:"
 echo "   Available drivers: $audio_possible_drivers"
-echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
-echo "   Available cards: $audio_possible_cards"
 echo "  --block-drv-whitelist=L  set block driver whitelist"
 echo "   (affects only QEMU, not qemu-img)"
 echo "  --enable-mixemu  enable mixer emulation"
@@ -934,6 +932,8 @@ echo "  --extra-ldflags=LDFLAGS  append extra linker flags 
LDFLAGS"
 echo "  --fmod-lib   path to FMOD library"
 echo "  --fmod-inc   path to FMOD includes"
 echo "  --oss-libpath to OSS library"
+echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
+echo "   Available cards: $audio_possible_cards"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo ""
-- 
1.7.2.3





[Qemu-devel] [PATCH 24/39] add autoconfy alias --enable-audio-drivers alias for --audio-drv-list

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index efebaa9..b144b21 100755
--- a/configure
+++ b/configure
@@ -572,7 +572,7 @@ for opt do
   ;;
   --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
   ;;
-  --audio-drv-list=*) audio_drv_list="$optarg"
+  --enable-audio-drivers=*|--audio-drv-list=*) audio_drv_list="$optarg"
   ;;
   --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ 
/g'`
   ;;
@@ -854,7 +854,7 @@ echo "  --disable-werror disable compilation abort 
on warning"
 echo "  --disable-sdldisable SDL"
 echo "  --enable-sdl enable SDL"
 echo "  --enable-cocoa   enable COCOA (Mac OS X only)"
-echo "  --audio-drv-list=LISTset audio drivers list:"
+echo "  --enable-audio-drivers=LISTset audio drivers list:"
 echo "   Available drivers: $audio_possible_drivers"
 echo "  --block-drv-whitelist=L  set block driver whitelist"
 echo "   (affects only QEMU, not qemu-img)"
@@ -934,6 +934,7 @@ echo "  --fmod-inc   path to FMOD includes"
 echo "  --oss-libpath to OSS library"
 echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
 echo "   Available cards: $audio_possible_cards"
+echo "  --audio-drv-list=LISTset audio drivers list"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo ""
-- 
1.7.2.3





[Qemu-devel] [PATCH 37/39] make more options "standard"

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 99de45b..27fc67a 100755
--- a/configure
+++ b/configure
@@ -806,6 +806,14 @@ EOF
 echo "Standard options:"
 echo "  --help   print this message"
 echo "  --prefix=PREFIX  install in PREFIX [$prefix]"
+echo "  --srcdir=PATHpath of source code [$srcdir]"
+echo "  --mandir=PATHinstall man pages in PATH"
+echo "  --datadir=PATH   install firmware in PATH"
+echo "  --docdir=PATHinstall documentation in PATH"
+echo "  --bindir=PATHinstall binaries in PATH"
+echo "  --sysconfdir=PATHinstall config in PATH/qemu"
+echo "  --build=BUILDspecify triplet for build machine [$build]"
+echo "  --host=HOST  cross-compile for host triplet HOST [$host]"
 echo ""
 echo "Libraries:"
 echo "  --with-fmod-lib  path to FMOD library"
@@ -814,19 +822,11 @@ echo "  --with-oss-lib   path to OSS library"
 echo "  --with-headers=PATH  look for kernel includes in PATH"
 echo ""
 echo "Advanced options (experts only):"
-echo "  --srcdir=PATHpath of source code [$srcdir]"
-echo "  --build=BUILDspecify triplet for build machine [$build]"
 echo "  --enable-targets=LISTchoose compiled targets [$target_list]"
 echo "  --with-arch=ARCH build qemu for given architecture"
 echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
-echo "  --host=HOST  cross-compile for host triplet HOST [$host]"
 echo "  --enable-static  enable static build [$static]"
-echo "  --mandir=PATHinstall man pages in PATH"
-echo "  --datadir=PATH   install firmware in PATH"
-echo "  --docdir=PATHinstall documentation in PATH"
-echo "  --bindir=PATHinstall binaries in PATH"
-echo "  --sysconfdir=PATHinstall config in PATH/qemu"
 echo "  --enable-debug-tcg   enable TCG debugging"
 echo "  --disable-debug-tcg  disable TCG debugging (default)"
 echo "  --enable-debug   enable common debug build options"
-- 
1.7.2.3





[Qemu-devel] Re: qdev: Some ISA devices don't handle second instantiation gracefully (was: isa-applesmc doesn't handle second instantiation gracefully)

2010-10-12 Thread Alexander Graf

On 12.10.2010, at 15:00, Markus Armbruster wrote:

> Markus Armbruster  writes:
> 
>> When I try -device isa-applesmc -device isa-applesmc, I get
>> 
>>WARNING: Using AppleSMC with invalid key
>>qemu: hardware error: register_ioport_read: invalid opaque
>>[...]
>> 
>> and a core dump.
>> 
>> I know nothing about this device.  Instantiating twice may well make no
>> sense.  But hw_error() is not a nice way to reject a command line
>> option.
> 
> Actually, ib700 and isa-debugcon fail the same way.
> 
> They call register_ioport_write(), which aborts via hw_error() when the
> port is already in use.  This is okay for non-configurable parts of a
> board emulation, but not okay for a qdev device, unless it has no_user
> set.
> 
> Related: when isa_init_irq() finds the requested IRQ already in use, it
> fails with exit(1).  Maybe register_ioport_write() & friends should do
> that as well.
> 
> Or maybe qdev device models should have an "at most one" flag.

There can be multiple of these devices on different ports, but a single PIO 
port can still only be managed by a single device. By creating the same device 
twice without giving it a PIO option, you put two devices on the same PIO port 
which can't work.

As this is a configuration error, I'd guess the best way to deal with it is to 
return an error for register_ioport which makes the qdev init fail. Then the 
respective instantiator can do what is fit. If the device is passed in on the 
cmdline, it'd refuse to create the machine and exit. If it's a hotplug event, 
it would fail to hotplug.


Alex




[Qemu-devel] [PATCH 31/39] add autoconfy alias --srcdir= for --source-path

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 39a7119..44b5be9 100755
--- a/configure
+++ b/configure
@@ -182,7 +182,7 @@ for opt do
   ;;
   CC=*|--cc=*) CC="$optarg"
   ;;
-  --source-path=*) source_path="$optarg"
+  --srcdir=*|--source-path=*) source_path="$optarg"
   source_path_used="yes"
   ;;
   CPP=*) CPP="$optarg"
@@ -516,7 +516,7 @@ for opt do
   ;;
   --with-sysroot=*|--interp-prefix=*) sysroot="$optarg"
   ;;
-  --source-path=*)
+  --srcdir=*|--source-path=*)
   ;;
   --cross-prefix=*)
   ;;
@@ -834,7 +834,7 @@ echo "  --with-oss-lib   path to OSS library"
 echo "  --with-headers=PATH  look for kernel includes in PATH"
 echo ""
 echo "Advanced options (experts only):"
-echo "  --source-path=PATH   path of source code [$source_path]"
+echo "  --srcdir=PATHpath of source code [$source_path]"
 echo "  --enable-targets=LISTchoose compiled targets [$target_list]"
 echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
@@ -927,6 +927,7 @@ echo ""
 echo "Deprecated options:"
 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
+echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
-- 
1.7.2.3





[Qemu-devel] [PATCH 27/39] add autoconfy alias --with-sysroot for --interp-prefix

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index d677b53..581b91e 100755
--- a/configure
+++ b/configure
@@ -514,7 +514,7 @@ for opt do
   ;;
   --prefix=*) prefix="$optarg"
   ;;
-  --interp-prefix=*) interp_prefix="$optarg"
+  --with-sysroot=*|--interp-prefix=*) interp_prefix="$optarg"
   ;;
   --source-path=*)
   ;;
@@ -826,8 +826,6 @@ EOF
 echo "Standard options:"
 echo "  --help   print this message"
 echo "  --prefix=PREFIX  install in PREFIX [$prefix]"
-echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
-echo "   use %M for cpu name [$interp_prefix]"
 echo "  --target-list=LIST   set target list [$target_list]"
 echo ""
 echo "Libraries:"
@@ -837,6 +835,8 @@ echo "  --with-oss-lib   path to OSS library"
 echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
+echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
+echo "   use %M for cpu name [$interp_prefix]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
 echo "  --enable-static  enable static build [$static]"
 echo "  --mandir=PATHinstall man pages in PATH"
@@ -925,6 +925,8 @@ echo "  --disable-spice  disable spice"
 echo "  --enable-spice   enable spice"
 echo ""
 echo "Deprecated options:"
+echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
+echo "   use %M for cpu name [$interp_prefix]"
 echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
-- 
1.7.2.3





[Qemu-devel] [PATCH 25/39] add autoconfy alias --enable-block-drivers for --block-drv-whitelist

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index b144b21..86b1835 100755
--- a/configure
+++ b/configure
@@ -574,7 +574,7 @@ for opt do
   ;;
   --enable-audio-drivers=*|--audio-drv-list=*) audio_drv_list="$optarg"
   ;;
-  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ 
/g'`
+  --enable-block-drivers=*|block-drv-whitelist=*) block_drv_whitelist=`echo 
"$optarg" | sed -e 's/,/ /g'`
   ;;
   --enable-debug-tcg) debug_tcg="yes"
   ;;
@@ -856,8 +856,7 @@ echo "  --enable-sdl enable SDL"
 echo "  --enable-cocoa   enable COCOA (Mac OS X only)"
 echo "  --enable-audio-drivers=LISTset audio drivers list:"
 echo "   Available drivers: $audio_possible_drivers"
-echo "  --block-drv-whitelist=L  set block driver whitelist"
-echo "   (affects only QEMU, not qemu-img)"
+echo "  --enable-block-drivers=LISTset block driver list for QEMU (not 
qemu-img)"
 echo "  --enable-mixemu  enable mixer emulation"
 echo "  --disable-xendisable xen backend driver support"
 echo "  --enable-xen enable xen backend driver support"
@@ -935,6 +934,7 @@ echo "  --oss-libpath to OSS library"
 echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
 echo "   Available cards: $audio_possible_cards"
 echo "  --audio-drv-list=LISTset audio drivers list"
+echo "  --block-drv-whitelist=L  set block driver list for QEMU (not qemu-img)"
 echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo ""
-- 
1.7.2.3





[Qemu-devel] [PATCH 28/39] rename interp_prefix to sysroot

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 bsd-user/main.c|   10 +-
 configure  |   14 +++---
 darwin-user/machload.c |   12 ++--
 darwin-user/main.c |6 +++---
 darwin-user/syscall.c  |2 +-
 linux-user/main.c  |   10 +-
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 6b12f8b..f5d22c9 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -43,7 +43,7 @@ unsigned long guest_base;
 int have_guest_base;
 #endif
 
-static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
+static const char *sysroot = CONFIG_QEMU_SYSROOT;
 const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
 extern char **environ;
 enum BSDType bsd_type;
@@ -706,7 +706,7 @@ static void usage(void)
"last change will stay in effect.\n"
,
TARGET_ARCH,
-   interp_prefix,
+   sysroot,
x86_stack_size,
DEBUG_LOGFILE);
 exit(1);
@@ -815,7 +815,7 @@ int main(int argc, char **argv)
 else if (*r == 'k' || *r == 'K')
 x86_stack_size *= 1024;
 } else if (!strcmp(r, "L")) {
-interp_prefix = argv[optind++];
+sysroot = argv[optind++];
 } else if (!strcmp(r, "p")) {
 qemu_host_page_size = atoi(argv[optind++]);
 if (qemu_host_page_size == 0 ||
@@ -873,8 +873,8 @@ int main(int argc, char **argv)
 /* Zero out image_info */
 memset(info, 0, sizeof(struct image_info));
 
-/* Scan interp_prefix dir for replacement files. */
-init_paths(interp_prefix);
+/* Scan sysroot dir for replacement files. */
+init_paths(sysroot);
 
 if (cpu_model == NULL) {
 #if defined(TARGET_I386)
diff --git a/configure b/configure
index 581b91e..b439bc2 100755
--- a/configure
+++ b/configure
@@ -80,7 +80,7 @@ path_of() {
 
 # default parameters
 cpu=""
-interp_prefix="/usr/gnemul/qemu-%M"
+sysroot="/usr/gnemul/qemu-%M"
 static="no"
 sparc_cpu=""
 cross_prefix=""
@@ -514,7 +514,7 @@ for opt do
   ;;
   --prefix=*) prefix="$optarg"
   ;;
-  --with-sysroot=*|--interp-prefix=*) interp_prefix="$optarg"
+  --with-sysroot=*|--interp-prefix=*) sysroot="$optarg"
   ;;
   --source-path=*)
   ;;
@@ -836,7 +836,7 @@ echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
 echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
-echo "   use %M for cpu name [$interp_prefix]"
+echo "   use %M for cpu name [$sysroot]"
 echo "  --cross-prefix=PREFIXuse PREFIX for compile tools [$cross_prefix]"
 echo "  --enable-static  enable static build [$static]"
 echo "  --mandir=PATHinstall man pages in PATH"
@@ -926,7 +926,7 @@ echo "  --enable-spice   enable spice"
 echo ""
 echo "Deprecated options:"
 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
-echo "   use %M for cpu name [$interp_prefix]"
+echo "   use %M for cpu name [$sysroot]"
 echo "  --cc=CC  use C compiler CC [$cc]"
 echo "  --extra-cflags=CFLAGSappend extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
@@ -2303,7 +2303,7 @@ echo "binary directory  `eval echo $bindir`"
 echo "config directory  `eval echo $sysconfdir`"
 if test "$mingw32" = "no" ; then
 echo "Manual directory  `eval echo $mandir`"
-echo "ELF interp prefix $interp_prefix"
+echo "Target sysroot`eval echo $sysroot`"
 fi
 echo "Source path   $source_path"
 echo "C compiler$cc"
@@ -2783,8 +2783,8 @@ echo "# Automatically generated by configure - do not 
modify" > $config_target_m
 
 bflt="no"
 target_nptl="no"
-interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
-echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
+sysroot1=`echo "$sysroot" | sed "s/%M/$target_arch2/g"`
+echo "CONFIG_QEMU_SYSROOT=\"$sysroot1\"" >> $config_target_mak
 gdb_xml_files=""
 
 TARGET_ARCH="$target_arch2"
diff --git a/darwin-user/machload.c b/darwin-user/machload.c
index 4bb5c72..e4796db 100644
--- a/darwin-user/machload.c
+++ b/darwin-user/machload.c
@@ -45,7 +45,7 @@
 
 # define check_mach_header(x) (x.magic == MH_CIGAM)
 
-extern const char *interp_prefix;
+extern const char *sysroot;
 
 /* we don't have a good implementation for this */
 #define DONT_USE_DYLD_SHARED_MAP
@@ -364,7 +364,7 @@ int load_dylinker(struct mach_header *mh, struct 
dylinker_command *dc, int fd, i
 #ifdef OVERRIDE_DYLINKER
 dylinker_name = DYLINKER_NAME;
 #else
-if(asprintf(&dylinker_name, "%s%s", interp_prefix, dylinker_name) == -1)
+if(asprintf(&dylinker_name, "%s%s", sysroot, dylinker_name) == -1)
 qerror("can't allocate the new dylinker name\n");
 #endif
 
@@ -809,12 +809,12 @@ unsigned long setup_arg_pages(void * mh, char ** argv, 
char ** env)
   

[Qemu-devel] [PATCH 38/39] provide a more gnuish default sysroot

2010-10-12 Thread Paolo Bonzini
the default sys-root already hads "gnemul" in it, so I do not feel
ashamed to follow the GNU conventions completely.

Signed-off-by: Paolo Bonzini 
---
 configure |   20 ++--
 create_config |2 +-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 27fc67a..0340cfe 100755
--- a/configure
+++ b/configure
@@ -80,7 +80,6 @@ path_of() {
 
 # default parameters
 cpu=""
-sysroot="/usr/gnemul/qemu-%M"
 static="no"
 with_arch=""
 cross_prefix=""
@@ -465,6 +464,22 @@ if test "$mingw32" = "yes" ; then
   confsuffix=""
 fi
 
+# examples:
+#   linux  ${prefix}/%M-linux/sys-root
+#   linux-gnu  ${prefix}/%M-linux-gnu/sys-root
+#   i686-redhat-linux-gnu  ${prefix}/%M-pc-linux-gnu/sys-root
+#   powerpc-apple-darwin8.0${prefix}/%M-apple-darwin8.0/sys-root
+#   openbsd${prefix}/%M-openbsd/sys-root
+#   i686-openbsd   ${prefix}/%M-openbsd/sys-root
+sysroot=`echo $host_noncanonical | awk '{
+  gnu = $0 ~ /-gnu$/   # config.guess wants to please rms
+  if (gnu) sub (/-gnu$/, "")   # ... but it gets in our way
+  if (/-/) sub(/[^-]*-/, "")   # remove cpu part of the host
+  if (!/^apple-/) sub(/[^-]*-/, "pc-") # for Linux/BSD use generic vendor
+  if (gnu) $0 = $0 "-gnu"  # put the GNUness back
+  print "${prefix}/%M-" $0 "/sys-root" # make complete path
+}' `
+
 werror=""
 
 for opt do
@@ -2771,7 +2786,8 @@ echo "# Automatically generated by configure - do not 
modify" > $config_target_m
 bflt="no"
 target_nptl="no"
 sysroot1=`echo "$sysroot" | sed "s/%M/$target_arch2/g"`
-echo "CONFIG_QEMU_SYSROOT=\"$sysroot1\"" >> $config_target_mak
+echo "prefix=$prefix" >> $config_target_mak
+echo "sysroot=\"$sysroot1\"" >> $config_target_mak
 gdb_xml_files=""
 
 TARGET_ARCH="$target_arch2"
diff --git a/create_config b/create_config
index f880a7c..6c8b469 100755
--- a/create_config
+++ b/create_config
@@ -13,7 +13,7 @@ case $line in
 pkgversion=${line#*=}
 echo "#define QEMU_PKGVERSION \"$pkgversion\""
 ;;
- prefix=* | [a-z]*dir=*) # directory configuration
+ prefix=* | [a-z]*dir=* | sysroot=*) # directory configuration
 name=${line%=*}
 value=${line#*=}
 define_name=`echo $name | tr '[:lower:]' '[:upper:]'`
-- 
1.7.2.3





[Qemu-devel] [PATCH 30/39] add autoconfy alias --with-headers for --kerneldir

2010-10-12 Thread Paolo Bonzini
This name is already used by glibc.

Signed-off-by: Paolo Bonzini 
---
 configure |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index e1eeda2..39a7119 100755
--- a/configure
+++ b/configure
@@ -726,7 +726,7 @@ for opt do
   ;;
   --disable-blobs) blobs="no"
   ;;
-  --kerneldir=*) kerneldir="$optarg"
+  --with-headers=*|--kerneldir=*) kerneldir="$optarg"
   ;;
   --with-pkgversion=*) pkgversion=" ($optarg)"
   ;;
@@ -831,6 +831,7 @@ echo "Libraries:"
 echo "  --with-fmod-lib  path to FMOD library"
 echo "  --with-fmod-inc  path to FMOD includes"
 echo "  --with-oss-lib   path to OSS library"
+echo "  --with-headers=PATH  look for kernel includes in PATH"
 echo ""
 echo "Advanced options (experts only):"
 echo "  --source-path=PATH   path of source code [$source_path]"
@@ -913,7 +914,6 @@ echo "  --disable-attr   disables attr and xattr 
support"
 echo "  --enable-attrenable attr and xattr support"
 echo "  --enable-io-thread   enable IO thread"
 echo "  --disable-blobs  disable installing provided firmware blobs"
-echo "  --kerneldir=PATH look for kernel includes in PATH"
 echo "  --enable-docsenable documentation build"
 echo "  --disable-docs   disable documentation build"
 echo "  --disable-vhost-net  disable vhost-net acceleration support"
@@ -932,6 +932,7 @@ echo "  --extra-cflags=CFLAGSappend extra C compiler 
flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo "  --fmod-lib   path to FMOD library"
 echo "  --fmod-inc   path to FMOD includes"
+echo "  --kerneldir=PATH look for kernel includes in PATH"
 echo "  --oss-libpath to OSS library"
 echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
 echo "   Available cards: $audio_possible_cards"
-- 
1.7.2.3





[Qemu-devel] [PATCH 33/39] rename source_path to srcdir

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   48 
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/configure b/configure
index 432bd3b..8ed9736 100755
--- a/configure
+++ b/configure
@@ -182,8 +182,8 @@ for opt do
   ;;
   CC=*|--cc=*) CC="$optarg"
   ;;
-  --srcdir=*|--source-path=*) source_path="$optarg"
-  source_path_used="yes"
+  --srcdir=*|--source-path=*) srcdir="$optarg"
+  srcdir_used="yes"
   ;;
   CPP=*) CPP="$optarg"
   ;;
@@ -245,15 +245,15 @@ else
 fi
 
 # find source path
-source_path=`dirname "$0"`
-source_path_used="no"
+srcdir=`dirname "$0"`
+srcdir_used="no"
 workdir=`pwd`
-if [ -z "$source_path" ]; then
-source_path=$workdir
+if [ -z "$srcdir" ]; then
+srcdir=$workdir
 else
-source_path=`cd "$source_path"; pwd`
+srcdir=`cd "$srcdir"; pwd`
 fi
-[ -f "$workdir/vl.c" ] || source_path_used="yes"
+[ -f "$workdir/vl.c" ] || srcdir_used="yes"
 
 check_define() {
 cat > $TMPC < /dev/null 2> 
/dev/null
+sh "$srcdir/tracetool" "--$trace_backend" --check-backend > /dev/null 2> 
/dev/null
 if test "$?" -ne 0 ; then
   echo
   echo "Error: invalid trace backend"
@@ -2237,7 +2237,7 @@ fi
 
 # Consult white-list to determine whether to enable werror
 # by default.  Only enable by default for git builds
-z_version=`cut -f3 -d. $source_path/VERSION`
+z_version=`cut -f3 -d. $srcdir/VERSION`
 
 if test -z "$werror" ; then
 if test "$z_version" = "50" -a \
@@ -2308,7 +2308,7 @@ if test "$mingw32" = "no" ; then
 echo "Manual directory  `eval echo $mandir`"
 echo "Target sysroot`eval echo $sysroot`"
 fi
-echo "Source path   $source_path"
+echo "Source path   $srcdir"
 echo "C compiler$cc"
 echo "C preprocessor$cpp"
 echo "CFLAGS$CFLAGS"
@@ -2517,10 +2517,10 @@ fi
 if test "$uuid" = "yes" ; then
   echo "CONFIG_UUID=y" >> $config_host_mak
 fi
-qemu_version=`head $source_path/VERSION`
+qemu_version=`head $srcdir/VERSION`
 echo "VERSION=$qemu_version" >>$config_host_mak
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
-echo "srcdir=$source_path" >> $config_host_mak
+echo "srcdir=$srcdir" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
 if [ "$docs" = "yes" ] ; then
   echo "BUILD_DOCS=yes" >> $config_host_mak
@@ -2710,7 +2710,7 @@ fi
 for d in libdis libdis-user; do
 mkdir -p $d
 rm -f $d/Makefile
-ln -s $source_path/Makefile.dis $d/Makefile
+ln -s $srcdir/Makefile.dis $d/Makefile
 echo > $d/config.mak
 done
 if test "$static" = "no" -a "$user_pie" = "yes" ; then
@@ -2779,7 +2779,7 @@ fi
 # don't use ln -sf as not all "ln -sf" over write the file/link
 #
 rm -f $target_dir/Makefile
-ln -s $source_path/Makefile.target $target_dir/Makefile
+ln -s $srcdir/Makefile.target $target_dir/Makefile
 
 
 echo "# Automatically generated by configure - do not modify" > 
$config_target_mak
@@ -2959,7 +2959,7 @@ fi
 list=""
 if test ! -z "$gdb_xml_files" ; then
   for x in $gdb_xml_files; do
-list="$list $source_path/gdb-xml/$x"
+list="$list $srcdir/gdb-xml/$x"
   done
   echo "TARGET_XML_FILES=$list" >> $config_target_mak
 fi
@@ -3133,7 +3133,7 @@ echo "QEMU_CPPFLAGS+=$cppflags" >> $config_target_mak
 done # for target in $targets
 
 # build tree in object directory if source path is different from current one
-if test "$source_path_used" = "yes" ; then
+if test "$srcdir_used" = "yes" ; then
 DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
 DIRS="$DIRS roms/seabios roms/vgabios"
 DIRS="$DIRS fsdev ui"
@@ -3142,7 +3142,7 @@ if test "$source_path_used" = "yes" ; then
 FILES="$FILES tests/test-mmap.c"
 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
-for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb 
$source_path/pc-bios/openbios-*; do
+for bios_file in $srcdir/pc-bios/*.bin $srcdir/pc-bios/*.dtb 
$srcdir/pc-bios/openbios-*; do
 FILES="$FILES pc-bios/`basename $bios_file`"
 done
 for dir in $DIRS ; do
@@ -3151,7 +3151,7 @@ if test "$source_path_used" = "yes" ; then
 # remove the link and recreate it, as not all "ln -sf" overwrite the link
 for f in $FILES ; do
 rm -f $f
-ln -s $source_path/$f $f
+ln -s $srcdir/$f $f
 done
 fi
 
@@ -3159,7 +3159,7 @@ fi
 for rom in seabios vgabios ; do
 config_mak=roms/$rom/config.mak
 echo "# Automatically generated by configure - do not modify" > $config_mak
-echo "srcdir=$source_path/roms/$rom" >> $config_mak
+echo "srcdir=$srcdir/roms/$rom" >> $config_mak
 echo "CC=$cc" >> $config_mak
 echo "BCC=bcc" >> $config_mak
 echo "CPP=$cpp" >> $config_mak
@@ -3173,14 +3173,14 @@ for hwlib in 32 64; do
   mkdir -p $d
   mkdir -p $d/ide
   rm -f $d/Makefile
-  ln -s $source_path/Makefile.hw $d/Makefile
+  ln -s $srcdir/Makefile.hw $d/Makefile
   echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >

Re: [Qemu-devel] Re: [PATCH v2 3/7] docs: Add QED image format specification

2010-10-12 Thread Stefan Hajnoczi
On Tue, Oct 12, 2010 at 10:07:53AM +0200, Kevin Wolf wrote:
> Am 11.10.2010 19:14, schrieb Anthony Liguori:
> > On 10/11/2010 11:18 AM, Anthony Liguori wrote:
> >> On 10/11/2010 10:46 AM, Stefan Hajnoczi wrote:
> >>> On Mon, Oct 11, 2010 at 05:39:01PM +0200, Avi Kivity wrote:
>    On 10/11/2010 05:30 PM, Stefan Hajnoczi wrote:
> >>   It was discussed before, but I don't think we came to a 
> >> conclusion. Are
> >>   there any circumstances under which you don't want to set the
> >>   QED_CF_BACKING_FORMAT flag?
> > I suggest the following:
> >
> > QED_CF_BACKING_FORMAT_RAW = 0x1
> >
> > When set, the backing file is a raw image and should not be probed for
> > its file format.  The default (unset) means that the backing image 
> > file
> > format may be probed.
> >
> > Now the backing_fmt_{offset,size} are no longer necessary.
>  Should it not be an incompatible option?  If the backing disk starts
>  with a format magic, it will be probed by an older qemu,
>  incorrectly.
> >>> Agreed, it should be a non-compat feature bit.
> >>
> >> If it's just raw or not raw, then I agree it should be non-compat.
> >>
> >> I think we just need a feature bit then that indicates that the 
> >> backing file is non-probeable which certainly simplifies the 
> >> implementation.
> >>
> >> QED_F_BACKING_FORMAT_NOPROBE maybe?
> > 
> > Er, thinking more, this is still a good idea but we still need 
> > QED_CF_BACKING_FORMAT because we specifically need to know when a 
> > protocol is specified.  Otherwise, we have no way of doing nbd as a 
> > backing file.
> 
> Well, the protocol is currently encoded in the file name, separated by a
> colon. Of course, we want to get rid of that, but we still don't know
> what we want instead. It's completely unrelated to the backing file
> format, though, it's about the format of the backing file name.

I agree with Kevin.  There's no need to have the ill-defined backing
format AFAICT.

Stefan



Re: [Qemu-devel] qdev: Some ISA devices don't handle second instantiation gracefully

2010-10-12 Thread Anthony Liguori

On 10/12/2010 08:00 AM, Markus Armbruster wrote:

Markus Armbruster  writes:

   

When I try -device isa-applesmc -device isa-applesmc, I get

 WARNING: Using AppleSMC with invalid key
 qemu: hardware error: register_ioport_read: invalid opaque
 [...]

and a core dump.

I know nothing about this device.  Instantiating twice may well make no
sense.  But hw_error() is not a nice way to reject a command line
option.
 

Actually, ib700 and isa-debugcon fail the same way.

They call register_ioport_write(), which aborts via hw_error() when the
port is already in use.  This is okay for non-configurable parts of a
board emulation, but not okay for a qdev device, unless it has no_user
set.
   


It's definitely right to fail but I agree, it's better to propagate the 
error.



Related: when isa_init_irq() finds the requested IRQ already in use, it
fails with exit(1).  Maybe register_ioport_write()&  friends should do
that as well.

Or maybe qdev device models should have an "at most one" flag.
   


I think the proper thing to do is remove all exit(1)s and propagate 
errors instead.


A simple approach would be to make register_ioport_{read,write}() return 
an int, then do a query-replace on the source tree to make all 
invocations of it simply check the return value and exit if it's non-zero.


Regards,

Anthony Liguori





Re: [Qemu-devel] [PATCH 00/39] Make configure command line autoconf-compatible

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> On 10/12/2010 03:22 PM, malc wrote:
> > >   19 files changed, 3729 insertions(+), 456 deletions(-)
> > 
> > I don't think the explanation above justified net plus of 3273 lines of new
> > code.
> 
> The part you forgot to quote is:

Yes, failed to notice that, sorry.

> 
> >  Makefile   |   54 +-
> >  Makefile.dis   |6 +-
> >  Makefile.hw|8 +-
> >  Makefile.objs  |4 +-
> >  Makefile.target|   32 +-
> >  Makefile.user  |6 +-
> >  bsd-user/main.c|   10 +-
> >  config.guess   | 1502 ++
> >  config.sub | 1731
> > 
> >  configure  |  757 ++-
> >  create_config  |5 +-
> >  darwin-user/machload.c |   12 +-
> >  darwin-user/main.c |6 +-
> >  darwin-user/syscall.c  |2 +-
> >  linux-user/main.c  |   10 +-
> >  pc-bios/optionrom/Makefile |8 +-
> >  rules.mak  |   10 +-
> >  tests/Makefile |   16 +-
> >  tests/cris/Makefile|6 +-
> >  19 files changed, 3729 insertions(+), 456 deletions(-)
> 
> All these lines are in config.guess and config.sub that are shared with all
> projects using Autotools and do not really need to be considered.
> 
> It's 40 lines of new code, 33 of which are in configure's help message.
> 
> Paolo
> 

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



[Qemu-devel] [PATCH 36/39] add autoconfy --with-arch= option, compatible with --sparc-cpu

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
Please test this on SPARC. :)

 configure |   72 +
 1 files changed, 39 insertions(+), 33 deletions(-)

diff --git a/configure b/configure
index d6f472b..99de45b 100755
--- a/configure
+++ b/configure
@@ -82,7 +82,7 @@ path_of() {
 cpu=""
 sysroot="/usr/gnemul/qemu-%M"
 static="no"
-sparc_cpu=""
+with_arch=""
 cross_prefix=""
 cross_compiling="no"
 default_cross_prefix=""
@@ -215,20 +215,7 @@ for opt do
   ;;
   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
   ;;
-  --sparc_cpu=*)
-sparc_cpu="$optarg"
-case $sparc_cpu in
-v7|v8|v8plus|v8plusa)
-  cpu="sparc"
-;;
-v9)
-  cpu="sparc64"
-;;
-*)
-  echo "undefined SPARC architecture. Exiting";
-  exit 1
-;;
-esac
+  --with-arch=*|--sparc_cpu=*) with_arch="$optarg"
   ;;
   esac
 done
@@ -661,7 +648,7 @@ for opt do
   ;;
   --enable-uname-release=*) uname_release="$optarg"
   ;;
-  --sparc_cpu=*)
+  --with-arch=*|--sparc_cpu=*)
   ;;
   --enable-werror) werror="yes"
   ;;
@@ -721,21 +708,40 @@ for opt do
 done
 
 #
-# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
-# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
+# Plug in the right QEMU_CFLAGS/LDFLAGS for the architecture
 #
 host_guest_base="no"
+
 case "$cpu" in
-sparc) case $sparc_cpu in
-   v7|v8)
- QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ 
$QEMU_CFLAGS"
-   ;;
-   v8plus|v8plusa)
- QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ 
$QEMU_CFLAGS"
-   ;;
-   *) # sparc_cpu not defined in the command line
- QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
-   esac
+arm*|i386|x86_64|mips*|hppa*|s390|s390x)
+  test -n "$with_arch" && QEMU_CFLAGS="-march=${with_arch} $QEMU_CFLAGS"
+  ;;
+
+sparc|sparc64)
+  test "$with_arch" = v8plusa && with_arch=v8plus
+  case "$cpu:$with_arch" in
+  *:v7|*:v8|*:v8plus)
+QEMU_CFLAGS="-mcpu=${with_arch} -D__sparc_${with_arch}__ $QEMU_CFLAGS"
+cpu=sparc
+  ;;
+  *:v9)
+QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${with_arch}__ $QEMU_CFLAGS"
+cpu=sparc64
+  ;;
+  sparc:*) QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
+  ;;
+  sparc64:*) QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
+  ;;
+  esac
+  ;;
+
+*)
+  test -n "$with_arch" && QEMU_CFLAGS="-mcpu=${with_arch} $QEMU_CFLAGS"
+  ;;
+esac
+
+case "${cpu}" in
+sparc)
LDFLAGS="-m32 $LDFLAGS"
QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
if test "$solaris" = "no" ; then
@@ -744,9 +750,8 @@ case "$cpu" in
fi
;;
 sparc64)
-   QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
LDFLAGS="-m64 $LDFLAGS"
-   QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
+   QEMU_CFLAGS="-m64 -ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
if test "$solaris" != "no" ; then
  QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
fi
@@ -812,6 +817,7 @@ echo "Advanced options (experts only):"
 echo "  --srcdir=PATHpath of source code [$srcdir]"
 echo "  --build=BUILDspecify triplet for build machine [$build]"
 echo "  --enable-targets=LISTchoose compiled targets [$target_list]"
+echo "  --with-arch=ARCH build qemu for given architecture"
 echo "  --with-sysroot=PREFIXwhere to find shared libraries, etc."
 echo "   use %M for cpu name [$sysroot]"
 echo "  --host=HOST  cross-compile for host triplet HOST [$host]"
@@ -879,7 +885,6 @@ echo "  --disable-guest-base disable GUEST_BASE support"
 echo "  --enable-user-piebuild usermode emulation targets as PIE"
 echo "  --disable-user-pie   do not build usermode emulation targets as 
PIE"
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
-echo "  --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, 
v8plus, v8plusa, v9"
 echo "  --disable-uuid   disable uuid support"
 echo "  --enable-uuidenable uuid support"
 echo "  --disable-vdedisable support for vde network"
@@ -920,6 +925,7 @@ echo "  --make=MAKE  use specified make [$make]"
 echo "  --install=INSTALLuse specified install [$install]"
 echo "  --static enable static build [$static]"
 echo "  --target-list=LIST   set target list [$target_list]"
+echo "  --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, 
v8plus, v8plusa, v9"
 echo ""
 echo "Some influential environment variables can be passed on the command 
line:"
 echo "  CC  C compiler command"
@@ -2323,8 +2329,8 @@ echo "VNC SASL support  $vnc_sasl"
 echo "VNC JPEG suppo

[Qemu-devel] [PATCH] e1000: Handle IO Port.

2010-10-12 Thread anthony . perard
From: Anthony PERARD 

This patch introduces the two IOPorts on e1000, IOADDR and IODATA. The
IOADDR is used to specify which register we want to access when we read
or write on IODATA.

It also check the RDLEN register when a packet is received, if the value
is 0, the receive descriptor buffer is not set, so we don't accept any
network packets.

This patch fixes some weird behavior that I see when I use e1000 with
QEMU/Xen, the guest memory can be corrupted by this NIC because it will
write on memory that it doesn't own anymore after a reset. It's because
the kernel Linux use the IOPort to reset the network card instead of the
MMIO.

Signed-off-by: Anthony PERARD 
---
 hw/e1000.c |  106 ++-
 1 files changed, 97 insertions(+), 9 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index 532efdc..d02c8aa 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -57,6 +57,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
 #define PNPMMIO_SIZE  0x2
 #define MIN_BUF_SIZE  60 /* Min. octets in an ethernet frame sans FCS */
 
+#define REG_IOADDR 0x0
+#define REG_IODATA 0x4
+
 /*
  * HW models:
  *  E1000_DEV_ID_82540EM works with Windows and Linux
@@ -82,6 +85,8 @@ typedef struct E1000State_st {
 NICState *nic;
 NICConf conf;
 int mmio_index;
+int ioport_base;
+uint32_t ioport_reg[2];
 
 uint32_t mac_reg[0x8000];
 uint16_t phy_reg[0x20];
@@ -149,13 +154,7 @@ static const char phy_regcap[0x20] = {
 [PHY_ID2] = PHY_R, [M88E1000_PHY_SPEC_STATUS] = PHY_R
 };
 
-static void
-ioport_map(PCIDevice *pci_dev, int region_num, pcibus_t addr,
-   pcibus_t size, int type)
-{
-DBGOUT(IO, "e1000_ioport_map addr=0x%04"FMT_PCIBUS
-   " size=0x%08"FMT_PCIBUS"\n", addr, size);
-}
+static void e1000_reset(void *opaque);
 
 static void
 set_interrupt_cause(E1000State *s, int index, uint32_t val)
@@ -201,6 +200,11 @@ rxbufsize(uint32_t v)
 static void
 set_ctrl(E1000State *s, int index, uint32_t val)
 {
+DBGOUT(IO, "set ctrl = %08x\n", val);
+if (val & E1000_CTRL_RST) {
+s->mac_reg[CTRL] = val;
+e1000_reset(s);
+}
 /* RST is self clearing */
 s->mac_reg[CTRL] = val & ~E1000_CTRL_RST;
 }
@@ -623,7 +627,7 @@ e1000_can_receive(VLANClientState *nc)
 {
 E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
 
-return (s->mac_reg[RCTL] & E1000_RCTL_EN);
+return (s->mac_reg[RCTL] & E1000_RCTL_EN && s->mac_reg[RDLEN] != 0);
 }
 
 static ssize_t
@@ -666,6 +670,11 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, 
size_t size)
 size -= 4;
 }
 
+if (s->mac_reg[RDLEN] == 0) {
+DBGOUT(RX, "receive descriptor buffer not set\n");
+return -1;
+}
+
 rdh_start = s->mac_reg[RDH];
 do {
 if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {
@@ -847,6 +856,60 @@ static void (*macreg_writeops[])(E1000State *, int, 
uint32_t) = {
 enum { NWRITEOPS = ARRAY_SIZE(macreg_writeops) };
 
 static void
+e1000_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
+{
+E1000State *s = opaque;
+
+if (addr == s->ioport_base + REG_IOADDR) {
+DBGOUT(IO, "e1000_ioport_writel write base: 0x%04x\n", val);
+s->ioport_reg[REG_IOADDR] = val & 0xf;
+} else if (addr == (s->ioport_base + REG_IODATA)) {
+unsigned int index = (s->ioport_reg[REG_IOADDR] & 0x1) >> 2;
+
+#ifdef TARGET_WORDS_BIGENDIAN
+val = bswap32(val);
+#endif
+DBGOUT(IO, "e1000_ioport_writel %x: 0x%04x\n", index, val);
+
+if (index < NWRITEOPS && macreg_writeops[index]) {
+macreg_writeops[index](s, index, val);
+} else if (index < NREADOPS && macreg_readops[index]) {
+DBGOUT(IO, "e1000_ioport_writel RO %x: 0x%04x\n", index << 2, val);
+} else {
+DBGOUT(UNKNOWN, "IO unknown write index=0x%08x,val=0x%08x\n",
+   index, val);
+}
+} else {
+DBGOUT(UNKNOWN, "IO unknown write addr=0x%08x,val=0x%08x\n",
+   addr, val);
+}
+}
+
+static uint32_t
+e1000_ioport_readl(void *opaque, uint32_t addr)
+{
+E1000State *s = opaque;
+
+if (addr == s->ioport_base + REG_IOADDR) {
+return s->ioport_reg[REG_IOADDR] & 0xf;
+} else if (addr == (s->ioport_base + REG_IODATA)) {
+unsigned int index = (s->ioport_reg[REG_IOADDR] & 0x1) >> 2;
+
+if (index < NREADOPS && macreg_readops[index]) {
+uint32_t val = macreg_readops[index](s, index);
+#ifdef TARGET_WORDS_BIGENDIAN
+val = bswap32(val);
+#endif
+return val;
+}
+DBGOUT(UNKNOWN, "IO unknown read addr=0x%08x\n", index<<2);
+} else {
+DBGOUT(UNKNOWN, "IO unknown read addr=0x%08x\n", addr);
+}
+return 0;
+}
+
+static void
 e1000_mmio_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
 {
 E1000State *s = opaque;
@@ -1031,6 +1094,30 @@ static const uint32_t mac_reg_init

Re: [Qemu-devel] qdev: Some ISA devices don't handle second instantiation gracefully

2010-10-12 Thread Markus Armbruster
Anthony Liguori  writes:

> On 10/12/2010 08:00 AM, Markus Armbruster wrote:
>> Markus Armbruster  writes:
>>
>>
>>> When I try -device isa-applesmc -device isa-applesmc, I get
>>>
>>>  WARNING: Using AppleSMC with invalid key
>>>  qemu: hardware error: register_ioport_read: invalid opaque
>>>  [...]
>>>
>>> and a core dump.
>>>
>>> I know nothing about this device.  Instantiating twice may well make no
>>> sense.  But hw_error() is not a nice way to reject a command line
>>> option.
>>>  
>> Actually, ib700 and isa-debugcon fail the same way.
>>
>> They call register_ioport_write(), which aborts via hw_error() when the
>> port is already in use.  This is okay for non-configurable parts of a
>> board emulation, but not okay for a qdev device, unless it has no_user
>> set.
>>
>
> It's definitely right to fail but I agree, it's better to propagate
> the error.
>
>> Related: when isa_init_irq() finds the requested IRQ already in use, it
>> fails with exit(1).  Maybe register_ioport_write()&  friends should do
>> that as well.
>>
>> Or maybe qdev device models should have an "at most one" flag.
>>
>
> I think the proper thing to do is remove all exit(1)s and propagate
> errors instead.

exit() is good enough during startup, i.e. -device.  It's wrong for hot
plug; anything to be used in a hot plug path must propagate errors.  We
could keep exiting in code that's only used by non-hotpluggable devices.

> A simple approach would be to make register_ioport_{read,write}()
> return an int, then do a query-replace on the source tree to make all
> invocations of it simply check the return value and exit if it's
> non-zero.

In similar cases, we've used a simple FOO_nofail() wrapper in places
that want to exit.

I'll see what I can do.



Re: [Qemu-devel] [PATCH 00/39] Make configure command line autoconf-compatible

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> Here is the patch series implementing the idea I mentioned a while ago.
> 
> The first 14 introduce small changes to group pieces of code together
> and help understanding/reviewing the next changes.  Most of them are
> just cosmetic changes, though some of them have small behavioral changes.
> 
> After these come 19 patches that introduce autoconf-compatible aliases
> for options not respecting the autoconf command-line syntax.  The old
> versions are deprecated, but there is no change in semantics: the new
> aliases take exactly the same syntax.
> 
> There are also patches also rename the "interp_prefix" and "source_path"
> concepts to "sysroot" and "srcdir", which is consistent with GNU Makefile
> standards and with the  with the new aliasesnew aliases.
> 
> Patches 34 to 36 introduce new command-line options for cross-compilation
> that are again compatible with the GNU standards.  With these changes
> it is more or less possible to drop QEMU inside a GCC/binutils tree
> configured for cross-compilation and make it build together.
> 
> Patch 37 is a simple change to the help text now that the command-line
> syntax is finalized.
> 
> Patch 38 and 39, finally, make a few more baby steps using host triplets
> instead of custom feature detection.
> 

[..snip..]

>  19 files changed, 3729 insertions(+), 456 deletions(-)

I don't think the explanation above justified net plus of 3273 lines of new
code.

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



Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)

2010-10-12 Thread Anthony Liguori

On 10/12/2010 07:58 AM, Alon Levy wrote:

This patch adds a new device, it is described in full in the second patch
intro and also in the documentation in docs. In brief it provides a standard
smart card reader device.

The first patch is the configure change and docs.
The second patch contains the actual device, I couldn't figure out a good
way to split it to ease review.

v2 changed:
  * all QSIMPLEQ turned into fixed sized rings
  * all allocated buffers turned into fixed size buffers
  * added migration support
  * added a message to tell client qemu has migrated to ip:port
   * for lack of monitor commands ip:port are 0:0, which causes the updated
vscclient to connect to one port higher on the same host. will add monitor
commands in a separate patch. tested with current setup.
   


This is way too much magic to live within a device.  Devices manage 
reconnecting themselves during migration.  When you create the 
destination qemu instance, you specify what to connect to.


IOW,

On the source:

qemu -chardev tcp:localhost:1025,id=foo -usbdevice ccid,chardev=foo ...

On the destination:

qemu -chardev tcp:localhost:1026,id=foo -usbdevice ccid,chardev=foo 
-incoming tcp:0.0.0.0:1024 ...


A connection happens when the device is created.

But now I'm even further confused then when I first reviewed it..  If 
you're now supporting migration, does that mean that you're relying on 
the daemon to emulate the device?


Regards,

Anthony Liguori


Alon Levy (2):
   usb-ccid: add CCID device. add configure option.
   usb-ccid: add CCID device (device itself)

  Makefile.objs  |1 +
  configure  |   12 +
  docs/usb-ccid.txt  |  115 +
  hw/usb-ccid.c  | 1376 
  hw/vscard_common.h |  131 +
  5 files changed, 1635 insertions(+), 0 deletions(-)
  create mode 100644 docs/usb-ccid.txt
  create mode 100644 hw/usb-ccid.c
  create mode 100644 hw/vscard_common.h

   





Re: [Qemu-devel] Re: [PATCH v2 3/7] docs: Add QED image format specification

2010-10-12 Thread Anthony Liguori

On 10/12/2010 08:16 AM, Stefan Hajnoczi wrote:



Well, the protocol is currently encoded in the file name, separated by a
colon. Of course, we want to get rid of that, but we still don't know
what we want instead. It's completely unrelated to the backing file
format, though, it's about the format of the backing file name.
 

I agree with Kevin.  There's no need to have the ill-defined backing
format AFAICT.
   


Yeah, I've now convinced myself we don't need backing format name too.

Regards,

Anthony Liguori


Stefan
   





[Qemu-devel] [PATCH 39/39] use host triplets for feature detection

2010-10-12 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure |   64 -
 1 files changed, 21 insertions(+), 43 deletions(-)

diff --git a/configure b/configure
index 0340cfe..69b3406 100755
--- a/configure
+++ b/configure
@@ -290,49 +290,25 @@ case "$cpu" in
   ;;
 esac
 
-check_define() {
-cat > $TMPC <

Re: [Qemu-devel] [PATCH 00/39] Make configure command line autoconf-compatible

2010-10-12 Thread Paolo Bonzini

On 10/12/2010 03:22 PM, malc wrote:

  19 files changed, 3729 insertions(+), 456 deletions(-)


I don't think the explanation above justified net plus of 3273 lines of new
code.


The part you forgot to quote is:


 Makefile   |   54 +-
 Makefile.dis   |6 +-
 Makefile.hw|8 +-
 Makefile.objs  |4 +-
 Makefile.target|   32 +-
 Makefile.user  |6 +-
 bsd-user/main.c|   10 +-
 config.guess   | 1502 ++
 config.sub | 1731 
 configure  |  757 ++-
 create_config  |5 +-
 darwin-user/machload.c |   12 +-
 darwin-user/main.c |6 +-
 darwin-user/syscall.c  |2 +-
 linux-user/main.c  |   10 +-
 pc-bios/optionrom/Makefile |8 +-
 rules.mak  |   10 +-
 tests/Makefile |   16 +-
 tests/cris/Makefile|6 +-
 19 files changed, 3729 insertions(+), 456 deletions(-)


All these lines are in config.guess and config.sub that are shared with 
all projects using Autotools and do not really need to be considered.


It's 40 lines of new code, 33 of which are in configure's help message.

Paolo



Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> Do not hardcode the list of 64-bit CPUs.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  configure |   14 --
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/configure b/configure
> index cb76177..873e4a6 100755
> --- a/configure
> +++ b/configure
> @@ -1088,12 +1088,14 @@ esac
>  fi
>  
>  # host long bits test
> -hostlongbits="32"
> -case "$cpu" in
> -  x86_64|alpha|ia64|sparc64|ppc64|s390x)
> -hostlongbits=64
> -  ;;
> -esac
> +cat > $TMPC << EOF
> +int sizeof_long_is_8[sizeof(long) == 8 ? 1 : -1];
> +EOF
> +if compile_object; then
> +hostlongbits=64
> +else
> +hostlongbits=32
> +fi

This is wrong.

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



Re: [Qemu-devel] [PATCH 23/39] deprecate --audio-card-list

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> We have config files now which provide fine-grained control.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  configure |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 5786729..efebaa9 100755
> --- a/configure
> +++ b/configure
> @@ -856,8 +856,6 @@ echo "  --enable-sdl enable SDL"
>  echo "  --enable-cocoa   enable COCOA (Mac OS X only)"
>  echo "  --audio-drv-list=LISTset audio drivers list:"
>  echo "   Available drivers: $audio_possible_drivers"
> -echo "  --audio-card-list=LIST   set list of emulated audio cards 
> [$audio_card_list]"
> -echo "   Available cards: $audio_possible_cards"
>  echo "  --block-drv-whitelist=L  set block driver whitelist"
>  echo "   (affects only QEMU, not qemu-img)"
>  echo "  --enable-mixemu  enable mixer emulation"
> @@ -934,6 +932,8 @@ echo "  --extra-ldflags=LDFLAGS  append extra linker 
> flags LDFLAGS"
>  echo "  --fmod-lib   path to FMOD library"
>  echo "  --fmod-inc   path to FMOD includes"
>  echo "  --oss-libpath to OSS library"
> +echo "  --audio-card-list=LIST   set list of emulated audio cards 
> [$audio_card_list]"
> +echo "   Available cards: $audio_possible_cards"
>  echo "  --make=MAKE  use specified make [$make]"
>  echo "  --install=INSTALLuse specified install [$install]"
>  echo ""

Point of this text shuffling is? 

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



Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread Paolo Bonzini

On 10/12/2010 03:47 PM, malc wrote:

  # host long bits test
-hostlongbits="32"
-case "$cpu" in
-  x86_64|alpha|ia64|sparc64|ppc64|s390x)
-hostlongbits=64
-  ;;
-esac
+cat>  $TMPC<<  EOF
+int sizeof_long_is_8[sizeof(long) == 8 ? 1 : -1];
+EOF
+if compile_object; then
+hostlongbits=64
+else
+hostlongbits=32
+fi


This is wrong.


Care to expand?

$ grep LONG +build*/config-host.h
+build-32/config-host.h:#define HOST_LONG_BITS 32
+build-64/config-host.h:#define HOST_LONG_BITS 64

Paolo



[Qemu-devel] Invitación a conectarnos en LinkedIn

2010-10-12 Thread Ernesto Domato via LinkedIn
LinkedIn
Ernesto Domato requested to add you as a connection on LinkedIn:
--

Jiajun,

Me gustaría añadirte a mi red profesional en LinkedIn.
 
-Ernesto

Accept invitation from Ernesto Domato
http://www.linkedin.com/e/-kkb1ec-gf6v999o-6x/qTMmi8QEI_f3FNXUkL1mvZgy00BGYniwg3/blk/I55691412_11/pmpxnSRJrSdvj4R5fnhv9ClRsDgZp6lQs6lzoQ5AomZIpn8_cj5vcz4QcjASdjl9bQJAj7cVhmtybP0NdjgPe30TdP4LrCBxbOYWrSlI/EML_comm_afe/

View invitation from Ernesto Domato
http://www.linkedin.com/e/-kkb1ec-gf6v999o-6x/qTMmi8QEI_f3FNXUkL1mvZgy00BGYniwg3/blk/I55691412_11/0NclYOcjgNejoRdkALqnpPbOYWrSlI/svi/

-- 
DID YOU KNOW your LinkedIn profile helps you control your public image when 
people search for you? Setting your profile as public means your LinkedIn 
profile will come up when people enter your name in leading search engines. 
Take control of your image! 
http://www.linkedin.com/e/-kkb1ec-gf6v999o-6x/ewp/inv-22/

 
-- 
(c) 2010, LinkedIn Corporation

Re: [Qemu-devel] [PATCH 23/39] deprecate --audio-card-list

2010-10-12 Thread Paolo Bonzini

On 10/12/2010 03:49 PM, malc wrote:

On Tue, 12 Oct 2010, Paolo Bonzini wrote:


We have config files now which provide fine-grained control.

Signed-off-by: Paolo Bonzini
---
  configure |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 5786729..efebaa9 100755
--- a/configure
+++ b/configure
@@ -856,8 +856,6 @@ echo "  --enable-sdl enable SDL"
  echo "  --enable-cocoa   enable COCOA (Mac OS X only)"
  echo "  --audio-drv-list=LISTset audio drivers list:"
  echo "   Available drivers: $audio_possible_drivers"
-echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
-echo "   Available cards: $audio_possible_cards"
  echo "  --block-drv-whitelist=L  set block driver whitelist"
  echo "   (affects only QEMU, not qemu-img)"
  echo "  --enable-mixemu  enable mixer emulation"
@@ -934,6 +932,8 @@ echo "  --extra-ldflags=LDFLAGS  append extra linker flags 
LDFLAGS"
  echo "  --fmod-lib   path to FMOD library"
  echo "  --fmod-inc   path to FMOD includes"
  echo "  --oss-libpath to OSS library"
+echo "  --audio-card-list=LIST   set list of emulated audio cards 
[$audio_card_list]"
+echo "   Available cards: $audio_possible_cards"
  echo "  --make=MAKE  use specified make [$make]"
  echo "  --install=INSTALLuse specified install [$install]"
  echo ""


Point of this text shuffling is?


It gets under the "Deprecated options:" heading, see patch subject.

Paolo



Re: [Qemu-devel] [PATCH 00/39] Make configure command line autoconf-compatible

2010-10-12 Thread Paolo Bonzini

On 10/12/2010 04:30 PM, Anthony Liguori wrote:

I think there's a fair bit of value in looking like autoconf but a 39
patch series is a bit to digest at once.

I'll try to do a thorough review but I'd suggest keeping patch series
down to about 20 patches whenever possible and do multiple rounds as
necessary.


Yeah, I posted the whole thing to make it easier to test it, especially 
for people who cross-compile, and for Blue Swirl :) to test the special 
SPARC configury.


We can start from the first 14-15 patches.  These are the tricky ones 
that just prepare the terrain for the autoconfy behavior, but should 
have little or no semantic change on their own.  So, they're definitely 
the ones to concentrate on for review and for an initial split.


Thanks,

Paolo



Re: [Qemu-devel] [PATCH 00/39] Make configure command line autoconf-compatible

2010-10-12 Thread Anthony Liguori

On 10/12/2010 08:32 AM, malc wrote:

On Tue, 12 Oct 2010, Paolo Bonzini wrote:

   

On 10/12/2010 03:22 PM, malc wrote:
 

   19 files changed, 3729 insertions(+), 456 deletions(-)
 

I don't think the explanation above justified net plus of 3273 lines of new
code.
   

The part you forgot to quote is:
 

Yes, failed to notice that, sorry.

   
 

  Makefile   |   54 +-
  Makefile.dis   |6 +-
  Makefile.hw|8 +-
  Makefile.objs  |4 +-
  Makefile.target|   32 +-
  Makefile.user  |6 +-
  bsd-user/main.c|   10 +-
  config.guess   | 1502 ++
  config.sub | 1731

  configure  |  757 ++-
  create_config  |5 +-
  darwin-user/machload.c |   12 +-
  darwin-user/main.c |6 +-
  darwin-user/syscall.c  |2 +-
  linux-user/main.c  |   10 +-
  pc-bios/optionrom/Makefile |8 +-
  rules.mak  |   10 +-
  tests/Makefile |   16 +-
  tests/cris/Makefile|6 +-
  19 files changed, 3729 insertions(+), 456 deletions(-)
   

All these lines are in config.guess and config.sub that are shared with all
projects using Autotools and do not really need to be considered.

It's 40 lines of new code, 33 of which are in configure's help message.
 


I think there's a fair bit of value in looking like autoconf but a 39 
patch series is a bit to digest at once.


I'll try to do a thorough review but I'd suggest keeping patch series 
down to about 20 patches whenever possible and do multiple rounds as 
necessary.


Regards,

Anthony Liguori


Paolo

 
   





Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> On 10/12/2010 03:47 PM, malc wrote:
> > >   # host long bits test
> > > -hostlongbits="32"
> > > -case "$cpu" in
> > > -  x86_64|alpha|ia64|sparc64|ppc64|s390x)
> > > -hostlongbits=64
> > > -  ;;
> > > -esac
> > > +cat>  $TMPC<<  EOF
> > > +int sizeof_long_is_8[sizeof(long) == 8 ? 1 : -1];
> > > +EOF
> > > +if compile_object; then
> > > +hostlongbits=64
> > > +else
> > > +hostlongbits=32
> > > +fi
> > 
> > This is wrong.
> 
> Care to expand?

Gives wrong results on Win64.

> 
> $ grep LONG +build*/config-host.h
> +build-32/config-host.h:#define HOST_LONG_BITS 32
> +build-64/config-host.h:#define HOST_LONG_BITS 64
> 
> Paolo
> 

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



[Qemu-devel] Re: [Bug 638955] Re: emulated netcards don't work with recent sunos kernel

2010-10-12 Thread Stefan Hajnoczi
On Sat, Oct 2, 2010 at 8:23 PM, daniel pecka <638...@bugs.launchpad.net> wrote:
> well, i did some more investigations and here come a results ..
>
> this patch http://patchwork.ozlabs.org/patch/65137/raw/ solves problem
> partially .. NICs are working with that but after a deeper look,
> connection is lost when the netstack is flooded with higher traffic ..

I haven't looked more into this but noticed an e1000 patch from
Anthony Perard which may improve the Solaris experience:
http://patchwork.ozlabs.org/patch/67594/

Stefan

-- 
emulated netcards don't work with recent sunos kernel
https://bugs.launchpad.net/bugs/638955
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:
hi there,

i'm using qemu-kvm backend in version: # qemu-kvm -version
QEMU PC emulator version 0.12.5 (qemu-kvm-0.12.5), Copyright (c) 2003-2008 
Fabrice Bellard

and there are just *not working any of model=$type with combinations of recent 
sunos (solaris, openindiana, opensolaris, ..) ..

you can download for testing purposes iso from here: 
http://dlc-origin.openindiana.org/isos/147/ or from here: 
http://genunix.org/distributions/indiana/ << osol and oi are also bubuntu-like 
*live cds, so no need to bother with installing

behaviour is as follows:
e1000 - receiving doesn't work, transmitting works .. dladm (tool for handle 
ethers) shows that is all ok, correct mode is loaded up, it just seems like 
this driver works at 100% but ..

rtl8169|pcnet - works in 10Mbit mode with several other issues like high cpu 
utilization and so .. dladm is unable to recognize options for this kind of -nic

others - just don't work

.. i experienced this issue several times in past .. woraround was, that 
rtl8169 worked so-so .. with recent sunos kernel it doesn't.

it's easy to reproduce, this is why i'm not putting here more then launching 
script for my virtual machine:

# cat openindiana.sh
qemu-kvm -hda /home/kvm/openindiana/openindiana.img -m 2048 -localtime -cdrom 
/home/kvm/+images/oi-dev-147-x86.iso -boot d \
-vga std -vnc :9 -k en-us -monitor 
unix:/home/kvm/openindiana/instance,server,nowait \
-net nic,model=e1000,vlan=1 -net tap,ifname=oi0,script=no,vlan=1 &

sleep 2;
ip l set oi0 up;
ip a a 192.168.99.9/24 dev oi0;

regards by daniel





[Qemu-devel] Re: qdev: Some ISA devices don't handle second instantiation gracefully

2010-10-12 Thread Gerd Hoffmann

  Hi,


They call register_ioport_write(), which aborts via hw_error() when
the port is already in use.  This is okay for non-configurable
parts of a board emulation, but not okay for a qdev device, unless
it has no_user set.

Related: when isa_init_irq() finds the requested IRQ already in
use, it fails with exit(1).  Maybe register_ioport_write()&
friends should do that as well.

Or maybe qdev device models should have an "at most one" flag.


There can be multiple of these devices on different ports, but a
single PIO port can still only be managed by a single device. By
creating the same device twice without giving it a PIO option, you
put two devices on the same PIO port which can't work.

As this is a configuration error, I'd guess the best way to deal with
it is to return an error for register_ioport which makes the qdev
init fail. Then the respective instantiator can do what is fit. If
the device is passed in on the cmdline, it'd refuse to create the
machine and exit. If it's a hotplug event, it would fail to hotplug.


ISA isn't hotpluggable anyway, so just exiting unconditionally here 
isn't a big issue IMHO as effectively only ISA devices are affected by 
this.


register_ioport_write() should exit with a more useful error message 
here instead of calling hw_error() though.


We could also make register_ioport_write() pass up an error and have all 
callers check that.  Not sure this is worth the trouble though.


An "at most one" flag might make sense.  But on a PC all ISA devices 
which exist only once at a fixed address (keyboard, floppy, ...) are 
automagically created so no_user does the trick here.  The other ones 
(serial, ne2k_isa, ...) actually can be created multiple times if you 
configure different iobases using properties.


Dunno what kind of device apple-smc is ...

cheers,
  Gerd




Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread Paolo Bonzini

On 10/12/2010 04:38 PM, malc wrote:

On Tue, 12 Oct 2010, Paolo Bonzini wrote:


On 10/12/2010 03:47 PM, malc wrote:

   # host long bits test
-hostlongbits="32"
-case "$cpu" in
-  x86_64|alpha|ia64|sparc64|ppc64|s390x)
-hostlongbits=64
-  ;;
-esac
+cat>   $TMPC<<   EOF
+int sizeof_long_is_8[sizeof(long) == 8 ? 1 : -1];
+EOF
+if compile_object; then
+hostlongbits=64
+else
+hostlongbits=32
+fi


This is wrong.


Care to expand?


Gives wrong results on Win64.


Then it's not HOST_LONG_BITS, it's HOST_POINTER_BITS.

Paolo



[Qemu-devel] Re: [PATCH v2 5/7] qed: Table, L2 cache, and cluster functions

2010-10-12 Thread Kevin Wolf
Am 08.10.2010 17:48, schrieb Stefan Hajnoczi:
> This patch adds code to look up data cluster offsets in the image via
> the L1/L2 tables.  The L2 tables are writethrough cached in memory for
> performance (each read/write requires a lookup so it is essential to
> cache the tables).
> 
> With cluster lookup code in place it is possible to implement
> bdrv_is_allocated() to query the number of contiguous
> allocated/unallocated clusters.
> 
> Signed-off-by: Stefan Hajnoczi 
> ---
>  Makefile.objs|2 +-
>  block/qed-cluster.c  |  145 +++
>  block/qed-gencb.c|   32 +
>  block/qed-l2-cache.c |  132 +
>  block/qed-table.c|  316 
> ++
>  block/qed.c  |   57 +-
>  block/qed.h  |  108 +
>  trace-events |6 +
>  8 files changed, 796 insertions(+), 2 deletions(-)
>  create mode 100644 block/qed-cluster.c
>  create mode 100644 block/qed-gencb.c
>  create mode 100644 block/qed-l2-cache.c
>  create mode 100644 block/qed-table.c
> 
> diff --git a/Makefile.objs b/Makefile.objs
> index ff15795..7b3b19c 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -14,7 +14,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
>  
>  block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o 
> vpc.o vvfat.o
>  block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
> -block-nested-y += qed.o
> +block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o
>  block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o
>  block-nested-$(CONFIG_WIN32) += raw-win32.o
>  block-nested-$(CONFIG_POSIX) += raw-posix.o
> diff --git a/block/qed-cluster.c b/block/qed-cluster.c
> new file mode 100644
> index 000..af65e5a
> --- /dev/null
> +++ b/block/qed-cluster.c
> @@ -0,0 +1,145 @@
> +/*
> + * QEMU Enhanced Disk Format Cluster functions
> + *
> + * Copyright IBM, Corp. 2010
> + *
> + * Authors:
> + *  Stefan Hajnoczi   
> + *  Anthony Liguori   
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
> + * See the COPYING file in the top-level directory.

Hm, just noticed it here: COPYING is the text of the GPL, not LGPL. The
same comment applies to all other QED files, too.

> + *
> + */
> +
> +#include "qed.h"
> +
> +/**
> + * Count the number of contiguous data clusters
> + *
> + * @s:  QED state
> + * @table:  L2 table
> + * @index:  First cluster index
> + * @n:  Maximum number of clusters
> + * @offset: Set to first cluster offset
> + *
> + * This function scans tables for contiguous allocated or free clusters.
> + */
> +static unsigned int qed_count_contiguous_clusters(BDRVQEDState *s,
> +  QEDTable *table,
> +  unsigned int index,
> +  unsigned int n,
> +  uint64_t *offset)
> +{
> +unsigned int end = MIN(index + n, s->table_nelems);
> +uint64_t last = table->offsets[index];
> +unsigned int i;
> +
> +*offset = last;
> +
> +for (i = index + 1; i < end; i++) {
> +if (last == 0) {
> +/* Counting free clusters */
> +if (table->offsets[i] != 0) {
> +break;
> +}
> +} else {
> +/* Counting allocated clusters */
> +if (table->offsets[i] != last + s->header.cluster_size) {
> +break;
> +}
> +last = table->offsets[i];
> +}
> +}
> +return i - index;
> +}
> +
> +typedef struct {
> +BDRVQEDState *s;
> +uint64_t pos;
> +size_t len;
> +
> +QEDRequest *request;
> +
> +/* User callback */
> +QEDFindClusterFunc *cb;
> +void *opaque;
> +} QEDFindClusterCB;
> +
> +static void qed_find_cluster_cb(void *opaque, int ret)
> +{
> +QEDFindClusterCB *find_cluster_cb = opaque;
> +BDRVQEDState *s = find_cluster_cb->s;
> +QEDRequest *request = find_cluster_cb->request;
> +uint64_t offset = 0;
> +size_t len = 0;
> +unsigned int index;
> +unsigned int n;
> +
> +if (ret) {
> +ret = QED_CLUSTER_ERROR;

Can ret be anything else here? If so, why would we return a more generic
error value instead of passing down the original one?

[Okay, after having read more code, this is the place where we throw
errno away. We shouldn't do that.]

I also wonder, if reading from the disk failed, is the errno value lost?

> +goto out;
> +}
> +
> +index = qed_l2_index(s, find_cluster_cb->pos);
> +n = qed_bytes_to_clusters(s,
> +  qed_offset_into_cluster(s, 
> find_cluster_cb->pos) +
> +  find_cluster_cb->len);
> +n = qed_count_contiguous_clusters(s, request->l2_table->table,
> + 

Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread Paolo Bonzini
On 10/12/2010 04:41 PM, malc wrote:
> > > >  Gives wrong results on Win64.
> >  
> >  Then it's not HOST_LONG_BITS, it's HOST_POINTER_BITS.
> 
> Not quite, [s]size_t/ptrdiff_t are 64 bits wide udner Win64, little
> to do with pointers.

Before (on Win64): sizeof(long) == 4, HOST_LONG_BITS == 64

After: sizeof(long) == 4, HOST_LONG_BITS == 32

If you say HOST_LONG_BITS should be 64, then I say it is poorly named: it
represents sizeof(void*) * CHAR_BIT and should be named HOST_POINTER_BITS.

BTW, HOST_LONG_BITS is used mostly for user-mode emulation, which does not
matter for Win64.  In exec-all.h it is used to second-guess
sizeof(tcg_target_long), which would be the size of a pointer.  However,
it is safe to give a conservative value based on sizeof(long).

Finally, in other places it is definitely used to mean sizeof(long).  Even
though the softmmu is probably not IL32P64-clean, there you have this:

#if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32
#define CPU_TLB_ENTRY_BITS 4
#else
#define CPU_TLB_ENTRY_BITS 5
#endif

typedef struct CPUTLBEntry {
/* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address
   bit TARGET_PAGE_BITS-1..4  : Nonzero for accesses that should not
go directly to ram.
   bit 3  : indicates that the entry is invalid
   bit 2..0   : zero
*/
target_ulong addr_read;
target_ulong addr_write;
target_ulong addr_code;
/* Addend to virtual address to get host address.  IO accesses
   use the corresponding iotlb value.  */
unsigned long addend;
/* padding to get a power of two size */
uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
  (sizeof(target_ulong) * 3 +
   ((-sizeof(target_ulong) * 3) & (sizeof(unsigned long) - 1)) 
+ 
   sizeof(unsigned long))];
} CPUTLBEntry;

_As things are now_ it is more correct to use sizeof(long), or at
least more conservative.

I can certainly change it to sizeof(void*) in v2, even though I don't think
it's a good idea, but it's your call as a maintainer.

Paolo



Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> On 10/12/2010 04:38 PM, malc wrote:
> > On Tue, 12 Oct 2010, Paolo Bonzini wrote:
> > 
> > > On 10/12/2010 03:47 PM, malc wrote:
> > > > ># host long bits test
> > > > > -hostlongbits="32"
> > > > > -case "$cpu" in
> > > > > -  x86_64|alpha|ia64|sparc64|ppc64|s390x)
> > > > > -hostlongbits=64
> > > > > -  ;;
> > > > > -esac
> > > > > +cat>   $TMPC<<   EOF
> > > > > +int sizeof_long_is_8[sizeof(long) == 8 ? 1 : -1];
> > > > > +EOF
> > > > > +if compile_object; then
> > > > > +hostlongbits=64
> > > > > +else
> > > > > +hostlongbits=32
> > > > > +fi
> > > > 
> > > > This is wrong.
> > > 
> > > Care to expand?
> > 
> > Gives wrong results on Win64.
> 
> Then it's not HOST_LONG_BITS, it's HOST_POINTER_BITS.

Not quite, [s]size_t/ptrdiff_t are 64 bits wide udner Win64, little
to do with pointers.

> 
> Paolo
> 

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



Re: [Qemu-devel] qdev: Some ISA devices don't handle second instantiation gracefully

2010-10-12 Thread Anthony Liguori

On 10/12/2010 08:54 AM, Markus Armbruster wrote:



I think the proper thing to do is remove all exit(1)s and propagate
errors instead.
 

exit() is good enough during startup, i.e. -device.  It's wrong for hot
plug; anything to be used in a hot plug path must propagate errors.  We
could keep exiting in code that's only used by non-hotpluggable devices.
   


I'm not really suggesting that we move exit()s out of all devices right 
now.  Am just suggesting that we bump them up one level.



A simple approach would be to make register_ioport_{read,write}()
return an int, then do a query-replace on the source tree to make all
invocations of it simply check the return value and exit if it's
non-zero.
 

In similar cases, we've used a simple FOO_nofail() wrapper in places
that want to exit.

I'll see what I can do.
   


I prefer propagating the exit but am not deeply opposed to nofail().

Regards,

Anthony Liguori



[Qemu-devel] Re: [PATCH v2 6/7] qed: Read/write support

2010-10-12 Thread Anthony Liguori

On 10/12/2010 10:08 AM, Kevin Wolf wrote:

  Otherwise we might destroy data that isn't
even touched by the guest request in case of a crash.
   


The failure scenarios are either that the cluster is leaked in which 
case, the old version of the data is still present or the cluster is 
orphaned because the L2 entry is written, in which case the old version 
of the data is present.


Are you referring to a scenario where the cluster is partially written 
because the data is present in the write cache and the write cache isn't 
flushed on power failure?


Regards,

Anthony Liguori


Kevin
   





Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread Paolo Bonzini

On 10/12/2010 05:12 PM, malc wrote:


Bottom line: QEMU assumes that long is large enough to hold a pointer,
this assumption is wrong, and your patch is wrong (not because it
miscalculates size of ABI long) but because of the assumptions current
code has. Whether two wrongs makes right is an open question, currently
Win64 isnot supported in any shape or form, even though Filip Navarra
once did a port[1] which never went into mainline.

[1] http://marc.info/?l=qemu-devel&m=124912692531724&w=2


His port apparently is fine with HOST_LONG_BITS == sizeof(void *), I'll 
adjust for v2.


Paolo



Re: [Qemu-devel] [PATCH 08/39] provide portable sizeof(long) test

2010-10-12 Thread malc
On Tue, 12 Oct 2010, Paolo Bonzini wrote:

> On 10/12/2010 04:41 PM, malc wrote:
> > > > >  Gives wrong results on Win64.
> > >  
> > >  Then it's not HOST_LONG_BITS, it's HOST_POINTER_BITS.
> > 
> > Not quite, [s]size_t/ptrdiff_t are 64 bits wide udner Win64, little
> > to do with pointers.
> 
> Before (on Win64): sizeof(long) == 4, HOST_LONG_BITS == 64
> 
> After: sizeof(long) == 4, HOST_LONG_BITS == 32
> 
> If you say HOST_LONG_BITS should be 64, then I say it is poorly named: it
> represents sizeof(void*) * CHAR_BIT and should be named HOST_POINTER_BITS.
> 
> BTW, HOST_LONG_BITS is used mostly for user-mode emulation, which does not
> matter for Win64.  In exec-all.h it is used to second-guess
> sizeof(tcg_target_long), which would be the size of a pointer.  However,
> it is safe to give a conservative value based on sizeof(long).
> 
> Finally, in other places it is definitely used to mean sizeof(long).  Even
> though the softmmu is probably not IL32P64-clean, there you have this:
> 
> #if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32
> #define CPU_TLB_ENTRY_BITS 4
> #else
> #define CPU_TLB_ENTRY_BITS 5
> #endif
> 
> typedef struct CPUTLBEntry {
> /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address
>bit TARGET_PAGE_BITS-1..4  : Nonzero for accesses that should not
> go directly to ram.
>bit 3  : indicates that the entry is invalid
>bit 2..0   : zero
> */
> target_ulong addr_read;
> target_ulong addr_write;
> target_ulong addr_code;
> /* Addend to virtual address to get host address.  IO accesses
>use the corresponding iotlb value.  */
> unsigned long addend;
> /* padding to get a power of two size */
> uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
>   (sizeof(target_ulong) * 3 +
>((-sizeof(target_ulong) * 3) & (sizeof(unsigned long) - 
> 1)) + 
>sizeof(unsigned long))];
> } CPUTLBEntry;
> 
> _As things are now_ it is more correct to use sizeof(long), or at
> least more conservative.
> 
> I can certainly change it to sizeof(void*) in v2, even though I don't think
> it's a good idea, but it's your call as a maintainer.
> 

Bottom line: QEMU assumes that long is large enough to hold a pointer,
this assumption is wrong, and your patch is wrong (not because it 
miscalculates size of ABI long) but because of the assumptions current
code has. Whether two wrongs makes right is an open question, currently
Win64 isnot supported in any shape or form, even though Filip Navarra
once did a port[1] which never went into mainline.

[1] http://marc.info/?l=qemu-devel&m=124912692531724&w=2

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



[Qemu-devel] Re: [PATCH v2 6/7] qed: Read/write support

2010-10-12 Thread Kevin Wolf
Am 08.10.2010 17:48, schrieb Stefan Hajnoczi:
> This patch implements the read/write state machine.  Operations are
> fully asynchronous and multiple operations may be active at any time.
> 
> Allocating writes lock tables to ensure metadata updates do not
> interfere with each other.  If two allocating writes need to update the
> same L2 table they will run sequentially.  If two allocating writes need
> to update different L2 tables they will run in parallel.
> 
> Signed-off-by: Stefan Hajnoczi 

I hope to review this in more detail tomorrow, but there's one thing I
already noticed: When allocating a cluster, but not writing the whole
cluster (i.e. requests involving COW), I think we need to flush after
the COW and before the cluster allocation is written to the L2 table to
maintain the right order. Otherwise we might destroy data that isn't
even touched by the guest request in case of a crash.

Kevin



[Qemu-devel] Re: [PATCH v2 6/7] qed: Read/write support

2010-10-12 Thread Kevin Wolf
Am 12.10.2010 17:22, schrieb Anthony Liguori:
> On 10/12/2010 10:08 AM, Kevin Wolf wrote:
>>   Otherwise we might destroy data that isn't
>> even touched by the guest request in case of a crash.
>>
> 
> The failure scenarios are either that the cluster is leaked in which 
> case, the old version of the data is still present or the cluster is 
> orphaned because the L2 entry is written, in which case the old version 
> of the data is present.

Hm, how does the latter case work? Or rather, what do mean by "orphaned"?

> Are you referring to a scenario where the cluster is partially written 
> because the data is present in the write cache and the write cache isn't 
> flushed on power failure?

The case I'm referring to is a COW. So let's assume a partial write to
an unallocated cluster, we then need to do a COW in pre/postfill. Then
we do a normal write and link the new cluster in the L2 table.

Assume that the write to the L2 table is already on the disk, but the
pre/postfill data isn't yet. At this point we have a bad state because
if we crash now we have lost the data that should have been copied from
the backing file.

If we can't guarantee that a new cluster is all zeros, the same happens
without a backing file. So as soon as we start reusing freed clusters,
we get this case for all QED images.

Kevin



[Qemu-devel] [Bug 659276] [NEW] Accessing Century byte via RTC

2010-10-12 Thread Ian Seyler
Public bug reported:

With the RTC configure for Binary instead of BCD I am getting the
incorrect result for Century.

mov al, 0x0B; Set RTC to binary mode
out 0x70, al
in al, 0x71
bts ax, 2
mov bl, al
mov al, 0x0B
out 0x70, al
mov al, bl
out 0x71, al

mov al, 0x32; Century
out 0x70, al
in al, 0x71

In QEMU 0.12.5 it returns 0x20 but should return 0x14. The following
work correctly:

mov al, 0x09; Year
out 0x70, al
in al, 0x71

mov al, 0x08; Month
out 0x70, al
in al, 0x71

mov al, 0x07; Day
out 0x70, al
in al, 0x71

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
Accessing Century byte via RTC
https://bugs.launchpad.net/bugs/659276
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:
With the RTC configure for Binary instead of BCD I am getting the incorrect 
result for Century.

mov al, 0x0B; Set RTC to binary mode
out 0x70, al
in al, 0x71
bts ax, 2
mov bl, al
mov al, 0x0B
out 0x70, al
mov al, bl
out 0x71, al

mov al, 0x32; Century
out 0x70, al
in al, 0x71

In QEMU 0.12.5 it returns 0x20 but should return 0x14. The following work 
correctly:

mov al, 0x09; Year
out 0x70, al
in al, 0x71

mov al, 0x08; Month
out 0x70, al
in al, 0x71

mov al, 0x07; Day
out 0x70, al
in al, 0x71





Re: [Qemu-devel] [RFT] qemu 0.13.0-rc3

2010-10-12 Thread Rick Vernam
I encountered two issues with 0.13.0-rc1, not sure how to tell if the patches 
have been applied?

one is this patch: http://patchwork.ozlabs.org/patch/62420/
discussed here:
http://lists.nongnu.org/archive/html/qemu-devel/2010-09/msg01114.html

the other was
http://lists.nongnu.org/archive/html/qemu-devel/2010-09/msg01165.html
which was applied to seabios, but how can I determine if the shipped seabios 
includes this particular patch?

Sorry for the noise...

On Monday 11 October 2010 17:15:30 Anthony Liguori wrote:
> After suffering from a prolonged maintainer softlockup, I'm attempting
> to get 0.13.0 release process back on track.
> 
> I've tagged qemu-0.13.0-rc3 in git which only carries a few changes
> since 0.13.0-rc1.  Most notably, a series of updates from Kevin Wolf and
> Cam Macdonell's ivshmem device.
> 
> I think we're pretty good testing wise for the final release but I
> wanted to offer a 24-hour window for last minute fixes.  I'm only
> interested in the following:
> 
> 1) Patches that are *tested* against the stable-0.13 branch that are
> already committed in master.  Please tell me explicitly that you've
> tested the patch and how you've tested it.
> 
> 2) Pull requests from other maintainers with cherry-picked patches
> against stable-0.13 that have been tested.
> 
> If you don't already have something ready, it's probably not worth
> worrying about.  We can follow with 0.13.1 in a relatively short period
> of time.
> 
> So please get any requests to me before 6PM US Central time October 12th.
> 
> Post 0.13.0, as part of the 0.14 planning, we can discuss how to avoid
> future delay with releases.
> 
> Thanks!
> 
> Regards,
> 
> Anthony Liguori



Re: [Qemu-devel] [PATCH 1/4] Introduce strtosz() library function to convert a string to a byte count.

2010-10-12 Thread Markus Armbruster
Still not entirely happy, but maybe we can commit it as is, and fix it
up later.

jes.soren...@redhat.com writes:

> From: Jes Sorensen 
>
> strtosz() returns -1 on error. It now supports human unit formats in
> eg. 1.0G, with better error handling.
>
> This version lets strtod() do the actual parsing instead of relying on
> strspn, as well as catches NaN input.

This is information on what changed since v5, and as such it doesn't
belong into the commit message.

> The following suffixes are supported:
> B/b = bytes
> K/k = KB
> M/m = MB
> G/g = GB
> T/t = TB
>
> Signed-off-by: Jes Sorensen 

Would be nice if commit message documented that this affects -numa and
-m.  In particular that they now accept more suffixes than before.

> ---
>  cutils.c  |   79 
> +
>  qemu-common.h |1 +
>  vl.c  |   31 +++---
>  3 files changed, 90 insertions(+), 21 deletions(-)
>
> diff --git a/cutils.c b/cutils.c
> index 5883737..8e79d92 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -23,6 +23,7 @@
>   */
>  #include "qemu-common.h"
>  #include "host-utils.h"
> +#include 
>  
>  void pstrcpy(char *buf, int buf_size, const char *str)
>  {
> @@ -283,3 +284,81 @@ int fcntl_setfl(int fd, int flag)
>  }
>  #endif
>  
> +/*
> + * Convert string to bytes, allowing either B/b for bytes, K/k for KB,
> + * M/m for MB, G/g for GB or T/t for TB. Default without any postfix
> + * is MB. End pointer will be returned in *end, if end is valid.

Nitpick: There are plenty of invalid pointers we'll happily attempt to
use.  "unless end is null" would be more precise.

> + * Return -1 on error.
> + */
> +ssize_t strtosz(const char *nptr, char **end)
> +{
> +ssize_t retval = -1;
> +int64_t tmpval;
> +char *endptr, c;
> +int mul_required = 0;
> +double val, mul, integral, fraction;
> +
> +errno = 0;
> +val = strtod(nptr, &endptr);
> +if (isnan(val) || endptr == nptr || errno != 0 || val < 0 ||
> +val == HUGE_VAL) {

ISO C permits implementations supporting infinities to make HUGE_VAL
*not* +inf.  So this may not catch +inf.  val >= HUGE_VAL would.

But since we have to catch val * mul out of range further down anyway,
the check for HUGE_VAL may be redundant here.

> +goto fail;
> +}
> +integral = modf(val, &fraction);
> +if (integral != 0) {
> +mul_required = 1;
> +}
> +/*
> + * Any whitespace character is fine for terminating the number,
> + * otherwise check that the suffix is just one character.
> + */
> +c = *endptr++;
> +if (isspace(c) || c == '\0') {
> +c = 0;
> +} else if (!isspace(*endptr) && *endptr != 0) {
> +goto fail;
> +}

I'm not happy with this check.

If the caller needs a complete string consumed, then this check is
insufficient, because it doesn't catch trailing garbage as long as it
starts with whitespace.  The caller still needs to check !*endptr.

If the caller needs to continue parsing after the value, and expects
anything but whitespace there, it has to copy the value first.  Only
easy if the value is followed by some delimiter that can't occur in the
value.  Example: parse a size value from something of them form
name=value,name=value...  Need to copy up to the next comma or end of
string.

The check complicates the second case without really helping the first
case.

Nevertheless, it's good enough for the uses in this patch series, so I'm
not insisting on getting this changed now.

> +switch (c) {
> +case 'B':
> +case 'b':
> +mul = 1;
> +if (mul_required) {
> +goto fail;
> +}
> +break;
> +case 'K':
> +case 'k':
> +mul = 1 << 10;
> +break;
> +case 0:
> +if (mul_required) {
> +goto fail;
> +}
> +case 'M':
> +case 'm':
> +mul = 1ULL << 20;
> +break;
> +case 'G':
> +case 'g':
> +mul = 1ULL << 30;
> +break;
> +case 'T':
> +case 't':
> +mul = 1ULL << 40;
> +break;
> +default:
> +goto fail;
> +}
> +tmpval = (val * mul);
> +if (tmpval >= ~(size_t)0) {
> +goto fail;

val * mul may exceed the range of int64_t tmpval, and then the
assignment has undefined behavior.  Obvious way to avoid that:

if (val * mul >= ~(size_t)0) {
goto fail;
}
retval = val * mul;

> +}
> +retval = tmpval;
> +
> +if (end) {
> +*end = endptr;
> +}
> +
> +fail:
> +return retval;
> +}
> diff --git a/qemu-common.h b/qemu-common.h
> index 81aafa0..0a062d4 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -153,6 +153,7 @@ time_t mktimegm(struct tm *tm);
>  int qemu_fls(int i);
>  int qemu_fdatasync(int fd);
>  int fcntl_setfl(int fd, int flag);
> +ssize_t strtosz(const char *nptr, char **end);
>  
>  /* path.c */
>  void init_paths(const char *prefix);
> diff --git a/vl.c b/vl.c
> index df414ef..604

[Qemu-devel] Re: [PATCH v2 6/7] qed: Read/write support

2010-10-12 Thread Stefan Hajnoczi
On Tue, Oct 12, 2010 at 05:39:48PM +0200, Kevin Wolf wrote:
> Am 12.10.2010 17:22, schrieb Anthony Liguori:
> > On 10/12/2010 10:08 AM, Kevin Wolf wrote:
> >>   Otherwise we might destroy data that isn't
> >> even touched by the guest request in case of a crash.
> >>
> > 
> > The failure scenarios are either that the cluster is leaked in which 
> > case, the old version of the data is still present or the cluster is 
> > orphaned because the L2 entry is written, in which case the old version 
> > of the data is present.
> 
> Hm, how does the latter case work? Or rather, what do mean by "orphaned"?
> 
> > Are you referring to a scenario where the cluster is partially written 
> > because the data is present in the write cache and the write cache isn't 
> > flushed on power failure?
> 
> The case I'm referring to is a COW. So let's assume a partial write to
> an unallocated cluster, we then need to do a COW in pre/postfill. Then
> we do a normal write and link the new cluster in the L2 table.
> 
> Assume that the write to the L2 table is already on the disk, but the
> pre/postfill data isn't yet. At this point we have a bad state because
> if we crash now we have lost the data that should have been copied from
> the backing file.

In this case QED_F_NEED_CHECK is set and the invalid cluster offset
should be reset to zero on open.

However, I think we can get into a state where the pre/postfill data
isn't on the disk yet but another allocation has increased the file
size, making the unwritten cluster "valid".  This fools consistency
check into thinking the data cluster (which was never written to on
disk) is valid.

Will think about this more tonight.

Stefan



Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)

2010-10-12 Thread Alon Levy

- "Anthony Liguori"  wrote:

> On 10/12/2010 07:58 AM, Alon Levy wrote:
> > This patch adds a new device, it is described in full in the second
> patch
> > intro and also in the documentation in docs. In brief it provides a
> standard
> > smart card reader device.
> >
> > The first patch is the configure change and docs.
> > The second patch contains the actual device, I couldn't figure out a
> good
> > way to split it to ease review.
> >
> > v2 changed:
> >   * all QSIMPLEQ turned into fixed sized rings
> >   * all allocated buffers turned into fixed size buffers
> >   * added migration support
> >   * added a message to tell client qemu has migrated to ip:port
> >* for lack of monitor commands ip:port are 0:0, which causes the
> updated
> > vscclient to connect to one port higher on the same host. will
> add monitor
> > commands in a separate patch. tested with current setup.
> >
> 
> This is way too much magic to live within a device.  Devices manage 
> reconnecting themselves during migration.  When you create the 
> destination qemu instance, you specify what to connect to.
> 
> IOW,
> 
> On the source:
> 
> qemu -chardev tcp:localhost:1025,id=foo -usbdevice ccid,chardev=foo
> ...
> 
> On the destination:
> 
> qemu -chardev tcp:localhost:1026,id=foo -usbdevice ccid,chardev=foo 
> -incoming tcp:0.0.0.0:1024 ...
> 
> A connection happens when the device is created.
> 
> But now I'm even further confused then when I first reviewed it..  If
> 
> you're now supporting migration, does that mean that you're relying on
> 
> the daemon to emulate the device?
> 

Let me try to clarify this. Nothing has changed since the last patch except
for what's in the notes, i.e. migration support. The device I'm adding is a
reader. The reader is just a pipe between smart cards and the guest operating
system. The smart card logic does live outside of this device, and is available
in the cac_card sources at http://cgit.freedesktop.org/~alon/cac_card/ (all of
this is in docs/usb_ccid.txt).

So when I speak of vscclient, I'm talking of an application that emulates a 
smart
card and initiates a tcp connection to qemu that connects to the usb-ccid 
device.
vscclient is also in the cac_card sources.

Regarding the method of reconnection: You are absolutely right that if I have 
qemu
connect to the remote instead of the other way around then I remove the need to 
inform
vscclient of the new address. But the way it stands requires the client to know 
the
address of the destination qemu. I have to inform it somehow. You are saying 
that
devices shouldn't know this information? ok, that's why I talked about monitor 
commands.
I come from the world of spice - in spice we use monitor commands for this. I 
could
change this to have qemu connect to vscclient, but I don't see the logic in 
general -
sometimes you do want to have a chardev that is listening (the fact that it is 
implemented
suggests someone found it useful), if you then migrate you have the same 
problem I'm
solving.

> Regards,
> 
> Anthony Liguori
> 
> > Alon Levy (2):
> >usb-ccid: add CCID device. add configure option.
> >usb-ccid: add CCID device (device itself)
> >
> >   Makefile.objs  |1 +
> >   configure  |   12 +
> >   docs/usb-ccid.txt  |  115 +
> >   hw/usb-ccid.c  | 1376
> 
> >   hw/vscard_common.h |  131 +
> >   5 files changed, 1635 insertions(+), 0 deletions(-)
> >   create mode 100644 docs/usb-ccid.txt
> >   create mode 100644 hw/usb-ccid.c
> >   create mode 100644 hw/vscard_common.h
> >
> >



[Qemu-devel] Re: [PATCH v2 6/7] qed: Read/write support

2010-10-12 Thread Avi Kivity

 On 10/12/2010 06:16 PM, Anthony Liguori wrote:


It's fairly simple to add a sync to this path.  It's probably worth 
checking the prefill/postfill for zeros and avoiding the write/sync if 
that's the case.  That should optimize the common cases of allocating 
new space within a file.


My intuition is that we can avoid the sync entirely but we'll need to 
think about it further.




I don't think so.  This isn't a guest initiated write so we can't shift 
responsibility to the guest.


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




Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)

2010-10-12 Thread Anthony Liguori

On 10/12/2010 11:03 AM, Alon Levy wrote:

- "Anthony Liguori"  wrote:

   

On 10/12/2010 07:58 AM, Alon Levy wrote:
 

This patch adds a new device, it is described in full in the second
   

patch
 

intro and also in the documentation in docs. In brief it provides a
   

standard
 

smart card reader device.

The first patch is the configure change and docs.
The second patch contains the actual device, I couldn't figure out a
   

good
 

way to split it to ease review.

v2 changed:
   * all QSIMPLEQ turned into fixed sized rings
   * all allocated buffers turned into fixed size buffers
   * added migration support
   * added a message to tell client qemu has migrated to ip:port
* for lack of monitor commands ip:port are 0:0, which causes the
   

updated
 

 vscclient to connect to one port higher on the same host. will
   

add monitor
 

 commands in a separate patch. tested with current setup.

   

This is way too much magic to live within a device.  Devices manage
reconnecting themselves during migration.  When you create the
destination qemu instance, you specify what to connect to.

IOW,

On the source:

qemu -chardev tcp:localhost:1025,id=foo -usbdevice ccid,chardev=foo
...

On the destination:

qemu -chardev tcp:localhost:1026,id=foo -usbdevice ccid,chardev=foo
-incoming tcp:0.0.0.0:1024 ...

A connection happens when the device is created.

But now I'm even further confused then when I first reviewed it..  If

you're now supporting migration, does that mean that you're relying on

the daemon to emulate the device?

 

Let me try to clarify this. Nothing has changed since the last patch except
for what's in the notes, i.e. migration support. The device I'm adding is a
reader. The reader is just a pipe between smart cards and the guest operating
system. The smart card logic does live outside of this device, and is available
in the cac_card sources at http://cgit.freedesktop.org/~alon/cac_card/ (all of
this is in docs/usb_ccid.txt).

So when I speak of vscclient, I'm talking of an application that emulates a 
smart
card and initiates a tcp connection to qemu that connects to the usb-ccid 
device.
vscclient is also in the cac_card sources.
   


Okay, let me be clear.  We shouldn't be doing device emulation outside 
of QEMU's source tree--at least, not in this type of context.  External 
devices present a great deal of challenges and we shouldn't just 
approach it in an ad-hoc fashion.


I'm not opposed to passthrough although I'd prefer QEMU to talk to the 
device directly instead of going through a daemon.


There's a lot of delicate integration between QEMU and a device and if a 
device lives outside of QEMU, it makes it extremely difficult for us to 
influence changes to that device to support QEMU new features.



Regarding the method of reconnection: You are absolutely right that if I have 
qemu
connect to the remote instead of the other way around then I remove the need to 
inform
vscclient of the new address. But the way it stands requires the client to know 
the
address of the destination qemu. I have to inform it somehow. You are saying 
that
devices shouldn't know this information? ok, that's why I talked about monitor 
commands.
I come from the world of spice - in spice we use monitor commands for this.


And none of that is upstream.

Regards,

Anthony Liguori


  I could
change this to have qemu connect to vscclient, but I don't see the logic in 
general -
sometimes you do want to have a chardev that is listening (the fact that it is 
implemented
suggests someone found it useful), if you then migrate you have the same 
problem I'm
solving.

   

Regards,

Anthony Liguori

 

Alon Levy (2):
usb-ccid: add CCID device. add configure option.
usb-ccid: add CCID device (device itself)

   Makefile.objs  |1 +
   configure  |   12 +
   docs/usb-ccid.txt  |  115 +
   hw/usb-ccid.c  | 1376
   


 

   hw/vscard_common.h |  131 +
   5 files changed, 1635 insertions(+), 0 deletions(-)
   create mode 100644 docs/usb-ccid.txt
   create mode 100644 hw/usb-ccid.c
   create mode 100644 hw/vscard_common.h


   





Re: [Qemu-devel] [RFT] qemu 0.13.0-rc3

2010-10-12 Thread Stefan Weil

Am 12.10.2010 00:15, schrieb Anthony Liguori:
After suffering from a prolonged maintainer softlockup, I'm attempting 
to get 0.13.0 release process back on track.


I've tagged qemu-0.13.0-rc3 in git which only carries a few changes 
since 0.13.0-rc1.  Most notably, a series of updates from Kevin Wolf 
and Cam Macdonell's ivshmem device.


I think we're pretty good testing wise for the final release but I 
wanted to offer a 24-hour window for last minute fixes.  I'm only 
interested in the following:


1) Patches that are *tested* against the stable-0.13 branch that are 
already committed in master.  Please tell me explicitly that you've 
tested the patch and how you've tested it.


2) Pull requests from other maintainers with cherry-picked patches 
against stable-0.13 that have been tested.


If you don't already have something ready, it's probably not worth 
worrying about.  We can follow with 0.13.1 in a relatively short 
period of time.


So please get any requests to me before 6PM US Central time October 12th.

Post 0.13.0, as part of the 0.14 planning, we can discuss how to avoid 
future delay with releases.


Thanks!

Regards,

Anthony Liguori




Michael's last PCI pull request ([PULL] eeepro100, virtio, net, vhost fixes)
was proposed for master and for 0.13, too.

I tested the patch 010ec6293409f10b88631c36145944b9c3277ce1
"eepro100: Add support for multiple individual addresses (multiple IA))"
and suggest to include it.

Regards,
Stefan Weil




[Qemu-devel] Re: Where's gpxe-eepro100-80862449.rom ?

2010-10-12 Thread Stefan Weil

Am 12.10.2010 14:41, schrieb Markus Armbruster:

Commit db667a12 added a reference to ROM file
gpxe-eepro100-80862449.rom, but no such file. Intentional?


Yes. See 
http://lists.nongnu.org/archive/html/qemu-devel/2010-05/msg00418.html


Citation from my former mail:

   Yes, it is missing. I did not add it for several reasons:

   * The new variant i82801 (which needs the missing ROM) is currently
   not available
   via model=i82801 (it can be selected by experts using other methods).

   * Experts can get the missing ROM from ROM-o-matic.

   * All three ROMs differ only in one or two bytes (device id). That's
   a waste
   of binary space (56832 bytes!). Therefore I plan to remove all but
   the first
   ROM file. The missing ones can be created by make or patched on the
   fly by
   QEMU during load. Maybe it is also possible to create ROM files
   which support
   more than one vendor/device entry - that would be the best solution.


There is still nothing new regarding these last points
because I did not spend any time on them.

Do you think there is urgent need for a gpxe-eepro100-80862449.rom binary?



  1   2   >