Cc: qemu-devel On Fri, Nov 4, 2011 at 22:37, Zhi Yong Wu <zwu.ker...@gmail.com> wrote: > On Sat, Nov 5, 2011 at 12:11 AM, Jordan Justen <jljus...@gmail.com> wrote: >> On Fri, Nov 4, 2011 at 04:34, Zhi Yong Wu <zwu.ker...@gmail.com> wrote: >>> BTW: what is the relationship between -bios and -pflash? >> >> Previously the QEMU/KVM PC system had no pflash support. You could >> specify a pflash drive, but it would not appear in the VM. >> >> Also, previously the -bios flag would cause the specified binary to be >> loaded by QEMU, and then it was put into a memory region to be used >> for the firmware. >> >> After this change, the pflash drive is used for firmware. So, it > This pflash drive is created with -pflash option, right?
-pflash can be used, but I think it is just a short cut. -pflash /path/to/file is similar to: -drive if=pflash,file=/path/to/file And, after this change, -bios /path/to/file is similar to: -drive if=pflash,file=/path/to/file,readonly=on >> should be able to support qcow2, since qemu drives support the >> different formats. I confirmed that you can use a qcow2 image with -bios after this change. >> For backward compatibility, this change makes the -bios parameter be >> another way to specify the pflash drive. If -bios is used, then a >> read-only pflash drive is created. > Sorry, i don't fully understand this. How about -bios and -pflash are > both specified. In this case the -pflash will be used, and -bios will be ignored. I use -bios to create a pflash drive only if no pflash drive exists already. I think this should be okay, since -pflash has no use in the QEMU PC system before this patch, so it is unlikely that both -pflash and -bios will be used previously. >>> If your patch is applied to my source tree, can you know how to use -pflash? > Sorry, i made a mistake. I wanted to ask you how to use -pflash if > your patch is not applied. I don't think you can use pflash in a PC system when my patch is not applied. I think without the patch qemu will create the pflash drive internally, but it will not be hooked to a device that the emulated PC system can see. I attached a log of me interacting with the pflash device under the EFI shell on OVMF *with* the patch applied. Thanks, -Jordan
Notes below refer to quoted item just above. > Device mapping table > blk0 :Floppy - Alias (null) > PciRoot(0x0)/Pci(0x1,0x0)/Floppy(0x0) > blk1 :Floppy - Alias (null) > PciRoot(0x0)/Pci(0x1,0x0)/Floppy(0x1) > blk2 :BlockDevice - Alias (null) > PciRoot(0x0)/Pci(0x1,0x1)/Ata(Secondary,Master,0x0) > > > Press ESC in 5 seconds to skip startup.nsh, any other key to continue. > Press ESC in 4 seconds to skip startup.nsh, any other key to continue. EFI shell started > Shell> mem fffe0 32 > Memory Address 00000000000FFFE0 20 Bytes > 000FFFE0: EB C3 90 90 90 90 90 90-00 00 00 00 56 54 46 00 > *............VTF.* > 000FFFF0: 90 90 EB AC 90 90 90 90-90 90 90 90 90 90 90 90 > *................* Dump firmware range in legacy F000 segment > Shell> mem ffffffe0 32 > Memory Address 00000000FFFFFFE0 20 Bytes > FFFFFFE0: EB C3 90 90 90 90 90 90-00 00 00 00 56 54 46 00 > *............VTF.* > FFFFFFF0: 90 90 EB AC 90 90 90 90-90 90 90 90 90 90 90 90 > *................* Dump firmware range at top of 4GB. > Shell> mem fff00000 32 > Memory Address 00000000FFF00000 20 Bytes > FFF00000: 01 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 > *................* > FFF00010: 78 E5 8C 8C 3D 8A 1C 4F-99 35 89 61 85 C3 2D D3 > *x...=..O.5.a..-.* Dump start of OVMF flash image. The first 16 bytes are reserved, and therefore we can program them without a negative side effect. Notice I have previously programmed the first byte from 00 to 01. > Shell> mm -mmio -w 1 -n fff00000 > MMIO 0x00000000FFF00000 : 0x01 Read the data in the first byte of the rom. > Shell> mm -mmio -w 1 -n fff00000 70 Request to read the pflash_cfi01 status register. (0x70 is the command written to address 0xfff00000.) > Shell> mm -mmio -w 1 -n fff00000 > MMIO 0x00000000FFF00000 : 0x00 Read the status register by reading address 0xfff00000. > Shell> mm -mmio -w 1 -n fff00000 ff Put the pflash_cfi01 back into read-data mode. (0xff is the command for putting the flash into read mode.) > Shell> mm -mmio -w 1 -n fff00000 > MMIO 0x00000000FFF00000 : 0x01 Notice we read the proper data again... 0x01. > Shell> mm -mmio -w 1 -n fff00001 > MMIO 0x00000000FFF00001 : 0x00 Now read the data at 0xfff00001. It is 0x00. > Shell> mm -mmio -w 1 -n fff00001 10 Put the pflash_cfi01 into programming mode. > Shell> mm -mmio -w 1 -n fff00001 ab Program the data at 0xfff00001. Data is 0xab. > Shell> mm -mmio -w 1 -n fff00001 ff Put the pflash_cfi01 back into read-data mode. > Shell> mm -mmio -w 1 -n fff00001 > MMIO 0x00000000FFF00001 : 0xAB 0xab was programmed into 0xfff00001. > Shell> mm -mmio -w 1 -n fff00001 70 Request to read the status register. > Shell> mm -mmio -w 1 -n fff00001 > MMIO 0x00000000FFF00001 : 0x80 bit7 (0x80) indicates device is ready. > Shell> mm -mmio -w 1 -n fff00001 ff Back to read-data mode again. > Shell> mm -mmio -w 1 -n fff00001 > MMIO 0x00000000FFF00001 : 0xAB The proper data is still returned. > Shell> reset -s Shutdown the system...