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

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