From patchwork Thu Mar 26 09:02:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Han, Weidong" X-Patchwork-Id: 14496 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 n2Q94ION031349 for ; Thu, 26 Mar 2009 09:04:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754520AbZCZJES (ORCPT ); Thu, 26 Mar 2009 05:04:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754576AbZCZJES (ORCPT ); Thu, 26 Mar 2009 05:04:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:19940 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754446AbZCZJER (ORCPT ); Thu, 26 Mar 2009 05:04:17 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 26 Mar 2009 02:00:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,425,1233561600"; d="scan'208,223";a="676134564" Received: from pgsmsx603.gar.corp.intel.com ([10.221.43.87]) by fmsmga001.fm.intel.com with ESMTP; 26 Mar 2009 02:07:59 -0700 Received: from pdsmsx601.ccr.corp.intel.com (172.16.12.94) by pgsmsx603.gar.corp.intel.com (10.221.43.87) with Microsoft SMTP Server (TLS) id 8.1.340.0; Thu, 26 Mar 2009 17:02:58 +0800 Received: from pdsmsx503.ccr.corp.intel.com ([172.16.12.95]) by pdsmsx601.ccr.corp.intel.com ([172.16.12.94]) with mapi; Thu, 26 Mar 2009 17:02:57 +0800 From: "Han, Weidong" To: "'Avi Kivity'" CC: "'kvm@vger.kernel.org'" Date: Thu, 26 Mar 2009 17:02:55 +0800 Subject: [PATCH 2/2] kvm: qemu: check device assignment command Thread-Topic: [PATCH 2/2] kvm: qemu: check device assignment command Thread-Index: Acmt8aaotAwNUYcBSdOFOXQY5vC3dQ== Message-ID: <715D42877B251141A38726ABF5CABF2C01A11B66EE@pdsmsx503.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Device assignment command is like "-pcidevice host=xx:yy.z". Check bus:dev.func length to make sure its format is xx:yy.z. Signed-off-by: Weidong Han --- qemu/hw/device-assignment.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c index cef7c8a..50a0d5c 100644 --- a/qemu/hw/device-assignment.c +++ b/qemu/hw/device-assignment.c @@ -1196,7 +1196,7 @@ out: AssignedDevInfo *add_assigned_device(const char *arg) { char *cp, *cp1; - char device[8]; + char device[9]; char dma[6]; int r; AssignedDevInfo *adev; @@ -1207,6 +1207,9 @@ AssignedDevInfo *add_assigned_device(const char *arg) return NULL; } r = get_param_value(device, sizeof(device), "host", arg); + /* b:d.f format: xx:yy.z */ + if (r != 7) + goto bad; r = get_param_value(adev->name, sizeof(adev->name), "name", arg); if (!r) snprintf(adev->name, sizeof(adev->name), "%s", device);