Skip to contentSkip to conversation

some help

Qemu-devel Ludovic Gele 14 participants 22 messages Jun 16, 2004 – Jun 21, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I am trying to use the network emulation with qemu 5.4 under debian sarge with a kernel 2.6.5-1-386, but I don't succeed. When I try to install an another debian with the netinst cd, the debian's installer won't detect the network card. I use the /etc/qemu-ifup script, and qemu don't give error about tun0.

Thanks

#1 lore raw

[Qemu-devel] Can't see network under qemu 0.5.5

I have this problem with using qemu 0.5.5 under windows 98.

I can ping the interface's own IP but can't see beyond that.

I have screen captures of my settings and other relevant system data at
http://www.lennyerwine.com/qemu-net.

If anyone can help me with this problem, I will be GLAD to transform the aforementioned web page into a help document. If I can get past this, I plan on doing this for Win2K, Linux as well.

Quoted 17 lines · Ludovic Gele

Hi,

I am trying to use the network emulation with qemu 5.4 under debian sarge with a kernel 2.6.5-1-386, but I don't succeed. When I try to install an another debian with the netinst cd, the debian's installer won't detect the network card. I use the /etc/qemu-ifup script, and qemu don't give error about tun0.

Thanks

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#6 lore raw

[Qemu-devel] Useful Q&A

In reply to Ludovic Gele

Hi all,

List of questions open to all - please answer any you can!

Where can I find a *Full* listing of all of the command line parameters for QEMU (i.e. includes "-cirrus")?
Will support for newer graphics cards be included any time soon?
Why doesn't (guest) Windows 98 (FE) recognise the emulated sound card as new hardware on my host Mandrake 10.0 machine when I specifiy "-enable-audio" - it doesn't think there is one at all? Any thoughts on binary builds for i586 and higher instead of default i386, are any processor specific optimizations likely to be made in future?

Benjamin

#7 lore raw

Re: [Qemu-devel] Useful Q&A

Quoted 1 line

Where can I find a *Full* listing of all of the command line parameters for QEMU (i.e. includes "-cirrus")?

I posted this a few days ago. Go to QEMU's source directory and run:

egrep "^ QEMU_OPTION_" vl.c

Quoted 1 line

Why doesn't (guest) Windows 98 (FE) recognise the emulated sound card as new hardware on my host Mandrake 10.0 machine when I specifiy "-enable-audio" - it doesn't think there is one at all?

If you're not using -pci, the sound card is not plug'n'play. Maybe the Windows hardware detection just fails to find it and you need to add it manually?

- Bartosz

#9 lore raw

Re: [Qemu-devel] Useful Q&A

In reply to Benjamin Brown
Quoted 5 lines · Benjamin Brown

Hi all,

List of questions open to all - please answer any you can!

Where can I find a *Full* listing of all of the command line parameters for QEMU (i.e. includes "-cirrus")?

All options of QEMU releases are documented. As the CVS version is not an official release, it contains test options that may be suppressed or modified without notice (in particular -pci and -cirrusvga). You can use the source code of the CVS version to have more information.

Quoted 1 line

Will support for newer graphics cards be included any time soon?

No.

Quoted 1 line

Why doesn't (guest) Windows 98 (FE) recognise the emulated sound card as new hardware on my host Mandrake 10.0 machine when I specifiy "-enable-audio" - it doesn't think there is one at all?

Did you try to relaunch the hardware probe in Windows ?

Quoted 1 line

Any thoughts on binary builds for i586 and higher instead of default i386, are any processor specific optimizations likely to be made in future?

No, except for translate-copy mode to use MMX/SSE/SSE2.

Fabrice.

#10 lore raw

Re: [Qemu-devel] Useful Q&A

Quoted 15 lines · Fabrice Bellard
Quoted 6 lines · Benjamin Brown

Hi all,

List of questions open to all - please answer any you can!

Where can I find a *Full* listing of all of the command line parameters for QEMU (i.e. includes "-cirrus")?

All options of QEMU releases are documented. As the CVS version is not an official release, it contains test options that may be suppressed or modified without notice (in particular -pci and -cirrusvga). You can use the source code of the CVS version to have more information.

Quoted 1 line

Will support for newer graphics cards be included any time soon?

Quoted 7 lines

No.

Quoted 3 lines

Why doesn't (guest) Windows 98 (FE) recognise the emulated sound card as new hardware on my host Mandrake 10.0 machine when I specifiy "-enable-audio" - it doesn't think there is one at all?

Did you try to relaunch the hardware probe in Windows ?

Windows 98 does not recognize emulated SB16, i have yet to isolate the problem. Then again i have successfully used Win2K's WDM drivers on Win98. Others(hetz) have been less lucky.

Quoted 7 lines
Quoted 3 lines

Any thoughts on binary builds for i586 and higher instead of default i386, are any processor specific optimizations likely to be made in future?

No, except for translate-copy mode to use MMX/SSE/SSE2.

Fabrice.

Signature · 1 line
mailto:[email protected]
#11 lore raw

Re: [Qemu-devel] Useful Q&A

In reply to Fabrice Bellard

Thanks for the info - few more questions tho:

Quoted 4 lines · Fabrice Bellard
Quoted 1 line

Will support for newer graphics cards be included any time soon?

No.

Is this sort of thing difficult (I've not written an emulator before)?

Quoted 5 lines
Quoted 2 lines

Why doesn't (guest) Windows 98 (FE) recognise the emulated sound card as new hardware on my host Mandrake 10.0 machine when I specifiy "-enable-audio" - it doesn't think there is one at all?

Did you try to relaunch the hardware probe in Windows ?

Yes, I'll look into it again. It may well be something with my setup as I also recently did a CVS build and still have the problem.

Quoted 5 lines
Quoted 2 lines

Any thoughts on binary builds for i586 and higher instead of default i386, are any processor specific optimizations likely to be made in future?

No, except for translate-copy mode to use MMX/SSE/SSE2.

To me the i386 support seems to be pointless - anybody who is seriously going to be running QEMU will be using a minimum of a i586 (K6-2, Pentium etc), granted QEMU it is not intended for just this processor platform - what is the justification for a 386 compatible version....? :)

Excellent software all round - wish I had the technical know how!

Benjamin

#2 lore raw

Re: [Qemu-devel] Can't see network under qemu 0.5.5

In reply to Leonard T. Erwine

Selon "Leonard T. Erwine" <[email protected]>:

Quoted 10 lines

I have this problem with using qemu 0.5.5 under windows 98.

I can ping the interface's own IP but can't see beyond that.

I have screen captures of my settings and other relevant system data at
http://www.lennyerwine.com/qemu-net.

If anyone can help me with this problem, I will be GLAD to transform the aforementioned web page into a help document. If I can get past this, I plan on doing this for Win2K, Linux as well.

Have you activate the ipforwarding on your host system? And the NAT?

#12 lore raw

Re: [Qemu-devel] Useful Q&A

In reply to Benjamin Brown

Hi,

Quoted 3 lines · Benjamin Brown
Quoted 2 lines
Quoted 1 line

Will support for newer graphics cards be included any time soon?

No.

Is this sort of thing difficult (I've not written an emulator before)?

Why on earth would you want to do that? It is an *emulated* graphics card. So any card which works should be fine. There is no point of maintaining two or more solutions to the same problem.

Quoted 4 lines

To me the i386 support seems to be pointless - anybody who is seriously going to be running QEMU will be using a minimum of a i586 (K6-2, Pentium etc), granted QEMU it is not intended for just this processor platform - what is the justification for a 386 compatible version....? :)

Well, there is more to it than just focusing on the newest, fastest, best processor there is.

First, why do you suppose at all, that the main use of QEMU is on INTEL platform? There are quite a few 386 compatible processors, and while not exactly being slow, they do not all support INTEL extensions.

Second, you need time to write the special support for all those extensions. Don't underestimate the effort!

Third, any day of the week I would rather fix things that don't work yet than fine tune some performance issues.

Fourth, I strongly doubt that supporting those extensions does have a high impact on performance: They are too special. They are mainly for large vector an matrix calculations, and last time I checked, a word processor does not really use many of those.

Quoted 1 line

Excellent software all round - wish I had the technical know how!

Use the source, Luke!

This is good for two reasons: You will learn a lot, especially how well-written code looks like. And you will be able to turn on debugging options, to understand what exactly happens, and to contribute back what you learnt as a means of saying "Thanks".

Ciao,
Dscho

#3 lore raw

Re: [Qemu-devel] Can't see network under qemu 0.5.5

In reply to Ludovic Gele

Here is the /etc/qemu-ifup I use to perform full network configuration:

-----------------------------------------------------
#!/bin/sh
#
# Inside the qemu VM, the following commands are required:
#

# ifconfig eth0 172.20.0.2
# route add default gw 172.20.0.1
#
intf=$1
eth0_ipaddr=$(ifconfig eth0 | awk '/inet addr:/ {print substr($2, 6)}')

sudo sh << EOT
/sbin/ifconfig $intf 172.20.0.1
/sbin/route add -host 172.20.0.2 $intf
/usr/sbin/iptables -t nat -F
/usr/sbin/iptables -t nat -A POSTROUTING -j SNAT -o eth0 --to $eth0_ipaddr echo 1 > /proc/sys/net/ipv4/ip_forward
EOT
---------------------------------------------------

Marc

Quoted 23 lines · Ludovic Gele

Selon "Leonard T. Erwine" <[email protected]>:

Quoted 11 lines

I have this problem with using qemu 0.5.5 under windows 98.

I can ping the interface's own IP but can't see beyond that.

I have screen captures of my settings and other relevant system data at
http://www.lennyerwine.com/qemu-net.

If anyone can help me with this problem, I will be GLAD to transform the aforementioned web page into a help document. If I can get past this, I plan on doing this for Win2K, Linux as well.

Have you activate the ipforwarding on your host system? And the NAT?

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#5 lore raw

Re: [Qemu-devel] Can't see network under qemu 0.5.5

In reply to Ludovic Gele

Yes I did enable IP forwarding. I did not set up any NAT. I did not think this was necessary to just get a connection to the host system. I was going to take care of IP forwarding and NAT once I positively established a connection.

Quoted 21 lines · Ludovic Gele

Selon "Leonard T. Erwine" <[email protected]>:

Quoted 10 lines

I have this problem with using qemu 0.5.5 under windows 98.

I can ping the interface's own IP but can't see beyond that.

I have screen captures of my settings and other relevant system data at
http://www.lennyerwine.com/qemu-net.

If anyone can help me with this problem, I will be GLAD to transform the aforementioned web page into a help document. If I can get past this, I plan on doing this for Win2K, Linux as well.

Have you activate the ipforwarding on your host system? And the NAT?

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#4 lore raw

Re: [Qemu-devel] Can't see network under qemu 0.5.5

In reply to Marc Vertes

I tried this, but still to no avail. Nothing gets in and nothing gets out of the qemu instance. Are you using Windows 98 for this?

Quoted 57 lines · Marc Vertes

Here is the /etc/qemu-ifup I use to perform full network configuration:

-----------------------------------------------------
#!/bin/sh
#
# Inside the qemu VM, the following commands are required:
#

# ifconfig eth0 172.20.0.2
# route add default gw 172.20.0.1
#
intf=$1
eth0_ipaddr=$(ifconfig eth0 | awk '/inet addr:/ {print substr($2, 6)}')

sudo sh << EOT
/sbin/ifconfig $intf 172.20.0.1
/sbin/route add -host 172.20.0.2 $intf
/usr/sbin/iptables -t nat -F
/usr/sbin/iptables -t nat -A POSTROUTING -j SNAT -o eth0 --to $eth0_ipaddr echo 1 > /proc/sys/net/ipv4/ip_forward
EOT
---------------------------------------------------

Marc

Quoted 14 lines · Ludovic Gele

Selon "Leonard T. Erwine" <[email protected]>:

Quoted 11 lines

I have this problem with using qemu 0.5.5 under windows 98.

I can ping the interface's own IP but can't see beyond that.

I have screen captures of my settings and other relevant system data at
http://www.lennyerwine.com/qemu-net.

If anyone can help me with this problem, I will be GLAD to transform the aforementioned web page into a help document. If I can get past this, I plan on doing this for Win2K, Linux as well.

Quoted 9 lines

Have you activate the ipforwarding on your host system? And the NAT?

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#14 lore raw

[Qemu-devel] Mounting a disk image under Linux

In reply to Benjamin Brown

I created a disk image under (host) Linux using dd and fdisked and formatted using a (guest)Windows 98 boot disk under QEMU. I then tried to mount this under linux to add files to it using:

mount -o loop /opt/qemu/tempImage /mnt/tempImage

This failed and asked me for the filesystem type so I specified:

mount -o loop -t vfat /opt/qemu/tempImage /mnt/tempImage

This also failed with the error:

mount: wrong fs type, bad option, bad superblock on /dev/loop1, or too many mounted file systems
(could this be the IDE device where you in fact use ide-scsi so that sr0 or sda or so is needed?)

Any ideas why this happens - this should just a straight fat formatted disk image?

#15 lore raw

Re: [Qemu-devel] Mounting a disk image under Linux

Yuo should mount it with offset (because of partition table). The right offset was posted several times to this list but I do not remember it. When you will find it you should add -o offset=xxxxx to mount command.

Grzegorz Kulewski

Quoted 19 lines · Benjamin Brown

I created a disk image under (host) Linux using dd and fdisked and formatted using a (guest)Windows 98 boot disk under QEMU. I then tried to mount this under linux to add files to it using:

mount -o loop /opt/qemu/tempImage /mnt/tempImage

This failed and asked me for the filesystem type so I specified:

mount -o loop -t vfat /opt/qemu/tempImage /mnt/tempImage

This also failed with the error:

mount: wrong fs type, bad option, bad superblock on /dev/loop1, or too many mounted file systems
(could this be the IDE device where you in fact use ide-scsi so that sr0 or sda or so is needed?)

Any ideas why this happens - this should just a straight fat formatted disk image?

#16 lore raw

Re: [Qemu-devel] Mounting a disk image under Linux

In reply to Benjamin Brown
Quoted 12 lines · Benjamin Brown

I created a disk image under (host) Linux using dd and fdisked and formatted using a (guest)Windows 98 boot disk under QEMU. I then tried to mount this under linux to add files to it using:

mount -o loop /opt/qemu/tempImage /mnt/tempImage

This failed and asked me for the filesystem type so I specified:

mount -o loop -t vfat /opt/qemu/tempImage /mnt/tempImage

This also failed with the error:

Quoted 7 lines

mount: wrong fs type, bad option, bad superblock on /dev/loop1, or too many mounted file systems
(could this be the IDE device where you in fact use ide-scsi so that sr0 or sda or so is needed?)

Any ideas why this happens - this should just a straight fat formatted disk image?

*bzzzt* it's partitioned ;)

You need to do losetup manually and specify an offset (expr 512 \* 63 usually).

Signature · 3 lines
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
#17 lore raw

Re: [Qemu-devel] Mounting a disk image under Linux

Thanks.

I did an sfdisk on the file and added -o loop,32256 to the mount command.
I know nothing of low level stuff so thats quite an achievement for me, I learn something new everyday ;)

Benjamin

Quoted 40 lines · Gianni Tedesco
Quoted 12 lines · Benjamin Brown

I created a disk image under (host) Linux using dd and fdisked and formatted using a (guest)Windows 98 boot disk under QEMU. I then tried to mount this under linux to add files to it using:

mount -o loop /opt/qemu/tempImage /mnt/tempImage

This failed and asked me for the filesystem type so I specified:

mount -o loop -t vfat /opt/qemu/tempImage /mnt/tempImage

This also failed with the error:

Quoted 9 lines

mount: wrong fs type, bad option, bad superblock on /dev/loop1, or too many mounted file systems
(could this be the IDE device where you in fact use ide-scsi so that sr0 or sda or so is needed?)

Any ideas why this happens - this should just a straight fat formatted disk image?

*bzzzt* it's partitioned ;)

You need to do losetup manually and specify an offset (expr 512 \* 63 usually).

------------------------------------------------------------------------

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#13 lore raw

Re: [Qemu-devel] Useful Q&A

In reply to Johannes Schindelin
Quoted 11 lines · Johannes Schindelin

Hi,

Quoted 6 lines · Benjamin Brown
Quoted 6 lines
Quoted 3 lines

Will support for newer graphics cards be included any time soon?

No.

Quoted 10 lines
Quoted 3 lines

Is this sort of thing difficult (I've not written an emulator before)?

Why on earth would you want to do that? It is an *emulated* graphics card. So any card which works should be fine. There is no point of maintaining two or more solutions to the same problem.

Perhaps to give it the edge over commercial solutions? I notice somebody recently mentioned open 3dfx specs were available. Don't get me wrong I'm all for the project plan of get everything working, then tune performance but asking the developers to at least consider the pros and cons of adding the support in the later stages of qemu dev (i.e. qemu 1.5-2?). I've some simple pros/cons here, pls add more. pro:
entices ppl from commercial products
will allow greater compat with direct 3d games (and effects)
con:
requires time
pos. v difficult

Quoted 7 lines
Quoted 6 lines

To me the i386 support seems to be pointless - anybody who is seriously going to be running QEMU will be using a minimum of a i586 (K6-2, Pentium etc), granted QEMU it is not intended for just this processor platform - what is the justification for a 386 compatible version....? :)

Quoted 5 lines

Well, there is more to it than just focusing on the newest, fastest, best processor there is.

Please elaborate on this point? I was suggesting upping the bar to i586, hardly cutting edge :)

Quoted 5 lines

First, why do you suppose at all, that the main use of QEMU is on INTEL platform? There are quite a few 386 compatible processors, and while not exactly being slow, they do not all support INTEL extensions.

I didn't in my day to day use I use Sparcs and ARM machines. I was suggesting extra compile support for i586 - that is when the more important issues have been rectified (i.e. bugs)

Quoted 4 lines

Second, you need time to write the special support for all those extensions. Don't underestimate the effort!

I realise its a lot of work but consider it to be of benefit in the later stages of the project especially as the projects main competitors are x86 based and currently have the perforamnce edge.

Quoted 5 lines

Third, any day of the week I would rather fix things that don't work yet than fine tune some performance issues.

Agreed. Bugs always come first.

Quoted 7 lines

Fourth, I strongly doubt that supporting those extensions does have a high impact on performance: They are too special. They are mainly for large vector an matrix calculations, and last time I checked, a word processor does not really use many of those.

They would be useful in software directx, multimedia and game usage...! :)

Quoted 8 lines
Quoted 3 lines

Excellent software all round - wish I had the technical know how!

Use the source, Luke!

I'm perusing it now when I need to see how certain things work, but as a beginner C programmer I'm fairly useless in this respect!

Quoted 5 lines

to contribute back what
you learnt as a means of saying "Thanks".

I'm considering a writing launcher, and time permitting figuring out how to grab the qemu display and fitting it into the launcher window.

Benjamin

#18 lore raw

Re: [Qemu-devel] Mounting a disk image under Linux

In reply to Benjamin Brown
Quoted 12 lines · Benjamin Brown

I created a disk image under (host) Linux using dd and fdisked and formatted using a (guest)Windows 98 boot disk under QEMU. I then tried to mount this under linux to add files to it using:

mount -o loop /opt/qemu/tempImage /mnt/tempImage

This failed and asked me for the filesystem type so I specified:

mount -o loop -t vfat /opt/qemu/tempImage /mnt/tempImage

This also failed with the error:

Quoted 9 lines

mount: wrong fs type, bad option, bad superblock on /dev/loop1, or too many mounted file systems
(could this be the IDE device where you in fact use ide-scsi so that sr0 or sda or so is needed?)

Any ideas why this happens - this should just a straight fat formatted disk image?

No its not. There is a partition table in it.

The quick and dirty way is to use this mount command:

mount -oloop,offset=sector_size*partition_start -t vfat /opt/qemu/tempImage /mnt/tempImage

sector_size is usually 512 and parition_start is usually 63. You can run

fdisk -lu /opt/qemu/tempImage

to be sure. I'm working on a wrapper called lomount that does this for you. Basicly you call it like this:

lomount -t vfat -diskimage /opt/qemu/tempImage -partition 1 /mnt/tempImage

It works great but has a bug if you try to mount a partition which doesnt exist.

Quoted 5 lines

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
#19 lore raw

Re: [Qemu-devel] Mounting a disk image under Linux

Quoted 4 lines · Jim C. Brown

lomount -t vfat -diskimage /opt/qemu/tempImage -partition 1 /mnt/tempImage

It works great but has a bug if you try to mount a partition which doesnt exist.

Sounds great. Perhaps it could be included with qemu, (at least in souce dist!)?

Do you want to post it on the list to fix it? Or have you just not had time?

Signature · 3 lines
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
#20 lore raw

Re: [Qemu-devel] Mounting a disk image under Linux

Quoted 8 lines · Gianni Tedesco
Quoted 4 lines · Jim C. Brown

lomount -t vfat -diskimage /opt/qemu/tempImage -partition 1 /mnt/tempImage

It works great but has a bug if you try to mount a partition which doesnt exist.

Sounds great. Perhaps it could be included with qemu, (at least in souce dist!)?

Sure. I have no problems with that.

Quoted 3 lines

Do you want to post it on the list to fix it? Or have you just not had time?

I wrote it in under an hour, right before I went to bed. I've attached the source code here but be warned: its very ugly. Very little error checking. Expects fdisk to work right (which in turns means it assumes fdisk is being passed a valid image with a valid parition table).

When I have some free time I'll try to clean it up. Right now it's full of ugly hacks. (It was originally meant to be a shell script not a C program, only my shell programming skills did not extend so far.)

Quoted 12 lines
Signature · 11 lines
-- 
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D



_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

#include <stdio.h>
#include <stdlib.h>

#define BUF 4096
#define TEMPFILE "/tmp/temp.minix"

int partnum(char * diskimage, FILE * temp, int * pnum)

{
	int num=0, c, i;
	char buf[BUF], buf2[BUF];
	strncpy(buf, diskimage, BUF);
	strncat(buf, "%d", BUF-strlen(buf));
	fscanf(temp, buf, pnum); /* skip start of line */
#ifdef DEBUG
	printf("pnum = %d\n", *pnum);
#endif
	c = fgetc(temp);
	while (c == ' ' || c == '*' || c == '@')
	{
		c = fgetc(temp);
#ifdef DEBUG
		printf("c = %d ", c);
#endif
	}
	/*ungetc(c, temp);
	fscanf(temp, "%d", &num);*/
#ifdef DEBUG
	printf("c = %d\n", c);
#endif
	buf2[0] = c;
	c = fgetc(temp);
	i = 1;
	while (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
	{
		buf2[i] = c;
		c = fgetc(temp);
		i++;
	}
	buf2[i] = '\0';
	num = atoi(buf2);
#ifdef DEBUG
	printf("buf2 = %s num = %d\n", buf2, num);
#endif
	fgets(buf, BUF, temp); /* skip rest of line */
	return num;
}

int main(int argc, char ** argv)

{
	FILE * temp;
	char buf[BUF], argv2[BUF], diskimage[BUF];
	int partition = 1, sec1, sec2, num = 0, pnum = 0, len = BUF, i, f = 0;
	for (i = 1; i < argc; i ++)
	{
		if (strncmp(argv[i], "-diskimage", BUF)==0)
		{
			strncpy(diskimage, argv[i+1], BUF);
			i++; f = 1;
		}
		else if (strncmp(argv[i], "-partition", BUF)==0)
		{
			partition = atoi(argv[i+1]);
			i++;
			if (partition < 1) partition = 1;
		}
		else
		{
			strncat(argv2, argv[i], len);
			strncat(argv2, " ", len-1);
			len -= strlen(argv[i]);
			len--;
		}
	}
	if (!f)
	{
		printf("You must specify -diskimage and -partition\n");
		printf("ex. lomount -t fs-type -diskimage hda.img -partition 1 /mnt\n");
		return 0;
	}
	snprintf(buf, BUF, "fdisk -lu %s > %s 2>&1", diskimage, TEMPFILE);
	system(buf);
	temp = fopen(TEMPFILE, "r");
	fgets(buf, BUF, temp); /* skip first line */
#ifdef DEBUG
	printf("spare line: %s\n", buf);
#endif
	fgets(buf, BUF, temp); /* skip second line */
#ifdef DEBUG
	printf("spare line: %s\n", buf);
#endif
	fgets(buf, BUF, temp); /* skip third line */
#ifdef DEBUG
	printf("spare line: %s\n", buf);
#endif
	fgets(buf, BUF, temp); /* skip fourth line */
#ifdef DEBUG
	printf("spare line: %s\n", buf);
#endif
	fscanf(temp, "Units = sectors of %d * %d bytes\n", &sec1, &sec2);
#ifdef DEBUG
	printf("sec1: %d sec2: %d\n", sec1, sec2);
#endif
	fgets(buf, BUF, temp); /* skip sixth line */
#ifdef DEBUG
	printf("spare line: %s\n", buf);
#endif
	while (pnum != partition)
	{
		num = partnum(diskimage, temp, &pnum);
	}
	fclose(temp);
	pnum = sec1 * sec2 * num;
#ifdef DEBUG
	printf("offset = %d\n", pnum);
#endif
	snprintf(buf, BUF, "echo mount -oloop,offset=%d %s %s", pnum, diskimage, argv2);
	return system(buf);
}
#21 lore raw

Re: Re: [Qemu-devel] Mounting a disk image under Linux

Hello all

I take Jim's program and add some checking of fdisk output. Basically, it just skip the output :

"You must set cylinders.
You can do this from the extra functions menu"

I got this message when run fdisk -lu, so I skip them until I get following lines:
"Disk /mnt/qemu/myimage: 0 MB, 0 bytes"

And the rest of the program is pretty similar

regards

Mulyadi

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#define BUF 4096
#define TEMPFILE "/tmp/temp.minix"

int partnum(char * diskimage, FILE * temp, int * pnum)

{
	int num=0, c, i;
	char buf[BUF], buf2[BUF];
	strncpy(buf, diskimage, BUF);
	strncat(buf, "%d", BUF-strlen(buf));
	fscanf(temp, buf, pnum); /* skip start of line */
#ifdef DEBUG
	printf("pnum = %d\n", *pnum);
#endif
	c = fgetc(temp);
	while (c == ' ' || c == '*' || c == '@')
	{
		c = fgetc(temp);
#ifdef DEBUG
		printf("c = %d ", c);
#endif
	}
	/*ungetc(c, temp);
	fscanf(temp, "%d", &num);*/
#ifdef DEBUG
	printf("c = %d\n", c);
#endif
	buf2[0] = c;
	c = fgetc(temp);
	i = 1;
	while (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
	{
		buf2[i] = c;
		c = fgetc(temp);
		i++;
	}
	buf2[i] = '\0';
	num = atoi(buf2);
#ifdef DEBUG
	printf("buf2 = %s num = %d\n", buf2, num);
#endif
	fgets(buf, BUF, temp); /* skip rest of line */
	return num;
}

int main(int argc, char ** argv)

{
	FILE * temp;
	char buf[BUF], argv2[BUF], diskimage[BUF];
	int partition = 1, sec1, sec2, num = 0, pnum = 0, len = BUF, i, f = 0;
	int total_sec;
	int pressed_key=0;
	for (i = 1; i < argc; i ++)
	{
		if (strncmp(argv[i], "-diskimage", BUF)==0)
		{
			strncpy(diskimage, argv[i+1], BUF);
			i++; f = 1;
		}
		else if (strncmp(argv[i], "-partition", BUF)==0)
		{
			partition = atoi(argv[i+1]);
			i++;
			if (partition < 1) partition = 1;
		}
		else
		{
			strncat(argv2, argv[i], len);
			strncat(argv2, " ", len-1);
			len -= strlen(argv[i]);
			len--;
		}
	}
	if (!f)
	{
		printf("You must specify -diskimage and -partition\n");
		printf("ex. lomount -t fs-type -diskimage hda.img -partition 1 /mnt\n");
		return 0;
	}
	snprintf(buf, BUF, "/sbin/fdisk -lu %s > %s 2>&1", diskimage, TEMPFILE);
	system(buf);
	temp = fopen(TEMPFILE, "r");

	do
	{
	    fgets(buf, BUF, temp); /* skip until we get "Disk" */
		
	} while (strncasecmp(buf, "Disk", 4)!=0);
	fgets(buf, BUF, temp); //skip once more
	fscanf(temp, "Units = sectors of %d * %d = %d bytes\n", &sec1, &sec2, &total_sec);
#ifdef DEBUG
	printf("sec1: %d sec2: %d\n", sec1, sec2);
#endif
	fgets(buf, BUF, temp); /* skip sixth line */
#ifdef DEBUG
	printf("spare line: %s\n", buf);
#endif
	while (pnum != partition)
	{
		num = partnum(diskimage, temp, &pnum);
	}
	fclose(temp);
	pnum = sec1 * sec2 * num;
#ifdef DEBUG
	printf("offset = %d\n", pnum);
#endif
	snprintf(buf, BUF, "mount -oloop,offset=%d %s %s", pnum, diskimage, argv2);
		
	printf("Do you want to execute mount command? [Y/n] ");
	pressed_key=getchar();
	
	/* if user press Enter (that means YES), or 'y' or 'Y'
	then execute the  command
	 */
	if ( (pressed_key==10) || (pressed_key==89) || (pressed_key==121) )
	{
	    system(buf);
	}
	return 0;
}
#8 lore raw

Re: [Qemu-devel] Useful Q&A

In reply to Bartosz Fabianowski
Quoted 7 lines · Bartosz Fabianowski
Quoted 2 lines

Where can I find a *Full* listing of all of the command line parameters for QEMU (i.e. includes "-cirrus")?

I posted this a few days ago. Go to QEMU's source directory and run:

egrep "^ QEMU_OPTION_" vl.c

Quoted 7 lines
Quoted 3 lines

Why doesn't (guest) Windows 98 (FE) recognise the emulated sound card as new hardware on my host Mandrake 10.0 machine when I specifiy "-enable-audio" - it doesn't think there is one at all?

If you're not using -pci, the sound card is not plug'n'play. Maybe the Windows hardware detection just fails to find it and you need to add it manually?

Using my PnP patch, it shouldn't be hard to make it "Plug and Play" compatible...