]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuProcessStartValidateGraphics: Move RDP validation logic to qemu_validate.c
authorPeter Krempa <pkrempa@redhat.com>
Mon, 26 May 2025 10:20:00 +0000 (12:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2025 11:11:02 +0000 (13:11 +0200)
Move the rest of the RDP graphics validation code to
qemuValidateDomainDeviceDefRDPGraphics together with the rest of the
validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_process.c
src/qemu/qemu_validate.c

index 920adef7df747c3136615495f679f8b83861a0f9..82cab3f76eec32672c3abf1bed9ce9dc4c096b21 100644 (file)
@@ -5509,57 +5509,6 @@ qemuProcessMakeDir(virQEMUDriver *driver,
 }
 
 
-static bool
-virDomainDefHasDBus(const virDomainDef *def, bool p2p)
-{
-    size_t i = 0;
-
-    for (i = 0; i < def->ngraphics; i++) {
-        virDomainGraphicsDef *graphics = def->graphics[i];
-
-        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_DBUS) {
-            return graphics->data.dbus.p2p == p2p;
-        }
-    }
-
-    return false;
-}
-
-
-static int
-qemuProcessStartValidateGraphics(virDomainObj *vm)
-{
-    size_t i;
-
-    for (i = 0; i < vm->def->ngraphics; i++) {
-        virDomainGraphicsDef *graphics = vm->def->graphics[i];
-
-        switch (graphics->type) {
-        case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
-        case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
-            break;
-
-        case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
-            if (!virDomainDefHasDBus(vm->def, false)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("qemu-rdp support requires a D-Bus bus graphics device."));
-                return -1;
-            }
-            break;
-
-        case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
-        case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
-        case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
-        case VIR_DOMAIN_GRAPHICS_TYPE_DBUS:
-        case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
-            break;
-        }
-    }
-
-    return 0;
-}
-
-
 /* 250 parts per million (ppm) is a half of NTP threshold */
 #define TSC_TOLERANCE 250
 
@@ -5664,9 +5613,6 @@ qemuProcessStartValidate(virQEMUDriver *driver,
     if (virDomainDefValidate(vm->def, 0, driver->xmlopt, qemuCaps) < 0)
         return -1;
 
-    if (qemuProcessStartValidateGraphics(vm) < 0)
-        return -1;
-
     if (vm->def->cpu) {
         if (virCPUValidateFeatures(vm->def->os.arch, vm->def->cpu) < 0)
             return -1;
index 1aa54bf59fe9b4d0e760362cf3ae929ba2a133cf..de391ce34df8c642cd93299912dbec78801cc4f0 100644 (file)
@@ -4522,8 +4522,11 @@ qemuValidateDomainDeviceDefDBusGraphics(const virDomainGraphicsDef *graphics,
 
 
 static int
-qemuValidateDomainDeviceDefRDPGraphics(const virDomainGraphicsDef *graphics)
+qemuValidateDomainDeviceDefRDPGraphics(const virDomainGraphicsDef *graphics,
+                                       const virDomainDef *def)
 {
+    size_t i;
+
     if (graphics->nListens > 1) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("qemu-rdp does not support multiple listens for one graphics device."));
@@ -4546,6 +4549,19 @@ qemuValidateDomainDeviceDefRDPGraphics(const virDomainGraphicsDef *graphics)
         return -1;
     }
 
+    for (i = 0; i < def->ngraphics; i++) {
+        virDomainGraphicsDef *g = def->graphics[i];
+
+        if (g->type == VIR_DOMAIN_GRAPHICS_TYPE_DBUS && g->data.dbus.p2p == false)
+            break;
+    }
+
+    if (i == def->ngraphics) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("qemu-rdp support requires a D-Bus bus graphics device."));
+        return -1;
+    }
+
     return 0;
 }
 
@@ -4623,7 +4639,7 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
-        if (qemuValidateDomainDeviceDefRDPGraphics(graphics) < 0)
+        if (qemuValidateDomainDeviceDefRDPGraphics(graphics, def) < 0)
             return -1;
 
         break;