Skip to content

Commit

Permalink
kvm: add more volume info to KVMPhysicalDisk
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Aug 14, 2024
1 parent 50c723c commit c118e98
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

public class KVMPhysicalDisk {
private String path;
private String name;
private KVMStoragePool pool;
private final String name;
private final KVMStoragePool pool;
private String dispName;
private String vmName;
private boolean useAsTemplate;

public static String RBDStringBuilder(String monHost, int monPort, String authUserName, String authSecret, String image) {
Expand Down Expand Up @@ -81,7 +83,9 @@ public KVMPhysicalDisk(String path, String name, KVMStoragePool pool) {

@Override
public String toString() {
return "KVMPhysicalDisk [path=" + path + ", name=" + name + ", pool=" + pool + ", format=" + format + ", size=" + size + ", virtualSize=" + virtualSize + "]";
return "KVMPhysicalDisk [path=" + path + ", name=" + name + ", pool=" + pool +
", format=" + format + ", size=" + size + ", virtualSize=" + virtualSize +
", dispName=" + dispName + ", vmName=" + vmName + "]";
}

public void setFormat(PhysicalDiskFormat format) {
Expand Down Expand Up @@ -135,4 +139,20 @@ public void setQemuEncryptFormat(QemuObject.EncryptFormat format) {
public void setUseAsTemplate() { this.useAsTemplate = true; }

public boolean useAsTemplate() { return this.useAsTemplate; }

public String getDispName() {
return dispName;
}

public void setDispName(String dispName) {
this.dispName = dispName;
}

public String getVmName() {
return vmName;
}

public void setVmName(String vmName) {
this.vmName = vmName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd) {
if (!storagePoolMgr.connectPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), path, details)) {
s_logger.warn("Failed to connect new volume at path: " + path + ", in storage pool id: " + primaryStore.getUuid());
}
BaseVol.setDispName(template.getName());

vol = storagePoolMgr.copyPhysicalDisk(BaseVol, path != null ? path : volume.getUuid(), primaryPool, cmd.getWaitInMillSeconds(), null, volume.getPassphrase(), volume.getProvisioningType());

Expand Down Expand Up @@ -524,6 +525,8 @@ public Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd) {
final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(srcVolumeName);

volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
volume.setDispName(srcVol.getName());
volume.setVmName(srcVol.getVmName());

final KVMPhysicalDisk newDisk = storagePoolMgr.copyPhysicalDisk(volume, path != null ? path : volumeName, primaryPool, cmd.getWaitInMillSeconds());

Expand Down Expand Up @@ -2486,6 +2489,8 @@ public Answer copyVolumeFromPrimaryToPrimary(CopyCommand cmd) {
}

volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
volume.setDispName(srcVol.getName());
volume.setVmName(srcVol.getVmName());

String destVolumeName = null;
if (destPrimaryStore.isManaged()) {
Expand Down

0 comments on commit c118e98

Please sign in to comment.