From c733e973232b6af2a3b72186c530f59793399c12 Mon Sep 17 00:00:00 2001 From: Eric Farman Date: Tue, 16 Jun 2015 23:29:54 -0400 Subject: [PATCH] docs: Fix XML schema handling of LUN address in hostdev tag Defining a domain with a SCSI disk attached via a hostdev tag and a source address unit value longer than two digits causes an error when editing the domain with virsh edit, even if no changes are made to the domain definition. The error suggests invalid XML, somewhere: # virsh edit lmb_guest error: XML document failed to validate against schema: Unable to validate doc against /usr/local/share/libvirt/schemas/domain.rng Extra element devices in interleave Element domain failed to validate content The virt-xml-validate tool fails with a similar error: # virt-xml-validate lmb_guest.xml Relax-NG validity error : Extra element devices in interleave lmb_guest.xml:17: element devices: Relax-NG validity error : Element domain failed to validate content lmb_guest.xml fails to validate The hostdev tag requires a source address to be specified, which includes bus, target, and unit address attributes. According to the SCSI Architecture Model spec (section 4.9 of SAM-2), a LUN address is 64 bits and thus could be up to 20 decimal digits long. Unfortunately, the XML schema limits this string to just two digits. Similarly, the target field can be up to 32 bits in length, which would be 10 decimal digits. # lsscsi -xx [0:0:19:0x4022401100000000] disk IBM 2107900 3.44 /dev/sda # lsscsi [0:0:19:1074872354]disk IBM 2107900 3.44 /dev/sda # cat lmb_guest.xml lmb_guest 1024 ...trimmed...
...trimmed... Since the reference unit and target fields are used in several places in the XML schema, create a separate one specific for SCSI Logical Units that will permit the greater length. This permits both the validation utility and the virsh edit command to succeed when a hostdev tag is included. Signed-off-by: Eric Farman Reviewed-by: Matthew Rosato Reviewed-by: Stefan Zimmermann Reviewed-by: Boris Fiuczynski --- docs/formatdomain.html.in | 9 ++++- docs/schemas/domaincommon.rng | 14 ++++++-- .../qemuxml2argv-hostdev-scsi-large-unit.xml | 35 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-large-unit.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6a524dfdb9..16f7eae253 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3283,7 +3283,14 @@
scsi
SCSI devices are described by both the adapter - and address elements. + and address elements. The address + element includes a bus attribute (a 2-digit bus + number), a target attribute (a 10-digit target + number), and a unit attribute (a 20-digit unit + number on the bus). Not all hypervisors support larger + target and unit values. It is up + to each hypervisor to determine the maximum value supported + for the adapter.

Since 1.2.8, the source element of a SCSI device may contain the protocol diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ca3bcfcb8d..3014365bb5 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3833,10 +3833,10 @@ - + - + @@ -5152,11 +5152,21 @@ [0-9]{1,2} + + + [0-9]{1,10} + + [0-9]{1,2} + + + [0-9]{1,20} + + [a-zA-Z0-9\-_\.]+ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-large-unit.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-large-unit.xml new file mode 100644 index 0000000000..b5efb408ee --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-large-unit.xml @@ -0,0 +1,35 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +

+ + + + + + + + +
+ +
+ + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 3287ea37d5..711827dfe6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -577,6 +577,7 @@ mymain(void) DO_TEST("hostdev-scsi-rawio"); DO_TEST_DIFFERENT("hostdev-scsi-autogen-address"); + DO_TEST("hostdev-scsi-large-unit"); DO_TEST("hostdev-scsi-lsi-iscsi"); DO_TEST("hostdev-scsi-lsi-iscsi-auth");