]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Build qemu command line for scsi host device
authorHan Cheng <hanc.fnst@cn.fujitsu.com>
Fri, 3 May 2013 18:07:23 +0000 (02:07 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 13 May 2013 10:50:16 +0000 (18:50 +0800)
commit0d70656afded421e434a03c4af4d004a0fbcde47
tree34a5ebdf96c81680716fbf96bbdbe01b3b2c11c4
parent7486584c9f0bd65e11958f5323f644f0f2511bea
qemu: Build qemu command line for scsi host device

Except the scsi host device's controller is "lsilogic", mapping
between the libvirt attributes and scsi-generic properties is:

  libvirt     qemu
-----------------------------------------
  controller  bus ($libvirt_controller.0)
  bus         channel
  target      scsi-id
  unit        lun

For scsi host device with "lsilogic" controller, the mapping is:
('target (libvirt)' must be 0, as it's not used; 'unit (libvirt)
must <= 7).

  libvirt            qemu
----------------------------------------------------------
  controller && bus  bus ($libvirt_controller.$libvirt_bus)
  unit               scsi-id

It's not good to hardcode/hard-check limits of these attributes,
and even worse, these limits are not documented, one has to find
out by either testing or reading the qemu code, I'm looking forward
to qemu expose limits like these one day). For example, exposing
"max_target", "max_lun" for megasas:

static const struct SCSIBusInfo megasas_scsi_info = {
    .tcq = true,
    .max_target = MFI_MAX_LD,
    .max_lun = 255,

    .transfer_data = megasas_xfer_complete,
    .get_sg_list = megasas_get_sg_list,
    .complete = megasas_command_complete,
    .cancel = megasas_command_cancel,
};

Example of the qemu command line (lsilogic controller):

  -drive file=/dev/sg2,if=none,id=drive-hostdev-scsi_host7-0-0-0 \
  -device scsi-generic,bus=scsi0.0,scsi-id=8,\
  drive=drive-hostdev-scsi_host7-0-0-0,id=hostdev-scsi_host7-0-0-0

Example of the qemu command line (virtio-scsi controller):

  -drive file=/dev/sg2,if=none,id=drive-hostdev-scsi_host7-0-0-0 \
  -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=128,lun=128,\
  drive=drive-hostdev-scsi_host7-0-0-0,id=hostdev-scsi_host7-0-0-0

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_command.h
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-scsi.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-scsi.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi.xml [deleted file]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c