Re: [libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view
On Mo, 2013-09-02 at 13:57 +0100, Daniel P. Berrange wrote: On Mon, Sep 02, 2013 at 05:38:42PM +0800, Guannan Ren wrote: usb-bot only supports 16 luns(0~15) and they must be contiguous, (using lun 0 and 2 without 1 doesn't work). In this case qemu doesn't throw an error, we can not find the lun 2 in guests. So Adding a checking function in libvirt to prevent from this case. Hmm, this seems like a problematic restriction. It's how the hardware works. How does this work if we start off a guest with 3 disks attached to the usb-bot SCSI controller. Then hot-unplug the 2nd disk. You can't hotplug individual luns anyway. cheers, Gerd -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view
On Tue, Sep 03, 2013 at 09:51:52AM +0200, Gerd Hoffmann wrote: On Mo, 2013-09-02 at 13:57 +0100, Daniel P. Berrange wrote: On Mon, Sep 02, 2013 at 05:38:42PM +0800, Guannan Ren wrote: usb-bot only supports 16 luns(0~15) and they must be contiguous, (using lun 0 and 2 without 1 doesn't work). In this case qemu doesn't throw an error, we can not find the lun 2 in guests. So Adding a checking function in libvirt to prevent from this case. Hmm, this seems like a problematic restriction. It's how the hardware works. How does this work if we start off a guest with 3 disks attached to the usb-bot SCSI controller. Then hot-unplug the 2nd disk. You can't hotplug individual luns anyway. How does hotplug/unplug work in the context of usb-bot ? AFAIK we need to be able to run device_add usb_bot drive_add file... device_add scsi-hd And the reverse, to unplug it, if we're to have feature parity with usb-storage. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view
Hi, How does this work if we start off a guest with 3 disks attached to the usb-bot SCSI controller. Then hot-unplug the 2nd disk. You can't hotplug individual luns anyway. How does hotplug/unplug work in the context of usb-bot ? AFAIK we need to be able to run device_add usb_bot drive_add file... device_add scsi-hd And the reverse, to unplug it, if we're to have feature parity with usb-storage. Hot-unplug is easy. You can remove the usb-bot device which will also remove all child devices. Hot-plug doesn't work at the moment, and I don't see any obvious way to fix that properly :-( We need some way to hotplug a *group* of devices (usb-bot + all children) as usb-bot itself is hotpluggable but the individual scsi devices connected to it are not. I could allow hotplug on usb-bot as workaround, then you can do stop device_add usb_bot device_add scsi-{hd,cd,whatever} cont but that would be more a gross hack than a solution ... cheers, Gerd -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view
On 09/03/2013 08:06 AM, Gerd Hoffmann wrote: Hi, How does this work if we start off a guest with 3 disks attached to the usb-bot SCSI controller. Then hot-unplug the 2nd disk. You can't hotplug individual luns anyway. How does hotplug/unplug work in the context of usb-bot ? AFAIK we need to be able to run device_add usb_bot drive_add file... device_add scsi-hd And the reverse, to unplug it, if we're to have feature parity with usb-storage. Hot-unplug is easy. You can remove the usb-bot device which will also remove all child devices. Hot-plug doesn't work at the moment, and I don't see any obvious way to fix that properly :-( We need some way to hotplug a *group* of devices (usb-bot + all children) as usb-bot itself is hotpluggable but the individual scsi devices connected to it are not. There is another case where hot-plug/unplug of a group of devices would be useful - if you want to hotplug/unplug a pci passthrough device using vfio *and* that device is a part of an iommu group that contains other devices *and* you're okay with having those other devices assigned to the guest as well *AND* you want to use managed='yes' (where libvirt automatically unbinds the devices from the host driver and binds them to vfio-pci before passing them off to the guest), then you need to be able to plug and unplug all the devices in that iommu group in a single operation, otherwise the plug fails (due to attempting to assign one device in a group when the other devices haven't been bound to vfio-pci or pci-stub). As it stands now you can only hot-plug/unplug with vfio if a device is in an iommu group all by itself, or if you don't use managed='yes', and instead deal with binding the devices to vfio-pci manually. If none of that makes sense, consider yourself lucky :-) I could allow hotplug on usb-bot as workaround, then you can do stop device_add usb_bot device_add scsi-{hd,cd,whatever} cont but that would be more a gross hack than a solution ... cheers, Gerd -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view
usb-bot only supports 16 luns(0~15) and they must be contiguous, (using lun 0 and 2 without 1 doesn't work). In this case qemu doesn't throw an error, we can not find the lun 2 in guests. So Adding a checking function in libvirt to prevent from this case. --- src/conf/domain_conf.c | 59 src/conf/domain_conf.h | 4 src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 32 ++ 4 files changed, 96 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 545c157..84dfe25 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4287,6 +4287,65 @@ virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, return 0; } +bool +virDomainDiskAttachedToUsbbotLunIsContiguous(virDomainDefPtr def) +{ +size_t i; +int controllerModel; +virBitmapPtr units = NULL; +bool is_set = false; +bool ret = false; + +if (!(units = virBitmapNew(SCSI_CONTROLLER_USB_BOT_MODEL_MAX_LUNS))) +goto cleanup; + +for (i = 0; i def-ndisks; i++) { +virDomainDiskDefPtr disk = def-disks[i]; +int unitValue = disk-info.addr.drive.unit; + +if (disk-bus != VIR_DOMAIN_DISK_BUS_SCSI) +continue; + +controllerModel = +virDomainDeviceFindControllerModel(def, disk-info, + VIR_DOMAIN_CONTROLLER_TYPE_SCSI); +if (controllerModel != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) +continue; + +/* usb-bot only supports 16 luns */ +if (unitValue ~0xf) { +virReportError(VIR_ERR_XML_ERROR, + _(The address unit value of disk '%s' is too big), + disk-src); +goto cleanup; +} + +if (virBitmapGetBit(units, unitValue, is_set) == 0 is_set) { +virReportError(VIR_ERR_XML_ERROR, + _(The address unit value of disk '%s' is already used), + disk-src); +goto cleanup; +} + +if (unitValue 0) { +if (virBitmapGetBit(units, unitValue - 1, is_set) == 0 !is_set) { +virReportError(VIR_ERR_XML_ERROR, %s, + _(The address unit value of disk + attached to usb-bot controller is not contiguous)); +goto cleanup; +} +} + +ignore_value(virBitmapSetBit(units, unitValue)); +} + +ret = true; + +cleanup: +virBitmapFree(units); +return ret; +} + static virSecurityLabelDefPtr virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, unsigned int flags) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3e69f84..9e2f477 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -778,6 +778,8 @@ typedef enum { VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST } virDomainControllerModelPCI; +# define SCSI_CONTROLLER_USB_BOT_MODEL_MAX_LUNS 16 + enum virDomainControllerModelSCSI { VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC, @@ -2362,6 +2364,8 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def, int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr def); +bool virDomainDiskAttachedToUsbbotLunIsContiguous(virDomainDefPtr def); + virDomainDiskDefPtr virDomainDiskRemove(virDomainDefPtr def, size_t i); virDomainDiskDefPtr diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 35f0f1b..c1f7da5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -179,6 +179,7 @@ virDomainDeviceFindControllerModel; virDomainDeviceInfoCopy; virDomainDeviceInfoIterate; virDomainDeviceTypeToString; +virDomainDiskAttachedToUsbbotLunIsContiguous; virDomainDiskBusTypeToString; virDomainDiskCacheTypeFromString; virDomainDiskCacheTypeToString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5f08a72..f38e98f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4257,6 +4257,32 @@ qemuBuildDriveDevStr(virDomainDefPtr def, disk-info.addr.drive.controller, disk-info.addr.drive.bus, disk-info.addr.drive.unit); +} else if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) { +if (disk-info.addr.drive.target != 0) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(target must be 0 for controller + model 'usb-bot')); +goto error; +} + +if (disk-device != VIR_DOMAIN_DISK_DEVICE_LUN) { +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) { +if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM) +
Re: [libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view
On Mon, Sep 02, 2013 at 05:38:42PM +0800, Guannan Ren wrote: usb-bot only supports 16 luns(0~15) and they must be contiguous, (using lun 0 and 2 without 1 doesn't work). In this case qemu doesn't throw an error, we can not find the lun 2 in guests. So Adding a checking function in libvirt to prevent from this case. Hmm, this seems like a problematic restriction. How does this work if we start off a guest with 3 disks attached to the usb-bot SCSI controller. Then hot-unplug the 2nd disk. Next time we need will need to start with with LUNs 0 and 2 populated only, otherwise we have ABI change upon migrate or save/restore. I think this restriction about contiguous luns must be removed if this device is to be usable with multiple luns. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list