Skip to content

Commit 6841e26

Browse files
Edison SuEdison Su
authored andcommitted
bug 10330: finally merge Rommer's CLVM patch
status 10330: resolved fixed
1 parent 1e86b5e commit 6841e26

31 files changed

Lines changed: 566 additions & 218 deletions

agent-simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public BackupSnapshotAnswer BackupSnapshot(BackupSnapshotCommand cmd, SimulatorI
416416
return new BackupSnapshotAnswer(cmd, false, "can't find snapshot" + snapshotPath, null, true);
417417
}
418418

419-
String secStorageUrl = cmd.getSecondaryStoragePoolURL();
419+
String secStorageUrl = cmd.getSecondaryStorageUrl();
420420
MockSecStorageVO secStorage = _mockSecStorageDao.findByUrl(secStorageUrl);
421421
if (secStorage == null) {
422422
return new BackupSnapshotAnswer(cmd, false, "can't find sec storage" + snapshotPath, null, true);
@@ -613,7 +613,7 @@ public CreatePrivateTemplateAnswer CreatePrivateTemplateFromSnapshot(CreatePriva
613613
}
614614
}
615615

616-
MockSecStorageVO sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStoragePoolURL());
616+
MockSecStorageVO sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStorageUrl());
617617
if (sec == null) {
618618
return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
619619
}
@@ -654,7 +654,7 @@ public CreatePrivateTemplateAnswer CreatePrivateTemplateFromVolume(CreatePrivate
654654
return new CreatePrivateTemplateAnswer(cmd, false, "cant' find volume" + cmd.getVolumePath());
655655
}
656656

657-
MockSecStorageVO sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStoragePoolURL());
657+
MockSecStorageVO sec = _mockSecStorageDao.findByUrl(cmd.getSecondaryStorageUrl());
658658
if (sec == null) {
659659
return new CreatePrivateTemplateAnswer(cmd, false, "can't find secondary storage");
660660
}

agent/src/com/cloud/agent/resource/computing/CloudZonesComputingResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ protected synchronized StartAnswer execute(StartCommand cmd) {
194194
// Attach each data volume to the VM, if there is a deferred attached disk
195195
for (DiskDef disk : vm.getDevices().getDisks()) {
196196
if (disk.isAttachDeferred()) {
197-
attachOrDetachDisk(conn, true, vmName, disk.getDiskPath(), disk.getDiskSeq());
197+
attachOrDetachDevice(conn, true, vmName, disk.toString());
198198
}
199199
}
200200

agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java

Lines changed: 218 additions & 121 deletions
Large diffs are not rendered by default.

agent/src/com/cloud/agent/resource/computing/LibvirtDomainXMLParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public boolean parseDomainXML(String domXML) {
7171
Element disk = (Element)disks.item(i);
7272
String diskFmtType = getAttrValue("driver", "type", disk);
7373
String diskFile = getAttrValue("source", "file", disk);
74+
String diskDev = getAttrValue("source", "dev", disk);
75+
7476
String diskLabel = getAttrValue("target", "dev", disk);
7577
String bus = getAttrValue("target", "bus", disk);
7678
String type = disk.getAttribute("type");
@@ -87,6 +89,8 @@ public boolean parseDomainXML(String domXML) {
8789
} else if (device.equalsIgnoreCase("cdrom")) {
8890
def.defISODisk(diskFile);
8991
}
92+
} else if (type.equalsIgnoreCase("block")) {
93+
def.defBlockBasedDisk(diskDev, diskLabel, DiskDef.diskBus.valueOf(bus.toUpperCase()));
9094
}
9195
diskDefs.add(def);
9296
}

agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeDef.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public enum volFormat {
3131
public String toString() {
3232
return _format;
3333
}
34+
35+
public static volFormat getFormat(String format) {
36+
if (format == null) {
37+
return null;
38+
}
39+
if (format.equalsIgnoreCase("raw")) {
40+
return RAW;
41+
} else if (format.equalsIgnoreCase("qcow2")) {
42+
return QCOW2;
43+
}
44+
return null;
45+
}
3446
}
3547
private String _volName;
3648
private Long _volSize;

agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeXMLParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public LibvirtStorageVolumeDef parseStorageVolumeXML(String volXML) {
3232
Element target = (Element)rootElement.getElementsByTagName("target").item(0);
3333
String format = getAttrValue("type", "format", target);
3434
Long capacity = Long.parseLong(getTagValue("capacity", rootElement));
35-
return new LibvirtStorageVolumeDef(VolName, capacity, LibvirtStorageVolumeDef.volFormat.QCOW2, null, null);
35+
return new LibvirtStorageVolumeDef(VolName, capacity, LibvirtStorageVolumeDef.volFormat.getFormat(format), null, null);
3636
} catch (ParserConfigurationException e) {
3737
s_logger.debug(e.toString());
3838
} catch (SAXException e) {

agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,14 @@ public void defBlockBasedDisk(String diskName, int devId, diskBus bus) {
345345
_diskLabel = getDevLabel(devId, bus);
346346
_bus = bus;
347347
}
348+
public void defBlockBasedDisk(String diskName, String diskLabel, diskBus bus) {
349+
_diskType = diskType.BLOCK;
350+
_deviceType = deviceType.DISK;
351+
_diskFmtType = diskFmtType.RAW;
352+
_sourcePath = diskName;
353+
_diskLabel = diskLabel;
354+
_bus = bus;
355+
}
348356
public void setReadonly() {
349357
_readonly = true;
350358
}

agent/src/com/cloud/agent/storage/KVMPhysicalDisk.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ public class KVMPhysicalDisk {
55
private String name;
66
private KVMStoragePool pool;
77
public static enum PhysicalDiskFormat {
8-
RAW,
9-
QCOW2
8+
RAW("raw"),
9+
QCOW2("qcow2");
10+
String format;
11+
private PhysicalDiskFormat(String format) {
12+
this.format = format;
13+
}
14+
public String toString() {
15+
return this.format;
16+
}
1017
}
1118
private PhysicalDiskFormat format;
1219
private long size;

agent/src/com/cloud/agent/storage/KVMStoragePool.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ public interface KVMStoragePool {
1818
public boolean isExternalSnapshot();
1919
public String getLocalPath();
2020
public StoragePoolType getType();
21+
public boolean delete();
22+
PhysicalDiskFormat getDefaultFormat();
2123
}

agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,6 @@ public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot, String s
7474
public KVMPhysicalDisk getPhysicalDiskFromUrl(String url) {
7575
return this._storageAdaptor.getPhysicalDiskFromURI(url);
7676
}
77+
78+
7779
}

0 commit comments

Comments
 (0)