Blame SOURCES/libvirt-cim-0.6.3-f70a8ea0.patch

9c78f5
From f70a8ea0305c82d14e47d08f2e130f8e11b0e9b3 Mon Sep 17 00:00:00 2001
9c78f5
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
9c78f5
Date: Mon, 7 Oct 2013 16:02:35 +0200
9c78f5
Subject: [PATCH 22/60] libxkutil: Simplify XML handling of consoles
9c78f5
9c78f5
The attempt to avoid duplication of console definitions was a bit
9c78f5
too complicated and error prone. We move the generation of console
9c78f5
XML entirely to the new console code.
9c78f5
Further, it's incorrect to restrict PTY consoles being represented
9c78f5
as GraphicsRASDs to virtio only. At least serial must be allowed,
9c78f5
but it doesn't really hurt to map all PTYs to GraphicsRASD consoles.
9c78f5
9c78f5
Further, the parsing code returned two instances for serial consoles,
9c78f5
one from the /domain/devices/console and /domain/devices/serial
9c78f5
both representing the same device. This confuses cimtest and,
9c78f5
more problematic, will prevent DefineSystem to work, if a reference
9c78f5
VSSD with a serial console is passed in.
9c78f5
9c78f5
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
9c78f5
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
9c78f5
Signed-off-by: John Ferlan <jferlan@redhat.com>
9c78f5
---
9c78f5
 libxkutil/device_parsing.c | 12 +-------
9c78f5
 libxkutil/xmlgen.c         | 76 ----------------------------------------------
9c78f5
 2 files changed, 1 insertion(+), 87 deletions(-)
9c78f5
9c78f5
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
9c78f5
index 55c8d57..aecca4c 100644
9c78f5
--- a/libxkutil/device_parsing.c
9c78f5
+++ b/libxkutil/device_parsing.c
9c78f5
@@ -47,7 +47,7 @@
9c78f5
  * still part of the graphics.
9c78f5
  */
9c78f5
 #define GRAPHICS_XPATH  (xmlChar *)"/domain/devices/graphics | "\
9c78f5
-        "/domain/devices/console | /domain/devices/serial"
9c78f5
+        "/domain/devices/console"
9c78f5
 #define INPUT_XPATH     (xmlChar *)"/domain/devices/input"
9c78f5
 
9c78f5
 #define DEFAULT_BRIDGE "xenbr0"
9c78f5
@@ -948,16 +948,6 @@ static int parse_graphics_device(xmlNode *node, struct virt_device **vdevs)
9c78f5
                         else if (XSTREQ(child->name, "target")) {
9c78f5
                                 gdev->dev.vnc.port =
9c78f5
                                         get_attr_value(child, "port");
9c78f5
-                                /* The graphics pty console can only be a
9c78f5
-                                   virtio console. If 'type' is not set in the
9c78f5
-                                   xml, the default of libvirt is virtio.*/
9c78f5
-                                char *t_type = get_attr_value(child, "type");
9c78f5
-                                if (t_type != NULL && !STREQC(t_type, "virtio")) {
9c78f5
-                                        CU_DEBUG("Not a pty-virtio graphics console");
9c78f5
-                                        free(t_type);
9c78f5
-                                        goto err;
9c78f5
-                                }
9c78f5
-                                free(t_type);
9c78f5
                         }
9c78f5
                 }
9c78f5
         }
9c78f5
diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c
9c78f5
index 45bfb04..7e8801d 100644
9c78f5
--- a/libxkutil/xmlgen.c
9c78f5
+++ b/libxkutil/xmlgen.c
9c78f5
@@ -42,36 +42,11 @@ typedef const char *(*devfn_t)(xmlNodePtr node, struct domain *dominfo);
9c78f5
 typedef const char *(*poolfn_t)(xmlNodePtr node, struct virt_pool *pool);
9c78f5
 typedef const char *(*resfn_t)(xmlNodePtr node, struct virt_pool_res *res);
9c78f5
 
9c78f5
-static int _count_graphics_console_definitions(struct domain *dominfo)
9c78f5
-{
9c78f5
-        int i;
9c78f5
-        int num = 0;
9c78f5
-
9c78f5
-        for (i = 0; i < dominfo->dev_graphics_ct; i++) {
9c78f5
-                struct virt_device *_dev = &dominfo->dev_graphics[i];
9c78f5
-                if (_dev->type == CIM_RES_TYPE_UNKNOWN)
9c78f5
-                        continue;
9c78f5
-
9c78f5
-                struct graphics_device *dev = &_dev->dev.graphics;
9c78f5
-
9c78f5
-                if (STREQC(dev->type, "console")) {
9c78f5
-                        num++;
9c78f5
-                }
9c78f5
-        }
9c78f5
-        CU_DEBUG("Found %d console defintions in graphics devices.",num);
9c78f5
-        return num;
9c78f5
-
9c78f5
-}
9c78f5
-
9c78f5
 static const char *console_xml(xmlNodePtr root, struct domain *dominfo)
9c78f5
 {
9c78f5
         int i;
9c78f5
         xmlNodePtr console;
9c78f5
         xmlNodePtr tmp;
9c78f5
-        int num_graphics_consol_def = 0;
9c78f5
-        int num_suppressed_console_def = 0;
9c78f5
-
9c78f5
-        num_graphics_consol_def = _count_graphics_console_definitions(dominfo);
9c78f5
 
9c78f5
         for (i = 0; i < dominfo->dev_console_ct; i++) {
9c78f5
                 struct virt_device *_dev = &dominfo->dev_console[i];
9c78f5
@@ -80,25 +55,6 @@ static const char *console_xml(xmlNodePtr root, struct domain *dominfo)
9c78f5
 
9c78f5
                 struct console_device *cdev = &_dev->dev.console;
9c78f5
 
9c78f5
-                /* Due to backward compatibility, the graphics device handling
9c78f5
-                   is still parsing consoles:
9c78f5
-                   source = pty, target = virtio (which is the default target)
9c78f5
-                   But the console device handling processes these kind of
9c78f5
-                   consoles too. This would lead to a duplication of these
9c78f5
-                   default consoles in the domain xml definition.
9c78f5
-                   This code prevents the console handling of writing xml for
9c78f5
-                   duplicate pty/virtio consoles which are written by the
9c78f5
-                   graphics device handling. */
9c78f5
-                if (cdev->source_type == CIM_CHARDEV_SOURCE_TYPE_PTY &&
9c78f5
-                    (cdev->target_type == NULL ||
9c78f5
-                     STREQC(cdev->target_type, "virtio"))) {
9c78f5
-                        if (num_suppressed_console_def <
9c78f5
-                            num_graphics_consol_def) {
9c78f5
-                                num_suppressed_console_def++;
9c78f5
-                                continue;
9c78f5
-                        }
9c78f5
-                }
9c78f5
-
9c78f5
                 console = xmlNewChild(root, NULL, BAD_CAST "console", NULL);
9c78f5
                 if (console == NULL)
9c78f5
                         return XML_ERROR;
9c78f5
@@ -760,35 +716,6 @@ static const char *graphics_vnc_xml(xmlNodePtr root,
9c78f5
         return NULL;
9c78f5
 }
9c78f5
 
9c78f5
-static const char *graphics_pty_xml(xmlNodePtr root,
9c78f5
-                       struct graphics_device *dev)
9c78f5
-{
9c78f5
-        xmlNodePtr pty = NULL;
9c78f5
-        xmlNodePtr tmp = NULL;
9c78f5
-
9c78f5
-        pty = xmlNewChild(root, NULL, BAD_CAST dev->type, NULL);
9c78f5
-        if (pty == NULL)
9c78f5
-                return XML_ERROR;
9c78f5
-
9c78f5
-        xmlNewProp(pty, BAD_CAST "type", BAD_CAST "pty");
9c78f5
-
9c78f5
-        tmp = xmlNewChild(pty, NULL, BAD_CAST "source", NULL);
9c78f5
-        if (tmp == NULL)
9c78f5
-                return XML_ERROR;
9c78f5
-
9c78f5
-        if(dev->dev.vnc.host)
9c78f5
-                xmlNewProp(tmp, BAD_CAST "path", BAD_CAST dev->dev.vnc.host);
9c78f5
-
9c78f5
-        tmp = xmlNewChild(pty, NULL, BAD_CAST "target", NULL);
9c78f5
-        if (tmp == NULL)
9c78f5
-                return XML_ERROR;
9c78f5
-
9c78f5
-        if(dev->dev.vnc.port)
9c78f5
-                xmlNewProp(tmp, BAD_CAST "port", BAD_CAST dev->dev.vnc.port);
9c78f5
-
9c78f5
-        return NULL;
9c78f5
-}
9c78f5
-
9c78f5
 static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo)
9c78f5
 {
9c78f5
         const char *msg = NULL;
9c78f5
@@ -803,9 +730,6 @@ static const char *graphics_xml(xmlNodePtr root, struct domain *dominfo)
9c78f5
 
9c78f5
                 if (STREQC(dev->type, "vnc") || STREQC(dev->type, "sdl"))
9c78f5
                         msg = graphics_vnc_xml(root, dev);
9c78f5
-                else if (STREQC(dev->type, "console") ||
9c78f5
-                        STREQC(dev->type, "serial"))
9c78f5
-                        msg = graphics_pty_xml(root, dev);
9c78f5
                 else
9c78f5
                         continue;
9c78f5
 
9c78f5
-- 
9c78f5
2.1.0
9c78f5