]> xenbits.xensource.com Git - libvirt.git/commitdiff
vboxDumpDisplay: add addDesktop bool
authorJán Tomko <jtomko@redhat.com>
Fri, 5 Feb 2016 14:44:19 +0000 (15:44 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 9 Feb 2016 09:08:00 +0000 (10:08 +0100)
When FRONTEND/Type is not any of "sdl", "gui", "vrdp", we add a DESKTOP.
Use a bool to track this, instead of checking that both
totalPresent ("sdl" or "gui" present) and vrdpPresent are zero.

src/vbox/vbox_common.c

index a7839de0e8ca37d5b73ca0130682bf8224ae8dda..5eadf84b3464f3f41d70ee5d239e4aca32b3aecc 100644 (file)
@@ -3300,7 +3300,6 @@ static void
 vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
 {
     /* dump display options vrdp/gui/sdl */
-    int vrdpPresent           = 0;
     int sdlPresent            = 0;
     int guiPresent            = 0;
     int totalPresent          = 0;
@@ -3311,6 +3310,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
     char      *valueTypeUtf8  = NULL;
     IVRDxServer *VRDxServer   = NULL;
     PRBool VRDxEnabled        = PR_FALSE;
+    bool addDesktop = false;
 
     def->ngraphics = 0;
 
@@ -3363,11 +3363,10 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
             totalPresent++;
         }
         VBOX_UTF8_FREE(valueDisplayUtf8);
+    } else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) {
+        addDesktop = true;
     }
 
-    if (STREQ_NULLABLE(valueTypeUtf8, "vrdp"))
-        vrdpPresent = 1;
-
     if ((totalPresent > 0) && (VIR_ALLOC_N(def->graphics, totalPresent) >= 0)) {
         if ((guiPresent) && (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0)) {
             def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
@@ -3382,7 +3381,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
                 def->graphics[def->ngraphics]->data.sdl.display = sdlDisplay;
             def->ngraphics++;
         }
-    } else if ((vrdpPresent != 1) && (totalPresent == 0) && (VIR_ALLOC_N(def->graphics, 1) >= 0)) {
+    } else if (addDesktop && (VIR_ALLOC_N(def->graphics, 1) >= 0)) {
         if (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0) {
             const char *tmp;
             def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;