[libvirt] [PATCH v2 0/2] Fixup SCSI node devices

SCSI targets seem to be missing proper treatment and it was actually not possible to import a SCSI target nodedev device definition because of some typo. In order to extend the test case to catch this, I found that the XML schema was missing as well. Bjoern Walk (2): conf: node_device: fix up SCSI target tests: nodedevxml2xml: add test for SCSI target docs/schemas/nodedev.rng | 11 +++++++++++ src/conf/node_device_conf.c | 2 +- tests/nodedevschemadata/scsi_target0_0_0.xml | 7 +++++++ tests/nodedevxml2xmltest.c | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/nodedevschemadata/scsi_target0_0_0.xml -- 2.6.5

When reading in an XML definition for a SCSI target device, the name property of struct scsi_target refers to the @target element. Let's fix this obvious typo and also extend the XML schema to provide validation. Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- docs/schemas/nodedev.rng | 11 +++++++++++ src/conf/node_device_conf.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 949811c..d937513 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -40,6 +40,7 @@ <ref name="capusbinterface"/> <ref name="capnet"/> <ref name="capscsihost"/> + <ref name="capscsitarget"/> <ref name="capscsi"/> <ref name="capstorage"/> </choice> @@ -382,6 +383,16 @@ </optional> </define> + <define name='capscsitarget'> + <attribute name='type'> + <value>scsi_target</value> + </attribute> + + <element name='target'> + <text/> + </element> + </define> + <define name='capscsi'> <attribute name='type'> <value>scsi</value> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 611045c..f74b34d 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -822,7 +822,7 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctxt, orignode = ctxt->node; ctxt->node = node; - data->scsi_target.name = virXPathString("string(./name[1])", ctxt); + data->scsi_target.name = virXPathString("string(./target[1])", ctxt); if (!data->scsi_target.name) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no target name supplied for '%s'"), -- 2.6.5

Let's add a test for SCSI target nodedev devices. Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- tests/nodedevschemadata/scsi_target0_0_0.xml | 7 +++++++ tests/nodedevxml2xmltest.c | 1 + 2 files changed, 8 insertions(+) create mode 100644 tests/nodedevschemadata/scsi_target0_0_0.xml diff --git a/tests/nodedevschemadata/scsi_target0_0_0.xml b/tests/nodedevschemadata/scsi_target0_0_0.xml new file mode 100644 index 0000000..b83c96d --- /dev/null +++ b/tests/nodedevschemadata/scsi_target0_0_0.xml @@ -0,0 +1,7 @@ +<device> + <name>scsi_target0_0_0</name> + <parent>scsi_host0</parent> + <capability type='scsi_target'> + <target>target0:0:0</target> + </capability> +</device> diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index f519bce..246cec7 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -93,6 +93,7 @@ mymain(void) DO_TEST("pci_8086_0c0c_snd_hda_intel"); DO_TEST("pci_0000_00_02_0_header_type"); DO_TEST("pci_0000_00_1c_0_header_type"); + DO_TEST("scsi_target0_0_0"); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.6.5

On 03/21/2016 10:49 AM, Bjoern Walk wrote:
SCSI targets seem to be missing proper treatment and it was actually not possible to import a SCSI target nodedev device definition because of some typo. In order to extend the test case to catch this, I found that the XML schema was missing as well.
Bjoern Walk (2): conf: node_device: fix up SCSI target tests: nodedevxml2xml: add test for SCSI target
docs/schemas/nodedev.rng | 11 +++++++++++ src/conf/node_device_conf.c | 2 +- tests/nodedevschemadata/scsi_target0_0_0.xml | 7 +++++++ tests/nodedevxml2xmltest.c | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/nodedevschemadata/scsi_target0_0_0.xml
ACK, pushed now Thanks, Cole
participants (2)
-
Bjoern Walk
-
Cole Robinson