Skip to contentSkip to conversation

option rom loading overhaul.

PATCH In review Gerd Hoffmann 15 participants 84 messages Dec 18, 2009 – Jan 12, 2010

lore
Share & tools
lore
#0 lore raw

cover option rom loading overhaul.

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Seabios patches will be posted shortly as separate patch series.

cheers,
Gerd

#1 lore raw

PATCH 1/8 Support PCI based option rom loading

From: Anthony Liguori <[email protected]>

Currently, we preload option roms into the option rom space in memory. This prevents DDIM from functioning correctly which severely limits the number of roms we can support.

This patch introduces a pci_add_option_rom() which registers the PCI_ROM_ADDRESS bar which points to our option rom. It also converts over the cirrus vga adapter, the rtl8139, virtio, and the e1000 to use this new mechanism.

The result is that PXE boot functions even with three unique types of cards.

---
 hw/cirrus_vga.c |    2 +-
 hw/e1000.c      |    2 +-
 hw/pci.c        |   35 +++++++++++++++++++++++++++++++++++
 hw/pci.h        |    5 +++++
 hw/rtl8139.c    |    2 +-
 hw/virtio-pci.c |    2 +-
 6 files changed, 44 insertions(+), 4 deletions(-)
hw/cirrus_vga.c +1 -1
index 24af81c..b08d2ae 100644
@@ -3211,7 +3211,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
      }
 
      /* ROM BIOS */
-     rom_add_vga(VGABIOS_CIRRUS_FILENAME);
+     pci_add_option_rom((PCIDevice *)d, VGABIOS_CIRRUS_FILENAME);
      return 0;
 }
 
hw/e1000.c +1 -1
index 8566fe3..f795601 100644
@@ -1125,7 +1125,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)
     if (!pci_dev->qdev.hotplugged) {
         static int loaded = 0;
         if (!loaded) {
-            rom_add_option("pxe-e1000.bin");
+            pci_add_option_rom(&d->dev, "pxe-e1000.bin");
             loaded = 1;
         }
     }
hw/pci.c +35 -0
index 404eead..dbdfdbf 100644
@@ -26,6 +26,7 @@
 #include "monitor.h"
 #include "net.h"
 #include "sysemu.h"
+#include "loader.h"
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
@@ -1463,6 +1464,40 @@ static uint8_t pci_find_capability_list(PCIDevice *pdev, uint8_t cap_id,
     return next;
 }
 
+static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, pcibus_t size, int type)
+{
+    cpu_register_physical_memory(addr, size, pdev->rom_offset);
+}
+
+/* Add an option rom for the device */
+int pci_add_option_rom(PCIDevice *pdev, const char *name)
+{
+    int size;
+    char *path;
+    void *ptr;
+
+    path = qemu_find_file(QEMU_FILE_TYPE_BIOS, name);
+    if (path == NULL) {
+        path = qemu_strdup(name);
+    }
+
+    size = get_image_size(path);
+    if (size & (size - 1)) {
+        size = 1 << qemu_fls(size);
+    }
+
+    pdev->rom_offset = qemu_ram_alloc(size);
+
+    ptr = qemu_get_ram_ptr(pdev->rom_offset);
+    load_image(path, ptr);
+    qemu_free(path);
+
+    pci_register_bar(pdev, PCI_ROM_SLOT, size,
+                     0, pci_map_option_rom);
+
+    return 0;
+}
+
 /* Reserve space and add capability to the linked list in pci config space */
 int pci_add_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
 {
hw/pci.h +5 -0
index d279e3f..89b3f55 100644
@@ -243,6 +243,9 @@ struct PCIDevice {
     uint32_t msix_bar_size;
     /* Version id needed for VMState */
     int32_t version_id;
+
+    /* Location of option rom */
+    ram_addr_t rom_offset;
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
@@ -254,6 +257,8 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
                             pcibus_t size, int type,
                             PCIMapIORegionFunc *map_func);
 
+int pci_add_option_rom(PCIDevice *pdev, const char *name);
+
 int pci_add_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
 
 void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
hw/rtl8139.c +1 -1
index 9fd05a8..2cee97b 100644
@@ -3357,7 +3357,7 @@ static int pci_rtl8139_init(PCIDevice *dev)
     if (!dev->qdev.hotplugged) {
         static int loaded = 0;
         if (!loaded) {
-            rom_add_option("pxe-rtl8139.bin");
+            pci_add_option_rom(&s->dev, "pxe-rtl8139.bin");
             loaded = 1;
         }
     }
hw/virtio-pci.c +1 -1
index 4500130..85f14a2 100644
@@ -522,7 +522,7 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
     if (!pci_dev->qdev.hotplugged) {
         static int loaded = 0;
         if (!loaded) {
-            rom_add_option("pxe-virtio.bin");
+            pci_add_option_rom(pci_dev, "pxe-virtio.bin");
             loaded = 1;
         }
     }
Signature · 1 line
1.6.5.2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 10 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Currently, we preload option roms into the option rom space in memory.  This prevents DDIM from functioning correctly which severely limits the number of roms we can support.

This patch introduces a pci_add_option_rom() which registers the PCI_ROM_ADDRESS bar which points to our option rom.  It also converts over the cirrus vga adapter, the rtl8139, virtio, and the e1000 to use this new mechanism.

This means that the VGA roms are now visible for all targets, not just when rom_enable_driver_roms is true. I'm not opposing this, but it may create regressions.

#3 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 14 lines · Blue Swirl
Quoted 11 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Currently, we preload option roms into the option rom space in memory. This prevents DDIM from functioning correctly which severely limits the number of roms we can support.

This patch introduces a pci_add_option_rom() which registers the PCI_ROM_ADDRESS bar which points to our option rom. It also converts over the cirrus vga adapter, the rtl8139, virtio, and the e1000 to use this new mechanism.

Quoted 4 lines

This means that the VGA roms are now visible for all targets, not just when rom_enable_driver_roms is true. I'm not opposing this, but it may create regressions.

This is pretty normal on bare metal though, no? I thought a lot of non-x86 systems actually use x86 emulators specifically to enable support for these roms.

Regards,

Anthony Liguori

#4 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 19 lines · Anthony Liguori
Quoted 18 lines · Blue Swirl
Quoted 14 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Currently, we preload option roms into the option rom space in memory. This
prevents DDIM from functioning correctly which severely limits the number of roms we can support.

This patch introduces a pci_add_option_rom() which registers the PCI_ROM_ADDRESS bar which points to our option rom.  It also converts over
the cirrus vga adapter, the rtl8139, virtio, and the e1000 to use this new mechanism.

Quoted 8 lines
Quoted 4 lines

This means that the VGA roms are now visible for all targets, not just when rom_enable_driver_roms is true. I'm not opposing this, but it may create regressions.

This is pretty normal on bare metal though, no?  I thought a lot of non-x86 systems actually use x86 emulators specifically to enable support for these roms.

I think so too, but ROM loading was first introduced with rom_enable_driver_roms mechanism just for cases like this.

But if there are no regressions, rom_enable_driver_roms mechanism could be removed.

#5 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 29 lines · Blue Swirl
Quoted 19 lines · Anthony Liguori
Quoted 18 lines · Blue Swirl
Quoted 14 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Currently, we preload option roms into the option rom space in memory.
This
prevents DDIM from functioning correctly which severely limits the number of roms we can support.

This patch introduces a pci_add_option_rom() which registers the PCI_ROM_ADDRESS bar which points to our option rom. It also converts over
the cirrus vga adapter, the rtl8139, virtio, and the e1000 to use this new mechanism.

Quoted 8 lines
Quoted 4 lines

This means that the VGA roms are now visible for all targets, not just when rom_enable_driver_roms is true. I'm not opposing this, but it may create regressions.

This is pretty normal on bare metal though, no? I thought a lot of non-x86 systems actually use x86 emulators specifically to enable support for these roms.

Quoted 5 lines

I think so too, but ROM loading was first introduced with rom_enable_driver_roms mechanism just for cases like this.

But if there are no regressions, rom_enable_driver_roms mechanism could be removed.

Don't macs usually have a powerpc vgabios?

I don't think we'd introduce regressions, just something you wouldn't find in a real machine. But then again the mac target isn't exactly that close to real hw anyways ...

Alex

#6 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 2 lines · Alexander Graf

Don't macs usually have a powerpc vgabios?

I'm not certain, but this is what x86emu is for in X11.

VGA is a PC concept and just about nothing about it really make sense on a different architecture. The interface is an extension of the PC BIOS (software interrupts) and the dictated memory layouts are specific to the x86. I think most non-x86 systems have to use native drivers for whatever graphics cards they support from the start.

Regards,

Anthony Liguori

#7 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 6 lines · Anthony Liguori
Quoted 2 lines · Alexander Graf

Don't macs usually have a powerpc vgabios?

I'm not certain, but this is what x86emu is for in X11.

VGA is a PC concept and just about nothing about it really make sense on a different architecture. The interface is an extension of the PC BIOS (software interrupts) and the dictated memory layouts are specific to the x86. I think most non-x86 systems have to use native drivers for whatever graphics cards they support from the start.

Yes. The Alpha for example used stock VGABIOSes. IIRC Sparc has its own graphics anyways and I don't know about the others, but I suspect they either use x86 VGABIOSes or no VGABIOSes.

Macs are different though. IIRC they have a normal VGA interface in ppc logic, but I might be wrong. Maybe it's also some OpenFirmware stuff. They definitely don't have an x86 VGABIOS in the graphics card's rom slot, but something different.

Since we're using the Cirrus on Macs, I guess we'd need a Cirrus PPC VGABIOS - phew.

Other PPCs on the other hand, such as the Powerstation, use x86 roms.

Oh well, let's just export the x86 one for now but use video.x for video output. Looks like there'd be quite a lot of work involved in getting it aligned to real world mac hw :-(.

Alex

PS: Ben, please correct me if I'm wrong.

#8 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Am 20.12.2009 um 19:01 schrieb Alexander Graf:

Quoted 8 lines · Anthony Liguori
Quoted 6 lines
Quoted 2 lines · Alexander Graf

Don't macs usually have a powerpc vgabios?

I'm not certain, but this is what x86emu is for in X11.

Quoted 7 lines
Quoted 1 line

VGA is a PC concept and just about nothing about it really make sense on a different architecture. The interface is an extension of the PC BIOS (software interrupts) and the dictated memory layouts are specific to the x86. I think most non-x86 systems have to use native drivers for whatever graphics cards they support from the start.

Yes. The Alpha for example used stock VGABIOSes. IIRC Sparc has its own graphics anyways and I don't know about the others, but I suspect they either use x86 VGABIOSes or no VGABIOSes.

Macs are different though. IIRC they have a normal VGA interface in ppc logic, but I might be wrong. Maybe it's also some OpenFirmware stuff. They definitely don't have an x86 VGABIOS in the graphics card's rom slot, but something different.

Since we're using the Cirrus on Macs, I guess we'd need a Cirrus PPC VGABIOS - phew.

ATI used to sell special "Mac Edition" graphics cards. That would seem to back up the possibility of a ppc VGABIOS on Mac.

Never tried putting such a card into a PC though or vice versa. Maybe we'd get the same sick-coloured penguins then...? ;)

Andreas

Quoted 8 lines

Other PPCs on the other hand, such as the Powerstation, use x86 roms.

Oh well, let's just export the x86 one for now but use video.x for video output. Looks like there'd be quite a lot of work involved in getting it aligned to real world mac hw :-(.

Alex

PS: Ben, please correct me if I'm wrong.

#9 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 27 lines · Andreas Färber

Am 20.12.2009 um 19:01 schrieb Alexander Graf:

Quoted 24 lines · Anthony Liguori
Quoted 5 lines
Quoted 3 lines · Alexander Graf

Don't macs usually have a powerpc vgabios?

Quoted 7 lines

I'm not certain, but this is what x86emu is for in X11.

VGA is a PC concept and just about nothing about it really make sense on a different architecture.  The interface is an extension of the PC BIOS (software interrupts) and the dictated memory layouts are specific to the x86.  I think most non-x86 systems have to use native drivers for whatever graphics cards they support from the start.

Yes. The Alpha for example used stock VGABIOSes. IIRC Sparc has its own graphics anyways and I don't know about the others, but I suspect they either use x86 VGABIOSes or no VGABIOSes.

Macs are different though. IIRC they have a normal VGA interface in ppc logic, but I might be wrong. Maybe it's also some OpenFirmware stuff. They definitely don't have an x86 VGABIOS in the graphics card's rom slot, but something different.

Quoted 5 lines
Quoted 2 lines

Since we're using the Cirrus on Macs, I guess we'd need a Cirrus PPC VGABIOS - phew.

ATI used to sell special "Mac Edition" graphics cards. That would seem to back up the possibility of a ppc VGABIOS on Mac.

Some Sun machines also had "ATY,Rage XL" cards but I don't know if they had special roms.

#10 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

Quoted 3 lines · Blue Swirl

Some Sun machines also had "ATY,Rage XL" cards but I don't know if they had special roms.

They would have similar f-code to the mac ones (ie. Tokenized forth for Open Firmware).

However, in the case of qemu, I don't see much point in doing so for the sake of OpenBIOS :-)

Cheers
Ben.

#11 lore raw

Re: [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading

In reply to Alexander Graf
Quoted 10 lines · Alexander Graf

Yes. The Alpha for example used stock VGABIOSes. IIRC Sparc has its own graphics anyways and I don't know about the others, but I suspect they either use x86 VGABIOSes or no VGABIOSes.

Macs are different though. IIRC they have a normal VGA interface in ppc logic, but I might be wrong. Maybe it's also some OpenFirmware stuff. They definitely don't have an x86 VGABIOS in the graphics card's rom slot, but something different.

Quoted 8 lines

Since we're using the Cirrus on Macs, I guess we'd need a Cirrus PPC VGABIOS - phew.

Other PPCs on the other hand, such as the Powerstation, use x86 roms.

Oh well, let's just export the x86 one for now but use video.x for video output. Looks like there'd be quite a lot of work involved in getting it aligned to real world mac hw :-(.

Hrm, I missed the beginning of the story :-) But basically here's what things look like vs. option ROMs on powerpc:

- Most Open Firmware based machines (pSeries and Macs) can load some
f-code firmware from there (tokenized forth). The f-code is platform agnostic (in theory, Apple did play games in that area) and so in theory the same f-code would work on, for example, an x86 with Open Firmware (if you had a slot on the OLPC you could try :-)

- That f-code firmware is used for whatever initializations the card
need (for example, video cards generally need specific inits before being usable at all by the OS, at least older ones do). It can create additional properties in the device-tree as well.

- On Macs specifically, they have a trick consisting of putting a
powerpc MacOS video driver in there, in the form of one big property (AAPL,NDRV iirc). This is a MacOS 7/8/9 style PEF driver but generally compiled and linked to work in a very limited environment for which OS X provides a sandbox, and which provides basic monitor detection and mode settings. video.x is such a driver (I wrote it :-) though I don't remember precisely whether the video.x file is the raw NDRV or the packaged f-code which contains the ndrv).

- Some powerpc machines (Pegasos, Efika, PowerStation, ... ) also have
an x86emu variant in their firmware that can load a VGA ROM and use it to setup some kind of boot display for the firmware.

- An option ROM can contain multiple images :-) IE. It can contain
-both- the x86 style ROM and the Open Firmware style f-code...

Now, in the light of the above, what is interesting to do on qemu ?

It all depends how "close" we consider OpenBIOS to be from qemu. If "close" then we don't need any of the f-code stuff. OpenBIOS could use some private calls to inside qemu and be done with it, including for sucking the video.x MacOS driver if the machine "profile" is a Mac (see the discussions on using the device-tree to define machines inside qemu, I believe that would be a great improvement).

A VGA ROM is not really useful past the firmware stage on ppc, as generally X is built without Int10 and we cannot really do anything with it appart from the FW initializing the card. This is not true of real ATI or nVidia cards because their driver uses tables in the VGA ROM for various things but that isn't necessarily very useful for qemu. But on the other hand, it doesn't hurt to have it there.

We should also look formward to native flat device tree booting without OpenBIOS in which case we probably don't care much (though again a VGA ROM might prove useful if whatever we boot has an x86emu variant).

Cheers,
Ben.

#12 lore raw

PATCH 2/8 pci romfiles: add property, add default to PCIDeviceInfo

In reply to Gerd Hoffmann

This patch adds a romfile property to the pci bus. It allows to specify a romfile to load into the rom bar of the pci device. The default value comes from a new field in PCIDeviceInfo. The property allows to change the file and also to disable the rom loading using an empty string.

---
 hw/cirrus_vga.c |    4 +---
 hw/e1000.c      |    9 +--------
 hw/pci.c        |   24 +++++++++++++++++++++---
 hw/pci.h        |    6 ++++--
 hw/rtl8139.c    |    9 +--------
 hw/virtio-pci.c |    9 +--------
 6 files changed, 29 insertions(+), 32 deletions(-)
hw/cirrus_vga.c +1 -3
index b08d2ae..6fe433d 100644
@@ -3209,9 +3209,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
          pci_register_bar((PCIDevice *)d, 1, CIRRUS_PNPMMIO_SIZE,
                           PCI_BASE_ADDRESS_SPACE_MEMORY, cirrus_pci_mmio_map);
      }
-
-     /* ROM BIOS */
-     pci_add_option_rom((PCIDevice *)d, VGABIOS_CIRRUS_FILENAME);
      return 0;
 }
 
@@ -3226,6 +3223,7 @@ static PCIDeviceInfo cirrus_vga_info = {
     .qdev.size    = sizeof(PCICirrusVGAState),
     .qdev.vmsd    = &vmstate_pci_cirrus_vga,
     .init         = pci_cirrus_vga_initfn,
+    .romfile      = VGABIOS_CIRRUS_FILENAME,
     .config_write = pci_cirrus_write_config,
 };
 
hw/e1000.c +1 -8
index f795601..33c4bc6 100644
@@ -1121,14 +1121,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
                           d->dev.qdev.info->name, d->dev.qdev.id, d);
 
     qemu_format_nic_info_str(&d->nic->nc, macaddr);
-
-    if (!pci_dev->qdev.hotplugged) {
-        static int loaded = 0;
-        if (!loaded) {
-            pci_add_option_rom(&d->dev, "pxe-e1000.bin");
-            loaded = 1;
-        }
-    }
     return 0;
 }
 
@@ -1146,6 +1138,7 @@ static PCIDeviceInfo e1000_info = {
     .qdev.vmsd  = &vmstate_e1000,
     .init       = pci_e1000_init,
     .exit       = pci_e1000_uninit,
+    .romfile    = "pxe-e1000.bin",
     .qdev.props = (Property[]) {
         DEFINE_NIC_PROPERTIES(E1000State, conf),
         DEFINE_PROP_END_OF_LIST(),
hw/pci.c +21 -3
index dbdfdbf..d54f05e 100644
@@ -63,12 +63,14 @@ static struct BusInfo pci_bus_info = {
     .print_dev  = pcibus_dev_print,
     .props      = (Property[]) {
         DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
+        DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
         DEFINE_PROP_END_OF_LIST()
     }
 };
 
 static void pci_update_mappings(PCIDevice *d);
 static void pci_set_irq(void *opaque, int irq_num, int level);
+static int pci_add_option_rom(PCIDevice *pdev);
 
 target_phys_addr_t pci_mem_base;
 static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
@@ -1387,6 +1389,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
     rc = info->init(pci_dev);
     if (rc != 0)
         return rc;
+
+    /* rom loading */
+    if (pci_dev->romfile == NULL && info->romfile != NULL)
+        pci_dev->romfile = qemu_strdup(info->romfile);
+    pci_add_option_rom(pci_dev);
+
     if (qdev->hotplugged)
         bus->hotplug(pci_dev, 1);
     return 0;
@@ -1470,18 +1478,28 @@ static void pci_map_option_rom(PCIDevice *pdev, int region_num, pcibus_t addr, p
 }
 
 /* Add an option rom for the device */
-int pci_add_option_rom(PCIDevice *pdev, const char *name)
+static int pci_add_option_rom(PCIDevice *pdev)
 {
     int size;
     char *path;
     void *ptr;
 
-    path = qemu_find_file(QEMU_FILE_TYPE_BIOS, name);
+    if (!pdev->romfile)
+        return 0;
+    if (strlen(pdev->romfile) == 0)
+        return 0;
+
+    path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile);
     if (path == NULL) {
-        path = qemu_strdup(name);
+        path = qemu_strdup(pdev->romfile);
     }
 
     size = get_image_size(path);
+    if (size < 0) {
+        qemu_error("%s: failed to find romfile \"%s\"\n", __FUNCTION__,
+                   pdev->romfile);
+        return -1;
+    }
     if (size & (size - 1)) {
         size = 1 << qemu_fls(size);
     }
hw/pci.h +4 -2
index 89b3f55..39da7df 100644
@@ -245,6 +245,7 @@ struct PCIDevice {
     int32_t version_id;
 
     /* Location of option rom */
+    char *romfile;
     ram_addr_t rom_offset;
 };
 
@@ -257,8 +258,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
                             pcibus_t size, int type,
                             PCIMapIORegionFunc *map_func);
 
-int pci_add_option_rom(PCIDevice *pdev, const char *name);
-
 int pci_add_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
 
 void pci_del_capability(PCIDevice *pci_dev, uint8_t cap_id, uint8_t cap_size);
@@ -386,6 +385,9 @@ typedef struct {
 
     /* pcie stuff */
     int is_express;   /* is this device pci express? */
+
+    /* rom bar */
+    const char *romfile;
 } PCIDeviceInfo;
 
 void pci_qdev_register(PCIDeviceInfo *info);
hw/rtl8139.c +1 -8
index 2cee97b..fcdcd1d 100644
@@ -3353,14 +3353,6 @@ static int pci_rtl8139_init(PCIDevice *dev)
     qemu_mod_timer(s->timer,
         rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
 #endif /* RTL8139_ONBOARD_TIMER */
-
-    if (!dev->qdev.hotplugged) {
-        static int loaded = 0;
-        if (!loaded) {
-            pci_add_option_rom(&s->dev, "pxe-rtl8139.bin");
-            loaded = 1;
-        }
-    }
     return 0;
 }
 
@@ -3371,6 +3363,7 @@ static PCIDeviceInfo rtl8139_info = {
     .qdev.vmsd  = &vmstate_rtl8139,
     .init       = pci_rtl8139_init,
     .exit       = pci_rtl8139_uninit,
+    .romfile    = "pxe-rtl8139.bin",
     .qdev.props = (Property[]) {
         DEFINE_NIC_PROPERTIES(RTL8139State, conf),
         DEFINE_PROP_END_OF_LIST(),
hw/virtio-pci.c +1 -8
index 85f14a2..62b46bd 100644
@@ -518,14 +518,6 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
 
     /* make the actual value visible */
     proxy->nvectors = vdev->nvectors;
-
-    if (!pci_dev->qdev.hotplugged) {
-        static int loaded = 0;
-        if (!loaded) {
-            pci_add_option_rom(pci_dev, "pxe-virtio.bin");
-            loaded = 1;
-        }
-    }
     return 0;
 }
 
@@ -569,6 +561,7 @@ static PCIDeviceInfo virtio_info[] = {
         .qdev.size  = sizeof(VirtIOPCIProxy),
         .init       = virtio_net_init_pci,
         .exit       = virtio_net_exit_pci,
+        .romfile    = "pxe-virtio.bin",
         .qdev.props = (Property[]) {
             DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
             DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
Signature · 1 line
1.6.5.2
#13 lore raw

[Qemu-devel] [RFC] New naming rules for GPXE romfiles

The current names of GPXE romfiles are something like pxe-e1000.bin, pxe-ne2k_pci.bin, pxe-rtl8139.bin.

This was adequate when these names were computed by a simple rule using the device name.

Today, an ethernet device can be associated to any romfile name.

Etherboot's Rom-o-Matic (which creates qemu's romfiles) creates names like gpxe-0.9.9-80861209.rom.

I don't think it would be good to use etherboot's names because they contain the gpxe version (0.9.9) which might change.

But a modified name without the gpxe version like gpxe-80861209.rom would have some advantages:

* gpxe* is better than pxe* because the files contain a gPXE boot ROM - not a proprietary PXE ROM.

* The romfiles are ROM files, not undefined binaries, so *.rom looks better than *.bin.

* For drivers like eepro100.c which implement several devices, a naming rule based on PCI device and vendor id (80861209) is better than a rule based on device names:
devices with same ids can share the same romfile.

* Transforming an etherboot romfile name to a qemu romfile name is simple when all you have to do is to remove the version. This would also simplify pc-bios/README.

The proposed new names should be used for new romfiles. Optionally, the existing romfiles could be renamed.

Please tell me what you think of these suggestions.

Regards
Stefan Weil

PS. Mixing ROM data for different hosts in one directory (as it is done today) could be improved, too:

* Separate directories for different hosts.
* Include the host in the romfile name (as it is done for the openbios roms).
* pc-bios was historically correct but is no longer adequate.

As far as I remember, there had already been some discussion on these points some time ago.

#14 lore raw

Re: [Qemu-devel] [RFC] New naming rules for GPXE romfiles

Quoted 30 lines · Stefan Weil

The current names of GPXE romfiles are something like pxe-e1000.bin, pxe-ne2k_pci.bin, pxe-rtl8139.bin.

This was adequate when these names were computed by a simple rule using the device name.

Today, an ethernet device can be associated to any romfile name.

Etherboot's Rom-o-Matic (which creates qemu's romfiles) creates names like gpxe-0.9.9-80861209.rom.

I don't think it would be good to use etherboot's names because they contain the gpxe version (0.9.9) which might change.

But a modified name without the gpxe version like gpxe-80861209.rom would have some advantages:

* gpxe* is better than pxe* because the files contain a gPXE boot ROM - not a proprietary PXE ROM.

* The romfiles are ROM files, not undefined binaries, so *.rom looks better than *.bin.

* For drivers like eepro100.c which implement several devices, a naming rule based on PCI device and vendor id (80861209) is better than a rule based on device names:
devices with same ids can share the same romfile.

Quoted 9 lines

* Transforming an etherboot romfile name to a qemu romfile name is simple when all you have to do is to remove the version. This would also simplify pc-bios/README.

The proposed new names should be used for new romfiles. Optionally, the existing romfiles could be renamed.

Please tell me what you think of these suggestions.

I don't feel strongly either way.

Regards,

Anthony Liguori

#15 lore raw

Re: [Qemu-devel] [RFC] New naming rules for GPXE romfiles

In reply to Stefan Weil

Am 11.01.2010 22:18, schrieb Stefan Weil:

Quoted 22 lines

The current names of GPXE romfiles are something like pxe-e1000.bin, pxe-ne2k_pci.bin, pxe-rtl8139.bin.

This was adequate when these names were computed by a simple rule using the device name.

Today, an ethernet device can be associated to any romfile name.

Etherboot's Rom-o-Matic (which creates qemu's romfiles) creates names like gpxe-0.9.9-80861209.rom.

I don't think it would be good to use etherboot's names because they contain the gpxe version (0.9.9) which might change.

But a modified name without the gpxe version like gpxe-80861209.rom would have some advantages:

* gpxe* is better than pxe* because the files contain a gPXE boot ROM - not a proprietary PXE ROM.

Quoted 7 lines

* The romfiles are ROM files, not undefined binaries, so *.rom looks better than *.bin.

* For drivers like eepro100.c which implement several devices, a naming rule based on PCI device and vendor id (80861209) is better than a rule based on device names:
devices with same ids can share the same romfile.

I dislike this part of your suggestion. Everyone knows what a pcnet is, but I guess most people don't know its PCI device/vendor ID. So it would add files that most people can't associate with anything specific. Maybe you could name your files gpxe-eepro100-vendor_dev.rom and just leave vendor_dev out for devices with just one ID?

I'm fine with the other suggestions, though.

Kevin

#16 lore raw

PATCH 3/8 fw_cfg: make calls typesafe

In reply to Gerd Hoffmann
---
 hw/fw_cfg.c |   26 ++++++++++++--------------
 hw/fw_cfg.h |   16 +++++++++-------
 2 files changed, 21 insertions(+), 21 deletions(-)
hw/fw_cfg.c +12 -14
index b25afff..2e3662d 100644
@@ -45,11 +45,11 @@ typedef struct _FWCfgEntry {
     FWCfgCallback callback;
 } FWCfgEntry;
 
-typedef struct _FWCfgState {
+struct _FWCfgState {
     FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
     uint16_t cur_entry;
     uint32_t cur_offset;
-} FWCfgState;
+};
 
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
 {
@@ -210,9 +210,8 @@ static const VMStateDescription vmstate_fw_cfg = {
     }
 };
 
-int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len)
+int fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)
 {
-    FWCfgState *s = opaque;
     int arch = !!(key & FW_CFG_ARCH_LOCAL);
 
     key &= FW_CFG_ENTRY_MASK;
@@ -226,37 +225,36 @@ int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len)
     return 1;
 }
 
-int fw_cfg_add_i16(void *opaque, uint16_t key, uint16_t value)
+int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
 {
     uint16_t *copy;
 
     copy = qemu_malloc(sizeof(value));
     *copy = cpu_to_le16(value);
-    return fw_cfg_add_bytes(opaque, key, (uint8_t *)copy, sizeof(value));
+    return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
 }
 
-int fw_cfg_add_i32(void *opaque, uint16_t key, uint32_t value)
+int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)
 {
     uint32_t *copy;
 
     copy = qemu_malloc(sizeof(value));
     *copy = cpu_to_le32(value);
-    return fw_cfg_add_bytes(opaque, key, (uint8_t *)copy, sizeof(value));
+    return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
 }
 
-int fw_cfg_add_i64(void *opaque, uint16_t key, uint64_t value)
+int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
 {
     uint64_t *copy;
 
     copy = qemu_malloc(sizeof(value));
     *copy = cpu_to_le64(value);
-    return fw_cfg_add_bytes(opaque, key, (uint8_t *)copy, sizeof(value));
+    return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
 }
 
-int fw_cfg_add_callback(void *opaque, uint16_t key, FWCfgCallback callback,
+int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
                         void *callback_opaque, uint8_t *data, size_t len)
 {
-    FWCfgState *s = opaque;
     int arch = !!(key & FW_CFG_ARCH_LOCAL);
 
     if (!(key & FW_CFG_WRITE_CHANNEL))
@@ -275,8 +273,8 @@ int fw_cfg_add_callback(void *opaque, uint16_t key, FWCfgCallback callback,
     return 1;
 }
 
-void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
-		target_phys_addr_t ctl_addr, target_phys_addr_t data_addr)
+FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
+                        target_phys_addr_t ctl_addr, target_phys_addr_t data_addr)
 {
     FWCfgState *s;
     int io_ctl_memory, io_data_memory;
hw/fw_cfg.h +9 -7
index 7070c94..b06665e 100644
@@ -37,14 +37,16 @@
 #ifndef NO_QEMU_PROTOS
 typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
 
-int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len);
-int fw_cfg_add_i16(void *opaque, uint16_t key, uint16_t value);
-int fw_cfg_add_i32(void *opaque, uint16_t key, uint32_t value);
-int fw_cfg_add_i64(void *opaque, uint16_t key, uint64_t value);
-int fw_cfg_add_callback(void *opaque, uint16_t key, FWCfgCallback callback,
+typedef struct _FWCfgState FWCfgState;
+int fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len);
+int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value);
+int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
+int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);
+int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
                         void *callback_opaque, uint8_t *data, size_t len);
-void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
-		target_phys_addr_t crl_addr, target_phys_addr_t data_addr);
+int fw_cfg_add_file(FWCfgState *s, uint8_t type, uint8_t *data, uint32_t len);
+FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
+                        target_phys_addr_t crl_addr, target_phys_addr_t data_addr);
 
 #endif /* NO_QEMU_PROTOS */
 
Signature · 1 line
1.6.5.2
#17 lore raw

PATCH 4/8 fw_cfg: add API for file transfer.

In reply to Gerd Hoffmann

This patch adds a file transfer interface to fw_cfg. Intended to be used for passing non-pci option roms and vgabios to seabios. Namespace is modeled after the existing cbfs filesystem support in seabios.

Reading the new FW_CFG_FILE_DIR entry returns a file list. Fields there are in network byte order (aka bigendian).

---
 hw/fw_cfg.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 hw/fw_cfg.h |   21 +++++++++++++++++++--
 2 files changed, 62 insertions(+), 2 deletions(-)
hw/fw_cfg.c +43 -0
index 2e3662d..0492f5f 100644
@@ -47,6 +47,7 @@ typedef struct _FWCfgEntry {
 
 struct _FWCfgState {
     FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
+    FWCfgFiles *files;
     uint16_t cur_entry;
     uint32_t cur_offset;
 };
@@ -273,6 +274,48 @@ int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
     return 1;
 }
 
+int fw_cfg_add_file(FWCfgState *s,  const char *dir, const char *filename,
+                    uint8_t *data, uint32_t len)
+{
+    const char *basename;
+    int index;
+
+    if (!s->files) {
+        int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
+        s->files = qemu_mallocz(dsize);
+        fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);
+    }
+
+    index = be32_to_cpu(s->files->count);
+    if (index == FW_CFG_FILE_SLOTS) {
+        fprintf(stderr, "fw_cfg: out of file slots\n");
+        return 0;
+    }
+
+    fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len);
+
+    basename = strrchr(filename, '/');
+    if (basename) {
+        basename++;
+    } else {
+        basename = filename;
+    }
+    if (dir) {
+        snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
+                 "%s/%s", dir, basename);
+    } else {
+        snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
+                 "%s", basename);
+    }
+    s->files->f[index].size   = cpu_to_be32(len);
+    s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
+    fprintf(stderr, "%s: #%d: %s (%d bytes)\n", __FUNCTION__,
+            index, s->files->f[index].name, len);
+
+    s->files->count = cpu_to_be32(index+1);
+    return 1;
+}
+
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
                         target_phys_addr_t ctl_addr, target_phys_addr_t data_addr)
 {
hw/fw_cfg.h +19 -2
index b06665e..a63f54f 100644
@@ -26,7 +26,11 @@
 #define FW_CFG_SETUP_ADDR       0x16
 #define FW_CFG_SETUP_SIZE       0x17
 #define FW_CFG_SETUP_DATA       0x18
-#define FW_CFG_MAX_ENTRY        0x19
+#define FW_CFG_FILE_DIR         0x19
+
+#define FW_CFG_FILE_FIRST       0x20
+#define FW_CFG_FILE_SLOTS       0x10
+#define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
 
 #define FW_CFG_WRITE_CHANNEL    0x4000
 #define FW_CFG_ARCH_LOCAL       0x8000
@@ -34,6 +38,18 @@
 
 #define FW_CFG_INVALID          0xffff
 
+typedef struct FWCfgFile {
+    uint32_t  size;        /* file size */
+    uint16_t  select;      /* write this to 0x510 to read it */
+    uint16_t  reserved;
+    char      name[56];
+} FWCfgFile;
+
+typedef struct FWCfgFiles {
+    uint32_t  count;
+    FWCfgFile f[];
+} FWCfgFiles;
+
 #ifndef NO_QEMU_PROTOS
 typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
 
@@ -44,7 +60,8 @@ int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
 int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);
 int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
                         void *callback_opaque, uint8_t *data, size_t len);
-int fw_cfg_add_file(FWCfgState *s, uint8_t type, uint8_t *data, uint32_t len);
+int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
+                    uint8_t *data, uint32_t len);
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
                         target_phys_addr_t crl_addr, target_phys_addr_t data_addr);
 
Signature · 1 line
1.6.5.2
#18 lore raw

Re: [Qemu-devel] [PATCH 4/8] fw_cfg: add API for file transfer.

Quoted 6 lines · Gerd Hoffmann

This patch adds a file transfer interface to fw_cfg.  Intended to be used for passing non-pci option roms and vgabios to seabios.  Namespace is modeled after the existing cbfs filesystem support in seabios.

Reading the new FW_CFG_FILE_DIR entry returns a file list. Fields there are in network byte order (aka bigendian).

The 16 bit selector for other cases is in little endian order. Please use LE for consistency.

Quoted 2 lines

+    fprintf(stderr, "%s: #%d: %s (%d bytes)\n", __FUNCTION__,
+            index, s->files->f[index].name, len);

No.

#19 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 4/8] fw_cfg: add API for file transfer.

In reply to Gerd Hoffmann
Quoted 79 lines · Gerd Hoffmann

This patch adds a file transfer interface to fw_cfg. Intended to be used for passing non-pci option roms and vgabios to seabios. Namespace is modeled after the existing cbfs filesystem support in seabios.

Reading the new FW_CFG_FILE_DIR entry returns a file list. Fields there are in network byte order (aka bigendian).

---
 hw/fw_cfg.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 hw/fw_cfg.h |   21 +++++++++++++++++++--
 2 files changed, 62 insertions(+), 2 deletions(-)
hw/fw_cfg.c +43 -0
index 2e3662d..0492f5f 100644
@@ -47,6 +47,7 @@ typedef struct _FWCfgEntry {
 
 struct _FWCfgState {
     FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
+    FWCfgFiles *files;
     uint16_t cur_entry;
     uint32_t cur_offset;
 };
@@ -273,6 +274,48 @@ int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
     return 1;
 }
 
+int fw_cfg_add_file(FWCfgState *s,  const char *dir, const char *filename,
+                    uint8_t *data, uint32_t len)
+{
+    const char *basename;
+    int index;
+
+    if (!s->files) {
+        int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
+        s->files = qemu_mallocz(dsize);
+        fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);
+    }
+
+    index = be32_to_cpu(s->files->count);
+    if (index == FW_CFG_FILE_SLOTS) {
+        fprintf(stderr, "fw_cfg: out of file slots\n");
+        return 0;
+    }
+
+    fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len);
+
+    basename = strrchr(filename, '/');
+    if (basename) {
+        basename++;
+    } else {
+        basename = filename;
+    }
+    if (dir) {
+        snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
+                 "%s/%s", dir, basename);
+    } else {
+        snprintf(s->files->f[index].name, sizeof(s->files->f[index].name),
+                 "%s", basename);
+    }
+    s->files->f[index].size   = cpu_to_be32(len);
+    s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
+    fprintf(stderr, "%s: #%d: %s (%d bytes)\n", __FUNCTION__,
+            index, s->files->f[index].name, len);
+
+    s->files->count = cpu_to_be32(index+1);
+    return 1;
+}
+
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
                         target_phys_addr_t ctl_addr, target_phys_addr_t data_addr)
 {
hw/fw_cfg.h +0 -0
index b06665e..a63f54f 100644

hw/fw_cfg.h line 32

Quoted 8 lines
hw/fw_cfg.h +4 -1
@@ -26,7 +26,11 @@
 #define FW_CFG_SETUP_ADDR       0x16
 #define FW_CFG_SETUP_SIZE       0x17
 #define FW_CFG_SETUP_DATA       0x18
-#define FW_CFG_MAX_ENTRY        0x19
+#define FW_CFG_FILE_DIR         0x19
+
+#define FW_CFG_FILE_FIRST       0x20
+#define FW_CFG_FILE_SLOTS       0x10

The name of this define looks like CFG option number but it is not. Lets rename it.

Quoted 41 lines
hw/fw_cfg.h +15 -1
+#define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
 
 #define FW_CFG_WRITE_CHANNEL    0x4000
 #define FW_CFG_ARCH_LOCAL       0x8000
@@ -34,6 +38,18 @@
 
 #define FW_CFG_INVALID          0xffff
 
+typedef struct FWCfgFile {
+    uint32_t  size;        /* file size */
+    uint16_t  select;      /* write this to 0x510 to read it */
+    uint16_t  reserved;
+    char      name[56];
+} FWCfgFile;
+
+typedef struct FWCfgFiles {
+    uint32_t  count;
+    FWCfgFile f[];
+} FWCfgFiles;
+
 #ifndef NO_QEMU_PROTOS
 typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
 
@@ -44,7 +60,8 @@ int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
 int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);
 int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
                         void *callback_opaque, uint8_t *data, size_t len);
-int fw_cfg_add_file(FWCfgState *s, uint8_t type, uint8_t *data, uint32_t len);
+int fw_cfg_add_file(FWCfgState *s, const char *dir, const char *filename,
+                    uint8_t *data, uint32_t len);
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
                         target_phys_addr_t crl_addr, target_phys_addr_t data_addr);
 
Signature · 7 lines
1.6.5.2


_______________________________________________
SeaBIOS mailing list
[email protected]
http://www.seabios.org/mailman/listinfo/seabios

--
Gleb.

#20 lore raw

PATCH 5/8 roms: use new fw_cfg file xfer support.

In reply to Gerd Hoffmann

roms: use fw_cfg for vgabios and option rom loading, additionally to deploying them the traditional way (copy to 0xc0000 -> 0xe0000 range).

---
 hw/loader.c |   25 ++++++++++++++++++++++---
 hw/loader.h |    5 +++--
 hw/pc.c     |    2 ++
 3 files changed, 27 insertions(+), 5 deletions(-)
hw/loader.c +22 -3
index 2d7a2c4..ccc0ccc 100644
@@ -48,6 +48,7 @@
 #include "sysemu.h"
 #include "uboot_image.h"
 #include "loader.h"
+#include "fw_cfg.h"
 
 #include <zlib.h>
 
@@ -528,6 +529,8 @@ struct Rom {
     uint8_t *data;
     int align;
     int isrom;
+    char *fw_dir;
+    char *fw_file;
 
     target_phys_addr_t min;
     target_phys_addr_t max;
@@ -556,7 +559,7 @@ static void rom_insert(Rom *rom)
     QTAILQ_INSERT_TAIL(&roms, rom, next);
 }
 
-int rom_add_file(const char *file,
+int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
                  target_phys_addr_t min, target_phys_addr_t max, int align)
 {
     Rom *rom;
@@ -576,6 +579,8 @@ int rom_add_file(const char *file,
         goto err;
     }
 
+    rom->fw_dir  = fw_dir  ? qemu_strdup(fw_dir)  : NULL;
+    rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
     rom->align   = align;
     rom->min     = min;
     rom->max     = max;
@@ -623,14 +628,16 @@ int rom_add_vga(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "vgaroms", file,
+                        PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
 }
 
 int rom_add_option(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "genroms", file,
+                        PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
 }
 
 static void rom_reset(void *unused)
@@ -692,6 +699,18 @@ int rom_load_all(void)
     return 0;
 }
 
+int rom_load_fw(void *fw_cfg)
+{
+    Rom *rom;
+
+    QTAILQ_FOREACH(rom, &roms, next) {
+        if (!rom->fw_file)
+            continue;
+        fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize);
+    }
+    return 0;
+}
+
 static Rom *find_rom(target_phys_addr_t addr)
 {
     Rom *rom;
hw/loader.h +3 -2
index b3311a3..634f7d5 100644
@@ -19,17 +19,18 @@ void pstrcpy_targphys(const char *name,
                       target_phys_addr_t dest, int buf_size,
                       const char *source);
 
-int rom_add_file(const char *file,
+int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
                  target_phys_addr_t min, target_phys_addr_t max, int align);
 int rom_add_blob(const char *name, const void *blob, size_t len,
                  target_phys_addr_t min, target_phys_addr_t max, int align);
 int rom_load_all(void);
+int rom_load_fw(void *fw_cfg);
 int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
 void *rom_ptr(target_phys_addr_t addr);
 void do_info_roms(Monitor *mon);
 
 #define rom_add_file_fixed(_f, _a)              \
-    rom_add_file(_f, _a, 0, 0)
+    rom_add_file(_f, NULL, NULL, _a, 0, 0)
 #define rom_add_blob_fixed(_f, _b, _l, _a)      \
     rom_add_blob(_f, _b, _l, _a, 0, 0)
 
hw/pc.c +2 -0
index 147a9a7..be70f50 100644
@@ -1248,6 +1248,8 @@ static void pc_init1(ram_addr_t ram_size,
             }
         }
     }
+
+    rom_load_fw(fw_cfg);
 }
 
 static void pc_init_pci(ram_addr_t ram_size,
Signature · 1 line
1.6.5.2
#21 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 5/8] roms: use new fw_cfg file xfer support.

Quoted 32 lines · Gerd Hoffmann

roms: use fw_cfg for vgabios and option rom loading, additionally to deploying them the traditional way (copy to 0xc0000 -> 0xe0000 range).

---
 hw/loader.c |   25 ++++++++++++++++++++++---
 hw/loader.h |    5 +++--
 hw/pc.c     |    2 ++
 3 files changed, 27 insertions(+), 5 deletions(-)
hw/loader.c +3 -0
index 2d7a2c4..ccc0ccc 100644
@@ -48,6 +48,7 @@
 #include "sysemu.h"
 #include "uboot_image.h"
 #include "loader.h"
+#include "fw_cfg.h"
 
 #include <zlib.h>
 
@@ -528,6 +529,8 @@ struct Rom {
     uint8_t *data;
     int align;
     int isrom;
+    char *fw_dir;
+    char *fw_file;
 
     target_phys_addr_t min;
     target_phys_addr_t max;

hw/loader.c static void rom_insert(Rom *rom) · line 562

Quoted 5 lines
hw/loader.c +1 -1
@@ -556,7 +559,7 @@ static void rom_insert(Rom *rom)
     QTAILQ_INSERT_TAIL(&roms, rom, next);
 }
 
-int rom_add_file(const char *file,
+int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,

Currently file == fw_file except for rom_add_file_fixed. Is this always going to be the case? If yes may be better to pass "bool fixed" instead of "const char *fw_file"?

Quoted 96 lines
hw/loader.c +18 -2
                  target_phys_addr_t min, target_phys_addr_t max, int align)
 {
     Rom *rom;
@@ -576,6 +579,8 @@ int rom_add_file(const char *file,
         goto err;
     }
 
+    rom->fw_dir  = fw_dir  ? qemu_strdup(fw_dir)  : NULL;
+    rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
     rom->align   = align;
     rom->min     = min;
     rom->max     = max;
@@ -623,14 +628,16 @@ int rom_add_vga(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "vgaroms", file,
+                        PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
 }
 
 int rom_add_option(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "genroms", file,
+                        PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
 }
 
 static void rom_reset(void *unused)
@@ -692,6 +699,18 @@ int rom_load_all(void)
     return 0;
 }
 
+int rom_load_fw(void *fw_cfg)
+{
+    Rom *rom;
+
+    QTAILQ_FOREACH(rom, &roms, next) {
+        if (!rom->fw_file)
+            continue;
+        fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize);
+    }
+    return 0;
+}
+
 static Rom *find_rom(target_phys_addr_t addr)
 {
     Rom *rom;
hw/loader.h +3 -2
index b3311a3..634f7d5 100644
@@ -19,17 +19,18 @@ void pstrcpy_targphys(const char *name,
                       target_phys_addr_t dest, int buf_size,
                       const char *source);
 
-int rom_add_file(const char *file,
+int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
                  target_phys_addr_t min, target_phys_addr_t max, int align);
 int rom_add_blob(const char *name, const void *blob, size_t len,
                  target_phys_addr_t min, target_phys_addr_t max, int align);
 int rom_load_all(void);
+int rom_load_fw(void *fw_cfg);
 int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
 void *rom_ptr(target_phys_addr_t addr);
 void do_info_roms(Monitor *mon);
 
 #define rom_add_file_fixed(_f, _a)              \
-    rom_add_file(_f, _a, 0, 0)
+    rom_add_file(_f, NULL, NULL, _a, 0, 0)
 #define rom_add_blob_fixed(_f, _b, _l, _a)      \
     rom_add_blob(_f, _b, _l, _a, 0, 0)
 
hw/pc.c +2 -0
index 147a9a7..be70f50 100644
@@ -1248,6 +1248,8 @@ static void pc_init1(ram_addr_t ram_size,
             }
         }
     }
+
+    rom_load_fw(fw_cfg);
 }
 
 static void pc_init_pci(ram_addr_t ram_size,
Signature · 7 lines
1.6.5.2


_______________________________________________
SeaBIOS mailing list
[email protected]
http://www.seabios.org/mailman/listinfo/seabios

--
Gleb.

#22 lore raw

PATCH 6/8 roms: remove option rom packing logic

In reply to Gerd Hoffmann

Now that we load the option roms via fw_cfg, we can stop copying them to the 0xc000 -> 0xe000. The patch does just that.

Also the rom loader gets simplified as all remaining users of the rom loader load the bits at a fixed address so the packing and aligning logic can go away.

---
 hw/loader.c |  103 ++++++++++++++++++++++++++---------------------------------
 hw/loader.h |    8 ++--
 2 files changed, 49 insertions(+), 62 deletions(-)
hw/loader.c +45 -58
index ccc0ccc..49d4839 100644
@@ -527,13 +527,10 @@ struct Rom {
     char *path;
     size_t romsize;
     uint8_t *data;
-    int align;
     int isrom;
     char *fw_dir;
     char *fw_file;
 
-    target_phys_addr_t min;
-    target_phys_addr_t max;
     target_phys_addr_t addr;
     QTAILQ_ENTRY(Rom) next;
 };
@@ -551,7 +548,7 @@ static void rom_insert(Rom *rom)
 
     /* list is ordered by load address */
     QTAILQ_FOREACH(item, &roms, next) {
-        if (rom->min >= item->min)
+        if (rom->addr >= item->addr)
             continue;
         QTAILQ_INSERT_BEFORE(item, rom, next);
         return;
@@ -560,7 +557,7 @@ static void rom_insert(Rom *rom)
 }
 
 int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
-                 target_phys_addr_t min, target_phys_addr_t max, int align)
+                 target_phys_addr_t addr)
 {
     Rom *rom;
     int rc, fd = -1;
@@ -581,9 +578,7 @@ int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
 
     rom->fw_dir  = fw_dir  ? qemu_strdup(fw_dir)  : NULL;
     rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
-    rom->align   = align;
-    rom->min     = min;
-    rom->max     = max;
+    rom->addr    = addr;
     rom->romsize = lseek(fd, 0, SEEK_END);
     rom->data    = qemu_mallocz(rom->romsize);
     lseek(fd, 0, SEEK_SET);
@@ -608,15 +603,13 @@ err:
 }
 
 int rom_add_blob(const char *name, const void *blob, size_t len,
-                 target_phys_addr_t min, target_phys_addr_t max, int align)
+                 target_phys_addr_t addr)
 {
     Rom *rom;
 
     rom = qemu_mallocz(sizeof(*rom));
     rom->name    = qemu_strdup(name);
-    rom->align   = align;
-    rom->min     = min;
-    rom->max     = max;
+    rom->addr    = addr;
     rom->romsize = len;
     rom->data    = qemu_mallocz(rom->romsize);
     memcpy(rom->data, blob, len);
@@ -628,16 +621,14 @@ int rom_add_vga(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, "vgaroms", file,
-                        PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "vgaroms", file, 0);
 }
 
 int rom_add_option(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, "genroms", file,
-                        PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "genroms", file, 0);
 }
 
 static void rom_reset(void *unused)
@@ -645,6 +636,8 @@ static void rom_reset(void *unused)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
+        if (rom->addr == 0)
+            continue;
         if (rom->data == NULL)
             continue;
         cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
@@ -663,32 +656,16 @@ int rom_load_all(void)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (addr < rom->min)
-            addr = rom->min;
-        if (rom->max) {
-            /* load address range */
-            if (rom->align) {
-                addr += (rom->align-1);
-                addr &= ~(rom->align-1);
-            }
-            if (addr + rom->romsize > rom->max) {
-                fprintf(stderr, "rom: out of memory (rom %s, "
-                        "addr 0x" TARGET_FMT_plx
-                        ", size 0x%zx, max 0x" TARGET_FMT_plx ")\n",
-                        rom->name, addr, rom->romsize, rom->max);
-                return -1;
-            }
-        } else {
-            /* fixed address requested */
-            if (addr != rom->min) {
-                fprintf(stderr, "rom: requested regions overlap "
-                        "(rom %s. free=0x" TARGET_FMT_plx
-                        ", addr=0x" TARGET_FMT_plx ")\n",
-                        rom->name, addr, rom->min);
-                return -1;
-            }
+        if (rom->addr == 0)
+            continue;
+        if (addr > rom->addr) {
+            fprintf(stderr, "rom: requested regions overlap "
+                    "(rom %s. free=0x" TARGET_FMT_plx
+                    ", addr=0x" TARGET_FMT_plx ")\n",
+                    rom->name, addr, rom->addr);
+            return -1;
         }
-        rom->addr = addr;
+        addr  = rom->addr;
         addr += rom->romsize;
         memtype = cpu_get_physical_page_desc(rom->addr) & (3 << IO_MEM_SHIFT);
         if (memtype == IO_MEM_ROM)
@@ -716,11 +693,11 @@ static Rom *find_rom(target_phys_addr_t addr)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->max)
+        if (rom->addr == 0)
             continue;
-        if (rom->min > addr)
+        if (rom->addr > addr)
             continue;
-        if (rom->min + rom->romsize < addr)
+        if (rom->addr + rom->romsize < addr)
             continue;
         return rom;
     }
@@ -735,25 +712,25 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->max)
+        if (rom->addr == 0)
             continue;
-        if (rom->min > addr)
+        if (rom->addr > addr)
             continue;
-        if (rom->min + rom->romsize < addr)
+        if (rom->addr + rom->romsize < addr)
             continue;
-        if (rom->min > end)
+        if (rom->addr > end)
             break;
         if (!rom->data)
             continue;
 
-        d = dest + (rom->min - addr);
+        d = dest + (rom->addr - addr);
         s = rom->data;
         l = rom->romsize;
 
-        if (rom->min < addr) {
+        if (rom->addr < addr) {
             d = dest;
-            s += (addr - rom->min);
-            l -= (addr - rom->min);
+            s += (addr - rom->addr);
+            l -= (addr - rom->addr);
         }
         if ((d + l) > (dest + size)) {
             l = dest - d;
@@ -772,7 +749,7 @@ void *rom_ptr(target_phys_addr_t addr)
     rom = find_rom(addr);
     if (!rom || !rom->data)
         return NULL;
-    return rom->data + (addr - rom->min);
+    return rom->data + (addr - rom->addr);
 }
 
 void do_info_roms(Monitor *mon)
@@ -780,10 +757,20 @@ void do_info_roms(Monitor *mon)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        monitor_printf(mon, "addr=" TARGET_FMT_plx
-                       " size=0x%06zx mem=%s name=\"%s\" \n",
-                       rom->addr, rom->romsize,
-                       rom->isrom ? "rom" : "ram",
-                       rom->name);
+        if (rom->addr) {
+            monitor_printf(mon, "addr=" TARGET_FMT_plx
+                           " size=0x%06zx mem=%s name=\"%s\" \n",
+                           rom->addr, rom->romsize,
+                           rom->isrom ? "rom" : "ram",
+                           rom->name);
+        } else {
+            monitor_printf(mon, "fw=%s%s%s"
+                           " size=0x%06zx name=\"%s\" \n",
+                           rom->fw_dir ? rom->fw_dir : "",
+                           rom->fw_dir ? "/" : "",
+                           rom->fw_file,
+                           rom->romsize,
+                           rom->name);
+        }
     }
 }
hw/loader.h +4 -4
index 634f7d5..77beb0e 100644
@@ -20,9 +20,9 @@ void pstrcpy_targphys(const char *name,
                       const char *source);
 
 int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
-                 target_phys_addr_t min, target_phys_addr_t max, int align);
+                 target_phys_addr_t addr);
 int rom_add_blob(const char *name, const void *blob, size_t len,
-                 target_phys_addr_t min, target_phys_addr_t max, int align);
+                 target_phys_addr_t addr);
 int rom_load_all(void);
 int rom_load_fw(void *fw_cfg);
 int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
@@ -30,9 +30,9 @@ void *rom_ptr(target_phys_addr_t addr);
 void do_info_roms(Monitor *mon);
 
 #define rom_add_file_fixed(_f, _a)              \
-    rom_add_file(_f, NULL, NULL, _a, 0, 0)
+    rom_add_file(_f, NULL, NULL, _a)
 #define rom_add_blob_fixed(_f, _b, _l, _a)      \
-    rom_add_blob(_f, _b, _l, _a, 0, 0)
+    rom_add_blob(_f, _b, _l, _a)
 
 #define PC_ROM_MIN_VGA     0xc0000
 #define PC_ROM_MIN_OPTION  0xc8000
Signature · 1 line
1.6.5.2
#23 lore raw

PATCH 7/8 updated seabios binary for testing convinience.

In reply to Gerd Hoffmann
---
 pc-bios/bios.bin |  Bin 131072 -> 131072 bytes
 1 files changed, 0 insertions(+), 0 deletions(-)
pc-bios/bios.bin binary +0 -0
index 29495801950660c19630444e410ff30d673e46af..22a555a2b0fe827500c0a859884bc69290a848da 100644
GIT binary patch
Signature · 1 line
1.6.5.2
#24 lore raw

PATCH 8/8 debug: enable bios messages

In reply to Gerd Hoffmann
---
 hw/pc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/pc.c +1 -1
index be70f50..18d958d 100644
@@ -46,7 +46,7 @@
 #include "elf.h"
 
 /* output Bochs bios info messages */
-//#define DEBUG_BIOS
+#define DEBUG_BIOS
 
 /* Show multiboot debug output */
 //#define DEBUG_MULTIBOOT
Signature · 1 line
1.6.5.2
#25 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Quoted 9 lines

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Seabios patches will be posted shortly as separate patch series.

I know this series carries a good bit of risk but I'd like to bring it in 0.12.0. Because this has a guest visible change to the PCI devices, we cannot carry it in stable-0.12 post release and I think the functionality it brings it's very important. Otherwise, it's easy to trip up with using multiple nics and extboot in qemu-kvm.

Any objections?

Regards,

Anthony Liguori

#26 lore raw
Quoted 4 lines · Anthony Liguori

I know this series carries a good bit of risk but I'd like to bring it in 0.12.0. Because this has a guest visible change to the PCI devices, we cannot carry it in stable-0.12 post release and I think the functionality it brings it's very important.

The guest visible change automatically raises the question:
Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Oh, and while thinking about compatibility issues: What about migration? I think we have to save rom_offset in case $pcidevice has a rom bar, otherwise your roms are gone after migration. Which you wouldn't notice until reboot though.

Is 0.11 -> 0.12 migration supposed to work? That could become quite nasty too. But maybe that is impossible anyway due to the switch to seabios?

cheers,
Gerd

#27 lore raw
Quoted 9 lines · Gerd Hoffmann
Quoted 4 lines · Anthony Liguori

I know this series carries a good bit of risk but I'd like to bring it in 0.12.0. Because this has a guest visible change to the PCI devices, we cannot carry it in stable-0.12 post release and I think the functionality it brings it's very important.

The guest visible change automatically raises the question:
Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Yes, we do. We can fix that problem as a stable-0.12 update though. Right now, migration with pc-0.11 is broken in other areas too.

Quoted 1 line

Oh, and while thinking about compatibility issues: What about migration? I think we have to save rom_offset in case $pcidevice has a rom bar, otherwise your roms are gone after migration. Which you wouldn't notice until reboot though.

It's really unclear to me the best way to handle live migration. The rom_offset is not enough because unfortunately it's not stable after invocations of qemu. I think we're going to have to actually save the some contents with the PCIDevices.

For 0.13, we need to change the way that we migrate memory to fix this problem properly.

Quoted 1 line

Is 0.11 -> 0.12 migration supposed to work? That could become quite nasty too. But maybe that is impossible anyway due to the switch to seabios?

In theory, it should work. SeaBIOS should not be a guest visible change because the guest should not depend on what BIOS we're using. While it's probably debatable about whether that's true, what's really important is whether it's actually functional. IOW, can we migrate, reboot Windows, and not have Windows freak out about the underlying machine changing.

If we can make the migration work, I suspect it won't be until 0.12.3 or 0.12.4.

Regards,

Anthony Liguori

#28 lore raw
Quoted 5 lines · Anthony Liguori
Quoted 2 lines

Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Yes, we do. We can fix that problem as a stable-0.12 update though. Right now, migration with pc-0.11 is broken in other areas too.

Ok. When it is fine to defer this to stable-0.12 then I have no objections to merge it for 0.12 (assuming the seabios folks ack+merge the seabios changes).

Note that I'll be offline for x-mas and newyear starting tomorrow, so I will not be able to work on that until January.

Quoted 4 lines

It's really unclear to me the best way to handle live migration. The rom_offset is not enough because unfortunately it's not stable after invocations of qemu. I think we're going to have to actually save the some contents with the PCIDevices.

With hotplug this will become a issue indeed.

Quoted 6 lines
Quoted 3 lines

Is 0.11 -> 0.12 migration supposed to work? That could become quite nasty too. But maybe that is impossible anyway due to the switch to seabios?

In theory, it should work. SeaBIOS should not be a guest visible change because the guest should not depend on what BIOS we're using.

Indeed. In theory even the switch of the option rom loading should work just fine. After migration old bios and roms are still in memory, the next reboot will be the world switch to new seabios, new roms, new way to deploy roms and everything.

Lets see how this works out in practice ...

cheers,
Gerd

#29 lore raw
Quoted 8 lines · Gerd Hoffmann
Quoted 5 lines · Anthony Liguori
Quoted 2 lines

Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Yes, we do. We can fix that problem as a stable-0.12 update though. Right now, migration with pc-0.11 is broken in other areas too.

Ok. When it is fine to defer this to stable-0.12 then I have no objections to merge it for 0.12 (assuming the seabios folks ack+merge the seabios changes).

Note, I also needed this to quiet things a bit.

hw/fw_cfg.c +2 -2
index 0492f5f..fe9c527 100644
@@ -309,8 +309,8 @@ int fw_cfg_add_file(FWCfgState *s,  const char *dir, const c
    }
    s->files->f[index].size   = cpu_to_be32(len);
    s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
-    fprintf(stderr, "%s: #%d: %s (%d bytes)\n", __FUNCTION__,
-            index, s->files->f[index].name, len);
+    FW_CFG_DPRINTF("%s: #%d: %s (%d bytes)\n", __FUNCTION__,
+                   index, s->files->f[index].name, len);
 
    s->files->count = cpu_to_be32(index+1);
    return 1;
Quoted 1 line

Note that I'll be offline for x-mas and newyear starting tomorrow, so I will not be able to work on that until January.

No problem.

Quoted 6 lines
Quoted 4 lines

It's really unclear to me the best way to handle live migration. The rom_offset is not enough because unfortunately it's not stable after invocations of qemu. I think we're going to have to actually save the some contents with the PCIDevices.

With hotplug this will become a issue indeed.

Yup.

Quoted 1 line

Lets see how this works out in practice ...

BTW, the following works:

sudo x86_64-softmmu/qemu-system-x86_64 -hda ~/images/linux.img -snapshot -m 512 -net nic,model=rtl8139,macaddr=56:54:32:12:34:56 -net nic,model=e1000,macaddr=56:54:32:12:34:57 -net nic,model=virtio,macaddr=56:54:32:12:34:58 -boot menu=on -net tap -kernel /boot/vmlinuz-2.6.27.38-170.2.113.fc10.x86_64 -initrd /boot/initrd-2.6.27.38-170.2.113.fc10.x86_64.img -append "ro"

Using the F12 menu, I can select any of the three option roms and it network boots or I can select 'Legacy Option ROM' and it will boot from -kernel. That is exceedingly cool :-) We just need to give it a proper PnP header and advertise it as a BEV device so that we can give it a meaningful name.

Regards,

Anthony Liguori

#30 lore raw
Quoted 9 lines · Anthony Liguori

BTW, the following works:

sudo x86_64-softmmu/qemu-system-x86_64 -hda ~/images/linux.img -snapshot -m 512 -net nic,model=rtl8139,macaddr=56:54:32:12:34:56 -net nic,model=e1000,macaddr=56:54:32:12:34:57 -net nic,model=virtio,macaddr=56:54:32:12:34:58 -boot menu=on -net tap -kernel /boot/vmlinuz-2.6.27.38-170.2.113.fc10.x86_64 -initrd /boot/initrd-2.6.27.38-170.2.113.fc10.x86_64.img -append "ro"

Quoted 5 lines

Using the F12 menu, I can select any of the three option roms and it network boots or I can select 'Legacy Option ROM' and it will boot from -kernel. That is exceedingly cool :-) We just need to give it a proper PnP header and advertise it as a BEV device so that we can give it a meaningful name.

As it stands now, if the command line has -kernel, it will always boot from the kernel regardless of the item one selects in the boot menu. (Legacy roms are always run - the boot menu only selects the order wrt BCVs.) However, converting the rom into a BEV will indeed make it selectable.

Also, to see a truly interesting boot menu - try appending something like the following to the command line:

-fda disk.dsk -fdb odin1440.img -hdd dos-drivec -cdrom ../../iso/win-vista.iso -drive file=../../iso/win-xp.iso,media=cdrom,index=1

SeaBIOS allows one to boot from either floppy, any harddrive, and any cdrom.

-Kevin

#31 lore raw
Quoted 10 lines · Kevin O'Connor
Quoted 8 lines · Anthony Liguori

BTW, the following works:

sudo x86_64-softmmu/qemu-system-x86_64 -hda ~/images/linux.img -snapshot
-m 512 -net nic,model=rtl8139,macaddr=56:54:32:12:34:56 -net nic,model=e1000,macaddr=56:54:32:12:34:57 -net nic,model=virtio,macaddr=56:54:32:12:34:58 -boot menu=on -net tap -kernel /boot/vmlinuz-2.6.27.38-170.2.113.fc10.x86_64 -initrd /boot/initrd-2.6.27.38-170.2.113.fc10.x86_64.img -append "ro"

Quoted 8 lines
Quoted 4 lines

Using the F12 menu, I can select any of the three option roms and it network boots or I can select 'Legacy Option ROM' and it will boot from -kernel. That is exceedingly cool :-) We just need to give it a proper
PnP header and advertise it as a BEV device so that we can give it a meaningful name.

As it stands now, if the command line has -kernel, it will always boot from the kernel regardless of the item one selects in the boot menu.

Ah, I spoke too soon, you are indeed correct.

I was wondering how that could possibly work :-)

Quoted 4 lines

(Legacy roms are always run - the boot menu only selects the order wrt BCVs.) However, converting the rom into a BEV will indeed make it selectable.

Quoted 8 lines

Also, to see a truly interesting boot menu - try appending something like the following to the command line:

-fda disk.dsk -fdb odin1440.img -hdd dos-drivec -cdrom ../../iso/win-vista.iso -drive file=../../iso/win-xp.iso,media=cdrom,index=1

SeaBIOS allows one to boot from either floppy, any harddrive, and any cdrom.

Very cool stuff! We just have to figure out a way to let a user specify which of these devices they want to boot from via the qemu command line. Maybe something that encodes a bus type and then an address on the bus or something like that. I think that works okay for PCI and IDE buses. For fw_cfg roms, I guess we could also just expose the filename as the address on the fw_cfg bus.

Regards,

Anthony Liguori

#32 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann
Quoted 6 lines
Quoted 3 lines

Is 0.11 -> 0.12 migration supposed to work? That could become quite nasty too. But maybe that is impossible anyway due to the switch to seabios?

In theory, it should work. SeaBIOS should not be a guest visible change because the guest should not depend on what BIOS we're using.

Indeed. In theory even the switch of the option rom loading should work just fine. After migration old bios and roms are still in memory, the next reboot will be the world switch to new seabios, new roms, new way to deploy roms and everything.

Lets see how this works out in practice ...

BTW, I've got the series in staging now and am testing it. I've folded in the changes we've passed around and updated the commit log appropriately.

If you've got additional changes, please send them out, otherwise, let me know if you're happy with what's in staging.

Regards,

Anthony Liguori

Quoted 3 lines

cheers,
Gerd

#33 lore raw
Quoted 2 lines · Anthony Liguori

If you've got additional changes, please send them out, otherwise, let me know if you're happy with what's in staging.

Looks good.

cheers,
Gerd

#34 lore raw
In reply to Gerd Hoffmann
Quoted 8 lines · Gerd Hoffmann
Quoted 5 lines · Anthony Liguori
Quoted 2 lines

Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Yes, we do. We can fix that problem as a stable-0.12 update though. Right now, migration with pc-0.11 is broken in other areas too.

Ok. When it is fine to defer this to stable-0.12 then I have no objections to merge it for 0.12 (assuming the seabios folks ack+merge the seabios changes).

0.12 will contain known regressions?

Quoted 15 lines

Note that I'll be offline for x-mas and newyear starting tomorrow, so I will not be able to work on that until January.

Quoted 4 lines

It's really unclear to me the best way to handle live migration. The rom_offset is not enough because unfortunately it's not stable after invocations of qemu. I think we're going to have to actually save the some contents with the PCIDevices.

With hotplug this will become a issue indeed.

Quoted 6 lines
Quoted 3 lines

Is 0.11 -> 0.12 migration supposed to work? That could become quite nasty too. But maybe that is impossible anyway due to the switch to seabios?

In theory, it should work. SeaBIOS should not be a guest visible change because the guest should not depend on what BIOS we're using.

If SeaBIOS would not have any regressions compared to Bochs BIOS then maybe.

Quoted 1 line

Indeed. In theory even the switch of the option rom loading should work just fine. After migration old bios and roms are still in memory, the next reboot will be the world switch to new seabios, new roms, new way to deploy roms and everything.

Automagical "world switch" on reboot sounds like a nightmare. The VM environment should be stable during reboots and only change if requested by the user.

- Sebastian

#35 lore raw
Quoted 11 lines · Sebastian Herbszt
Quoted 8 lines · Gerd Hoffmann
Quoted 5 lines · Anthony Liguori
Quoted 2 lines

Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Yes, we do. We can fix that problem as a stable-0.12 update though. Right now, migration with pc-0.11 is broken in other areas too.

Ok. When it is fine to defer this to stable-0.12 then I have no objections to merge it for 0.12 (assuming the seabios folks ack+merge the seabios changes).

0.12 will contain known regressions?

Migrating between versions is not a regression.

Quoted 1 line

If SeaBIOS would not have any regressions compared to Bochs BIOS then maybe.

Does it? I'm not aware of any SeaBIOS regressions.

Quoted 4 lines
Quoted 1 line

Indeed. In theory even the switch of the option rom loading should work just fine. After migration old bios and roms are still in memory, the next reboot will be the world switch to new seabios, new roms, new way to deploy roms and everything.

Automagical "world switch" on reboot sounds like a nightmare. The VM environment should be stable during reboots and only change if requested by the user.

That's extremely difficult to support.

Regards,

Anthony Liguori

#36 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 10 lines · Sebastian Herbszt
Quoted 8 lines · Gerd Hoffmann
Quoted 5 lines · Anthony Liguori
Quoted 2 lines

Do we need to do something for -M pc-0.11? Like loading the pci roms via fw_cfg too so the guest doesn't see the new pci rom bar?

Yes, we do. We can fix that problem as a stable-0.12 update though. Right now, migration with pc-0.11 is broken in other areas too.

Ok. When it is fine to defer this to stable-0.12 then I have no objections to merge it for 0.12 (assuming the seabios folks ack+merge the seabios changes).

Quoted 7 lines
Quoted 1 line

0.12 will contain known regressions?

Migrating between versions is not a regression.

Quoted 1 line

If SeaBIOS would not have any regressions compared to Bochs BIOS then maybe.

Does it? I'm not aware of any SeaBIOS regressions.

E.g. BIOS32 and INT 15h function 89h.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Indeed. In theory even the switch of the option rom loading should work just fine. After migration old bios and roms are still in memory, the next reboot will be the world switch to new seabios, new roms, new way to deploy roms and everything.

Automagical "world switch" on reboot sounds like a nightmare. The VM environment should be stable during reboots and only change if requested by the user.

That's extremely difficult to support.

Isn't this what VMotion supports?

- Sebastian

#37 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Quoted 9 lines

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Seabios patches will be posted shortly as separate patch series.

I see that this is merged already, but I have a question. How migration during ROM loading suppose to work? What will happed if we migrate to newer qemu with updated vgabios ROM while BIOS is in the middle of loading it on the source? It seems that destination will have garbled ROM loaded.

--
Gleb.

#38 lore raw
Quoted 19 lines · Gleb Natapov
Quoted 17 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Quoted 5 lines
Quoted 3 lines

Seabios patches will be posted shortly as separate patch series.

I see that this is merged already, but I have a question. How migration during ROM loading suppose to work?

Magically :-)

Really, we have a fundamentally problem with live migration (that's orthogonal to this series). We allocate memory via qemu_ram_alloc() but we don't have any context to that allocation. When we migrate memory, we do so by transferring ram basically in allocation order.

If for some reason allocation order changes, badness ensues. The problem is, a lot of devices use qemu_ram_alloc() now and they do so when they are initialized so the stability of the allocation depends on the initialization order. It's exacerbated by things like PCI hotplug.

We need to make a change in the live migration protocol that transfers memory identified with tuples (id, chunk offset). We'll need to change every qemu_ram_alloc() to take an id argument too.

Quoted 4 lines

What will happed if we migrate to newer
qemu with updated vgabios ROM while BIOS is in the middle of loading it on the source? It seems that destination will have garbled ROM loaded.

During device init, pci device allocates memory, loads rom into allocated memory. Upon live migration, allocated memory gets over written by rom contents from source. So in this case, it will actually work today (assuming you get stable ram allocation offsets).

Regards,

Anthony Liguori

#39 lore raw
Quoted 45 lines · Anthony Liguori
Quoted 14 lines · Gleb Natapov
Quoted 13 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

Quoted 8 lines
Quoted 6 lines

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Seabios patches will be posted shortly as separate patch series.

I see that this is merged already, but I have a question. How migration during ROM loading suppose to work?

Magically :-)

Really, we have a fundamentally problem with live migration (that's orthogonal to this series). We allocate memory via qemu_ram_alloc() but we don't have any context to that allocation. When we migrate memory, we do so by transferring ram basically in allocation order.

If for some reason allocation order changes, badness ensues. The problem is, a lot of devices use qemu_ram_alloc() now and they do so when they are initialized so the stability of the allocation depends on the initialization order. It's exacerbated by things like PCI hotplug.

We need to make a change in the live migration protocol that transfers memory identified with tuples (id, chunk offset). We'll need to change every qemu_ram_alloc() to take an id argument too.

Quoted 3 lines

What will happed if we migrate to newer
qemu with updated vgabios ROM while BIOS is in the middle of loading it on the source? It seems that destination will have garbled ROM loaded.

Quoted 6 lines

During device init, pci device allocates memory, loads rom into allocated memory. Upon live migration, allocated memory gets over written by rom contents from source. So in this case, it will actually work today (assuming you get stable ram allocation offsets).

That much I noticed :), but first after reboot new ROMs should take effect. Does this happed? Second what if ROM size have changed (on destination it is smaller)? And third what about roms that are loaded with fw_cfg interface (me mentioning vgabios was not accident :))

--
Gleb.

#40 lore raw
Quoted 58 lines · Gleb Natapov
Quoted 49 lines · Anthony Liguori
Quoted 19 lines · Gleb Natapov
Quoted 17 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Quoted 6 lines
Quoted 3 lines

Seabios patches will be posted shortly as separate patch series.

I see that this is merged already, but I have a question. How migration during ROM loading suppose to work?

Magically :-)

Really, we have a fundamentally problem with live migration (that's orthogonal to this series). We allocate memory via qemu_ram_alloc() but we don't have any context to that allocation. When we migrate memory, we do so by transferring ram basically in allocation order.

If for some reason allocation order changes, badness ensues. The problem is, a lot of devices use qemu_ram_alloc() now and they do so when they are initialized so the stability of the allocation depends on the initialization order. It's exacerbated by things like PCI hotplug.

We need to make a change in the live migration protocol that transfers memory identified with tuples (id, chunk offset). We'll need to change every qemu_ram_alloc() to take an id argument too.

Quoted 4 lines

What will happed if we migrate to newer
qemu with updated vgabios ROM while BIOS is in the middle of loading it on the source? It seems that destination will have garbled ROM loaded.

Quoted 7 lines

During device init, pci device allocates memory, loads rom into allocated memory. Upon live migration, allocated memory gets over written by rom contents from source. So in this case, it will actually work today (assuming you get stable ram allocation offsets).

Quoted 2 lines

That much I noticed :), but first after reboot new ROMs should take effect. Does this happed?

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Quoted 2 lines

Second what if ROM size have changed (on destination it is
smaller)?

Then we're in trouble :-)

Quoted 3 lines

And third what about roms that are loaded with fw_cfg interface (me
mentioning vgabios was not accident :))

vgabios will be loaded as a PCI rom. -std vga still uses fw_cfg but that's a really easy fix.

But the fw_cfg rom loading doesn't seem handle migration :-/

Regards,

Anthony Liguori

#41 lore raw
Quoted 51 lines · Anthony Liguori
Quoted 50 lines · Gleb Natapov
Quoted 49 lines · Anthony Liguori
Quoted 14 lines · Gleb Natapov
Quoted 13 lines · Gerd Hoffmann

From: Anthony Liguori <[email protected]>

Hi,

Option rom saga continued. This is the first series I consider ready for merging. Changes:

* pci roms: will be loaded via option pci rom bar.
* non-pci roms: will be loaded via fw_cfg.

Note that using the old bochs-bios based pc-bios will stop working with this patch series applied.

Quoted 8 lines
Quoted 6 lines

The last two patches of this series are *not* intended to be merged, they are just for testing convinience. They carry a new seabios binary and the changes needed and turn on bios debug messages in qemu.

Seabios patches will be posted shortly as separate patch series.

I see that this is merged already, but I have a question. How migration during ROM loading suppose to work?

Magically :-)

Really, we have a fundamentally problem with live migration (that's orthogonal to this series). We allocate memory via qemu_ram_alloc() but we don't have any context to that allocation. When we migrate memory, we do so by transferring ram basically in allocation order.

If for some reason allocation order changes, badness ensues. The problem is, a lot of devices use qemu_ram_alloc() now and they do so when they are initialized so the stability of the allocation depends on the initialization order. It's exacerbated by things like PCI hotplug.

We need to make a change in the live migration protocol that transfers memory identified with tuples (id, chunk offset). We'll need to change every qemu_ram_alloc() to take an id argument too.

Quoted 3 lines

What will happed if we migrate to newer
qemu with updated vgabios ROM while BIOS is in the middle of loading it on the source? It seems that destination will have garbled ROM loaded.

During device init, pci device allocates memory, loads rom into allocated memory. Upon live migration, allocated memory gets over written by rom contents from source. So in this case, it will actually work today (assuming you get stable ram allocation offsets).

Quoted 6 lines
Quoted 2 lines

That much I noticed :), but first after reboot new ROMs should take effect. Does this happed?

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Reset is equivalent (or should be) to shut down and start up again.

Quoted 5 lines
Quoted 2 lines

Second what if ROM size have changed (on destination it is smaller)?

Then we're in trouble :-)

Yeah, we are. May be relaying on file size is not good enough heuristic to determine ROM BAR size.

Quoted 5 lines
Quoted 2 lines

And third what about roms that are loaded with fw_cfg interface (me mentioning vgabios was not accident :))

vgabios will be loaded as a PCI rom. -std vga still uses fw_cfg but that's a really easy fix.

I mean -std vga and other "genroms" (multiboot, linuxboot, vapic).

Quoted 3 lines

But the fw_cfg rom loading doesn't seem handle migration :-/

Looks like it. We should send them over during migration too.

--
Gleb.

#42 lore raw
Quoted 8 lines · Gleb Natapov
Quoted 4 lines · Anthony Liguori

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Reset is equivalent (or should be) to shut down and start up again.

Not at all. Reset can happen in a lot of different ways, some that there is really no way to detect (jumping right to BIOS vector). From a hardware perspective, powering down a CPU and powering it on again behaves very differently than reset (consider the VT enablement MSRs).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Second what if ROM size have changed (on destination it is smaller)?

Then we're in trouble :-)

Yeah, we are. May be relaying on file size is not good enough heuristic to determine ROM BAR size.

Practically speaking, I don't think it's a huge problem to be honest. It's a very unlikely scenario. We could make the rom size a qdev property which would allow a user to explicitly deal with this case.

Quoted 5 lines
Quoted 3 lines

But the fw_cfg rom loading doesn't seem handle migration :-/

Looks like it. We should send them over during migration too.

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Regards,

Anthony Liguori

#43 lore raw
Quoted 2 lines · Anthony Liguori

Not at all. Reset can happen in a lot of different ways, some that there is really no way to detect (jumping right to BIOS vector). From a hardware perspective, powering down a CPU and powering it on again behaves very differently than reset (consider the VT enablement MSRs).

Power down and reset are equivalent, you're thinking of INIT (though some boards wire reset to INIT).

Quoted 1 line

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Currently live migration uses ram_addrs, so this would work. But ram_addrs have no meaning in the guest and thus depend on qemu implementation details. IMO we should switch live migration to use guest physical addresses, which would require a different migration implementation for roms. Most of it can be shared with ram, though.

Signature · 1 line
error compiling committee.c: too many arguments to function
#44 lore raw
Quoted 3 lines · Avi Kivity
Quoted 1 line

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Currently live migration uses ram_addrs, so this would work. But ram_addrs have no meaning in the guest and thus depend on qemu implementation details. IMO we should switch live migration to use guest physical addresses, which would require a different migration implementation for roms. Most of it can be shared with ram, though.

I'd rather do (id, offset) instead of guest physical address. Guest physical addresses map to ram_addrs in chunks. Each chunk usually has some reasonable identification (below 640k, above 1mb, above 4gb, etc.). Other type of memory like roms and vga lfb memory aren't always part of the guest physical address space but nonetheless still need to be migrated. This gives us one mechanism to support everything.

Regards,

Anthony Liguori

#45 lore raw
Quoted 7 lines · Anthony Liguori
Quoted 3 lines · Avi Kivity
Quoted 1 line

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Currently live migration uses ram_addrs, so this would work. But ram_addrs have no meaning in the guest and thus depend on qemu implementation details. IMO we should switch live migration to use guest physical addresses, which would require a different migration implementation for roms. Most of it can be shared with ram, though.

I'd rather do (id, offset) instead of guest physical address. Guest physical addresses map to ram_addrs in chunks. Each chunk usually has some reasonable identification (below 640k, above 1mb, above 4gb, etc.). Other type of memory like roms and vga lfb memory aren't always part of the guest physical address space but nonetheless still need to be migrated. This gives us one mechanism to support everything.

What about hotplugged memory? I guess we can introduce the notion of user-visible memory slots; those exist on real hardware as well. These slots would be different from the kvm memory slots, of course.

ids do have a nice property in that pci memory can be migrated while its BAR changes. With gpa you'd need special handling.

Signature · 1 line
error compiling committee.c: too many arguments to function
#46 lore raw
In reply to Avi Kivity
Quoted 10 lines
Quoted 4 lines

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Currently live migration uses ram_addrs, so this would work. But ram_addrs have no meaning in the guest and thus depend on qemu implementation details. IMO we should switch live migration to use guest physical addresses, which would require a different migration implementation for roms. Most of it can be shared with ram, though.

Ram allocations should be associated with a device. The VMState stuff this should make this fairly straightforward.

Guest address space mappings are a completely separate issue. The device should be migrating the mappings (directly or via a PCI BAR) as part of its state migration. The ram regions might not be mapped into guest address space at all.

Paul

#47 lore raw
Quoted 11 lines · Paul Brook
Quoted 11 lines
Quoted 5 lines

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Currently live migration uses ram_addrs, so this would work. But ram_addrs have no meaning in the guest and thus depend on qemu implementation details. IMO we should switch live migration to use guest physical addresses, which would require a different migration implementation for roms. Most of it can be shared with ram, though.

Quoted 8 lines

Ram allocations should be associated with a device. The VMState stuff this should make this fairly straightforward.

Guest address space mappings are a completely separate issue. The device should be migrating the mappings (directly or via a PCI BAR) as part of its state migration. The ram regions might not be mapped into guest address space at all.

Yes, this is essentially Anthony's reply (which I agree with).

Signature · 1 line
error compiling committee.c: too many arguments to function
#48 lore raw
In reply to Paul Brook
Quoted 5 lines · Paul Brook
Quoted 5 lines
Quoted 5 lines

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

Quoted 9 lines
Quoted 6 lines

Currently live migration uses ram_addrs, so this would work. But ram_addrs have no meaning in the guest and thus depend on qemu implementation details. IMO we should switch live migration to use guest physical addresses, which would require a different migration implementation for roms. Most of it can be shared with ram, though.

Ram allocations should be associated with a device. The VMState stuff this should make this fairly straightforward.

Right, but for the sake of simplicity, you don't want to treat that ram any differently than main ram wrt live migration. That's why I proposed adding a context id for each ram region. That would allow us to use something like the qdev name + id as the context id for a ram chunk to get that association while still doing live ram migration of the memory.

Quoted 5 lines

Guest address space mappings are a completely separate issue. The device should be migrating the mappings (directly or via a PCI BAR) as part of its state migration. The ram regions might not be mapped into guest address space at all.

We don't migrate guest address space memory today. We migrate anything that's qemu_ram_alloc()'d. The big problem we have though is that we don't have any real association between the qemu_ram_alloc() results and what the context of the allocation was. We assume the order of these allocations are fixed and that's entirely wrong.

For non-device qemu_ram_alloc()'s, we could either create essentially dummy ram devices or we could just special case it.

Regards,

Anthony Liguori

Quoted 2 lines

Paul

#49 lore raw
Quoted 8 lines
Quoted 2 lines

Ram allocations should be associated with a device. The VMState stuff this should make this fairly straightforward.

Right, but for the sake of simplicity, you don't want to treat that ram any differently than main ram wrt live migration. That's why I proposed adding a context id for each ram region. That would allow us to use something like the qdev name + id as the context id for a ram chunk to get that association while still doing live ram migration of the memory.

IMO the best way to do this is to do it via existing VMState machinery. We've already matched up DeviceStates so this gets us a handy unique identifier for every ram block. For system memory we can add a dummy device. Medium term we're probably going to want this anyway.

Quoted 10 lines
Quoted 4 lines

Guest address space mappings are a completely separate issue. The device should be migrating the mappings (directly or via a PCI BAR) as part of its state migration. The ram regions might not be mapped into guest address space at all.

We don't migrate guest address space memory today. We migrate anything that's qemu_ram_alloc()'d. The big problem we have though is that we don't have any real association between the qemu_ram_alloc() results and what the context of the allocation was. We assume the order of these allocations are fixed and that's entirely wrong.

The nice thing about the VMState approach is that the device doesn't know or care how the migration occurs. For bonus points it leads fairly directly to an object based mapping API, so we can change the implementation or migrate the ram to a different location without disturbing the device.

Paul

#50 lore raw
Quoted 9 lines · Paul Brook
Quoted 9 lines
Quoted 3 lines

Ram allocations should be associated with a device. The VMState stuff this should make this fairly straightforward.

Right, but for the sake of simplicity, you don't want to treat that ram any differently than main ram wrt live migration. That's why I proposed adding a context id for each ram region. That would allow us to use something like the qdev name + id as the context id for a ram chunk to get that association while still doing live ram migration of the memory.

Quoted 5 lines

IMO the best way to do this is to do it via existing VMState machinery. We've already matched up DeviceStates so this gets us a handy unique identifier for every ram block. For system memory we can add a dummy device. Medium term we're probably going to want this anyway.

Okay, I understand and agree.

I think the way this would work is that we would have a ram_addr type for VMState that would be an actual ram allocation and size. qemu_ram_alloc() would not need to take a context. ram live migration would walk the list of registered VMState entries searching for anything that had a ram_addr type and would add that to the ram migration.

For system ram, we need dummy devices.

I think we probably ought to integrate VMState into qdev first though. I think that makes everything a bit more managable.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

Guest address space mappings are a completely separate issue. The device should be migrating the mappings (directly or via a PCI BAR) as part of its state migration. The ram regions might not be mapped into guest address space at all.

We don't migrate guest address space memory today. We migrate anything that's qemu_ram_alloc()'d. The big problem we have though is that we don't have any real association between the qemu_ram_alloc() results and what the context of the allocation was. We assume the order of these allocations are fixed and that's entirely wrong.

Quoted 5 lines

The nice thing about the VMState approach is that the device doesn't know or care how the migration occurs. For bonus points it leads fairly directly to an object based mapping API, so we can change the implementation or migrate the ram to a different location without disturbing the device.

Yeah, I like it.

Regards,

Anthony Liguori

Quoted 2 lines

Paul

#51 lore raw
In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Gleb Natapov
Quoted 3 lines · Anthony Liguori

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Reset is equivalent (or should be) to shut down and start up again.

Not at all. Reset can happen in a lot of different ways, some that

We support only one way of reset: hard reset. It equivalent to full HW power cycling. ACPI spec define ACPI reset as equivalent to HW power cycling too BTW (see 4.7.3.6).

Quoted 1 line

there is really no way to detect (jumping right to BIOS vector).

This is not reset at all from qemu POV. No need to reload ROMS.

Quoted 3 lines

From a hardware perspective, powering down a CPU and powering it on again behaves very differently than reset (consider the VT enablement MSRs).

May be you are confusing cpu reset by INIT with CPU reset by power cycling. system_reset (or triple fault or kbd reset or ACPI reset) does the later.

Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Second what if ROM size have changed (on destination it is smaller)?

Then we're in trouble :-)

Yeah, we are. May be relaying on file size is not good enough heuristic to determine ROM BAR size.

Practically speaking, I don't think it's a huge problem to be honest. It's a very unlikely scenario. We could make the rom size a qdev property which would allow a user to explicitly deal with this case.

Agree that it is unlikely, but I don't want to be the one debugging it.

Quoted 10 lines
Quoted 4 lines
Quoted 3 lines

But the fw_cfg rom loading doesn't seem handle migration :-/

Looks like it. We should send them over during migration too.

We should just qemu_ram_alloc() that memory regardless of whether we every map it into the guest. Since roms can be large, we want to send their contents over during the live part of migration. If we use qemu_ram_alloc(), we get that for free.

This will work only if we assume that rom file size doesn't shrink,

--
Gleb.

#52 lore raw
Quoted 10 lines · Gleb Natapov
Quoted 8 lines · Anthony Liguori
Quoted 6 lines · Gleb Natapov
Quoted 4 lines · Anthony Liguori

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Reset is equivalent (or should be) to shut down and start up again.

Not at all. Reset can happen in a lot of different ways, some that

We support only one way of reset: hard reset. It equivalent to full HW power cycling. ACPI spec define ACPI reset as equivalent to HW power cycling too BTW (see 4.7.3.6).

For every system periphereal? For instance, memory contents survive a reset whereas they won't survive a hard power down.

More importantly though, what's the use-case here?

Quoted 1 line

This will work only if we assume that rom file size doesn't shrink,

Well the easy thing to do is hard code the rom size into qemu and throw an error if the rom size increases. That way, if a rom does shrink, we're safe and if a rom size increases, we get an immediate run time error that gives the contributor feed back that they need to bump the constant.

Regards,

Anthony Liguori

Quoted 5 lines

--
Gleb.

#53 lore raw
Quoted 7 lines · Anthony Liguori
Quoted 6 lines · Gleb Natapov
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Gleb Natapov
Quoted 3 lines · Anthony Liguori

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Reset is equivalent (or should be) to shut down and start up again.

Not at all. Reset can happen in a lot of different ways, some that

We support only one way of reset: hard reset. It equivalent to full HW power cycling. ACPI spec define ACPI reset as equivalent to HW power cycling too BTW (see 4.7.3.6).

For every system periphereal?

To cite ACPI spec : "From an OSPM perspective, asserting the reset mechanism is the logical equivalent to power cycling the machine."

Quoted 3 lines

For instance, memory contents survive
a reset whereas they won't survive a hard power down.

We cannot rely on memory content after such reset.

Quoted 2 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Quoted 8 lines
Quoted 1 line

This will work only if we assume that rom file size doesn't shrink,

Well the easy thing to do is hard code the rom size into qemu and throw an error if the rom size increases. That way, if a rom does shrink, we're safe and if a rom size increases, we get an immediate run time error that gives the contributor feed back that they need to bump the constant.

--
Gleb.

#54 lore raw
Quoted 6 lines · Gleb Natapov
Quoted 3 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Live migration is transparent to the guest. The fact that firmware can upgrade itself without the guest doing anything is not something that really has a real world equivalent.

Even if it did, whether that automatic upgrade happens after a reboot vs. a hard power cycle is irrelevant. The guest has no knowledge of the fact that the automatic firmware upgrade happened so if it gets delayed indefinitely, it doesn't matter.

It's not a matter of correctness IMHO.

I can understand an argument for predictability wrt wanted to be able to guarantee that after the first reboot during a live migration, you'll get the new firmware. I'm not sure that's less predictable then hard shutdown/start-up and I'm not sure I can really make an argument for one way vs. the other.

If anything, I can better understand the argument for not ever upgrading the firmware transparently. Something like having a nvram file that we load all of the ROMs into, then do live migration and migrate the nvram file. That would mean that we would have to be very careful in the future about supporting fw_cfg as a versioned interface.

We would also want to provide a mechanism for a user to manually upgrade the firmware from within a guest if we went this route.

Regards,

Anthony Liguori

#55 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 4 lines · Gleb Natapov
Quoted 2 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Live migration is transparent to the guest. The fact that firmware can upgrade itself without the guest doing anything is not something that really has a real world equivalent.

Quoted 7 lines

Even if it did, whether that automatic upgrade happens after a reboot vs. a hard power cycle is irrelevant. The guest has no knowledge of the fact that the automatic firmware upgrade happened so if it gets delayed indefinitely, it doesn't matter.

It's not a matter of correctness IMHO.

Ah now I see what you mean. New FW has to be used after reboot because old one may not be able to init HW any longer. Suppose some bug in cirrus emulation has being fixed and old vga bios should be accommodated to those changes, if old vga bios will run after reset video output may not work. Thinking about it we'll have the same problem if migration happens during vga bios loading, but this is MUCH less likely to happen.

Quoted 6 lines

I can understand an argument for predictability wrt wanted to be able to guarantee that after the first reboot during a live migration, you'll get the new firmware. I'm not sure that's less predictable then hard shutdown/start-up and I'm not sure I can really make an argument for one way vs. the other.

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

Quoted 6 lines

If anything, I can better understand the argument for not ever upgrading the firmware transparently. Something like having a nvram file that we load all of the ROMs into, then do live migration and migrate the nvram file. That would mean that we would have to be very careful in the future about supporting fw_cfg as a versioned interface.

This will prevent us from fixing bugs/adding features.

Quoted 7 lines

We would also want to provide a mechanism for a user to manually upgrade the firmware from within a guest if we went this route.

Regards,

Anthony Liguori

--
Gleb.

#56 lore raw
Quoted 31 lines · Gleb Natapov
Quoted 10 lines · Anthony Liguori
Quoted 4 lines · Gleb Natapov
Quoted 2 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Live migration is transparent to the guest.  The fact that firmware can upgrade itself without the guest doing anything is not something that really has a real world equivalent.

Quoted 7 lines

Even if it did, whether that automatic upgrade happens after a reboot vs. a hard power cycle is irrelevant.  The guest has no knowledge of the fact that the automatic firmware upgrade happened so if it gets delayed indefinitely, it doesn't matter.

It's not a matter of correctness IMHO.

Ah now I see what you mean. New FW has to be used after reboot because old one may not be able to init HW any longer. Suppose some bug in cirrus emulation has being fixed and old vga bios should be accommodated to those changes, if old vga bios will run after reset video output may not work. Thinking about it we'll have the same problem if migration happens during vga bios loading, but this is MUCH less likely to happen.

Quoted 6 lines

I can understand an argument for predictability wrt wanted to be able to guarantee that after the first reboot during a live migration, you'll get the new firmware.  I'm not sure that's less predictable then hard shutdown/start-up and I'm not sure I can really make an argument for one way vs. the other.

Quoted 3 lines

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

Some devices are careful enough to implement warm reset using a flag, see for example hw/sun4u.c. If you want more precision, you could introduce for example system_off_on with the memory clearing behavior you want.

#57 lore raw
Quoted 32 lines · Blue Swirl
Quoted 31 lines · Gleb Natapov
Quoted 10 lines · Anthony Liguori
Quoted 4 lines · Gleb Natapov
Quoted 2 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Live migration is transparent to the guest.  The fact that firmware can upgrade itself without the guest doing anything is not something that really has a real world equivalent.

Quoted 7 lines

Even if it did, whether that automatic upgrade happens after a reboot vs. a hard power cycle is irrelevant.  The guest has no knowledge of the fact that the automatic firmware upgrade happened so if it gets delayed indefinitely, it doesn't matter.

It's not a matter of correctness IMHO.

Ah now I see what you mean. New FW has to be used after reboot because old one may not be able to init HW any longer. Suppose some bug in cirrus emulation has being fixed and old vga bios should be accommodated to those changes, if old vga bios will run after reset video output may not work. Thinking about it we'll have the same problem if migration happens during vga bios loading, but this is MUCH less likely to happen.

Quoted 6 lines

I can understand an argument for predictability wrt wanted to be able to guarantee that after the first reboot during a live migration, you'll get the new firmware.  I'm not sure that's less predictable then hard shutdown/start-up and I'm not sure I can really make an argument for one way vs. the other.

Quoted 8 lines
Quoted 3 lines

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

Some devices are careful enough to implement warm reset using a flag, see for example hw/sun4u.c. If you want more precision, you could introduce for example system_off_on with the memory clearing behavior you want.

I am not familiar with other architectures. All I am saying applies to IBM PC only. Of course it is possible to design a system that impossible to reset completely from software or by pushing reset button. (To design general purpose computer like that one should be braindead though). On IBM PC there are ways to reset different parts of the system and there are ways to completely reset the system. We support only the later and ACPI spec mandates this kind of reset if reset is done via ACPI.

--
Gleb.

#58 lore raw

2009/12/20 Gleb Natapov <[email protected]>:

Quoted 41 lines · Blue Swirl
Quoted 32 lines · Gleb Natapov
Quoted 31 lines · Anthony Liguori
Quoted 10 lines
Quoted 4 lines · Gleb Natapov
Quoted 2 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Live migration is transparent to the guest.  The fact that firmware can upgrade itself without the guest doing anything is not something that really has a real world equivalent.

Quoted 7 lines

Even if it did, whether that automatic upgrade happens after a reboot vs. a hard power cycle is irrelevant.  The guest has no knowledge of the fact that the automatic firmware upgrade happened so if it gets delayed indefinitely, it doesn't matter.

It's not a matter of correctness IMHO.

Ah now I see what you mean. New FW has to be used after reboot because old one may not be able to init HW any longer. Suppose some bug in cirrus emulation has being fixed and old vga bios should be accommodated to those changes, if old vga bios will run after reset video output may not work. Thinking about it we'll have the same problem if migration happens during vga bios loading, but this is MUCH less likely to happen.

Quoted 6 lines

I can understand an argument for predictability wrt wanted to be able to guarantee that after the first reboot during a live migration, you'll get the new firmware.  I'm not sure that's less predictable then hard shutdown/start-up and I'm not sure I can really make an argument for one way vs. the other.

Quoted 8 lines
Quoted 3 lines

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

Some devices are careful enough to implement warm reset using a flag, see for example hw/sun4u.c. If you want more precision, you could introduce for example system_off_on with the memory clearing behavior you want.

Quoted 7 lines

I am not familiar with other architectures. All I am saying applies to IBM PC only. Of course it is possible to design a system that impossible to reset completely from software or by pushing reset button. (To design general purpose computer like that one should be braindead though). On IBM PC there are ways to reset different parts of the system and there are ways to completely reset the system. We support only the later and ACPI spec mandates this kind of reset if reset is done via ACPI.

Then hw/pc.c could install a reset handler that clears all memory etc.

#59 lore raw
In reply to Gleb Natapov
Quoted 5 lines · Gleb Natapov
Quoted 3 lines

It's not a matter of correctness IMHO.

Ah now I see what you mean. New FW has to be used after reboot because old one may not be able to init HW any longer.

I think we have two ways to view firmware. The first would be to treat guest firmware as part of the guest. What that means it that we should store all firmware in an nvram file, migrate the nvram file during migration, and provide a mechanism for the user to individually upgrade/replace the firmware. We would never replace it from underneath the guest. We only put things in nvram the first time it is initialized. After that, it's entirely based on what the guest does.

On the one hand, this simplifies live migration, puts the user in more control over when there are firmware changes, gives us a very clear set of rules to follow with respect to compatibility. On the other hand, it means we must provide backwards compatibility at the fw_cfg level and it means that any firmware upgrade has to be initiated by the user. That means it's very likely that a user will not upgrade their firmware when upgrading qemu. We could version the nvram and if we detect a guest image being moved between versions (without the use of -M xxx) we could automatically clear the nvram causing new firmware to be loaded. Stable fixes for firmware though would require explicit action on the part of the guest. This could be considered an advantage depending on your perspective.

The other option would be to treat guest firmware as part of the machine state. The problem with this approach is that the firmware maintains state within the guest that qemu has no visibility into. This makes it impossible for us to upgrade the firmware unless the guest is at a very well defined point in time (IOW, start-up or reset). This has very different semantics than the rest of our machine and that's concerning.

I'm honestly on the fence about the two. The first mechanism (nvram) is very appealing in that it matches hardware. Having to rely on a guest to update it's firmware is concerning though. The second mechanism is appealing from an ease of use perspective but the semantics of doing a live migration and getting a different firmware after reset/shutdown is rather scary from a support perspective.

Quoted 11 lines
Quoted 7 lines

I can understand an argument for predictability wrt wanted to be able to guarantee that after the first reboot during a live migration, you'll get the new firmware. I'm not sure that's less predictable then hard shutdown/start-up and I'm not sure I can really make an argument for one way vs. the other.

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

It's not and it will never be completely. By this logic, we should close the file descriptors for the block devices and try to reopen them. It's certainly possible that someone does a mv of the block device and replaces it under the covers.

Likewise, if a user upgrades the firmware independently of the qemu version, it would need to reread the firmware from disk each boot.

Regards,

Anthony Liguori

#60 lore raw
Quoted 4 lines · Anthony Liguori

I think we have two ways to view firmware. The first would be to treat guest firmware as part of the guest. What that means it that we should store all firmware in an nvram file, migrate the nvram file during migration

[...]

Quoted 2 lines

The other option would be to treat guest firmware as part of the machine state.

How about mixing the two? Store the firmware in an nvram file and migrate it during migration, but clear the nvram and reload the firmware on each start-up and qemu reset.

[...]

Quoted 4 lines

The second mechanism is
appealing from an ease of use perspective but the semantics of doing a live migration and getting a different firmware after reset/shutdown is rather scary from a support perspective.

I'm not sure I see the problem with upgrading firmware on a reboot. I think it would be a pretty severe bug if a new firmware broke the OS or if an OS was heavily dependent on a specific firmware across reboots. After all, normal users update their bios and reboot into pre-existing OSs all the time.

-Kevin

#61 lore raw
Quoted 5 lines · Kevin O'Connor
Quoted 4 lines · Anthony Liguori

I think we have two ways to view firmware. The first would be to treat guest firmware as part of the guest. What that means it that we should store all firmware in an nvram file, migrate the nvram file during migration

Quoted 8 lines

[...]

Quoted 2 lines

The other option would be to treat guest firmware as part of the machine state.

How about mixing the two? Store the firmware in an nvram file and migrate it during migration, but clear the nvram and reload the firmware on each start-up and qemu reset.

That's precisely what I propose.

Quoted 6 lines

[...]

Quoted 4 lines

The second mechanism is
appealing from an ease of use perspective but the semantics of doing a live migration and getting a different firmware after reset/shutdown is rather scary from a support perspective.

Quoted 6 lines

I'm not sure I see the problem with upgrading firmware on a reboot. I think it would be a pretty severe bug if a new firmware broke the OS or if an OS was heavily dependent on a specific firmware across reboots. After all, normal users update their bios and reboot into pre-existing OSs all the time.

Exactly.

--
Gleb.

#62 lore raw
Quoted 14 lines · Gleb Natapov
Quoted 12 lines · Kevin O'Connor
Quoted 5 lines · Anthony Liguori

I think we have two ways to view firmware. The first would be to treat guest firmware as part of the guest. What that means it that we should store all firmware in an nvram file, migrate the nvram file during migration

[...]

Quoted 3 lines

The other option would be to treat guest firmware as part of the machine state.

Quoted 7 lines
Quoted 5 lines

How about mixing the two? Store the firmware in an nvram file and migrate it during migration, but clear the nvram and reload the firmware on each start-up and qemu reset.

That's precisely what I propose.

There are some really ugly corner cases here. For instance, guest is running and the user does a yum update which upgrades the qemu package. This includes laying down a new bios.

User eventually restarts guest, now we re-read BIOS and we're on a newer BIOS than the device model. Badness ensues.

And more importantly, what is the end-user benefit of doing this?

Regards,

Anthony Liguori

#63 lore raw
Quoted 14 lines · Anthony Liguori
Quoted 13 lines · Gleb Natapov
Quoted 12 lines · Kevin O'Connor
Quoted 4 lines · Anthony Liguori

I think we have two ways to view firmware. The first would be to treat guest firmware as part of the guest. What that means it that we should store all firmware in an nvram file, migrate the nvram file during migration

[...]

Quoted 2 lines

The other option would be to treat guest firmware as part of the machine state.

How about mixing the two? Store the firmware in an nvram file and migrate it during migration, but clear the nvram and reload the firmware on each start-up and qemu reset.

Quoted 9 lines
Quoted 1 line

That's precisely what I propose.

There are some really ugly corner cases here. For instance, guest is running and the user does a yum update which upgrades the qemu package. This includes laying down a new bios.

User eventually restarts guest, now we re-read BIOS and we're on a newer BIOS than the device model. Badness ensues.

My package manager warns me that certain application need to be restarted to work correctly after upgrade. This is hardly qemu specific problem.

Quoted 2 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

--
Gleb.

#64 lore raw
Quoted 4 lines · Gleb Natapov
Quoted 4 lines

There are some really ugly corner cases here. For instance, guest is running and the user does a yum update which upgrades the qemu package. This includes laying down a new bios.

Quoted 8 lines
Quoted 4 lines

User eventually restarts guest, now we re-read BIOS and we're on a newer BIOS than the device model. Badness ensues.

My package manager warns me that certain application need to be restarted to work correctly after upgrade. This is hardly qemu specific problem.

But again, I don't see when this is ever a feature that a user actually wants. Unless you change restart to fork/exec+exit, you'll never have reset equivalent to power off + startup. Can you advocate rereading roms and not advocate re-execing qemu?

Quoted 5 lines
Quoted 3 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

How does it fix migration? Migration needs to transfer the current roms in order to work. A new version of qemu must support interacting with the old version of the firmware for migration to work. What happens after reset has nothing to do with migration but because of the last requirement, the guest will obviously continue to work after reboot too.

Regards,

Anthony Liguori

#65 lore raw
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Gleb Natapov
Quoted 7 lines

There are some really ugly corner cases here. For instance, guest is running and the user does a yum update which upgrades the qemu package. This includes laying down a new bios.

User eventually restarts guest, now we re-read BIOS and we're on a newer BIOS than the device model. Badness ensues.

Quoted 8 lines
Quoted 3 lines

My package manager warns me that certain application need to be restarted to work correctly after upgrade. This is hardly qemu specific problem.

But again, I don't see when this is ever a feature that a user actually wants. Unless you change restart to fork/exec+exit, you'll never have reset equivalent to power off + startup. Can you advocate rereading roms and not advocate re-execing qemu?

Why I will never have reset equivalent to power off + startup? Are you saying we are not capable of implementing spec correctly?

Quoted 10 lines
Quoted 3 lines
Quoted 2 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

How does it fix migration? Migration needs to transfer the current roms in order to work. A new version of qemu must support interacting with the old version of the firmware for migration to work. What happens after reset has nothing to do with migration but because of the last requirement, the guest will obviously continue to work after reboot too.

I don't agree with your last requirement. Firmware goes hand in hand with HW. Change that is only FW visible should not be backwards compatible.

--
Gleb.

#66 lore raw

[Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 13 lines · Gleb Natapov
Quoted 12 lines · Anthony Liguori
Quoted 10 lines · Gleb Natapov
Quoted 7 lines

There are some really ugly corner cases here. For instance, guest is running and the user does a yum update which upgrades the qemu package. This includes laying down a new bios.

User eventually restarts guest, now we re-read BIOS and we're on a newer BIOS than the device model. Badness ensues.

My package manager warns me that certain application need to be restarted to work correctly after upgrade. This is hardly qemu specific problem.

Quoted 6 lines
Quoted 4 lines

But again, I don't see when this is ever a feature that a user actually wants. Unless you change restart to fork/exec+exit, you'll never have reset equivalent to power off + startup. Can you advocate rereading roms and not advocate re-execing qemu?

Why I will never have reset equivalent to power off + startup? Are you saying we are not capable of implementing spec correctly?

In the "POST failure (loop) with isapc and seabios" thread we have concluded that the "system_reset" monitor command should trigger a power cycle, but it currently doesn't. This same power cycle logic has to be implemented for ACPI reset.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

Quoted 8 lines
Quoted 6 lines

How does it fix migration? Migration needs to transfer the current roms in order to work. A new version of qemu must support interacting with the old version of the firmware for migration to work. What happens after reset has nothing to do with migration but because of the last requirement, the guest will obviously continue to work after reboot too.

I don't agree with your last requirement. Firmware goes hand in hand with HW. Change that is only FW visible should not be backwards compatible.

As stated before i don't like the idea of automagically upgrading the firmware on reset, e.g. after a live migration to a newer qemu version. You have explained that qemu-kvm needs this in order to work with live migration and changed hw support because of bug fixes. Is this only needed in the kvm case?

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios) for licensing? It would be ugly if Windows wants you to re-activate after a reboot following a migration to newer qemu version and therefore possibly changed tables due to newer bios.

- Sebastian

#67 lore raw

[Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 18 lines · Sebastian Herbszt
Quoted 17 lines · Gleb Natapov
Quoted 16 lines · Anthony Liguori
Quoted 10 lines · Gleb Natapov
Quoted 7 lines

There are some really ugly corner cases here. For instance, guest is running and the user does a yum update which upgrades the qemu package. This includes laying down a new bios.

User eventually restarts guest, now we re-read BIOS and we're on a newer BIOS than the device model. Badness ensues.

My package manager warns me that certain application need to be restarted to work correctly after upgrade. This is hardly qemu specific problem.

But again, I don't see when this is ever a feature that a user actually wants. Unless you change restart to fork/exec+exit, you'll never have reset equivalent to power off + startup. Can you advocate rereading roms and not advocate re-execing qemu?

Quoted 8 lines
Quoted 2 lines

Why I will never have reset equivalent to power off + startup? Are you saying we are not capable of implementing spec correctly?

In the "POST failure (loop) with isapc and seabios" thread we have concluded that the "system_reset" monitor command should trigger a power cycle, but it currently doesn't. This same power cycle logic has to be implemented for ACPI reset.

It currently tries to do that, but state after reset is not exactly the same as after qemu start. Each and every such difference is an instance of a bug.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 2 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

How does it fix migration? Migration needs to transfer the current roms in order to work. A new version of qemu must support interacting with the old version of the firmware for migration to work. What happens after reset has nothing to do with migration but because of the last requirement, the guest will obviously continue to work after reboot too.

Quoted 8 lines
Quoted 2 lines

I don't agree with your last requirement. Firmware goes hand in hand with HW. Change that is only FW visible should not be backwards compatible.

As stated before i don't like the idea of automagically upgrading the firmware on reset, e.g. after a live migration to a newer qemu version. You have explained that qemu-kvm needs this in order to work with live migration and changed hw support because of bug fixes. Is this only needed in the kvm case?

There basically two approaches. One is you allow HW to change in such a way that new FW is needed to init it and then you have to reload newer FW after migration or you disallow HW changes that will prevent old FW from configuring it and then you can use old FW after migration.

This is nothing special for KVM.

Quoted 5 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios) for licensing? It would be ugly if Windows wants you to re-activate after a reboot following a migration to newer qemu version and therefore possibly changed tables due to newer bios.

I am not talking about OS visible stuff.

--
Gleb.

#68 lore raw

[Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 7 lines · Gleb Natapov
Quoted 5 lines · Sebastian Herbszt

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios) for licensing? It would be ugly if Windows wants you to re-activate after a reboot following a migration to newer qemu version and therefore possibly changed tables due to newer bios.

I am not talking about OS visible stuff.

How do you want to avoid OS visible changes if the bios is reread on each reset? People can upgrade/change their bios in the pc-bios directory and bad things could happen if its reloaded on each reset.

- Sebastian

#69 lore raw

[Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 7 lines · Sebastian Herbszt
Quoted 6 lines · Gleb Natapov
Quoted 5 lines · Sebastian Herbszt

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios) for licensing? It would be ugly if Windows wants you to re-activate after a reboot following a migration to newer qemu version and therefore possibly changed tables due to newer bios.

Quoted 6 lines
Quoted 1 line

I am not talking about OS visible stuff.

How do you want to avoid OS visible changes if the bios is reread on each reset? People can upgrade/change their bios in the pc-bios directory and bad things could happen if its reloaded on each reset.

The fact that people can doesn't mean people should. Arbitrary combination of qemu + BIOS is not supported. If people do what you say the bad things will happen anyway after restarting qemu instead of reboot.

--
Gleb.

#70 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

In reply to Sebastian Herbszt
Quoted 4 lines · Sebastian Herbszt

As stated before i don't like the idea of automagically upgrading the firmware on reset, e.g. after a live migration to a newer qemu version. You have explained that qemu-kvm needs this in order to work with live migration and changed hw support because of bug fixes. Is this only needed in the kvm case?

It's not "needed", it's desired. The same case can be made for real hardware (automated firmware updates).

Quoted 4 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios) for licensing? It would be ugly if Windows wants you to re-activate after a reboot following a migration to newer qemu version and therefore possibly changed tables due to newer bios.

Yes, and this is a good point. ACPI table changes can absolutely cause re-activation. If we migrate from 0.12 -> 0.13 and make major changes to the ACPI tables in 0.13, then it's very likely that will result in problems for Windows guests.

I really think that we need to snapshot the FW and store it with the guest state. If we switch all FW to be allocated with qemu_ram_alloc() and we use an id mechanism, then this will Just Work for savevm based snapshots and live migration. However, for it to work with -M pc-0.11 started from a cold boot, we need an nvram file. We probably want to make available versioned nvram files from each release too.

Regards,

Anthony Liguori

Quoted 3 lines

- Sebastian

#71 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 7 lines · Anthony Liguori
Quoted 4 lines · Sebastian Herbszt

As stated before i don't like the idea of automagically upgrading the firmware on reset, e.g. after a live migration to a newer qemu version. You have explained that qemu-kvm needs this in order to work with live migration and changed hw support because of bug fixes. Is this only needed in the kvm case?

It's not "needed", it's desired. The same case can be made for real hardware (automated firmware updates).

Tho on real hardware those updates are initiated by someone and not automagic.

Quoted 6 lines
Quoted 4 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios) for licensing? It would be ugly if Windows wants you to re-activate after a reboot following a migration to newer qemu version and therefore possibly changed tables due to newer bios.

Yes, and this is a good point. ACPI table changes can absolutely cause re-activation. If we migrate from 0.12 -> 0.13 and make major changes to the ACPI tables in 0.13, then it's very likely that will result in problems for Windows guests.

Another problem could be on guest resume from S3 after migration if the bios or acpi tables change.

Quoted 1 line

I really think that we need to snapshot the FW and store it with the guest state. If we switch all FW to be allocated with qemu_ram_alloc() and we use an id mechanism, then this will Just Work for savevm based snapshots and live migration. However, for it to work with -M pc-0.11 started from a cold boot, we need an nvram file. We probably want to make available versioned nvram files from each release too.

So the idea is to store the bios/option roms in the guest state and read them from there on reset or power cycle?

- Sebastian

#72 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 10 lines · Sebastian Herbszt
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Sebastian Herbszt

As stated before i don't like the idea of automagically upgrading the firmware
on reset, e.g. after a live migration to a newer qemu version. You have explained
that qemu-kvm needs this in order to work with live migration and changed hw
support because of bug fixes. Is this only needed in the kvm case?

Quoted 6 lines
Quoted 2 lines

It's not "needed", it's desired. The same case can be made for real hardware (automated firmware updates).

Tho on real hardware those updates are initiated by someone and not automagic.

Because on real hardware it is impossible to do it differently may be? My cable TV provider upgrades FW on my set-top-box automatically.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios)
for licensing? It would be ugly if Windows wants you to re-activate after a reboot
following a migration to newer qemu version and therefore possibly changed tables
due to newer bios.

Quoted 7 lines
Quoted 4 lines

Yes, and this is a good point. ACPI table changes can absolutely cause re-activation. If we migrate from 0.12 -> 0.13 and make major changes to the ACPI tables in 0.13, then it's very likely that will result in problems for Windows guests.

Another problem could be on guest resume from S3 after migration if the bios or acpi tables change.

On resume from S3 BIOS doesn't recreate ACPI tables. ACPI tables are not part of a BIOS image and in fact OS can reuse memory ACPI tables reside in. So such problem definitely does not exist.

Quoted 9 lines
Quoted 8 lines

I really think that we need to snapshot the FW and store it with the guest state. If we switch all FW to be allocated with qemu_ram_alloc() and we use an id mechanism, then this will Just Work for savevm based snapshots and live migration. However, for it to work with -M pc-0.11 started from a cold boot, we need an nvram file. We probably want to make available versioned nvram files from each release too.

Quoted 4 lines

So the idea is to store the bios/option roms in the guest state and read them from there on reset or power cycle?

- Sebastian

--
Gleb.

#73 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 11 lines · Gleb Natapov
Quoted 10 lines · Sebastian Herbszt
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Sebastian Herbszt

As stated before i don't like the idea of automagically upgrading the firmware
on reset, e.g. after a live migration to a newer qemu version. You have explained
that qemu-kvm needs this in order to work with live migration and changed hw
support because of bug fixes. Is this only needed in the kvm case?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

It's not "needed", it's desired. The same case can be made for real hardware (automated firmware updates).

Tho on real hardware those updates are initiated by someone and not automagic.

Because on real hardware it is impossible to do it differently may be? My cable TV provider upgrades FW on my set-top-box automatically.

Your cable TV provider does likely also control what beside the FW (if anything) runs on your set-top-box. So he can verify the FW upgrade doesn't break anything in the field. That pre-deployment verification is not possible in non closed environments.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 7 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios)
for licensing? It would be ugly if Windows wants you to re-activate after a reboot
following a migration to newer qemu version and therefore possibly changed tables
due to newer bios.

Yes, and this is a good point. ACPI table changes can absolutely cause re-activation. If we migrate from 0.12 -> 0.13 and make major changes to the ACPI tables in 0.13, then it's very likely that will result in problems for Windows guests.

Quoted 5 lines
Quoted 2 lines

Another problem could be on guest resume from S3 after migration if the bios or acpi tables change.

On resume from S3 BIOS doesn't recreate ACPI tables. ACPI tables are not part of a BIOS image and in fact OS can reuse memory ACPI tables reside in. So such problem definitely does not exist.

If the OS recycles the whole memory which holds the ACPI tables i am not sure how the BIOS will find the firmware_waking_vector. Maybe the OS can only use the memory which holds the DSDT? Anyway, will the guest even resume from S3 if the hw changed on migration and the bios doesn't know how to init it?

- Sebastian

#74 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 18 lines · Sebastian Herbszt
Quoted 17 lines · Gleb Natapov
Quoted 16 lines · Sebastian Herbszt
Quoted 11 lines · Anthony Liguori
Quoted 7 lines · Sebastian Herbszt

As stated before i don't like the idea of automagically upgrading the firmware
on reset, e.g. after a live migration to a newer qemu version. You have explained
that qemu-kvm needs this in order to work with live migration and changed hw
support because of bug fixes. Is this only needed in the kvm case?

It's not "needed", it's desired. The same case can be made for real hardware (automated firmware updates).

Tho on real hardware those updates are initiated by someone and not automagic.

Quoted 8 lines
Quoted 2 lines

Because on real hardware it is impossible to do it differently may be? My cable TV provider upgrades FW on my set-top-box automatically.

Your cable TV provider does likely also control what beside the FW (if anything) runs on your set-top-box. So he can verify the FW upgrade doesn't break anything in the field. That pre-deployment verification is not possible in non closed environments.

Yet it doesn't stop HW manufacturers to require FW update as the first step of their support procedure. They don't do it automatically only because they can't.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 8 lines
Quoted 7 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios)
for licensing? It would be ugly if Windows wants you to re-activate after a reboot
following a migration to newer qemu version and therefore possibly changed tables
due to newer bios.

Quoted 4 lines

Yes, and this is a good point. ACPI table changes can absolutely cause re-activation. If we migrate from 0.12 -> 0.13 and make major changes to the ACPI tables in 0.13, then it's very likely that will result in problems for Windows guests.

Another problem could be on guest resume from S3 after migration if the bios or acpi tables change.

Quoted 7 lines
Quoted 3 lines

On resume from S3 BIOS doesn't recreate ACPI tables. ACPI tables are not part of a BIOS image and in fact OS can reuse memory ACPI tables reside in. So such problem definitely does not exist.

If the OS recycles the whole memory which holds the ACPI tables i am not sure how the BIOS will find the firmware_waking_vector. Maybe the OS can only use the memory which holds the DSDT?

OS can reuse memory marked as "ACPI data" in e820 map. BIOS can put firmware_waking_vector pointer into reserved memory or "ACPI NVS"

Quoted 2 lines

Anyway, will the guest even resume from S3 if the hw changed
on migration and the bios doesn't know how to init it?

Probably not, so we need to use new BIOS that knows how to init HW.

--
Gleb.

#75 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 10 lines · Gleb Natapov
Quoted 6 lines

Your cable TV provider does likely also control what beside the FW (if anything) runs on your set-top-box. So he can verify the FW upgrade doesn't break anything in the field. That pre-deployment verification is not possible in non closed environments.

Yet it doesn't stop HW manufacturers to require FW update as the first step of their support procedure. They don't do it automatically only because they can't.

Let's put correctness aside for a moment.

Right now, if you replace the contents of pc-bios while you have a guest running, heck, even if you rm -rf, the guest will continue functioning until you do a hard power off.

Changing this behavior feels like a regression to me. It really seems to me like it makes things a lot more brittle.

The only benefit I can see is that you'll use a new rom after migration after the first reset. Maybe that's desirable behavior although I'm not sure.

I'd feel a lot better about something that read the real rom contents at start-up, and then replaced migrated roms after reset or something like that. That gives us the use-case without making qemu depend on rereading things while it's running.

Regards,

Anthony Liguori

#76 lore raw

[Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 7 lines

Does any OS (Windows?) depend on the tables the bios creates (e.g. smbios)
for licensing? It would be ugly if Windows wants you to re-activate after a reboot
following a migration to newer qemu version and therefore possibly changed tables
due to newer bios.

Quoted 5 lines

Yes, and this is a good point. ACPI table changes can absolutely cause re-activation. If we migrate from 0.12 -> 0.13 and make major changes to the ACPI tables in 0.13, then it's very likely that will result in problems for Windows guests.

On the contrary. This is very unlikely. Otherwise BIOS upgrade would cause Windows reactivation.

Quoted 8 lines

I really think that we need to snapshot the FW and store it with the guest state. If we switch all FW to be allocated with qemu_ram_alloc() and we use an id mechanism, then this will Just Work for savevm based snapshots and live migration. However, for it to work with -M pc-0.11 started from a cold boot, we need an nvram file. We probably want to make available versioned nvram files from each release too.

Yes, firmware should be part of machine description.

--
Gleb.

#77 lore raw
In reply to Gleb Natapov
Quoted 3 lines · Gleb Natapov

Why I will never have reset equivalent to power off + startup? Are you saying we are not capable of implementing spec correctly?

No, I'm saying that if you want reset absolutely equivalent to power off + startup, then you need to fork() and re-exec qemu at startup since the qemu binary may have changed while the guest was running.

My point behind this is I think that's equivalent to re-reading rom contents from disk.

Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

How does it fix migration? Migration needs to transfer the current roms in order to work. A new version of qemu must support interacting with the old version of the firmware for migration to work. What happens after reset has nothing to do with migration but because of the last requirement, the guest will obviously continue to work after reboot too.

Quoted 3 lines

I don't agree with your last requirement. Firmware goes hand in hand with HW. Change that is only FW visible should not be backwards compatible.

I think we're papering over this issue. FW interfaces are guest visible even though we've been pretending like they aren't.

SeaBIOS does not implement every possible BIOS function. I'm sure that it will implement new functions over time. The presence of those functions are certainly visible to the guest. Likewise, any bug or added feature is visible to a guest.

More concretely, we have an internal OS that interacts very closely with PXE roms (it makes use of UNDI). It's very aware of the difference between etherboot and gPXE and it is also aware of different versions of those two.

The arguments for saying FW is not guest visible is that FW interfaces are well defined and do not change. The same is true for 99% of the hardware we emulate. The reason we have guest visible changes is that we're constantly improving and increasing the functionality of the hardware. The same is true for FW.

I'm starting to think having an nvram with saved firmware and user driven upgrades is the best approach for compatibility by far. I'm still concerned though about the relatively complexity of having to force users to upgrade their firmware.

Regards,

Anthony Liguori

#78 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 2 lines · Gleb Natapov

Why I will never have reset equivalent to power off + startup? Are you saying we are not capable of implementing spec correctly?

No, I'm saying that if you want reset absolutely equivalent to power off + startup, then you need to fork() and re-exec qemu at startup since the qemu binary may have changed while the guest was running.

My point behind this is I think that's equivalent to re-reading rom contents from disk.

You are exaggerating. If user want to update qemu it should exit old one and re-run new one. Power off + startup, on the other hand, is defied to be equivalent to ACPI reset by ACPI spec. In other words if devices state as seen by vmstate after qemu start is different by even one bit from the state after system_restart this is bug. This is completely orthogonal to our firmware loading discussion.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

And more importantly, what is the end-user benefit of doing this?

Working migration?

How does it fix migration? Migration needs to transfer the current roms in order to work. A new version of qemu must support interacting with the old version of the firmware for migration to work. What happens after reset has nothing to do with migration but because of the last requirement, the guest will obviously continue to work after reboot too.

Quoted 5 lines
Quoted 2 lines

I don't agree with your last requirement. Firmware goes hand in hand with HW. Change that is only FW visible should not be backwards compatible.

I think we're papering over this issue. FW interfaces are guest visible even though we've been pretending like they aren't.

Not all of it. We can completely change extboot interface, for instance, and support migration if we will handle things right. We can fix bugs in tpr patching without losing migration capability.

Quoted 6 lines

SeaBIOS does not implement every possible BIOS function. I'm sure that it will implement new functions over time. The presence of those functions are certainly visible to the guest. Likewise, any bug or added feature is visible to a guest.

No, not any bug is visible to the guest. Example: kvm currently configures lvt0 to virtual wire inside qemu/kvm acpi code, but this should be done by the BIOS on real HW. So suppose we fixed this bug and moved initialization into the BIOS If we'll try to init new kvm with old BIOS next OS boot will fail.

Quoted 11 lines

More concretely, we have an internal OS that interacts very closely with PXE roms (it makes use of UNDI). It's very aware of the difference between etherboot and gPXE and it is also aware of different versions of those two.

The arguments for saying FW is not guest visible is that FW interfaces are well defined and do not change. The same is true for 99% of the hardware we emulate. The reason we have guest visible changes is that we're constantly improving and increasing the functionality of the hardware. The same is true for FW.

We can't do guest visible changes in devices and FW and support migration from older qemu. I think we agree on this. Non guest visible changes are allowed for device emulation, you are trying to disallow it for FW.

Quoted 5 lines

I'm starting to think having an nvram with saved firmware and user driven upgrades is the best approach for compatibility by far. I'm still concerned though about the relatively complexity of having to force users to upgrade their firmware.

Please stop thinking so :) Especially about "user driven upgrades". Why combine disadvantages of vitalization with pain of physical HW management? Or may be next step will be to require uploading of CPU microcode to take advantage of KVM/tcg bug fixes?

--
Gleb.

#79 lore raw
Quoted 5 lines · Gleb Natapov

Please stop thinking so :) Especially about "user driven upgrades". Why combine disadvantages of vitalization with pain of physical HW management? Or may be next step will be to require uploading of CPU microcode to take advantage of KVM/tcg bug fixes?

I think your real argument boils down to that we can be better than real hardware therefore we should. I actually agree with you for 90% of users. Let me summarize where I'm at.

- We are currently horribly broken with respect to how we handle roms
particularly with respect to backwards compatibility
- We must support running older roms on newer qemu at least within a
stable series (because of live migration)
- We need a mechanism to include roms specific to a machine type
- Probably by default, we want new roms to be used by guests at some
well defined time (either first reset or first power-down/start-up)
- We ought to make all roms live in qemu_ram_alloc()'d memory and we
ought to change that api to contain contexts, this will make sure rom live migration works properly.

The best approach I can think of is to introduce an nvram mechanism. A tar file probably work really well. If a user doesn't supply an explicit -nvram, we could create a temporary file and delete it. If the nvram is empty, we populate it with whatever the appropriate roms are for the machine type.

I would also suggest that we support the guest updating roms on its own (through fw_cfg). I can think of a number of reasons for this. For instance, why shouldn't a guest be able to update the gPXE associated with the network card? The code runs entirely in the guest so there's no harm to the host. Allow a guest to do this sort of thing takes pressure off of the management system so particularly in an environment like a cloud, I think this could prove very useful.

It could be possible to add an option to -nvram to make it re-read roms from disk every reboot. I really think this is a bad idea though, I'd like to hear more people comment on it but it's certainly technically feasible.

Regards,

Anthony Liguori

Quoted 3 lines

--
Gleb.

#80 lore raw

[Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul.

Quoted 9 lines · Anthony Liguori
Quoted 5 lines · Gleb Natapov

Please stop thinking so :) Especially about "user driven upgrades". Why combine disadvantages of vitalization with pain of physical HW management? Or may be next step will be to require uploading of CPU microcode to take advantage of KVM/tcg bug fixes?

I think your real argument boils down to that we can be better than real hardware therefore we should. I actually agree with you for 90% of users. Let me summarize where I'm at.

Quoted 7 lines

- We are currently horribly broken with respect to how we handle roms
particularly with respect to backwards compatibility
- We must support running older roms on newer qemu at least within a
stable series (because of live migration)
- We need a mechanism to include roms specific to a machine type
- Probably by default, we want new roms to be used by guests at some
well defined time (either first reset or first power-down/start-up)

Start-up sounds good.

Quoted 6 lines

- We ought to make all roms live in qemu_ram_alloc()'d memory and we
ought to change that api to contain contexts, this will make sure rom live migration works properly.

The best approach I can think of is to introduce an nvram mechanism. A tar file probably work really well. If a user doesn't supply an explicit -nvram, we could create a temporary file and delete it. If the nvram is empty, we populate it with whatever the appropriate roms are for the machine type.

I would also suggest that we support the guest updating roms on its own (through fw_cfg). I can think of a number of reasons for this. For instance, why shouldn't a guest be able to update the gPXE associated with the network card? The code runs entirely in the guest so there's no harm to the host.

You mean the nvram file on the host or in memory? Will there be a size limit?

Quoted 1 line

Allow a guest to do this sort of thing takes pressure off of the management system so particularly in an environment like a cloud, I think this could prove very useful.

It might not be desired and make support efforts harder. Could have security implications too.

Quoted 1 line

It could be possible to add an option to -nvram to make it re-read roms from disk every reboot. I really think this is a bad idea though, I'd like to hear more people comment on it but it's certainly technically feasible.

- Sebastian

#81 lore raw
In reply to Anthony Liguori
Quoted 5 lines · Anthony Liguori
Quoted 3 lines

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

It's not and it will never be completely.

There are always bugs left. As long as we agree on what is right that is OK.

Quoted 4 lines

By this logic, we should
close the file descriptors for the block devices and try to reopen them. It's certainly possible that someone does a mv of the block device and replaces it under the covers.

What is the analogue in real HW? BTW it is not a bad idea to get notification when disk file has changed and issue "change device" automatically.

Quoted 4 lines

Likewise, if a user upgrades the firmware independently of the qemu version, it would need to reread the firmware from disk each boot.

That's the idea. Qemu should reread firmware from disk on each hard reset.

--
Gleb.

#82 lore raw
Quoted 18 lines · Gleb Natapov
Quoted 5 lines · Anthony Liguori
Quoted 3 lines

system_reset _is_ hard shutdown/start-up. If it is not it is a bug, we just arguing if the same applies for the case that migration was done between boot and reset.

It's not and it will never be completely.

There are always bugs left. As long as we agree on what is right that is OK.

Quoted 4 lines

By this logic, we should
close the file descriptors for the block devices and try to reopen them. It's certainly possible that someone does a mv of the block device and replaces it under the covers.

What is the analogue in real HW? BTW it is not a bad idea to get notification when disk file has changed and issue "change device" automatically.

Quoted 1 line
Quoted 4 lines
Quoted 3 lines

Likewise, if a user upgrades the firmware independently of the qemu version, it would need to reread the firmware from disk each boot.

That's the idea. Qemu should reread firmware from disk on each hard reset.

We could have another copy in memory if we are concerned about being consistent, reset firmware to that on reboot.

Quoted 3 lines

--
Gleb.

#83 lore raw
In reply to Gleb Natapov
Quoted 16 lines · Gleb Natapov
Quoted 7 lines · Anthony Liguori
Quoted 6 lines · Gleb Natapov
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Gleb Natapov
Quoted 3 lines · Anthony Liguori

No. You have to physically shut down and start up again. That's the right semantics IMHO.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

Reset is equivalent (or should be) to shut down and start up again.

Not at all. Reset can happen in a lot of different ways, some that

We support only one way of reset: hard reset. It equivalent to full HW power cycling. ACPI spec define ACPI reset as equivalent to HW power cycling too BTW (see 4.7.3.6).

For every system periphereal?

Quoted 7 lines

To cite ACPI spec : "From an OSPM perspective, asserting the reset mechanism is the logical equivalent to power cycling the machine."

Quoted 2 lines

For instance, memory contents
survive a reset whereas they won't survive a hard power down.

We cannot rely on memory content after such reset.

Some software expects it. But the worst situation is when it's "mostly reliable", i.e. works normally but unreliable if migration occurs during the reset cycle. It should either be reliable, or if that is not intended, the memory should be wiped on reset to be sure nobody is running guests which depend on it. (They might not even know).

Quoted 4 lines
Quoted 2 lines

More importantly though, what's the use-case here?

Use-case for what? This just what need to be done for correct HW emulation.

Reminder about x86 HW emulation; recent message:

http://www.mail-archive.com/[email protected]/msg22676.html

Quoted 8 lines · toshiya
Quoted 3 lines · Anthony Liguori

Hi,

Why is this needed verses qemu_system_reset()?

PC-98 has the ioport to reset only cpu (don't reset other periferals) and I need qemu_cpu_reset() to emulate thios port.

Quoted 7 lines

This port was used to return to real mode from protect mode by resetting cpu. It was added for 80286, but was used on PC-98 with 80386 and later. (For example for checking of over 1mb memory in hardware initialization bios.)

Thanks,
TAKEDA, toshiya

That is, PC-98 emulation requires a CPU-only reset that retains memory contents and does not reset peripherals. It has an I/O port explicitly for it.

Regular x86 PCs also require this under some circumstances, for the same reasons: To run 80286 MS-DOS software (on a later CPU of course :-) that switches from protected mode to real mode by triggering a hardware reset. It does not reset the peripherals and memory contents are reliable, except possibly for some regions that the BIOS may affect.

I assume this was one of the things meant in Anthony's qemu 0.12 release announcment:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[please test...]
- exotic x86 guests that may interact with the BIOS in special ways

But I don't really understand

- what strange things are being implemented with ROMs changing on boot and during migration
- how it depends in some intricate way on ACPI tables and option ROMS and migration and qemu upgrades all at once
- those are things which the "exotic" guests don't care about
- memory is preserved, isn't it, when qemu resets, even though it is called "not reliable", meaning that test guests will run fine with it while having some hidden bug waiting to happen under a rare conjunction of qemu's circumstances - is that right?

So I don't know quite what to test to confirm or deny bugs in emulation of things that exotic x86 guests depend on.

-- Jamie