From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8FQW-0007wU-JQ for qemu-devel@nongnu.org; Sun, 24 May 2009 11:15:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8FQR-0007nz-EU for qemu-devel@nongnu.org; Sun, 24 May 2009 11:15:51 -0400 Received: from [199.232.76.173] (port=34645 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8FQR-0007nn-As for qemu-devel@nongnu.org; Sun, 24 May 2009 11:15:47 -0400 Received: from mx2.redhat.com ([66.187.237.31]:38001) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M8FQQ-0003El-PL for qemu-devel@nongnu.org; Sun, 24 May 2009 11:15:47 -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 n4OFEmaP022729 for ; Sun, 24 May 2009 11:14:48 -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 n4OFEmS6016003 for ; Sun, 24 May 2009 11:14:48 -0400 Received: from localhost.localdomain (vpn-12-4.rdu.redhat.com [10.11.12.4]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4OFEkkP002749 for ; Sun, 24 May 2009 11:14:47 -0400 Message-ID: <4A196483.1070600@redhat.com> Date: Sun, 24 May 2009 18:15:15 +0300 From: Dor Laor MIME-Version: 1.0 References: <49F9F86C.3000009@redhat.com> <20090430200901.GA30530@lst.de> <49FA0788.5000809@redhat.com> <20090430203122.GA31440@lst.de> <49FA1117.1070306@codemonkey.ws> <49FA1564.5050609@redhat.com> <49FA180B.8050806@codemonkey.ws> In-Reply-To: <49FA180B.8050806@codemonkey.ws> Content-Type: multipart/mixed; boundary="------------040705060905090504020103" Subject: [Qemu-devel] [PATCH]Optionally change the virtio-block storage class to PCI_CLASS_STORAGE_SCSI Reply-To: dlaor@redhat.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel This is a multi-part message in MIME format. --------------040705060905090504020103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Here is a new patch that allows a configurable option to be passed to qemu. The default will be PCI_CLASS_STORAGE_SCSI. To be able to sustain migration from older qemu's, a parameter - driver ...,class=128 can be passed. While it's not the most beautiful piece of code, it aligned with current qemu code. --------------040705060905090504020103 Content-Type: text/plain; name="0001-Optionaly-change-the-virtio-block-storage-class-to-P.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-Optionaly-change-the-virtio-block-storage-class-to-P.pa"; filename*1="tch" >>From a19863b191e5e32812ddcbd63f88826ff16d2298 Mon Sep 17 00:00:00 2001 From: Dor Laor Date: Sun, 24 May 2009 18:01:39 +0300 Subject: [PATCH] Optionally change the virtio-block storage class to PCI_CLASS_STORAGE_SCSI Windows whql tests does not recognizes the virtio device since its storage class is PCI_CLASS_STORAGE_OTHER. Changing the default and allow and option to pass the class as -drive file=...,class=128. Signed-off-by: Dor Laor --- hw/virtio-blk.c | 7 +++++++ hw/virtio-pci.c | 6 +++++- hw/virtio.h | 1 + sysemu.h | 2 ++ vl.c | 23 ++++++++++++++++++++++- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 8dd3c7a..7f89e0d 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -348,6 +348,13 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) return 0; } +int virtio_blk_get_class(DeviceState *dev) +{ + VirtIOBlock *s = (VirtIOBlock *)dev; + + return drive_get_class_code(s->bs); +} + VirtIODevice *virtio_blk_init(DeviceState *dev) { VirtIOBlock *s; diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index c072423..77d4a54 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -14,6 +14,7 @@ */ #include +#include #include "virtio.h" #include "pci.h" @@ -286,12 +287,15 @@ static void virtio_blk_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); VirtIODevice *vdev; + int class_code; vdev = virtio_blk_init(&pci_dev->qdev); + if ((class_code = virtio_blk_get_class(vdev)) == -1) + class_code = PCI_CLASS_STORAGE_SCSI; virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BLOCK, - PCI_CLASS_STORAGE_OTHER, + (uint16_t)class_code, 0x00); } diff --git a/hw/virtio.h b/hw/virtio.h index 425727e..fd8b7a7 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -151,5 +151,6 @@ VirtIODevice *virtio_blk_init(DeviceState *dev); VirtIODevice *virtio_net_init(DeviceState *dev); VirtIODevice *virtio_console_init(DeviceState *dev); VirtIODevice *virtio_balloon_init(DeviceState *dev); +int virtio_blk_get_class(DeviceState *dev); #endif diff --git a/sysemu.h b/sysemu.h index 92501ed..659e222 100644 --- a/sysemu.h +++ b/sysemu.h @@ -154,6 +154,7 @@ typedef struct DriveInfo { BlockDriverState *bdrv; BlockInterfaceType type; int bus; + int class; int unit; int used; int drive_opt_idx; @@ -174,6 +175,7 @@ extern void drive_uninit(BlockDriverState *bdrv); extern void drive_remove(int index); extern const char *drive_get_serial(BlockDriverState *bdrv); extern BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv); +extern int drive_get_class_code(BlockDriverState *bdrv); BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type); diff --git a/vl.c b/vl.c index 2c1f0e0..5c8ac6f 100644 --- a/vl.c +++ b/vl.c @@ -2181,6 +2181,17 @@ BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv) return BLOCK_ERR_STOP_ENOSPC; } +extern int drive_get_class_code(BlockDriverState *bdrv) +{ + int index; + + for (index = 0; index < nb_drives; index++) + if (drives_table[index].bdrv == bdrv) + return drives_table[index].class; + + return -1; +} + static void bdrv_format_print(void *opaque, const char *name) { fprintf(stderr, " %s", name); @@ -2218,13 +2229,14 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) int index; int cache; int bdrv_flags, onerror; + int class = -1; int drives_table_idx; char *str = arg->opt; static const char * const params[] = { "bus", "unit", "if", "index", "cyls", "heads", "secs", "trans", "media", "snapshot", "file", "cache", "format", "serial", "werror", - NULL }; + "class", NULL }; if (check_params(params, str) < 0) { fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n", @@ -2355,6 +2367,14 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) } } + if (get_param_value(buf, sizeof(buf), "class", str)) { + if (type != IF_VIRTIO) { + fprintf(stderr, "class is no supported by this format\n"); + return -1; + } + class = strtol(buf, NULL, 0); + } + if (get_param_value(buf, sizeof(buf), "media", str)) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; @@ -2502,6 +2522,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) drives_table[drives_table_idx].bus = bus_id; drives_table[drives_table_idx].unit = unit_id; drives_table[drives_table_idx].onerror = onerror; + drives_table[drives_table_idx].class = class; drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt; strncpy(drives_table[drives_table_idx].serial, serial, sizeof(serial)); nb_drives++; -- 1.5.6.6 --------------040705060905090504020103--