# hv_checker_gui.py import sys import platform import subprocess from PySide6.QtWidgets import ( QApplication, QWidget, QVBoxLayout, QLabel, QPushButton, QMessageBox, QHBoxLayout ) from PySide6.QtGui import QIcon, QPixmap, QColor from PySide6.QtCore import Qt class MainWindow(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Hyper-V 환경 점검기") self.resize(400, 300) self.layout = QVBoxLayout(self) # 상태 항목 레이블들 self.lbl_win = QLabel("Windows 버전: 점검 대기 중") self.lbl_vtx = QLabel("가상화 지원/활성화: 점검 대기 중") self.lbl_hv = QLabel("Hyper-V 설치 여부: 점검 대기 중") for lbl in (self.lbl_win, self.lbl_vtx, self.lbl_hv): lbl.setAlignment(Qt.AlignLeft) lbl.setStyleSheet("font-size: 14px;") self.layout.addWidget(lbl) # 다시 점검 버튼 btn_check = QPushButton("다시 점검") btn_check.clicked.connect(self.run_checks) self.layout.addWidget(btn_check, alignment=Qt.AlignCenter) # 초기 점검 실행 self.run_checks() def run_checks(self): self.check_windows_version() self.check_virtualization() self.check_hyperv() def check_windows_version(self): """ Windows 버전이 10 이상인지 확인 """ ver = platform.version().split('.') major = int(ver[0]) if platform.system() == "Windows" and (major >= 10): self.set_ok(self.lbl_win, f"Windows {platform.release()} ({platform.version()}) — OK") else: self.set_fail( self.lbl_win, f"Windows {platform.release()} ({platform.version()}) — 지원되지 않음", "Windows 10 프로 이상에서만 Hyper-V가 지원됩니다.\n" "설정 → 시스템 → 정보에서 Windows 에디션을 확인하세요." ) def check_virtualization(self): """ systeminfo 명령어로 가상화 지원 및 활성화 여부 파싱 """ try: proc = subprocess.run( "systeminfo", capture_output=True, text=True, shell=True, timeout=10 ) out = proc.stdout # 필수 키워드들 ok1 = "VM Monitor Mode Extensions: Yes" in out ok2 = "Virtualization Enabled In Firmware: Yes" in out if ok1 and ok2: self.set_ok(self.lbl_vtx, "가상화 지원 및 활성화됨 — OK") else: msgs = [] if not ok1: msgs.append("CPU에서 VT-x/AMD-V 미지원") if not ok2: msgs.append("펌웨어에서 가상화 비활성화") self.set_fail( self.lbl_vtx, "가상화 미지원 또는 비활성화", "\n".join(msgs) + "\n\n" "BIOS/UEFI 설정에서 가상화(VT-x 또는 SVM)를 활성화하세요." ) except Exception as e: self.set_fail( self.lbl_vtx, "가상화 점검 오류", f"systeminfo 실행 중 오류 발생:\n{e}" ) def check_hyperv(self): """ PowerShell로 Hyper-V 기능 설치 여부 확인 """ try: cmd = [ "powershell", "-NoProfile", "-Command", "(Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All).State" ] result = subprocess.run(cmd, capture_output=True, text=True, timeout=10) state = result.stdout.strip() if state.lower() == "enabled": self.set_ok(self.lbl_hv, "Hyper-V 기능 설치됨 — OK") else: self.set_fail( self.lbl_hv, "Hyper-V 미설치", "관리자 권한 PowerShell에서 다음을 실행하세요:\n" "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All" ) except Exception as e: self.set_fail( self.lbl_hv, "Hyper-V 점검 오류", f"PowerShell 실행 중 오류 발생:\n{e}" ) def set_ok(self, label: QLabel, text: str): label.setText(text) label.setStyleSheet("color: green; font-weight: bold;") def set_fail(self, label: QLabel, text: str, detail: str): label.setText(text) label.setStyleSheet("color: red; font-weight: bold;") QMessageBox.warning(self, "요구사항 미충족", detail, QMessageBox.Ok) if __name__ == "__main__": app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec())