qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel][PATCH]Get machine name from name of executable
@ 2006-05-14 10:42 Stefan Weil
  2006-05-14 11:34 ` Thiemo Seufer
  2006-05-14 11:48 ` Fabrice Bellard
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Weil @ 2006-05-14 10:42 UTC (permalink / raw)
  To: qemu-devel

Today, QEMU allows machine selection using command line option -M.
Without this option, it will always take the first machine
for the given target architecture.

With my patch, QEMU first parses the name of the executable.
The string after the last '-' is interpreted as machine name.
If this machine does not exist, the first machine is taken,
so the new QEMU remains compatible with the old behaviour.

With this patch, an installation might link e.g. qemu-system-arm
to qemu-system-arm-integratorcp926, and running 
qemu-system-arm-integratorcp926
will automatically select machine integratorcp926.

My goal is a MIPS emulation which supports big and little endian mode
in the same executable (like the real hardware). qemu-system-mipsel
would be a symbolic link to qemu-system-mips and enable little endian mode.

I propose another code modification: instead of registration of all machines
in vl.c, vl.c might call a target procedure which does this registration.
So if MIPS, ARM or other targets add machines, vl.c would not change.
Example: vl.c calls qemu_register_mips_machines() which calls
qemu_register_machine(&mips_machine).

Regards,
Stefan


--- vl.c    3 May 2006 22:02:44 -0000    1.185
+++ vl.c    12 May 2006 20:19:15 -0000
@@ -4252,7 +4254,7 @@
     return 0;
 }
 
-QEMUMachine *find_machine(const char *name)
+static QEMUMachine *find_machine(const char *name)
 {
     QEMUMachine *m;
 
@@ -5075,7 +5077,14 @@
     mallopt(M_MMAP_THRESHOLD, 4096 * 1024);
 #endif
     register_machines();
+    machine = 0;
+    optarg = strrchr(argv[0], '-');
+    if (optarg != 0) {
+        machine = find_machine(optarg + 1);
+    }
+    if (!machine) {
     machine = first_machine;
+    }
     initrd_filename = NULL;
     for(i = 0; i < MAX_FD; i++)
         fd_filename[i] = NULL;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel][PATCH]Get machine name from name of executable
  2006-05-14 10:42 [Qemu-devel][PATCH]Get machine name from name of executable Stefan Weil
@ 2006-05-14 11:34 ` Thiemo Seufer
  2006-05-14 11:48 ` Fabrice Bellard
  1 sibling, 0 replies; 5+ messages in thread
From: Thiemo Seufer @ 2006-05-14 11:34 UTC (permalink / raw)
  To: qemu-devel

Stefan Weil wrote:
> Today, QEMU allows machine selection using command line option -M.
> Without this option, it will always take the first machine
> for the given target architecture.
> 
> With my patch, QEMU first parses the name of the executable.
> The string after the last '-' is interpreted as machine name.
> If this machine does not exist, the first machine is taken,
> so the new QEMU remains compatible with the old behaviour.
> 
> With this patch, an installation might link e.g. qemu-system-arm
> to qemu-system-arm-integratorcp926, and running 
> qemu-system-arm-integratorcp926
> will automatically select machine integratorcp926.
> 
> My goal is a MIPS emulation which supports big and little endian mode
> in the same executable (like the real hardware). qemu-system-mipsel
> would be a symbolic link to qemu-system-mips and enable little endian mode.

A similiar approach was abandoned years ago in the case of GNU
ls/dir/vdir due to continuous trouble on non-posix systems, and the
potential of unexpected results with this aproach. (E.g. what happens
if somebody adds a symlink qemu-default -> qemu-system-mipsel).


Thiemo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel][PATCH]Get machine name from name of executable
  2006-05-14 10:42 [Qemu-devel][PATCH]Get machine name from name of executable Stefan Weil
  2006-05-14 11:34 ` Thiemo Seufer
@ 2006-05-14 11:48 ` Fabrice Bellard
  2006-05-14 13:30   ` Stefan Weil
  1 sibling, 1 reply; 5+ messages in thread
From: Fabrice Bellard @ 2006-05-14 11:48 UTC (permalink / raw)
  To: weil; +Cc: qemu-devel

Hi,

The long term plan for qemu is to have a single executable for all 
machines. If you make a single executable for mips and mipsel, it is 
better to select the endianness in the code of the machine itself when 
initializing the CPU.

Regards,

Fabrice.


Stefan Weil wrote:
> Today, QEMU allows machine selection using command line option -M.
> Without this option, it will always take the first machine
> for the given target architecture.
> 
> With my patch, QEMU first parses the name of the executable.
> The string after the last '-' is interpreted as machine name.
> If this machine does not exist, the first machine is taken,
> so the new QEMU remains compatible with the old behaviour.
> 
> With this patch, an installation might link e.g. qemu-system-arm
> to qemu-system-arm-integratorcp926, and running 
> qemu-system-arm-integratorcp926
> will automatically select machine integratorcp926.
> 
> My goal is a MIPS emulation which supports big and little endian mode
> in the same executable (like the real hardware). qemu-system-mipsel
> would be a symbolic link to qemu-system-mips and enable little endian mode.
> 
> I propose another code modification: instead of registration of all 
> machines
> in vl.c, vl.c might call a target procedure which does this registration.
> So if MIPS, ARM or other targets add machines, vl.c would not change.
> Example: vl.c calls qemu_register_mips_machines() which calls
> qemu_register_machine(&mips_machine).
> 
> Regards,
> Stefan
> 
> 
> --- vl.c    3 May 2006 22:02:44 -0000    1.185
> +++ vl.c    12 May 2006 20:19:15 -0000
> @@ -4252,7 +4254,7 @@
>     return 0;
> }
> 
> -QEMUMachine *find_machine(const char *name)
> +static QEMUMachine *find_machine(const char *name)
> {
>     QEMUMachine *m;
> 
> @@ -5075,7 +5077,14 @@
>     mallopt(M_MMAP_THRESHOLD, 4096 * 1024);
> #endif
>     register_machines();
> +    machine = 0;
> +    optarg = strrchr(argv[0], '-');
> +    if (optarg != 0) {
> +        machine = find_machine(optarg + 1);
> +    }
> +    if (!machine) {
>     machine = first_machine;
> +    }
>     initrd_filename = NULL;
>     for(i = 0; i < MAX_FD; i++)
>         fd_filename[i] = NULL;
> 
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel][PATCH]Get machine name from name of executable
  2006-05-14 11:48 ` Fabrice Bellard
@ 2006-05-14 13:30   ` Stefan Weil
  2006-05-14 18:03     ` Fabrice Bellard
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Weil @ 2006-05-14 13:30 UTC (permalink / raw)
  To: qemu-devel

Hi,

ok, I think this plan is a good one. It might even be possible to run 
several different machines by
starting a single QEMU emulation process. But you need some mechanism to 
tell QEMU which machine(s) to run.
Of course, you could add new command line options. MIPS, for example, 
could select endianness
automatically in user mode (from ELF format), but not in system mode 
when running a complete system
with a firmware loader. So you need some way to tell QEMU that this is a 
MIPS CPU with a certain kind
of endianness (the real CPU has a hardware input pin for this, we need 
something which replaces this
hardware input pin).

Did you think about using configuration files (XML, YAML, or any other 
format) with machine descriptions
(CPU, CPU variant, endianness, network hardware, serial ports, other 
hardware features which are
compiled into the code or configured via command line options today)?

Regards
Stefan

Fabrice Bellard schrieb:

> Hi,
>
> The long term plan for qemu is to have a single executable for all 
> machines. If you make a single executable for mips and mipsel, it is 
> better to select the endianness in the code of the machine itself when 
> initializing the CPU.
>
> Regards,
>
> Fabrice.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel][PATCH]Get machine name from name of executable
  2006-05-14 13:30   ` Stefan Weil
@ 2006-05-14 18:03     ` Fabrice Bellard
  0 siblings, 0 replies; 5+ messages in thread
From: Fabrice Bellard @ 2006-05-14 18:03 UTC (permalink / raw)
  To: qemu-devel

I don't understand your problem : the '-M' option is used to select the 
machine. Your "ar7" machine must be added as a new machine. The 
endianness must be selected inside the machine code. If the machine can 
be launched with the two endiannesses, then you can just add two 
machines names.

Fabrice.

Stefan Weil wrote:
> Hi,
> 
> ok, I think this plan is a good one. It might even be possible to run 
> several different machines by
> starting a single QEMU emulation process. But you need some mechanism to 
> tell QEMU which machine(s) to run.
> Of course, you could add new command line options. MIPS, for example, 
> could select endianness
> automatically in user mode (from ELF format), but not in system mode 
> when running a complete system
> with a firmware loader. So you need some way to tell QEMU that this is a 
> MIPS CPU with a certain kind
> of endianness (the real CPU has a hardware input pin for this, we need 
> something which replaces this
> hardware input pin).
> 
> Did you think about using configuration files (XML, YAML, or any other 
> format) with machine descriptions
> (CPU, CPU variant, endianness, network hardware, serial ports, other 
> hardware features which are
> compiled into the code or configured via command line options today)?
> 
> Regards
> Stefan
> 
> Fabrice Bellard schrieb:
> 
>> Hi,
>>
>> The long term plan for qemu is to have a single executable for all 
>> machines. If you make a single executable for mips and mipsel, it is 
>> better to select the endianness in the code of the machine itself when 
>> initializing the CPU.
>>
>> Regards,
>>
>> Fabrice.
> 
> 
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-14 18:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-14 10:42 [Qemu-devel][PATCH]Get machine name from name of executable Stefan Weil
2006-05-14 11:34 ` Thiemo Seufer
2006-05-14 11:48 ` Fabrice Bellard
2006-05-14 13:30   ` Stefan Weil
2006-05-14 18:03     ` Fabrice Bellard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).