"scsi",
"storage",
"fc_host",
- "vports")
+ "vports",
+ "scsi_generic")
VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST,
"80203",
virBufferAddLit(&buf,
" <capability type='hotpluggable' />\n");
break;
+ case VIR_NODE_DEV_CAP_SCSI_GENERIC:
+ virBufferEscapeString(&buf, " <char>%s</char>\n",
+ data->sg.path);
+ break;
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_LAST:
VIR_FREE(data->storage.serial);
VIR_FREE(data->storage.media_label);
break;
+ case VIR_NODE_DEV_CAP_SCSI_GENERIC:
+ VIR_FREE(data->sg.path);
+ break;
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_LAST:
VIR_NODE_DEV_CAP_STORAGE, /* Storage device */
VIR_NODE_DEV_CAP_FC_HOST, /* FC Host Bus Adapter */
VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */
+ VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */
+
VIR_NODE_DEV_CAP_LAST
};
char *media_label;
unsigned int flags; /* virNodeDevStorageCapFlags bits */
} storage;
+ struct {
+ char *path;
+ } sg; /* SCSI generic device */
} data;
virNodeDevCapsDefPtr next; /* next capability */
};
return ret;
}
+static int
+udevProcessScsiGeneric(struct udev_device *dev,
+ virNodeDeviceDefPtr def)
+{
+ if (udevGetStringProperty(dev,
+ "DEVNAME",
+ &def->caps->data.sg.path) != PROPERTY_FOUND)
+ return -1;
+
+ if (udevGenerateDeviceName(dev, def, NULL) != 0)
+ return -1;
+
+ return 0;
+}
+
static bool
udevHasDeviceProperty(struct udev_device *dev,
const char *key)
enum virNodeDevCapType *type)
{
const char *devtype = NULL;
+ char *subsystem = NULL;
int ret = -1;
devtype = udev_device_get_devtype(device);
* property exists, we have a network device. */
if (udevHasDeviceProperty(device, "INTERFACE"))
*type = VIR_NODE_DEV_CAP_NET;
+
+ /* SCSI generic device doesn't set DEVTYPE property */
+ if (udevGetStringProperty(device, "SUBSYSTEM", &subsystem) ==
+ PROPERTY_FOUND &&
+ STREQ(subsystem, "scsi_generic"))
+ *type = VIR_NODE_DEV_CAP_SCSI_GENERIC;
+ VIR_FREE(subsystem);
}
if (!*type)
case VIR_NODE_DEV_CAP_STORAGE:
ret = udevProcessStorage(device, def);
break;
+ case VIR_NODE_DEV_CAP_SCSI_GENERIC:
+ ret = udevProcessScsiGeneric(device, def);
+ break;
default:
VIR_ERROR(_("Unknown device type %d"), def->caps->type);
ret = -1;