Skip to contentSkip to conversation

Bugfixes for 2.3.0-rc2

GIT PULL Applied Paolo Bonzini 3 participants 10 messages Apr 1, 2015 Arm STM32

lore
Share & tools
lore
#0 lore raw

The following changes since commit 033a20359aaf93f4d8aa2be12558901e8e028baa:

Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging (2015-03-31 12:12:23 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 4025446f0ac6213335c22ec43f3c3d8362ce7286:

Revert "exec: Respect as_tranlsate_internal length clamp" (2015-04-01 10:06:38 +0200)

----------------------------------------------------------------
Fix for object_del of in-use memory, pvpanic regression, PPC regression and bogus error message with Oxygen theme.

----------------------------------------------------------------
Igor Mammedov (1):
pc: acpi: fix pvpanic regression

Lin Ma (2):
qom: Add can_be_deleted callback to UserCreatableClass
hostmem: Prevent removing an in-use memory backend

Paolo Bonzini (2):
rcu: do not create thread in pthread_atfork callback Revert "exec: Respect as_tranlsate_internal length clamp"

 backends/hostmem.c              | 14 ++++++++++++++
 exec.c                          |  6 ++++--
 hw/i386/acpi-build.c            |  2 +-
 include/qemu/rcu.h              |  1 +
 include/qom/object_interfaces.h | 13 +++++++++++++
 linux-user/syscall.c            |  1 +
 os-posix.c                      |  2 ++
 qmp.c                           |  5 +++++
 qom/object_interfaces.c         | 12 ++++++++++++
 util/rcu.c                      |  7 +++----
 10 files changed, 56 insertions(+), 7 deletions(-)
Signature · 1 line
2.3.4
#1 lore raw

[Qemu-devel] [PULL 1/5] qom: Add can_be_deleted callback to UserCreatableClass

From: Lin Ma <[email protected]>

If backends implement the can_be_deleted and it returns false, Then the qmp_object_del won't delete the given backends.

Message-Id: <[email protected]>

---
 include/qom/object_interfaces.h | 13 +++++++++++++
 qmp.c                           |  5 +++++
 qom/object_interfaces.c         | 12 ++++++++++++
 3 files changed, 30 insertions(+)
include/qom/object_interfaces.h +13 -0
index b792283..283ae0d 100644
@@ -25,6 +25,8 @@ typedef struct UserCreatable {
  * UserCreatableClass:
  * @parent_class: the base class
  * @complete: callback to be called after @obj's properties are set.
+ * @can_be_deleted: callback to be called before an object is removed
+ * to check if @obj can be removed safely.
  *
  * Interface is designed to work with -object/object-add/object_add
  * commands.
@@ -47,6 +49,7 @@ typedef struct UserCreatableClass {
 
     /* <public> */
     void (*complete)(UserCreatable *uc, Error **errp);
+    bool (*can_be_deleted)(UserCreatable *uc, Error **errp);
 } UserCreatableClass;
 
 /**
@@ -59,4 +62,14 @@ typedef struct UserCreatableClass {
  * nothing.
  */
 void user_creatable_complete(Object *obj, Error **errp);
+
+/**
+ * user_creatable_can_be_deleted:
+ * @uc: the object whose can_be_deleted() method is called if implemented
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Wrapper to call can_be_deleted() method if one of types it's inherited
+ * from implements USER_CREATABLE interface.
+ */
+bool user_creatable_can_be_deleted(UserCreatable *uc, Error **errp);
 #endif
qmp.c +5 -0
index c479e77..e6c7050 100644
@@ -711,6 +711,11 @@ void qmp_object_del(const char *id, Error **errp)
         error_setg(errp, "object id not found");
         return;
     }
+
+    if (!user_creatable_can_be_deleted(USER_CREATABLE(obj), errp)) {
+        error_setg(errp, "%s is in use, can not be deleted", id);
+        return;
+    }
     object_unparent(obj);
 }
 
qom/object_interfaces.c +12 -0
index 6360818..a66cd60 100644
@@ -18,6 +18,18 @@ void user_creatable_complete(Object *obj, Error **errp)
     }
 }
 
+bool user_creatable_can_be_deleted(UserCreatable *uc, Error **errp)
+{
+
+    UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
+
+    if (ucc->can_be_deleted) {
+        return ucc->can_be_deleted(uc, errp);
+    } else {
+        return true;
+    }
+}
+
 static void register_types(void)
 {
     static const TypeInfo uc_interface_info = {
Signature · 1 line
2.3.4
#2 lore raw

[Qemu-devel] [PULL 3/5] pc: acpi: fix pvpanic regression

In reply to Paolo Bonzini

From: Igor Mammedov <[email protected]>

Commit cd61cb2 pc: acpi-build: generate pvpanic device description dynamically

introduced regression changing pvpanic device HID from QEMU0001 to QEMU0002.
Fix AML generated code so that pvpanic device would keep its original HID. i.e. QEMU0001

Message-Id: <[email protected]>

---
 hw/i386/acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/acpi-build.c +1 -1
index d0a5c85..e761005 100644
@@ -788,7 +788,7 @@ build_ssdt(GArray *table_data, GArray *linker,
         scope = aml_scope("\\_SB.PCI0.ISA");
 
         dev = aml_device("PEVR");
-        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
+        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
 
         crs = aml_resource_template();
         aml_append(crs,
Signature · 1 line
2.3.4
#3 lore raw

[Qemu-devel] [PULL 2/5] hostmem: Prevent removing an in-use memory backend

In reply to Paolo Bonzini

From: Lin Ma <[email protected]>

showing a memory device whose memdev is removed leads an assert:

(qemu) object_add memory-backend-ram,id=ram0,size=128M (qemu) device_add pc-dimm,id=d0,memdev=ram0 (qemu) object_del ram0
(qemu) info memory-devices
**

ERROR:qom/object.c:1274:object_get_canonical_path_component:\
                            assertion failed: (obj->parent != NULL)

Aborted

The patch prevents removing an in-use mem backend and error out.

Message-Id: <[email protected]>

---
 backends/hostmem.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
backends/hostmem.c +14 -0
index 99e8f99..b7b6cf8 100644
@@ -335,12 +335,26 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
     }
 }
 
+static bool
+host_memory_backend_can_be_deleted(UserCreatable *uc, Error **errp)
+{
+    MemoryRegion *mr;
+
+    mr = host_memory_backend_get_memory(MEMORY_BACKEND(uc), errp);
+    if (memory_region_is_mapped(mr)) {
+        return false;
+    } else {
+        return true;
+    }
+}
+
 static void
 host_memory_backend_class_init(ObjectClass *oc, void *data)
 {
     UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
 
     ucc->complete = host_memory_backend_memory_complete;
+    ucc->can_be_deleted = host_memory_backend_can_be_deleted;
 }
 
 static const TypeInfo host_memory_backend_info = {
Signature · 1 line
2.3.4
#4 lore raw

[Qemu-devel] [PULL 5/5] Revert "exec: Respect as_tranlsate_internal length clamp"

In reply to Paolo Bonzini

This reverts commit c3c1bb99d1c11978d9ce94d1bdcf0705378c1459. It causes problems with boards that declare memory regions shorter than the registers they contain.

---
 exec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
exec.c +4 -2
index 6d1e1e4..874ecfc 100644
@@ -380,6 +380,7 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
     IOMMUTLBEntry iotlb;
     MemoryRegionSection *section;
     MemoryRegion *mr;
+    hwaddr len = *plen;
 
     rcu_read_lock();
     for (;;) {
@@ -394,7 +395,7 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
         iotlb = mr->iommu_ops->translate(mr, addr, is_write);
         addr = ((iotlb.translated_addr & ~iotlb.addr_mask)
                 | (addr & iotlb.addr_mask));
-        *plen = MIN(*plen, (addr | iotlb.addr_mask) - addr + 1);
+        len = MIN(len, (addr | iotlb.addr_mask) - addr + 1);
         if (!(iotlb.perm & (1 << is_write))) {
             mr = &io_mem_unassigned;
             break;
@@ -405,9 +406,10 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
 
     if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
         hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr;
-        *plen = MIN(page, *plen);
+        len = MIN(page, len);
     }
 
+    *plen = len;
     *xlat = addr;
     rcu_read_unlock();
     return mr;
Signature · 1 line
2.3.4
#5 lore raw

Re: [Qemu-devel] [PULL 5/5] Revert "exec: Respect as_tranlsate_internal length clamp"

Quoted 1 line · Paolo Bonzini

This reverts commit c3c1bb99d1c11978d9ce94d1bdcf0705378c1459.

Which means the typo in that commit message (tranlsate) is perpetuated here too. Cute. Thankfully doesn't hurt anything other than bothering OCD editors (does that mean I'm becoming one? :)

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw

Re: [Qemu-devel] [PULL 5/5] Revert "exec: Respect as_tranlsate_internal length clamp"

Quoted 5 lines · Eric Blake
Quoted 1 line · Paolo Bonzini

This reverts commit c3c1bb99d1c11978d9ce94d1bdcf0705378c1459.

Which means the typo in that commit message (tranlsate) is perpetuated here too. Cute.

Yep, but since we're quoting the earlier commit message it's correct to include it typo and all. I guess Paolo could have added a "(sic)" :-)

-- PMM

#7 lore raw

Re: [Qemu-devel] [PULL 5/5] Revert "exec: Respect as_tranlsate_internal length clamp"

Quoted 8 lines · Peter Maydell
Quoted 5 lines
Quoted 5 lines · Paolo Bonzini
Quoted 1 line
Quoted 1 line

This reverts commit c3c1bb99d1c11978d9ce94d1bdcf0705378c1459.

Which means the typo in that commit message (tranlsate) is perpetuated here too. Cute.

Yep, but since we're quoting the earlier commit message it's correct to include it typo and all. I guess Paolo could have added a "(sic)" :-)

I have fixed the typo in the version I staged for 2.4. :)

Paolo

#8 lore raw

[Qemu-devel] [PULL 4/5] rcu: do not create thread in pthread_atfork callback

In reply to Paolo Bonzini

If QEMU forks after the CPU threads have been created, qemu_mutex_lock_iothread will not be able to do qemu_cpu_kick_thread. There is no solution other than assuming that forks after the CPU threads have been created will end up in an exec. Forks before the CPU threads have been created (such as -daemonize) have to call rcu_after_fork manually.

Notably, the oxygen theme for GTK+ forks and shows a "No such process" error without this patch.

This patch can be reverted once the iothread loses the "kick the TCG thread" magic.

User-mode emulation does not use the iothread, so it can also call rcu_after_fork.

Reported by: Dr. David Alan Gilbert <[email protected]> Tested by: Dr. David Alan Gilbert <[email protected]>

---
 include/qemu/rcu.h   | 1 +
 linux-user/syscall.c | 1 +
 os-posix.c           | 2 ++
 util/rcu.c           | 7 +++----
 4 files changed, 7 insertions(+), 4 deletions(-)
include/qemu/rcu.h +1 -0
index 506ab58..7df1e86 100644
@@ -117,6 +117,7 @@ extern void synchronize_rcu(void);
  */
 extern void rcu_register_thread(void);
 extern void rcu_unregister_thread(void);
+extern void rcu_after_fork(void);
 
 struct rcu_head;
 typedef void RCUCBFunc(struct rcu_head *head);
linux-user/syscall.c +1 -0
index 4bd9543..1622ad6 100644
@@ -4572,6 +4572,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
         ret = fork();
         if (ret == 0) {
             /* Child Process.  */
+            rcu_after_fork();
             cpu_clone_regs(env, newsp);
             fork_end(1);
             /* There is a race condition here.  The parent process could
os-posix.c +2 -0
index ba091f1..e4da406 100644
@@ -39,6 +39,7 @@
 #include "sysemu/sysemu.h"
 #include "net/slirp.h"
 #include "qemu-options.h"
+#include "qemu/rcu.h"
 
 #ifdef CONFIG_LINUX
 #include <sys/prctl.h>
@@ -247,6 +248,7 @@ void os_daemonize(void)
         signal(SIGTSTP, SIG_IGN);
         signal(SIGTTOU, SIG_IGN);
         signal(SIGTTIN, SIG_IGN);
+        rcu_after_fork();
     }
 }
 
util/rcu.c +3 -4
index 27802a4..7270151 100644
@@ -311,19 +311,18 @@ static void rcu_init_unlock(void)
 {
     qemu_mutex_unlock(&rcu_gp_lock);
 }
+#endif
 
-static void rcu_init_child(void)
+void rcu_after_fork(void)
 {
-    qemu_mutex_unlock(&rcu_gp_lock);
     memset(&registry, 0, sizeof(registry));
     rcu_init_complete();
 }
-#endif
 
 static void __attribute__((__constructor__)) rcu_init(void)
 {
 #ifdef CONFIG_POSIX
-    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child);
+    pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_unlock);
 #endif
     rcu_init_complete();
 }
Signature · 1 line
2.3.4
#9 lore raw
In reply to Paolo Bonzini
Quoted 8 lines · Paolo Bonzini

The following changes since commit 033a20359aaf93f4d8aa2be12558901e8e028baa:

Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging (2015-03-31 12:12:23 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream

Quoted 9 lines

for you to fetch changes up to 4025446f0ac6213335c22ec43f3c3d8362ce7286:

Revert "exec: Respect as_tranlsate_internal length clamp" (2015-04-01 10:06:38 +0200)

----------------------------------------------------------------
Fix for object_del of in-use memory, pvpanic regression, PPC regression and bogus error message with Oxygen theme.

Applied, thanks.

-- PMM