From patchwork Thu Jul 23 08:52:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 36947 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6N8rHoL008666 for ; Thu, 23 Jul 2009 08:53:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751716AbZGWIxO (ORCPT ); Thu, 23 Jul 2009 04:53:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751601AbZGWIxO (ORCPT ); Thu, 23 Jul 2009 04:53:14 -0400 Received: from mx2.redhat.com ([66.187.237.31]:50612 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990AbZGWIxO (ORCPT ); Thu, 23 Jul 2009 04:53:14 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6N8rEJc005405 for ; Thu, 23 Jul 2009 04:53:14 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6N8rDT1008012; Thu, 23 Jul 2009 04:53:13 -0400 Received: from redhat.com (dhcp-0-94.tlv.redhat.com [10.35.0.94]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6N8rBag006884; Thu, 23 Jul 2009 04:53:11 -0400 Date: Thu, 23 Jul 2009 11:52:16 +0300 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org, avi@redhat.com, gleb@redhat.com, mtosatti@redhat.com Subject: [PATCHv2] qemu-kvm: routing table update thinko fix Message-ID: <20090723085216.GA10799@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When updating irq routing entries, we should memcpy the new entry over the old one. Current code gets it wrong, and only works because it's uncommon for guests to change tables. Signed-off-by: Michael S. Tsirkin --- Changes since v1: updated irqchip case as well qemu-kvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 60e5eac..b4de9c6 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1544,7 +1544,7 @@ int kvm_update_routing_entry(kvm_context_t kvm, case KVM_IRQ_ROUTING_IRQCHIP: if (e->u.irqchip.irqchip == entry->u.irqchip.irqchip && e->u.irqchip.pin == entry->u.irqchip.pin) { - memcpy(&e->u.irqchip, &entry->u.irqchip, sizeof e->u.irqchip); + memcpy(&e->u.irqchip, &newentry->u.irqchip, sizeof e->u.irqchip); return 0; } break; @@ -1552,7 +1552,7 @@ int kvm_update_routing_entry(kvm_context_t kvm, if (e->u.msi.address_lo == entry->u.msi.address_lo && e->u.msi.address_hi == entry->u.msi.address_hi && e->u.msi.data == entry->u.msi.data) { - memcpy(&e->u.msi, &entry->u.msi, sizeof e->u.msi); + memcpy(&e->u.msi, &newentry->u.msi, sizeof e->u.msi); return 0; } break;