@@ -56,6 +56,18 @@ bool commandCanceled(const CommandRunner::Result &result) {
5656 return result.exitCode == -3 ;
5757}
5858
59+ QString missingNvidiaHardwareMessage () {
60+ NvidiaDetector detector;
61+ if (detector.hasNvidiaGpu () || detector.isDriverInstalled ()) {
62+ return {};
63+ }
64+
65+ return NvidiaUpdater::tr (
66+ " No NVIDIA GPU or installed NVIDIA driver was detected. In a virtual "
67+ " machine, attach or passthrough an NVIDIA GPU before starting driver "
68+ " updates." );
69+ }
70+
5971QString normalizedTransactionOutput (const CommandRunner::Result &result) {
6072 return (result.stdout + QLatin1Char (' \n ' ) + result.stderr ).toLower ();
6173}
@@ -468,7 +480,6 @@ QStringList
468480NvidiaUpdater::buildDriverTargets (const QString &version,
469481 const QString &sessionType,
470482 const QString &kernelPackageName) const {
471- Q_UNUSED (sessionType);
472483 QStringList targets;
473484 QStringList versionLockedPackages{kernelPackageName};
474485 versionLockedPackages << kCommonVersionLockedDriverPackages ;
@@ -513,98 +524,6 @@ QStringList NvidiaUpdater::buildTransactionArguments(
513524 return args;
514525}
515526
516- bool NvidiaUpdater::finalizeDriverChange (CommandRunner &runner,
517- const SessionUtil::SessionInfo
518- &sessionInfo,
519- QString *errorMessage) {
520- auto result =
521- runner.runAsRoot (QStringLiteral (" akmods" ), {QStringLiteral (" --force" )});
522- if (!result.success ()) {
523- if (errorMessage != nullptr ) {
524- *errorMessage = tr (" Kernel module build failed: " ) +
525- commandError (result, tr (" unknown error" ));
526- }
527- return false ;
528- }
529-
530- const QString sessionType = sessionInfo.type .trimmed ().toLower ();
531- if (sessionType != QStringLiteral (" wayland" ) &&
532- sessionType != QStringLiteral (" x11" )) {
533- if (errorMessage != nullptr ) {
534- *errorMessage =
535- tr (" The active display session could not be detected reliably. "
536- " ro-Control will not guess Wayland or X11 specific NVIDIA setup." );
537- }
538- return false ;
539- }
540-
541- emit progressMessage (
542- tr (" Detected %1 session via %2." )
543- .arg (sessionType == QStringLiteral (" wayland" ) ? tr (" Wayland" )
544- : tr (" X11" ),
545- sessionInfo.source .isEmpty () ? tr (" session probe" )
546- : sessionInfo.source ));
547-
548- emit progressMessage (
549- tr (" Adding NVIDIA kernel modules to the initramfs driver set..." ));
550- result = runner.runAsRoot (
551- QStringLiteral (" dracut" ),
552- QStringList{QStringLiteral (" --force" ), QStringLiteral (" --add-drivers" ),
553- kNvidiaKernelModules .join (QLatin1Char (' ' ))});
554- if (!result.success ()) {
555- if (errorMessage != nullptr ) {
556- *errorMessage = tr (" Failed to prepare NVIDIA kernel modules: " ) +
557- commandError (result, tr (" unknown error" ));
558- }
559- return false ;
560- }
561-
562- if (sessionType == QStringLiteral (" wayland" )) {
563- emit progressMessage (tr (" Wayland detected: installing EGL Wayland support "
564- " and enabling NVIDIA DRM modeset..." ));
565- result = runner.runAsRoot (
566- QStringLiteral (" dnf" ),
567- {QStringLiteral (" install" ), QStringLiteral (" -y" ),
568- QStringLiteral (" egl-wayland" )});
569- if (!result.success ()) {
570- if (errorMessage != nullptr ) {
571- *errorMessage =
572- tr (" Failed to install Wayland NVIDIA support packages: " ) +
573- commandError (result, tr (" unknown error" ));
574- }
575- return false ;
576- }
577-
578- result = runner.runAsRoot (QStringLiteral (" grubby" ),
579- {QStringLiteral (" --update-kernel=ALL" ),
580- QStringLiteral (" --args=nvidia-drm.modeset=1 "
581- " nvidia-drm.fbdev=1" )});
582- if (!result.success ()) {
583- if (errorMessage != nullptr ) {
584- *errorMessage = tr (" Failed to update the Wayland kernel parameter: " ) +
585- commandError (result, tr (" unknown error" ));
586- }
587- return false ;
588- }
589- return true ;
590- }
591-
592- emit progressMessage (tr (" X11 detected: checking NVIDIA Xorg packages..." ));
593- result = runner.runAsRoot (
594- QStringLiteral (" dnf" ),
595- {QStringLiteral (" install" ), QStringLiteral (" -y" ),
596- QStringLiteral (" xorg-x11-drv-nvidia" )});
597- if (!result.success ()) {
598- if (errorMessage != nullptr ) {
599- *errorMessage = tr (" Failed to install the X11 NVIDIA package: " ) +
600- commandError (result, tr (" unknown error" ));
601- }
602- return false ;
603- }
604-
605- return true ;
606- }
607-
608527void NvidiaUpdater::refreshAvailableVersions () {
609528 QPointer<NvidiaUpdater> guard (this );
610529 runAsyncTask ([guard]() {
@@ -674,6 +593,12 @@ void NvidiaUpdater::applyUpdate() { applyVersion(QString()); }
674593void NvidiaUpdater::applyVersion (const QString &version) {
675594 const QString trimmedVersion = version.trimmed ();
676595 const QStringList knownVersions = m_availableVersions;
596+ const QString hardwareMessage = missingNvidiaHardwareMessage ();
597+ if (!hardwareMessage.isEmpty ()) {
598+ emit updateFinished (false , hardwareMessage);
599+ return ;
600+ }
601+
677602 const QString architectureSupportMessage =
678603 CapabilityProbe::fedoraNvidiaDriverFlowSupportMessage ();
679604
0 commit comments