[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] domain_conf: Include the correct console alias



For some crazy backward compatibility, a console can by just an alias to
a serial device. This is detected in the XML formating function which
takes the values to format from corresponding serial device. Including
the device alias. This results in wrong alias being written into the XML
definition:

    <console type='pty' tty='/dev/pts/5'>
      ...
      <alias name='serial0'/>
    </console>

While holding the correct alias still in the memory, it doesn't matter.
However, it starts to matter as soon as libvirtd is restarted and the
(incorrect) alias is read from status file.
---
 src/conf/domain_conf.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 011de71..61de836 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16417,6 +16417,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             memcpy(&console, def->serials[n], sizeof(console));
             console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
             console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+            memcpy(&console.info, &def->consoles[n]->info, sizeof(console.info));
         } else {
             memcpy(&console, def->consoles[n], sizeof(console));
         }
@@ -16427,11 +16428,20 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         def->nconsoles == 0 &&
         def->nserials > 0) {
         virDomainChrDef console;
+        char *alias = NULL;
         memcpy(&console, def->serials[n], sizeof(console));
         console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
         console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-        if (virDomainChrDefFormat(buf, &console, flags) < 0)
+        if (console.info.alias) {
+            if (VIR_STRDUP(alias, "console0") < 0)
+                goto error;
+            console.info.alias = alias;
+        }
+        if (virDomainChrDefFormat(buf, &console, flags) < 0) {
+            VIR_FREE(alias);
             goto error;
+        }
+        VIR_FREE(alias);
     }
 
     for (n = 0; n < def->nchannels; n++)
-- 
1.8.1.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]