From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] kvm: qemu: check device assignment command Date: Thu, 26 Mar 2009 14:04:37 +0200 Message-ID: <49CB6F55.10603@redhat.com> References: <715D42877B251141A38726ABF5CABF2C01A11B66EE@pdsmsx503.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "'kvm@vger.kernel.org'" To: "Han, Weidong" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:42184 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753158AbZCZMEk (ORCPT ); Thu, 26 Mar 2009 08:04:40 -0400 In-Reply-To: <715D42877B251141A38726ABF5CABF2C01A11B66EE@pdsmsx503.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Han, Weidong wrote: > 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); > I suggest replacing the parsing code with pci_parse_devaddr() (needs to be extended to support functions) so that all the checking and parsing is done in one place. -- error compiling committee.c: too many arguments to function