From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTcIj-00060a-FR for qemu-devel@nongnu.org; Mon, 06 Jun 2011 12:05:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTcIg-0000OF-HI for qemu-devel@nongnu.org; Mon, 06 Jun 2011 12:05:12 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:51045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTcIf-0000FC-91 for qemu-devel@nongnu.org; Mon, 06 Jun 2011 12:05:09 -0400 Received: by mail-pz0-f45.google.com with SMTP id 30so2107087pzk.4 for ; Mon, 06 Jun 2011 09:05:08 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 6 Jun 2011 18:04:17 +0200 Message-Id: <1307376262-1255-9-git-send-email-pbonzini@redhat.com> In-Reply-To: <1307376262-1255-1-git-send-email-pbonzini@redhat.com> References: <1307376262-1255-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [RFC PATCH v2 08/13] scsi: introduce the scsi-path device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This introduces a device that dispatches SCSI requests according to the "target" field of a hierarchical LUN. The device does not have to do any processing: requests are always forwarded to a target. Signed-off-by: Paolo Bonzini --- Makefile.objs | 2 +- hw/scsi-luns.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletions(-) create mode 100644 hw/scsi-luns.c diff --git a/Makefile.objs b/Makefile.objs index 90838f6..90940d3 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -85,7 +85,7 @@ common-obj-$(CONFIG_MAX111X) += max111x.o common-obj-$(CONFIG_DS1338) += ds1338.o common-obj-y += i2c.o smbus.o smbus_eeprom.o common-obj-y += eeprom93xx.o -common-obj-y += scsi-disk.o cdrom.o +common-obj-y += scsi-disk.o cdrom.o scsi-luns.o common-obj-y += scsi-generic.o scsi-bus.o common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o common-obj-y += usb-serial.o usb-net.o usb-bus.o usb-desc.o diff --git a/hw/scsi-luns.c b/hw/scsi-luns.c new file mode 100644 index 0000000..699e3c1 --- /dev/null +++ b/hw/scsi-luns.c @@ -0,0 +1,42 @@ +/* + * SCSI Device emulation + * + * Copyright (c) 2011 Red Hat, Inc. + * + * Author: Paolo Bonzini . + * + * This code is licenced under the LGPL. + */ + +#include "qemu-common.h" +#include "qemu-error.h" +#include "scsi.h" +#include "sysemu.h" + +static struct SCSIBusOps path_scsi_ops = { + .decode_lun = scsi_decode_target_from_lun +}; + +static int scsi_path_initfn(SCSIDevice *s) +{ + s->children = qemu_mallocz(sizeof(SCSIBus)); + scsi_bus_new(s->children, &s->qdev, 1, MAX_SCSI_DEVS, + &path_scsi_ops); + return 0; +} + +static SCSIDeviceInfo scsi_path_info = { + .qdev.name = "scsi-path", + .qdev.desc = "SCSI initiator device connected to multiple targets", + .qdev.size = sizeof(SCSIDevice), + .init = scsi_path_initfn, + .qdev.props = (Property[]) { + DEFINE_PROP_END_OF_LIST(), + }, +}; + +static void scsi_luns_register_devices(void) +{ + scsi_qdev_register(&scsi_path_info); +} +device_init(scsi_luns_register_devices) -- 1.7.4.4