Skip to content

Commit 1c10d00

Browse files
author
Anthony Xu
committed
avoid to create same FileSR on host more than once
1 parent fc8e79c commit 1c10d00

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer620Resource.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected void waitForTask(Connection c, Task task, long pollInterval, long time
127127
@SuppressWarnings("unchecked")
128128
Set<Event.Record> events = (Set<Event.Record>)map.get("events");
129129
if (events.size() == 0) {
130-
String msg = "Async " + timeout / 1000 + " seconds timeout for task " + task.toString();
130+
String msg = "No event for task " + task.toString();
131131
s_logger.warn(msg);
132132
task.cancel(c);
133133
throw new TimeoutException(msg);
@@ -144,11 +144,14 @@ protected void waitForTask(Connection c, Task task, long pollInterval, long time
144144

145145
if (taskRecord.status != Types.TaskStatusType.PENDING) {
146146
if (s_logger.isDebugEnabled()) {
147-
s_logger.debug("Task is done " + taskRecord.status);
147+
s_logger.debug("Task: " + taskRecord.uuid + " is done " + taskRecord.status);
148148
}
149149
return;
150150
} else {
151-
s_logger.debug("Task is not done " + taskRecord);
151+
if (s_logger.isDebugEnabled()) {
152+
s_logger.debug("Task: " + taskRecord.uuid + " progress: " + taskRecord.progress);
153+
}
154+
152155
}
153156
}
154157
if (System.currentTimeMillis() - beginTime > timeout) {

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/Xenserver625StorageProcessor.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,19 @@ protected SR createFileSR(Connection conn, String path) {
8686
SR sr = null;
8787
PBD pbd = null;
8888
try {
89+
String srname = hypervisorResource.getHost().uuid + path.trim();
90+
try {
91+
Set<SR> srs = SR.getByNameLabel(conn, srname);
92+
if ( srs != null && !srs.isEmpty()) {
93+
return srs.iterator().next();
94+
}
95+
} catch (Exception e) {
96+
}
8997
Map<String, String> smConfig = new HashMap<String, String>();
9098
Host host = Host.getByUuid(conn, hypervisorResource.getHost().uuid);
9199
String uuid = UUID.randomUUID().toString();
92100

93-
sr = SR.introduce(conn,uuid, uuid, uuid, "file", "file", false, smConfig);
101+
sr = SR.introduce(conn,uuid, srname, srname, "file", "file", false, smConfig);
94102
PBD.Record record = new PBD.Record();
95103
record.host = host;
96104
record.SR = sr;

0 commit comments

Comments
 (0)