public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] kvm: qemu: check device assignment command
@ 2009-03-26  9:02 Han, Weidong
  2009-03-26 12:04 ` Avi Kivity
  0 siblings, 1 reply; 6+ messages in thread
From: Han, Weidong @ 2009-03-26  9:02 UTC (permalink / raw)
  To: 'Avi Kivity'; +Cc: 'kvm@vger.kernel.org'

[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]

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 <weidong.han@intel.com>
---
 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);
-- 
1.6.0.4

[-- Attachment #2: 0002-kvm-qemu-check-device-assignment-command.patch --]
[-- Type: application/octet-stream, Size: 1251 bytes --]

From 7ce0e9784ec2d9743fce28537c3369d924b33a90 Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Fri, 27 Mar 2009 00:53:06 +0800
Subject: [PATCH] kvm: qemu: check device assignment command

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 <weidong.han@intel.com>
---
 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);
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-01  9:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-26  9:02 [PATCH 2/2] kvm: qemu: check device assignment command Han, Weidong
2009-03-26 12:04 ` Avi Kivity
2009-03-27  9:31   ` Han, Weidong
2009-03-29 14:35     ` Avi Kivity
2009-03-30 12:41       ` Han, Weidong
2009-04-01  9:18         ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox