Re: [PATCH v4 2/3] hostdev: Add iSCSI hostdev XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/05/2014 05:24 PM, John Ferlan wrote:
> Introduce a new structure to handle an iSCSI host device based on the
> existing virDomainHostdevSubsysSCSI by adding a "protocol='iscsi'" to
> the <source/> element.  The hostdev structure mimics the existing
> <disk/> element for an iSCSI device (network) device. New XML is:
> 
>   <hostdev mode='subsystem' type='scsi' managed='yes'>
>     <source protocol='iscsi' name='iqn.1992-01.com.example'>
>       <host name='example.org' port='3260'/>
>       <auth username='myname'>
>         <secret type='iscsi' usage='mycluster_myname'/>
>       </auth>
>     </source>
>     <address type='drive' controller='0' bus='0' target='2' unit='5'/>
>   </hostdev>
> 
> The controller element will mimic the existing scsi_host code insomuch
> as when 'lsi' and 'virtio-scsi' are used.

Might be worth mentioning that protocol='adapter' was added as an
optional marker of the existing use.

> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
> Changes since v3:
>   * Rework RNG to match comments from review 8/8
>   * Move the <auth> inside the <source>
>   * Modify the tests and html doc to match where the <auth> is found
> 


> +++ b/src/conf/domain_conf.c
> @@ -597,6 +597,11 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend,
>                "vfio",
>                "xen")
>  
> +VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol,
> +              VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
> +              "adapter",
> +              "iscsi")

So 0 == adapter...

> +static int
>  virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
>                                        virDomainHostdevSubsysSCSIPtr scsisrc)
>  {
> -    return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);
> +    char *protocol = NULL;
> +    int ret = -1;
> +
> +    if ((protocol = virXMLPropString(sourcenode, "protocol"))) {
> +        scsisrc->protocol =
> +            virDomainHostdevSubsysSCSIProtocolTypeFromString(protocol);
> +        if (scsisrc->protocol < 0) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                           _("Unknown SCSI subsystem protocol '%s'"),
> +                           protocol);
> +            goto cleanup;
> +        }
> +    }
> +
> +    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
> +        ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc);
> +    else
> +        ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);

so whether the user omitted protocol or specified it as adapter, they
get the old style parse...

> -    if (def->missing &&
> -        !(flags & VIR_DOMAIN_XML_INACTIVE))
> -        virBufferAddLit(buf, " missing='yes'");
> +    if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
> +        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
> +        const char *protocol =
> +            virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protocol);

...but here, you don't output the protocol.  I can live with that (the
alternative would be to always output the protocol, whether or not it
was provided on input, and then touch up existing tests to reflect the
new output; but the end result is the same).

ACK

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]