summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-03-29 16:10:31 +0200
committerSimon Rettberg2016-03-29 16:10:31 +0200
commit6cacb1191590223af6afab5c13acc3664b72e8e3 (patch)
tree94f3e2b29cc645d27716117ec14b965c82c7d311
parentdur dur... (diff)
downloadvmchooser2-6cacb1191590223af6afab5c13acc3664b72e8e3.tar.gz
vmchooser2-6cacb1191590223af6afab5c13acc3664b72e8e3.tar.xz
vmchooser2-6cacb1191590223af6afab5c13acc3664b72e8e3.zip
Feature: Show warning for 64bit VMs if no VT-x available
-rw-r--r--src/command_line_options.cpp66
-rw-r--r--src/globals.cpp2
-rw-r--r--src/globals.h2
-rw-r--r--src/i18n/de.ts12
-rwxr-xr-xsrc/i18n/pt.ts42
-rw-r--r--src/main.cpp5
-rw-r--r--src/session.h4
-rw-r--r--src/sessiontreemodel.cpp4
-rw-r--r--src/vsession.cpp18
-rw-r--r--src/vsession.h3
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&apos;t support VT-x/AMD-V (mark 64bit guests)
FILE can be a vmware .xml or an X .desktop file
</source>
@@ -185,4 +186,15 @@ p, li { white-space: pre-wrap; }
<translation>Native X-Sessions</translation>
</message>
</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <source>Warning</source>
+ <translation type="unfinished">Warnung</translation>
+ </message>
+ <message>
+ <source>The selected session is based on a 64 bit operating system, but this computer doesn&apos;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.</source>
+ <translation type="unfinished">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.</translation>
+ </message>
+</context>
</TS>
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&apos;t support VT-x/AMD-V (mark 64bit guests)
FILE can be a vmware .xml or an X .desktop file
</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../main.cpp" line="79"/>
+ <location filename="../main.cpp" line="80"/>
<source>vmchooser: failed to run session</source>
<translation>vmchooser: falhou ao executar a sessão</translation>
</message>
<message>
- <location filename="../main.cpp" line="85"/>
+ <location filename="../main.cpp" line="86"/>
<source>vmchooser: invalid session file</source>
<translation>vmchooser: arquivo de sessão inválido</translation>
</message>
<message>
- <location filename="../main.cpp" line="129"/>
+ <location filename="../main.cpp" line="130"/>
<source>vmchooser: no URL given</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../main.cpp" line="144"/>
+ <location filename="../main.cpp" line="145"/>
<source>vmchooser: invalid URL</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../main.cpp" line="173"/>
+ <location filename="../main.cpp" line="174"/>
<source>vmchooser: invalid size argument</source>
<translation type="unfinished"></translation>
</message>
@@ -60,7 +61,7 @@ FILE can be a vmware .xml or an X .desktop file
<name>Dialog</name>
<message>
<location filename="../ui/dialog.ui" line="14"/>
- <location filename="../dialog.cpp" line="149"/>
+ <location filename="../dialog.cpp" line="156"/>
<source>vmchooser</source>
<translation>seletor</translation>
</message>
@@ -184,44 +185,57 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../dialog.cpp" line="412"/>
+ <location filename="../dialog.cpp" line="420"/>
<source>Native Linux</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../dialog.cpp" line="545"/>
+ <location filename="../dialog.cpp" line="553"/>
<source>Could not get news.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../dialog.cpp" line="610"/>
+ <location filename="../dialog.cpp" line="618"/>
<source>Could not get help.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../dialog.cpp" line="150"/>
+ <location filename="../dialog.cpp" line="157"/>
<source>Vmchooser failed to run the selected session!</source>
<translation>O seletor da VM falhou ao executar a sessão selecionada!</translation>
</message>
<message>
- <location filename="../sessiontreeitem.cpp" line="6"/>
+ <location filename="../sessiontreeitem.cpp" line="7"/>
<source>Working environments for this room</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../sessiontreeitem.cpp" line="8"/>
+ <location filename="../sessiontreeitem.cpp" line="9"/>
<source>Templates</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../sessiontreeitem.cpp" line="10"/>
+ <location filename="../sessiontreeitem.cpp" line="11"/>
<source>Working environments</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../sessiontreeitem.cpp" line="12"/>
+ <location filename="../sessiontreeitem.cpp" line="13"/>
<source>X-Sessions</source>
<translation type="unfinished"></translation>
</message>
</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../vsession.cpp" line="317"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../vsession.cpp" line="317"/>
+ <source>The selected session is based on a 64 bit operating system, but this computer doesn&apos;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.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
</TS>
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<Session*> 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 <QVariant>
+
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 <QThread>
#include <QStringList>
#include <QIcon>
+#include <QMessageBox>
#if 0
#include <QHostInfo> // 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<Session*> 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<QString> keywords() const;