if (!this.hypervisorResource.isRefNull(vgm) && vgm.getPVDriversUpToDate(conn)) {
pvDrvInstalled = true;
}
if (isHVM && !pvDrvInstalled) {
s_logger.warn(": You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected");
return new DettachAnswer("You attempted an operation that requires PV drivers to be installed on the VM. Please install them by inserting xen-pv-drv.iso.");
}
// Look up all VBDs for this VDI
Set<VBD> vbds = vdi.getVBDs(conn);
// Detach each VBD from its VM, and then destroy it
for (VBD vbd : vbds) {
VBD.Record vbdr = vbd.getRecord(conn);
if (vbdr.currentlyAttached) {
vbd.unplug(conn);
}
vbd.destroy(conn);
}
// Update the VDI's label to be "detached"
vdi.setNameLabel(conn, "detached");
this.hypervisorResource.umount(conn, vdi);
if (cmd.isManaged()) {
this.hypervisorResource.handleSrAndVdiDetach(cmd.get_iScsiName());
}
return new DettachAnswer(disk);
} catch(Exception e) {
s_logger.warn("Failed dettach volume: " + data.getPath());
return new DettachAnswer("Failed dettach volume: " + data.getPath() + ", due to " + e.toString());
}
}