Francesco Romani has uploaded a new change for review. Change subject: virt: move Vm._guestSockCleanup() into utils ......................................................................
virt: move Vm._guestSockCleanup() into utils The Vm._guestSockCleanup() is a static method, but could be trivally made a function to remove code duplication and noise from vm.py Change-Id: I9a3334a824b0d0e4edaedff1687bb6477bb4534d Signed-off-by: Francesco Romani <[email protected]> --- M vdsm/virt/utils.py M vdsm/virt/vm.py M vdsm/virt/vmdevices/core.py 3 files changed, 13 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/40750/1 diff --git a/vdsm/virt/utils.py b/vdsm/virt/utils.py index 60becfa..55a60c6 100644 --- a/vdsm/virt/utils.py +++ b/vdsm/virt/utils.py @@ -22,9 +22,10 @@ shared utilities and common code for the virt package """ +import os.path import threading -from vdsm.utils import monotonic_time +from vdsm.utils import monotonic_time, rmFile def isVdsmImage(drive): @@ -110,3 +111,9 @@ raise ItemExpired return value + + +def cleanup_guest_socket(sock): + if os.path.islink(sock): + rmFile(os.path.realpath(sock)) + rmFile(sock) diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index cb28861..3f4f1d7 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -71,7 +71,7 @@ from .vmtune import io_tune_values_to_dom, io_tune_dom_to_values from . import vmxml -from .utils import isVdsmImage +from .utils import isVdsmImage, cleanup_guest_socket from vmpowerdown import VmShutdown, VmReboot _VMCHANNEL_DEVICE_NAME = 'com.redhat.rhevm.vdsm' @@ -1192,7 +1192,7 @@ except Exception: pass - self._guestSockCleanup(self._guestSocketFile) + cleanup_guest_socket(self._guestSocketFile) def _reattachHostDevices(self): # reattach host devices @@ -1564,12 +1564,6 @@ return domxml.toxml() - @staticmethod - def _guestSockCleanup(sock): - if os.path.islink(sock): - utils.rmFile(os.path.realpath(sock)) - utils.rmFile(sock) - def _cleanup(self): """ General clean up routine @@ -1578,7 +1572,7 @@ self._cleanupFloppy() self._cleanupGuestAgent() utils.rmFile(self._recoveryFile) - self._guestSockCleanup(self._qemuguestSocketFile) + cleanup_guest_socket(self._qemuguestSocketFile) self._reattachHostDevices() self._cleanupStatsCache() for con in self._devices[hwclass.CONSOLE]: diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py index 82fb6b9..b6e89d4 100644 --- a/vdsm/virt/vmdevices/core.py +++ b/vdsm/virt/vmdevices/core.py @@ -18,14 +18,13 @@ # Refer to the README and COPYING files for full details of the license # -import os.path - from vdsm import constants from vdsm import utils import caps import supervdsm +from ..utils import cleanup_guest_socket from .. import vmxml @@ -100,9 +99,7 @@ "Failed to prepare the VM console channel") def cleanup(self): - if os.path.islink(self._path): - utils.rmFile(os.path.realpath(self._path)) - utils.rmFile(self._path) + cleanup_guest_socket(self._path) def getXML(self): """ -- To view, visit https://gerrit.ovirt.org/40750 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9a3334a824b0d0e4edaedff1687bb6477bb4534d Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
