[libvirt] [PATCH v2 09/12] conf: Add SCSI hostdev check for disk drive address already in use

Ján Tomko jtomko at redhat.com
Mon Aug 3 13:46:28 UTC 2015


On Wed, Jul 22, 2015 at 10:54:31AM -0400, John Ferlan wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1210587  (partial)
> 
> If a SCSI subsystem <hostdev> element address is provided, we need to
> make sure the address provided doesn't conflict with an existing or
> libvirt generated address for a SCSI <disk> element.
> 
> This will fix the issue where the domain XML provided an <address> for
> the <hostdev>, but not the <disk> element where the address provided
> ends up being the same address used for the <disk>. A <disk> address
> is generated using it's assigned <target> 'dev' name prior to the
> check/validation of the <hostdev> address value.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/conf/domain_conf.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 44ce71b..eba264d 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -11872,7 +11872,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
>  }
>  
>  static virDomainHostdevDefPtr
> -virDomainHostdevDefParseXML(const virDomainDef *vmdef ATTRIBUTE_UNUSED,
> +virDomainHostdevDefParseXML(const virDomainDef *vmdef,
>                              xmlNodePtr node,
>                              xmlXPathContextPtr ctxt,
>                              virHashTablePtr bootHash,
> @@ -11939,6 +11939,26 @@ virDomainHostdevDefParseXML(const virDomainDef *vmdef ATTRIBUTE_UNUSED,
>                                 _("SCSI host device must use 'drive' "
>                                   "address type"));
>                  goto error;
> +            } else if (def->info->type ==
> +                       VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
> +                /* Ensure provided address doesn't conflict with existing
> +                 * scsi disk drive address
> +                 */
> +                virDomainDeviceDriveAddressPtr addr = &def->info->addr.drive;
> +                if (virDomainDriveAddressIsUsedByDisk(vmdef,
> +                                                      VIR_DOMAIN_DISK_BUS_SCSI,
> +                                                      addr->controller,
> +                                                      addr->bus,
> +                                                      addr->target,
> +                                                      addr->unit)) {

This check seems out of place in HostdevDefParse. It also does not
check for conflicts with other hostdevs.

Jan

> +                    virReportError(VIR_ERR_XML_ERROR,
> +                                   _("SCSI host address controller='%u' "
> +                                     "bus='%u' target='%u' unit='%u' in "
> +                                     "use by a SCSI disk"),
> +                                   addr->controller, addr->bus,
> +                                   addr->target, addr->unit);
> +                    goto error;
> +                }
>              }
>  
>              if (virXPathBoolean("boolean(./readonly)", ctxt))
> -- 
> 2.1.0
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150803/13e1458b/attachment-0001.sig>


More information about the libvir-list mailing list