Re: [libvirt] [PATCH 3/3] domain_conf: Process the "rawio" for a hostdev device

2014-09-18 Thread Michal Privoznik

On 10.09.2014 01:40, John Ferlan wrote:

Add a "rawio" to the hostdev XML and process it mimicing the
disk XML for a lun which supports/requires rawio

Signed-off-by: John Ferlan 
---
  docs/formatdomain.html.in  | 12 ++--
  docs/schemas/domaincommon.rng  | 18 +++
  src/conf/domain_conf.c | 31 +++
  .../qemuxml2argv-hostdev-scsi-rawio.xml| 35 ++
  tests/qemuxml2xmltest.c|  1 +
  5 files changed, 88 insertions(+), 9 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-rawio.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 94236dd..07640af 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1774,7 +1774,7 @@
rawio attribute
since 0.9.10
  
-Indicates whether the disk is needs rawio capability; valid
+Indicates whether the disk needs rawio capability. Valid
  settings are "yes" or "no" (default is "no"). If any one disk
  in a domain has rawio='yes', rawio capability will be enabled
  for all disks in the domain (because, in the case of QEMU, this
@@ -2884,7 +2884,7 @@
  
...

-
+

  
  
@@ -2943,7 +2943,13 @@ (since 1.0.6) attribute indicates whether the kernel will filter unprivileged SG_IO commands for the disk, valid settings are "filtered" or "unfiltered". -The default is "filtered". +The default is "filtered". The optional rawio +(since 1.2.9) attribute indicates +whether the lun needs the rawio capability. Valid settings are +"yes" or "no". See the rawio description within the +disk section. +If a disk lun in the domain already has the rawio capability, +then this setting not required. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index cedceae..84f0b28 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1224,12 +1224,7 @@ - - -yes -no - - + @@ -3608,6 +3603,9 @@ + + + @@ -4972,4 +4970,12 @@ + + + +yes +no + or instead of enumerating the possible values just: + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index aac78a6..c1f23bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4482,6 +4482,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, xmlNodePtr sourcenode; char *managed = NULL; char *sgio = NULL; +char *rawio = NULL; char *backendStr = NULL; int backend; int ret = -1; @@ -4499,6 +4500,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, } sgio = virXMLPropString(node, "sgio"); +rawio = virXMLPropString(node, "rawio"); /* @type is passed in from the caller rather than read from the * xml document, because it is specified in different places for @@ -4550,6 +4552,26 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, } } +if (rawio) { +if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { +virReportError(VIR_ERR_XML_ERROR, "%s", + _("rawio is only supported for scsi host device")); +goto error; +} + +scsisrc->rawio_specified = true; +if (STREQ(rawio, "yes")) { +scsisrc->rawio = 1; +} else if (STREQ(rawio, "no")) { +scsisrc->rawio = 0; +} else { +virReportError(VIR_ERR_XML_ERROR, + _("unknown hostdev rawio setting '%s'"), + rawio); +goto error; +} You can save a few lines if you use the virTristateBoolTypeFromString(). +} + switch (def->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) < 0) @@ -4589,6 +4611,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, error: VIR_FREE(managed); VIR_FREE(sgio); +VIR_FREE(rawio); VIR_FREE(backendStr); return ret; } @@ -17639,6 +17662,14 @@ virDomainHostdevDefFormat(virBufferPtr buf, scsisrc->sgio) virBufferAsprintf(buf, " sgio='%s'",

[libvirt] [PATCH 3/3] domain_conf: Process the "rawio" for a hostdev device

2014-09-09 Thread John Ferlan
Add a "rawio" to the hostdev XML and process it mimicing the
disk XML for a lun which supports/requires rawio

Signed-off-by: John Ferlan 
---
 docs/formatdomain.html.in  | 12 ++--
 docs/schemas/domaincommon.rng  | 18 +++
 src/conf/domain_conf.c | 31 +++
 .../qemuxml2argv-hostdev-scsi-rawio.xml| 35 ++
 tests/qemuxml2xmltest.c|  1 +
 5 files changed, 88 insertions(+), 9 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-rawio.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 94236dd..07640af 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1774,7 +1774,7 @@
   rawio attribute
   since 0.9.10
 
-Indicates whether the disk is needs rawio capability; valid
+Indicates whether the disk needs rawio capability. Valid
 settings are "yes" or "no" (default is "no"). If any one disk
 in a domain has rawio='yes', rawio capability will be enabled
 for all disks in the domain (because, in the case of QEMU, this
@@ -2884,7 +2884,7 @@
 
   ...
   
-
+
   
 
 
@@ -2943,7 +2943,13 @@ (since 1.0.6) attribute indicates whether the kernel will filter unprivileged SG_IO commands for the disk, valid settings are "filtered" or "unfiltered". -The default is "filtered". +The default is "filtered". The optional rawio +(since 1.2.9) attribute indicates +whether the lun needs the rawio capability. Valid settings are +"yes" or "no". See the rawio description within the +disk section. +If a disk lun in the domain already has the rawio capability, +then this setting not required. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index cedceae..84f0b28 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1224,12 +1224,7 @@ - - -yes -no - - + @@ -3608,6 +3603,9 @@ + + + @@ -4972,4 +4970,12 @@ + + + +yes +no + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index aac78a6..c1f23bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4482,6 +4482,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, xmlNodePtr sourcenode; char *managed = NULL; char *sgio = NULL; +char *rawio = NULL; char *backendStr = NULL; int backend; int ret = -1; @@ -4499,6 +4500,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, } sgio = virXMLPropString(node, "sgio"); +rawio = virXMLPropString(node, "rawio"); /* @type is passed in from the caller rather than read from the * xml document, because it is specified in different places for @@ -4550,6 +4552,26 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, } } +if (rawio) { +if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { +virReportError(VIR_ERR_XML_ERROR, "%s", + _("rawio is only supported for scsi host device")); +goto error; +} + +scsisrc->rawio_specified = true; +if (STREQ(rawio, "yes")) { +scsisrc->rawio = 1; +} else if (STREQ(rawio, "no")) { +scsisrc->rawio = 0; +} else { +virReportError(VIR_ERR_XML_ERROR, + _("unknown hostdev rawio setting '%s'"), + rawio); +goto error; +} +} + switch (def->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, def, flags) < 0) @@ -4589,6 +4611,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, error: VIR_FREE(managed); VIR_FREE(sgio); +VIR_FREE(rawio); VIR_FREE(backendStr); return ret; } @@ -17639,6 +17662,14 @@ virDomainHostdevDefFormat(virBufferPtr buf, scsisrc->sgio) virBufferAsprintf(buf, " sgio='%s'", virDomainDeviceSGIOTypeToString(scsisrc->sgio)); + +if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && +scsisrc->rawio_specified) { +if (scsisrc->rawio) +