On 2013年03月04日 14:01, Han Cheng wrote:
---
docs/formatdomain.html.in | 36 ++++++++++++++++----
tests/qemuhelpdata/qemu-1.0-device | 10 +++++
tests/qemuhelpdata/qemu-1.1.0-device | 10 +++++
tests/qemuhelpdata/qemu-1.2.0-device | 5 +++
tests/qemuhelpdata/qemu-kvm-1.2.0-device | 5 +++
tests/qemuhelptest.c | 19 ++++++++---
.../qemuxml2argv-hostdev-scsi-address-boot.args | 9 +++++
.../qemuxml2argv-hostdev-scsi-address-boot.xml | 34 ++++++++++++++++++
...qemuxml2argv-hostdev-scsi-address-readonly.args | 9 +++++
.../qemuxml2argv-hostdev-scsi-address-readonly.xml | 35 +++++++++++++++++++
.../qemuxml2argv-hostdev-scsi-address.args | 9 +++++
.../qemuxml2argv-hostdev-scsi-address.xml | 34 ++++++++++++++++++
tests/qemuxml2argvtest.c | 12 ++++++
tests/qemuxml2xmltest.c | 4 ++
14 files changed, 219 insertions(+), 12 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.xml
create mode 100644
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.args
create mode 100644
tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
Oh, these stuffs should be foldered into the previous XML parsing
and formating patches.
index 1835b39..57a2e8a 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2136,13 +2136,13 @@
<h4><a name="elementsHostDev">Host device
assignment</a></h4>
-<h5><a href="elementsHostDevSubsys">USB / PCI
devices</a></h5>
+<h5><a href="elementsHostDevSubsys">USB / PCI /SCSI
devices</a></h5>
<p>
- USB and PCI devices attached to the host can be passed through
+ USB, PCI and SCSI devices attached to the host can be passed through
to the guest using the<code>hostdev</code> element.
-<span class="since">since after 0.4.4 for USB and 0.6.0 for PCI
- (KVM only)</span>:
+<span class="since">since after 0.4.4 for USB, 0.6.0 for PCI and
+ 0.13.0 for SCSI(KVM only)</span>:
</p>
<pre>
@@ -2168,17 +2168,34 @@
<address bus='0x06' slot='0x02'
function='0x0'/>
</source>
<boot order='1'/>
+<readonly/>
This should be in 1/5. Others should be in 2/5, or you can just
merge 1/5 and 2/5 together, with these docs.
<rom bar='on'
file='/etc/fake/boot.bin'/>
</hostdev>
</devices>
...</pre>
+<p>or:</p>
+
+<pre>
+ ...
+<devices>
+<hostdev mode='subsystem' type='scsi'>
+<source>
+<adapter name='scsi_host0'/>
+<address type='scsi' bus='0' target='0'
unit='0'/>
+</source>
+<address type='scsi' controller= '0' bus='0'
target='0' unit='0'/>
+</hostdev>
+</devices>
+ ...</pre>
+
<dl>
<dt><code>hostdev</code></dt>
<dd>The<code>hostdev</code> element is the main container for
describing
host devices. For usb device passthrough<code>mode</code> is
always
- "subsystem" and<code>type</code> is "usb" for a
USB device and "pci"
- for a PCI device. When<code>managed</code> is "yes" for a
PCI
+ "subsystem" and<code>type</code> is "usb" for
a USB device, "pci"
+ for a PCI device and "scsi" for a SCSI device. When
+<code>managed</code> is "yes" for a PCI
device, it is detached from the host before being passed on to
the guest, and reattached to the host after the guest exits.
If<code>managed</code> is omitted or "no", and for USB
@@ -2188,7 +2205,8 @@
hot-plugging the device,
and<code>virNodeDeviceReAttach</code> (or<code>virsh
nodedev-reattach</code>) after hot-unplug or stopping the
- guest.</dd>
+ guest.For SCSI device, user is responsible to make sure do not
+ use this device</dd>
<dt><code>source</code></dt>
<dd>The source element describes the device as seen from the host.
The USB device can either be addressed by vendor / product id using the
@@ -2221,6 +2239,9 @@
<code>id</code> attribute that specifies the USB vendor and product
id.
The ids can be given in decimal, hexadecimal (starting with 0x) or
octal (starting with 0) form.</dd>
+<dt><code>readonly</code></dt>
+<dd>Specifies that the device is readonly.
+<span class="since">Since 0.13.0</span> for SCSI devices.
<dt><code>boot</code></dt>
<dd>Specifies that the device is bootable.
The<code>order</code>
attribute determines the order in which devices will be tried during
@@ -2229,6 +2250,7 @@
<a href="#elementsOSBIOS">BIOS bootloader</a> section.
<span class="since">Since 0.8.8</span> for PCI devices,
<span class="since">Since 1.0.1</span> for USB devices.
+<span class="since">Since 1.0.0</span> for SCSI devices.
<dt><code>rom</code></dt>
<dd>The<code>rom</code> element is used to change how a PCI
device's ROM is presented to the guest. The
optional<code>bar</code>
diff --git a/tests/qemuhelpdata/qemu-1.0-device b/tests/qemuhelpdata/qemu-1.0-device
index 0bdfbbd..d557f0e 100644
--- a/tests/qemuhelpdata/qemu-1.0-device
+++ b/tests/qemuhelpdata/qemu-1.0-device
@@ -136,3 +136,13 @@ virtio-net-pci.romfile=string
virtio-net-pci.rombar=uint32
virtio-net-pci.multifunction=on/off
virtio-net-pci.command_serr_enable=on/off
+scsi-generic.drive=drive
+scsi-generic.logical_block_size=uint16
+scsi-generic.physical_block_size=uint16
+scsi-generic.min_io_size=uint16
+scsi-generic.opt_io_size=uint32
+scsi-generic.bootindex=int32
+scsi-generic.discard_granularity=uint32
+scsi-generic.channel=uint32
+scsi-generic.scsi-id=uint32
+scsi-generic.lun=uint32
diff --git a/tests/qemuhelpdata/qemu-1.1.0-device b/tests/qemuhelpdata/qemu-1.1.0-device
index abbf850..7313a34 100644
--- a/tests/qemuhelpdata/qemu-1.1.0-device
+++ b/tests/qemuhelpdata/qemu-1.1.0-device
@@ -158,3 +158,13 @@ scsi-disk.dpofua=on/off
scsi-disk.channel=uint32
scsi-disk.scsi-id=uint32
scsi-disk.lun=uint32
+scsi-generic.drive=drive
+scsi-generic.logical_block_size=blocksize
+scsi-generic.physical_block_size=blocksize
+scsi-generic.min_io_size=uint16
+scsi-generic.opt_io_size=uint32
+scsi-generic.bootindex=int32
+scsi-generic.discard_granularity=uint32
+scsi-generic.channel=uint32
+scsi-generic.scsi-id=uint32
+scsi-generic.lun=uint32
diff --git a/tests/qemuhelpdata/qemu-1.2.0-device b/tests/qemuhelpdata/qemu-1.2.0-device
index 5613e00..40845e4 100644
--- a/tests/qemuhelpdata/qemu-1.2.0-device
+++ b/tests/qemuhelpdata/qemu-1.2.0-device
@@ -208,3 +208,8 @@ usb-host.bootindex=int32
usb-host.pipeline=on/off
usb-host.port=string
usb-host.full-path=on/off
+scsi-generic.drive=drive
+scsi-generic.bootindex=int32
+scsi-generic.channel=uint32
+scsi-generic.scsi-id=uint32
+scsi-generic.lun=uint32
diff --git a/tests/qemuhelpdata/qemu-kvm-1.2.0-device
b/tests/qemuhelpdata/qemu-kvm-1.2.0-device
index 879a049..09e3ef7 100644
--- a/tests/qemuhelpdata/qemu-kvm-1.2.0-device
+++ b/tests/qemuhelpdata/qemu-kvm-1.2.0-device
@@ -220,3 +220,8 @@ usb-host.bootindex=int32
usb-host.pipeline=on/off
usb-host.port=string
usb-host.full-path=on/off
+scsi-generic.drive=drive
+scsi-generic.bootindex=int32
+scsi-generic.channel=uint32
+scsi-generic.scsi-id=uint32
+scsi-generic.lun=uint32
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 720a188..c3516dd 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -506,7 +506,8 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_SCSI_GENERIC);
DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -723,7 +724,9 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_SCSI_GENERIC,
+ QEMU_CAPS_SCSI_HOST_BOOTINDEX);
DO_TEST("qemu-1.1.0", 1001000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -811,7 +814,9 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_SCSI_GENERIC,
+ QEMU_CAPS_SCSI_HOST_BOOTINDEX);
DO_TEST("qemu-1.2.0", 1002000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -910,7 +915,9 @@ mymain(void)
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_SCSI_GENERIC,
+ QEMU_CAPS_SCSI_HOST_BOOTINDEX);
DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -1014,7 +1021,9 @@ mymain(void)
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_SCSI_GENERIC,
+ QEMU_CAPS_SCSI_HOST_BOOTINDEX);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.args
new file mode 100644
index 0000000..d326f13
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.args
IMHO the name should be hostdev-scsi-generic. Or just hostdev-scsi
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -device \
+virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb -drive \
+file=/dev/HostVG/QEMUGuest2,if=none,id=drive-ide0-0-0 -device \
+ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive \
+file=/dev/sg0,if=none,id=drive-hostdev-scsi0-0-0-0 -device \
+scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,drive=drive-hostdev-scsi0-0-0-0,id=hostdev-scsi0-0-0-0,bootindex=1
\
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.xml
new file mode 100644
index 0000000..e3de719
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-boot.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+<name>QEMUGuest2</name>
+<uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+<memory unit='KiB'>219100</memory>
+<currentMemory unit='KiB'>219100</currentMemory>
+<vcpu placement='static'>1</vcpu>
+<os>
+<type arch='i686' machine='pc'>hvm</type>
+</os>
+<clock offset='utc'/>
+<on_poweroff>destroy</on_poweroff>
+<on_reboot>restart</on_reboot>
+<on_crash>destroy</on_crash>
+<devices>
+<emulator>/usr/bin/qemu</emulator>
+<disk type='block' device='disk'>
+<source dev='/dev/HostVG/QEMUGuest2'/>
+<target dev='hda' bus='ide'/>
+<address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+</disk>
+<controller type='scsi' index='0' model='virtio-scsi'/>
+<controller type='usb' index='0'/>
+<controller type='ide' index='0'/>
+<hostdev mode='subsystem' type='scsi' managed='yes'>
+<source>
+<adapter name='scsi_host0'/>
+<address bus='0' target='0' unit='0'/>
+</source>
+<boot order='1'/>
+<address type='drive' controller='0' bus='0'
target='4' unit='8'/>
+</hostdev>
+<memballoon model='virtio'/>
+</devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.args
new file mode 100644
index 0000000..57ecdcb
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \
+-m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
+virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb -drive \
+file=/dev/HostVG/QEMUGuest2,if=none,id=drive-ide0-0-0 -device \
+ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive \
+file=/dev/sg0,if=none,id=drive-hostdev-scsi0-0-0-0,readonly=on -device \
+scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,drive=drive-hostdev-scsi0-0-0-0,id=hostdev-scsi0-0-0-0
\
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.xml
new file mode 100644
index 0000000..11d1712
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address-readonly.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+<name>QEMUGuest2</name>
+<uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+<memory unit='KiB'>219100</memory>
+<currentMemory unit='KiB'>219100</currentMemory>
+<vcpu placement='static'>1</vcpu>
+<os>
+<type arch='i686' machine='pc'>hvm</type>
+<boot dev='hd'/>
+</os>
+<clock offset='utc'/>
+<on_poweroff>destroy</on_poweroff>
+<on_reboot>restart</on_reboot>
+<on_crash>destroy</on_crash>
+<devices>
+<emulator>/usr/bin/qemu</emulator>
+<disk type='block' device='disk'>
+<source dev='/dev/HostVG/QEMUGuest2'/>
+<target dev='hda' bus='ide'/>
+<address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+</disk>
+<controller type='scsi' index='0' model='virtio-scsi'/>
+<controller type='usb' index='0'/>
+<controller type='ide' index='0'/>
+<hostdev mode='subsystem' type='scsi' managed='yes'>
+<source>
+<adapter name='scsi_host0'/>
+<address bus='0' target='0' unit='0'/>
+</source>
+<readonly/>
+<address type='drive' controller='0' bus='0'
target='4' unit='8'/>
+</hostdev>
+<memballoon model='virtio'/>
+</devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.args
new file mode 100644
index 0000000..8c7c5c7
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.args
and hostdev-scsi-generic-readonly, or hostdev-scsi-readonly.
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
+virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb -drive \
+file=/dev/HostVG/QEMUGuest2,if=none,id=drive-ide0-0-0 -device \
+ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive \
+file=/dev/sg0,if=none,id=drive-hostdev-scsi0-0-0-0 -device \
+scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,drive=drive-hostdev-scsi0-0-0-0,id=hostdev-scsi0-0-0-0
\
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.xml
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.xml
new file mode 100644
index 0000000..ccdbb0d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-address.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+<name>QEMUGuest2</name>
+<uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+<memory unit='KiB'>219100</memory>
+<currentMemory unit='KiB'>219100</currentMemory>
+<vcpu placement='static'>1</vcpu>
+<os>
+<type arch='i686' machine='pc'>hvm</type>
+<boot dev='hd'/>
+</os>
+<clock offset='utc'/>
+<on_poweroff>destroy</on_poweroff>
+<on_reboot>restart</on_reboot>
+<on_crash>destroy</on_crash>
+<devices>
+<emulator>/usr/bin/qemu</emulator>
+<disk type='block' device='disk'>
+<source dev='/dev/HostVG/QEMUGuest2'/>
+<target dev='hda' bus='ide'/>
+<address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+</disk>
+<controller type='scsi' index='0' model='virtio-scsi'/>
+<controller type='usb' index='0'/>
+<controller type='ide' index='0'/>
+<hostdev mode='subsystem' type='scsi' managed='yes'>
+<source>
+<adapter name='scsi_host0'/>
+<address bus='0' target='0' unit='0'/>
+</source>
+<address type='drive' controller='0' bus='0'
target='4' unit='8'/>
+</hostdev>
+<memballoon model='virtio'/>
+</devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b6b5489..33fe4f1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -887,6 +887,18 @@ mymain(void)
DO_TEST("virtio-rng-egd", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_EGD);
+ DO_TEST("hostdev-scsi-address",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI_PCI, QEMU_CAPS_SCSI_GENERIC);
Do we need QEMU_CAPS_VIRTIO_SCSI_PCI and QEMU_CAPS_NODEFCONFIG?
+ DO_TEST("hostdev-scsi-address-boot",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI_PCI, QEMU_CAPS_SCSI_GENERIC,
+ QEMU_CAPS_BOOTINDEX, QEMU_CAPS_SCSI_HOST_BOOTINDEX);
Likewise.
+ DO_TEST("hostdev-scsi-address-readonly",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_READONLY,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI_PCI, QEMU_CAPS_SCSI_GENERIC);
Likewise.
+
virObjectUnref(driver.config);
virObjectUnref(driver.caps);
VIR_FREE(map);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index d64960f..773c55f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -261,6 +261,10 @@ mymain(void)
DO_TEST_DIFFERENT("metadata");
+ DO_TEST("hostdev-scsi-address");
+ DO_TEST("hostdev-scsi-address-boot");
+ DO_TEST("hostdev-scsi-address-readonly");
+
virObjectUnref(driver.caps);
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;