Skip to contentSkip to conversation

kvm: merge fixes for vmstate/block name from qemu.git

PATCH In review Alex Williamson 2 participants 2 messages Jul 7, 2010 – Jul 8, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: merge fixes for vmstate/block name from qemu.git

Also updates qemu_ram_map() and create qemu_ram_unmap() to match qemu_ram_alloc/qemu_ram_free().

---

This patch should fix all the qemu-kvm build failures that will occur as a result of my qemu.git series fixing migration after hotplug. This also updates device-assignment to the new qemu_ram_* calling standards so migration will also work after a hotunplug of a pci-assign device.

 cpu-common.h           |    4 ++
 exec.c                 |   83 ++++++++++++++++++++++++++++++++----------------
 hw/device-assignment.c |   21 +++++++++---
 hw/i8254-kvm.c         |    2 +
 hw/i8259.c             |    2 +
 kvm-tpr-opt.c          |    2 +
 qemu-kvm-x86.c         |    2 +
 7 files changed, 78 insertions(+), 38 deletions(-)
cpu-common.h +3 -1
index 4890da4..f430f2d 100644
@@ -40,8 +40,10 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,
 }
 
 ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr);
-ram_addr_t qemu_ram_map(ram_addr_t size, void *host);
+ram_addr_t qemu_ram_map(DeviceState *dev, const char *name,
+                        ram_addr_t size, void *host);
 ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
+void qemu_ram_unmap(ram_addr_t addr);
 void qemu_ram_free(ram_addr_t addr);
 /* This should only be used for ram local to a device.  */
 void *qemu_get_ram_ptr(ram_addr_t addr);
exec.c +56 -27

101 lines not on this page · raw message

hw/device-assignment.c +15 -6
index 48ac73c..cbbf37f 100644
@@ -571,9 +571,13 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
 
             if (!slow_map) {
                 void *virtbase = pci_dev->v_addrs[i].u.r_virtbase;
-
-                pci_dev->v_addrs[i].memory_index = qemu_ram_map(cur_region->size,
-                                                                virtbase);
+                char name[32];
+                snprintf(name, sizeof(name), "%s.bar%d",
+                         pci_dev->dev.qdev.info->name, i);
+                pci_dev->v_addrs[i].memory_index =
+                                            qemu_ram_map(&pci_dev->dev.qdev,
+                                                         name, cur_region->size,
+                                                         virtbase);
             } else
                 pci_dev->v_addrs[i].memory_index = 0;
 
@@ -779,9 +783,14 @@ static void free_assigned_device(AssignedDevice *dev)
                 continue;
             } else if (pci_region->type & IORESOURCE_MEM) {
                 if (region->u.r_virtbase) {
-                    int ret = munmap(region->u.r_virtbase,
-                                     (pci_region->size + 0xFFF) & 0xFFFFF000);
-                    if (ret != 0)
+                    if (region->memory_index) {
+                        cpu_register_physical_memory(region->e_physbase,
+                                                     region->e_size,
+                                                     IO_MEM_UNASSIGNED);
+                        qemu_ram_unmap(region->memory_index);
+                    }
+                    if (munmap(region->u.r_virtbase,
+                               (pci_region->size + 0xFFF) & 0xFFFFF000))
                         fprintf(stderr,
 				"Failed to unmap assigned device region: %s\n",
 				strerror(errno));
hw/i8254-kvm.c +1 -1
index c62ab6a..6125213 100644
@@ -114,7 +114,7 @@ PITState *kvm_pit_init(int base, qemu_irq irq)
     s->irq_timer = qemu_new_timer(vm_clock, dummy_timer, s);
     vmstate_pit.pre_save = kvm_pit_pre_save;
     vmstate_pit.post_load = kvm_pit_post_load;
-    vmstate_register(base, &vmstate_pit, pit);
+    vmstate_register(NULL, base, &vmstate_pit, pit);
     qemu_register_reset(pit_reset, pit);
     pit_reset(pit);
 
hw/i8259.c +1 -1
index 70da847..11060d3 100644
@@ -658,7 +658,7 @@ static void kvm_i8259_set_irq(void *opaque, int irq, int level)
 
 static void kvm_pic_init1(int io_addr, PicState *s)
 {
-    vmstate_register(io_addr, &vmstate_pic, s);
+    vmstate_register(NULL, io_addr, &vmstate_pic, s);
     qemu_register_reset(pic_reset, s);
 }
 
kvm-tpr-opt.c +1 -1
index 429c2f4..46890e2 100644
@@ -370,7 +370,7 @@ static void vtpr_ioport_write(void *opaque, uint32_t addr, uint32_t val)
 
 static void kvm_tpr_opt_setup(void)
 {
-    register_savevm("kvm-tpr-opt", 0, 1, tpr_save, tpr_load, NULL);
+    register_savevm(NULL, "kvm-tpr-opt", 0, 1, tpr_save, tpr_load, NULL);
     register_ioport_write(0x7e, 1, 1, vtpr_ioport_write, NULL);
     register_ioport_write(0x7e, 2, 2, vtpr_ioport_write16, NULL);
 }
qemu-kvm-x86.c +1 -1
index 403337a..fd426b7 100644
@@ -598,7 +598,7 @@ int kvm_arch_qemu_create_context(void)
 
 #ifdef KVM_CAP_ADJUST_CLOCK
     if (kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK))
-        vmstate_register(0, &vmstate_kvmclock, &kvmclock_data);
+        vmstate_register(NULL, 0, &vmstate_kvmclock, &kvmclock_data);
 #endif
 
     r = kvm_set_boot_cpu_id(0);
#1 lore raw
Quoted 4 lines · Alex Williamson

Also updates qemu_ram_map() and create qemu_ram_unmap() to match qemu_ram_alloc/qemu_ram_free().

Patch does not apply, multiple failures. Are you patching an old tree?

Quoted 5 lines

This patch should fix all the qemu-kvm build failures that will occur as a result of my qemu.git series fixing migration after hotplug. This also updates device-assignment to the new qemu_ram_* calling standards so migration will also work after a hotunplug of a pci-assign device.

A bit much for a single patch. Can you split it a bit?

qemu-kvm-x86.c int kvm_arch_qemu_create_context(void) · line 604

Quoted 12 lines

index 403337a..fd426b7 100644

qemu-kvm-x86.c +1 -1
@@ -598,7 +598,7 @@ int kvm_arch_qemu_create_context(void)
 
  #ifdef KVM_CAP_ADJUST_CLOCK
      if (kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK))
-        vmstate_register(0,&vmstate_kvmclock,&kvmclock_data);
+        vmstate_register(NULL, 0,&vmstate_kvmclock,&kvmclock_data);
  #endif
 
 

It's worrying that I didn't see this. I'll update the kvm headers in qemu-kvm.git.

Signature · 1 line
error compiling committee.c: too many arguments to function