From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umlnf-0002Bu-Fq for qemu-devel@nongnu.org; Wed, 12 Jun 2013 10:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UmlnW-000636-8Q for qemu-devel@nongnu.org; Wed, 12 Jun 2013 10:13:23 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:60965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmlnV-00062n-Uk for qemu-devel@nongnu.org; Wed, 12 Jun 2013 10:13:14 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa11so6686631pad.5 for ; Wed, 12 Jun 2013 07:13:12 -0700 (PDT) Message-ID: <51B881F1.9080209@ozlabs.ru> Date: Thu, 13 Jun 2013 00:13:05 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1371017717-5439-1-git-send-email-fred.konrad@greensocs.com> <20130612090324.GB8060@redhat.com> <51B839B0.8070104@ozlabs.ru> <20130612091623.GA8686@redhat.com> <51B859C5.3080707@ozlabs.ru> <20130612115206.GA29747@redhat.com> In-Reply-To: <20130612115206.GA29747@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RESEND PATCH] virtio-scsi: forward scsibus for virtio-scsi-pci. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: kwolf@redhat.com, aliguori@us.ibm.com, mark.burton@greensocs.com, qemu-stable@nongnu.org, qemu-devel@nongnu.org, pbonzini@redhat.com, fred.konrad@greensocs.com On 06/12/2013 09:52 PM, Michael S. Tsirkin wrote: > On Wed, Jun 12, 2013 at 09:21:41PM +1000, Alexey Kardashevskiy wrote: >> On 06/12/2013 07:16 PM, Michael S. Tsirkin wrote: >>> On Wed, Jun 12, 2013 at 07:04:48PM +1000, Alexey Kardashevskiy wrote: >>>> On 06/12/2013 07:03 PM, Michael S. Tsirkin wrote: >>>>> On Wed, Jun 12, 2013 at 08:15:17AM +0200, fred.konrad@greensocs.com wrote: >>>>>> From: KONRAD Frederic >>>>>> >>>>>> This fix a bug with scsi hotplug on virtio-scsi-pci: >>>>>> >>>>>> As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add >>>>>> to the virtio-scsi-device plugged on the virtio-bus. >>>>>> >>>>>> Cc: qemu-stable@nongnu.org >>>>>> Reported-by: Alexey Kardashevskiy >>>>>> Reviewed-by: Andreas Färber >>>>>> Signed-off-by: KONRAD Frederic >>>>> >>>>> Acked-by: Michael S. Tsirkin >>>>> >>>>> Note: we don't seem to have any decent way to >>>>> add disks to devices: no QMP interface, >>>>> pci address is required instead of using an id ... >>>>> >>>>> Anyone can be bothered to fix this? >>>> >>>> >>>> Actually PCI address is not always required, this field (we are talking >>>> about "drive_add"?) is ignored when "if=none". >>>> >>> >>> Then documentation in hmp-commands.hx is wrong, isn't it? >>> Add that to the list. >>> >>> if=none can't be actually used to hot-add >>> a disk to a device, can it? It creates a disc and assumes you will >>> use it by a device created later. >> >> >> Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in >> console: >> drive_add auto file=virtimg/fc18guest,if=none,id=bar1 >> device_add scsi-disk,bus=device0.0,drive=bar1 >> >> Pretty hot plug :) > > I see. So you pass the device id of a patent as a bus option? Yes. Furthermore I can add many drive+scsi-disk to the same virtio-scsi-pci device/bus this way. > So the real problem is that there's no documentation > and what is there in hmp-commands.hx, is wrong. Yes, confusing. > >> >>> >>> >>>> >>>>>> --- >>>>>> hw/pci/pci-hotplug.c | 19 +++++++++++++++++-- >>>>>> 1 file changed, 17 insertions(+), 2 deletions(-) >>>>>> >>>>>> diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c >>>>>> index 12287d1..c708752 100644 >>>>>> --- a/hw/pci/pci-hotplug.c >>>>>> +++ b/hw/pci/pci-hotplug.c >>>>>> @@ -30,6 +30,8 @@ >>>>>> #include "monitor/monitor.h" >>>>>> #include "hw/scsi/scsi.h" >>>>>> #include "hw/virtio/virtio-blk.h" >>>>>> +#include "hw/virtio/virtio-scsi.h" >>>>>> +#include "hw/virtio/virtio-pci.h" >>>>>> #include "qemu/config-file.h" >>>>>> #include "sysemu/blockdev.h" >>>>>> #include "qapi/error.h" >>>>>> @@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter, >>>>>> { >>>>>> SCSIBus *scsibus; >>>>>> SCSIDevice *scsidev; >>>>>> + VirtIOPCIProxy *virtio_proxy; >>>>>> >>>>>> scsibus = (SCSIBus *) >>>>>> object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)), >>>>>> TYPE_SCSI_BUS); >>>>>> if (!scsibus) { >>>>>> - error_report("Device is not a SCSI adapter"); >>>>>> - return -1; >>>>>> + /* >>>>>> + * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add >>>>>> + * to the virtio-scsi-device. >>>>>> + */ >>>>>> + if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) { >>>>>> + error_report("Device is not a SCSI adapter"); >>>>>> + return -1; >>>>>> + } >>>>>> + virtio_proxy = VIRTIO_PCI(adapter); >>>>>> + adapter = DEVICE(virtio_proxy->bus.vdev); >>>>>> + scsibus = (SCSIBus *) >>>>>> + object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)), >>>>>> + TYPE_SCSI_BUS); >>>>>> + assert(scsibus); >>>>>> } >>>>>> >>>>>> /* -- Alexey