mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
* src/storage_backend_scsi.[ch]: add SCSI storage rescan support,
patch by David Allan daniel
This commit is contained in:
parent
8536e697b6
commit
b2df3510b7
@ -1,3 +1,8 @@
|
|||||||
|
Tue Apr 7 14:48:35 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/storage_backend_scsi.[ch]: add SCSI storage rescan support,
|
||||||
|
patch by David Allan
|
||||||
|
|
||||||
Fri Apr 3 16:47:22 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
Fri Apr 3 16:47:22 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* configure.in libvirt.spec.in NEWS docs/*: release of 0.6.2
|
* configure.in libvirt.spec.in NEWS docs/*: release of 0.6.2
|
||||||
|
@ -565,6 +565,53 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virStorageBackendSCSITriggerRescan(virConnectPtr conn,
|
||||||
|
uint32_t host)
|
||||||
|
{
|
||||||
|
int fd = -1;
|
||||||
|
int retval = 0;
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
VIR_DEBUG(_("Triggering rescan of host %d"), host);
|
||||||
|
|
||||||
|
if (virAsprintf(&path, "/sys/class/scsi_host/host%u/scan", host) < 0) {
|
||||||
|
virReportOOMError(conn);
|
||||||
|
retval = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_DEBUG(_("Scan trigger path is '%s'"), path);
|
||||||
|
|
||||||
|
fd = open(path, O_WRONLY);
|
||||||
|
|
||||||
|
if (fd < 0) {
|
||||||
|
virReportSystemError(conn, errno,
|
||||||
|
_("Could not open '%s' to trigger host scan"),
|
||||||
|
path);
|
||||||
|
retval = -1;
|
||||||
|
goto free_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (safewrite(fd,
|
||||||
|
LINUX_SYSFS_SCSI_HOST_SCAN_STRING,
|
||||||
|
sizeof(LINUX_SYSFS_SCSI_HOST_SCAN_STRING)) < 0) {
|
||||||
|
|
||||||
|
virReportSystemError(conn, errno,
|
||||||
|
_("Write to '%s' to trigger host scan failed"),
|
||||||
|
path);
|
||||||
|
retval = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
free_path:
|
||||||
|
VIR_FREE(path);
|
||||||
|
out:
|
||||||
|
VIR_DEBUG(_("Rescan of host %d complete"), host);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageBackendSCSIRefreshPool(virConnectPtr conn,
|
virStorageBackendSCSIRefreshPool(virConnectPtr conn,
|
||||||
virStoragePoolObjPtr pool)
|
virStoragePoolObjPtr pool)
|
||||||
@ -575,13 +622,19 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn,
|
|||||||
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
|
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
|
||||||
|
|
||||||
if (sscanf(pool->def->source.adapter, "host%u", &host) != 1) {
|
if (sscanf(pool->def->source.adapter, "host%u", &host) != 1) {
|
||||||
VIR_DEBUG(_("Failed to get host number from '%s'"), pool->def->source.adapter);
|
VIR_DEBUG(_("Failed to get host number from '%s'"),
|
||||||
|
pool->def->source.adapter);
|
||||||
retval = -1;
|
retval = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG(_("Scanning host%u"), host);
|
VIR_DEBUG(_("Scanning host%u"), host);
|
||||||
|
|
||||||
|
if (virStorageBackendSCSITriggerRescan(conn, host) < 0) {
|
||||||
|
retval = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
virStorageBackendSCSIFindLUs(conn, pool, host);
|
virStorageBackendSCSIFindLUs(conn, pool, host);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host"
|
#define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host"
|
||||||
#define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
|
#define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
|
||||||
|
#define LINUX_SYSFS_SCSI_HOST_SCAN_STRING "- - -"
|
||||||
|
|
||||||
extern virStorageBackend virStorageBackendSCSI;
|
extern virStorageBackend virStorageBackendSCSI;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user