Re: [PATCH v1 15/19] conf: Create vhost-scsi hostdev protocol in dumpxml

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

 



On 25.07.2016 22:48, Eric Farman wrote:
> When issuing virsh dumpxml and parsing a hostdev element,
> the vhost-scsi protocol needs to be handled separately from
> the existing options, to create valid XML.
> 
> Signed-off-by: Eric Farman <farman@xxxxxxxxxxxxxxxxxx>
> Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
> ---
>  src/conf/domain_conf.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)

Yet again, this should go into very same patch that changes the parser.

> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b67d0ea..79087b2 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -20441,6 +20441,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
>      virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
>      virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
>      virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
> +    virDomainHostdevSubsysSCSIVhostPtr vhostsrc = &scsisrc->u.vhost;
>  
>      if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
>          pcisrc->backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
> @@ -20470,13 +20471,22 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
>              virBufferAddLit(buf, " missing='yes'");
>      }
>  
> -    if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
> -        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
> +    if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
>          const char *protocol =
>              virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protocol);
>  
> -        virBufferAsprintf(buf, " protocol='%s' name='%s'",
> -                          protocol, iscsisrc->path);
> +        switch (scsisrc->protocol) {

The idea of switch() is that compiler will check for all the missing
enum members. For some reasons, we store @protocol as int, therefore you
should type cast this to virDomainHostdevSCSIProtocolType and drop the
'default' label. Next time somebody is introducing new SCSI protocol,
they will thank you because compiler will identify majority of the
places they need too look at.

> +        case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
> +            virBufferAsprintf(buf, " protocol='%s' name='%s'",
> +                              protocol, iscsisrc->path);
> +            break;
> +        case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST:
> +            virBufferAsprintf(buf, " protocol='%s' wwpn='%s'",
> +                              protocol, vhostsrc->wwpn);
> +            break;
> +        default:
> +            break;
> +        }
>      }
>  
>      virBufferAddLit(buf, ">\n");
> @@ -20522,6 +20532,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
>              virBufferEscapeString(buf, " name='%s'", iscsisrc->hosts[0].name);
>              virBufferEscapeString(buf, " port='%s'", iscsisrc->hosts[0].port);
>              virBufferAddLit(buf, "/>\n");
> +        } else if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST) {
> +            /* Nothing to do here */
>          } else {
>              virBufferAsprintf(buf, "<adapter name='%s'/>\n",
>                                scsihostsrc->adapter);
> 


Michal

--
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]