* [Qemu-devel] [PATCH] FW_CFG_EMULATOR
@ 2009-08-03 15:05 Jes Sorensen
2009-08-05 10:59 ` Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Jes Sorensen @ 2009-08-03 15:05 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Kevin O'Connor, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 393 bytes --]
Hi,
Here's a patch for QEMU which tells the BIOS it is running on
QEMU/KQEMU/KVM.
I have a set if patches for Seabios using this to runtime select KVM
and QEMU settings, eliminating the need for a specially compiled BIOS
binary.
If we can agree on the interface, I would look into doing something
similar for BOCHS as well.
I will be posting the Seabios patches in a minute.
Cheers,
Jes
[-- Attachment #2: 0003-qemu-cfg-emu-runtime.patch --]
[-- Type: text/x-patch, Size: 3603 bytes --]
Provide FW_CFG_EMULATOR info to the BIOS
This option provides info to the BIOS informing it which emulator it
is running on top of.
The emulator version is designed as a master rev, for the upper 8
bits, and a minor version for the lower 8 bits. This allows one to
specify QEMU_KVM vs QEMU_KQEMU for example. It should leave space for
other emulators to register themselves too.
If the BIOS' probe for FW_CFG fails, it is expected it sets it's
emulator version to the same as CFG_EMU_NONE.
I have a set of patches for Seabios using this to determine it is
running on top of QEMU and KVM. This allows setting certain KVM
specific bits, and also determining at runtime that Seabios is running
on top of QEMU, eliminating the #define CONFIG_KVM.
Signed-off-by: Jes Sorensen
---
hw/fw_cfg.c | 3 +++
hw/fw_cfg.h | 11 ++++++++++-
vl.c | 6 ++++++
3 files changed, 19 insertions(+), 1 deletion(-)
Index: qemu/hw/fw_cfg.c
===================================================================
--- qemu.orig/hw/fw_cfg.c
+++ qemu/hw/fw_cfg.c
@@ -38,6 +38,8 @@
#define FW_CFG_SIZE 2
+extern uint16_t emu_type;
+
typedef struct _FWCfgEntry {
uint16_t len;
uint8_t *data;
@@ -281,6 +283,7 @@ void *fw_cfg_init(uint32_t ctl_port, uin
fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
+ fw_cfg_add_i16(s, FW_CFG_EMULATOR, emu_type);
register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s);
qemu_register_reset(fw_cfg_reset, s);
Index: qemu/hw/fw_cfg.h
===================================================================
--- qemu.orig/hw/fw_cfg.h
+++ qemu/hw/fw_cfg.h
@@ -17,7 +17,8 @@
#define FW_CFG_NUMA 0x0d
#define FW_CFG_BOOT_MENU 0x0e
#define FW_CFG_MAX_CPUS 0x0f
-#define FW_CFG_MAX_ENTRY 0x10
+#define FW_CFG_EMULATOR 0x10
+#define FW_CFG_MAX_ENTRY 0x11
#define FW_CFG_WRITE_CHANNEL 0x4000
#define FW_CFG_ARCH_LOCAL 0x8000
@@ -25,6 +26,14 @@
#define FW_CFG_INVALID 0xffff
+/*
+ * Values for FW_CFG_EMULATOR
+ */
+#define CFG_EMU_NONE 0x0000
+#define CFG_EMU_QEMU 0x0100
+#define CFG_EMU_QEMU_KVM 0x0101
+#define CFG_EMU_QEMU_KQEMU 0x0102
+
#ifndef NO_QEMU_PROTOS
typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -142,6 +142,7 @@ int main(int argc, char **argv)
#include "hw/smbios.h"
#include "hw/xen.h"
#include "hw/qdev.h"
+#include "hw/fw_cfg.h"
#include "bt-host.h"
#include "net.h"
#include "monitor.h"
@@ -270,6 +271,8 @@ uint8_t qemu_uuid[16];
static QEMUBootSetHandler *boot_set_handler;
static void *boot_set_opaque;
+uint16_t emu_type = CFG_EMU_QEMU;
+
/***********************************************************/
/* x86 ISA bus support */
@@ -5426,14 +5429,17 @@ int main(int argc, char **argv, char **e
#ifdef CONFIG_KQEMU
case QEMU_OPTION_enable_kqemu:
kqemu_allowed = 1;
+ emu_type = CFG_EMU_QEMU_KQEMU;
break;
case QEMU_OPTION_kernel_kqemu:
kqemu_allowed = 2;
+ emu_type = CFG_EMU_QEMU_KQEMU;
break;
#endif
#ifdef CONFIG_KVM
case QEMU_OPTION_enable_kvm:
kvm_allowed = 1;
+ emu_type = CFG_EMU_QEMU_KVM;
#ifdef CONFIG_KQEMU
kqemu_allowed = 0;
#endif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] FW_CFG_EMULATOR
2009-08-03 15:05 [Qemu-devel] [PATCH] FW_CFG_EMULATOR Jes Sorensen
@ 2009-08-05 10:59 ` Avi Kivity
2009-08-05 12:26 ` Jes Sorensen
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2009-08-05 10:59 UTC (permalink / raw)
To: Jes Sorensen; +Cc: Anthony Liguori, Kevin O'Connor, qemu-devel
On 08/03/2009 06:05 PM, Jes Sorensen wrote:
> Hi,
>
> Here's a patch for QEMU which tells the BIOS it is running on
> QEMU/KQEMU/KVM.
>
> I have a set if patches for Seabios using this to runtime select KVM
> and QEMU settings, eliminating the need for a specially compiled BIOS
> binary.
>
> If we can agree on the interface, I would look into doing something
> similar for BOCHS as well.
>
> I will be posting the Seabios patches in a minute.
The guest never runs on kvm or kqemu. It always runs on qemu, which may
use kvm or kqemu for cpu virtualization.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] FW_CFG_EMULATOR
2009-08-05 10:59 ` Avi Kivity
@ 2009-08-05 12:26 ` Jes Sorensen
0 siblings, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2009-08-05 12:26 UTC (permalink / raw)
To: Avi Kivity; +Cc: Anthony Liguori, Kevin O'Connor, qemu-devel
On 08/05/2009 12:59 PM, Avi Kivity wrote:
> The guest never runs on kvm or kqemu. It always runs on qemu, which may
> use kvm or kqemu for cpu virtualization.
>
That is exactly why I designed it to have QEMU as the master emu version
and then KVM/KQEMU etc. as the minor version.
However given our conversation yesterday, I am going to respin it as
fw cfg features instead of the blank 'you are running on KVM' thing.
Cheers,
Jes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-05 12:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-03 15:05 [Qemu-devel] [PATCH] FW_CFG_EMULATOR Jes Sorensen
2009-08-05 10:59 ` Avi Kivity
2009-08-05 12:26 ` Jes Sorensen
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).