[Qemu-devel] [PATCH 2/3] vhost/scsi: Add VIRTIO_SCSI_F_T10_PI host_feature bit
From: Nicholas Bellinger Signed-off-by: Nicholas Bellinger --- hw/scsi/vhost-scsi.c| 1 + hw/scsi/virtio-scsi.c | 3 +++ hw/virtio/virtio-pci.c | 2 ++ include/hw/i386/pc.h| 13 - include/hw/virtio/virtio-scsi.h | 5 - 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index dcb2bc5..95f7b99 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -31,6 +31,7 @@ static const int kernel_feature_bits[] = { VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, +VIRTIO_SCSI_F_T10_PI, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 9e2c718..61e9988 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -887,6 +887,9 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp) return; } +/* Protection information is not supported yet. */ +vdev->guest_features &= ~VIRTIO_SCSI_F_T10_PI; + scsi_bus_new(&s->bus, sizeof(s->bus), dev, &virtio_scsi_scsi_info, vdev->bus_name); /* override default SCSI bus hotplug-handler, with virtio-scsi's one */ diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 5127efb..861ec95 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1200,6 +1200,8 @@ static Property vhost_scsi_pci_properties[] = { DEV_NVECTORS_UNSPECIFIED), DEFINE_PROP_BIT("hotplug", VirtIOPCIProxy, host_features, VIRTIO_SCSI_F_HOTPLUG, true), +DEFINE_PROP_BIT("prot_info", VirtIOPCIProxy, host_features, + VIRTIO_SCSI_F_T10_PI, true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 69d9cf8..c81e2e9 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -315,7 +315,18 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .driver = "virtio-scsi-pci",\ .property = "any_layout",\ .value= "off",\ -},{\ +},\ +{\ +.driver = "virtio-scsi-pci",\ +.property = "prot_info",\ +.value= "off",\ +},\ +{\ +.driver = "vhost-scsi-pci",\ +.property = "prot_info",\ +.value= "off",\ +},\ +{\ .driver = "PIIX4_PM",\ .property = "memory-hotplug-support",\ .value= "off",\ diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index bf17cc9..08bc54a 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -36,6 +36,7 @@ #define VIRTIO_SCSI_F_INOUT0 #define VIRTIO_SCSI_F_HOTPLUG 1 #define VIRTIO_SCSI_F_CHANGE 2 +#define VIRTIO_SCSI_F_T10_PI 3 #define VIRTIO_SCSI_VQ_SIZE 128 #define VIRTIO_SCSI_CDB_SIZE32 @@ -258,7 +259,9 @@ QEMU_BUILD_BUG_ON(offsetof(VirtIOSCSIReq, req.cdb) != DEFINE_PROP_BIT("hotplug", _state, _feature_field, VIRTIO_SCSI_F_HOTPLUG, \ true), \ DEFINE_PROP_BIT("param_change", _state, _feature_field, \ -VIRTIO_SCSI_F_CHANGE, true) +VIRTIO_SCSI_F_CHANGE, true), \ +DEFINE_PROP_BIT("prot_info", _state, _feature_field, \ +VIRTIO_SCSI_F_T10_PI, true) typedef void (*HandleOutput)(VirtIODevice *, VirtQueue *); -- 1.9.1
[Qemu-devel] [PATCH 1/3] vhost/scsi: Add VIRTIO_SCSI_F_HOTPLUG host_feature bit
From: Nicholas Bellinger Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio/virtio-pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index dde1d73..5127efb 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1198,6 +1198,8 @@ static const TypeInfo virtio_scsi_pci_info = { static Property vhost_scsi_pci_properties[] = { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), +DEFINE_PROP_BIT("hotplug", VirtIOPCIProxy, host_features, + VIRTIO_SCSI_F_HOTPLUG, true), DEFINE_PROP_END_OF_LIST(), }; -- 1.9.1
[Qemu-devel] [PATCH 3/3] vhost/scsi: Add VIRTIO_F_ANY_LAYOUT host_feature bit
From: Nicholas Bellinger Signed-off-by: Nicholas Bellinger --- hw/scsi/vhost-scsi.c | 1 + hw/virtio/virtio-pci.c | 2 ++ include/hw/i386/pc.h | 5 + 3 files changed, 8 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 95f7b99..bfb7005 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -32,6 +32,7 @@ static const int kernel_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_SCSI_F_T10_PI, +VIRTIO_F_ANY_LAYOUT, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 861ec95..7863dcc 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1198,6 +1198,8 @@ static const TypeInfo virtio_scsi_pci_info = { static Property vhost_scsi_pci_properties[] = { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), +DEFINE_PROP_BIT("any_layout", VirtIOPCIProxy, host_features, + VIRTIO_F_ANY_LAYOUT, true), DEFINE_PROP_BIT("hotplug", VirtIOPCIProxy, host_features, VIRTIO_SCSI_F_HOTPLUG, true), DEFINE_PROP_BIT("prot_info", VirtIOPCIProxy, host_features, diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index c81e2e9..16f52bd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -322,6 +322,11 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value= "off",\ },\ {\ +.driver = "vhost-scsi-pci", \ +.property = "any_layout",\ +.value= "off",\ +},\ +{\ .driver = "vhost-scsi-pci",\ .property = "prot_info",\ .value= "off",\ -- 1.9.1
[Qemu-devel] [PATCH 0/3] vhost/scsi: Enable virtio 1.0 host_feature bits
From: Nicholas Bellinger Hi MST & Paolo, Here are the associated QEMU vhost/scsi changes to enable KVM host for expose F_HOTPLUG, F_T10_PI, and ANY_LAYOUT feature bits into virtio 1.0 compatible guests. Note this does not include VIRTIO_SCSI_F_CHANGE, which is currently not supported by vhost/scsi kernel code host_feature bits. Thank you, --nab Nicholas Bellinger (3): vhost/scsi: Add VIRTIO_SCSI_F_HOTPLUG host_feature bit vhost/scsi: Add VIRTIO_SCSI_F_T10_PI host_feature bit vhost/scsi: Add VIRTIO_F_ANY_LAYOUT host_feature bit hw/scsi/vhost-scsi.c| 2 ++ hw/scsi/virtio-scsi.c | 3 +++ hw/virtio/virtio-pci.c | 6 ++ include/hw/i386/pc.h| 18 +- include/hw/virtio/virtio-scsi.h | 5 - 5 files changed, 32 insertions(+), 2 deletions(-) -- 1.9.1
Re: [Qemu-devel] [PATCH] virtio-scsi: fix object check failure
Hi Ming & Paolo, On Wed, 2014-06-18 at 23:11 +0800, Ming Lei wrote: > On Wed, Jun 18, 2014 at 11:06 PM, Paolo Bonzini wrote: > > Il 18/06/2014 17:02, Paolo Bonzini ha scritto: > > > >> Il 18/06/2014 16:18, Ming Lei ha scritto: > > > This should never be triggered by vhost-scsi. Perhaps a bug in the > kernel? > >>> > >>> It can be triggered with rmmod, system suspend, reboot... > >> > >> > >> Yes, but it should not. > >> > >> What happens if you change VHOST_SCSI_VQ_NUM_FIXED from 2 to 3? > > > > > > Sorry, brain fart here. The number of interrupts in virtio-scsi is queues+3 > > because of the configuration interrupt. This does not apply here. > > > > Anyway, vhost-scsi passes the number of virtqueues correctly to the kernel. > > > > QEMU might be triggering this because, when vhost is stopped, the queue is > > still not empty (as expected, since it's a receive queue). > > > > Can you check that this is the case? > > Yes, that is the case. > > > > > If so, patching QEMU is correct, but you need to change VIRTIO_SCSI(vdev) to > > VIRTIO_SCSI_COMMON(vdev), and move events_dropped from VirtIOSCSI to > > VirtIOSCSICommon. > > This approach should be better. Just curious if this patch was picked up by upstream yet, and if it needs to be CC'd to stable for vhost-scsi code in >= v1.5.y ..? Thanks, --nab
Re: [Qemu-devel] MSI interrupt support with vioscsi.c miniport driver
On Wed, 2014-02-19 at 19:03 +1100, Vadim Rozenfeld wrote: > On Tue, 2014-02-18 at 13:00 -0800, Nicholas A. Bellinger wrote: > > On Mon, 2014-02-10 at 11:05 -0800, Nicholas A. Bellinger wrote: > > > > > > > > > > > > Hi Yan, > > > > > > > > > > > > So recently I've been doing some KVM guest performance comparisons > > > > > > between the scsi-mq prototype using virtio-scsi + vhost-scsi, and > > > > > > Windows Server 2012 with vioscsi.sys (virtio-win-0.1-74.iso) + > > > > > > vhost-scsi using PCIe flash backend devices. > > > > > > > > > > > > I've noticed that small block random performance for the MSFT guest > > > > > > is > > > > > > at around ~80K IOPs with multiple vioscsi LUNs + adapters, which > > > > > > ends up > > > > > > being well below what the Linux guest with scsi-mq + virtio-scsi is > > > > > > capable of (~500K). > > > > > > > > > > > > After searching through the various vioscsi registry settings, it > > > > > > appears that MSIEnabled is being explicitly disabled (0x), > > > > > > that > > > > > > is different from what vioscsi.inx is currently defining: > > > > > > > > > > > > [pnpsafe_pci_addreg_msix] > > > > > > HKR, "Interrupt Management",, 0x0010 > > > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties",, > > > > > > 0x0010 > > > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > > > > MSISupported, 0x00010001, 0 > > > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > > > > MessageNumberLimit, 0x00010001, 4 > > > > > > > > > > > > Looking deeper at vioscsi.c code, I've noticed that MSI_SUPPORTED=0 > > > > > > is > > > > > > explicitly disabled at build time in SOURCES + vioscsi.vcxproj, as > > > > > > well > > > > > > as VioScsiFindAdapter() code always ends setting msix_enabled = > > > > > > FALSE > > > > > > here, regardless of MSI_SUPPORTED: > > > > > > > > > > > > > > > > > > https://github.com/YanVugenfirer/kvm-guest-drivers-windows/blob/master/vioscsi/vioscsi.c#L340 > > > > > > > > > > > > Also looking at virtio_stor.c for the raw block driver, > > > > > > MSI_SUPPORTED=1 > > > > > > appears to be the default setting for the driver included in the > > > > > > offical > > > > > > virtio-win iso builds, right..? > > > > > > > > > > > > Sooo, I'd like to try enabling MSI_SUPPORTED=1 in a test vioscsi.sys > > > > > > build of my own, but before going down the WDK development rabbit > > > > > > whole, > > > > > > I'd like to better understand why you've explicitly disabled this > > > > > > logic > > > > > > within vioscsi.c code to start..? > > > > > > > > > > > > Is there anything that needs to be addressed / carried over from > > > > > > virtio_stor.c in order to get MSI_SUPPORTED=1 to work with vioscsi.c > > > > > > miniport code..? > > > > > > > > Hi Nicholas, > > > > > > > > I was thinking about enabling MSI in RHEL 6.6 (build 74) but for some > > > > reasons decided to keep it disabled until adding mq support. > > > > > > > > > > > > You definitely should be able to turn on MSI_SUPPORTED, rebuild the > > > > driver, and switch MSISupported to 1 to make vioscsi driver working in > > > > MSI mode. > > > > > > > > > > Thanks for the quick response. We'll give MSI_SUPPORTED=1 a shot over > > > the next days with a test build on Server 2012 / Server 2008 R2 and see > > > how things go.. > > > > > > > Just a quick update on progress. > > > > I've been able to successfully build + load a unsigned vioscsi.sys > > driver on Server 2012 with WDK 8.0. > > > > Running with MSI_SUPPORTED=1 against vhost-scsi results in a significant > > performance and efficiency gain, on the order of 100K to 225K IOPs for > > 4K block random I/O workload, depending on read/write mix. > > > > Below is a simple patch to enable MSI operation by default. Any chance > > to apply this separate from future mq efforts..? > > Yes, we differently can enable MSI and rebuild vioscsi. > But then we need to re-spin WHQL testing for this particular > driver. This process requires a lot of resources, and I doubt that > it will be initiated soon, unless we have some significant amount of > bug-fixes. > Any idea on a rough time frame to expect an official WHQL build with MSI enabled..? Or, would it be possible to generate some -BETA builds that are at least signed and don't require extra hoops to jump through for testing..? Thanks again, --nab
Re: [Qemu-devel] MSI interrupt support with vioscsi.c miniport driver
On Tue, 2014-02-18 at 13:00 -0800, Nicholas A. Bellinger wrote: > On Mon, 2014-02-10 at 11:05 -0800, Nicholas A. Bellinger wrote: > > > > > > > > Hi Yan, > > > > > > > > > > So recently I've been doing some KVM guest performance comparisons > > > > > between the scsi-mq prototype using virtio-scsi + vhost-scsi, and > > > > > Windows Server 2012 with vioscsi.sys (virtio-win-0.1-74.iso) + > > > > > vhost-scsi using PCIe flash backend devices. > > > > > > > > > > I've noticed that small block random performance for the MSFT guest is > > > > > at around ~80K IOPs with multiple vioscsi LUNs + adapters, which ends > > > > > up > > > > > being well below what the Linux guest with scsi-mq + virtio-scsi is > > > > > capable of (~500K). > > > > > > > > > > After searching through the various vioscsi registry settings, it > > > > > appears that MSIEnabled is being explicitly disabled (0x), > > > > > that > > > > > is different from what vioscsi.inx is currently defining: > > > > > > > > > > [pnpsafe_pci_addreg_msix] > > > > > HKR, "Interrupt Management",, 0x0010 > > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties",, > > > > > 0x0010 > > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > > > MSISupported, 0x00010001, 0 > > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > > > MessageNumberLimit, 0x00010001, 4 > > > > > > > > > > Looking deeper at vioscsi.c code, I've noticed that MSI_SUPPORTED=0 is > > > > > explicitly disabled at build time in SOURCES + vioscsi.vcxproj, as > > > > > well > > > > > as VioScsiFindAdapter() code always ends setting msix_enabled = FALSE > > > > > here, regardless of MSI_SUPPORTED: > > > > > > > > > > > > > > > https://github.com/YanVugenfirer/kvm-guest-drivers-windows/blob/master/vioscsi/vioscsi.c#L340 > > > > > > > > > > Also looking at virtio_stor.c for the raw block driver, > > > > > MSI_SUPPORTED=1 > > > > > appears to be the default setting for the driver included in the > > > > > offical > > > > > virtio-win iso builds, right..? > > > > > > > > > > Sooo, I'd like to try enabling MSI_SUPPORTED=1 in a test vioscsi.sys > > > > > build of my own, but before going down the WDK development rabbit > > > > > whole, > > > > > I'd like to better understand why you've explicitly disabled this > > > > > logic > > > > > within vioscsi.c code to start..? > > > > > > > > > > Is there anything that needs to be addressed / carried over from > > > > > virtio_stor.c in order to get MSI_SUPPORTED=1 to work with vioscsi.c > > > > > miniport code..? > > > > > > Hi Nicholas, > > > > > > I was thinking about enabling MSI in RHEL 6.6 (build 74) but for some > > > reasons decided to keep it disabled until adding mq support. > > > > > > > > > You definitely should be able to turn on MSI_SUPPORTED, rebuild the > > > driver, and switch MSISupported to 1 to make vioscsi driver working in > > > MSI mode. > > > > > > > Thanks for the quick response. We'll give MSI_SUPPORTED=1 a shot over > > the next days with a test build on Server 2012 / Server 2008 R2 and see > > how things go.. > > > > Just a quick update on progress. > > I've been able to successfully build + load a unsigned vioscsi.sys > driver on Server 2012 with WDK 8.0. > > Running with MSI_SUPPORTED=1 against vhost-scsi results in a significant > performance and efficiency gain, on the order of 100K to 225K IOPs for > 4K block random I/O workload, depending on read/write mix. > One other performance related question.. In vioscsi.c:VioScsiFindAdapter() code, the default setting for adaptExt->queue_depth ends up getting set to 32 (pageNum / 4) when indirect mode is enabled in the following bits: if(adaptExt->indirect) { adaptExt->queue_depth = max(2, (pageNum / 4)); } else { adaptExt->queue_depth = pageNum / ConfigInfo->NumberOfPhysicalBreaks - 1; } Looking at viostor/virtio_stor.c:VirtIoFindAdapter() code, the default setting for ->queue_depth appears to be 128 (pageNum): #if (INDIRECT_SUPPORTED) if(!adaptExt->dump_mode) { adaptExt->indirect = CHECKBIT(adaptExt->features, VIRTIO_RING_F_INDIRECT_DESC); } if(adaptExt->indirect) { adaptExt->queue_depth = pageNum; } #else adaptExt->indirect = 0; #endif Is there a reason for the lower queue_depth for vioscsi vs. viostor..? How about using min(adaptExt->scsi_config.cmd_per_lun, pageNum) instead..? Thanks! -nab
Re: [Qemu-devel] MSI interrupt support with vioscsi.c miniport driver
On Mon, 2014-02-10 at 11:05 -0800, Nicholas A. Bellinger wrote: > > > > Hi Yan, > > > > > > > > So recently I've been doing some KVM guest performance comparisons > > > > between the scsi-mq prototype using virtio-scsi + vhost-scsi, and > > > > Windows Server 2012 with vioscsi.sys (virtio-win-0.1-74.iso) + > > > > vhost-scsi using PCIe flash backend devices. > > > > > > > > I've noticed that small block random performance for the MSFT guest is > > > > at around ~80K IOPs with multiple vioscsi LUNs + adapters, which ends up > > > > being well below what the Linux guest with scsi-mq + virtio-scsi is > > > > capable of (~500K). > > > > > > > > After searching through the various vioscsi registry settings, it > > > > appears that MSIEnabled is being explicitly disabled (0x), that > > > > is different from what vioscsi.inx is currently defining: > > > > > > > > [pnpsafe_pci_addreg_msix] > > > > HKR, "Interrupt Management",, 0x0010 > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties",, > > > > 0x0010 > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > > MSISupported, 0x00010001, 0 > > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > > MessageNumberLimit, 0x00010001, 4 > > > > > > > > Looking deeper at vioscsi.c code, I've noticed that MSI_SUPPORTED=0 is > > > > explicitly disabled at build time in SOURCES + vioscsi.vcxproj, as well > > > > as VioScsiFindAdapter() code always ends setting msix_enabled = FALSE > > > > here, regardless of MSI_SUPPORTED: > > > > > > > > > > > > https://github.com/YanVugenfirer/kvm-guest-drivers-windows/blob/master/vioscsi/vioscsi.c#L340 > > > > > > > > Also looking at virtio_stor.c for the raw block driver, MSI_SUPPORTED=1 > > > > appears to be the default setting for the driver included in the offical > > > > virtio-win iso builds, right..? > > > > > > > > Sooo, I'd like to try enabling MSI_SUPPORTED=1 in a test vioscsi.sys > > > > build of my own, but before going down the WDK development rabbit whole, > > > > I'd like to better understand why you've explicitly disabled this logic > > > > within vioscsi.c code to start..? > > > > > > > > Is there anything that needs to be addressed / carried over from > > > > virtio_stor.c in order to get MSI_SUPPORTED=1 to work with vioscsi.c > > > > miniport code..? > > > > Hi Nicholas, > > > > I was thinking about enabling MSI in RHEL 6.6 (build 74) but for some > > reasons decided to keep it disabled until adding mq support. > > > > > > You definitely should be able to turn on MSI_SUPPORTED, rebuild the > > driver, and switch MSISupported to 1 to make vioscsi driver working in > > MSI mode. > > > > Thanks for the quick response. We'll give MSI_SUPPORTED=1 a shot over > the next days with a test build on Server 2012 / Server 2008 R2 and see > how things go.. > Just a quick update on progress. I've been able to successfully build + load a unsigned vioscsi.sys driver on Server 2012 with WDK 8.0. Running with MSI_SUPPORTED=1 against vhost-scsi results in a significant performance and efficiency gain, on the order of 100K to 225K IOPs for 4K block random I/O workload, depending on read/write mix. Below is a simple patch to enable MSI operation by default. Any chance to apply this separate from future mq efforts..? Thanks, --nab >From 89adb6d5800386d44b36737d1587e0ffc09c4902 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Fri, 14 Feb 2014 10:26:04 -0800 Subject: [PATCH] vioscsi: Set MSI_SUPPORTED=1 by default Signed-off-by: Nicholas Bellinger --- vioscsi/SOURCES | 2 +- vioscsi/vioscsi.c | 2 -- vioscsi/vioscsi.inx | 2 +- vioscsi/vioscsi.vcxproj | 6 +++--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/vioscsi/SOURCES b/vioscsi/SOURCES index f2083de..f631bd2 100644 --- a/vioscsi/SOURCES +++ b/vioscsi/SOURCES @@ -6,7 +6,7 @@ C_DEFINES = -D_MINORVERSION_=$(_BUILD_MINOR_VERSION_) $(C_DEFINES) C_DEFINES = -D_NT_TARGET_MAJ=$(_NT_TARGET_MAJ) $(C_DEFINES) C_DEFINES = -D_NT_TARGET_MIN=$(_RHEL_RELEASE_VERSION_) $(C_DEFINES) -C_DEFINES = -DMSI_SUPPORTED=0 $(C_DEFINES) +C_DEFINES = -DMSI_SUPPORTED=1 $(C_DEFINES) C_DEFINES = -DINDIRECT_SUPPORTED=1 $(C_DEFINES) TARGETLIBS=$(SDK_LIB_PATH)\sto
Re: [Qemu-devel] MSI interrupt support with vioscsi.c miniport driver
Hi Vadim & Yan, On Sun, 2014-02-09 at 22:35 +1100, Vadim Rozenfeld wrote: > On Sun, 2014-02-09 at 11:24 +0200, Yan Vugenfirer wrote: > > Hi Nicholas, > > > > Adding Vadim Rozenfeld who wrote the virtio-scsi driver. > > > > Best regards, > > Yan. > > > > On Feb 7, 2014, at 10:14 PM, Nicholas A. Bellinger > > wrote: > > > > > Hi Yan, > > > > > > So recently I've been doing some KVM guest performance comparisons > > > between the scsi-mq prototype using virtio-scsi + vhost-scsi, and > > > Windows Server 2012 with vioscsi.sys (virtio-win-0.1-74.iso) + > > > vhost-scsi using PCIe flash backend devices. > > > > > > I've noticed that small block random performance for the MSFT guest is > > > at around ~80K IOPs with multiple vioscsi LUNs + adapters, which ends up > > > being well below what the Linux guest with scsi-mq + virtio-scsi is > > > capable of (~500K). > > > > > > After searching through the various vioscsi registry settings, it > > > appears that MSIEnabled is being explicitly disabled (0x), that > > > is different from what vioscsi.inx is currently defining: > > > > > > [pnpsafe_pci_addreg_msix] > > > HKR, "Interrupt Management",, 0x0010 > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties",, > > > 0x0010 > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > MSISupported, 0x00010001, 0 > > > HKR, "Interrupt Management\MessageSignaledInterruptProperties", > > > MessageNumberLimit, 0x00010001, 4 > > > > > > Looking deeper at vioscsi.c code, I've noticed that MSI_SUPPORTED=0 is > > > explicitly disabled at build time in SOURCES + vioscsi.vcxproj, as well > > > as VioScsiFindAdapter() code always ends setting msix_enabled = FALSE > > > here, regardless of MSI_SUPPORTED: > > > > > > > > > https://github.com/YanVugenfirer/kvm-guest-drivers-windows/blob/master/vioscsi/vioscsi.c#L340 > > > > > > Also looking at virtio_stor.c for the raw block driver, MSI_SUPPORTED=1 > > > appears to be the default setting for the driver included in the offical > > > virtio-win iso builds, right..? > > > > > > Sooo, I'd like to try enabling MSI_SUPPORTED=1 in a test vioscsi.sys > > > build of my own, but before going down the WDK development rabbit whole, > > > I'd like to better understand why you've explicitly disabled this logic > > > within vioscsi.c code to start..? > > > > > > Is there anything that needs to be addressed / carried over from > > > virtio_stor.c in order to get MSI_SUPPORTED=1 to work with vioscsi.c > > > miniport code..? > > Hi Nicholas, > > I was thinking about enabling MSI in RHEL 6.6 (build 74) but for some > reasons decided to keep it disabled until adding mq support. > > > You definitely should be able to turn on MSI_SUPPORTED, rebuild the > driver, and switch MSISupported to 1 to make vioscsi driver working in > MSI mode. > Thanks for the quick response. We'll give MSI_SUPPORTED=1 a shot over the next days with a test build on Server 2012 / Server 2008 R2 and see how things go.. Thanks again! --nab
[Qemu-devel] MSI interrupt support with vioscsi.c miniport driver
Hi Yan, So recently I've been doing some KVM guest performance comparisons between the scsi-mq prototype using virtio-scsi + vhost-scsi, and Windows Server 2012 with vioscsi.sys (virtio-win-0.1-74.iso) + vhost-scsi using PCIe flash backend devices. I've noticed that small block random performance for the MSFT guest is at around ~80K IOPs with multiple vioscsi LUNs + adapters, which ends up being well below what the Linux guest with scsi-mq + virtio-scsi is capable of (~500K). After searching through the various vioscsi registry settings, it appears that MSIEnabled is being explicitly disabled (0x), that is different from what vioscsi.inx is currently defining: [pnpsafe_pci_addreg_msix] HKR, "Interrupt Management",, 0x0010 HKR, "Interrupt Management\MessageSignaledInterruptProperties",, 0x0010 HKR, "Interrupt Management\MessageSignaledInterruptProperties", MSISupported, 0x00010001, 0 HKR, "Interrupt Management\MessageSignaledInterruptProperties", MessageNumberLimit, 0x00010001, 4 Looking deeper at vioscsi.c code, I've noticed that MSI_SUPPORTED=0 is explicitly disabled at build time in SOURCES + vioscsi.vcxproj, as well as VioScsiFindAdapter() code always ends setting msix_enabled = FALSE here, regardless of MSI_SUPPORTED: https://github.com/YanVugenfirer/kvm-guest-drivers-windows/blob/master/vioscsi/vioscsi.c#L340 Also looking at virtio_stor.c for the raw block driver, MSI_SUPPORTED=1 appears to be the default setting for the driver included in the offical virtio-win iso builds, right..? Sooo, I'd like to try enabling MSI_SUPPORTED=1 in a test vioscsi.sys build of my own, but before going down the WDK development rabbit whole, I'd like to better understand why you've explicitly disabled this logic within vioscsi.c code to start..? Is there anything that needs to be addressed / carried over from virtio_stor.c in order to get MSI_SUPPORTED=1 to work with vioscsi.c miniport code..? TIA! --nab
Re: [Qemu-devel] updated: kvm PCI todo wiki
On Wed, 2013-08-21 at 14:45 +0200, Hannes Reinecke wrote: > On 08/21/2013 12:48 PM, Michael S. Tsirkin wrote: > > Hey guys, > > I've put up a wiki page with a kvm PCI todo list, > > mainly to avoid effort duplication, but also in the hope > > to draw attention to what I think we should try addressing > > in KVM: > > > > http://www.linux-kvm.org/page/PCITodo > > > > This page could cover all PCI related activity in KVM, > > it is very incomplete. > > We should probably add e.g. IOMMU related stuff. > > > > Note: if there's no developer listed for an item, > > this just means I don't know of anyone actively working > > on an issue at the moment, not that no one intends to. > > > > I would appreciate it if others working on one of the items on this list > > would add their names so we can communicate better. If others like this > > wiki page, please go ahead and add stuff you are working on if any. > > > > It would be especially nice to add testing projects. > > > > Also, feel free to add links to bugzillas items. > > > On a related note, did anyone ever tried to test MSI / MSI-X with a > windows guest? I've tried to enable it for virtio but for some reason > Windows didn't wanted to enable it. AHCI was even worse; the stock > Windows version doesn't support MSI and the Intel one doesn't like our > implementation :-(. > > Anyone ever managed to get this to work? > > If not it'd be a good topic for the wiki ... > Speaking of which, I asked Asias about this recently and he seems to think that virtio-net + virtio-blk drivers for MSFT do in fact support MSI /MSI-X. MST, do you know if that that true..? --nab
Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Wed, 2013-05-29 at 21:29 -0700, Nicholas A. Bellinger wrote: > On Thu, 2013-05-30 at 06:17 +0800, Asias He wrote: > > On Wed, May 29, 2013 at 08:10:44AM -0700, Badari Pulavarty wrote: > > > On 05/29/2013 02:05 AM, Wenchao Xia wrote: > > > >于 2013-5-28 17:00, Wenchao Xia 写道: > > > > > > > I have done a basic test of vhost-scsi, following is the result I'd > > > >like to post, generally it seems fine: > > > > > > > >Result: > > > > fdisk/mkfs: fdisk can find it, mke2fs works fine. > > > > mount: can mount it. > > > > file I/O: dd 90M zero to a file in that disk succeed. > > > > > > > > > > > > I tried without nested kvm. > > > > > > > > > > >Issues: > > > > 1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error, > > > >dev fd0, sector 0", I guess it is caused by nested KVM that failed > > > >to kick host kernel? > > > > > > > > > I don't see this issue. Are you sure "fd0" is actually the scsi device ? > > > what is "fd0" ? > > > > > > > 2) in fdisk -l, it shows 512 bytes larger than the parameter I > > > >specified in fd_dev_size parameter in configfs on host.(shows > > > >104858112 bytes, see the invocation script below) > > > > > > > > > > I see the same. For some reason "fdisk -l" in the VM shows > > > 512-bytes more than the actual size for the file (on the host). > > > > Hmm, interesting. Will look into it. > > > > Nick, Any ideas here? > > > > Mmm, fd_get_blocks() is not returning the expected minus one logical > blocks with a !S_ISBLK() setup. > > This is happening for every other backend ->get_blocks() call already, > and should be happening for the fd_dev_size case as well. > > Applying the following to target-pending.git now. > Actually sorry, that last patch is not correct.. Here's a better one to properly set fd_dev->fd_block_size at configure time, and use dev_attrib.block_size in fd_get_blocks() to allow for user defined block_sizes. Thanks, --nab commit 9e309f9307fe644dee8718980bfcb77de91ce38e Author: Nicholas Bellinger Date: Wed May 29 21:35:23 2013 -0700 target/file: Fix off-by-one READ_CAPACITY bug for !S_ISBLK export This patch fixes a bug where FILEIO was incorrectly reporting the number of logical blocks (+ 1) when using non struct block_device export mode. It changes fd_get_blocks() to follow all other backend ->get_blocks() cases, and reduces the calculated dev_size by one dev->dev_attrib.block_size number of bytes, and fixes the initial block_size assignment within fd_configure_device() Reported-by: Wenchao Xia Reported-by: Badari Pulavarty Signed-off-by: Nicholas Bellinger diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 1b1d544..b11890d 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -153,6 +153,7 @@ static int fd_configure_device(struct se_device *dev) struct request_queue *q = bdev_get_queue(inode->i_bdev); unsigned long long dev_size; + fd_dev->fd_block_size = bdev_logical_block_size(inode->i_bdev); /* * Determine the number of bytes from i_size_read() minus * one (1) logical sector from underlying struct block_device @@ -199,6 +200,7 @@ static int fd_configure_device(struct se_device *dev) goto fail; } + fd_dev->fd_block_size = FD_BLOCKSIZE; /* * Limit UNMAP emulation to 8k Number of LBAs (NoLB) */ @@ -217,9 +219,7 @@ static int fd_configure_device(struct se_device *dev) dev->dev_attrib.max_write_same_len = 0x1000; } - fd_dev->fd_block_size = dev->dev_attrib.hw_block_size; - - dev->dev_attrib.hw_block_size = FD_BLOCKSIZE; + dev->dev_attrib.hw_block_size = fd_dev->fd_block_size; dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; @@ -694,11 +694,12 @@ static sector_t fd_get_blocks(struct se_device *dev) * to handle underlying block_device resize operations. */ if (S_ISBLK(i->i_mode)) - dev_size = (i_size_read(i) - fd_dev->fd_block_size); + dev_size = i_size_read(i); else dev_size = fd_dev->fd_dev_size; - return div_u64(dev_size, dev->dev_attrib.block_size); + return div_u64(dev_size - dev->dev_attrib.block_size, + dev->dev_attrib.block_size); } static struct sbc_ops fd_sbc_ops = {
Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Thu, 2013-05-30 at 06:17 +0800, Asias He wrote: > On Wed, May 29, 2013 at 08:10:44AM -0700, Badari Pulavarty wrote: > > On 05/29/2013 02:05 AM, Wenchao Xia wrote: > > >于 2013-5-28 17:00, Wenchao Xia 写道: > > > I have done a basic test of vhost-scsi, following is the result I'd > > >like to post, generally it seems fine: > > > > > >Result: > > > fdisk/mkfs: fdisk can find it, mke2fs works fine. > > > mount: can mount it. > > > file I/O: dd 90M zero to a file in that disk succeed. > > > > > > > > I tried without nested kvm. > > > > > > > >Issues: > > > 1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error, > > >dev fd0, sector 0", I guess it is caused by nested KVM that failed > > >to kick host kernel? > > > > > > I don't see this issue. Are you sure "fd0" is actually the scsi device ? > > what is "fd0" ? > > > > > 2) in fdisk -l, it shows 512 bytes larger than the parameter I > > >specified in fd_dev_size parameter in configfs on host.(shows > > >104858112 bytes, see the invocation script below) > > > > > > > I see the same. For some reason "fdisk -l" in the VM shows > > 512-bytes more than the actual size for the file (on the host). > > Hmm, interesting. Will look into it. > > Nick, Any ideas here? > Mmm, fd_get_blocks() is not returning the expected minus one logical blocks with a !S_ISBLK() setup. This is happening for every other backend ->get_blocks() call already, and should be happening for the fd_dev_size case as well. Applying the following to target-pending.git now. diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 1b1d544..8a2ac90 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -694,11 +694,12 @@ static sector_t fd_get_blocks(struct se_device *dev) * to handle underlying block_device resize operations. */ if (S_ISBLK(i->i_mode)) - dev_size = (i_size_read(i) - fd_dev->fd_block_size); + dev_size = i_size_read(i); else dev_size = fd_dev->fd_dev_size; - return div_u64(dev_size, dev->dev_attrib.block_size); + return div_u64(dev_size - fd_dev->fd_block_size, + dev->dev_attrib.block_size); } static struct sbc_ops fd_sbc_ops = {
Re: [Qemu-devel] [PULL 0/9] SCSI updates for 2013-04-13
On Fri, 2013-04-19 at 16:24 +0200, Paolo Bonzini wrote: > The following changes since commit 09dada400328d75daf79e3eca1e48e024fec148d: > > configure: remove duplicate test (2013-04-18 14:12:31 +0200) > > are available in the git repository at: > > git://github.com/bonzini/qemu.git scsi-next > > for you to fetch changes up to d6e51919a7e3250bbfb4bb0ad0f208ab6fd688a4: > > vhost-scsi-s390: new device supporting the tcm_vhost Linux kernel module > (2013-04-19 16:19:13 +0200) > > The VMware PVSCSI implementation and vhost-scsi are finally getting in. > Hi Paolo & Co, Thanks for all of the efforts to finally get the vhost-scsi series merged into upstream QEMU v1.5 code! Also, just a reminder that pc-bios/bios.bin needs to be updated to include Asias's seabios.git commits below for this code to boot. b44a7be17bdd270ea029a8e2ec0c2e80c6cd0444 virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd} 5a7730db57ab0715223421e65b54fb50d6fefe5c virtio-scsi: Set _DRIVER_OK flag before scsi target scanning I just tested with this afternoon's qemu.git and seabios.git HEADs, and both are functioning as expected. Anthony + Gerd, can we expect an rev to pc-bios/bios.bin soon to pick up these seabios changes for vhost-scsi..? Thanks, --nab > Paolo > > Dmitry Fleytman (1): > scsi: VMWare PVSCSI paravirtual device implementation > > Nicholas Bellinger (3): > vhost: Add vhost_commit callback for SeaBIOS ROM region re-mapping > vhost-scsi: new device supporting the tcm_vhost Linux kernel module > vhost-scsi-pci: new device supporting the tcm_vhost Linux kernel module > > Paolo Bonzini (5): > scsi: avoid assertion failure on VERIFY command > virtio-scsi: create VirtIOSCSICommon > virtio: simplify Makefile conditionals > vhost-scsi-ccw: new device supporting the tcm_vhost Linux kernel module > vhost-scsi-s390: new device supporting the tcm_vhost Linux kernel module > > configure | 10 + > default-configs/pci.mak |1 + > docs/specs/vmw_pvscsi-spec.txt | 92 +++ > hw/Makefile.objs|2 +- > hw/s390x/s390-virtio-bus.c | 51 +- > hw/s390x/s390-virtio-bus.h | 16 + > hw/s390x/virtio-ccw.c | 53 +- > hw/s390x/virtio-ccw.h | 14 + > hw/scsi/Makefile.objs |7 +- > hw/scsi/scsi-disk.c | 19 +- > hw/scsi/vhost-scsi.c| 288 ++ > hw/scsi/virtio-scsi.c | 212 +++ > hw/scsi/vmw_pvscsi.c| 1216 > +++ > hw/scsi/vmw_pvscsi.h| 434 ++ > hw/virtio/Makefile.objs |8 +- > hw/virtio/vhost.c | 53 +- > hw/virtio/virtio-pci.c | 65 ++- > hw/virtio/virtio-pci.h | 18 + > include/hw/pci/pci.h|1 + > include/hw/virtio/vhost-scsi.h | 73 +++ > include/hw/virtio/vhost.h |3 + > include/hw/virtio/virtio-scsi.h | 135 - > include/qemu/osdep.h|4 + > trace-events| 35 ++ > 24 files changed, 2636 insertions(+), 174 deletions(-) > create mode 100644 docs/specs/vmw_pvscsi-spec.txt > create mode 100644 hw/scsi/vhost-scsi.c > create mode 100644 hw/scsi/vmw_pvscsi.c > create mode 100644 hw/scsi/vmw_pvscsi.h > create mode 100644 include/hw/virtio/vhost-scsi.h
Re: [Qemu-devel] Is anyone rebasing the tcm_vhost QEMU patches?
On Tue, 2013-04-16 at 13:45 -0500, Anthony Liguori wrote: > I know there are a few different trees out there. Not sure if anyone is > currently working on rebasing the earlier patch series. I had thought > we were aiming for 1.5 but we're getting pretty late for that. > Hi Anthony, The branch against maineline qemu from 3-29 that I've been using is here: https://git.kernel.org/cgit/virt/kvm/nab/qemu-kvm.git/log/?h=vhost-scsi-for-1.4 Last time I checked with Paolo two weeks ago he was including this into scsi-next. Paolo, is this ready to go, or shall I rebase + repost for you to merge for 1.5..? --nab
Re: [Qemu-devel] Bug in SeaBIOS virtio-ring handling bug with vhost-scsi-pci
On Tue, 2013-04-09 at 12:24 +0800, Asias He wrote: > On Mon, Apr 08, 2013 at 09:09:54PM -0700, Nicholas A. Bellinger wrote: > > Ping. > > > > Any ideas on this one..? It seems like this bug would be effecting > > non vhost-scsi-pci code as well.. > > Nicholas, where is the latest v3 code. Can you push it to your tree. > Sure. Just pushed to: http://git.kernel.org/cgit/virt/kvm/nab/qemu-kvm.git/log/?h=vhost-scsi-for-1.4 and should be appearing momentarily. --nab > > --nab > > > > On Thu, 2013-04-04 at 19:59 -0700, Nicholas A. Bellinger wrote: > > > Hi Paolo & Co, > > > > > > So I've been running into another bug with SeaBIOS w/ virtio-scsi + > > > vhost-scsi-pci code.. > > > > > > During the last weeks debugging on the QEMU vhost memory re-mapping bug, > > > my seabios builds have been using a smaller target ID (16) for scanning > > > than the default hard coded value of 256 in init_virtio_scsi(). > > > > > > After bumping this value back to 256 recently, a bogus out_num value > > > from vhost_get_vq_desc() start appearing on the tcm_vhost side: > > > > > > [17348.044031] Invalid buffer layout out: 0 in: 2 > > > > > > After adding more debug output to SeaBIOS, the vring->num value appears > > > to be reset from the expected MAX_QUEUE_NUM=128, then incremented each > > > time after vring_more_used() is called to poll for completion.. > > > > > > init virtio-scsi > > > found virtio-scsi at 0:4 > > > vring_init Setting vr->num: 128 > > > Calling virtio_scsi_scan_target for target: 0 > > > Searching bootorder for: /pci@i0cf8/*@4/*@0/*@0,0 > > > virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 > > > virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 128 > > > vring_add_buf, vr: 0x000ed404 vr->num: 128 > > > vring_add_buf, head: 0, index: 0 > > > vring_add_buf, setting desc[prev=2].flags > > > vring_add_buf, setting free_head: 3 > > > vring_add_buf, setting q->vdata[head=0] > > > vring_add_buf, setting q->ring[av=0] > > > virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 128 > > > virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 128 > > > virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 1 > > > ^ > > > > > >Reset from 128 to 1 immediate after first vring_more_used()..? > > > > > > vring_get_buf last_used_idx: 0 vr: 0x000ed404 vr->num: 1 > > > vring_get_buf checking &used->ring[0] > > > vring_get_buf, using new last_unsed: 0 >>>>>>>>>>>>>>>>>> > > > vring_get_buf using id: 0 from elem->id: 0x000ed004 > > > vring_detach: vq->free_head: 3 > > > vring_detach: Setting new vq->free_head: 0 > > > virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 1 > > > Calling virtio_scsi_scan_target for target: 1 > > > Searching bootorder for: /pci@i0cf8/*@4/*@0/*@1,0 > > > virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 > > > virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 1 > > > vring_add_buf, vr: 0x000ed404 vr->num: 1 > > > vring_add_buf, head: 0, index: 0 > > > vring_add_buf, setting desc[prev=2].flags > > > vring_add_buf, setting free_head: 3 > > > vring_add_buf, setting q->vdata[head=0] > > > vring_add_buf, setting q->ring[av=0] > > > virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 1 > > > virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 1 > > > virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 2 > > > ^ > > > > > > Incremented from 1 to 2 after second vring_more_used()..? > > > > > > vring_get_buf last_used_idx: 1 vr: 0x000ed404 vr->num: 2 > > > vring_get_buf checking &used->ring[1] > > > vring_get_buf, using new last_unsed: 1 >>>>>>>>>>>>>>>>>> > > > vring_get_buf using id: 0 from elem->id: 0x000ed00c > > > vring_detach: vq->free_head: 3 > > > vring_detach: Setting new vq->free_head: 0 > > > virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 2 > > > virtio-scsi vendor='LIO-ORG' product='RAMDISK-MCP' rev='4.0'
Re: [Qemu-devel] Bug in SeaBIOS virtio-ring handling bug with vhost-scsi-pci
Ping. Any ideas on this one..? It seems like this bug would be effecting non vhost-scsi-pci code as well.. --nab On Thu, 2013-04-04 at 19:59 -0700, Nicholas A. Bellinger wrote: > Hi Paolo & Co, > > So I've been running into another bug with SeaBIOS w/ virtio-scsi + > vhost-scsi-pci code.. > > During the last weeks debugging on the QEMU vhost memory re-mapping bug, > my seabios builds have been using a smaller target ID (16) for scanning > than the default hard coded value of 256 in init_virtio_scsi(). > > After bumping this value back to 256 recently, a bogus out_num value > from vhost_get_vq_desc() start appearing on the tcm_vhost side: > > [17348.044031] Invalid buffer layout out: 0 in: 2 > > After adding more debug output to SeaBIOS, the vring->num value appears > to be reset from the expected MAX_QUEUE_NUM=128, then incremented each > time after vring_more_used() is called to poll for completion.. > > init virtio-scsi > found virtio-scsi at 0:4 > vring_init Setting vr->num: 128 > Calling virtio_scsi_scan_target for target: 0 > Searching bootorder for: /pci@i0cf8/*@4/*@0/*@0,0 > virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 > virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 128 > vring_add_buf, vr: 0x000ed404 vr->num: 128 > vring_add_buf, head: 0, index: 0 > vring_add_buf, setting desc[prev=2].flags > vring_add_buf, setting free_head: 3 > vring_add_buf, setting q->vdata[head=0] > vring_add_buf, setting q->ring[av=0] > virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 128 > virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 128 > virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 1 > ^ > >Reset from 128 to 1 immediate after first vring_more_used()..? > > vring_get_buf last_used_idx: 0 vr: 0x000ed404 vr->num: 1 > vring_get_buf checking &used->ring[0] > vring_get_buf, using new last_unsed: 0 >>>>>>>>>>>>>>>>>> > vring_get_buf using id: 0 from elem->id: 0x000ed004 > vring_detach: vq->free_head: 3 > vring_detach: Setting new vq->free_head: 0 > virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 1 > Calling virtio_scsi_scan_target for target: 1 > Searching bootorder for: /pci@i0cf8/*@4/*@0/*@1,0 > virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 > virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 1 > vring_add_buf, vr: 0x000ed404 vr->num: 1 > vring_add_buf, head: 0, index: 0 > vring_add_buf, setting desc[prev=2].flags > vring_add_buf, setting free_head: 3 > vring_add_buf, setting q->vdata[head=0] > vring_add_buf, setting q->ring[av=0] > virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 1 > virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 1 > virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 2 > ^ > > Incremented from 1 to 2 after second vring_more_used()..? > > vring_get_buf last_used_idx: 1 vr: 0x000ed404 vr->num: 2 > vring_get_buf checking &used->ring[1] > vring_get_buf, using new last_unsed: 1 >>>>>>>>>>>>>>>>>> > vring_get_buf using id: 0 from elem->id: 0x000ed00c > vring_detach: vq->free_head: 3 > vring_detach: Setting new vq->free_head: 0 > virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 2 > virtio-scsi vendor='LIO-ORG' product='RAMDISK-MCP' rev='4.0' type=0 > removable=0 > virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 1 > virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 2 > vring_add_buf, vr: 0x000ed404 vr->num: 2 > vring_add_buf, head: 0, index: 0 > vring_add_buf, setting desc[prev=1].flags > vring_add_buf, setting free_head: 2 > vring_add_buf, setting q->vdata[head=0] > vring_add_buf, setting q->ring[av=0] > virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 2 > virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 2 > virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 3 > ^ > > Incremented from 2 to 3, and so on.. > > and this keeps happening until vr->num begins to exceed > MAX_QUEUE_NUM around scanning of target ID 127: > > virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 128 > virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 128 > virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 129 > vring
Re: [Qemu-devel] [PATCH-v2 1/2] virtio-scsi: create VirtIOSCSICommon
On Mon, 2013-04-08 at 16:59 -0500, Anthony Liguori wrote: > "Nicholas A. Bellinger" writes: > > > From: Paolo Bonzini > > > > This patch refactors existing virtio-scsi code into VirtIOSCSICommon > > in order to allow virtio_scsi_init_common() to be used by both internal > > virtio_scsi_init() and external vhost-scsi-pci code. > > > > Changes in Patch-v2: > >- Move ->get_features() assignment to virtio_scsi_init() instead of > > virtio_scsi_init_common() > > > Any reason we're not doing this as a QOM base class? > > Similiar to how the in-kernel PIT/PIC work using a common base class... > Mmm, not sure. Paolo, what do you prefer here..? Also, has your qemu/scsi-next branch with this series been pushed to a public tree yet..? ;) --nab
[Qemu-devel] Bug in SeaBIOS virtio-ring handling bug with vhost-scsi-pci
Hi Paolo & Co, So I've been running into another bug with SeaBIOS w/ virtio-scsi + vhost-scsi-pci code.. During the last weeks debugging on the QEMU vhost memory re-mapping bug, my seabios builds have been using a smaller target ID (16) for scanning than the default hard coded value of 256 in init_virtio_scsi(). After bumping this value back to 256 recently, a bogus out_num value from vhost_get_vq_desc() start appearing on the tcm_vhost side: [17348.044031] Invalid buffer layout out: 0 in: 2 After adding more debug output to SeaBIOS, the vring->num value appears to be reset from the expected MAX_QUEUE_NUM=128, then incremented each time after vring_more_used() is called to poll for completion.. init virtio-scsi found virtio-scsi at 0:4 vring_init Setting vr->num: 128 Calling virtio_scsi_scan_target for target: 0 Searching bootorder for: /pci@i0cf8/*@4/*@0/*@0,0 virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 128 vring_add_buf, vr: 0x000ed404 vr->num: 128 vring_add_buf, head: 0, index: 0 vring_add_buf, setting desc[prev=2].flags vring_add_buf, setting free_head: 3 vring_add_buf, setting q->vdata[head=0] vring_add_buf, setting q->ring[av=0] virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 128 virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 128 virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 1 ^ Reset from 128 to 1 immediate after first vring_more_used()..? vring_get_buf last_used_idx: 0 vr: 0x000ed404 vr->num: 1 vring_get_buf checking &used->ring[0] vring_get_buf, using new last_unsed: 0 >> vring_get_buf using id: 0 from elem->id: 0x000ed004 vring_detach: vq->free_head: 3 vring_detach: Setting new vq->free_head: 0 virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 1 Calling virtio_scsi_scan_target for target: 1 Searching bootorder for: /pci@i0cf8/*@4/*@0/*@1,0 virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 1 vring_add_buf, vr: 0x000ed404 vr->num: 1 vring_add_buf, head: 0, index: 0 vring_add_buf, setting desc[prev=2].flags vring_add_buf, setting free_head: 3 vring_add_buf, setting q->vdata[head=0] vring_add_buf, setting q->ring[av=0] virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 1 virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 1 virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 2 ^ Incremented from 1 to 2 after second vring_more_used()..? vring_get_buf last_used_idx: 1 vr: 0x000ed404 vr->num: 2 vring_get_buf checking &used->ring[1] vring_get_buf, using new last_unsed: 1 >> vring_get_buf using id: 0 from elem->id: 0x000ed00c vring_detach: vq->free_head: 3 vring_detach: Setting new vq->free_head: 0 virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 2 virtio-scsi vendor='LIO-ORG' product='RAMDISK-MCP' rev='4.0' type=0 removable=0 virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 1 virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 2 vring_add_buf, vr: 0x000ed404 vr->num: 2 vring_add_buf, head: 0, index: 0 vring_add_buf, setting desc[prev=1].flags vring_add_buf, setting free_head: 2 vring_add_buf, setting q->vdata[head=0] vring_add_buf, setting q->ring[av=0] virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 2 virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 2 virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 3 ^ Incremented from 2 to 3, and so on.. and this keeps happening until vr->num begins to exceed MAX_QUEUE_NUM around scanning of target ID 127: virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 128 virtio_scsi_cmd, after vring_kick vr: 0x000ed404 vr->num: 128 virtio_scsi_cmd, after vring_more_used #4 vr: 0x000ed404 vr->num: 129 vring_get_buf last_used_idx: 128 vr: 0x000ed404 vr->num: 129 vring_get_buf checking &used->ring[128] vring_get_buf, using new last_unsed: 128 >> vring_get_buf using id: 129 from elem->id: 0x000ed404 vring_detach: vq->free_head: 3 vring_detach: Setting new vq->free_head: 129 virtio_scsi_cmd, after vring_get_buf #5 vr: 0x000ed404 vr->num: 129 Calling virtio_scsi_scan_target for target: 127 Searching bootorder for: /pci@i0cf8/*@4/*@0/*@127,0 virtio_scsi_cmd, using vring_add_buf for out_num: 1 in_num: 2 virtio_scsi_cmd, using vring_add_buf vr: 0x000ed404 vr->num: 129 vring_add_buf, vr: 0x000ed404 vr->num: 129 vring_add_buf, head: 129, index: 0 vring_add_buf, setting desc[prev=4].flags vring_add_buf, setting free_head: 5 vring_add_buf, setting q->vdata[head=0] vring_add_buf, setting q->ring[av=129] virtio_scsi_cmd, after vring_add_buf vr: 0x000ed404 vr->num: 129 virtio_scsi_cmd, after vring_kick vr: 0x000
Re: [Qemu-devel] [PATCH] vhost: Add vhost_commit callback for SeaBIOS ROM region re-mapping
On Wed, 2013-04-03 at 12:34 +0200, Paolo Bonzini wrote: > Il 03/04/2013 12:34, Michael S. Tsirkin ha scritto: > > > Applied to the SCSI branch, thanks. > > > > Is the rest of vhost-scsi there now? > > No, but it will be shortly. :) > Hi Paolo, Just a heads up that PATCH-v2 for vhost-scsi-pci does not apply cleanly against the latest qemu.git/master. Let me know if your OK with fixing the fuzz, or would prefer a -v3 re-spin before for applying to SCSI branch. Also, please include the uninitialized VQs checks that MST recently ACK'ed here: virtio/vhost: Add checks for uninitialized VQs http://www.spinics.net/lists/target-devel/msg04298.html Btw, has the SCSI branch been pushed to a public repo..? --nab
[Qemu-devel] [PATCH] vhost: Add vhost_commit callback for SeaBIOS ROM region re-mapping
From: Nicholas Bellinger This patch follows MST's recommendation to move checks for vhost_verify_ring_mappings() -> cpu_physical_memory_map() operations from MemoryListener->region_[add,del]() -> vhost_set_memory() into final MemoryListener->commit() -> vhost_commit() callback. It addresses the case where virtio-scsi vq ioport RAM re-mapping to read-only SeaBIOS ROM triggers a cpu_physical_memory_map() NIL MemoryRegionSection pointer failure. Also save vhost_dev->mem_changed_[start,end]_addr values in vhost_set_memory() for final ranges_overlap checks. (Thanks Paolo!) Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Asias He Signed-off-by: Nicholas Bellinger --- hw/vhost.c | 53 ++--- hw/vhost.h |3 +++ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 832cc89..00345f2 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -385,8 +385,6 @@ static void vhost_set_memory(MemoryListener *listener, bool log_dirty = memory_region_is_logging(section->mr); int s = offsetof(struct vhost_memory, regions) + (dev->mem->nregions + 1) * sizeof dev->mem->regions[0]; -uint64_t log_size; -int r; void *ram; dev->mem = g_realloc(dev->mem, s); @@ -419,12 +417,47 @@ static void vhost_set_memory(MemoryListener *listener, /* Remove old mapping for this memory, if any. */ vhost_dev_unassign_memory(dev, start_addr, size); } +dev->mem_changed_start_addr = MIN(dev->mem_changed_start_addr, start_addr); +dev->mem_changed_end_addr = MAX(dev->mem_changed_end_addr, start_addr + size - 1); +dev->memory_changed = true; +} + +static bool vhost_section(MemoryRegionSection *section) +{ +return memory_region_is_ram(section->mr); +} + +static void vhost_begin(MemoryListener *listener) +{ +struct vhost_dev *dev = container_of(listener, struct vhost_dev, + memory_listener); +dev->mem_changed_end_addr = 0; +dev->mem_changed_start_addr = -1; +} +static void vhost_commit(MemoryListener *listener) +{ +struct vhost_dev *dev = container_of(listener, struct vhost_dev, + memory_listener); +hwaddr start_addr = 0; +ram_addr_t size = 0; +uint64_t log_size; +int r; + +if (!dev->memory_changed) { +return; +} if (!dev->started) { return; } +if (dev->mem_changed_start_addr > dev->mem_changed_end_addr) { +return; +} if (dev->started) { +start_addr = dev->mem_changed_start_addr; +size = dev->mem_changed_end_addr - dev->mem_changed_start_addr + 1; + r = vhost_verify_ring_mappings(dev, start_addr, size); assert(r >= 0); } @@ -432,6 +465,7 @@ static void vhost_set_memory(MemoryListener *listener, if (!dev->log_enabled) { r = ioctl(dev->control, VHOST_SET_MEM_TABLE, dev->mem); assert(r >= 0); +dev->memory_changed = false; return; } log_size = vhost_get_log_size(dev); @@ -448,19 +482,7 @@ static void vhost_set_memory(MemoryListener *listener, if (dev->log_size > log_size + VHOST_LOG_BUFFER) { vhost_dev_log_resize(dev, log_size); } -} - -static bool vhost_section(MemoryRegionSection *section) -{ -return memory_region_is_ram(section->mr); -} - -static void vhost_begin(MemoryListener *listener) -{ -} - -static void vhost_commit(MemoryListener *listener) -{ +dev->memory_changed = false; } static void vhost_region_add(MemoryListener *listener, @@ -854,6 +876,7 @@ int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, hdev->log_size = 0; hdev->log_enabled = false; hdev->started = false; +hdev->memory_changed = false; memory_listener_register(&hdev->memory_listener, &address_space_memory); hdev->force = force; return 0; diff --git a/hw/vhost.h b/hw/vhost.h index f062d48..adb40c3 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -45,6 +45,9 @@ struct vhost_dev { vhost_log_chunk_t *log; unsigned long long log_size; bool force; +bool memory_changed; +hwaddr mem_changed_start_addr; +hwaddr mem_changed_end_addr; }; int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, -- 1.7.2.5
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Tue, 2013-04-02 at 21:04 -0700, Nicholas A. Bellinger wrote: > On Tue, 2013-04-02 at 16:27 +0300, Michael S. Tsirkin wrote: > > On Mon, Apr 01, 2013 at 06:05:47PM -0700, Nicholas A. Bellinger wrote: > > > On Fri, 2013-03-29 at 09:14 +0100, Paolo Bonzini wrote: > > > > Il 29/03/2013 03:53, Nicholas A. Bellinger ha scritto: > > > > > On Thu, 2013-03-28 at 06:13 -0400, Paolo Bonzini wrote: > > > > >>> I think it's the right thing to do, but maybe not the right place > > > > >>> to do this, need to reset after all IO is done, before > > > > >>> ring memory is write protected. > > > > >> > > > > >> Our emails are crossing each other unfortunately, but I want to > > > > >> reinforce this: ring memory is not write protected. > > > > > > > > > > Understood. However, AFAICT the act of write protecting these ranges > > > > > for ROM generates the offending callbacks to vhost_set_memory(). > > > > > > > > > > The part that I'm missing is if ring memory is not being write > > > > > protected > > > > > by make_bios_readonly_intel(), why are the vhost_set_memory() calls > > > > > being invoked..? > > > > > > > > Because mappings change for the region that contains the ring. vhost > > > > doesn't know yet that the changes do not affect ring memory, > > > > vhost_set_memory() is called exactly to ascertain that. > > > > > > > > Is it possible that what is going on here, > > is that we had a region at address 0x0 size 0x8000, > > and now a chunk from it is being made readonly, > > and to this end the whole old region is removed > > then new ones are added? > > Yes, I believe this is exactly what is happening.. > > > > > If yes maybe the problem is that we don't use the atomic > > begin/commit ops in the memory API. > > Maybe the following will help? > > Completely untested, posting just to give you the idea: > > > > Mmmm, one question on how vhost_region_del() + vhost_region_add() + > vhost_commit() should work.. > > Considering the following when the same seabios code snippet: > >pci_config_writeb(0x31): bdf: 0x pam: 0x005b > > is executed to mark an pc.ram area 0xc as readonly: > > Entering vhost_begin >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > Entering vhost_region_del section: 0x7fd037a4bb60 offset_within_region: > 0xc size: 2146697216 readonly: 0 > vhost_region_del: is_rom: 0, rom_device: 0 > vhost_region_del: readable: 1 > vhost_region_del: ram_addr 0x0, addr: 0x0 size: 2147483648 > vhost_region_del: name: pc.ram > Entering vhost_set_memory, section: 0x7fd037a4bb60 add: 0, dev->started: 1 > vhost_set_memory: Setting dev->memory_changed = true for start_addr: 0xc > Entering vhost_region_add section: 0x7fd037a4baa0 offset_within_region: > 0xc size: 32768 readonly: 1 > vhost_region_add is readonly !!! > vhost_region_add: is_rom: 0, rom_device: 0 > vhost_region_add: readable: 1 > vhost_region_add: ram_addr 0x, addr: 0x 0 size: > 2147483648 > vhost_region_add: name: pc.ram > Entering vhost_set_memory, section: 0x7fd037a4baa0 add: 1, dev->started: 1 > vhost_dev_assign_memory(); >>>>>>>>>>>>>>>>>>>>>>>>>>>> reg->guest_phys_addr: > 0xc > vhost_set_memory: Setting dev->memory_changed = true for start_addr: 0xc > Entering vhost_region_add section: 0x7fd037a4baa0 offset_within_region: > 0xc8000 size: 2146664448 readonly: 0 > vhost_region_add: is_rom: 0, rom_device: 0 > vhost_region_add: readable: 1 > vhost_region_add: ram_addr 0x, addr: 0x 0 size: > 2147483648 > vhost_region_add: name: pc.ram > Entering vhost_set_memory, section: 0x7fd037a4baa0 add: 1, dev->started: 1 > vhost_set_memory: Setting dev->memory_changed = true for start_addr: 0xc8000 > phys_page_find got PHYS_MAP_NODE_NIL >>>>>>>>>>>>>>>>>>>>>>.. > Entering vhost_commit >>>>>>>>>>>>>>>>>>>>>>>>>>> > > Note that originally we'd see the cpu_physical_memory_map() failure in > vhost_verify_ring_mappings() after the first ->region_del() above. > > Adding a hardcoded cpu_physical_memory_map() testc
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Tue, 2013-04-02 at 16:27 +0300, Michael S. Tsirkin wrote: > On Mon, Apr 01, 2013 at 06:05:47PM -0700, Nicholas A. Bellinger wrote: > > On Fri, 2013-03-29 at 09:14 +0100, Paolo Bonzini wrote: > > > Il 29/03/2013 03:53, Nicholas A. Bellinger ha scritto: > > > > On Thu, 2013-03-28 at 06:13 -0400, Paolo Bonzini wrote: > > > >>> I think it's the right thing to do, but maybe not the right place > > > >>> to do this, need to reset after all IO is done, before > > > >>> ring memory is write protected. > > > >> > > > >> Our emails are crossing each other unfortunately, but I want to > > > >> reinforce this: ring memory is not write protected. > > > > > > > > Understood. However, AFAICT the act of write protecting these ranges > > > > for ROM generates the offending callbacks to vhost_set_memory(). > > > > > > > > The part that I'm missing is if ring memory is not being write protected > > > > by make_bios_readonly_intel(), why are the vhost_set_memory() calls > > > > being invoked..? > > > > > > Because mappings change for the region that contains the ring. vhost > > > doesn't know yet that the changes do not affect ring memory, > > > vhost_set_memory() is called exactly to ascertain that. > > > > > > > Hi Paolo & Co, > > > > Here's a bit more information on what is going on with the same > > cpu_physical_memory_map() failure in vhost_verify_ring_mappings().. > > > > So as before, at the point that seabios is marking memory as readonly > > for ROM in src/shadow.c:make_bios_readonly_intel() with the following > > call: > > > > Calling pci_config_writeb(0x31): bdf: 0x pam: 0x005b > > > > the memory API update hook triggers back into vhost_region_del() code, > > and following occurs: > > > > Entering vhost_region_del section: 0x7fd30a213b60 offset_within_region: > > 0xc size: 2146697216 readonly: 0 > > vhost_region_del: is_rom: 0, rom_device: 0 > > vhost_region_del: readable: 1 > > vhost_region_del: ram_addr 0x0, addr: 0x0 size: 2147483648 > > vhost_region_del: name: pc.ram > > Entering vhost_set_memory, section: 0x7fd30a213b60 add: 0, dev->started: 1 > > Entering verify_ring_mappings: start_addr 0x000c size: > > 2146697216 > > verify_ring_mappings: ring_phys 0x0 ring_size: 0 > > verify_ring_mappings: ring_phys 0x0 ring_size: 0 > > verify_ring_mappings: ring_phys 0xed000 ring_size: 5124 > > verify_ring_mappings: calling cpu_physical_memory_map ring_phys: 0xed000 l: > > 5124 > > address_space_map: addr: 0xed000, plen: 5124 > > address_space_map: l: 4096, len: 5124 > > phys_page_find got PHYS_MAP_NODE_NIL >>>>>>>>>>>>>>>>>>>>>>.. > > address_space_map: section: 0x7fd30fabaed0 memory_region_is_ram: 0 > > readonly: 0 > > address_space_map: section: 0x7fd30fabaed0 offset_within_region: 0x0 > > section size: 18446744073709551615 > > Unable to map ring buffer for ring 2, l: 4096 > > > > So the interesting part is that phys_page_find() is not able to locate > > the corresponding page for vq->ring_phys: 0xed000 from the > > vhost_region_del() callback with section->offset_within_region: > > 0xc.. > > > > Is there any case where this would not be considered a bug..? > > > > register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 > > register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 > > register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 > > Entering vhost_region_add section: 0x7fd30a213aa0 offset_within_region: > > 0xc size: 32768 readonly: 1 > > vhost_region_add: is_rom: 0, rom_device: 0 > > vhost_region_add: readable: 1 > > vhost_region_add: ram_addr 0x, addr: 0x 0 > > size: 2147483648 > > vhost_region_add: name: pc.ram > > Entering vhost_set_memory, section: 0x7fd30a213aa0 add: 1, dev->started: 1 > > Entering verify_ring_mappings: start_addr 0x000c size: 32768 > > verify_ring_mappings: ring_phys 0x0 ring_size: 0 > > verify_ring_mappings: ring_phys 0x0 ring_size: 0 > > verify_ring_mappings: ring_phys 0xed000 ring_size: 5124 > > verify_ring_mappings: Got !ranges_overlap, skipping > > register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 > > Entering vhost_region_add section: 0x7fd30a213aa0 offset_within_region: > > 0xc8000 size: 2146664448 readonly: 0 >
Re: [Qemu-devel] [PATCH-v2 0/3] virtio/vhost: Add checks for uninitialized VQs
On Tue, 2013-04-02 at 15:01 +0300, Michael S. Tsirkin wrote: > On Mon, Apr 01, 2013 at 11:58:21PM +0000, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > Hi folks, > > > > This series adds a virtio_queue_valid() for use by virtio-pci code in > > order to prevent opreations upon uninitialized VQs, which is currently > > expected to occur during seabios setup of virtio-scsi with in-flight > > vhost-scsi-pci device code. > > > > On the vhost side, it also adds virtio_queue_valid() sanity checks in > > vhost_virtqueue_[start,stop]() and vhost_verify_ring_mappings() in order > > to skip the same uninitialized VQs. > > > > Changes from v1: > > - Remove now unnecessary virtio_queue_get_num() calls in virtio-pci.c > > - Add virtio_queue_valid() calls in vhost_virtqueue_[start,stop]() > > > > Please review. > > > > --nab > > Looks reasonable. > Acked-by: Michael S. Tsirkin > Thanks MST! Anthony, do you want to pick these up now..? Or shall I include in the next vhost-scsi-pci PATCH-v3 series..? --nab > So - does this fix the issues you saw with vhost-scsi? > > > Michael S. Tsirkin (1): > > virtio: add API to check that ring is setup > > > > Nicholas Bellinger (2): > > virtio-pci: Add virtio_queue_valid checks ahead of > > virtio_queue_get_num > > vhost: Skip uninitialized VQs in vhost_virtqueue_[start,stop] > > > > hw/vhost.c | 12 > > hw/virtio-pci.c | 34 +++--- > > hw/virtio.c |5 + > > hw/virtio.h |1 + > > 4 files changed, 33 insertions(+), 19 deletions(-) > > > > -- > > 1.7.2.5 > -- > To unsubscribe from this list: send the line "unsubscribe target-devel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [PATCH 0/5] vhost-scsi: Add support for host virtualized target
Hello Wenchao, On Tue, 2013-04-02 at 11:28 +0800, Wenchao Xia wrote: > Hi, Nicholas > Have this serial been merged to qemu 1.4? Not just yet. Asias, MST, Paolo and myself have been working recently on the series for qemu 1.4. > If not, I am rebasing it to > upstream, hope no one else is working on that. > The latest PATCH-v2 for vhost-scsi-pci against upstream qemu commit dcadaa9b (from March 25th) is here: http://www.spinics.net/lists/target-devel/msg04263.html Note that you'll need this small work-around patch to avoid a bug that we're currently tracking down: http://www.spinics.net/lists/target-devel/msg04122.html Also, you'll need a recent SeaBios build with the following commits: commit 5a7730db57ab0715223421e65b54fb50d6fefe5c Author: Asias He Date: Fri Mar 15 09:45:15 2013 +0800 virtio-scsi: Set _DRIVER_OK flag before scsi target scanning commit b44a7be17bdd270ea029a8e2ec0c2e80c6cd0444 Author: Asias He Date: Fri Mar 15 09:45:16 2013 +0800 virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd} I'll be rebasing to qemu HEAD over the next few days and posting a PATCH-v3, and would be happy to include you in the CC to follow along. Thanks! --nab > > From: Nicholas Bellinger > > > > Hello Anthony & Co, > > > > This is the fourth installment to add host virtualized target support for > > the mainline tcm_vhost fabric driver using Linux v3.6-rc into QEMU 1.3.0-rc. > > > > The series is available directly from the following git branch: > > > > git://git.kernel.org/pub/scm/virt/kvm/nab/qemu-kvm.git > > vhost-scsi-for-1.3 > > > > Note the code is cut against yesterday's QEMU head, and dispite the name > > of the tree is based upon mainline qemu.org git code + has thus far been > > running overnight with > 100K IOPs small block 4k workloads using v3.6-rc2+ > > based target code with RAMDISK_DR backstores. > > > > Other than some minor fuzz between jumping from QEMU 1.2.0 -> 1.2.50, this > > series is functionally identical to what's been posted for vhost-scsi RFC-v3 > > to qemu-devel. > > > > Please consider applying these patches for an initial vhost-scsi merge into > > QEMU 1.3.0-rc code, or let us know what else you'd like to see addressed for > > this series to in order to merge. > > > > Thank you! > > > > --nab > > > > Nicholas Bellinger (2): > >monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param > >virtio-scsi: Set max_target=0 during vhost-scsi operation > > > > Stefan Hajnoczi (3): > >vhost: Pass device path to vhost_dev_init() > >vhost-scsi: add -vhost-scsi host device for use with tcm-vhost > >virtio-scsi: Add start/stop functionality for vhost-scsi > > > > configure| 10 +++ > > hw/Makefile.objs |1 + > > hw/qdev-properties.c | 41 +++ > > hw/vhost-scsi.c | 190 > > ++ > > hw/vhost-scsi.h | 62 > > hw/vhost.c |5 +- > > hw/vhost.h |3 +- > > hw/vhost_net.c |2 +- > > hw/virtio-pci.c |2 + > > hw/virtio-scsi.c | 55 ++- > > hw/virtio-scsi.h |1 + > > monitor.c| 18 + > > monitor.h|1 + > > net.c| 18 - > > net.h|2 - > > net/socket.c |2 +- > > net/tap.c|4 +- > > qemu-common.h|1 + > > qemu-config.c| 19 + > > qemu-options.hx |4 + > > vl.c | 18 + > > 21 files changed, 431 insertions(+), 28 deletions(-) > > create mode 100644 hw/vhost-scsi.c > > create mode 100644 hw/vhost-scsi.h > > > >
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Fri, 2013-03-29 at 09:14 +0100, Paolo Bonzini wrote: > Il 29/03/2013 03:53, Nicholas A. Bellinger ha scritto: > > On Thu, 2013-03-28 at 06:13 -0400, Paolo Bonzini wrote: > >>> I think it's the right thing to do, but maybe not the right place > >>> to do this, need to reset after all IO is done, before > >>> ring memory is write protected. > >> > >> Our emails are crossing each other unfortunately, but I want to > >> reinforce this: ring memory is not write protected. > > > > Understood. However, AFAICT the act of write protecting these ranges > > for ROM generates the offending callbacks to vhost_set_memory(). > > > > The part that I'm missing is if ring memory is not being write protected > > by make_bios_readonly_intel(), why are the vhost_set_memory() calls > > being invoked..? > > Because mappings change for the region that contains the ring. vhost > doesn't know yet that the changes do not affect ring memory, > vhost_set_memory() is called exactly to ascertain that. > Hi Paolo & Co, Here's a bit more information on what is going on with the same cpu_physical_memory_map() failure in vhost_verify_ring_mappings().. So as before, at the point that seabios is marking memory as readonly for ROM in src/shadow.c:make_bios_readonly_intel() with the following call: Calling pci_config_writeb(0x31): bdf: 0x pam: 0x005b the memory API update hook triggers back into vhost_region_del() code, and following occurs: Entering vhost_region_del section: 0x7fd30a213b60 offset_within_region: 0xc size: 2146697216 readonly: 0 vhost_region_del: is_rom: 0, rom_device: 0 vhost_region_del: readable: 1 vhost_region_del: ram_addr 0x0, addr: 0x0 size: 2147483648 vhost_region_del: name: pc.ram Entering vhost_set_memory, section: 0x7fd30a213b60 add: 0, dev->started: 1 Entering verify_ring_mappings: start_addr 0x000c size: 2146697216 verify_ring_mappings: ring_phys 0x0 ring_size: 0 verify_ring_mappings: ring_phys 0x0 ring_size: 0 verify_ring_mappings: ring_phys 0xed000 ring_size: 5124 verify_ring_mappings: calling cpu_physical_memory_map ring_phys: 0xed000 l: 5124 address_space_map: addr: 0xed000, plen: 5124 address_space_map: l: 4096, len: 5124 phys_page_find got PHYS_MAP_NODE_NIL >>>>>>>>>>>>>>>>>>>>>>.. address_space_map: section: 0x7fd30fabaed0 memory_region_is_ram: 0 readonly: 0 address_space_map: section: 0x7fd30fabaed0 offset_within_region: 0x0 section size: 18446744073709551615 Unable to map ring buffer for ring 2, l: 4096 So the interesting part is that phys_page_find() is not able to locate the corresponding page for vq->ring_phys: 0xed000 from the vhost_region_del() callback with section->offset_within_region: 0xc.. Is there any case where this would not be considered a bug..? register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 Entering vhost_region_add section: 0x7fd30a213aa0 offset_within_region: 0xc size: 32768 readonly: 1 vhost_region_add: is_rom: 0, rom_device: 0 vhost_region_add: readable: 1 vhost_region_add: ram_addr 0x, addr: 0x 0 size: 2147483648 vhost_region_add: name: pc.ram Entering vhost_set_memory, section: 0x7fd30a213aa0 add: 1, dev->started: 1 Entering verify_ring_mappings: start_addr 0x000c size: 32768 verify_ring_mappings: ring_phys 0x0 ring_size: 0 verify_ring_mappings: ring_phys 0x0 ring_size: 0 verify_ring_mappings: ring_phys 0xed000 ring_size: 5124 verify_ring_mappings: Got !ranges_overlap, skipping register_multipage : d: 0x7fd30f7d0ed0 section: 0x7fd30a2139b0 Entering vhost_region_add section: 0x7fd30a213aa0 offset_within_region: 0xc8000 size: 2146664448 readonly: 0 vhost_region_add: is_rom: 0, rom_device: 0 vhost_region_add: readable: 1 vhost_region_add: ram_addr 0x, addr: 0x 0 size: 2147483648 vhost_region_add: name: pc.ram Entering vhost_set_memory, section: 0x7fd30a213aa0 add: 1, dev->started: 1 Entering verify_ring_mappings: start_addr 0x000c8000 size: 2146664448 verify_ring_mappings: ring_phys 0x0 ring_size: 0 verify_ring_mappings: ring_phys 0x0 ring_size: 0 verify_ring_mappings: ring_phys 0xed000 ring_size: 5124 verify_ring_mappings: calling cpu_physical_memory_map ring_phys: 0xed000 l: 5124 address_space_map: addr: 0xed000, plen: 5124 address_space_map: l: 4096, len: 5124 address_space_map: section: 0x7fd30fabb020 memory_region_is_ram: 1 readonly: 0 address_space_map: section: 0x7fd30fabb020 offset_within_region: 0xc8000 section size: 2146664448 address_space_map: l: 4096, len: 1028 address_space_map: section: 0x7fd30fabb020 memory_region_is_ram: 1 readonly: 0 address_space_map: section:
[Qemu-devel] [PATCH-v2 3/3] vhost: Skip uninitialized VQs in vhost_virtqueue_[start, stop]
From: Nicholas Bellinger This patch adds virtio_queue_valid() checks in vhost_virtqueue_start() and vhost_virtqueue_stop() to avoid uninitialized VQs during vhost-scsi-pci seabios operation, where we currently expect only the request VQ to have been initialized before virtio-scsi LLD guest hand-off. Also, go ahead and skip the same uninitialized VQs during sanity checks within vhost_verify_ring_mappings() by checking vq->ring_[phys,size] directly. Cc: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/vhost.c | 12 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 4d6aee3..832cc89 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -314,6 +314,9 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev, hwaddr l; void *p; +if (!vq->ring_phys || !vq->ring_size) { +continue; +} if (!ranges_overlap(start_addr, size, vq->ring_phys, vq->ring_size)) { continue; } @@ -645,6 +648,10 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs); +if (!virtio_queue_valid(vdev, idx)) { +return 0; +} + vq->num = state.num = virtio_queue_get_num(vdev, idx); r = ioctl(dev->control, VHOST_SET_VRING_NUM, &state); if (r) { @@ -732,6 +739,11 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, }; int r; assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs); + +if (!virtio_queue_valid(vdev, idx)) { +return; +} + r = ioctl(dev->control, VHOST_GET_VRING_BASE, &state); if (r < 0) { fprintf(stderr, "vhost VQ %d ring restore failed: %d\n", idx, r); -- 1.7.2.5
[Qemu-devel] [PATCH-v2 2/3] virtio-pci: Add virtio_queue_valid checks ahead of virtio_queue_get_num
From: Nicholas Bellinger This patch adds a number of virtio_queue_valid() checks to virtio-pci ahead of virtio_queue_get_num() usage in order to skip operation upon the detection of an uninitialized VQ. There is one exception in virtio_ioport_read():VIRTIO_PCI_QUEUE_NUM, where virtio_queue_get_num() may still be called without a valid vdev->vq[n].vring.desc physical address. v2: Drop now unnecessary virtio_queue_get_num calls (mst) Cc: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-pci.c | 34 +++--- 1 files changed, 15 insertions(+), 19 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 0d67b84..1369d9a 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -211,10 +211,9 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) } for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { -if (!virtio_queue_get_num(proxy->vdev, n)) { +if (!virtio_queue_valid(proxy->vdev, n)) { continue; } - r = virtio_pci_set_host_notifier_internal(proxy, n, true, true); if (r < 0) { goto assign_error; @@ -225,10 +224,9 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) assign_error: while (--n >= 0) { -if (!virtio_queue_get_num(proxy->vdev, n)) { +if (!virtio_queue_valid(proxy->vdev, n)) { continue; } - r = virtio_pci_set_host_notifier_internal(proxy, n, false, false); assert(r >= 0); } @@ -246,10 +244,9 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) } for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { -if (!virtio_queue_get_num(proxy->vdev, n)) { +if (!virtio_queue_valid(proxy->vdev, n)) { continue; } - r = virtio_pci_set_host_notifier_internal(proxy, n, false, false); assert(r >= 0); } @@ -546,8 +543,8 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) MSIMessage msg; for (queue_no = 0; queue_no < nvqs; queue_no++) { -if (!virtio_queue_get_num(vdev, queue_no)) { -break; +if (!virtio_queue_valid(vdev, queue_no)) { +continue; } vector = virtio_queue_vector(vdev, queue_no); if (vector >= msix_nr_vectors_allocated(dev)) { @@ -593,8 +590,8 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) int queue_no; for (queue_no = 0; queue_no < nvqs; queue_no++) { -if (!virtio_queue_get_num(vdev, queue_no)) { -break; +if (!virtio_queue_valid(vdev, queue_no)) { +continue; } vector = virtio_queue_vector(vdev, queue_no); if (vector >= msix_nr_vectors_allocated(dev)) { @@ -665,8 +662,8 @@ static int kvm_virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector, int ret, queue_no; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { -if (!virtio_queue_get_num(vdev, queue_no)) { -break; +if (!virtio_queue_valid(vdev, queue_no)) { +continue; } if (virtio_queue_vector(vdev, queue_no) != vector) { continue; @@ -695,8 +692,8 @@ static void kvm_virtio_pci_vector_mask(PCIDevice *dev, unsigned vector) int queue_no; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { -if (!virtio_queue_get_num(vdev, queue_no)) { -break; +if (!virtio_queue_valid(vdev, queue_no)) { +continue; } if (virtio_queue_vector(vdev, queue_no) != vector) { continue; @@ -717,8 +714,8 @@ static void kvm_virtio_pci_vector_poll(PCIDevice *dev, VirtQueue *vq; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { -if (!virtio_queue_get_num(vdev, queue_no)) { -break; +if (!virtio_queue_valid(vdev, queue_no)) { +continue; } vector = virtio_queue_vector(vdev, queue_no); if (vector < vector_start || vector >= vector_end || @@ -790,10 +787,9 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) } for (n = 0; n < nvqs; n++) { -if (!virtio_queue_get_num(vdev, n)) { -break; +if (!virtio_queue_valid(vdev, n)) { +continue; } - r = virtio_pci_set_guest_notifier(d, n, assign, kvm_msi_via_irqfd_enabled()); if (r < 0) { -- 1.7.2.5
[Qemu-devel] [PATCH-v2 1/3] virtio: add API to check that ring is setup
From: Michael S. Tsirkin virtio scsi makes it legal to only setup a subset of rings. The only way to detect the ring is setup seems to be to check whether PA was written to. Add API to do this, and teach code to use it instead of checking hardware queue size. (nab: use .vring.desc instead of .vring.pa) Signed-off-by: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio.c |5 + hw/virtio.h |1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 26fbc79..65ba253 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -651,6 +651,11 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n) return vdev->vq[n].vring.num; } +bool virtio_queue_valid(VirtIODevice *vdev, int n) +{ +return vdev->vq[n].vring.num && vdev->vq[n].vring.desc; +} + int virtio_queue_get_id(VirtQueue *vq) { VirtIODevice *vdev = vq->vdev; diff --git a/hw/virtio.h b/hw/virtio.h index fdbe931..3086798 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -227,6 +227,7 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr); hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n); int virtio_queue_get_num(VirtIODevice *vdev, int n); +bool virtio_queue_valid(VirtIODevice *vdev, int n); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector); -- 1.7.2.5
[Qemu-devel] [PATCH-v2 0/3] virtio/vhost: Add checks for uninitialized VQs
From: Nicholas Bellinger Hi folks, This series adds a virtio_queue_valid() for use by virtio-pci code in order to prevent opreations upon uninitialized VQs, which is currently expected to occur during seabios setup of virtio-scsi with in-flight vhost-scsi-pci device code. On the vhost side, it also adds virtio_queue_valid() sanity checks in vhost_virtqueue_[start,stop]() and vhost_verify_ring_mappings() in order to skip the same uninitialized VQs. Changes from v1: - Remove now unnecessary virtio_queue_get_num() calls in virtio-pci.c - Add virtio_queue_valid() calls in vhost_virtqueue_[start,stop]() Please review. --nab Michael S. Tsirkin (1): virtio: add API to check that ring is setup Nicholas Bellinger (2): virtio-pci: Add virtio_queue_valid checks ahead of virtio_queue_get_num vhost: Skip uninitialized VQs in vhost_virtqueue_[start,stop] hw/vhost.c | 12 hw/virtio-pci.c | 34 +++--- hw/virtio.c |5 + hw/virtio.h |1 + 4 files changed, 33 insertions(+), 19 deletions(-) -- 1.7.2.5
Re: [Qemu-devel] [PATCH 0/3] virtio/vhost: Add checks for uninitialized VQs
On Sun, 2013-03-31 at 10:46 +0300, Michael S. Tsirkin wrote: > On Fri, Mar 29, 2013 at 04:33:09AM +0000, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > Hi folks, > > > > This series adds a virtio_queue_valid() for use by virtio-pci code in > > order to prevent opreations upon uninitialized VQs, that is currently > > expected to occur during seabios setup of virtio-scsi. > > > > This also includes a vhost specific check for uninitialized VQs in > > vhost_verify_ring_mappings() to avoid this same case. > > > > Please review. > > > > --nab > > Okay, and does this fix the failures in vhost_verify_ring_mappings > that you've observed? > Unfortunately, no. I've done some more digging and will follow up with additional details on the original thread shortly.. --nab
Re: [Qemu-devel] [PATCH 3/3] vhost: Check+skip uninitialized VQs in vhost_verify_ring_mappings
On Sun, 2013-03-31 at 10:45 +0300, Michael S. Tsirkin wrote: > On Fri, Mar 29, 2013 at 04:33:12AM +0000, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > With the virtio_queue_valid() checks in place to skip uninitialized VQs > > within virtio-pci code, go ahead and skip the same uninitialized VQs > > during vhost_verify_ring_mappings(). > > > > Note this patch does not prevent vhost_virtqueue_start() from executing > > by checking virtio_queue_valid(), as other logic during seabios -> > > virtio-scsi LLD guest hand-off appears to depend upon this execution. > > Weird. > cpu_physical_memory_map only succeeds for PA==0 by chance, > we really should not depend on this. > So the right thing really should be to skip vhost_virtqueue_start IMHO, > maybe add an explicit valid flag in vhost_virtqueue > so vhost_verify_ring_mappings can check it. > What exactly does it do that is needed? > So the issue with virtio_queue_valid() preventing vhost_virtqueue_start() execution in the original patch was that vhost_virtqueue_stop() was missing a matching virtio_queue_valid() call, which ended up triggering a bad ram pointer during subsequent cpu_physical_memory_unmap() calls to non-existent virtio queue memory.. With the matching virtio_queue_valid() call in place preventing vhost_virtqueue_stop() when vhost_virtqueue_start() is skipped for an uninitialized VQ, a explicit valid flag should not be necessary. --nab > > > > Cc: Michael S. Tsirkin > > Cc: Asias He > > Cc: Paolo Bonzini > > Signed-off-by: Nicholas Bellinger > > --- > > hw/vhost.c |3 +++ > > 1 files changed, 3 insertions(+), 0 deletions(-) > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > index 4d6aee3..3a71aee 100644 > > --- a/hw/vhost.c > > +++ b/hw/vhost.c > > @@ -314,6 +314,9 @@ static int vhost_verify_ring_mappings(struct vhost_dev > > *dev, > > hwaddr l; > > void *p; > > > > +if (!vq->ring_phys || !vq->ring_size) { > > +continue; > > +} > > if (!ranges_overlap(start_addr, size, vq->ring_phys, > > vq->ring_size)) { > > continue; > > } > > -- > > 1.7.2.5 > -- > To unsubscribe from this list: send the line "unsubscribe target-devel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [PATCH 2/3] virtio-pci: Add virtio_queue_valid checks ahead of virtio_queue_get_num
On Sun, 2013-03-31 at 10:37 +0300, Michael S. Tsirkin wrote: > On Fri, Mar 29, 2013 at 04:33:11AM +0000, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > This patch adds a number of virtio_queue_valid() checks to virtio-pci > > ahead of virtio_queue_get_num() usage in order to skip operation upon > > the detection of an uninitialized VQ. > > > > There is one exception in virtio_ioport_read():VIRTIO_PCI_QUEUE_NUM, > > where virtio_queue_get_num() may still be called without a valid > > vdev->vq[n].vring.desc physical address. > > > > Cc: Michael S. Tsirkin > > Cc: Asias He > > Cc: Paolo Bonzini > > Signed-off-by: Nicholas Bellinger > > Makes sense. Minor nit: virtio_queue_valid calls virtio_queue_get_num > internally, so we can drop it everywhere we know queue is valid. > Yes, of course. This includes every location in virtio-pci.c below.. Including for patch-v2. > > --- > > hw/virtio-pci.c | 27 +++ > > 1 files changed, 27 insertions(+), 0 deletions(-) > > > > diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > > index 0d67b84..231ca0c 100644 > > --- a/hw/virtio-pci.c > > +++ b/hw/virtio-pci.c > > @@ -211,6 +211,9 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy > > *proxy) > > } > > > > for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { > > +if (!virtio_queue_valid(proxy->vdev, n)) { > > +continue; > > +} > > if (!virtio_queue_get_num(proxy->vdev, n)) { > > continue; > > } > > @@ -225,6 +228,9 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy > > *proxy) > > > > assign_error: > > while (--n >= 0) { > > +if (!virtio_queue_valid(proxy->vdev, n)) { > > +continue; > > +} > > if (!virtio_queue_get_num(proxy->vdev, n)) { > > continue; > > } > > @@ -246,6 +252,9 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy > > *proxy) > > } > > > > for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { > > +if (!virtio_queue_valid(proxy->vdev, n)) { > > +continue; > > +} > > if (!virtio_queue_get_num(proxy->vdev, n)) { > > continue; > > } > > @@ -546,6 +555,9 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy > > *proxy, int nvqs) > > MSIMessage msg; > > > > for (queue_no = 0; queue_no < nvqs; queue_no++) { > > +if (!virtio_queue_valid(vdev, queue_no)) { > > +continue; > > +} > > if (!virtio_queue_get_num(vdev, queue_no)) { > > break; > > } > > @@ -593,6 +605,9 @@ static void > > kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) > > int queue_no; > > > > for (queue_no = 0; queue_no < nvqs; queue_no++) { > > +if (!virtio_queue_valid(vdev, queue_no)) { > > +continue; > > +} > > if (!virtio_queue_get_num(vdev, queue_no)) { > > break; > > } > > @@ -665,6 +680,9 @@ static int kvm_virtio_pci_vector_unmask(PCIDevice *dev, > > unsigned vector, > > int ret, queue_no; > > > > for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { > > +if (!virtio_queue_valid(vdev, queue_no)) { > > +continue; > > +} > > if (!virtio_queue_get_num(vdev, queue_no)) { > > break; > > } > > @@ -695,6 +713,9 @@ static void kvm_virtio_pci_vector_mask(PCIDevice *dev, > > unsigned vector) > > int queue_no; > > > > for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { > > +if (!virtio_queue_valid(vdev, queue_no)) { > > +continue; > > +} > > if (!virtio_queue_get_num(vdev, queue_no)) { > > break; > > } > > @@ -717,6 +738,9 @@ static void kvm_virtio_pci_vector_poll(PCIDevice *dev, > > VirtQueue *vq; > > > > for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { > > +if (!virtio_queue_valid(vdev, queue_no)) { > > +continue; > > +} > > if (!virtio_queue_get_num(vdev, queue_no)) { > > break; > > } > > @@ -790,6 +814,9 @@ static int virtio_pci_set_guest_notifiers(DeviceState > > *d, int nvqs, bool assign) > > } > > > > for (n = 0; n < nvqs; n++) { > > +if (!virtio_queue_valid(vdev, n)) { > > +continue; > > +} > > if (!virtio_queue_get_num(vdev, n)) { > > break; > > } > > -- > > 1.7.2.5 > -- > To unsubscribe from this list: send the line "unsubscribe target-devel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [PATCH-v2 0/2] Add support for vhost-scsi-pci
On Fri, 2013-03-29 at 14:39 +0800, Asias He wrote: > On Fri, Mar 29, 2013 at 01:08:14AM +0000, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > Hi QEMU folks, > > > > The following is the patch-v2 series to support vhost-scsi-pci within > > the upstream QEMU tree. > > > > This includes the refactoring of existing virtio-scsi code from Paolo > > to allow a VirtIOSCSICommon structure that is shared amoungst existing > > virtio-scsi-pci device and new vhost-scsi-pci device code. > > > > Currently this code requires Asias's seabios bugfixes (commit 5a7730db5 > > and b44a7be17), and two other tcm_vhost patches to reset vq->last_used_idx > > after seabios handoff and disable EVENT_IDX from GET_FEATURES that's > > currently in flight for v3.9.0 kernel code. > > > > There is a seperate issue with seabios virtio-scsi that's causing a failure > > in vhost_verify_ring_mappings() is still being tracked down, but this series > > should now be getting close to a merge minus this last outstanding item. > > > > Changes in Patch-v2: > >- Move ->get_features() assignment to virtio_scsi_init() instead of > > virtio_scsi_init_common() (nab) > >- Add vhost_scsi_get_features() in order to determine feature bits > > supports by host kernel (mst + nab) > >- Re-enable usage of DEFINE_VIRTIO_COMMON_FEATURES, and allow > > EVENT_IDX to be disabled by host in vhost_scsi_get_features() (mst) > >- Drop unused hotplug bit in DEFINE_VHOST_SCSI_PROPERTIES (mst) > >- Drop vhost_verify_ring_mappings() enable-only hack (mst) > > > > A big thanks to Paolo, Asias, MST, and Stefan for all of their efforts > > on this series. > > > > Thank you, > > > > Paolo Bonzini (2): > > virtio-scsi: create VirtIOSCSICommon > > vhost-scsi: new device supporting the tcm_vhost Linux kernel module > > Seems this does not apply against latest qemu/master. Could you rebase. > Fast moving target.. ;) Will rebase against qemu/master for -v3 after MST's comments on the other patches for (better) handling of uninitialized VQs during seabios -> virtio-scsi LLD guest hand-off. > > configure | 15 +++- > > hw/Makefile.objs |5 +- > > hw/s390x/s390-virtio-bus.c | 35 ++ > > hw/vhost-scsi.c| 264 > > > > hw/vhost-scsi.h| 64 +++ > > hw/virtio-pci.c| 62 ++ > > hw/virtio-scsi.c | 192 > > hw/virtio-scsi.h | 132 +- > > include/qemu/osdep.h |4 + > > 9 files changed, 623 insertions(+), 150 deletions(-) > > create mode 100644 hw/vhost-scsi.c > > create mode 100644 hw/vhost-scsi.h > > > > -- > > 1.7.2.5 > > >
[Qemu-devel] [PATCH 1/3] virtio: add API to check that ring is setup
From: Michael S. Tsirkin virtio scsi makes it legal to only setup a subset of rings. The only way to detect the ring is setup seems to be to check whether PA was written to. Add API to do this, and teach code to use it instead of checking hardware queue size. (nab: use .vring.desc instead of .vring.pa) Signed-off-by: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio.c |5 + hw/virtio.h |1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 26fbc79..65ba253 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -651,6 +651,11 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n) return vdev->vq[n].vring.num; } +bool virtio_queue_valid(VirtIODevice *vdev, int n) +{ +return vdev->vq[n].vring.num && vdev->vq[n].vring.desc; +} + int virtio_queue_get_id(VirtQueue *vq) { VirtIODevice *vdev = vq->vdev; diff --git a/hw/virtio.h b/hw/virtio.h index fdbe931..3086798 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -227,6 +227,7 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr); hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n); int virtio_queue_get_num(VirtIODevice *vdev, int n); +bool virtio_queue_valid(VirtIODevice *vdev, int n); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector); -- 1.7.2.5
[Qemu-devel] [PATCH 3/3] vhost: Check+skip uninitialized VQs in vhost_verify_ring_mappings
From: Nicholas Bellinger With the virtio_queue_valid() checks in place to skip uninitialized VQs within virtio-pci code, go ahead and skip the same uninitialized VQs during vhost_verify_ring_mappings(). Note this patch does not prevent vhost_virtqueue_start() from executing by checking virtio_queue_valid(), as other logic during seabios -> virtio-scsi LLD guest hand-off appears to depend upon this execution. Cc: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/vhost.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 4d6aee3..3a71aee 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -314,6 +314,9 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev, hwaddr l; void *p; +if (!vq->ring_phys || !vq->ring_size) { +continue; +} if (!ranges_overlap(start_addr, size, vq->ring_phys, vq->ring_size)) { continue; } -- 1.7.2.5
[Qemu-devel] [PATCH 2/3] virtio-pci: Add virtio_queue_valid checks ahead of virtio_queue_get_num
From: Nicholas Bellinger This patch adds a number of virtio_queue_valid() checks to virtio-pci ahead of virtio_queue_get_num() usage in order to skip operation upon the detection of an uninitialized VQ. There is one exception in virtio_ioport_read():VIRTIO_PCI_QUEUE_NUM, where virtio_queue_get_num() may still be called without a valid vdev->vq[n].vring.desc physical address. Cc: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-pci.c | 27 +++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 0d67b84..231ca0c 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -211,6 +211,9 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) } for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { +if (!virtio_queue_valid(proxy->vdev, n)) { +continue; +} if (!virtio_queue_get_num(proxy->vdev, n)) { continue; } @@ -225,6 +228,9 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) assign_error: while (--n >= 0) { +if (!virtio_queue_valid(proxy->vdev, n)) { +continue; +} if (!virtio_queue_get_num(proxy->vdev, n)) { continue; } @@ -246,6 +252,9 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) } for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { +if (!virtio_queue_valid(proxy->vdev, n)) { +continue; +} if (!virtio_queue_get_num(proxy->vdev, n)) { continue; } @@ -546,6 +555,9 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) MSIMessage msg; for (queue_no = 0; queue_no < nvqs; queue_no++) { +if (!virtio_queue_valid(vdev, queue_no)) { +continue; +} if (!virtio_queue_get_num(vdev, queue_no)) { break; } @@ -593,6 +605,9 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) int queue_no; for (queue_no = 0; queue_no < nvqs; queue_no++) { +if (!virtio_queue_valid(vdev, queue_no)) { +continue; +} if (!virtio_queue_get_num(vdev, queue_no)) { break; } @@ -665,6 +680,9 @@ static int kvm_virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector, int ret, queue_no; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { +if (!virtio_queue_valid(vdev, queue_no)) { +continue; +} if (!virtio_queue_get_num(vdev, queue_no)) { break; } @@ -695,6 +713,9 @@ static void kvm_virtio_pci_vector_mask(PCIDevice *dev, unsigned vector) int queue_no; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { +if (!virtio_queue_valid(vdev, queue_no)) { +continue; +} if (!virtio_queue_get_num(vdev, queue_no)) { break; } @@ -717,6 +738,9 @@ static void kvm_virtio_pci_vector_poll(PCIDevice *dev, VirtQueue *vq; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { +if (!virtio_queue_valid(vdev, queue_no)) { +continue; +} if (!virtio_queue_get_num(vdev, queue_no)) { break; } @@ -790,6 +814,9 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) } for (n = 0; n < nvqs; n++) { +if (!virtio_queue_valid(vdev, n)) { +continue; +} if (!virtio_queue_get_num(vdev, n)) { break; } -- 1.7.2.5
[Qemu-devel] [PATCH 0/3] virtio/vhost: Add checks for uninitialized VQs
From: Nicholas Bellinger Hi folks, This series adds a virtio_queue_valid() for use by virtio-pci code in order to prevent opreations upon uninitialized VQs, that is currently expected to occur during seabios setup of virtio-scsi. This also includes a vhost specific check for uninitialized VQs in vhost_verify_ring_mappings() to avoid this same case. Please review. --nab Michael S. Tsirkin (1): virtio: add API to check that ring is setup Nicholas Bellinger (2): virtio-pci: Add virtio_queue_valid checks ahead of virtio_queue_get_num vhost: Check+skip uninitialized VQs in vhost_verify_ring_mappings hw/vhost.c |3 +++ hw/virtio-pci.c | 27 +++ hw/virtio.c |5 + hw/virtio.h |1 + 4 files changed, 36 insertions(+), 0 deletions(-) -- 1.7.2.5
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Thu, 2013-03-28 at 11:04 +0200, Michael S. Tsirkin wrote: > On Thu, Mar 28, 2013 at 12:35:42AM -0700, Nicholas A. Bellinger wrote: > > On Wed, 2013-03-27 at 23:45 -0700, Nicholas A. Bellinger wrote: > > > On Wed, 2013-03-27 at 15:33 -0700, Nicholas A. Bellinger wrote: > > > > On Wed, 2013-03-27 at 23:56 +0200, Michael S. Tsirkin wrote: > > > > > On Wed, Mar 27, 2013 at 02:31:27PM -0700, Nicholas A. Bellinger wrote: > > > > locking shadow ram > > romend: 0x000cb800 romtop: 0x000ec000 > > mem: 0x000c, pam: 0x005a > > Calling pci_config_writeb(0x11): bdf: 0x pam: 0x005a > > > > > > > > > > > Calling pci_config_writeb(0x31): bdf: 0x pam: 0x005b > > > > > > > > > > mem: 0x000c8000, pam: 0x005b > > romend: 0x000cb800 mem + 16*1024: 0x000cc000 > > romtop: 0x000ec000 mem + 32*1024: 0x000d > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > romend: 0x000cb800, mem: 0x000c8000, romtop: 0x000ec000, mem + 16*1024: > > 0x000cc000 > > Calling pci_config_writeb(0x31): bdf: 0x pam: 0x005b > > > > > > > > > > > > > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 2146697216 add: 0 > > > Before vhost_verify_ring_mappings: start_addr: c size: 2146697216 > > > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > This is also a bug. -net always initializes VQs 0..N so this is what > vhost assumed. Please teach vhost that it should skip uninitialized > VQs. There are more places to fix. > Basically look for if (!virtio_queue_get_num(vdev, queue_no)), > all of them need to be updated to skip uninitialized vqs. > Probably switch to a new API checking PA too. > See patch below. > > > > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > > > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > > > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>>>>>>>>>>>>>>>>>. > > > Calling l: 5124 for start_addr: c for vq 2 > > > Unable to map ring buffer for ring 2 > > > l: 4096 ring_size: 5124 > > okay so the ring address is within ROM. > Unsurprisingly it fails. > bios should stop device before write protect. > --- > > virtio: add API to check that ring is setup > > virtio scsi makes it legal to only setup a subset of rings. The only > way to detect the ring is setup seems to be to check whether PA was > written to. Add API to do this, and teach code to use it instead of > checking hardware queue size. > > Signed-off-by: Michael S. Tsirkin > > ---> > > diff --git a/hw/virtio.c b/hw/virtio.c > index 26fbc79..ac12c01 100644 > --- a/hw/virtio.c > +++ b/hw/virtio.c > @@ -651,6 +651,11 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n) > return vdev->vq[n].vring.num; > } > > +bool virtio_queue_valid(VirtIODevice *vdev, int n) > +{ > +return vdev->vq[n].vring.num && vdev->vq[n].vring.pa; > +} I assume you mean vring.desc here, right..? Sending out these as a separate patch series shortly. --nab
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Thu, 2013-03-28 at 06:13 -0400, Paolo Bonzini wrote: > > I think it's the right thing to do, but maybe not the right place > > to do this, need to reset after all IO is done, before > > ring memory is write protected. > > Our emails are crossing each other unfortunately, but I want to > reinforce this: ring memory is not write protected. Understood. However, AFAICT the act of write protecting these ranges for ROM generates the offending callbacks to vhost_set_memory(). The part that I'm missing is if ring memory is not being write protected by make_bios_readonly_intel(), why are the vhost_set_memory() calls being invoked..? > Remember that > SeaBIOS can even provide virtio-scsi access to DOS, so you must > not reset the device. It must remain functional all the time, > and the OS's own driver will reset it when it's started. > Mmmm, so a vp_reset() is out of the question then.. --nab
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Thu, 2013-03-28 at 11:03 +0100, Paolo Bonzini wrote: > Il 28/03/2013 10:04, Michael S. Tsirkin ha scritto: > >>> > > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > >>> > > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>. > >>> > > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > >>> > > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>. > >>> > > Calling l: 5124 for start_addr: c for vq 2 > >>> > > Unable to map ring buffer for ring 2 > >>> > > l: 4096 ring_size: 5124 > > okay so the ring address is within ROM. > > Unsurprisingly it fails. > > bios should stop device before write protect. > > > > The above log is very early, when everything is RAM: > > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 2146697216 add: 0 > Before vhost_verify_ring_mappings: start_addr: c size: 2146697216 > > The rings are not within ROM. ROM is at 0xc-0xcc000 according to the > PAM registers. > > The way I followed the debug output, "Got ranges_overlap" means > actually "bailing out because ranges do not overlap". Yes, this is when !ranges_overlap() is hit in vhost_verify_ring_mappings(), so the offending cpu_physical_memory_map() is skipped.. > In particular, > here all three virtqueues fail the test, because this is the ROM area > 0xc..0xc7fff: > > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 32768 add: 1 > Before vhost_verify_ring_mappings: start_addr: c size: 32768 > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>. > Got ranges_overlap for vq: 2 ring_phys: ed000 ring_size: 5124 > > Just below, vhost looks at the large RAM area starting at 0xc8000 > (it's large because 0xf..0xf is still RAM): > > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 2146664448 add: 1 > Before vhost_verify_ring_mappings: start_addr: c8000 size: 2146664448 > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>. > Calling l: 5124 for start_addr: c8000 for vq 2 > > Here vq 0 and 1 fail the test because they are in low RAM, vq 2 passes. > > After 0xf..0xf is marked readonly, Btw, the first vhost_set_memory() and failing vhost_verify_ring_mappings() do not occur until the pci_config_writeb(..., 0x31) code is executed in src/shadow.c:make_bios_readonly_intel() below: static void make_bios_readonly_intel(u16 bdf, u32 pam0) { // Flush any pending writes before locking memory. wbinvd(); // Write protect roms from 0xc-0xf u32 romend = rom_get_last(), romtop = rom_get_max(); int i; for (i=0; i<6; i++) { u32 mem = BUILD_ROM_START + i * 32*1024; u32 pam = pam0 + 1 + i; if (romend <= mem + 16*1024 || romtop <= mem + 32*1024) { if (romend > mem && romtop > mem + 16*1024) pci_config_writeb(bdf, pam, 0x31); ^ break; } pci_config_writeb(bdf, pam, 0x11); } // Write protect 0xf-0x10 pci_config_writeb(bdf, pam0, 0x10); } Up until this point, vhost_verify_ring_mappings() is not called by vhost_set_memory() as vhost_dev_start() has not been invoked to set vdev->started yet.. > vhost looks at the RAM > between 0xc9000 and 0xf: > > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 159744 add: 1 > Before vhost_verify_ring_mappings: start_addr: c9000 size: 159744 > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>. > Calling l: 5124 for start_addr: c9000 for vq 2 > > and the ROM between 0xf and 0xf, which no ring overlaps with: > > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 65536 add: 1 > Before vhost_verify_ring_mappings: start_addr: f size: 65536 > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>. > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > Checking vq: 2 ring_phys: ed000 ring_size: 5124 >>. > Got ranges_overlap for vq: 2 ring_phys: ed000 ring_size: 5124 > > > > SeaBIOS is indeed
[Qemu-devel] [PATCH-v2 2/2] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
From: Paolo Bonzini The WWPN specified in configfs is passed to "-device vhost-scsi-pci". The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not available from the QEMU command-line. Instead, I hardcode it to zero. Changes in Patch-v2: - Add vhost_scsi_get_features() in order to determine feature bits supports by host kernel (mst + nab) - Re-enable usage of DEFINE_VIRTIO_COMMON_FEATURES, and allow EVENT_IDX to be disabled by host in vhost_scsi_get_features() - Drop unused hotplug bit in DEFINE_VHOST_SCSI_PROPERTIES Changes in Patch-v1: - Set event_idx=off by default (nab, thanks asias) - Disable hotplug feature bit for v3.9 tcm_vhost kernel code, need to re-enable in v3.10 (nab) - Update to latest qemu.git/master HEAD Changes in WIP-V3: - Drop ioeventfd vhost_scsi_properties (asias, thanks stefanha) - Add CONFIG_VHOST_SCSI (asias, thanks stefanha) - Add hotplug feature bit Changes in WIP-V2: - Add backend guest masking support (nab) - Bump ABI_VERSION to 1 (nab) - Set up set_guest_notifiers (asias) - Set up vs->dev.vq_index (asias) - Drop vs->vs.vdev.{set,clear}_vhost_endpoint (asias) - Drop VIRTIO_CONFIG_S_DRIVER check in vhost_scsi_set_status (asias) Howto: Use the latest seabios, at least commit b44a7be17b git clone git://git.seabios.org/seabios.git make cp out/bios.bin /usr/share/qemu/bios.bin qemu -device vhost-scsi-pci,wwpn=naa.6001405bd4e8476d,event_idx=off ... Signed-off-by: Paolo Bonzini Signed-off-by: Asias He Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- configure | 15 +++- hw/Makefile.objs |5 +- hw/s390x/s390-virtio-bus.c | 35 ++ hw/vhost-scsi.c| 264 hw/vhost-scsi.h| 64 +++ hw/virtio-pci.c| 62 ++ hw/virtio-scsi.h |2 + 7 files changed, 445 insertions(+), 2 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h diff --git a/configure b/configure index f2af714..6b67e35 100755 --- a/configure +++ b/configure @@ -169,6 +169,7 @@ libattr="" xfs="" vhost_net="no" +vhost_scsi="no" kvm="no" gprof="no" debug_tcg="no" @@ -532,6 +533,7 @@ Haiku) usb="linux" kvm="yes" vhost_net="yes" + vhost_scsi="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi @@ -858,6 +860,10 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-vhost-scsi) vhost_scsi="no" + ;; + --enable-vhost-scsi) vhost_scsi="yes" + ;; --disable-glx) glx="no" ;; --enable-glx) glx="yes" @@ -3078,7 +3084,7 @@ fi # __sync_fetch_and_and requires at least -march=i486. Many toolchains # use i686 as default anyway, but for those that don't, an explicit # specification is necessary -if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then +if (test "$vhost_net" = "yes" -o "$vhost_scsi" = "yes") && test "$cpu" = "i386"; then cat > $TMPC << EOF static int sfaa(int *ptr) { @@ -3424,6 +3430,7 @@ echo "sigev_thread_id $sigev_thread_id" echo "uuid support $uuid" echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" +echo "vhost-scsi support $vhost_scsi" echo "Trace backend $trace_backend" echo "Trace output file $trace_file-" echo "spice support $spice ($spice_protocol_version/$spice_server_version)" @@ -3697,6 +3704,9 @@ fi if test "$virtfs" = "yes" ; then echo "CONFIG_VIRTFS=y" >> $config_host_mak fi +if test "$vhost_scsi" = "yes" ; then + echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak +fi if test "$blobs" = "yes" ; then echo "INSTALL_BLOBS=yes" >> $config_host_mak fi @@ -4175,6 +4185,9 @@ case "$target_arch2" in if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi + if test "$vhost_scsi" = "yes" ; then +echo "CONFIG_VHOST_SCSI=y" >> $config_target_mak + fi fi esac case "$target_arch2" in diff --git a/hw/Makefile.objs b/hw/Makefile.objs index d0b2ecb..0a38eb5 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -205,8 +205,11 @@ common-obj-$(CONFIG_XEN_BACKEND) += xen_console.o xenfb.o xen_disk.o xen_nic.o obj-$(CONFIG_VIRTIO) += dataplane/ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o virtio-balloon.o virtio-net.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o +ifeq ($(CONFIG_VIRTIO), y) +obj-$(CONFIG_LINUX) += vhost-scsi.o +endif obj-$(CONFIG_SOFTMMU) += vhost_net.o -obj-$(CONFIG_VHOST_NET) += vhost.o +obj-$(CONFIG_LINUX) += vhost.o obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ obj-$(CONFIG_VGA) += vga.o diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index c5d5456..73d93fd 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -28,6 +28,8 @@ #include "hw/virtio-rng.h" #include "hw/virtio-serial.h" #include "hw/virtio-net.h" +#inclu
[Qemu-devel] [PATCH-v2 1/2] virtio-scsi: create VirtIOSCSICommon
From: Paolo Bonzini This patch refactors existing virtio-scsi code into VirtIOSCSICommon in order to allow virtio_scsi_init_common() to be used by both internal virtio_scsi_init() and external vhost-scsi-pci code. Changes in Patch-v2: - Move ->get_features() assignment to virtio_scsi_init() instead of virtio_scsi_init_common() Signed-off-by: Paolo Bonzini Cc: Michael S. Tsirkin Cc: Asias He Signed-off-by: Nicholas Bellinger --- hw/virtio-scsi.c | 192 +- hw/virtio-scsi.h | 130 -- include/qemu/osdep.h |4 + 3 files changed, 178 insertions(+), 148 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 8620712..c59e9c6 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -18,118 +18,6 @@ #include #include -#define VIRTIO_SCSI_VQ_SIZE 128 -#define VIRTIO_SCSI_CDB_SIZE32 -#define VIRTIO_SCSI_SENSE_SIZE 96 -#define VIRTIO_SCSI_MAX_CHANNEL 0 -#define VIRTIO_SCSI_MAX_TARGET 255 -#define VIRTIO_SCSI_MAX_LUN 16383 - -/* Response codes */ -#define VIRTIO_SCSI_S_OK 0 -#define VIRTIO_SCSI_S_OVERRUN 1 -#define VIRTIO_SCSI_S_ABORTED 2 -#define VIRTIO_SCSI_S_BAD_TARGET 3 -#define VIRTIO_SCSI_S_RESET4 -#define VIRTIO_SCSI_S_BUSY 5 -#define VIRTIO_SCSI_S_TRANSPORT_FAILURE6 -#define VIRTIO_SCSI_S_TARGET_FAILURE 7 -#define VIRTIO_SCSI_S_NEXUS_FAILURE8 -#define VIRTIO_SCSI_S_FAILURE 9 -#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10 -#define VIRTIO_SCSI_S_FUNCTION_REJECTED11 -#define VIRTIO_SCSI_S_INCORRECT_LUN12 - -/* Controlq type codes. */ -#define VIRTIO_SCSI_T_TMF 0 -#define VIRTIO_SCSI_T_AN_QUERY 1 -#define VIRTIO_SCSI_T_AN_SUBSCRIBE 2 - -/* Valid TMF subtypes. */ -#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0 -#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1 -#define VIRTIO_SCSI_T_TMF_CLEAR_ACA2 -#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3 -#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4 -#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5 -#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6 -#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7 - -/* Events. */ -#define VIRTIO_SCSI_T_EVENTS_MISSED0x8000 -#define VIRTIO_SCSI_T_NO_EVENT 0 -#define VIRTIO_SCSI_T_TRANSPORT_RESET 1 -#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 -#define VIRTIO_SCSI_T_PARAM_CHANGE 3 - -/* Reasons for transport reset event */ -#define VIRTIO_SCSI_EVT_RESET_HARD 0 -#define VIRTIO_SCSI_EVT_RESET_RESCAN 1 -#define VIRTIO_SCSI_EVT_RESET_REMOVED 2 - -/* SCSI command request, followed by data-out */ -typedef struct { -uint8_t lun[8]; /* Logical Unit Number */ -uint64_t tag;/* Command identifier */ -uint8_t task_attr; /* Task attribute */ -uint8_t prio; -uint8_t crn; -uint8_t cdb[]; -} QEMU_PACKED VirtIOSCSICmdReq; - -/* Response, followed by sense data and data-in */ -typedef struct { -uint32_t sense_len; /* Sense data length */ -uint32_t resid; /* Residual bytes in data buffer */ -uint16_t status_qualifier; /* Status qualifier */ -uint8_t status; /* Command completion status */ -uint8_t response;/* Response values */ -uint8_t sense[]; -} QEMU_PACKED VirtIOSCSICmdResp; - -/* Task Management Request */ -typedef struct { -uint32_t type; -uint32_t subtype; -uint8_t lun[8]; -uint64_t tag; -} QEMU_PACKED VirtIOSCSICtrlTMFReq; - -typedef struct { -uint8_t response; -} QEMU_PACKED VirtIOSCSICtrlTMFResp; - -/* Asynchronous notification query/subscription */ -typedef struct { -uint32_t type; -uint8_t lun[8]; -uint32_t event_requested; -} QEMU_PACKED VirtIOSCSICtrlANReq; - -typedef struct { -uint32_t event_actual; -uint8_t response; -} QEMU_PACKED VirtIOSCSICtrlANResp; - -typedef struct { -uint32_t event; -uint8_t lun[8]; -uint32_t reason; -} QEMU_PACKED VirtIOSCSIEvent; - -typedef struct { -uint32_t num_queues; -uint32_t seg_max; -uint32_t max_sectors; -uint32_t cmd_per_lun; -uint32_t event_info_size; -uint32_t sense_size; -uint32_t cdb_size; -uint16_t max_channel; -uint16_t max_target; -uint32_t max_lun; -} QEMU_PACKED VirtIOSCSIConfig; - typedef struct VirtIOSCSIReq { VirtIOSCSI *dev; VirtQueue *vq; @@ -178,7 +66,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req) scsi_req_unref(req->sreq); } g_free(req); -virtio_notify(&s->vdev, vq); +virtio_notify(&s->vs.vdev, vq); } static void virtio_scsi_bad_req(void) @@ -237,7 +125,7 @@ static void virtio_scsi_save_request(QEMUFile *f, SCSIRequest *sreq) VirtIOSCSIReq
[Qemu-devel] [PATCH-v2 0/2] Add support for vhost-scsi-pci
From: Nicholas Bellinger Hi QEMU folks, The following is the patch-v2 series to support vhost-scsi-pci within the upstream QEMU tree. This includes the refactoring of existing virtio-scsi code from Paolo to allow a VirtIOSCSICommon structure that is shared amoungst existing virtio-scsi-pci device and new vhost-scsi-pci device code. Currently this code requires Asias's seabios bugfixes (commit 5a7730db5 and b44a7be17), and two other tcm_vhost patches to reset vq->last_used_idx after seabios handoff and disable EVENT_IDX from GET_FEATURES that's currently in flight for v3.9.0 kernel code. There is a seperate issue with seabios virtio-scsi that's causing a failure in vhost_verify_ring_mappings() is still being tracked down, but this series should now be getting close to a merge minus this last outstanding item. Changes in Patch-v2: - Move ->get_features() assignment to virtio_scsi_init() instead of virtio_scsi_init_common() (nab) - Add vhost_scsi_get_features() in order to determine feature bits supports by host kernel (mst + nab) - Re-enable usage of DEFINE_VIRTIO_COMMON_FEATURES, and allow EVENT_IDX to be disabled by host in vhost_scsi_get_features() (mst) - Drop unused hotplug bit in DEFINE_VHOST_SCSI_PROPERTIES (mst) - Drop vhost_verify_ring_mappings() enable-only hack (mst) A big thanks to Paolo, Asias, MST, and Stefan for all of their efforts on this series. Thank you, Paolo Bonzini (2): virtio-scsi: create VirtIOSCSICommon vhost-scsi: new device supporting the tcm_vhost Linux kernel module configure | 15 +++- hw/Makefile.objs |5 +- hw/s390x/s390-virtio-bus.c | 35 ++ hw/vhost-scsi.c| 264 hw/vhost-scsi.h| 64 +++ hw/virtio-pci.c| 62 ++ hw/virtio-scsi.c | 192 hw/virtio-scsi.h | 132 +- include/qemu/osdep.h |4 + 9 files changed, 623 insertions(+), 150 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h -- 1.7.2.5
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Wed, 2013-03-27 at 23:45 -0700, Nicholas A. Bellinger wrote: > On Wed, 2013-03-27 at 15:33 -0700, Nicholas A. Bellinger wrote: > > On Wed, 2013-03-27 at 23:56 +0200, Michael S. Tsirkin wrote: > > > On Wed, Mar 27, 2013 at 02:31:27PM -0700, Nicholas A. Bellinger wrote: Adding a bit more detailed seabios PCI setup info, and make_bios_readonly_intel() debug output for Kevin & Co to review. > > > > > I still do not understand how this happened. Somehow a memory region > > > was deleted after vhost_dev_start but before vhost_virtqueue_start was > > > called? > > > > Not sure.. > > > > To clarify, this is only happening during seabios setup+scan of > > virtio-scsi, and not during normal virtio_scsi LLD operation. > > > > > Can you set a breakpoint there and see please? > > > > > > > > > > A bit more context here.. > > After debugging seabios this evening, I've isolated the spot where > things begin to go south for vhost_verify_ring_mappings check() > > Below are logs from qemu + seabios serial output mixed to (attempt) to > demonstrate what's going on.. > > root@tifa:/usr/src# qemu-system-x86_64 -enable-kvm -smp 4 -m 2048 > -serial file:/tmp/vhost-serial.txt > -hda /usr/src/qemu-paolo.git/debian_squeeze_amd64_standard.qcow2 -device > vhost-scsi-pci,wwpn=naa.600140579ad21088 > qemu-system-x86_64: pci_add_option_rom: failed to find romfile "efi-e1000.rom" > Calling ->region_add: section.size: 655360 > vhost_set_memory: section: 0x7fff962c2580 section->size: 655360 add: 1 > Calling ->region_add: section.size: 131072 > Calling ->region_add: section.size: 131072 > vhost_set_memory: section: 0x7fff962c2580 section->size: 131072 add: 1 > Calling ->region_add: section.size: 131072 > vhost_set_memory: section: 0x7fff962c2580 section->size: 131072 add: 1 > Calling ->region_add: section.size: 2146435072 > vhost_set_memory: section: 0x7fff962c2580 section->size: 2146435072 add: 1 > Calling ->region_add: section.size: 4096 > Calling ->region_add: section.size: 1024 > Calling ->region_add: section.size: 1048576 > Calling ->region_add: section.size: 262144 > vhost_set_memory: section: 0x7fff962c2580 section->size: 262144 add: 1 > vhost_scsi_init_pci Before virtio_init_pci > virtio_init_pci: size: 60 > virtio_init_pci: new size: 64 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 131072 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 32768 add: 1 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 98304 add: 1 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 32768 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 98304 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 65536 add: 1 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 65536 add: 1 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 65536 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 65536 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 98304 add: 1 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 32768 add: 1 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 98304 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 32768 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 131072 add: 1 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 131072 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 131072 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 163840 add: 1 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 98304 add: 1 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 163840 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 98304 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 196608 add: 1 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 65536 add: 1 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 196608 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 65536 add: 0 > vhost_set_memory: section: 0x7fe2801f2b60 section->size: 2146435072 add: 0 > vhost_set_memory: section: 0x7fe2801f2aa0 section->size: 2146697216 add: 1 > vhost_set_memory: section: 0x7fe2801f29f0 section->size: 65536 add: 1 > vhost_set_memory: section: 0x7fe2801f2ab0 section->size: 65536 add: 0 > vhost_set_memory: section: 0x7fe2801f2a70 section->size: 8388608 add: 1 > Entering vhost_dev_start >>>>>>>>>>>>>>>>>>>>>. > Before vhost_virtqueue_start >>>&g
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Wed, 2013-03-27 at 15:33 -0700, Nicholas A. Bellinger wrote: > On Wed, 2013-03-27 at 23:56 +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 27, 2013 at 02:31:27PM -0700, Nicholas A. Bellinger wrote: > > > On Wed, 2013-03-20 at 11:51 +0200, Michael S. Tsirkin wrote: > > > > On Tue, Mar 19, 2013 at 06:57:08PM -0700, Nicholas A. Bellinger wrote: > > > > > On Tue, 2013-03-19 at 09:40 +0100, Stefan Hajnoczi wrote: > > > > > > On Tue, Mar 19, 2013 at 08:34:45AM +0800, Asias He wrote: > > > > > > > --- > > > > > > > hw/vhost.c | 2 ++ > > > > > > > 1 file changed, 2 insertions(+) > > > > > > > > > > > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > > > > > > index 4d6aee3..0c52ec4 100644 > > > > > > > --- a/hw/vhost.c > > > > > > > +++ b/hw/vhost.c > > > > > > > @@ -421,10 +421,12 @@ static void vhost_set_memory(MemoryListener > > > > > > > *listener, > > > > > > > return; > > > > > > > } > > > > > > > > > > > > > > +#if 0 > > > > > > > if (dev->started) { > > > > > > > r = vhost_verify_ring_mappings(dev, start_addr, size); > > > > > > > assert(r >= 0); > > > > > > > } > > > > > > > +#endif > > > > > > > > > > > > Please add a comment to explain why. > > > > > > > > > > > > > > > > Btw, the output that Asias added in the failure case at the behest of > > > > > MST is here: > > > > > > > > > > http://www.spinics.net/lists/target-devel/msg04077.html > > > > > > > > Yes I suspected we could get l > ring_size, but this is > > > > not the case here. > > > > > > > > > > Hi MST & Co, > > > > > > A quick update here.. > > > > > > So this issue appears to be related to performing the > > > vhost_verify_ring_mappings() call after vhost_dev_unassign_memory() has > > > been invoked with vhost_set_memory(..., add=false). > > > > > > AFAICT from the logs below, things appear to work as expected when > > > vhost_verify_ring_mappings() is called only for the > > > vhost_set_memory(..., add=true) case. > > > > > > Calling vhost_verify_ring_mappings() when dev->started == true + > > > vhost_set_memory(..., add=false) appears to be a bug caused by fallout > > > from: > > > > > > commit 24f4fe345c1b80bab1ee18573914123d8028a9e6 > > > Author: Michael S. Tsirkin > > > Date: Tue Dec 25 17:41:07 2012 +0200 > > > > > > vhost: set started flag while start is in progress > > > > > > I'm including the following patch in the forth-coming vhost-scsi series. > > > Please let me know if you have any concerns. > > > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > > index 4d6aee3..687a689 100644 > > > --- a/hw/vhost.c > > > +++ b/hw/vhost.c > > > @@ -421,7 +421,7 @@ static void vhost_set_memory(MemoryListener *listener, > > > return; > > > } > > > > > > -if (dev->started) { > > > +if (dev->started && add) { > > > r = vhost_verify_ring_mappings(dev, start_addr, size); > > > assert(r >= 0); > > > } > > > > > > Thanks! > > > > > > --nab > > > > Sorry NAK, > > I think this will shut down too much stuff: > > the main reason to check is when we delete a region. > > > > > I still do not understand how this happened. Somehow a memory region > > was deleted after vhost_dev_start but before vhost_virtqueue_start was > > called? > > Not sure.. > > To clarify, this is only happening during seabios setup+scan of > virtio-scsi, and not during normal virtio_scsi LLD operation. > > > Can you set a breakpoint there and see please? > > > > > A bit more context here.. After debugging seabios this evening, I've isolated the spot where things begin to go south for vhost_verify_ring_mappings check() Below are logs from qemu + seabios serial output mixed to (attempt) to demonstrate what's going on.. root@tifa:/usr/src# qemu-system-x86_64 -enable-kvm -smp 4 -m 2048 -serial file:/tmp/vhos
Re: [Qemu-devel] [PATCH 2/3] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Thu, 2013-03-28 at 08:19 +0200, Michael S. Tsirkin wrote: > On Wed, Mar 27, 2013 at 04:24:22PM -0700, Nicholas A. Bellinger wrote: > > On Thu, 2013-03-28 at 00:53 +0200, Michael S. Tsirkin wrote: > > > On Thu, Mar 28, 2013 at 12:50:21AM +0200, Michael S. Tsirkin wrote: > > > > On Wed, Mar 27, 2013 at 03:45:42PM -0700, Nicholas A. Bellinger wrote: > > > > > On Thu, 2013-03-28 at 00:28 +0200, Michael S. Tsirkin wrote: > > > > > > On Wed, Mar 27, 2013 at 09:59:45PM +, Nicholas A. Bellinger > > > > > > wrote: > > > > > > > From: Paolo Bonzini > > > > > > > > > > > > > > The WWPN specified in configfs is passed to "-device > > > > > > > vhost-scsi-pci". > > > > > > > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it > > > > > > > is not > > > > > > > available from the QEMU command-line. Instead, I hardcode it to > > > > > > > zero. > > > > > > > > > > > > > > Changes in V4: > > > > > > >- Set event_idx=off by default (nab, thanks asias) > > > > > > > > > > > > Why? What's going on here? > > > > > > > > > > > > > > > > Not disabling event_idx by default, or disabling from the command line > > > > > ends up resulting in ->handle_kick() not getting called for subsequent > > > > > commands.. > > > > > > > > > > I spent some time trying to track this down recently with no luck, and > > > > > AFAICT it's always been required in order for vhost-scsi to function. > > > > > > > > Hmm this is a bug in kernel then. A better work-around is > > > > to disable EVENT_IDX in kernel. Let's do it for 3.9? > > > > > > But before we do, can you check that SET_FEATURES is > > > called with this bit set if you enable event_idx? > > > If not that's your bug then ... > > > > > > > Ok, SET_FEATURES is currently not setting any bits at all based upon > > vhost_dev->features, so it looks like a vhost-scsi-pci bug.. > > > > > > If you call SET_FEATURES, does it start working even without > disabling EVENT_IDX in kernel? > Unfortunately, no. The same strangeness persists unless event_idx=off is passed, or EVENT_IDX is disabled in the kernel and stripped off with the vhost_scsi_get_features() patch.
Re: [Qemu-devel] [PATCH 2/3] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Wed, 2013-03-27 at 16:24 -0700, Nicholas A. Bellinger wrote: > On Thu, 2013-03-28 at 00:53 +0200, Michael S. Tsirkin wrote: > > On Thu, Mar 28, 2013 at 12:50:21AM +0200, Michael S. Tsirkin wrote: > > > On Wed, Mar 27, 2013 at 03:45:42PM -0700, Nicholas A. Bellinger wrote: > > > > On Thu, 2013-03-28 at 00:28 +0200, Michael S. Tsirkin wrote: > > > > > On Wed, Mar 27, 2013 at 09:59:45PM +, Nicholas A. Bellinger wrote: > > > > > > From: Paolo Bonzini > > > > > > > > > > > > The WWPN specified in configfs is passed to "-device > > > > > > vhost-scsi-pci". > > > > > > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is > > > > > > not > > > > > > available from the QEMU command-line. Instead, I hardcode it to > > > > > > zero. > > > > > > > > > > > > Changes in V4: > > > > > >- Set event_idx=off by default (nab, thanks asias) > > > > > > > > > > Why? What's going on here? > > > > > > > > > > > > > Not disabling event_idx by default, or disabling from the command line > > > > ends up resulting in ->handle_kick() not getting called for subsequent > > > > commands.. > > > > > > > > I spent some time trying to track this down recently with no luck, and > > > > AFAICT it's always been required in order for vhost-scsi to function. > > > > > > Hmm this is a bug in kernel then. A better work-around is > > > to disable EVENT_IDX in kernel. Let's do it for 3.9? > > > > But before we do, can you check that SET_FEATURES is > > called with this bit set if you enable event_idx? > > If not that's your bug then ... > > > > Ok, SET_FEATURES is currently not setting any bits at all based upon > vhost_dev->features, so it looks like a vhost-scsi-pci bug.. > > Adding the following patch for a vhost_scsi specific ->get_features() call in order to strip off the unsupported host feature bits. Please review. Also, providing the proper EVENT_IDX bit to SET_FEATURES results in the same lost ->handle_kick() for vhost-scsi-pci devices, so the previous VHOST_TCM_FEATURES patch to strip off EVENT_IDX is still required to work.. Sending this out separately, please review and ACK. Thanks, --nab diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c index 70e42fc..adc929b 100644 --- a/hw/vhost-scsi.c +++ b/hw/vhost-scsi.c @@ -128,6 +128,28 @@ static void vhost_scsi_stop(VHostSCSI *vs, VirtIODevice *vdev) vhost_dev_disable_notifiers(&vs->dev, vdev); } +static uint32_t vhost_scsi_get_features(VirtIODevice *vdev, +uint32_t features) +{ +VHostSCSI *vs = (VHostSCSI *)vdev; + +/* Clear features not supported by host kernel. */ +if (!(vs->dev.features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY))) { +features &= ~(1 << VIRTIO_F_NOTIFY_ON_EMPTY); +} +if (!(vs->dev.features & (1 << VIRTIO_RING_F_INDIRECT_DESC))) { +features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC); +} +if (!(vs->dev.features & (1 << VIRTIO_RING_F_EVENT_IDX))) { +features &= ~(1 << VIRTIO_RING_F_EVENT_IDX); +} +if (!(vs->dev.features & (1 << VIRTIO_SCSI_F_HOTPLUG))) { +features &= ~(1 << VIRTIO_SCSI_F_HOTPLUG); +} + +return features; +} + static void vhost_scsi_set_config(VirtIODevice *vdev, const uint8_t *config) { @@ -203,6 +225,7 @@ VirtIODevice *vhost_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) vs = (VHostSCSI *)virtio_scsi_init_common(dev, proxyconf, sizeof(VHostSCSI)); +vs->vs.vdev.get_features = vhost_scsi_get_features; vs->vs.vdev.set_config = vhost_scsi_set_config; vs->vs.vdev.set_status = vhost_scsi_set_status; vs->vs.vdev.guest_notifier_mask = vhost_scsi_guest_notifier_mask; @@ -219,7 +242,7 @@ VirtIODevice *vhost_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) return NULL; } vs->dev.backend_features = 0; -vs->dev.acked_features = 0; +vs->dev.acked_features = vs->dev.features; error_setg(&vs->migration_blocker, "vhost-scsi does not support migration"); diff --git a/hw/vhost-scsi.h b/hw/vhost-scsi.h index b01f012..70f4a58 100644 --- a/hw/vhost-scsi.h +++ b/hw/vhost-scsi.h @@ -50,14 +50,12 @@ enum vhost_scsi_vq_list { #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int) #define DEFINE_VHOST_SCSI_PROPERTIES(_state,
Re: [Qemu-devel] [PATCH 2/3] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Thu, 2013-03-28 at 00:53 +0200, Michael S. Tsirkin wrote: > On Thu, Mar 28, 2013 at 12:50:21AM +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 27, 2013 at 03:45:42PM -0700, Nicholas A. Bellinger wrote: > > > On Thu, 2013-03-28 at 00:28 +0200, Michael S. Tsirkin wrote: > > > > On Wed, Mar 27, 2013 at 09:59:45PM +, Nicholas A. Bellinger wrote: > > > > > From: Paolo Bonzini > > > > > > > > > > The WWPN specified in configfs is passed to "-device vhost-scsi-pci". > > > > > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not > > > > > available from the QEMU command-line. Instead, I hardcode it to zero. > > > > > > > > > > Changes in V4: > > > > >- Set event_idx=off by default (nab, thanks asias) > > > > > > > > Why? What's going on here? > > > > > > > > > > Not disabling event_idx by default, or disabling from the command line > > > ends up resulting in ->handle_kick() not getting called for subsequent > > > commands.. > > > > > > I spent some time trying to track this down recently with no luck, and > > > AFAICT it's always been required in order for vhost-scsi to function. > > > > Hmm this is a bug in kernel then. A better work-around is > > to disable EVENT_IDX in kernel. Let's do it for 3.9? > > But before we do, can you check that SET_FEATURES is > called with this bit set if you enable event_idx? > If not that's your bug then ... > Ok, SET_FEATURES is currently not setting any bits at all based upon vhost_dev->features, so it looks like a vhost-scsi-pci bug..
Re: [Qemu-devel] [PATCH 2/3] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Thu, 2013-03-28 at 00:50 +0200, Michael S. Tsirkin wrote: > On Wed, Mar 27, 2013 at 03:45:42PM -0700, Nicholas A. Bellinger wrote: > > On Thu, 2013-03-28 at 00:28 +0200, Michael S. Tsirkin wrote: > > > On Wed, Mar 27, 2013 at 09:59:45PM +, Nicholas A. Bellinger wrote: > > > > From: Paolo Bonzini > > > > > > > > The WWPN specified in configfs is passed to "-device vhost-scsi-pci". > > > > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not > > > > available from the QEMU command-line. Instead, I hardcode it to zero. > > > > > > > > Changes in V4: > > > >- Set event_idx=off by default (nab, thanks asias) > > > > > > Why? What's going on here? > > > > > > > Not disabling event_idx by default, or disabling from the command line > > ends up resulting in ->handle_kick() not getting called for subsequent > > commands.. > > > > I spent some time trying to track this down recently with no luck, and > > AFAICT it's always been required in order for vhost-scsi to function. > > Hmm this is a bug in kernel then. A better work-around is > to disable EVENT_IDX in kernel. Let's do it for 3.9? > Then when we fix it, things just work for userspace. > Mmmm, the following patch yields the same results with the event_idx=on default for DEFINE_VHOST_SCSI_PROPERTIES. Is there another method you had in mind to disable EVENT_IDX..? diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index 0524267..757cbda 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c @@ -981,7 +981,7 @@ static void vhost_scsi_flush(struct vhost_scsi *vs) static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features) { - if (features & ~VHOST_FEATURES) + if (features & ~VHOST_TCM_FEATURES) return -EOPNOTSUPP; mutex_lock(&vs->dev.mutex); @@ -1027,7 +1027,7 @@ static long vhost_scsi_ioctl(struct file *f, unsigned int ioctl, return -EFAULT; return 0; case VHOST_GET_FEATURES: - features = VHOST_FEATURES; + features = VHOST_TCM_FEATURES; if (copy_to_user(featurep, &features, sizeof features)) return -EFAULT; return 0; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 17261e2..588536e 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -204,6 +204,9 @@ enum { VHOST_NET_FEATURES = VHOST_FEATURES | (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) | (1ULL << VIRTIO_NET_F_MRG_RXBUF), + VHOST_TCM_FEATURES = (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | +(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | +(1ULL << VHOST_F_LOG_ALL) }; static inline int vhost_has_feature(struct vhost_dev *dev, int bit)
Re: [Qemu-devel] [PATCH 2/3] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Thu, 2013-03-28 at 00:28 +0200, Michael S. Tsirkin wrote: > On Wed, Mar 27, 2013 at 09:59:45PM +0000, Nicholas A. Bellinger wrote: > > From: Paolo Bonzini > > > > The WWPN specified in configfs is passed to "-device vhost-scsi-pci". > > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not > > available from the QEMU command-line. Instead, I hardcode it to zero. > > > > Changes in V4: > >- Set event_idx=off by default (nab, thanks asias) > > Why? What's going on here? > Not disabling event_idx by default, or disabling from the command line ends up resulting in ->handle_kick() not getting called for subsequent commands.. I spent some time trying to track this down recently with no luck, and AFAICT it's always been required in order for vhost-scsi to function. > >- Disable hotplug feature bit for v3.9 tcm_vhost kernel code, need to > > re-enable in v3.10 (nab) > > Userspace needs to support detecting host features > at runtime, based on dev->features. > In particular this applies to event_idx, but also hotplug. > See vhost_net_get_features. , will get this fixed up. > > >- Update to latest qemu.git/master HEAD > > > > Changes in V3: > >- Drop ioeventfd vhost_scsi_properties (asias, thanks stefanha) > >- Add CONFIG_VHOST_SCSI (asias, thanks stefanha) > >- Add hotplug feature bit > > > > Changes in V2: > >- Add backend guest masking support (nab) > >- Bump ABI_VERSION to 1 (nab) > >- Set up set_guest_notifiers (asias) > >- Set up vs->dev.vq_index (asias) > >- Drop vs->vs.vdev.{set,clear}_vhost_endpoint (asias) > >- Drop VIRTIO_CONFIG_S_DRIVER check in vhost_scsi_set_status (asias) > > > > Howto: > >Use the latest seabios, at least commit b44a7be17b > >git clone git://git.seabios.org/seabios.git > >make > >cp out/bios.bin /usr/share/qemu/bios.bin > >qemu -device vhost-scsi-pci,wwpn=naa.6001405bd4e8476d,event_idx=off > > ... > > > > Signed-off-by: Paolo Bonzini > > Signed-off-by: Asias He > > Cc: Michael S. Tsirkin > > Signed-off-by: Nicholas Bellinger > > --- > > configure | 15 +++- > > hw/Makefile.objs |5 +- > > hw/s390x/s390-virtio-bus.c | 35 +++ > > hw/vhost-scsi.c| 241 > > > > hw/vhost-scsi.h| 66 > > hw/virtio-pci.c| 62 +++ > > hw/virtio-scsi.h |2 + > > 7 files changed, 424 insertions(+), 2 deletions(-) > > create mode 100644 hw/vhost-scsi.c > > create mode 100644 hw/vhost-scsi.h > > > > diff --git a/hw/vhost-scsi.h b/hw/vhost-scsi.h > > new file mode 100644 > > index 000..b01f012 > > --- /dev/null > > +++ b/hw/vhost-scsi.h > > @@ -0,0 +1,66 @@ > > +/* > > + * vhost_scsi host device > > + * > > + * Copyright IBM, Corp. 2011 > > + * > > + * Authors: > > + * Stefan Hajnoczi > > + * > > + * This work is licensed under the terms of the GNU LGPL, version 2 or > > later. > > + * See the COPYING.LIB file in the top-level directory. > > + * > > + */ > > + > > +#ifndef VHOST_SCSI_H > > +#define VHOST_SCSI_H > > + > > +#include "qemu-common.h" > > +#include "qdev.h" > > +#include "virtio-scsi.h" > > + > > +/* > > + * Used by QEMU userspace to ensure a consistent vhost-scsi ABI. > > + * > > + * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate > > + > > + *RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage > > + * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct > > vhost_scsi_target. > > + * All the targets under vhost_wwpn can be seen and used by > > guest. > > + */ > > + > > +#define VHOST_SCSI_ABI_VERSION 1 > > + > > +/* TODO #include properly */ > > +/* For VHOST_SCSI_SET_ENDPOINT/VHOST_SCSI_CLEAR_ENDPOINT ioctl */ > > +struct vhost_scsi_target { > > +int abi_version; > > +char vhost_wwpn[224]; > > +unsigned short vhost_tpgt; > > +unsigned short reserved; > > +}; > > + > > +enum vhost_scsi_vq_list { > > +VHOST_SCSI_VQ_CONTROL = 0, > > +VHOST_SCSI_VQ_EVENT = 1, > > +VHOST_SCSI_VQ_NUM_FIXED = 2, > > +}; > > + > > +#define VHOST_VIRTIO 0xAF > > +#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO,
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Wed, 2013-03-27 at 23:56 +0200, Michael S. Tsirkin wrote: > On Wed, Mar 27, 2013 at 02:31:27PM -0700, Nicholas A. Bellinger wrote: > > On Wed, 2013-03-20 at 11:51 +0200, Michael S. Tsirkin wrote: > > > On Tue, Mar 19, 2013 at 06:57:08PM -0700, Nicholas A. Bellinger wrote: > > > > On Tue, 2013-03-19 at 09:40 +0100, Stefan Hajnoczi wrote: > > > > > On Tue, Mar 19, 2013 at 08:34:45AM +0800, Asias He wrote: > > > > > > --- > > > > > > hw/vhost.c | 2 ++ > > > > > > 1 file changed, 2 insertions(+) > > > > > > > > > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > > > > > index 4d6aee3..0c52ec4 100644 > > > > > > --- a/hw/vhost.c > > > > > > +++ b/hw/vhost.c > > > > > > @@ -421,10 +421,12 @@ static void vhost_set_memory(MemoryListener > > > > > > *listener, > > > > > > return; > > > > > > } > > > > > > > > > > > > +#if 0 > > > > > > if (dev->started) { > > > > > > r = vhost_verify_ring_mappings(dev, start_addr, size); > > > > > > assert(r >= 0); > > > > > > } > > > > > > +#endif > > > > > > > > > > Please add a comment to explain why. > > > > > > > > > > > > > Btw, the output that Asias added in the failure case at the behest of > > > > MST is here: > > > > > > > > http://www.spinics.net/lists/target-devel/msg04077.html > > > > > > Yes I suspected we could get l > ring_size, but this is > > > not the case here. > > > > > > > Hi MST & Co, > > > > A quick update here.. > > > > So this issue appears to be related to performing the > > vhost_verify_ring_mappings() call after vhost_dev_unassign_memory() has > > been invoked with vhost_set_memory(..., add=false). > > > > AFAICT from the logs below, things appear to work as expected when > > vhost_verify_ring_mappings() is called only for the > > vhost_set_memory(..., add=true) case. > > > > Calling vhost_verify_ring_mappings() when dev->started == true + > > vhost_set_memory(..., add=false) appears to be a bug caused by fallout > > from: > > > > commit 24f4fe345c1b80bab1ee18573914123d8028a9e6 > > Author: Michael S. Tsirkin > > Date: Tue Dec 25 17:41:07 2012 +0200 > > > > vhost: set started flag while start is in progress > > > > I'm including the following patch in the forth-coming vhost-scsi series. > > Please let me know if you have any concerns. > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > index 4d6aee3..687a689 100644 > > --- a/hw/vhost.c > > +++ b/hw/vhost.c > > @@ -421,7 +421,7 @@ static void vhost_set_memory(MemoryListener *listener, > > return; > > } > > > > -if (dev->started) { > > +if (dev->started && add) { > > r = vhost_verify_ring_mappings(dev, start_addr, size); > > assert(r >= 0); > > } > > > > Thanks! > > > > --nab > > Sorry NAK, > I think this will shut down too much stuff: > the main reason to check is when we delete a region. > > > vhost_set_memory: section: 0x7f2249986b60 section->size: 2146697216 add: 0 > > Before vhost_verify_ring_mappings: start_addr: c size: 2146697216 > > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 > > Checking vq: 2 ring_phys: ee000 ring_size: 5124 >>>>>>>>>>>>>>>>>>. > > Calling l: 5124 for start_addr: c for vq 2 > > Unable to map ring buffer for ring 2 > > l: 4096 ring_size: 5124 > > vhost_set_memory: section: 0x7f2249986aa0 section->size: 32768 add: 1 > > Before vhost_verify_ring_mappings: start_addr: c size: 32768 > > Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. > > Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 > > Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>
[Qemu-devel] [PATCH 1/3] virtio-scsi: create VirtIOSCSICommon
From: Paolo Bonzini This patch refactors existing virtio-scsi code into VirtIOSCSICommon in order to allow virtio_scsi_init_common() to be used by both internal virtio_scsi_init() and external vhost-scsi-pci code. Signed-off-by: Paolo Bonzini Cc: Michael S. Tsirkin Cc: Asias He Signed-off-by: Nicholas Bellinger --- hw/virtio-scsi.c | 190 +- hw/virtio-scsi.h | 130 +-- include/qemu/osdep.h |4 + 3 files changed, 177 insertions(+), 147 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 8620712..9dc7150 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -18,118 +18,6 @@ #include #include -#define VIRTIO_SCSI_VQ_SIZE 128 -#define VIRTIO_SCSI_CDB_SIZE32 -#define VIRTIO_SCSI_SENSE_SIZE 96 -#define VIRTIO_SCSI_MAX_CHANNEL 0 -#define VIRTIO_SCSI_MAX_TARGET 255 -#define VIRTIO_SCSI_MAX_LUN 16383 - -/* Response codes */ -#define VIRTIO_SCSI_S_OK 0 -#define VIRTIO_SCSI_S_OVERRUN 1 -#define VIRTIO_SCSI_S_ABORTED 2 -#define VIRTIO_SCSI_S_BAD_TARGET 3 -#define VIRTIO_SCSI_S_RESET4 -#define VIRTIO_SCSI_S_BUSY 5 -#define VIRTIO_SCSI_S_TRANSPORT_FAILURE6 -#define VIRTIO_SCSI_S_TARGET_FAILURE 7 -#define VIRTIO_SCSI_S_NEXUS_FAILURE8 -#define VIRTIO_SCSI_S_FAILURE 9 -#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10 -#define VIRTIO_SCSI_S_FUNCTION_REJECTED11 -#define VIRTIO_SCSI_S_INCORRECT_LUN12 - -/* Controlq type codes. */ -#define VIRTIO_SCSI_T_TMF 0 -#define VIRTIO_SCSI_T_AN_QUERY 1 -#define VIRTIO_SCSI_T_AN_SUBSCRIBE 2 - -/* Valid TMF subtypes. */ -#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0 -#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1 -#define VIRTIO_SCSI_T_TMF_CLEAR_ACA2 -#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3 -#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4 -#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5 -#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6 -#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7 - -/* Events. */ -#define VIRTIO_SCSI_T_EVENTS_MISSED0x8000 -#define VIRTIO_SCSI_T_NO_EVENT 0 -#define VIRTIO_SCSI_T_TRANSPORT_RESET 1 -#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 -#define VIRTIO_SCSI_T_PARAM_CHANGE 3 - -/* Reasons for transport reset event */ -#define VIRTIO_SCSI_EVT_RESET_HARD 0 -#define VIRTIO_SCSI_EVT_RESET_RESCAN 1 -#define VIRTIO_SCSI_EVT_RESET_REMOVED 2 - -/* SCSI command request, followed by data-out */ -typedef struct { -uint8_t lun[8]; /* Logical Unit Number */ -uint64_t tag;/* Command identifier */ -uint8_t task_attr; /* Task attribute */ -uint8_t prio; -uint8_t crn; -uint8_t cdb[]; -} QEMU_PACKED VirtIOSCSICmdReq; - -/* Response, followed by sense data and data-in */ -typedef struct { -uint32_t sense_len; /* Sense data length */ -uint32_t resid; /* Residual bytes in data buffer */ -uint16_t status_qualifier; /* Status qualifier */ -uint8_t status; /* Command completion status */ -uint8_t response;/* Response values */ -uint8_t sense[]; -} QEMU_PACKED VirtIOSCSICmdResp; - -/* Task Management Request */ -typedef struct { -uint32_t type; -uint32_t subtype; -uint8_t lun[8]; -uint64_t tag; -} QEMU_PACKED VirtIOSCSICtrlTMFReq; - -typedef struct { -uint8_t response; -} QEMU_PACKED VirtIOSCSICtrlTMFResp; - -/* Asynchronous notification query/subscription */ -typedef struct { -uint32_t type; -uint8_t lun[8]; -uint32_t event_requested; -} QEMU_PACKED VirtIOSCSICtrlANReq; - -typedef struct { -uint32_t event_actual; -uint8_t response; -} QEMU_PACKED VirtIOSCSICtrlANResp; - -typedef struct { -uint32_t event; -uint8_t lun[8]; -uint32_t reason; -} QEMU_PACKED VirtIOSCSIEvent; - -typedef struct { -uint32_t num_queues; -uint32_t seg_max; -uint32_t max_sectors; -uint32_t cmd_per_lun; -uint32_t event_info_size; -uint32_t sense_size; -uint32_t cdb_size; -uint16_t max_channel; -uint16_t max_target; -uint32_t max_lun; -} QEMU_PACKED VirtIOSCSIConfig; - typedef struct VirtIOSCSIReq { VirtIOSCSI *dev; VirtQueue *vq; @@ -178,7 +66,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req) scsi_req_unref(req->sreq); } g_free(req); -virtio_notify(&s->vdev, vq); +virtio_notify(&s->vs.vdev, vq); } static void virtio_scsi_bad_req(void) @@ -237,7 +125,7 @@ static void virtio_scsi_save_request(QEMUFile *f, SCSIRequest *sreq) VirtIOSCSIReq *req = sreq->hba_private; uint32_t n = virtio_queue_get_id(req->vq) - 2; -assert(n < req->dev->conf->num_queues
[Qemu-devel] [PATCH 3/3] vhost: Only call vhost_verify_ring_mappings when adding vhost memory
From: Nicholas Bellinger This patch fixes a bug where vhost_verify_ring_mappings() could be called after vhost_dev_unassign_memory() has been called during vhost_set_memory(..., add=false). This appears to be fallout from when dev->started = true assignment occurs before vhost_set_memory(..., add=false) is called in: commit 24f4fe345c1b80bab1ee18573914123d8028a9e6 Author: Michael S. Tsirkin Date: Tue Dec 25 17:41:07 2012 +0200 vhost: set started flag while start is in progress Cc: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/vhost.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 4d6aee3..687a689 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -421,7 +421,7 @@ static void vhost_set_memory(MemoryListener *listener, return; } -if (dev->started) { +if (dev->started && add) { r = vhost_verify_ring_mappings(dev, start_addr, size); assert(r >= 0); } -- 1.7.2.5
[Qemu-devel] [PATCH 2/3] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
From: Paolo Bonzini The WWPN specified in configfs is passed to "-device vhost-scsi-pci". The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not available from the QEMU command-line. Instead, I hardcode it to zero. Changes in V4: - Set event_idx=off by default (nab, thanks asias) - Disable hotplug feature bit for v3.9 tcm_vhost kernel code, need to re-enable in v3.10 (nab) - Update to latest qemu.git/master HEAD Changes in V3: - Drop ioeventfd vhost_scsi_properties (asias, thanks stefanha) - Add CONFIG_VHOST_SCSI (asias, thanks stefanha) - Add hotplug feature bit Changes in V2: - Add backend guest masking support (nab) - Bump ABI_VERSION to 1 (nab) - Set up set_guest_notifiers (asias) - Set up vs->dev.vq_index (asias) - Drop vs->vs.vdev.{set,clear}_vhost_endpoint (asias) - Drop VIRTIO_CONFIG_S_DRIVER check in vhost_scsi_set_status (asias) Howto: Use the latest seabios, at least commit b44a7be17b git clone git://git.seabios.org/seabios.git make cp out/bios.bin /usr/share/qemu/bios.bin qemu -device vhost-scsi-pci,wwpn=naa.6001405bd4e8476d,event_idx=off ... Signed-off-by: Paolo Bonzini Signed-off-by: Asias He Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- configure | 15 +++- hw/Makefile.objs |5 +- hw/s390x/s390-virtio-bus.c | 35 +++ hw/vhost-scsi.c| 241 hw/vhost-scsi.h| 66 hw/virtio-pci.c| 62 +++ hw/virtio-scsi.h |2 + 7 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h diff --git a/configure b/configure index f2af714..6b67e35 100755 --- a/configure +++ b/configure @@ -169,6 +169,7 @@ libattr="" xfs="" vhost_net="no" +vhost_scsi="no" kvm="no" gprof="no" debug_tcg="no" @@ -532,6 +533,7 @@ Haiku) usb="linux" kvm="yes" vhost_net="yes" + vhost_scsi="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi @@ -858,6 +860,10 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-vhost-scsi) vhost_scsi="no" + ;; + --enable-vhost-scsi) vhost_scsi="yes" + ;; --disable-glx) glx="no" ;; --enable-glx) glx="yes" @@ -3078,7 +3084,7 @@ fi # __sync_fetch_and_and requires at least -march=i486. Many toolchains # use i686 as default anyway, but for those that don't, an explicit # specification is necessary -if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then +if (test "$vhost_net" = "yes" -o "$vhost_scsi" = "yes") && test "$cpu" = "i386"; then cat > $TMPC << EOF static int sfaa(int *ptr) { @@ -3424,6 +3430,7 @@ echo "sigev_thread_id $sigev_thread_id" echo "uuid support $uuid" echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" +echo "vhost-scsi support $vhost_scsi" echo "Trace backend $trace_backend" echo "Trace output file $trace_file-" echo "spice support $spice ($spice_protocol_version/$spice_server_version)" @@ -3697,6 +3704,9 @@ fi if test "$virtfs" = "yes" ; then echo "CONFIG_VIRTFS=y" >> $config_host_mak fi +if test "$vhost_scsi" = "yes" ; then + echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak +fi if test "$blobs" = "yes" ; then echo "INSTALL_BLOBS=yes" >> $config_host_mak fi @@ -4175,6 +4185,9 @@ case "$target_arch2" in if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi + if test "$vhost_scsi" = "yes" ; then +echo "CONFIG_VHOST_SCSI=y" >> $config_target_mak + fi fi esac case "$target_arch2" in diff --git a/hw/Makefile.objs b/hw/Makefile.objs index d0b2ecb..0a38eb5 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -205,8 +205,11 @@ common-obj-$(CONFIG_XEN_BACKEND) += xen_console.o xenfb.o xen_disk.o xen_nic.o obj-$(CONFIG_VIRTIO) += dataplane/ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o virtio-balloon.o virtio-net.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o +ifeq ($(CONFIG_VIRTIO), y) +obj-$(CONFIG_LINUX) += vhost-scsi.o +endif obj-$(CONFIG_SOFTMMU) += vhost_net.o -obj-$(CONFIG_VHOST_NET) += vhost.o +obj-$(CONFIG_LINUX) += vhost.o obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ obj-$(CONFIG_VGA) += vga.o diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index c5d5456..73d93fd 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -28,6 +28,8 @@ #include "hw/virtio-rng.h" #include "hw/virtio-serial.h" #include "hw/virtio-net.h" +#include "hw/virtio-scsi.h" +#include "hw/vhost-scsi.h" #include "hw/sysbus.h" #include "sysemu/kvm.h" @@ -214,6 +216,18 @@ static int s390_virtio_scsi_init(VirtIOS390Device *dev) return s390_virtio_device_init(dev, vdev); } +static int s390_vhost_scsi_init(VirtIOS390Device *dev) +{ +VirtIODevice *vdev; + +vdev = vhost_sc
[Qemu-devel] [PATCH 0/3] Add support for vhost-scsi-pci
From: Nicholas Bellinger Hi QEMU folks, The following is the patch series to support vhost-scsi-pci within the upstream QEMU tree. This includes the refactoring of existing virtio-scsi code from Paolo to allow a VirtIOSCSICommon structure that is shared amoungst existing virtio-scsi-pci device and new vhost-scsi-pci device code. Currently this code requires Asias's seabios bugfixes (commit 5a7730db5 and b44a7be17), and another tcm_vhost patch to reset vq->last_used_idx after seabios handoff that's currently in flight for v3.9.0 kernel code. A big thanks to Paolo, Asias, MST, and Stefan for all of their efforts on this series. Thank you, --nab Nicholas Bellinger (1): vhost: Only call vhost_verify_ring_mappings when adding vhost memory Paolo Bonzini (2): virtio-scsi: create VirtIOSCSICommon vhost-scsi: new device supporting the tcm_vhost Linux kernel module configure | 15 +++- hw/Makefile.objs |5 +- hw/s390x/s390-virtio-bus.c | 35 +++ hw/vhost-scsi.c| 241 hw/vhost-scsi.h| 66 hw/vhost.c |2 +- hw/virtio-pci.c| 62 +++ hw/virtio-scsi.c | 190 +-- hw/virtio-scsi.h | 132 +++- include/qemu/osdep.h |4 + 10 files changed, 602 insertions(+), 150 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h -- 1.7.2.5
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Wed, 2013-03-20 at 11:51 +0200, Michael S. Tsirkin wrote: > On Tue, Mar 19, 2013 at 06:57:08PM -0700, Nicholas A. Bellinger wrote: > > On Tue, 2013-03-19 at 09:40 +0100, Stefan Hajnoczi wrote: > > > On Tue, Mar 19, 2013 at 08:34:45AM +0800, Asias He wrote: > > > > --- > > > > hw/vhost.c | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > > > index 4d6aee3..0c52ec4 100644 > > > > --- a/hw/vhost.c > > > > +++ b/hw/vhost.c > > > > @@ -421,10 +421,12 @@ static void vhost_set_memory(MemoryListener > > > > *listener, > > > > return; > > > > } > > > > > > > > +#if 0 > > > > if (dev->started) { > > > > r = vhost_verify_ring_mappings(dev, start_addr, size); > > > > assert(r >= 0); > > > > } > > > > +#endif > > > > > > Please add a comment to explain why. > > > > > > > Btw, the output that Asias added in the failure case at the behest of > > MST is here: > > > > http://www.spinics.net/lists/target-devel/msg04077.html > > Yes I suspected we could get l > ring_size, but this is > not the case here. > Hi MST & Co, A quick update here.. So this issue appears to be related to performing the vhost_verify_ring_mappings() call after vhost_dev_unassign_memory() has been invoked with vhost_set_memory(..., add=false). AFAICT from the logs below, things appear to work as expected when vhost_verify_ring_mappings() is called only for the vhost_set_memory(..., add=true) case. Calling vhost_verify_ring_mappings() when dev->started == true + vhost_set_memory(..., add=false) appears to be a bug caused by fallout from: commit 24f4fe345c1b80bab1ee18573914123d8028a9e6 Author: Michael S. Tsirkin Date: Tue Dec 25 17:41:07 2012 +0200 vhost: set started flag while start is in progress I'm including the following patch in the forth-coming vhost-scsi series. Please let me know if you have any concerns. diff --git a/hw/vhost.c b/hw/vhost.c index 4d6aee3..687a689 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -421,7 +421,7 @@ static void vhost_set_memory(MemoryListener *listener, return; } -if (dev->started) { +if (dev->started && add) { r = vhost_verify_ring_mappings(dev, start_addr, size); assert(r >= 0); } Thanks! --nab vhost_set_memory: section: 0x7f2249986b60 section->size: 2146697216 add: 0 Before vhost_verify_ring_mappings: start_addr: c size: 2146697216 Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 Checking vq: 2 ring_phys: ee000 ring_size: 5124 >>>>>>>>>>>>>>>>>>. Calling l: 5124 for start_addr: c for vq 2 Unable to map ring buffer for ring 2 l: 4096 ring_size: 5124 vhost_set_memory: section: 0x7f2249986aa0 section->size: 32768 add: 1 Before vhost_verify_ring_mappings: start_addr: c size: 32768 Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 Checking vq: 2 ring_phys: ee000 ring_size: 5124 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 2 ring_phys: ee000 ring_size: 5124 vhost_set_memory: section: 0x7f2249986aa0 section->size: 2146664448 add: 1 Before vhost_verify_ring_mappings: start_addr: c8000 size: 2146664448 Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 0 ring_phys: 0 ring_size: 1028 Checking vq: 1 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for vq: 1 ring_phys: 0 ring_size: 1028 Checking vq: 2 ring_phys: ee000 ring_size: 5124 >>>>>>>>>>>>>>>>>>. Calling l: 5124 for start_addr: c8000 for vq 2 vhost_set_memory: section: 0x7f2249986b60 section->size: 32768 add: 0 Before vhost_verify_ring_mappings: start_addr: c size: 32768 Checking vq: 0 ring_phys: 0 ring_size: 1028 >>>>>>>>>>>>>>>>>>. Got ranges_overlap for
Re: [Qemu-devel] [PATCH V3 WIP 3/3] disable vhost_verify_ring_mappings check
On Tue, 2013-03-19 at 09:40 +0100, Stefan Hajnoczi wrote: > On Tue, Mar 19, 2013 at 08:34:45AM +0800, Asias He wrote: > > --- > > hw/vhost.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/hw/vhost.c b/hw/vhost.c > > index 4d6aee3..0c52ec4 100644 > > --- a/hw/vhost.c > > +++ b/hw/vhost.c > > @@ -421,10 +421,12 @@ static void vhost_set_memory(MemoryListener *listener, > > return; > > } > > > > +#if 0 > > if (dev->started) { > > r = vhost_verify_ring_mappings(dev, start_addr, size); > > assert(r >= 0); > > } > > +#endif > > Please add a comment to explain why. > Btw, the output that Asias added in the failure case at the behest of MST is here: http://www.spinics.net/lists/target-devel/msg04077.html MST seemed to think it may be a bug in cpu_physical_memory_map, but as this worked with the original vhost-scsi code it would seem to indicate something else at fault.. I'll be comparing what the original code did vs. vhost-scsi-pci to track this down, but any extra ideas to track is down is appreciated. ;) --nab
Re: [Qemu-devel] [PATCH 0/2] Fix booting tcm_vhost + seabios
On Fri, 2013-03-15 at 09:45 +0800, Asias He wrote: > Asias He (2): > virtio-scsi: Set _DRIVER_OK flag before scsi target scanning > virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd} > > src/virtio-scsi.c | 5 +++-- > src/virtio-scsi.h | 4 ++-- > 2 files changed, 5 insertions(+), 4 deletions(-) > Hi Asias, Thanks for taking the initiative on this, and nice work tracking both of these stubborn bugs down. So with these out of the way, we're good to go for an RFC of Paolo's vhost-scsi-pci code for upstream QEMU, yes..? I'll have some extra bandwidth this week to spend time on the RFC if you'd like, otherwise I'm happy with you making the upstream QEMU push for Paolo's code. Whatever works best for you. :) Thank you, --nab
Re: [Qemu-devel] [PATCH WIP 0/4] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
Hi Paolo, On Thu, 2013-01-31 at 00:12 -0800, Nicholas A. Bellinger wrote: > Hi Paolo, > > On Wed, 2013-01-30 at 17:41 +0100, Paolo Bonzini wrote: > > As expected, using a separate device finds a snag: vhost-scsi is passing > > force=false to vhost_dev_init, and the BIOS does not use MSI-X so it > > will actually use the non-vhost implementation which is wrong. I fixed > > this by passing force=true; I'm not sure what that would break, but I > > figured "not much" since the BIOS polls and does not rely on interrupts. > > > > That makes vhost start, but it still doesn't work for me with a 3.7.2 > > kernel on the host. Even Nick's patches hang the guest as soon as vhost > > starts, and I get the same behavior with mine. > > After bisection this evening, the change that ended up breaking > vhost-scsi is vhost backend guest notifier masking support patch in > commit f56a12475. > > After adding the two new notifiers in vhost-scsi/virtio-scsi following > in qemu.git/virtio-scsi-nab code, the tcm_vhost LUN scan is functioning > again.. > > > (Of course with my > > patches the BIOS hangs and you never reach Linux; but try a BIOS without > > virtio-scsi support, and you'll see Linux hanging in the same way). > > > > Here is my configuration: > > > > cd /sys/kernel/config/target > > mkdir -p core/fileio_0/fileio > > echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' > > > core/fileio_0/fileio/control > > echo 1 > core/fileio_0/fileio/enable > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0 > > cd vhost/naa.600140554cf3a18e/tpgt_0 > > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port > > echo naa.60014053226f0388 > nexus > > > > Nick's patches are run with "-vhost-scsi > > id=vs,tpgt=0,wwpn=naa.600140554cf3a18e > > -device virtio-scsi-pci,vhost-scsi=vs". Perhaps I'm doing something wrong. > > So after adding the same vhost backend guest notifiers to the new > VirtIOSCSICommon vhost-scsi code, I'm now hitting an QEMU invalid > option: > > ./x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m 2048 -serial > file:/tmp/vhost-serial.txt > -hda /usr/src/qemu-vhost.git/debian_squeeze_amd64_standard-old.qcow2 > -vhost-scsi id=vs,tpgt=0,wwpn=naa.600140579ad21088 -device > virtio-scsi-pci,vhost-scsi=vs > qemu-system-x86_64: -vhost-scsi: invalid option > > Debugging this now.. > Ok, so after using the correct -vhost-scsi-pci opts with thew new code (thanks btw :), I'm also running into a SeaBIOS hang at boot: Starting program: /usr/src/qemu-paolo.git/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m 2048 -serial file:/tmp/vhost-serial.txt -hda /usr/src/qemu-vhost.git/debian_squeeze_amd64_standard-old.qcow2 -device vhost-scsi-pci,wwpn=naa.600140579ad21088 [Thread debugging using libthread_db enabled] [New Thread 0x743a1700 (LWP 13079)] [New Thread 0x7399f700 (LWP 13080)] [New Thread 0x7319e700 (LWP 13081)] [New Thread 0x7299d700 (LWP 13082)] [New Thread 0x7219c700 (LWP 13083)] [Thread 0x743a1700 (LWP 13079) exited] ^C Program received signal SIGINT, Interrupt. 0x75cca8d3 in select () from /lib/libc.so.6 (gdb) bt #0 0x75cca8d3 in select () from /lib/libc.so.6 #1 0x005050e5 in os_host_main_loop_wait (nonblocking=) at main-loop.c:230 #2 main_loop_wait (nonblocking=) at main-loop.c:416 #3 0x0056a8ec in main_loop (argc=, argv=, envp=) at vl.c:1951 #4 main (argc=, argv=, envp=) at vl.c:4224 (gdb) and a quick look with strace: ioctl(15, KVM_SET_LAPIC, 0x7fffca93f6e0) = 0 ioctl(15, KVM_SET_PIT2 or KVM_SET_VCPU_EVENTS, 0x7fffca93f6e0) = 0 ioctl(15, 0x4080aea2, 0x7fffca93f6e0) = 0 write(4, "\1\0\0\0\0\0\0\0", 8) = 8 write(4, "\1\0\0\0\0\0\0\0", 8) = 8 ioctl(7, KVM_CHECK_EXTENSION, 0x4c) = 1 ioctl(12, 0xaead, 0)= -1 EINVAL (Invalid argument) futex(0x1469ce4, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0xe54e20, 4) = 1 tgkill(13107, 13109, SIGUSR1) = 0 futex(0x1460114, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0xe54e20, 4) = 1 tgkill(13107, 13110, SIGUSR1) = 0 futex(0x14613b4, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0xe54e20, 4) = 1 tgkill(13107, 13111, SIGUSR1) = 0 futex(0x1454e84, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0xe54e20, 4) = 1 tgkill(13107, 13112, SIGUSR1) = 0 select(10, [3 4 5 9], [], [], {0, 0}) = 2 (in [3 4], left {0, 0}) read(4, "\2\0\0\0\0\0\0\0", 512)= 8 read(3, "\16\0\0\0\0\0\0\0\376\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 128) = 128 rt_sigaction(SIGALRM, NULL, {0x52b810, ~[KILL S
Re: [Qemu-devel] [PATCH WIP 0/4] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
On Thu, 2013-01-31 at 13:12 +0200, Michael S. Tsirkin wrote: > On Wed, Jan 30, 2013 at 05:41:22PM +0100, Paolo Bonzini wrote: > > Another small bug I found is an ordering problem between > > VHOST_SET_VRING_KICK and VHOST_SCSI_SET_ENDPOINT. Starting the vq > > causes a "vhost_scsi_handle_vq endpoint not set" error in dmesg. > > Because of this I added the first two patches, which let me do > > VHOST_SCSI_SET_ENDPOINT before VHOST_SET_VRING_KICK but after setting > > up the vring. > > > > Unfortunately, this is not enough to fix the hang. And anyway, it's > > probably simpler to avoid the two patches and remove this test from the > > tcm_vhost.c vhost_scsi_set/clear_endpoint functions: > > > > mutex_lock(&vs->dev.mutex); > > /* Verify that ring has been setup correctly. */ > > for (index = 0; index < vs->dev.nvqs; ++index) { > > /* Verify that ring has been setup correctly. */ > > if (!vhost_vq_access_ok(&vs->vqs[index])) { > > mutex_unlock(&vs->dev.mutex); > > return -EFAULT; > > } > > } > > mutex_unlock(&vs->dev.mutex); > > Well userspace should initialize the kick eventfd to 0, > it seems to init it to 1 which is why we get the error. > But I think the only issue is pr_err: vhost-net already > ignores such a kick with no backend. So let's just > remove it, preferably for 3.8. > That's fine with me. Applying to target-pending/master, and will include in the next PULL request for v3.8.0. Thanks, --nab > ---> > tcm_vhost: fix pr_err on early kick > > It's OK to get kick before backend is set or after > it is cleared, we can just ignore it. > > Signed-off-by: Michael S. Tsirkin > > --- > > diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c > index b20df5c..22321cf 100644 > --- a/drivers/vhost/tcm_vhost.c > +++ b/drivers/vhost/tcm_vhost.c > @@ -575,10 +575,8 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs) > > /* Must use ioctl VHOST_SCSI_SET_ENDPOINT */ > tv_tpg = vs->vs_tpg; > - if (unlikely(!tv_tpg)) { > - pr_err("%s endpoint not set\n", __func__); > + if (unlikely(!tv_tpg)) > return; > - } > > mutex_lock(&vq->mutex); > vhost_disable_notify(&vs->dev, vq);
Re: [Qemu-devel] [PATCH WIP 0/4] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
Hi Paolo, On Wed, 2013-01-30 at 17:41 +0100, Paolo Bonzini wrote: > Ok, so here is my attempt at a vhost-scsi device. I'm creating an > entirely separate device, with the common parts of virtio-scsi and > vhost-scsi (actually little more than the initialization) grouped into > a VirtIOSCSICommon type. The device is used simply like "-device > vhost-scsi-pci,wwpn=WWPN", with all configuration done in configfs > beforehand. > Cool. :) > As expected, using a separate device finds a snag: vhost-scsi is passing > force=false to vhost_dev_init, and the BIOS does not use MSI-X so it > will actually use the non-vhost implementation which is wrong. I fixed > this by passing force=true; I'm not sure what that would break, but I > figured "not much" since the BIOS polls and does not rely on interrupts. > > That makes vhost start, but it still doesn't work for me with a 3.7.2 > kernel on the host. Even Nick's patches hang the guest as soon as vhost > starts, and I get the same behavior with mine. After bisection this evening, the change that ended up breaking vhost-scsi is vhost backend guest notifier masking support patch in commit f56a12475. After adding the two new notifiers in vhost-scsi/virtio-scsi following in qemu.git/virtio-scsi-nab code, the tcm_vhost LUN scan is functioning again.. > (Of course with my > patches the BIOS hangs and you never reach Linux; but try a BIOS without > virtio-scsi support, and you'll see Linux hanging in the same way). > > Here is my configuration: > > cd /sys/kernel/config/target > mkdir -p core/fileio_0/fileio > echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' > > core/fileio_0/fileio/control > echo 1 > core/fileio_0/fileio/enable > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0 > cd vhost/naa.600140554cf3a18e/tpgt_0 > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port > echo naa.60014053226f0388 > nexus > > Nick's patches are run with "-vhost-scsi > id=vs,tpgt=0,wwpn=naa.600140554cf3a18e > -device virtio-scsi-pci,vhost-scsi=vs". Perhaps I'm doing something wrong. So after adding the same vhost backend guest notifiers to the new VirtIOSCSICommon vhost-scsi code, I'm now hitting an QEMU invalid option: ./x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m 2048 -serial file:/tmp/vhost-serial.txt -hda /usr/src/qemu-vhost.git/debian_squeeze_amd64_standard-old.qcow2 -vhost-scsi id=vs,tpgt=0,wwpn=naa.600140579ad21088 -device virtio-scsi-pci,vhost-scsi=vs qemu-system-x86_64: -vhost-scsi: invalid option Debugging this now.. > > Another small bug I found is an ordering problem between > VHOST_SET_VRING_KICK and VHOST_SCSI_SET_ENDPOINT. Starting the vq > causes a "vhost_scsi_handle_vq endpoint not set" error in dmesg. > Because of this I added the first two patches, which let me do > VHOST_SCSI_SET_ENDPOINT before VHOST_SET_VRING_KICK but after setting > up the vring. > > Unfortunately, this is not enough to fix the hang. And anyway, it's > probably simpler to avoid the two patches and remove this test from the > tcm_vhost.c vhost_scsi_set/clear_endpoint functions: > > mutex_lock(&vs->dev.mutex); > /* Verify that ring has been setup correctly. */ > for (index = 0; index < vs->dev.nvqs; ++index) { > /* Verify that ring has been setup correctly. */ > if (!vhost_vq_access_ok(&vs->vqs[index])) { > mutex_unlock(&vs->dev.mutex); > return -EFAULT; > } > } > mutex_unlock(&vs->dev.mutex); > > This way, VHOST_SCSI_SET_ENDPOINT can simply be invoked right after > vhost_dev_init, and likewise VHOST_SCSI_CLEAR_ENDPOINT in vhost_scsi_exit. > , Ok, I'll generate a patch for this soon. > I placed both sets of patches on two branches (vhost-scsi-nab and > vhost-scsi) of my github repo at git://github.com/bonzini/qemu.git. > One thing I haven't done due to lack of time is applying Nick's patches > to a tree from last September. If it works, we can bisect. But this is > pretty much all the time I can devote to vhost-scsi. Nick/Asias, if > you want to pick it up please do. > Thanks Paolo! --nab > Paolo > > Paolo Bonzini (4): > vhost: do VHOST_SET_VRING_KICK after setting up all vrings > vhost: add set_vhost_endpoint and clear_vhost_endpoint callbacks > virtio-scsi: create VirtIOSCSICommon > vhost-scsi: new device supporting the tcm_vhost Linux kernel module > > hw/Makefile.objs | 5 +- > hw/s390-virtio-bus.c | 35 + > hw/vhost-scsi.c | 188 > hw/vhost-scsi.h | 62 > hw/vhost.c | 75 --- > hw/virtio-pci.c | 59 +++ > hw/virtio-scsi.c | 199 > +-- > hw/virtio-scsi.h | 129 + > hw/virtio.h | 2 + > include/qemu/osdep.h | 4 ++ > 1
Re: [Qemu-devel] [PATCH 0/5] vhost-scsi: Add support for host virtualized target
On Tue, 2013-01-29 at 16:03 -0500, Paolo Bonzini wrote: > > Also, I'm not exactly sure what's involved with a vhost=on/off > > frontend > > option discussed above, so if you or Paolo could handle this bit it > > would be very helpful. > > I can do the forward port, if you take care of testing we have > enough time to make it into 1.4. > Perfect, thanks for the extra help here. ;) I'll look for your forward-port of vhost-scsi, and test as soon as it's available. --nab
Re: [Qemu-devel] [PATCH 0/5] vhost-scsi: Add support for host virtualized target
Hi MST, Paolo & Co, On Mon, 2013-01-28 at 15:39 +0200, Michael S. Tsirkin wrote: > On Mon, Jan 28, 2013 at 02:33:44PM +0100, Paolo Bonzini wrote: > > Il 28/01/2013 14:36, Michael S. Tsirkin ha scritto: > > > On Mon, Jan 28, 2013 at 02:29:23PM +0100, Paolo Bonzini wrote: > > >> Il 28/01/2013 14:11, Michael S. Tsirkin ha scritto: > > I asked for a standalone device because the configuration mechanism > > (configfs vs. command-line) and the feature set are completely > > different. Unlike virtio-net, it's not possible to switch one to the > > other at run time. > > >>> > > >>> Exactly the same applies to any other frontend option. > > >>> For example if you have two qemu instances with > > >>> different num_queues values you can not migrate one > > >>> to the other. > > >>> So in this sense it is not different from any other > > >>> frontend option, right? > > >> > > >> Indeed, in this sense it is not. > > >> > > >> Actually in this case migrating one to the other could succeed, and make > > >> all disks disappear on the destination (because of the different > > >> configuration mechanism). That however could be overcome with vhost=on > > >> registering a migration blocker. > > > > > > Or better add a subsection if vhost is set: vhost=on to vhost=on > > > can migrate, right? > > > > I think it's not yet supported by the kernel. You have no guarantee > > that I/O is quiescent at the time the VM starts on the destination. > > You'd need a ioctl to do the equivalent of bdrv_drain_all(). > > > > Once you have that, a subsection would do the job, yes. > > > > Paolo > > OK once that's in it would be easy to probe for. > > > >> I won't really block the patch with the vhost=on/off frontend option if > > >> it is properly done (e.g. the QEMU SCSI bus should not be created for > > >> vhost=on) and minimally invasive to the non-vhost code. > > >> So what's the verdict here..? Shall I respin the vhost-scsi patches against qemu.git HEAD to make it in before Friday's cutoff for v1.4..? Also, I'm not exactly sure what's involved with a vhost=on/off frontend option discussed above, so if you or Paolo could handle this bit it would be very helpful. :) --nab
Re: [Qemu-devel] [PATCH 0/5] vhost-scsi: Add support for host virtualized target
Hi MST & Co, On Thu, 2013-01-17 at 18:43 +0200, Michael S. Tsirkin wrote: > On Fri, Sep 07, 2012 at 06:48:14AM +, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > Hello Anthony & Co, > > > > This is the fourth installment to add host virtualized target support for > > the mainline tcm_vhost fabric driver using Linux v3.6-rc into QEMU 1.3.0-rc. > > > > The series is available directly from the following git branch: > > > >git://git.kernel.org/pub/scm/virt/kvm/nab/qemu-kvm.git vhost-scsi-for-1.3 > > > > Note the code is cut against yesterday's QEMU head, and dispite the name > > of the tree is based upon mainline qemu.org git code + has thus far been > > running overnight with > 100K IOPs small block 4k workloads using v3.6-rc2+ > > based target code with RAMDISK_DR backstores. > > > > Other than some minor fuzz between jumping from QEMU 1.2.0 -> 1.2.50, this > > series is functionally identical to what's been posted for vhost-scsi RFC-v3 > > to qemu-devel. > > > > Please consider applying these patches for an initial vhost-scsi merge into > > QEMU 1.3.0-rc code, or let us know what else you'd like to see addressed for > > this series to in order to merge. > > > > Thank you! > > > > --nab > > OK what's the status here? > We missed 1.3 but let's try not to miss 1.4? > Unfortunately, I've not been able to get back to the conversion requested by Paolo for a standalone vhost-scsi PCI device. At this point my hands are still full with iSER-target for-3.9 kernel code over the next weeks. What's the v1.4 feature cut-off looking like at this point..? --nab
Re: [Qemu-devel] [PATCH 4/5] virtio-scsi: Add start/stop functionality for vhost-scsi
On Tue, 2012-09-11 at 18:07 +0300, Michael S. Tsirkin wrote: > On Tue, Sep 11, 2012 at 08:46:34AM -0500, Anthony Liguori wrote: > > On 09/10/2012 01:24 AM, Michael S. Tsirkin wrote: > > >On Mon, Sep 10, 2012 at 08:16:54AM +0200, Paolo Bonzini wrote: > > >>Il 09/09/2012 00:40, Michael S. Tsirkin ha scritto: > > >>>On Fri, Sep 07, 2012 at 06:00:50PM +0200, Paolo Bonzini wrote: > > Please create a completely separate device vhost-scsi-pci instead (or > > virtio-scsi-tcm-pci, or something like that). It is used completely > > differently from virtio-scsi-pci, it does not make sense to conflate the > > two. > > >>> > > >>>Ideally the name would say how it is different, not what backend it > > >>>uses. Any good suggestions? > > >> > > >>I chose the backend name because, ideally, there would be no other > > >>difference. QEMU _could_ implement all the goodies in vhost-scsi (such > > >>as reservations or ALUA), it just doesn't do that yet. > > >> > > >>Paolo > > > > > >Then why do you say "It is used completely differently from > > >virtio-scsi-pci"? Isn't it just a different backend? > > > > > >If yes then it should be a backend option, like it is > > >for virtio-net. > > > > I don't mean to bike shed here so don't take this as a nack on > > making it a backend option, but in retrospect, the way we did > > vhost-net was a mistake even though I strongly advocated for it to > > be a backend option. > > > > The code to do it is really, really ugly. I think it would have > > made a lot more sense to just make it a device and then have it not > > use a netdev backend or any other kind of backend split. > > > > For instance: > > > > qemu -device vhost-net-pci,tapfd=X > > > > I know this breaks the model of separate backends and frontends but > > since vhost-net absolutely requires a tap fd, I think it's better in > > the long run to not abuse the netdev backend to prevent user > > confusion. Having a dedicated backend type that only has one > > possible option and can only be used by one device is a bit silly > > too. > > > > So I would be in favor of dropping/squashing 3/5 and radically > > simplifying how this was exposed to the user. > > > > I would just take qemu_vhost_scsi_opts and make them device properties. > > > > Regards, > > > > Anthony Liguori > > I'd like to clarify that I'm fine with either approach. > Even a separate device is OK if this is what others want > though I like it the least. > Hi MST, Paolo & Co, I've been out the better part of the week with the flu, and am just now catching up on emails from the last days.. So to better understand the reasoning for adding an separate PCI device for vhost-scsi ahead of implementing the code changes, here are main points from folk's comments: *) Convert vhost-scsi into a separate standalone vhost-scsi-pci device - Lets userspace know that virtio-scsi + QEMU block and virtio-scsi + tcm_vhost do not track SCSI state (such as reservations + ALUA), and hence are not interchangeable during live-migration. - Reduces complexity of adding vhost-scsi related logic into existing virtio-scsi-pci code path. - Having backends with one possible option doesn’t make much sense. *) Keep vhost-scsi as a backend to virtio-scsi-pci - Reduces duplicated code amongst multiple virtio-scsi backends. - Follows the split for what existing vhost-net code already does. So that said, two quick questions for Paolo & Co.. For the standalone vhost-scsi-pci device case, can you give a brief idea as to what extent you'd like to see virtio-scsi.c code/defs duplicated and/or shared amongst a new vhost-scsi-pci device..? Also to help me along, can you give an example based on the current usage below how the QEMU command line arguments would change with a standalone vhost-scsi-pci device..? ./x86_64-softmmu/qemu-system-x86_64 -enable-kvm -smp 4 -m 2048 \ -hda /usr/src/qemu-vhost.git/debian_squeeze_amd64_standard-old.qcow2 \ -vhost-scsi id=vhost-scsi0,wwpn=naa.600140579ad21088,tpgt=1 \ -device virtio-scsi-pci,vhost-scsi=vhost-scsi0,event_idx=off Thank you! --nab
Re: [Qemu-devel] [PATCH 0/5] vhost-scsi: Add support for host virtualized target
On Tue, 2012-09-11 at 12:36 +0800, Asias He wrote: > Hello Nicholas, > Hello Asias! > On 09/07/2012 02:48 PM, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > Hello Anthony & Co, > > > > This is the fourth installment to add host virtualized target support for > > the mainline tcm_vhost fabric driver using Linux v3.6-rc into QEMU 1.3.0-rc. > > > > The series is available directly from the following git branch: > > > >git://git.kernel.org/pub/scm/virt/kvm/nab/qemu-kvm.git vhost-scsi-for-1.3 > > > > Note the code is cut against yesterday's QEMU head, and dispite the name > > of the tree is based upon mainline qemu.org git code + has thus far been > > running overnight with > 100K IOPs small block 4k workloads using v3.6-rc2+ > > based target code with RAMDISK_DR backstores. > > Are you still seeing the performance degradation discussed in the thread > > "vhost-scsi port to v1.1.0 + MSI-X performance regression" > So the performance regression reported here with QEMU v1.2-rc + virtio-scsi ended up being related to virtio interrupts being delivered across multiple CPUs. After explicitly setting the IRQ affinity of the virtio0-request MSI-X vector to a specific CPU, the small block (4k) mixed random I/O performance jumped back up to the expected ~100K IOPs for a single LUN. FYI, I just tried this again with the most recent QEMU v1.2.50 (v1.3-rc) code, and both cases appear to be performing as expected once again regardless of the explicit IRQ affinity setting. --nab
Re: [Qemu-devel] [PATCH 4/5] virtio-scsi: Add start/stop functionality for vhost-scsi
On Fri, 2012-09-07 at 18:00 +0200, Paolo Bonzini wrote: > Il 07/09/2012 08:48, Nicholas A. Bellinger ha scritto: > > Cc: Stefan Hajnoczi > > Cc: Zhi Yong Wu > > Cc: Michael S. Tsirkin > > Cc: Paolo Bonzini > > Signed-off-by: Nicholas Bellinger > > --- > > hw/virtio-pci.c |2 ++ > > hw/virtio-scsi.c | 49 + > > hw/virtio-scsi.h |1 + > > 3 files changed, 52 insertions(+), 0 deletions(-) > > Please create a completely separate device vhost-scsi-pci instead (or > virtio-scsi-tcm-pci, or something like that). It is used completely > differently from virtio-scsi-pci, it does not make sense to conflate the > two. > Ok, I need to figure out what this will involve over the next days, and will likely have some more questions for you to get a standlone vhost-scsi-pci up and running. Also just curious (question for Anthony + QEMU folks), how long can we expect the QEMU 1.3 merge window to be open..? Thanks Paolo! --nab
[Qemu-devel] [PATCH 5/5] virtio-scsi: Set max_target=0 during vhost-scsi operation
From: Nicholas Bellinger This QEMU patch sets VirtIOSCSIConfig->max_target=0 for vhost-scsi operation to restrict virtio-scsi LLD guest scanning to max_id=0 (a single target ID instance) when connected to individual tcm_vhost endpoints. This ensures that virtio-scsi LLD only attempts to scan target IDs up to VIRTIO_SCSI_MAX_TARGET when connected via virtio-scsi-raw. Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-scsi.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index edda097..ab5ca72 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -546,7 +546,11 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, stl_raw(&scsiconf->sense_size, s->sense_size); stl_raw(&scsiconf->cdb_size, s->cdb_size); stl_raw(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL); -stl_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); +if (s->vhost_scsi) { +stl_raw(&scsiconf->max_target, 0); +} else { +stl_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); +} stl_raw(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN); } -- 1.7.2.5
[Qemu-devel] [PATCH 2/5] vhost: Pass device path to vhost_dev_init()
From: Stefan Hajnoczi The path to /dev/vhost-net is currently hardcoded in vhost_dev_init(). This needs to be changed so that /dev/vhost-scsi can be used. Pass in the device path instead of hardcoding it. Signed-off-by: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- hw/vhost.c |5 +++-- hw/vhost.h |3 ++- hw/vhost_net.c |2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 0fd8da8..d0ce5aa 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -747,14 +747,15 @@ static void vhost_eventfd_del(MemoryListener *listener, { } -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force) +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force) { uint64_t features; int r; if (devfd >= 0) { hdev->control = devfd; } else { -hdev->control = open("/dev/vhost-net", O_RDWR); +hdev->control = open(devpath, O_RDWR); if (hdev->control < 0) { return -errno; } diff --git a/hw/vhost.h b/hw/vhost.h index 80e64df..0c47229 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -44,7 +44,8 @@ struct vhost_dev { bool force; }; -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force); +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force); void vhost_dev_cleanup(struct vhost_dev *hdev); bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); diff --git a/hw/vhost_net.c b/hw/vhost_net.c index ecaa22d..df2c4a3 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -109,7 +109,7 @@ struct vhost_net *vhost_net_init(NetClientState *backend, int devfd, (1 << VHOST_NET_F_VIRTIO_NET_HDR); net->backend = r; -r = vhost_dev_init(&net->dev, devfd, force); +r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force); if (r < 0) { goto fail; } -- 1.7.2.5
[Qemu-devel] [PATCH 3/5] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
From: Stefan Hajnoczi This patch adds a new type of host device that drives the vhost_scsi device. The syntax to add vhost-scsi is: qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123 The virtio-scsi emulated device will make use of vhost-scsi to process virtio-scsi requests inside the kernel and hand them to the in-kernel SCSI target stack using the tcm_vhost fabric driver. The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2, and the commit can be found here: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297 Changelog v2 -> v3: - Move qdev_prop_vhost_scsi + DEFINE_PROP_VHOST_SCSI defs into vhost-scsi.[c,h] (reported by MST) - Add enum vhost_scsi_vq_list for VHostSCSI->vqs[] enumeration (reported by MST) - Add missing braces around single like if statement to following QEMU style (reported by Blue Swirl) - Change vhost_scsi_target->vhost_wwpn to char *, in order to drop casts to pstrcpy in vhost_scsi_start() + vhost_scsi_stop() (reported by Blue Swirl) - Change VHOST_SCSI_GET_ABI_VERSION to 'int' type (MST) - Fix 4 byte alignment of vhost_scsi_target (MST) - Convert fprintf(stderr, ...) usage to -> error_report() (reported by MST) - Do explict memset of backend before calling VHOST_SCSI_CLEAR_ENDPOINT in vhost_scsi_stop() (reported by MST) - Add support for vhostfd passing in vhost_scsi_add() (reported by MST) - Change vhost_scsi_add() to use monitor_handle_fd_param() (reported by MST) Changelog v1 -> v2: - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as starting point for v3.6-rc code (Stefan + ALiguori + nab) - Fix upstream qemu conflict in hw/qdev-properties.c - Make GET_ABI_VERSION use int (nab + mst) - Fix vhost-scsi case lables in configure (reported by paolo) - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following qdev_prop_netdev (reported by paolo) - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) Changelog v0 -> v1: - Add VHOST_SCSI_SET_ENDPOINT call (stefan) - Enable vhost notifiers for multiple queues (Zhi) - clear vhost-scsi endpoint on stopped (Zhi) - Add CONFIG_VHOST_SCSI for QEMU build configure (nab) - Rename vhost_vring_target -> vhost_scsi_target (mst + nab) - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab) Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Anthony Liguori Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- configure| 10 +++ hw/Makefile.objs |1 + hw/qdev-properties.c | 41 +++ hw/vhost-scsi.c | 190 ++ hw/vhost-scsi.h | 62 qemu-common.h|1 + qemu-config.c| 19 + qemu-options.hx |4 + vl.c | 18 + 9 files changed, 346 insertions(+), 0 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h diff --git a/configure b/configure index f0dbc03..1f03202 100755 --- a/configure +++ b/configure @@ -168,6 +168,7 @@ libattr="" xfs="" vhost_net="no" +vhost_scsi="no" kvm="no" gprof="no" debug_tcg="no" @@ -513,6 +514,7 @@ Haiku) usb="linux" kvm="yes" vhost_net="yes" + vhost_scsi="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi @@ -818,6 +820,10 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-vhost-scsi) vhost_scsi="no" + ;; + --enable-vhost-scsi) vhost_scsi="yes" + ;; --disable-opengl) opengl="no" ;; --enable-opengl) opengl="yes" @@ -3116,6 +3122,7 @@ echo "posix_madvise $posix_madvise" echo "uuid support $uuid" echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" +echo "vhost-scsi support $vhost_scsi" echo "Trace backend $trace_backend" echo "Trace output file $trace_file-" echo "spice support $spice" @@ -3828,6 +3835,9 @@ case "$target_arch2" in if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi + if test "$vhost_scsi" = "yes" ; then +echo "CONFIG_VHOST_SCSI=y" >> $config_target_mak + fi fi esac case "$target_arch2" in diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 3ba5dd0..6ab75ec 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o virtio-balloon.o virtio-net.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o obj-$(CONFIG_SOFTMMU) += vhost_net.o obj-$(CONFIG_VHOST_NET) += vhost.o +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ obj-$(CONFIG_NO_PCI) += pci-stub.o obj-$(CONFIG_VGA) += vga.o diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 8aca0d4..8b505ca 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -4,6 +4,7 @@ #include "blockdev.h" #include "hw/block-common.h" #include "net/hub.h" +#include "vhost-s
[Qemu-devel] [PATCH 1/5] monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param
From: Nicholas Bellinger This patch renames+moves the net_handle_fd_param() caller used to obtain a file descriptor from either qemu_parse_fd() (the normal case) or from monitor_get_fd() (migration case) into a generically prefixed monitor_handle_fd_param() to be used by vhost-scsi code. Also update net/[socket,tap].c consumers to use the new prefix. Reported-by: Michael S. Tsirkin Cc: Michael S. Tsirkin Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Anthony Liguori Signed-off-by: Nicholas Bellinger --- monitor.c| 18 ++ monitor.h|1 + net.c| 18 -- net.h|2 -- net/socket.c |2 +- net/tap.c|4 ++-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/monitor.c b/monitor.c index 49dccfe..0641efe 100644 --- a/monitor.c +++ b/monitor.c @@ -2389,6 +2389,24 @@ int monitor_get_fd(Monitor *mon, const char *fdname) return -1; } +int monitor_handle_fd_param(Monitor *mon, const char *fdname) +{ +int fd; + +if (!qemu_isdigit(fdname[0]) && mon) { + +fd = monitor_get_fd(mon, fdname); +if (fd == -1) { +error_report("No file descriptor named %s found", fdname); +return -1; +} +} else { +fd = qemu_parse_fd(fdname); +} + +return fd; +} + /* mon_cmds and info_cmds would be sorted at runtime */ static mon_cmd_t mon_cmds[] = { #include "hmp-commands.h" diff --git a/monitor.h b/monitor.h index 5f4de1b..d557e97 100644 --- a/monitor.h +++ b/monitor.h @@ -65,6 +65,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, void *opaque); int monitor_get_fd(Monitor *mon, const char *fdname); +int monitor_handle_fd_param(Monitor *mon, const char *fdname); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); diff --git a/net.c b/net.c index 60043dd..e5d25d4 100644 --- a/net.c +++ b/net.c @@ -522,24 +522,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, return -1; } -int net_handle_fd_param(Monitor *mon, const char *param) -{ -int fd; - -if (!qemu_isdigit(param[0]) && mon) { - -fd = monitor_get_fd(mon, param); -if (fd == -1) { -error_report("No file descriptor named %s found", param); -return -1; -} -} else { -fd = qemu_parse_fd(param); -} - -return fd; -} - static int net_init_nic(const NetClientOptions *opts, const char *name, NetClientState *peer) { diff --git a/net.h b/net.h index 2975056..04fda1d 100644 --- a/net.h +++ b/net.h @@ -168,8 +168,6 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret); void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); -int net_handle_fd_param(Monitor *mon, const char *param); - #define POLYNOMIAL 0x04c11db6 unsigned compute_mcast_idx(const uint8_t *ep); diff --git a/net/socket.c b/net/socket.c index c172c24..7c602e4 100644 --- a/net/socket.c +++ b/net/socket.c @@ -629,7 +629,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, if (sock->has_fd) { int fd; -fd = net_handle_fd_param(cur_mon, sock->fd); +fd = monitor_handle_fd_param(cur_mon, sock->fd); if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) { return -1; } diff --git a/net/tap.c b/net/tap.c index 1971525..a88ae8f 100644 --- a/net/tap.c +++ b/net/tap.c @@ -610,7 +610,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } -fd = net_handle_fd_param(cur_mon, tap->fd); +fd = monitor_handle_fd_param(cur_mon, tap->fd); if (fd == -1) { return -1; } @@ -686,7 +686,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, int vhostfd; if (tap->has_vhostfd) { -vhostfd = net_handle_fd_param(cur_mon, tap->vhostfd); +vhostfd = monitor_handle_fd_param(cur_mon, tap->vhostfd); if (vhostfd == -1) { return -1; } -- 1.7.2.5
[Qemu-devel] [PATCH 4/5] virtio-scsi: Add start/stop functionality for vhost-scsi
From: Stefan Hajnoczi This patch starts and stops vhost as the virtio device transitions through its status phases. Vhost can only be started once the guest reports its driver has successfully initialized, which means the virtqueues have been set up by the guest. v3: - Add vhost-scsi.h include for DEFINE_PROP_VHOST_SCSI (mst + nab) - Move vhost-scsi related struct members ahead of *cmd_vqs[0] within VirtIOSCSI definition. (paolo + nab) v2: - Squash virtio-scsi: use the vhost-scsi host device from stefan (nab) - Fix up virtio_scsi_properties[] conflict w/ upstream qemu (nab) - Drop usage of to_virtio_scsi() in virtio_scsi_set_status() (reported by paolo) - Use modern VirtIOSCSIConf define in virtio-scsi.h (reported by paolo) - Use s->conf->vhost_scsi instead of proxyconf->vhost_scsi in virtio_scsi_init() (reported by paolo) - Only register QEMU SCSI bus is vhost-scsi is not active (reported by paolo) Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-pci.c |2 ++ hw/virtio-scsi.c | 49 + hw/virtio-scsi.h |1 + 3 files changed, 52 insertions(+), 0 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 125eded..8ec7cf1 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -22,6 +22,7 @@ #include "virtio-net.h" #include "virtio-serial.h" #include "virtio-scsi.h" +#include "vhost-scsi.h" #include "pci.h" #include "qemu-error.h" #include "msi.h" @@ -1036,6 +1037,7 @@ static void virtio_scsi_exit_pci(PCIDevice *pci_dev) } static Property virtio_scsi_properties[] = { +DEFINE_PROP_VHOST_SCSI("vhost-scsi", VirtIOPCIProxy, scsi.vhost_scsi), DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOPCIProxy, host_features, scsi), diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 5f737ac..edda097 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -13,9 +13,13 @@ * */ +#include "qemu-common.h" +#include "qemu-error.h" +#include "vhost-scsi.h" #include "virtio-scsi.h" #include #include +#include "vhost.h" #define VIRTIO_SCSI_VQ_SIZE 128 #define VIRTIO_SCSI_CDB_SIZE32 @@ -144,6 +148,10 @@ typedef struct { uint32_t cdb_size; int resetting; bool events_dropped; + +bool vhost_started; +VHostSCSI *vhost_scsi; + VirtQueue *ctrl_vq; VirtQueue *event_vq; VirtQueue *cmd_vqs[0]; @@ -699,6 +707,38 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = { .load_request = virtio_scsi_load_request, }; +static bool virtio_scsi_started(VirtIOSCSI *s, uint8_t val) +{ +return (val & VIRTIO_CONFIG_S_DRIVER_OK) && s->vdev.vm_running; +} + +static void virtio_scsi_set_status(VirtIODevice *vdev, uint8_t val) +{ +VirtIOSCSI *s = (VirtIOSCSI *)vdev; +bool start = virtio_scsi_started(s, val); + +if (s->vhost_started == start) { +return; +} + +if (start) { +int ret; + +ret = vhost_scsi_start(s->vhost_scsi, vdev); +if (ret < 0) { +error_report("virtio-scsi: unable to start vhost: %s\n", + strerror(-ret)); + +/* There is no userspace virtio-scsi fallback so exit */ +exit(1); +} +} else { +vhost_scsi_stop(s->vhost_scsi, vdev); +} + +s->vhost_started = start; +} + VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) { VirtIOSCSI *s; @@ -712,12 +752,17 @@ VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) s->qdev = dev; s->conf = proxyconf; +s->vhost_started = false; +s->vhost_scsi = s->conf->vhost_scsi; /* TODO set up vdev function pointers */ s->vdev.get_config = virtio_scsi_get_config; s->vdev.set_config = virtio_scsi_set_config; s->vdev.get_features = virtio_scsi_get_features; s->vdev.reset = virtio_scsi_reset; +if (s->vhost_scsi) { +s->vdev.set_status = virtio_scsi_set_status; +} s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_ctrl); @@ -743,5 +788,9 @@ void virtio_scsi_exit(VirtIODevice *vdev) { VirtIOSCSI *s = (VirtIOSCSI *)vdev; unregister_savevm(s->qdev, "virtio-scsi", s); + +/* This will stop vhost backend if appropriate. */ +virtio_scsi_set_status(vdev, 0); + virtio_cleanup(vdev); } diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h index 4bc889d..74e9422 100644 --- a/hw/virtio-scsi.h +++ b/hw/virtio-scsi.h @@ -22,6 +22,7 @@ #define VIRTIO_SCSI_F_CHANGE 2 struct VirtIOSCSIConf { +VHostSCSI *vhost_scsi; uint32_t num_queues; uint32_t max_sectors; uint32_t cmd_per_lun; -- 1.7.2.5
Re: [Qemu-devel] [RFC-v3 0/5] vhost-scsi: Add support for host virtualized target
On Fri, 2012-09-07 at 09:37 +0300, Michael S. Tsirkin wrote: > On Fri, Sep 07, 2012 at 09:32:37AM +0300, Michael S. Tsirkin wrote: > > On Fri, Sep 07, 2012 at 09:23:22AM +0300, Michael S. Tsirkin wrote: > > > On Tue, Aug 21, 2012 at 08:52:06PM +, Nicholas A. Bellinger wrote: > > > > From: Nicholas Bellinger > > > > > > > > Hi folks, > > > > > > > > This is the third RFC for vhost-scsi patches against mainline QEMU v1.1 > > > > > > I rebased on top of 1.2 and put this in my tree: > > > git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git pci > > > > > > Please check it out, meanwhile we'll see if anyone complains. > > > > OK I will be the first :). > > Looks like build *without* CONFIG_VHOST_SCSI > > is broken now: > > LINK sparc64-softmmu/qemu-system-sparc64 > > ../hw/qdev-properties.o: In function `parse_vhost_scsi_dev': > > /scm/qemu/hw/qdev-properties.c:706: undefined reference to > > `find_vhost_scsi' > > ../hw/qdev-properties.o: In function `print_vhost_scsi_dev': > > /scm/qemu/hw/qdev-properties.c:719: undefined reference to > > `vhost_scsi_get_id' > > ../libhw64/vl.o: In function `vhost_scsi_init_func': > > /scm/qemu/vl.c:1943: undefined reference to `vhost_scsi_add_opts' > > hw/virtio-scsi.o: In function `virtio_scsi_set_status': > > /scm/qemu/hw/virtio-scsi.c:733: undefined reference to `vhost_scsi_stop' > > /scm/qemu/hw/virtio-scsi.c:724: undefined reference to > > `vhost_scsi_start' > > > > Please add stubs *and test* without CONFIG_VHOST_SCSI. > > > > While at it can we please rename file to vhost_scsi.c, vhost_scsi.h? > > qemu is inconsistent but vhost files all use _ as separator: > > this means function names and file names are in sync. > > > > Reverted for now, waiting for v4. > > Please note vhost, net and monitor changes are all merged. > That's patches 1/5 and 2/5. Hi MST! Looks like we just cross emails here within 10 mins here.. I'm happy to respin a PATCH and/or GIT PULL request minus 1-2 depending on the vhost-scsi workflow that ALiguori is comfortable with here. Thank you! --nab
[Qemu-devel] [PATCH 0/5] vhost-scsi: Add support for host virtualized target
From: Nicholas Bellinger Hello Anthony & Co, This is the fourth installment to add host virtualized target support for the mainline tcm_vhost fabric driver using Linux v3.6-rc into QEMU 1.3.0-rc. The series is available directly from the following git branch: git://git.kernel.org/pub/scm/virt/kvm/nab/qemu-kvm.git vhost-scsi-for-1.3 Note the code is cut against yesterday's QEMU head, and dispite the name of the tree is based upon mainline qemu.org git code + has thus far been running overnight with > 100K IOPs small block 4k workloads using v3.6-rc2+ based target code with RAMDISK_DR backstores. Other than some minor fuzz between jumping from QEMU 1.2.0 -> 1.2.50, this series is functionally identical to what's been posted for vhost-scsi RFC-v3 to qemu-devel. Please consider applying these patches for an initial vhost-scsi merge into QEMU 1.3.0-rc code, or let us know what else you'd like to see addressed for this series to in order to merge. Thank you! --nab Nicholas Bellinger (2): monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param virtio-scsi: Set max_target=0 during vhost-scsi operation Stefan Hajnoczi (3): vhost: Pass device path to vhost_dev_init() vhost-scsi: add -vhost-scsi host device for use with tcm-vhost virtio-scsi: Add start/stop functionality for vhost-scsi configure| 10 +++ hw/Makefile.objs |1 + hw/qdev-properties.c | 41 +++ hw/vhost-scsi.c | 190 ++ hw/vhost-scsi.h | 62 hw/vhost.c |5 +- hw/vhost.h |3 +- hw/vhost_net.c |2 +- hw/virtio-pci.c |2 + hw/virtio-scsi.c | 55 ++- hw/virtio-scsi.h |1 + monitor.c| 18 + monitor.h|1 + net.c| 18 - net.h|2 - net/socket.c |2 +- net/tap.c|4 +- qemu-common.h|1 + qemu-config.c| 19 + qemu-options.hx |4 + vl.c | 18 + 21 files changed, 431 insertions(+), 28 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h -- 1.7.2.5
Re: [Qemu-devel] [PATCH 1/2 v1] blkdrv: Add queue limits parameters for sg block drive
On Thu, 2012-08-23 at 11:08 +0100, Stefan Hajnoczi wrote: > On Thu, Aug 23, 2012 at 11:03 AM, Paolo Bonzini wrote: > > Il 23/08/2012 11:31, Cong Meng ha scritto: > >>> For disks, this should be fixed simply by using scsi-block instead of > >>> scsi-generic. > >>> > >>> CD-ROMs are indeed more complicated because burning CDs cannot be done > >>> with syscalls. :/ > >> > >> So, as the problem exist to CD-ROM, I will continue to get these patches > >> move on. > > > > I'm still trying to understand the extent of the problem. > > > > The problem occurs for _USB_ CD-ROMs according to Ben. Passthrough of > > USB storage devices should be done via USB passthrough, not virtio-scsi. > > If we do USB passthrough via the SCSI layer we miss on all the quirks > > that the OS may do based on the USB product/vendor pairs. There's no > > end to these, and some of the quirks may cause the device to lock up or > > corruption. > > > > I'd rather see a reproducer using SAS/ATA/ATAPI disks before punting. > > This issue affects passthrough: either an entire sg device or at least > a SG_IO ioctl (e.g. a non-READ/WRITE SCSI command). > > To reproduce it, check host queue limits and guest virtio-scsi queue > limits. Then pick a command that can exceed the limits and try it > from inside the guest :). > Just following along on this thread, and wanted to add a few of my experiences with this scenario from the kernel target perspective.. So up until very recently, TCM would accept an I/O request for an DATA I/O type CDB with a max_sectors larger than the reported max_sectors for it's TCM backend (regardless of backend type), and silently generate N backend 'tasks' to complete the single initiator generated command. Also FYI for Paolo, for control type CDBs I've never actually seen an allocation length exceed max_sectors, so in practice AFAIK this only happens for DATA I/O type CDBs. This was historically required by the pSCSI backend driver (using a number of old SCSI passthrough interfaces) in order to support this very type of case described above, but over the years the logic ended up creeping into various other non-passthrough backend drivers like IBLOCK +FILEIO. So for v3.6-rc1 code, hch ended up removing the 'task' logic thus allowing backends (and the layers below) to the I/O sectors > max_sectors handling work, allowing modern pSCSI using struct request to do the same. (hch assured me this works now for pSCSI) Anyways, I think having the guest limit virtio-scsi DATA I/O to max_sectors based upon the host accessible block limits is reasonable approach to consider. Reducing this value even further based upon the lowest max_sectors available amongst possible migration hosts would be a good idea here to avoid having to reject any I/O's exceeding a new host's device block queue limits. --nab
[Qemu-devel] [RFC-v3 4/5] virtio-scsi: Add start/stop functionality for vhost-scsi
From: Stefan Hajnoczi This patch starts and stops vhost as the virtio device transitions through its status phases. Vhost can only be started once the guest reports its driver has successfully initialized, which means the virtqueues have been set up by the guest. v3: - Add vhost-scsi.h include for DEFINE_PROP_VHOST_SCSI (mst + nab) - Move vhost-scsi related struct members ahead of *cmd_vqs[0] within VirtIOSCSI definition. (paolo + nab) v2: - Squash virtio-scsi: use the vhost-scsi host device from stefan (nab) - Fix up virtio_scsi_properties[] conflict w/ upstream qemu (nab) - Drop usage of to_virtio_scsi() in virtio_scsi_set_status() (reported by paolo) - Use modern VirtIOSCSIConf define in virtio-scsi.h (reported by paolo) - Use s->conf->vhost_scsi instead of proxyconf->vhost_scsi in virtio_scsi_init() (reported by paolo) - Only register QEMU SCSI bus is vhost-scsi is not active (reported by paolo) Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-pci.c |2 ++ hw/virtio-scsi.c | 49 + hw/virtio-scsi.h |1 + 3 files changed, 52 insertions(+), 0 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 125eded..8ec7cf1 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -22,6 +22,7 @@ #include "virtio-net.h" #include "virtio-serial.h" #include "virtio-scsi.h" +#include "vhost-scsi.h" #include "pci.h" #include "qemu-error.h" #include "msi.h" @@ -1036,6 +1037,7 @@ static void virtio_scsi_exit_pci(PCIDevice *pci_dev) } static Property virtio_scsi_properties[] = { +DEFINE_PROP_VHOST_SCSI("vhost-scsi", VirtIOPCIProxy, scsi.vhost_scsi), DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOPCIProxy, host_features, scsi), diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 5f737ac..edda097 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -13,9 +13,13 @@ * */ +#include "qemu-common.h" +#include "qemu-error.h" +#include "vhost-scsi.h" #include "virtio-scsi.h" #include #include +#include "vhost.h" #define VIRTIO_SCSI_VQ_SIZE 128 #define VIRTIO_SCSI_CDB_SIZE32 @@ -144,6 +148,10 @@ typedef struct { uint32_t cdb_size; int resetting; bool events_dropped; + +bool vhost_started; +VHostSCSI *vhost_scsi; + VirtQueue *ctrl_vq; VirtQueue *event_vq; VirtQueue *cmd_vqs[0]; @@ -699,6 +707,38 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = { .load_request = virtio_scsi_load_request, }; +static bool virtio_scsi_started(VirtIOSCSI *s, uint8_t val) +{ +return (val & VIRTIO_CONFIG_S_DRIVER_OK) && s->vdev.vm_running; +} + +static void virtio_scsi_set_status(VirtIODevice *vdev, uint8_t val) +{ +VirtIOSCSI *s = (VirtIOSCSI *)vdev; +bool start = virtio_scsi_started(s, val); + +if (s->vhost_started == start) { +return; +} + +if (start) { +int ret; + +ret = vhost_scsi_start(s->vhost_scsi, vdev); +if (ret < 0) { +error_report("virtio-scsi: unable to start vhost: %s\n", + strerror(-ret)); + +/* There is no userspace virtio-scsi fallback so exit */ +exit(1); +} +} else { +vhost_scsi_stop(s->vhost_scsi, vdev); +} + +s->vhost_started = start; +} + VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) { VirtIOSCSI *s; @@ -712,12 +752,17 @@ VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) s->qdev = dev; s->conf = proxyconf; +s->vhost_started = false; +s->vhost_scsi = s->conf->vhost_scsi; /* TODO set up vdev function pointers */ s->vdev.get_config = virtio_scsi_get_config; s->vdev.set_config = virtio_scsi_set_config; s->vdev.get_features = virtio_scsi_get_features; s->vdev.reset = virtio_scsi_reset; +if (s->vhost_scsi) { +s->vdev.set_status = virtio_scsi_set_status; +} s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_ctrl); @@ -743,5 +788,9 @@ void virtio_scsi_exit(VirtIODevice *vdev) { VirtIOSCSI *s = (VirtIOSCSI *)vdev; unregister_savevm(s->qdev, "virtio-scsi", s); + +/* This will stop vhost backend if appropriate. */ +virtio_scsi_set_status(vdev, 0); + virtio_cleanup(vdev); } diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h index 4bc889d..74e9422 100644 --- a/hw/virtio-scsi.h +++ b/hw/virtio-scsi.h @@ -22,6 +22,7 @@ #define VIRTIO_ID_SCSI 8 struct VirtIOSCSIConf { +VHostSCSI *vhost_scsi; uint32_t num_queues; uint32_t max_sectors; uint32_t cmd_per_lun; -- 1.7.2.5
[Qemu-devel] [RFC-v3 5/5] virtio-scsi: Set max_target=0 during vhost-scsi operation
From: Nicholas Bellinger This QEMU patch sets VirtIOSCSIConfig->max_target=0 for vhost-scsi operation to restrict virtio-scsi LLD guest scanning to max_id=0 (a single target ID instance) when connected to individual tcm_vhost endpoints. This ensures that virtio-scsi LLD only attempts to scan target IDs up to VIRTIO_SCSI_MAX_TARGET when connected via virtio-scsi-raw. Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-scsi.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index edda097..ab5ca72 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -546,7 +546,11 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, stl_raw(&scsiconf->sense_size, s->sense_size); stl_raw(&scsiconf->cdb_size, s->cdb_size); stl_raw(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL); -stl_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); +if (s->vhost_scsi) { +stl_raw(&scsiconf->max_target, 0); +} else { +stl_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); +} stl_raw(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN); } -- 1.7.2.5
[Qemu-devel] [RFC-v3 2/5] vhost: Pass device path to vhost_dev_init()
From: Stefan Hajnoczi The path to /dev/vhost-net is currently hardcoded in vhost_dev_init(). This needs to be changed so that /dev/vhost-scsi can be used. Pass in the device path instead of hardcoding it. Signed-off-by: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- hw/vhost.c |5 +++-- hw/vhost.h |3 ++- hw/vhost_net.c |2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 0fd8da8..d0ce5aa 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -747,14 +747,15 @@ static void vhost_eventfd_del(MemoryListener *listener, { } -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force) +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force) { uint64_t features; int r; if (devfd >= 0) { hdev->control = devfd; } else { -hdev->control = open("/dev/vhost-net", O_RDWR); +hdev->control = open(devpath, O_RDWR); if (hdev->control < 0) { return -errno; } diff --git a/hw/vhost.h b/hw/vhost.h index 80e64df..0c47229 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -44,7 +44,8 @@ struct vhost_dev { bool force; }; -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force); +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force); void vhost_dev_cleanup(struct vhost_dev *hdev); bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); diff --git a/hw/vhost_net.c b/hw/vhost_net.c index ecaa22d..df2c4a3 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -109,7 +109,7 @@ struct vhost_net *vhost_net_init(NetClientState *backend, int devfd, (1 << VHOST_NET_F_VIRTIO_NET_HDR); net->backend = r; -r = vhost_dev_init(&net->dev, devfd, force); +r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force); if (r < 0) { goto fail; } -- 1.7.2.5
[Qemu-devel] [RFC-v3 3/5] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
From: Stefan Hajnoczi This patch adds a new type of host device that drives the vhost_scsi device. The syntax to add vhost-scsi is: qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123 The virtio-scsi emulated device will make use of vhost-scsi to process virtio-scsi requests inside the kernel and hand them to the in-kernel SCSI target stack using the tcm_vhost fabric driver. The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2, and the commit can be found here: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297 Changelog v2 -> v3: - Move qdev_prop_vhost_scsi + DEFINE_PROP_VHOST_SCSI defs into vhost-scsi.[c,h] (reported by MST) - Add enum vhost_scsi_vq_list for VHostSCSI->vqs[] enumeration (reported by MST) - Add missing braces around single like if statement to following QEMU style (reported by Blue Swirl) - Change vhost_scsi_target->vhost_wwpn to char *, in order to drop casts to pstrcpy in vhost_scsi_start() + vhost_scsi_stop() (reported by Blue Swirl) - Change VHOST_SCSI_GET_ABI_VERSION to 'int' type (MST) - Fix 4 byte alignment of vhost_scsi_target (MST) - Convert fprintf(stderr, ...) usage to -> error_report() (reported by MST) - Do explict memset of backend before calling VHOST_SCSI_CLEAR_ENDPOINT in vhost_scsi_stop() (reported by MST) - Add support for vhostfd passing in vhost_scsi_add() (reported by MST) - Change vhost_scsi_add() to use monitor_handle_fd_param() (reported by MST) Changelog v1 -> v2: - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as starting point for v3.6-rc code (Stefan + ALiguori + nab) - Fix upstream qemu conflict in hw/qdev-properties.c - Make GET_ABI_VERSION use int (nab + mst) - Fix vhost-scsi case lables in configure (reported by paolo) - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following qdev_prop_netdev (reported by paolo) - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) Changelog v0 -> v1: - Add VHOST_SCSI_SET_ENDPOINT call (stefan) - Enable vhost notifiers for multiple queues (Zhi) - clear vhost-scsi endpoint on stopped (Zhi) - Add CONFIG_VHOST_SCSI for QEMU build configure (nab) - Rename vhost_vring_target -> vhost_scsi_target (mst + nab) - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab) Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Anthony Liguori Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- configure| 10 +++ hw/Makefile.objs |1 + hw/qdev-properties.c | 41 +++ hw/vhost-scsi.c | 190 ++ hw/vhost-scsi.h | 62 qemu-common.h|1 + qemu-config.c| 19 + qemu-options.hx |4 + vl.c | 18 + 9 files changed, 346 insertions(+), 0 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h diff --git a/configure b/configure index f0dbc03..1f03202 100755 --- a/configure +++ b/configure @@ -168,6 +168,7 @@ libattr="" xfs="" vhost_net="no" +vhost_scsi="no" kvm="no" gprof="no" debug_tcg="no" @@ -513,6 +514,7 @@ Haiku) usb="linux" kvm="yes" vhost_net="yes" + vhost_scsi="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi @@ -818,6 +820,10 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-vhost-scsi) vhost_scsi="no" + ;; + --enable-vhost-scsi) vhost_scsi="yes" + ;; --disable-opengl) opengl="no" ;; --enable-opengl) opengl="yes" @@ -3116,6 +3122,7 @@ echo "posix_madvise $posix_madvise" echo "uuid support $uuid" echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" +echo "vhost-scsi support $vhost_scsi" echo "Trace backend $trace_backend" echo "Trace output file $trace_file-" echo "spice support $spice" @@ -3828,6 +3835,9 @@ case "$target_arch2" in if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi + if test "$vhost_scsi" = "yes" ; then +echo "CONFIG_VHOST_SCSI=y" >> $config_target_mak + fi fi esac case "$target_arch2" in diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 3ba5dd0..6ab75ec 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o virtio-balloon.o virtio-net.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o obj-$(CONFIG_SOFTMMU) += vhost_net.o obj-$(CONFIG_VHOST_NET) += vhost.o +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ obj-$(CONFIG_NO_PCI) += pci-stub.o obj-$(CONFIG_VGA) += vga.o diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 8aca0d4..8b505ca 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -4,6 +4,7 @@ #include "blockdev.h" #include "hw/block-common.h" #include "net/hub.h" +#include "vhost-s
[Qemu-devel] [RFC-v3 1/5] monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param
From: Nicholas Bellinger This patch renames+moves the net_handle_fd_param() caller used to obtain a file descriptor from either qemu_parse_fd() (the normal case) or from monitor_get_fd() (migration case) into a generically prefixed monitor_handle_fd_param() to be used by vhost-scsi code. Also update net/[socket,tap].c consumers to use the new prefix. Reported-by: Michael S. Tsirkin Cc: Michael S. Tsirkin Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Anthony Liguori Signed-off-by: Nicholas Bellinger --- monitor.c| 18 ++ monitor.h|1 + net.c| 18 -- net.h|2 -- net/socket.c |2 +- net/tap.c|4 ++-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/monitor.c b/monitor.c index 49dccfe..0641efe 100644 --- a/monitor.c +++ b/monitor.c @@ -2389,6 +2389,24 @@ int monitor_get_fd(Monitor *mon, const char *fdname) return -1; } +int monitor_handle_fd_param(Monitor *mon, const char *fdname) +{ +int fd; + +if (!qemu_isdigit(fdname[0]) && mon) { + +fd = monitor_get_fd(mon, fdname); +if (fd == -1) { +error_report("No file descriptor named %s found", fdname); +return -1; +} +} else { +fd = qemu_parse_fd(fdname); +} + +return fd; +} + /* mon_cmds and info_cmds would be sorted at runtime */ static mon_cmd_t mon_cmds[] = { #include "hmp-commands.h" diff --git a/monitor.h b/monitor.h index 5f4de1b..d557e97 100644 --- a/monitor.h +++ b/monitor.h @@ -65,6 +65,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, void *opaque); int monitor_get_fd(Monitor *mon, const char *fdname); +int monitor_handle_fd_param(Monitor *mon, const char *fdname); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); diff --git a/net.c b/net.c index 60043dd..e5d25d4 100644 --- a/net.c +++ b/net.c @@ -522,24 +522,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, return -1; } -int net_handle_fd_param(Monitor *mon, const char *param) -{ -int fd; - -if (!qemu_isdigit(param[0]) && mon) { - -fd = monitor_get_fd(mon, param); -if (fd == -1) { -error_report("No file descriptor named %s found", param); -return -1; -} -} else { -fd = qemu_parse_fd(param); -} - -return fd; -} - static int net_init_nic(const NetClientOptions *opts, const char *name, NetClientState *peer) { diff --git a/net.h b/net.h index 2975056..04fda1d 100644 --- a/net.h +++ b/net.h @@ -168,8 +168,6 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret); void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); -int net_handle_fd_param(Monitor *mon, const char *param); - #define POLYNOMIAL 0x04c11db6 unsigned compute_mcast_idx(const uint8_t *ep); diff --git a/net/socket.c b/net/socket.c index c172c24..7c602e4 100644 --- a/net/socket.c +++ b/net/socket.c @@ -629,7 +629,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, if (sock->has_fd) { int fd; -fd = net_handle_fd_param(cur_mon, sock->fd); +fd = monitor_handle_fd_param(cur_mon, sock->fd); if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) { return -1; } diff --git a/net/tap.c b/net/tap.c index 1971525..a88ae8f 100644 --- a/net/tap.c +++ b/net/tap.c @@ -610,7 +610,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } -fd = net_handle_fd_param(cur_mon, tap->fd); +fd = monitor_handle_fd_param(cur_mon, tap->fd); if (fd == -1) { return -1; } @@ -686,7 +686,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, int vhostfd; if (tap->has_vhostfd) { -vhostfd = net_handle_fd_param(cur_mon, tap->vhostfd); +vhostfd = monitor_handle_fd_param(cur_mon, tap->vhostfd); if (vhostfd == -1) { return -1; } -- 1.7.2.5
[Qemu-devel] [RFC-v3 0/5] vhost-scsi: Add support for host virtualized target
From: Nicholas Bellinger Hi folks, This is the third RFC for vhost-scsi patches against mainline QEMU v1.1 to support the upstream tcm_vhost host virtualized target driver now available in v3.6-rc kernel code. This series is based upon last week's commit 346fe0c4c0b, and is aiming for a future QEMU v1.3 merge. The patch series is available directly from: git://git.kernel.org/pub/scm/virt/kvm/nab/qemu-kvm.git vhost-scsi-merge-v3 This -v3 series contains further review changes based upon feedback from MST, Paolo, and Blue. It also contains the changes to function against the changes in target-pending/master -> headed for v3.6-rc3 code. Changes from v3 -> v2: - Move qdev_prop_vhost_scsi + DEFINE_PROP_VHOST_SCSI defs into vhost-scsi.[c,h] (reported by MST) - Add enum vhost_scsi_vq_list for VHostSCSI->vqs[] enumeration (reported by MST) - Add missing braces around single like if statement to following QEMU style (reported by Blue Swirl) - Change vhost_scsi_target->vhost_wwpn to char *, in order to drop casts to pstrcpy in vhost_scsi_start() + vhost_scsi_stop() (reported by Blue Swirl) - Change VHOST_SCSI_GET_ABI_VERSION to 'int' type (MST) - Add vhost-scsi.h include for DEFINE_PROP_VHOST_SCSI (mst + nab) - Move vhost-scsi related struct members ahead of *cmd_vqs[0] within VirtIOSCSI definition. (paolo + nab) - Fix 4 byte alignment of vhost_scsi_target (MST) - Convert fprintf(stderr, ...) usage to -> error_report() (reported by MST) - Do explict memset of backend before calling VHOST_SCSI_CLEAR_ENDPOINT in vhost_scsi_stop() (reported by MST) - Add support for vhostfd passing in vhost_scsi_add() (reported by MST) - Move net_handle_fd_param() -> monitor_handle_fd_param() for generic usage by net/ + vhost-scsi (reported by MST) - Change vhost_scsi_add() to use monitor_handle_fd_param() (reported by MST) Changes from v1 -> v2: - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as starting point for v3.6-rc code (Stefan + ALiguori + nab) - Fix upstream qemu conflict in hw/qdev-properties.c - Make GET_ABI_VERSION use int (nab + mst) - Drop unnecessary event-notifier changes (nab) - Fix vhost-scsi case lables in configure (reported by paolo) - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following qdev_prop_netdev (reported by paolo) - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) - Squash virtio-scsi: use the vhost-scsi host device from stefan (nab) - Fix up virtio_scsi_properties[] conflict w/ upstream qemu (nab) - Drop usage of to_virtio_scsi() in virtio_scsi_set_status() (reported by paolo) - Use modern VirtIOSCSIConf define in virtio-scsi.h (reported by paolo) - Use s->conf->vhost_scsi instead of proxyconf->vhost_scsi in virtio_scsi_init() (reported by paolo) - Only register QEMU SCSI bus is vhost-scsi is not active (reported by paolo) - Fix incorrect VirtIOSCSI->cmd_vqs[0] definition (nab) Thanks again to everyone who has been reviewing this series! --nab Nicholas Bellinger (2): monitor: Rename+move net_handle_fd_param -> monitor_handle_fd_param virtio-scsi: Set max_target=0 during vhost-scsi operation Stefan Hajnoczi (3): vhost: Pass device path to vhost_dev_init() vhost-scsi: add -vhost-scsi host device for use with tcm-vhost virtio-scsi: Add start/stop functionality for vhost-scsi configure| 10 +++ hw/Makefile.objs |1 + hw/qdev-properties.c | 41 +++ hw/vhost-scsi.c | 190 ++ hw/vhost-scsi.h | 62 hw/vhost.c |5 +- hw/vhost.h |3 +- hw/vhost_net.c |2 +- hw/virtio-pci.c |2 + hw/virtio-scsi.c | 55 ++- hw/virtio-scsi.h |1 + monitor.c| 18 + monitor.h|1 + net.c| 18 - net.h|2 - net/socket.c |2 +- net/tap.c|4 +- qemu-common.h|1 + qemu-config.c| 19 + qemu-options.hx |4 + vl.c | 18 + 21 files changed, 431 insertions(+), 28 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h -- 1.7.2.5
Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
On Sun, 2012-08-19 at 11:44 +0300, Michael S. Tsirkin wrote: > On Sat, Aug 18, 2012 at 05:36:26PM -0700, Nicholas A. Bellinger wrote: > > On Sat, 2012-08-18 at 22:12 +0300, Michael S. Tsirkin wrote: > > > On Tue, Aug 14, 2012 at 01:31:14PM -0700, Nicholas A. Bellinger wrote: > > > > On Mon, 2012-08-13 at 11:53 +0300, Michael S. Tsirkin wrote: > > > > > On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote: > > > > > > From: Stefan Hajnoczi > > > > Mmm, looking at how vhost_net_init + tap.c does this, but am not quite > > > > what fd needs to be propagated up for virtio-scsi -> vhost-scsi.. > > > > > > > > Can you please elaborate on this one a bit more..? > > > > > > > > > > The idea is to allow running as a user without access to > > > /dev/vhost-scsi. > > > For this, allow passing in the fd of /dev/vhost-scsi through unix domain > > > sockets. > > > > > > > Ah, that is a pretty neat trick.. So for vhost-scsi code, this would > > mean something along the lines of the following, yes..? > > Yes but with one correction. See below. > > > Thanks MST! > > > diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c > > index 4206a75..8af8758 100644 > > --- a/hw/vhost-scsi.c > > +++ b/hw/vhost-scsi.c > > @@ -21,6 +21,7 @@ struct VHostSCSI { > > const char *id; > > const char *wwpn; > > uint16_t tpgt; > > +int vhostfd; > > struct vhost_dev dev; > > struct vhost_virtqueue vqs[VHOST_SCSI_VQ_NUM]; > > QLIST_ENTRY(VHostSCSI) list; > > @@ -114,13 +115,32 @@ void vhost_scsi_stop(VHostSCSI *vs, VirtIODevice > > *vdev) > > } > > > > static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn, > > - uint16_t tpgt) > > + uint16_t tpgt, const char *vhostfd_str) > > { > > -VHostSCSI *vs = g_malloc0(sizeof(*vs)); > > +VHostSCSI *vs; > > int ret; > > > > +vs = g_malloc0(sizeof(*vs)); > > +if (!vs) { > > +error_report("vhost-scsi: unable to allocate *vs\n"); > > +return NULL; > > +} > > +vs->vhostfd = -1; > > + > > +if (vhostfd_str) { > > +if (!qemu_isdigit(vhostfd_str[0])) { > > +error_report("vhost-scsi: passed vhostfd value is not a > > digit\n"); > > +return NULL; > > This let you use an fd which was open at exec > but does not allow for fd to be open later in > case device is hot-plugged. > > See net_handle_fd_param - I think you can just rename it > qemu_handle_fd_param to avoid code duplication. > OK, so monitor_get_fd() will set this up for the case where the device is hot-plugged. That makes alot more sense now.. So renaming net_handle_fd_param -> qemu_handle_fd_param + moving into cutils.c, and will include as a leading patch for RFC-v3. Thanks MST! --nab
Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
On Sat, 2012-08-18 at 22:12 +0300, Michael S. Tsirkin wrote: > On Tue, Aug 14, 2012 at 01:31:14PM -0700, Nicholas A. Bellinger wrote: > > On Mon, 2012-08-13 at 11:53 +0300, Michael S. Tsirkin wrote: > > > On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote: > > > > From: Stefan Hajnoczi > > > > +static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn, > > > > + uint16_t tpgt) > > > > +{ > > > > +VHostSCSI *vs = g_malloc0(sizeof(*vs)); > > > > +int ret; > > > > + > > > > +/* TODO set up vhost-scsi device and bind to > > > > tcm_vhost/$wwpm/tpgt_$tpgt */ > > > > +fprintf(stderr, "wwpn = \"%s\" tpgt = \"%u\"\n", id, tpgt); > > > > + > > > > +ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false); > > > > > > This -1 is a hack. You need to support passing in fd from > > > the monitor, and pass it here. > > > > > > > Mmm, looking at how vhost_net_init + tap.c does this, but am not quite > > what fd needs to be propagated up for virtio-scsi -> vhost-scsi.. > > > > Can you please elaborate on this one a bit more..? > > > > The idea is to allow running as a user without access to > /dev/vhost-scsi. > For this, allow passing in the fd of /dev/vhost-scsi through unix domain > sockets. > Ah, that is a pretty neat trick.. So for vhost-scsi code, this would mean something along the lines of the following, yes..? Thanks MST! diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c index 4206a75..8af8758 100644 --- a/hw/vhost-scsi.c +++ b/hw/vhost-scsi.c @@ -21,6 +21,7 @@ struct VHostSCSI { const char *id; const char *wwpn; uint16_t tpgt; +int vhostfd; struct vhost_dev dev; struct vhost_virtqueue vqs[VHOST_SCSI_VQ_NUM]; QLIST_ENTRY(VHostSCSI) list; @@ -114,13 +115,32 @@ void vhost_scsi_stop(VHostSCSI *vs, VirtIODevice *vdev) } static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn, - uint16_t tpgt) + uint16_t tpgt, const char *vhostfd_str) { -VHostSCSI *vs = g_malloc0(sizeof(*vs)); +VHostSCSI *vs; int ret; +vs = g_malloc0(sizeof(*vs)); +if (!vs) { +error_report("vhost-scsi: unable to allocate *vs\n"); +return NULL; +} +vs->vhostfd = -1; + +if (vhostfd_str) { +if (!qemu_isdigit(vhostfd_str[0])) { +error_report("vhost-scsi: passed vhostfd value is not a digit\n"); +return NULL; +} + +vs->vhostfd = qemu_parse_fd(vhostfd_str); +if (vs->vhostfd == -1) { +error_report("vhost-scsi: unable to parse vs->vhostfd\n"); +return NULL; +} +} /* TODO set up vhost-scsi device and bind to tcm_vhost/$wwpm/tpgt_$tpgt */ -ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false); +ret = vhost_dev_init(&vs->dev, vs->vhostfd, "/dev/vhost-scsi", false); if (ret < 0) { error_report("vhost-scsi: vhost initialization failed: %s\n", strerror(-ret)); @@ -140,7 +160,7 @@ static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn, VHostSCSI *vhost_scsi_add_opts(QemuOpts *opts) { const char *id; -const char *wwpn; +const char *wwpn, *vhostfd; uint64_t tpgt; id = qemu_opts_id(opts); @@ -164,6 +184,7 @@ VHostSCSI *vhost_scsi_add_opts(QemuOpts *opts) error_report("vhost-scsi: \"%s\" needs a 16-bit tpgt\n", id); return NULL; } +vhostfd = qemu_opt_get(opts, "vhostfd"); -return vhost_scsi_add(id, wwpn, tpgt); +return vhost_scsi_add(id, wwpn, tpgt, vhostfd); } diff --git a/qemu-config.c b/qemu-config.c index 33399ea..2d4884c 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -636,6 +636,9 @@ QemuOptsList qemu_vhost_scsi_opts = { }, { .name = "tpgt", .type = QEMU_OPT_NUMBER, +}, { +.name = "vhostfd", +.type = QEMU_OPT_STRING, }, { /* end of list */ } },
Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
On Sat, 2012-08-18 at 22:10 +0300, Michael S. Tsirkin wrote: > On Tue, Aug 14, 2012 at 02:12:29PM -0700, Nicholas A. Bellinger wrote: > > On Mon, 2012-08-13 at 11:59 +0300, Michael S. Tsirkin wrote: > > > On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote: > > > > > > +if (ret < 0) { > > > > +fprintf(stderr, "vhost-scsi: vhost initialization failed: > > > > %s\n", > > > > +strerror(-ret)); > > > > > > errors should go to monitor, here and elsewhere. > > > > > > > I think this means using monitor_printf() right..? > > > > Looking at that now.. > > > error_report is handier. > Converted all fprintf(stderr, ...) -> error_report() usage for RFC-v3. Thanks MST!
Re: [Qemu-devel] [GIT PULL] tcm_vhost: Initial merge of vhost level target fabric driver
On Sat, 2012-08-18 at 23:04 +0300, Michael S. Tsirkin wrote: > Hi Nicholas, > I just noticed this problem in the interface: > > +#include > + > +/* > + * Used by QEMU userspace to ensure a consistent vhost-scsi ABI. > + * > + * ABI Rev 0: July 2012 version starting point for v3.6-rc merge > candidate + > + *RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl > usage > + */ > + > +#define VHOST_SCSI_ABI_VERSION 0 > + > +struct vhost_scsi_target { > + int abi_version; > + unsigned char vhost_wwpn[TRANSPORT_IQN_LEN]; > + unsigned short vhost_tpgt; > +}; > + > > Here TRANSPORT_IQN_LEN is 224, which is a multiple of 4. > Since vhost_tpgt is 2 bytes and abi_version is 4, the total size would > be 230. But gcc needs struct size be aligned to first field size, which > is 4 bytes, so it pads the structure by extra 2 bytes to the total of > 232. > > This padding is very undesirable in an ABI: > - it can not be initialized easily > - it can not be checked easily > - it can leak information between kernel and userspace > H, yes. Very good reasons to avoid ABI ambiguity .. > Simplest solution is probably just to make the padding > explicit: > > +struct vhost_scsi_target { > + int abi_version; > + unsigned char vhost_wwpn[TRANSPORT_IQN_LEN]; > + unsigned short vhost_tpgt; > + unsigned short reserved; > +}; > + > > I think we should fix this buglet before it goes out to users. > , fixing this up in target-pending/master now w/ your reported-by +signoff, and will change vhost-scsi's copy of these defs for next week's RFC-v3 posting. Thanks MST! --nab
Re: [Qemu-devel] [RFC-v2 6/6] virtio-scsi: Fix incorrect VirtIOSCSI->cmd_vqs[0] definition
On Sat, 2012-08-18 at 20:52 +0200, Paolo Bonzini wrote: > Il 14/08/2012 22:20, Nicholas A. Bellinger ha scritto: > >>> > > Since virtio_scsi currently assumes a single vqs for data, this patch > >>> > > simply changes ->cmd_vqs[1] to handle the single VirtQueue. > > Wrong, multiqueue works just fine. :) It's just the kernel driver that > doesn't support it yet. > > >>> > > Cc: Paolo Bonzini > >>> > > Cc: Stefan Hajnoczi > >>> > > Cc: Michael S. Tsirkin > >>> > > Signed-off-by: Nicholas Bellinger > >> > > >> > This is a bugfix we need even without vhost, right? > >> > > > I believe so, as it appears to be stomping past the end of memory for > > every virtio-scsi initialization regardless of vhost usage.. > > You just did a wrong merge. When commit d2ad7dd (virtio-scsi: add > multiqueue capability, 2012-04-06) changed cmd_vq from pointer to array > of pointers, you should have moved the following fields to the middle of > the struct, just like that commit did. Ahh, I see how virtio_scsi_init() -> virtio_common_init() are setting up the memory now.. Apologies, my mistake. So moving the vhost-scsi related structure members ahead of the VirtQueue releated definitions for RFC-v3, and dropping this patch. Thanks Paolo! --nab
Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
On Mon, 2012-08-13 at 19:47 +, Blue Swirl wrote: > On Mon, Aug 13, 2012 at 8:35 AM, Nicholas A. Bellinger > wrote: > > From: Stefan Hajnoczi > > > > This patch adds a new type of host device that drives the vhost_scsi > > device. The syntax to add vhost-scsi is: > > > > qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123 > > > > The virtio-scsi emulated device will make use of vhost-scsi to process > > virtio-scsi requests inside the kernel and hand them to the in-kernel > > SCSI target stack using the tcm_vhost fabric driver. > > > > The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2, > > and the commit can be found here: > > > > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297 > > > > Changelog v1 -> v2: > > > > - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as > > starting point for v3.6-rc code (Stefan + ALiguori + nab) > > - Fix upstream qemu conflict in hw/qdev-properties.c > > - Make GET_ABI_VERSION use int (nab + mst) > > - Fix vhost-scsi case lables in configure (reported by paolo) > > - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following > > qdev_prop_netdev (reported by paolo) > > - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) > > > > Changelog v0 -> v1: > > > > - Add VHOST_SCSI_SET_ENDPOINT call (stefan) > > - Enable vhost notifiers for multiple queues (Zhi) > > - clear vhost-scsi endpoint on stopped (Zhi) > > - Add CONFIG_VHOST_SCSI for QEMU build configure (nab) > > - Rename vhost_vring_target -> vhost_scsi_target (mst + nab) > > - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab) > > > > Cc: Stefan Hajnoczi > > Cc: Zhi Yong Wu > > Cc: Anthony Liguori > > Cc: Paolo Bonzini > > Cc: Michael S. Tsirkin > > Signed-off-by: Nicholas Bellinger > > --- > > configure| 10 +++ > > hw/Makefile.objs |1 + > > hw/qdev-properties.c | 40 > > hw/qdev.h|3 + > > hw/vhost-scsi.c | 170 > > ++ > > hw/vhost-scsi.h | 50 +++ > > qemu-common.h|1 + > > qemu-config.c| 16 + > > qemu-options.hx |4 + > > vl.c | 18 + > > 10 files changed, 313 insertions(+), 0 deletions(-) > > create mode 100644 hw/vhost-scsi.c > > create mode 100644 hw/vhost-scsi.h > > > > > > +/* --- vhost-scsi --- */ > > + > > +static int parse_vhost_scsi_dev(DeviceState *dev, const char *str, void > > **ptr) > > +{ > > + VHostSCSI *p; > > + > > + p = find_vhost_scsi(str); > > + if (p == NULL) > > + return -ENOENT; > > Braces, please. > Fixed > > + > > + *ptr = p; > > + return 0; > > +} > > + > > +static const char *print_vhost_scsi_dev(void *ptr) > > +{ > > +VHostSCSI *p = ptr; > > + > > +return (p) ? vhost_scsi_get_id(p) : ""; > > +} > > + > > +static void get_vhost_scsi_dev(Object *obj, Visitor *v, void *opaque, > > + const char *name, Error **errp) > > +{ > > +get_pointer(obj, v, opaque, print_vhost_scsi_dev, name, errp); > > +} > > + > > +static void set_vhost_scsi_dev(Object *obj, Visitor *v, void *opaque, > > + const char *name, Error **errp) > > +{ > > +set_pointer(obj, v, opaque, parse_vhost_scsi_dev, name, errp); > > +} > > + > > +PropertyInfo qdev_prop_vhost_scsi = { > > + .name = "vhost-scsi", > > + .get = get_vhost_scsi_dev, > > + .set = set_vhost_scsi_dev, > > +}; > > + > > /* --- pointer --- */ > > > > /* Not a proper property, just for dirty hacks. TODO Remove it! */ > > diff --git a/hw/qdev.h b/hw/qdev.h > > index d699194..d5873bb 100644 > > --- a/hw/qdev.h > > +++ b/hw/qdev.h > > @@ -238,6 +238,7 @@ extern PropertyInfo qdev_prop_vlan; > > extern PropertyInfo qdev_prop_pci_devfn; > > extern PropertyInfo qdev_prop_blocksize; > > extern PropertyInfo qdev_prop_pci_host_devaddr; > > +extern PropertyInfo qdev_prop_vhost_scsi; > > > > #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \ > > .name = (_name),\ > > @@ -305,6 +306,8 @@ extern PropertyInfo qdev_prop_pci_host_devaddr; > > DEFIN
Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
On Mon, 2012-08-13 at 11:59 +0300, Michael S. Tsirkin wrote: > On Mon, Aug 13, 2012 at 08:35:14AM +0000, Nicholas A. Bellinger wrote: > > From: Stefan Hajnoczi > > > > This patch adds a new type of host device that drives the vhost_scsi > > device. The syntax to add vhost-scsi is: > > > > qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123 > > > > The virtio-scsi emulated device will make use of vhost-scsi to process > > virtio-scsi requests inside the kernel and hand them to the in-kernel > > SCSI target stack using the tcm_vhost fabric driver. > > > > The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2, > > and the commit can be found here: > > > > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297 > > > > Changelog v1 -> v2: > > > > - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as > > starting point for v3.6-rc code (Stefan + ALiguori + nab) > > - Fix upstream qemu conflict in hw/qdev-properties.c > > - Make GET_ABI_VERSION use int (nab + mst) > > - Fix vhost-scsi case lables in configure (reported by paolo) > > - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following > > qdev_prop_netdev (reported by paolo) > > - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) > > > > Changelog v0 -> v1: > > > > - Add VHOST_SCSI_SET_ENDPOINT call (stefan) > > - Enable vhost notifiers for multiple queues (Zhi) > > - clear vhost-scsi endpoint on stopped (Zhi) > > - Add CONFIG_VHOST_SCSI for QEMU build configure (nab) > > - Rename vhost_vring_target -> vhost_scsi_target (mst + nab) > > - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab) > > > > Cc: Stefan Hajnoczi > > Cc: Zhi Yong Wu > > Cc: Anthony Liguori > > Cc: Paolo Bonzini > > Cc: Michael S. Tsirkin > > Signed-off-by: Nicholas Bellinger > > > Sent mail too fast, sorry. More comments below. > > > --- > > configure| 10 +++ > > hw/Makefile.objs |1 + > > hw/qdev-properties.c | 40 > > hw/qdev.h|3 + > > hw/vhost-scsi.c | 170 > > ++ > > hw/vhost-scsi.h | 50 +++ > > qemu-common.h|1 + > > qemu-config.c| 16 + > > qemu-options.hx |4 + > > vl.c | 18 + > > 10 files changed, 313 insertions(+), 0 deletions(-) > > create mode 100644 hw/vhost-scsi.c > > create mode 100644 hw/vhost-scsi.h > > > > diff --git a/configure b/configure > > index f0dbc03..1f03202 100755 > > --- a/configure > > +++ b/configure > > @@ -168,6 +168,7 @@ libattr="" > > xfs="" > > > > vhost_net="no" > > +vhost_scsi="no" > > kvm="no" > > gprof="no" > > debug_tcg="no" > > @@ -513,6 +514,7 @@ Haiku) > >usb="linux" > >kvm="yes" > >vhost_net="yes" > > + vhost_scsi="yes" > >if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then > > audio_possible_drivers="$audio_possible_drivers fmod" > >fi > > @@ -818,6 +820,10 @@ for opt do > >;; > >--enable-vhost-net) vhost_net="yes" > >;; > > + --disable-vhost-scsi) vhost_scsi="no" > > + ;; > > + --enable-vhost-scsi) vhost_scsi="yes" > > + ;; > >--disable-opengl) opengl="no" > >;; > >--enable-opengl) opengl="yes" > > @@ -3116,6 +3122,7 @@ echo "posix_madvise $posix_madvise" > > echo "uuid support $uuid" > > echo "libcap-ng support $cap_ng" > > echo "vhost-net support $vhost_net" > > +echo "vhost-scsi support $vhost_scsi" > > echo "Trace backend $trace_backend" > > echo "Trace output file $trace_file-" > > echo "spice support $spice" > > @@ -3828,6 +3835,9 @@ case "$target_arch2" in > >if test "$vhost_net" = "yes" ; then > > echo "CONFIG_VHOST_NET=y" >> $config_target_mak > >fi > > + if test "$vhost_scsi" = "yes" ; then > > +echo "CONFIG_VHOST_SCSI=y" >> $config_target_mak > > + fi > >
Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
On Mon, 2012-08-13 at 11:53 +0300, Michael S. Tsirkin wrote: > On Mon, Aug 13, 2012 at 08:35:14AM +0000, Nicholas A. Bellinger wrote: > > From: Stefan Hajnoczi > > > > This patch adds a new type of host device that drives the vhost_scsi > > device. The syntax to add vhost-scsi is: > > > > qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123 > > > > The virtio-scsi emulated device will make use of vhost-scsi to process > > virtio-scsi requests inside the kernel and hand them to the in-kernel > > SCSI target stack using the tcm_vhost fabric driver. > > +static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn, > > + uint16_t tpgt) > > +{ > > +VHostSCSI *vs = g_malloc0(sizeof(*vs)); > > +int ret; > > + > > +/* TODO set up vhost-scsi device and bind to > > tcm_vhost/$wwpm/tpgt_$tpgt */ > > +fprintf(stderr, "wwpn = \"%s\" tpgt = \"%u\"\n", id, tpgt); > > + > > +ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false); > > This -1 is a hack. You need to support passing in fd from > the monitor, and pass it here. > Mmm, looking at how vhost_net_init + tap.c does this, but am not quite what fd needs to be propagated up for virtio-scsi -> vhost-scsi.. Can you please elaborate on this one a bit more..? --nab
Re: [Qemu-devel] [RFC-v2 6/6] virtio-scsi: Fix incorrect VirtIOSCSI->cmd_vqs[0] definition
On Mon, 2012-08-13 at 12:02 +0300, Michael S. Tsirkin wrote: > On Mon, Aug 13, 2012 at 08:35:17AM +0000, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > This patch fixes bug in the definition of VirtIOSCSI->cmd_vqs[0], > > where the return of virtio_add_queue() in virtio_scsi_init() ends up > > overwriting past the end of ->cmd_vqs[0]. > > > > Since virtio_scsi currently assumes a single vqs for data, this patch > > simply changes ->cmd_vqs[1] to handle the single VirtQueue. > > > > Cc: Paolo Bonzini > > Cc: Stefan Hajnoczi > > Cc: Michael S. Tsirkin > > Signed-off-by: Nicholas Bellinger > > This is a bugfix we need even without vhost, right? > I believe so, as it appears to be stomping past the end of memory for every virtio-scsi initialization regardless of vhost usage.. Paolo, can you pickup this fix now for stable so it can be dropped from RFC-v3..? --nab > > --- > > hw/virtio-scsi.c |2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > > diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c > > index 5e2ff6b..2c70f89 100644 > > --- a/hw/virtio-scsi.c > > +++ b/hw/virtio-scsi.c > > @@ -150,7 +150,7 @@ typedef struct { > > bool events_dropped; > > VirtQueue *ctrl_vq; > > VirtQueue *event_vq; > > -VirtQueue *cmd_vqs[0]; > > +VirtQueue *cmd_vqs[1]; > > > > bool vhost_started; > > VHostSCSI *vhost_scsi; > > -- > > 1.7.2.5 > -- > To unsubscribe from this list: send the line "unsubscribe target-devel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [RFC-v2 1/6] msix: Work-around for vhost-scsi with KVM in-kernel MSI injection
On Mon, 2012-08-13 at 21:17 +0300, Michael S. Tsirkin wrote: > On Mon, Aug 13, 2012 at 08:06:17PM +0200, Jan Kiszka wrote: > > On 2012-08-13 20:03, Michael S. Tsirkin wrote: > > > On Mon, Aug 13, 2012 at 02:06:10PM +0200, Jan Kiszka wrote: > > >> On 2012-08-13 10:35, Nicholas A. Bellinger wrote: > > >>> From: Nicholas Bellinger > > >>> > > >>> This is required to get past the following assert with: > > >>> > > >>> commit 1523ed9e1d46b0b54540049d491475ccac7e6421 > > >>> Author: Jan Kiszka > > >>> Date: Thu May 17 10:32:39 2012 -0300 > > >>> > > >>> virtio/vhost: Add support for KVM in-kernel MSI injection > > >>> > > >>> Cc: Stefan Hajnoczi > > >>> Cc: Jan Kiszka > > >>> Cc: Paolo Bonzini > > >>> Cc: Anthony Liguori > > >>> Signed-off-by: Nicholas Bellinger > > >>> --- > > >>> hw/msix.c |3 +++ > > >>> 1 files changed, 3 insertions(+), 0 deletions(-) > > >>> > > >>> diff --git a/hw/msix.c b/hw/msix.c > > >>> index 800fc32..c1e6dc3 100644 > > >>> --- a/hw/msix.c > > >>> +++ b/hw/msix.c > > >>> @@ -544,6 +544,9 @@ void msix_unset_vector_notifiers(PCIDevice *dev) > > >>> { > > >>> int vector; > > >>> > > >>> +if (!dev->msix_vector_use_notifier && > > >>> !dev->msix_vector_release_notifier) > > >>> +return; > > >>> + > > >>> assert(dev->msix_vector_use_notifier && > > >>> dev->msix_vector_release_notifier); > > >>> > > >>> > > >> > > >> I think to remember pointing out that there is a bug somewhere in the > > >> reset code which deactivates a non-active vhost instance, no? > > >> > > >> Jan > > > > > > Could not find it. Could you dig it up pls? > > > > http://thread.gmane.org/gmane.linux.scsi.target.devel/2277/focus=2309 > > > > Jan > > Ah yes. So let's not work around, need to get to the bottom of that. > Ok, so the assert being triggered in msix_unset_vector_notifiers() appears to have been a side effect of the memory corruption bug in virtio-scsi fixed in Patch #6, and is no longer required to start vhost-scsi with the bugfix in place. That said, dropping this patch for RFC-v3..
[Qemu-devel] [RFC-v2 4/6] virtio-scsi: Add start/stop functionality for vhost-scsi
From: Stefan Hajnoczi This patch starts and stops vhost as the virtio device transitions through its status phases. Vhost can only be started once the guest reports its driver has successfully initialized, which means the virtqueues have been set up by the guest. v2: - Squash virtio-scsi: use the vhost-scsi host device from stefan (nab) - Fix up virtio_scsi_properties[] conflict w/ upstream qemu (nab) - Drop usage of to_virtio_scsi() in virtio_scsi_set_status() (reported by paolo) - Use modern VirtIOSCSIConf define in virtio-scsi.h (reported by paolo) - Use s->conf->vhost_scsi instead of proxyconf->vhost_scsi in virtio_scsi_init() (reported by paolo) - Only register QEMU SCSI bus is vhost-scsi is not active (reported by paolo) Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-pci.c |1 + hw/virtio-scsi.c | 48 hw/virtio-scsi.h |1 + 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 125eded..b29fc3b 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -1036,6 +1036,7 @@ static void virtio_scsi_exit_pci(PCIDevice *pci_dev) } static Property virtio_scsi_properties[] = { +DEFINE_PROP_VHOST_SCSI("vhost-scsi", VirtIOPCIProxy, scsi.vhost_scsi), DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOPCIProxy, host_features, scsi), diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 5f737ac..8130956 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -13,9 +13,13 @@ * */ +#include "qemu-common.h" +#include "qemu-error.h" +#include "vhost-scsi.h" #include "virtio-scsi.h" #include #include +#include "vhost.h" #define VIRTIO_SCSI_VQ_SIZE 128 #define VIRTIO_SCSI_CDB_SIZE32 @@ -147,6 +151,9 @@ typedef struct { VirtQueue *ctrl_vq; VirtQueue *event_vq; VirtQueue *cmd_vqs[0]; + +bool vhost_started; +VHostSCSI *vhost_scsi; } VirtIOSCSI; typedef struct VirtIOSCSIReq { @@ -699,6 +706,38 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = { .load_request = virtio_scsi_load_request, }; +static bool virtio_scsi_started(VirtIOSCSI *s, uint8_t val) +{ +return (val & VIRTIO_CONFIG_S_DRIVER_OK) && s->vdev.vm_running; +} + +static void virtio_scsi_set_status(VirtIODevice *vdev, uint8_t val) +{ +VirtIOSCSI *s = (VirtIOSCSI *)vdev; +bool start = virtio_scsi_started(s, val); + +if (s->vhost_started == start) { +return; +} + +if (start) { +int ret; + +ret = vhost_scsi_start(s->vhost_scsi, vdev); +if (ret < 0) { +error_report("virtio-scsi: unable to start vhost: %s\n", + strerror(-ret)); + +/* There is no userspace virtio-scsi fallback so exit */ +exit(1); +} +} else { +vhost_scsi_stop(s->vhost_scsi, vdev); +} + +s->vhost_started = start; +} + VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) { VirtIOSCSI *s; @@ -712,12 +751,17 @@ VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf) s->qdev = dev; s->conf = proxyconf; +s->vhost_started = false; +s->vhost_scsi = s->conf->vhost_scsi; /* TODO set up vdev function pointers */ s->vdev.get_config = virtio_scsi_get_config; s->vdev.set_config = virtio_scsi_set_config; s->vdev.get_features = virtio_scsi_get_features; s->vdev.reset = virtio_scsi_reset; +if (s->vhost_scsi) { +s->vdev.set_status = virtio_scsi_set_status; +} s->ctrl_vq = virtio_add_queue(&s->vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_ctrl); @@ -743,5 +787,9 @@ void virtio_scsi_exit(VirtIODevice *vdev) { VirtIOSCSI *s = (VirtIOSCSI *)vdev; unregister_savevm(s->qdev, "virtio-scsi", s); + +/* This will stop vhost backend if appropriate. */ +virtio_scsi_set_status(vdev, 0); + virtio_cleanup(vdev); } diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h index 4bc889d..74e9422 100644 --- a/hw/virtio-scsi.h +++ b/hw/virtio-scsi.h @@ -22,6 +22,7 @@ #define VIRTIO_ID_SCSI 8 struct VirtIOSCSIConf { +VHostSCSI *vhost_scsi; uint32_t num_queues; uint32_t max_sectors; uint32_t cmd_per_lun; -- 1.7.2.5
[Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
From: Stefan Hajnoczi This patch adds a new type of host device that drives the vhost_scsi device. The syntax to add vhost-scsi is: qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123 The virtio-scsi emulated device will make use of vhost-scsi to process virtio-scsi requests inside the kernel and hand them to the in-kernel SCSI target stack using the tcm_vhost fabric driver. The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2, and the commit can be found here: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297 Changelog v1 -> v2: - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as starting point for v3.6-rc code (Stefan + ALiguori + nab) - Fix upstream qemu conflict in hw/qdev-properties.c - Make GET_ABI_VERSION use int (nab + mst) - Fix vhost-scsi case lables in configure (reported by paolo) - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following qdev_prop_netdev (reported by paolo) - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) Changelog v0 -> v1: - Add VHOST_SCSI_SET_ENDPOINT call (stefan) - Enable vhost notifiers for multiple queues (Zhi) - clear vhost-scsi endpoint on stopped (Zhi) - Add CONFIG_VHOST_SCSI for QEMU build configure (nab) - Rename vhost_vring_target -> vhost_scsi_target (mst + nab) - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab) Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Anthony Liguori Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- configure| 10 +++ hw/Makefile.objs |1 + hw/qdev-properties.c | 40 hw/qdev.h|3 + hw/vhost-scsi.c | 170 ++ hw/vhost-scsi.h | 50 +++ qemu-common.h|1 + qemu-config.c| 16 + qemu-options.hx |4 + vl.c | 18 + 10 files changed, 313 insertions(+), 0 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h diff --git a/configure b/configure index f0dbc03..1f03202 100755 --- a/configure +++ b/configure @@ -168,6 +168,7 @@ libattr="" xfs="" vhost_net="no" +vhost_scsi="no" kvm="no" gprof="no" debug_tcg="no" @@ -513,6 +514,7 @@ Haiku) usb="linux" kvm="yes" vhost_net="yes" + vhost_scsi="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi @@ -818,6 +820,10 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-vhost-scsi) vhost_scsi="no" + ;; + --enable-vhost-scsi) vhost_scsi="yes" + ;; --disable-opengl) opengl="no" ;; --enable-opengl) opengl="yes" @@ -3116,6 +3122,7 @@ echo "posix_madvise $posix_madvise" echo "uuid support $uuid" echo "libcap-ng support $cap_ng" echo "vhost-net support $vhost_net" +echo "vhost-scsi support $vhost_scsi" echo "Trace backend $trace_backend" echo "Trace output file $trace_file-" echo "spice support $spice" @@ -3828,6 +3835,9 @@ case "$target_arch2" in if test "$vhost_net" = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi + if test "$vhost_scsi" = "yes" ; then +echo "CONFIG_VHOST_SCSI=y" >> $config_target_mak + fi fi esac case "$target_arch2" in diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 3ba5dd0..6ab75ec 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o virtio-balloon.o virtio-net.o obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o obj-$(CONFIG_SOFTMMU) += vhost_net.o obj-$(CONFIG_VHOST_NET) += vhost.o +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/ obj-$(CONFIG_NO_PCI) += pci-stub.o obj-$(CONFIG_VGA) += vga.o diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 8aca0d4..0266266 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -4,6 +4,7 @@ #include "blockdev.h" #include "hw/block-common.h" #include "net/hub.h" +#include "vhost-scsi.h" void *qdev_get_prop_ptr(DeviceState *dev, Property *prop) { @@ -696,6 +697,45 @@ PropertyInfo qdev_prop_vlan = { .set = set_vlan, }; +/* --- vhost-scsi --- */ + +static int parse_vhost_scsi_dev(DeviceState *dev, const char *str, void **ptr) +{ + VHostSCSI *p; + + p = find_vhost_scsi(str); + if (p == NULL) + return -ENOENT; + + *ptr = p; + return 0; +} + +static const char *print_vhost_scsi_dev(void *ptr) +{ +VHostSCSI *p = ptr; + +return (p) ? vhost_scsi_get_id(p) : ""; +} + +static void get_vhost_scsi_dev(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ +get_pointer(obj, v, opaque, print_vhost_scsi_dev, name, errp); +} + +static void set_vhost_scsi_dev(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ +s
[Qemu-devel] [RFC-v2 2/6] vhost: Pass device path to vhost_dev_init()
From: Stefan Hajnoczi The path to /dev/vhost-net is currently hardcoded in vhost_dev_init(). This needs to be changed so that /dev/vhost-scsi can be used. Pass in the device path instead of hardcoding it. Signed-off-by: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- hw/vhost.c |5 +++-- hw/vhost.h |3 ++- hw/vhost_net.c |2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 0fd8da8..d0ce5aa 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -747,14 +747,15 @@ static void vhost_eventfd_del(MemoryListener *listener, { } -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force) +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force) { uint64_t features; int r; if (devfd >= 0) { hdev->control = devfd; } else { -hdev->control = open("/dev/vhost-net", O_RDWR); +hdev->control = open(devpath, O_RDWR); if (hdev->control < 0) { return -errno; } diff --git a/hw/vhost.h b/hw/vhost.h index 80e64df..0c47229 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -44,7 +44,8 @@ struct vhost_dev { bool force; }; -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force); +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force); void vhost_dev_cleanup(struct vhost_dev *hdev); bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); diff --git a/hw/vhost_net.c b/hw/vhost_net.c index ecaa22d..df2c4a3 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -109,7 +109,7 @@ struct vhost_net *vhost_net_init(NetClientState *backend, int devfd, (1 << VHOST_NET_F_VIRTIO_NET_HDR); net->backend = r; -r = vhost_dev_init(&net->dev, devfd, force); +r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force); if (r < 0) { goto fail; } -- 1.7.2.5
[Qemu-devel] [RFC-v2 5/6] virtio-scsi: Set max_target=0 during vhost-scsi operation
From: Nicholas Bellinger This QEMU patch sets VirtIOSCSIConfig->max_target=0 for vhost-scsi operation to restrict virtio-scsi LLD guest scanning to max_id=0 (a single target ID instance) when connected to individual tcm_vhost endpoints. This ensures that virtio-scsi LLD only attempts to scan target IDs up to VIRTIO_SCSI_MAX_TARGET when connected via virtio-scsi-raw. Cc: Stefan Hajnoczi Cc: Zhi Yong Wu Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio-scsi.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 8130956..5e2ff6b 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -545,7 +545,11 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, stl_raw(&scsiconf->sense_size, s->sense_size); stl_raw(&scsiconf->cdb_size, s->cdb_size); stl_raw(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL); -stl_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); +if (s->vhost_scsi) { +stl_raw(&scsiconf->max_target, 0); +} else { +stl_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); +} stl_raw(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN); } -- 1.7.2.5
[Qemu-devel] [RFC-v2 6/6] virtio-scsi: Fix incorrect VirtIOSCSI->cmd_vqs[0] definition
From: Nicholas Bellinger This patch fixes bug in the definition of VirtIOSCSI->cmd_vqs[0], where the return of virtio_add_queue() in virtio_scsi_init() ends up overwriting past the end of ->cmd_vqs[0]. Since virtio_scsi currently assumes a single vqs for data, this patch simply changes ->cmd_vqs[1] to handle the single VirtQueue. Cc: Paolo Bonzini Cc: Stefan Hajnoczi Cc: Michael S. Tsirkin Signed-off-by: Nicholas Bellinger --- hw/virtio-scsi.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c index 5e2ff6b..2c70f89 100644 --- a/hw/virtio-scsi.c +++ b/hw/virtio-scsi.c @@ -150,7 +150,7 @@ typedef struct { bool events_dropped; VirtQueue *ctrl_vq; VirtQueue *event_vq; -VirtQueue *cmd_vqs[0]; +VirtQueue *cmd_vqs[1]; bool vhost_started; VHostSCSI *vhost_scsi; -- 1.7.2.5
[Qemu-devel] [RFC-v2 0/6] vhost-scsi: Add support for host virtualized target
From: Nicholas Bellinger Hi Paolo, Stefan, & QEMU folks, The following is the second RFC series for vhost-scsi patches against mainline QEMU v1.1.0. The series is available from the following working branch: git://git.kernel.org/pub/scm/virt/kvm/nab/qemu-kvm.git vhost-scsi-merge Apologies for the delayed follow-up on this series. The changes detailed below addresses Paolo's original comments on vhost-scsi code from the last weeks. As of this evening the tcm_vhost driver has now been merged into the mainline kernel for 3.6-rc2 here: tcm_vhost: Initial merge for vhost level target fabric driver http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297877 Also, after following up on the qemu-kvm IRQ injection changes (from Jan) that caused a performance regerssion with QEMU 1.1.0 code originally reported here: vhost-scsi port to v1.1.0 + MSI-X performance regression http://comments.gmane.org/gmane.linux.scsi.target.devel/2277 It turns out that setting explict virtio-queue IRQ affinity within guest appears to bring small block random IOPs performance back up to the pre IRQ injection conversion levels. I'm not sure why this ended up making so much of a difference post IRQ injection conversion, but setting virtio-queue affinity is now getting us back to pre IQN injection conversion levels. Changes from v1 -> v2: - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as starting point for v3.6-rc code (Stefan + ALiguori + nab) - Fix upstream qemu conflict in hw/qdev-properties.c - Make GET_ABI_VERSION use int (nab + mst) - Drop unnecessary event-notifier changes (nab) - Fix vhost-scsi case lables in configure (reported by paolo) - Convert qdev_prop_vhost_scsi to use ->get() + ->set() following qdev_prop_netdev (reported by paolo) - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo) - Squash virtio-scsi: use the vhost-scsi host device from stefan (nab) - Fix up virtio_scsi_properties[] conflict w/ upstream qemu (nab) - Drop usage of to_virtio_scsi() in virtio_scsi_set_status() (reported by paolo) - Use modern VirtIOSCSIConf define in virtio-scsi.h (reported by paolo) - Use s->conf->vhost_scsi instead of proxyconf->vhost_scsi in virtio_scsi_init() (reported by paolo) - Only register QEMU SCSI bus is vhost-scsi is not active (reported by paolo) - Fix incorrect VirtIOSCSI->cmd_vqs[0] definition (nab) Please have another look, and let me know if anything else needs to be addressed. Thanks! --nab Nicholas Bellinger (3): msix: Work-around for vhost-scsi with KVM in-kernel MSI injection virtio-scsi: Set max_target=0 during vhost-scsi operation virtio-scsi: Fix incorrect VirtIOSCSI->cmd_vqs[0] definition Stefan Hajnoczi (3): vhost: Pass device path to vhost_dev_init() vhost-scsi: add -vhost-scsi host device for use with tcm-vhost virtio-scsi: Add start/stop functionality for vhost-scsi configure| 10 +++ hw/Makefile.objs |1 + hw/msix.c|3 + hw/qdev-properties.c | 40 hw/qdev.h|3 + hw/vhost-scsi.c | 170 ++ hw/vhost-scsi.h | 50 +++ hw/vhost.c |5 +- hw/vhost.h |3 +- hw/vhost_net.c |2 +- hw/virtio-pci.c |1 + hw/virtio-scsi.c | 56 - hw/virtio-scsi.h |1 + qemu-common.h|1 + qemu-config.c| 16 + qemu-options.hx |4 + vl.c | 18 + 17 files changed, 378 insertions(+), 6 deletions(-) create mode 100644 hw/vhost-scsi.c create mode 100644 hw/vhost-scsi.h -- 1.7.2.5
[Qemu-devel] [RFC-v2 1/6] msix: Work-around for vhost-scsi with KVM in-kernel MSI injection
From: Nicholas Bellinger This is required to get past the following assert with: commit 1523ed9e1d46b0b54540049d491475ccac7e6421 Author: Jan Kiszka Date: Thu May 17 10:32:39 2012 -0300 virtio/vhost: Add support for KVM in-kernel MSI injection Cc: Stefan Hajnoczi Cc: Jan Kiszka Cc: Paolo Bonzini Cc: Anthony Liguori Signed-off-by: Nicholas Bellinger --- hw/msix.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 800fc32..c1e6dc3 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -544,6 +544,9 @@ void msix_unset_vector_notifiers(PCIDevice *dev) { int vector; +if (!dev->msix_vector_use_notifier && !dev->msix_vector_release_notifier) +return; + assert(dev->msix_vector_use_notifier && dev->msix_vector_release_notifier); -- 1.7.2.5
Re: [Qemu-devel] [GIT PULL] tcm_vhost: Initial merge of vhost level target fabric driver
Hi Linus, Ping on the initial tcm_vhost merge for-3.6..? I know it's been a busier than usual merge window, but hopefully this one is still in your PULL queue.. Otherwise if there is something else that you'd like to see different from this PULL request, please let us know. Thank you! --nab On Mon, 2012-07-30 at 18:19 -0700, Nicholas A. Bellinger wrote: > Hi Linus, > > Here is the PULL request for the initial merge of tcm_vhost based on > RFC-v5 code with MST's ACK appended to the initial merge commit. > As promised, the commit is available from two different branches for you > to consider merging as for-3.6 code. > > The 'for-next-merge' branch based on mainline commit 7409a6657ae using > 3.5-rc2 code contains two duplicates of pre-merge vhost patch > dependencies that have already been merged into mainline via net-next. > This commit is also in the 07302012 -next patchset, and available here: > > git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git > for-next-merge > > Or the 'for-linus' branch containing an -rc0 head @ commit bdc0077af57: > >Merge tag 'scsi-misc' of git://git.kernel.org/../jejb/scsi) > > rebased up to the last commit in scsi-misc required for virtio-scsi > client LLD scanning logic to function properly with tcm_vhost fabric > ports, is available here: > > git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git > for-linus > > Both branches have gotten recent testing and have been running > over-night small block random I/O tests connected to raw block flash > backends. The same diffstat below will result from pulling either > branch. > > Also, the incremental patch to address MST's last round of post-merge > comments has been sent to the lists for feedback this afternoon. This > will be included into the usual post -rc1 PULL via 3.6-rc-fixes, along > with any other bits that end up changing post-merge. > > Please let us know if you have any concerns. > > Thank you! > > --nab > > Nicholas Bellinger (1): > tcm_vhost: Initial merge for vhost level target fabric driver > > drivers/vhost/Kconfig |3 + > drivers/vhost/Kconfig.tcm |6 + > drivers/vhost/Makefile|2 + > drivers/vhost/tcm_vhost.c | 1628 > + > drivers/vhost/tcm_vhost.h | 101 +++ > 5 files changed, 1740 insertions(+), 0 deletions(-) > create mode 100644 drivers/vhost/Kconfig.tcm > create mode 100644 drivers/vhost/tcm_vhost.c > create mode 100644 drivers/vhost/tcm_vhost.h > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/