if (STRPREFIX(name, "/dev") &&
driver->scsiLockSpaceDir) {
VIR_DEBUG("Trying to find an SCSI ID for %s", name);
- if (virStorageFileGetSCSIKey(name, &newName) < 0)
+ if (virStorageFileGetSCSIKey(name, &newName, false) < 0)
goto cleanup;
if (newName) {
static char *
virStorageBackendSCSISerial(const char *dev)
{
+ int rc;
char *serial = NULL;
-#ifdef WITH_UDEV
- virCommandPtr cmd = virCommandNewArgList(
- "/lib/udev/scsi_id",
- "--replace-whitespace",
- "--whitelisted",
- "--device", dev,
- NULL
- );
-
- /* Run the program and capture its output */
- virCommandSetOutputBuffer(cmd, &serial);
- if (virCommandRun(cmd, NULL) < 0)
- goto cleanup;
-#endif
- if (serial && STRNEQ(serial, "")) {
- char *nl = strchr(serial, '\n');
- if (nl)
- *nl = '\0';
- } else {
- VIR_FREE(serial);
- ignore_value(VIR_STRDUP(serial, dev));
- }
+ rc = virStorageFileGetSCSIKey(dev, &serial, true);
+ if (rc == 0 && serial)
+ return serial;
-#ifdef WITH_UDEV
- cleanup:
- virCommandFree(cmd);
-#endif
+ if (rc == -2)
+ return NULL;
+ ignore_value(VIR_STRDUP(serial, dev));
return serial;
}
/* virStorageFileGetSCSIKey
* @path: Path to the SCSI device
* @key: Unique key to be returned
+ * @ignoreError: Used to not report ENOSYS
*
* Using a udev specific function, query the @path to get and return a
* unique @key for the caller to use.
*/
int
virStorageFileGetSCSIKey(const char *path,
- char **key)
+ char **key,
+ bool ignoreError ATTRIBUTE_UNUSED)
{
int status;
virCommandPtr cmd = virCommandNewArgList("/lib/udev/scsi_id",
}
#else
int virStorageFileGetSCSIKey(const char *path,
- char **key ATTRIBUTE_UNUSED)
+ char **key ATTRIBUTE_UNUSED,
+ bool ignoreError)
{
- virReportSystemError(ENOSYS, _("Unable to get SCSI key for %s"), path);
+ if (!ignoreError)
+ virReportSystemError(ENOSYS, _("Unable to get SCSI key for %s"), path);
return -1;
}
#endif
int virStorageFileGetLVMKey(const char *path,
char **key);
int virStorageFileGetSCSIKey(const char *path,
- char **key);
+ char **key,
+ bool ignoreError);
void virStorageAuthDefFree(virStorageAuthDefPtr def);
virStorageAuthDefPtr virStorageAuthDefCopy(const virStorageAuthDef *src);