From 6cacb1191590223af6afab5c13acc3664b72e8e3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 29 Mar 2016 16:10:31 +0200 Subject: Feature: Show warning for 64bit VMs if no VT-x available --- src/command_line_options.cpp | 66 +++++++++++++++++++++++--------------------- src/globals.cpp | 2 ++ src/globals.h | 2 ++ src/i18n/de.ts | 12 ++++++++ src/i18n/pt.ts | 42 ++++++++++++++++++---------- src/main.cpp | 5 ++++ src/session.h | 4 +++ src/sessiontreemodel.cpp | 4 ++- src/vsession.cpp | 18 +++++++++++- src/vsession.h | 3 ++ 10 files changed, 111 insertions(+), 47 deletions(-) diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp index bd085fc..4f1b4f6 100644 --- a/src/command_line_options.cpp +++ b/src/command_line_options.cpp @@ -4,38 +4,39 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { // parse command line arguments (please sort by short option for easier handling) - static const struct option longOptions[] = { - {"base", required_argument, NULL, 'b'}, - {"path", required_argument, NULL, 'b'}, // Compatibility to v1.0 - {"config", required_argument, NULL, 'c'}, - {"debug", no_argument, NULL, 'D'}, - {"default", required_argument, NULL, 'd'}, - {"fullscreen", no_argument, NULL, 'F'}, - {"file", required_argument, NULL, 'f'}, - {"help", no_argument, NULL, 'h'}, - {"locations", required_argument, NULL, 'l'}, - {"pool", required_argument, NULL, 'P'}, - {"pvs", no_argument, NULL, 'p'}, - {"runscript", no_argument, NULL, 'S'}, - {"size", required_argument, NULL, 's'}, - {"tab", required_argument, NULL, 'T'}, - {"theme", required_argument, NULL, 't'}, - {"url", required_argument, NULL, 'u'}, - {"version", no_argument, NULL, 'v'}, - {"xpath", required_argument, NULL, 'x'}, - {"location-mode", required_argument, NULL, 'locm'}, - {"template-mode", required_argument, NULL, 'tmpm'}, - {0, 0, 0, 0} - }; + static const struct option longOptions[] = { + {"base", required_argument, NULL, 'b'}, + {"path", required_argument, NULL, 'b'}, // Compatibility to v1.0 + {"config", required_argument, NULL, 'c'}, + {"debug", no_argument, NULL, 'D'}, + {"default", required_argument, NULL, 'd'}, + {"fullscreen", no_argument, NULL, 'F'}, + {"file", required_argument, NULL, 'f'}, + {"help", no_argument, NULL, 'h'}, + {"locations", required_argument, NULL, 'l'}, + {"pool", required_argument, NULL, 'P'}, + {"pvs", no_argument, NULL, 'p'}, + {"runscript", no_argument, NULL, 'S'}, + {"size", required_argument, NULL, 's'}, + {"tab", required_argument, NULL, 'T'}, + {"theme", required_argument, NULL, 't'}, + {"url", required_argument, NULL, 'u'}, + {"version", no_argument, NULL, 'v'}, + {"xpath", required_argument, NULL, 'x'}, + {"location-mode", required_argument, NULL, 'locm'}, + {"template-mode", required_argument, NULL, 'tmpm'}, + {"no-vtx", no_argument, NULL, 'nvtx'}, + {0, 0, 0, 0} + }; - int c; + int c; - // Again, please sort alphabetically in getopt_long call and switch statement + // Again, please sort alphabetically in getopt_long call and switch statement while ((c = getopt_long(argc, argv, "b:c:Dd:Ff:hl:P:pSs:t:T:u:vx:?", longOptions, NULL)) != -1) { switch (c) { case 'b': - options.insert("base", optarg); - break; + options.insert("base", optarg); + break; case 'c': options.insert("config", optarg); break; @@ -65,8 +66,8 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { options.insert("pool", optarg); break; case 'S': - options.insert("runscript", optarg); - break; + options.insert("runscript", optarg); + break; case 's': options.insert("size", optarg); break; @@ -77,8 +78,8 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { options.insert("tab", optarg); break; case 'u': - options.insert("url", optarg); - break; + options.insert("url", optarg); + break; case 'v': options.insert("version", "version"); break; @@ -91,6 +92,9 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { case 'tmpm': options.insert("template-mode", optarg); break; + case 'nvtx': + options.insert("no-vtx", "no-vtx"); + break; default: options.insert("error", "error"); break; diff --git a/src/globals.cpp b/src/globals.cpp index 3262089..6ff2e25 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -37,6 +37,8 @@ bool _fullscreen = false; int g_templateHandling = TEMPLATES_IGNORE; int g_forLocationHandling = LOCATION_BUMP; +bool g_noVtx = false; + bool myLessThan(Session* a, Session* b) { return *a < *b; } diff --git a/src/globals.h b/src/globals.h index 60f3d31..a3b1e99 100644 --- a/src/globals.h +++ b/src/globals.h @@ -62,6 +62,8 @@ extern int g_templateHandling; #define LOCATION_EXCLUSIVE (2) extern int g_forLocationHandling; +extern bool g_noVtx; + bool myLessThan(Session* a, Session* b); #endif diff --git a/src/i18n/de.ts b/src/i18n/de.ts index cccd582..359142d 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -44,6 +44,7 @@ -h, --help print usage information and exit -S, --runscript change path to run-virt.sh -T --tab default tab (0=xsession, 1=my vms, 2=all vms) + --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests) FILE can be a vmware .xml or an X .desktop file @@ -185,4 +186,15 @@ p, li { white-space: pre-wrap; } Native X-Sessions + + QObject + + Warning + Warnung + + + The selected session is based on a 64 bit operating system, but this computer doesn't seem to support this (VT-x/AMD-V not supported by CPU, or disabled in BIOS). You will probably get an error message while the virtualizer is initializing. + Die gewählte Veranstaltung basiert auf einer 64 Bit VM, jedoch scheint dieser Computer keine 64-Bit-Virtualisierung zu unterstützen (VT-x/AMD-V nicht unterstützt oder im BIOS deaktiviert). Beim Starten der VM wird wahrscheinlich ein Fehler auftreten. + + diff --git a/src/i18n/pt.ts b/src/i18n/pt.ts index f15beb2..efb7a4e 100755 --- a/src/i18n/pt.ts +++ b/src/i18n/pt.ts @@ -25,33 +25,34 @@ -h, --help print usage information and exit -S, --runscript change path to run-virt.sh -T --tab default tab (0=xsession, 1=my vms, 2=all vms) + --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests) FILE can be a vmware .xml or an X .desktop file - + vmchooser: failed to run session vmchooser: falhou ao executar a sessão - + vmchooser: invalid session file vmchooser: arquivo de sessão inválido - + vmchooser: no URL given - + vmchooser: invalid URL - + vmchooser: invalid size argument @@ -60,7 +61,7 @@ FILE can be a vmware .xml or an X .desktop file Dialog - + vmchooser seletor @@ -184,44 +185,57 @@ p, li { white-space: pre-wrap; } - + Native Linux - + Could not get news. - + Could not get help. - + Vmchooser failed to run the selected session! O seletor da VM falhou ao executar a sessão selecionada! - + Working environments for this room - + Templates - + Working environments - + X-Sessions + + QObject + + + Warning + + + + + The selected session is based on a 64 bit operating system, but this computer doesn't seem to support this (VT-x/AMD-V not supported by CPU, or disabled in BIOS). You will probably get an error message while the virtualizer is initializing. + + + diff --git a/src/main.cpp b/src/main.cpp index 2c1a17b..7dfdfc7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,6 +50,7 @@ int main(int argc, char *argv[]) { " -h, --help print usage information and exit\n" " -S, --runscript change path to run-virt.sh\n" " -T --tab default tab (0=xsession, 1=my vms, 2=all vms)\n" + " --no-vtx Host doesn't support VT-x/AMD-V (mark 64bit guests)\n" "\nFILE can be a vmware .xml or an X .desktop file\n").toUtf8().data()); if (cmdOptions.contains("error")) { @@ -241,6 +242,10 @@ int main(int argc, char *argv[]) { locationIds = cmdOptions.value("locations"); } + if (cmdOptions.contains("no-vtx")) { + g_noVtx = true; + } + /* read session files */ QList xsessions(XSession::readSessions(xSessionPath)); diff --git a/src/session.h b/src/session.h index 4a9699f..c490d88 100644 --- a/src/session.h +++ b/src/session.h @@ -1,6 +1,8 @@ #ifndef VMCHOOSER_SESSION_H_ #define VMCHOOSER_SESSION_H_ +#include + class QString; class QIcon; @@ -27,6 +29,8 @@ class Session { virtual QString execCommand() const = 0; virtual int type() const = 0; virtual SectionType section() const = 0; + virtual bool is64Bit() const { return false; } + virtual QVariant backgroundRole() const { return QVariant(); } virtual bool operator<(const Session& s) const = 0; diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp index d77555f..08b43e4 100644 --- a/src/sessiontreemodel.cpp +++ b/src/sessiontreemodel.cpp @@ -53,9 +53,11 @@ QVariant SessionTreeModel::data(const QModelIndex &index, int role) const { return s->shortDescription(); if (role == Qt::ToolTipRole) return s->description(); + if (role == Qt::BackgroundRole) + return s->backgroundRole(); if (role == Qt::DecorationRole) { if (index.column() == 0) { // TODO: is this line needed? - return s->icon(); + return s->icon(); } } } else if (role == Qt::DisplayRole) { diff --git a/src/vsession.cpp b/src/vsession.cpp index f0038aa..3720bb7 100644 --- a/src/vsession.cpp +++ b/src/vsession.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #if 0 #include // available since Qt 4.7 #endif @@ -165,7 +166,7 @@ bool VSession::isActive() const { QString value(getAttribute("active")); if (value.compare("false") == 0) { - if (debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: active == false"; + if (debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: active == false"; return false; } else if (value.count("/") == 1) { // try to interpret value as date range @@ -312,6 +313,10 @@ bool VSession::run() const { qDebug() << "Sarting session " << this->getAttribute("short_description", "param") << " ..."; } + if (g_noVtx && is64Bit()) { + QMessageBox::warning(NULL, QObject::trUtf8("Warning"), QObject::trUtf8("The selected session is based on a 64 bit operating system, but this computer doesn't seem to support this (VT-x/AMD-V not supported by CPU, or disabled in BIOS). You will probably get an error message while the virtualizer is initializing.")); + } + QString command = getAttribute("command"); if (!command.isEmpty()) { return QProcess::startDetached(command); @@ -420,6 +425,17 @@ QList VSession::readXmlFile(const QString& filepath) { return retval; } +bool VSession::is64Bit() const { + return imgtype() == VMWARE && getAttribute("os").endsWith("64"); + // TODO: vmbox, qemu-kvm, ... +} + +QVariant VSession::backgroundRole() const { + if (!g_noVtx || !is64Bit()) + return Session::backgroundRole(); + return QColor(200, 200, 200); +} + bool VSession::operator<(const Session& other) const { int p0 = this->priority(); int p1 = other.priority(); diff --git a/src/vsession.h b/src/vsession.h index 0fbb0b5..820b411 100644 --- a/src/vsession.h +++ b/src/vsession.h @@ -59,6 +59,9 @@ class VSession : public Session { return SECTION_GENERIC; } + bool is64Bit() const; + QVariant backgroundRole() const; + QString getAttribute(const QString& nodeName, const QString& attribute = "param") const; QList keywords() const; -- cgit v1.2.3-55-g7522