Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3121,7 +3121,7 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
}

}

pool.customizeLibvirtDiskDef(disk);
}

if (data instanceof VolumeObjectTO) {
Expand Down Expand Up @@ -3496,6 +3496,7 @@ public synchronized String attachOrDetachDisk(final Connect conn,

diskdef.setPhysicalBlockIOSize(attachingPool.getSupportedPhysicalBlockSize());
diskdef.setLogicalBlockIOSize(attachingPool.getSupportedLogicalBlockSize());
attachingPool.customizeLibvirtDiskDef(diskdef);
}

final String xml = diskdef.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,22 @@ public LibvirtDiskEncryptDetails(String passphraseUuid, QemuObject.EncryptFormat
public QemuObject.EncryptFormat getEncryptFormat() { return this.encryptFormat; }
}

public static class DiskGeometry {
int cylinders;
int heads;
int sectors;

public DiskGeometry(int cylinders, int heads, int sectors) {
this.cylinders = cylinders;
this.heads = heads;
this.sectors = sectors;
}

public String toXml() {
return String.format("<geometry cyls='%d' heads='%d' secs='%d'/>\n", this.cylinders, this.heads, this.sectors);
}
}

public enum DeviceType {
FLOPPY("floppy"), DISK("disk"), CDROM("cdrom"), LUN("lun");
String _type;
Expand Down Expand Up @@ -747,6 +763,7 @@ public String toString() {
private boolean isIothreadsEnabled;
private BlockIOSize logicalBlockIOSize = null;
private BlockIOSize physicalBlockIOSize = null;
private DiskGeometry geometry = null;

public DiscardType getDiscard() {
return _discard;
Expand Down Expand Up @@ -1087,9 +1104,20 @@ public void setSerial(String serial) {
this._serial = serial;
}

public void setLibvirtDiskEncryptDetails(LibvirtDiskEncryptDetails details) { this.encryptDetails = details; }
public void setLibvirtDiskEncryptDetails(LibvirtDiskEncryptDetails details)
{
this.encryptDetails = details;
}

public LibvirtDiskEncryptDetails getLibvirtDiskEncryptDetails()
{
return this.encryptDetails;
}

public LibvirtDiskEncryptDetails getLibvirtDiskEncryptDetails() { return this.encryptDetails; }
public void setGeometry(DiskGeometry geometry)
{
this.geometry = geometry;
}

public String getSourceHost() {
return _sourceHost;
Expand Down Expand Up @@ -1174,6 +1202,10 @@ public String toString() {
}
diskBuilder.append("/>\n");

if (geometry != null) {
diskBuilder.append(geometry.toXml());
}

if (logicalBlockIOSize != null || physicalBlockIOSize != null) {
diskBuilder.append("<blockio ");
if (logicalBlockIOSize != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ default LibvirtVMDef.DiskDef.BlockIOSize getSupportedLogicalBlockSize() {
default LibvirtVMDef.DiskDef.BlockIOSize getSupportedPhysicalBlockSize() {
return null;
}

default void customizeLibvirtDiskDef(LibvirtVMDef.DiskDef disk) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ protected synchronized void attachOrDetachDisk(final Connect conn, final boolean
}
diskdef.setPhysicalBlockIOSize(attachingPool.getSupportedPhysicalBlockSize());
diskdef.setLogicalBlockIOSize(attachingPool.getSupportedLogicalBlockSize());
attachingPool.customizeLibvirtDiskDef(diskdef);
}

attachOrDetachDevice(conn, attach, vmName, diskdef, waitDetachDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ public void testDiskDefWithBlockIO() {
assertEquals(expectedXml, disk.toString());
}

@Test
public void testDiskDefWithGeometry() {
DiskDef disk = new DiskDef();
disk.defBlockBasedDisk("disk1", 1, DiskDef.DiskBus.VIRTIO);
disk.setGeometry(new DiskDef.DiskGeometry(16383, 16, 63));
String expectedXML = "<disk device='disk' type='block'>\n" +
"<driver name='qemu' type='raw' cache='none' />\n" +
"<source dev='disk1'/>\n" +
"<target dev='vdb' bus='virtio'/>\n" +
"<geometry cyls='16383' heads='16' secs='63'/>\n" +
"</disk>\n";
assertEquals(expectedXML, disk.toString());
}

@Test
public void testDiskDefWithMultipleHosts() {
String path = "/mnt/primary1";
Expand Down