Skip to content

Commit 3f5f1cc

Browse files
committed
kvm: remove unused private members reported by PMD
Running PMD's UnusedPrivateMethod, UnusedPrivateField and UnusedLocalVariable rules over the module reported these, each verified by hand against the sources and the tests: LibvirtComputingResource: field host, field gson, method executeBashScript, local devNum in configureIpAddresses, local brname in destroyNetworkRulesForVM LibvirtConnection: field s_connection LibvirtStorageAdaptor: field _manageSnapshotPath and its lookup of managesnapshot.sh, which the adaptor never ran LibvirtMigrateCommandWrapper: method isClvmBlockDevice LibvirtCopyToSecondaryStorageWrapper: local success LibvirtCreateDiskOnlyVMSnapshotCommandWrapper: two unused copies of the volume list Left as reported: getPifs and getOvsPifs are called and were flagged in error, and the write-only fields _crash and _readonly in LibvirtVMDef are kept because dropping them would silently turn their setters into no-ops.
1 parent f5ef4e6 commit 3f5f1cc

6 files changed

Lines changed: 0 additions & 23 deletions

File tree

‎plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@
255255
import com.cloud.vm.VirtualMachine.PowerState;
256256
import com.cloud.vm.VmDetailConstants;
257257

258-
import com.google.gson.Gson;
259258
import com.google.gson.JsonArray;
260259
import com.google.gson.JsonElement;
261260
import com.google.gson.JsonObject;
@@ -439,7 +438,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
439438
private String setupTungstenVrouterPath;
440439
private String updateTungstenLoadbalancerStatsPath;
441440
private String updateTungstenLoadbalancerSslPath;
442-
private String host;
443441

444442
private String dcId;
445443
private String clusterId;
@@ -599,7 +597,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
599597

600598
private boolean isReconcileCommandsEnabled = false;
601599

602-
private static Gson gson = new Gson();
603600

604601
/**
605602
* Virsh command to set the memory balloon stats period.<br><br>
@@ -2747,7 +2744,6 @@ protected ExecutionResult prepareNetworkElementCommand(final IpAssocVpcCommand c
27472744
conn = getLibvirtUtilitiesHelper().getConnectionByVmName(routerName);
27482745
Pair<Map<String, Integer>, Integer> macAddressToNicNumPair = getMacAddressToNicNumPair(conn, routerName);
27492746
final Map<String, Integer> macAddressToNicNum = macAddressToNicNumPair.first();
2750-
Integer devNum = macAddressToNicNumPair.second();
27512747

27522748
final IpAddressTO[] ips = cmd.getIpAddresses();
27532749
for (final IpAddressTO ip : ips) {
@@ -5080,10 +5076,6 @@ public List<DiskDef> getDisks(final Connect conn, final String vmName) {
50805076
}
50815077
}
50825078

5083-
private String executeBashScript(final String script) {
5084-
return createScript(script).execute();
5085-
}
5086-
50875079
private Script createScript(final String script) {
50885080
final Script command = new Script("/bin/bash", timeout, LOGGER);
50895081
command.add("-c");
@@ -5606,7 +5598,6 @@ public boolean destroyNetworkRulesForNic(final Connect conn, final String vmName
56065598
}
56075599

56085600
final InterfaceDef intf = intfs.get(nic.getDeviceId());
5609-
final String brname = intf.getBrName();
56105601
final String vif = intf.getDevName();
56115602

56125603
final Script cmd = new Script(securityGroupPath, timeout, LOGGER);

‎plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public class LibvirtConnection {
3434
protected static Logger LOGGER = LogManager.getLogger(LibvirtConnection.class);
3535
static private Map<String, Connect> s_connections = new HashMap<String, Connect>();
3636

37-
static private Connect s_connection;
3837
static private String s_hypervisorURI;
3938
static private Thread libvirtEventThread;
4039

‎plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyToSecondaryStorageWrapper.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public Answer execute(CopyToSecondaryStorageCommand command, LibvirtComputingRes
4747
KVMStoragePoolManager storagePoolMgr = libvirtResource.getStoragePoolMgr();
4848
KVMStoragePool secondaryPool;
4949

50-
boolean success;
51-
5250
secondaryPool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl);
5351
String mountPoint = secondaryPool.getLocalPath();
5452

‎plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateDiskOnlyVMSnapshotCommandWrapper.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ protected Answer takeDiskOnlyVmSnapshotOfRunningVm(CreateDiskOnlyVmSnapshotComma
9696
try {
9797
LibvirtUtilitiesHelper libvirtUtilitiesHelper = resource.getLibvirtUtilitiesHelper();
9898
Connect conn = libvirtUtilitiesHelper.getConnection();
99-
List<VolumeObjectTO> volumeObjectTOS = cmd.getVolumeTOs();
10099
List<LibvirtVMDef.DiskDef> disks = resource.getDisks(conn, vmName);
101100

102101
dm = resource.getDomain(conn, vmName);
@@ -164,7 +163,6 @@ protected Answer takeDiskOnlyVmSnapshotOfStoppedVm(CreateDiskOnlyVmSnapshotComma
164163
Map<String, Long> mapVolumeToSnapshotSize = new HashMap<>();
165164
String nvramSnapshotPath = null;
166165

167-
List<VolumeObjectTO> volumeObjectTos = cmd.getVolumeTOs();
168166
KVMStoragePoolManager storagePoolMgr = resource.getStoragePoolMgr();
169167
try {
170168
nvramSnapshotPath = backupNvramIfNeeded(cmd, resource);

‎plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,13 +1082,6 @@ public static String maskSensitiveInfoInXML(String xmlDesc) {
10821082
"$1*****$3");
10831083
}
10841084

1085-
private boolean isClvmBlockDevice(MigrateCommand.MigrateDiskInfo diskInfo) {
1086-
if (diskInfo == null ||diskInfo.getDestPoolType() == null) {
1087-
return false;
1088-
}
1089-
return (Storage.StoragePoolType.CLVM.equals(diskInfo.getDestPoolType()) || Storage.StoragePoolType.CLVM_NG.equals(diskInfo.getDestPoolType()));
1090-
}
1091-
10921085
/**
10931086
* Determines if the driver type should be updated during migration based on CLVM involvement.
10941087
* The driver type needs to be updated when:

‎plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
8585
protected Logger logger = LogManager.getLogger(getClass());
8686
private StorageLayer _storageLayer;
8787
private String _mountPoint = "/mnt";
88-
private String _manageSnapshotPath;
8988
private static final ConcurrentHashMap<String, Integer> storagePoolRefCounts = new ConcurrentHashMap<>();
9089

9190
private String rbdTemplateSnapName = "cloudstack-base-snap";
@@ -106,7 +105,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
106105

107106
public LibvirtStorageAdaptor(StorageLayer storage) {
108107
_storageLayer = storage;
109-
_manageSnapshotPath = Script.findScript("scripts/storage/qcow2/", "managesnapshot.sh");
110108
}
111109

112110
@Override

0 commit comments

Comments
 (0)